|
1 /* |
|
2 * Hedgewars, a free turn based strategy game |
|
3 * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com> |
|
4 * |
|
5 * This program is free software; you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License as published by |
|
7 * the Free Software Foundation; version 2 of the License |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU General Public License |
|
15 * along with this program; if not, write to the Free Software |
|
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 */ |
|
18 |
|
19 #include <QGridLayout> |
|
20 #include <QLabel> |
|
21 #include <QLineEdit> |
|
22 #include <QSpinBox> |
|
23 #include <QPushButton> |
|
24 #include <QTextBrowser> |
|
25 |
|
26 #include "pages.h" |
|
27 #include "chatwidget.h" |
|
28 |
|
29 PageAdmin::PageAdmin(QWidget* parent) : |
|
30 AbstractPage(parent) |
|
31 { |
|
32 QGridLayout * pageLayout = new QGridLayout(this); |
|
33 |
|
34 // 0 |
|
35 pbAsk = addButton(tr("Fetch data"), pageLayout, 0, 0, 1, 3); |
|
36 connect(pbAsk, SIGNAL(clicked()), this, SIGNAL(askServerVars())); |
|
37 |
|
38 // 1 |
|
39 QLabel * lblSMN = new QLabel(this); |
|
40 lblSMN->setText(tr("Server message for latest version:")); |
|
41 pageLayout->addWidget(lblSMN, 1, 0); |
|
42 |
|
43 leServerMessageNew = new QLineEdit(this); |
|
44 pageLayout->addWidget(leServerMessageNew, 1, 1); |
|
45 |
|
46 // 2 |
|
47 QLabel * lblSMO = new QLabel(this); |
|
48 lblSMO->setText(tr("Server message for previous versions:")); |
|
49 pageLayout->addWidget(lblSMO, 2, 0); |
|
50 |
|
51 leServerMessageOld = new QLineEdit(this); |
|
52 pageLayout->addWidget(leServerMessageOld, 2, 1); |
|
53 |
|
54 // 3 |
|
55 QLabel * lblP = new QLabel(this); |
|
56 lblP->setText(tr("Latest version protocol number:")); |
|
57 pageLayout->addWidget(lblP, 3, 0); |
|
58 |
|
59 sbProtocol = new QSpinBox(this); |
|
60 pageLayout->addWidget(sbProtocol, 3, 1); |
|
61 |
|
62 // 4 |
|
63 QLabel * lblPreview = new QLabel(this); |
|
64 lblPreview->setText(tr("MOTD preview:")); |
|
65 pageLayout->addWidget(lblPreview, 4, 0); |
|
66 |
|
67 tb = new QTextBrowser(this); |
|
68 tb->setOpenExternalLinks(true); |
|
69 tb->document()->setDefaultStyleSheet(HWChatWidget::STYLE); |
|
70 pageLayout->addWidget(tb, 4, 1, 1, 2); |
|
71 connect(leServerMessageNew, SIGNAL(textEdited(const QString &)), tb, SLOT(setHtml(const QString &))); |
|
72 connect(leServerMessageOld, SIGNAL(textEdited(const QString &)), tb, SLOT(setHtml(const QString &))); |
|
73 |
|
74 // 5 |
|
75 pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), pageLayout, 5, 0); |
|
76 |
|
77 // 6 |
|
78 pbSetSM = addButton(tr("Set data"), pageLayout, 6, 0, 1, 3); |
|
79 |
|
80 // 7 |
|
81 BtnBack = addButton(":/res/Exit.png", pageLayout, 7, 0, true); |
|
82 |
|
83 connect(pbSetSM, SIGNAL(clicked()), this, SLOT(smChanged())); |
|
84 } |
|
85 |
|
86 void PageAdmin::smChanged() |
|
87 { |
|
88 emit setServerMessageNew(leServerMessageNew->text()); |
|
89 emit setServerMessageOld(leServerMessageOld->text()); |
|
90 emit setProtocol(sbProtocol->value()); |
|
91 } |
|
92 |
|
93 void PageAdmin::serverMessageNew(const QString & str) |
|
94 { |
|
95 leServerMessageNew->setText(str); |
|
96 } |
|
97 |
|
98 void PageAdmin::serverMessageOld(const QString & str) |
|
99 { |
|
100 leServerMessageOld->setText(str); |
|
101 } |
|
102 void PageAdmin::protocol(int proto) |
|
103 { |
|
104 sbProtocol->setValue(proto); |
|
105 } |