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
|
#include <qmessagebox.h>
#include <qpushbutton.h>
#include <qlineedit.h>
#include <qlabel.h>
#include "passdiag.h"
PassDiag::PassDiag(QString text, QWidget *parent, const char *name, bool modal, WFlags fl)
: PassDiagBase(parent, name, modal, fl)
{
infoLabel->setText(text);
connect(ok, SIGNAL(clicked()), SLOT(accept()));
connect(cancel, SIGNAL(clicked()), SLOT(close()));
}
void PassDiag::accept()
{
if (password->text().isEmpty()) {
QMessageBox::information(this, tr("Error"), tr("<p>You have to enter a password or click on cancel.</p>"), tr("Ok"));
return;
}
QDialog::accept();
}
QString PassDiag::getPassword(QWidget *parent, QString text)
{
PassDiag *diag = new PassDiag(text, parent, 0, true);
diag->show();
if (QDialog::Accepted == diag->exec()) {
return diag->password->text();
}
return 0;
}
|