Contact cannot be a null ptr, and it is accessed before anyway. Disscussed with kedge.
[kdenetwork.git] / kppp / pwentry.cpp
blob168459baa4f28cb736a854ad05642540e400a052
1 /*
3 * Kppp: A pppd front end for the KDE project
5 * $Id$
6 *
7 * Copyright (C) 1997 Bernd Johannes Wuebben
8 * wuebben@math.cornell.edu
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public
22 * License along with this program; if not, write to the Free
23 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 #include <stdio.h>
29 #include <qapplication.h>
30 //Added by qt3to4:
31 #include <QFocusEvent>
32 #include <QResizeEvent>
33 #include <kglobalsettings.h>
34 #include "pwentry.h"
36 #ifdef __GNUC__
37 #warning A null parent is a weird choice. Any reason?
38 #endif
39 PWEntry::PWEntry( QWidget *parent, const char *name )
40 : QWidget(NULL) {
41 setObjectName(name);
43 if(parent){
45 QPoint point = mapToGlobal (QPoint (0,0));
46 QRect pos = geometry();
48 setGeometry(point.x() + pos.width()/2 - 300/2,
49 point.y() + pos.height()/2 - 90/2,
50 300,
51 90);
52 } else {
53 QRect desk = KGlobalSettings::desktopGeometry(parent);
54 setGeometry( desk.center().x() - 150, desk.center().y() - 50, 300, 90 );
57 frame = new Q3GroupBox(name, this );
59 setFocusPolicy( Qt::StrongFocus );
61 pw = new QLineEdit( this );
62 pw->setObjectName( "le" );
63 pw->setEchoMode( QLineEdit::Password );
64 connect( pw, SIGNAL(returnPressed()), this, SLOT(hide()) );
66 isconsumed = true;
69 QString PWEntry::text() { return (pw->text()); }
71 void PWEntry::focusInEvent( QFocusEvent *){
73 pw->setFocus();
77 void PWEntry::setEchoModeNormal() {
79 pw->setEchoMode(QLineEdit::Normal);
83 void PWEntry::setEchoModePassword() {
85 pw->setEchoMode(QLineEdit::Password);
89 void PWEntry::setPrompt(const QString &p) {
91 frame->setTitle(p);
95 void PWEntry::resizeEvent(QResizeEvent* ){
97 pw->setGeometry( 15,35, width() - 30, 25 );
98 frame->setGeometry(5,5, width() - 10, height() - 10 );
103 void PWEntry::show() {
105 pw->setText("");
106 isconsumed = false;
107 QWidget::show();
110 bool PWEntry::Consumed() {
111 return(isconsumed);
114 void PWEntry::setConsumed() {
115 isconsumed = true;
118 void PWEntry::hide() {
119 QWidget::hide();
120 return;
123 #include "pwentry.moc"