1/*
2 *
3 * Kppp: A pppd front end for the KDE project
4 *
5 * $Id$
6 *
7 * Copyright (C) 1997 Bernd Johannes Wuebben
8 * wuebben@math.cornell.edu
9 *
10 *
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.
15 *
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.
20 *
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.
24 */
25
26
27
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"
35
36#ifdef __GNUC__
37#warning A null parent is a weird choice. Any reason?
38#endif
39PWEntry::PWEntry( QWidget *parent, const char *name )
40 : QWidget(NULL) {
41 setObjectName(name);
42
43 if(parent){
44
45 QPoint point = mapToGlobal (QPoint (0,0));
46 QRect pos = geometry();
47
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 );
55 }
56
57 frame = new Q3GroupBox(name, this );
58
59 setFocusPolicy( Qt::StrongFocus );
60
61 pw = new QLineEdit( this );
62 pw->setObjectName( "le" );
63 pw->setEchoMode( QLineEdit::Password );
64 connect( pw, SIGNAL(returnPressed()), this, SLOT(hide()) );
65
66 isconsumed = true;
67}
68
69QString PWEntry::text() { return (pw->text()); }
70
71void PWEntry::focusInEvent( QFocusEvent *){
72
73 pw->setFocus();
74
75}
76
77void PWEntry::setEchoModeNormal() {
78
79 pw->setEchoMode(QLineEdit::Normal);
80
81}
82
83void PWEntry::setEchoModePassword() {
84
85 pw->setEchoMode(QLineEdit::Password);
86
87}
88
89void PWEntry::setPrompt(const QString &p) {
90
91 frame->setTitle(p);
92
93}
94
95void PWEntry::resizeEvent(QResizeEvent* ){
96
97 pw->setGeometry( 15,35, width() - 30, 25 );
98 frame->setGeometry(5,5, width() - 10, height() - 10 );
99
100}
101
102
103void PWEntry::show() {
104
105 pw->setText("");
106 isconsumed = false;
107 QWidget::show();
108}
109
110bool PWEntry::Consumed() {
111 return(isconsumed);
112}
113
114void PWEntry::setConsumed() {
115 isconsumed = true;
116}
117
118void PWEntry::hide() {
119 QWidget::hide();
120 return;
121}
122
123#include "pwentry.moc"
124