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>
|
|
9 |
|
|
10 |
#include "bandialog.h"
|
|
11 |
|
|
12 |
BanDialog::BanDialog(QWidget *parent) :
|
|
13 |
QDialog(parent)
|
|
14 |
{
|
|
15 |
QFormLayout * formLayout = new QFormLayout(this);
|
|
16 |
|
|
17 |
rbIP = new QRadioButton(this);
|
|
18 |
rbIP->setChecked(true);
|
|
19 |
rbNick = new QRadioButton(this);
|
|
20 |
leId = new QLineEdit(this);
|
|
21 |
leReason = new QLineEdit(this);
|
|
22 |
cbTime = new QComboBox(this);
|
|
23 |
|
|
24 |
cbTime->addItem(tr("10 minutes"), 5 * 60);
|
|
25 |
cbTime->addItem(tr("30 minutes"), 10 * 60);
|
|
26 |
cbTime->addItem(tr("1 hour"), 60 * 60);
|
|
27 |
cbTime->addItem(tr("3 hours"), 3 * 60 * 60);
|
|
28 |
cbTime->addItem(tr("5 hours"), 5 * 60 * 60);
|
|
29 |
cbTime->addItem(tr("24 hours"), 24 * 60 * 60);
|
|
30 |
cbTime->addItem(tr("3 days"), 72 * 60 * 60);
|
|
31 |
cbTime->addItem(tr("7 days"), 168 * 60 * 60);
|
|
32 |
cbTime->addItem(tr("14 days"), 336 * 60 * 60);
|
8177
|
33 |
cbTime->addItem(tr("permanent"), 3650 * 24 * 60 * 60);
|
8157
|
34 |
cbTime->setCurrentIndex(0);
|
|
35 |
|
|
36 |
formLayout->addRow(tr("IP"), rbIP);
|
|
37 |
formLayout->addRow(tr("Nick"), rbNick);
|
|
38 |
formLayout->addRow(tr("IP/Nick"), leId);
|
|
39 |
formLayout->addRow(tr("Reason"), leReason);
|
|
40 |
formLayout->addRow(tr("Duration"), cbTime);
|
|
41 |
|
|
42 |
formLayout->setLabelAlignment(Qt::AlignRight);
|
|
43 |
|
|
44 |
QHBoxLayout * hbox = new QHBoxLayout();
|
|
45 |
formLayout->addRow(hbox);
|
|
46 |
QPushButton * btnOk = new QPushButton(tr("Ok"), this);
|
|
47 |
QPushButton * btnCancel = new QPushButton(tr("Cancel"), this);
|
|
48 |
hbox->addStretch();
|
|
49 |
hbox->addWidget(btnOk);
|
|
50 |
hbox->addWidget(btnCancel);
|
|
51 |
|
|
52 |
connect(btnOk, SIGNAL(clicked()), this, SLOT(okClicked()));
|
|
53 |
connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
|
8159
|
54 |
|
|
55 |
this->setWindowModality(Qt::WindowModal);
|
8157
|
56 |
}
|
|
57 |
|
|
58 |
bool BanDialog::byIP()
|
|
59 |
{
|
|
60 |
return rbIP->isChecked();
|
|
61 |
}
|
|
62 |
|
|
63 |
int BanDialog::duration()
|
|
64 |
{
|
|
65 |
return cbTime->itemData(cbTime->currentIndex()).toInt();
|
|
66 |
}
|
|
67 |
|
|
68 |
QString BanDialog::banId()
|
|
69 |
{
|
|
70 |
return leId->text();
|
|
71 |
}
|
|
72 |
|
|
73 |
QString BanDialog::reason()
|
|
74 |
{
|
|
75 |
return leReason->text().isEmpty() ? tr("you know why") : leReason->text();
|
|
76 |
}
|
|
77 |
|
|
78 |
void BanDialog::okClicked()
|
|
79 |
{
|
|
80 |
if(leId->text().isEmpty())
|
|
81 |
{
|
|
82 |
QMessageBox::warning(this, tr("Warning"), tr("Please, specify %1").arg(byIP() ? tr("IP") : tr("nickname")));
|
|
83 |
return;
|
|
84 |
}
|
|
85 |
|
|
86 |
accept();
|
|
87 |
}
|