-
Notifications
You must be signed in to change notification settings - Fork 0
/
changepassworddialog.cpp
executable file
·62 lines (49 loc) · 1.88 KB
/
changepassworddialog.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
/*
* This file is part of community judge client project developed by Shervin Kh.
* Copyright (C) 2014 Shervin Kh.
* License: GPLv3 Or Later
* Full license could be found in License file shipped with program or at http://www.gnu.org/licenses/
*/
#include "changepassworddialog.h"
#include <QtGui>
#if QT_VERSION >= 0x050000
#include <QtWidgets>
#endif
ChangePasswordDialog::ChangePasswordDialog(QWidget *parent) :
QDialog(parent)
{
passLabel = new QLabel("Password:");
passLE = new QLineEdit;
passLabel->setBuddy(passLE);
passLE->setMaxLength(64);
passLE->setEchoMode(QLineEdit::Password);
passConfirmLabel = new QLabel("Confirm Password:");
passConfirmLE = new QLineEdit;
passConfirmLabel->setBuddy(passConfirmLE);
passConfirmLE->setMaxLength(64);
passConfirmLE->setEchoMode(QLineEdit::Password);
grid = new QGridLayout;
grid->addWidget(passLabel, 0, 0);
grid->addWidget(passLE, 0, 1);
grid->addWidget(passConfirmLabel, 1, 0);
grid->addWidget(passConfirmLE, 1, 1);
buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
totalLayout = new QVBoxLayout;
totalLayout->addLayout(grid);
totalLayout->addWidget(buttons);
setLayout(totalLayout);
connect(passLE, SIGNAL(textChanged(QString)), this, SLOT(validateForm()));
connect(passConfirmLE, SIGNAL(textChanged(QString)), this, SLOT(validateForm()));
validateForm();
}
void ChangePasswordDialog::validateForm()
{
buttons->button(QDialogButtonBox::Ok)->setEnabled(!passLE->text().isEmpty() && !passConfirmLE->text().isEmpty()
&& passLE->text() == passConfirmLE->text());
}
QString ChangePasswordDialog::password() const
{
return passLE->text();
}