Proof-reading - fixed one usage of the i18n plural form (it wasn't doing before,...
[kdeadmin.git] / kuser / ku_pwdlg.cpp
blob348e6ef8cdbaf128cce3faea73272ebed2cd378a
1 /*
2 * Copyright (c) 1998 Denis Perchine <dyp@perchine.com>
3 * Copyright (c) 2004 Szombathelyi György <gyurco@freemail.hu>
4 * Former maintainer: Adriaan de Groot <groot@kde.org>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 **/
22 #include "ku_pwdlg.h"
24 #include <QLabel>
25 #include <QGridLayout>
27 #include <kmessagebox.h>
28 #include <klocale.h>
30 KU_PwDlg::KU_PwDlg( QWidget* parent )
31 : KDialog(parent)
33 setCaption(i18n("Enter Password"));
34 setButtons(Ok | Cancel);
35 setDefaultButton(Ok);
36 QFrame *page = new QFrame( this );
37 setMainWidget( page );
38 QLabel* lb1 = new QLabel(page);
39 lb1->setText(i18n("Password:"));
40 lb1->setMinimumSize(lb1->sizeHint());
41 lb1->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
43 lepw1 = new KLineEdit(page);
45 // ensure it fits at least 12 characters
46 lepw1->setText( "XXXXXXXXXXXX" );
47 lepw1->setMinimumSize(lepw1->sizeHint());
49 // clear text
50 lepw1->clear();
51 lepw1->setFocus();
52 lepw1->setEchoMode(KLineEdit::Password);
54 QLabel* lb2 = new QLabel(page);
55 lb2->setText(i18n("Verify:"));
56 lb2->setMinimumSize(lb2->sizeHint());
57 lb2->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
59 lepw2 = new KLineEdit(page);
61 // ensure it fits at least 12 characters
62 lepw2->setText( "XXXXXXXXXXXX" );
63 lepw2->setMinimumSize(lepw2->sizeHint());
65 // clear text
66 lepw2->clear();
67 lepw2->setEchoMode(KLineEdit::Password);
69 QGridLayout *layout = new QGridLayout;
70 layout->addWidget(lb1, 0, 0);
71 layout->addWidget(lepw1, 0, 1);
72 layout->addWidget(lb2, 1, 0);
73 layout->addWidget(lepw2, 1, 1);
74 page->setLayout(layout);
77 KU_PwDlg::~KU_PwDlg()
79 delete lepw1;
80 delete lepw2;
83 void KU_PwDlg::accept()
85 if ( lepw1->text() != lepw2->text() ) {
86 KMessageBox::sorry( 0, i18n("Passwords are not identical.\nTry again.") );
87 lepw1->clear();
88 lepw2->clear();
89 lepw1->setFocus();
90 } else {
91 KDialog::accept();
95 QString KU_PwDlg::getPassword() const
97 return lepw1->text();
100 #include "ku_pwdlg.moc"