author | unc0rr |
Wed, 05 Jun 2013 00:26:22 +0400 | |
changeset 9107 | 4dde5fecffe2 |
parent 8417 | 790492abc004 |
child 10079 | c88e38a0f478 |
permissions | -rw-r--r-- |
8157 | 1 |
#include <QFormLayout> |
2 |
#include <QComboBox> |
|
3 |
#include <QRadioButton> |
|
4 |
#include <QLineEdit> |
|
5 |
#include <QLabel> |
|
6 |
#include <QPushButton> |
|
7 |
#include <QHBoxLayout> |
|
8 |
#include <QMessageBox> |
|
8411
cb371dac50c0
reuse the same words with tr() and .arg() in bandialog
koda
parents:
8177
diff
changeset
|
9 |
#include "HWApplication.h" |
8157 | 10 |
|
11 |
#include "bandialog.h" |
|
12 |
||
13 |
BanDialog::BanDialog(QWidget *parent) : |
|
14 |
QDialog(parent) |
|
15 |
{ |
|
16 |
QFormLayout * formLayout = new QFormLayout(this); |
|
17 |
||
18 |
rbIP = new QRadioButton(this); |
|
19 |
rbIP->setChecked(true); |
|
20 |
rbNick = new QRadioButton(this); |
|
21 |
leId = new QLineEdit(this); |
|
22 |
leReason = new QLineEdit(this); |
|
23 |
cbTime = new QComboBox(this); |
|
24 |
||
8417
790492abc004
Learn to properly localize strings with numbers pleeeeaaaase
unc0rr
parents:
8411
diff
changeset
|
25 |
cbTime->addItem(HWApplication::tr("%1 minutes", 0, 10).arg("10"), 5 * 60); |
790492abc004
Learn to properly localize strings with numbers pleeeeaaaase
unc0rr
parents:
8411
diff
changeset
|
26 |
cbTime->addItem(HWApplication::tr("%1 minutes", 0, 30).arg("30"), 10 * 60); |
790492abc004
Learn to properly localize strings with numbers pleeeeaaaase
unc0rr
parents:
8411
diff
changeset
|
27 |
cbTime->addItem(HWApplication::tr("%1 hour", 0, 10).arg("10"), 60 * 60); |
790492abc004
Learn to properly localize strings with numbers pleeeeaaaase
unc0rr
parents:
8411
diff
changeset
|
28 |
cbTime->addItem(HWApplication::tr("%1 hours", 0, 3).arg("3"), 3 * 60 * 60); |
790492abc004
Learn to properly localize strings with numbers pleeeeaaaase
unc0rr
parents:
8411
diff
changeset
|
29 |
cbTime->addItem(HWApplication::tr("%1 hours", 0, 5).arg("5"), 5 * 60 * 60); |
790492abc004
Learn to properly localize strings with numbers pleeeeaaaase
unc0rr
parents:
8411
diff
changeset
|
30 |
cbTime->addItem(HWApplication::tr("%1 hours", 0, 12).arg("12"), 12 * 60 * 60); |
790492abc004
Learn to properly localize strings with numbers pleeeeaaaase
unc0rr
parents:
8411
diff
changeset
|
31 |
cbTime->addItem(HWApplication::tr("%1 day", 0, 1).arg("1"), 24 * 60 * 60); |
790492abc004
Learn to properly localize strings with numbers pleeeeaaaase
unc0rr
parents:
8411
diff
changeset
|
32 |
cbTime->addItem(HWApplication::tr("%1 days", 0, 3).arg("3"), 72 * 60 * 60); |
790492abc004
Learn to properly localize strings with numbers pleeeeaaaase
unc0rr
parents:
8411
diff
changeset
|
33 |
cbTime->addItem(HWApplication::tr("%1 days", 0, 7).arg("7"), 168 * 60 * 60); |
790492abc004
Learn to properly localize strings with numbers pleeeeaaaase
unc0rr
parents:
8411
diff
changeset
|
34 |
cbTime->addItem(HWApplication::tr("%1 days", 0, 14).arg("14"), 336 * 60 * 60); |
8177 | 35 |
cbTime->addItem(tr("permanent"), 3650 * 24 * 60 * 60); |
8157 | 36 |
cbTime->setCurrentIndex(0); |
37 |
||
38 |
formLayout->addRow(tr("IP"), rbIP); |
|
39 |
formLayout->addRow(tr("Nick"), rbNick); |
|
40 |
formLayout->addRow(tr("IP/Nick"), leId); |
|
41 |
formLayout->addRow(tr("Reason"), leReason); |
|
42 |
formLayout->addRow(tr("Duration"), cbTime); |
|
43 |
||
44 |
formLayout->setLabelAlignment(Qt::AlignRight); |
|
45 |
||
46 |
QHBoxLayout * hbox = new QHBoxLayout(); |
|
47 |
formLayout->addRow(hbox); |
|
48 |
QPushButton * btnOk = new QPushButton(tr("Ok"), this); |
|
49 |
QPushButton * btnCancel = new QPushButton(tr("Cancel"), this); |
|
50 |
hbox->addStretch(); |
|
51 |
hbox->addWidget(btnOk); |
|
52 |
hbox->addWidget(btnCancel); |
|
53 |
||
54 |
connect(btnOk, SIGNAL(clicked()), this, SLOT(okClicked())); |
|
55 |
connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject())); |
|
8159 | 56 |
|
57 |
this->setWindowModality(Qt::WindowModal); |
|
8157 | 58 |
} |
59 |
||
60 |
bool BanDialog::byIP() |
|
61 |
{ |
|
62 |
return rbIP->isChecked(); |
|
63 |
} |
|
64 |
||
65 |
int BanDialog::duration() |
|
66 |
{ |
|
67 |
return cbTime->itemData(cbTime->currentIndex()).toInt(); |
|
68 |
} |
|
69 |
||
70 |
QString BanDialog::banId() |
|
71 |
{ |
|
72 |
return leId->text(); |
|
73 |
} |
|
74 |
||
75 |
QString BanDialog::reason() |
|
76 |
{ |
|
77 |
return leReason->text().isEmpty() ? tr("you know why") : leReason->text(); |
|
78 |
} |
|
79 |
||
80 |
void BanDialog::okClicked() |
|
81 |
{ |
|
82 |
if(leId->text().isEmpty()) |
|
83 |
{ |
|
84 |
QMessageBox::warning(this, tr("Warning"), tr("Please, specify %1").arg(byIP() ? tr("IP") : tr("nickname"))); |
|
85 |
return; |
|
86 |
} |
|
87 |
||
88 |
accept(); |
|
89 |
} |