-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
ku_pwdlg.cpp
100 lines (84 loc) · 2.68 KB
/
ku_pwdlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Copyright (c) 1998 Denis Perchine <[email protected]>
* Copyright (c) 2004 Szombathelyi György <[email protected]>
* Former maintainer: Adriaan de Groot <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
**/
#include "ku_pwdlg.h"
#include <QLabel>
#include <QGridLayout>
#include <kmessagebox.h>
#include <klocale.h>
KU_PwDlg::KU_PwDlg( QWidget* parent )
: KDialog(parent)
{
setCaption(i18n("Enter Password"));
setButtons(Ok | Cancel);
setDefaultButton(Ok);
QFrame *page = new QFrame( this );
setMainWidget( page );
QLabel* lb1 = new QLabel(page);
lb1->setText(i18n("Password:"));
lb1->setMinimumSize(lb1->sizeHint());
lb1->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
lepw1 = new KLineEdit(page);
// ensure it fits at least 12 characters
lepw1->setText( QLatin1String( "XXXXXXXXXXXX" ) );
lepw1->setMinimumSize(lepw1->sizeHint());
// clear text
lepw1->clear();
lepw1->setFocus();
lepw1->setEchoMode(KLineEdit::Password);
QLabel* lb2 = new QLabel(page);
lb2->setText(i18n("Verify:"));
lb2->setMinimumSize(lb2->sizeHint());
lb2->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
lepw2 = new KLineEdit(page);
// ensure it fits at least 12 characters
lepw2->setText( QLatin1String( "XXXXXXXXXXXX" ) );
lepw2->setMinimumSize(lepw2->sizeHint());
// clear text
lepw2->clear();
lepw2->setEchoMode(KLineEdit::Password);
QGridLayout *layout = new QGridLayout;
layout->addWidget(lb1, 0, 0);
layout->addWidget(lepw1, 0, 1);
layout->addWidget(lb2, 1, 0);
layout->addWidget(lepw2, 1, 1);
page->setLayout(layout);
}
KU_PwDlg::~KU_PwDlg()
{
delete lepw1;
delete lepw2;
}
void KU_PwDlg::accept()
{
if ( lepw1->text() != lepw2->text() ) {
KMessageBox::sorry( 0, i18n("Passwords are not identical.\nTry again.") );
lepw1->clear();
lepw2->clear();
lepw1->setFocus();
} else {
KDialog::accept();
}
}
QString KU_PwDlg::getPassword() const
{
return lepw1->text();
}
#include "ku_pwdlg.moc"