-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrivernumberdialog.cpp
74 lines (62 loc) · 2.38 KB
/
drivernumberdialog.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
#include "drivernumberdialog.h"
#include <QDebug>
DriverNumberDialog::DriverNumberDialog(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
//QValidator *validator = new QIntValidator(0, 500, this);
//ui.driverNumberLineEdit->setValidator(validator); //add a int validator min value 0 max value 500. This will force the numpad to show, you can also use a QDoubleValidator
//QValidator *validator_2 = new QIntValidator(0, 999999, this);
//ui.passwordEdit->setValidator(validator_2); //add a int validator min value 0 max value 500. This will force the numpad to show, you can also use a QDoubleValidator
ui.driverNumberLineEdit->setAttribute(Qt::WA_InputMethodEnabled, true);
ui.driverNumberLineEdit->setFocusPolicy(Qt::StrongFocus);
ui.driverNumberLineEdit->setInputMethodHints(Qt::ImhDigitsOnly | Qt::ImhNoPredictiveText);
ui.driverNumberLineEdit->setFocus();
ui.passwordEdit->setAttribute(Qt::WA_InputMethodEnabled, true);
ui.passwordEdit->setFocusPolicy(Qt::StrongFocus);
ui.passwordEdit->setText("");
ui.passwordEdit->setInputMethodHints(Qt::ImhDigitsOnly | Qt::ImhNoPredictiveText);
}
DriverNumberDialog::~DriverNumberDialog()
{
}
void DriverNumberDialog::setDriverName(QString driverName)
{
ui.driverNumberLineEdit->setText(driverName);
}
bool DriverNumberDialog::showPassword(int mode)
{
bool result = false;
switch (mode) {
case DRIVER_NUMBER:
ui.label->setText("ПОЗЫВНОЙ");
ui.driverNumberLineEdit->setText("");
ui.passwordEdit->setText("");
break;
case TAXI_ORG_NUMBER:
ui.driverNumberLineEdit->setText("");
ui.passwordEdit->setText("");
ui.label->setText("ТАКСИ #");
break;
}
// FIXME
setGeometry(0, 36, 800, 444);
result = exec() == QDialog::Accepted;
qApp->inputMethod()->hide();
return result;
}
void DriverNumberDialog::checkPassword()
{
qDebug() << "==========================================";
qDebug() << "xxx" << ui.passwordEdit->text() << "xxx";
qDebug() << "xxx" << ui.driverNumberLineEdit->text() << "xxx";
qDebug() << "==========================================";
if (ui.driverNumberLineEdit->text() != "" && ui.passwordEdit->text() == "987321") {
_driverNumber = ui.driverNumberLineEdit->text().toInt();
ui.passwordEdit->setText("");
accept();
} else {
ui.passwordEdit->setText("");
reject();
}
}