author | unc0rr |
Tue, 21 Oct 2008 16:53:34 +0000 | |
changeset 1391 | 735f6d43780b |
parent 1389 | 6e411559cc7b |
child 1395 | 46fd70de89e2 |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
1236 | 3 |
* Copyright (c) 2006-2008 Andrey Korotaev <unC0Rr@gmail.com> |
184 | 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 <QPushButton> |
|
21 |
#include <QGroupBox> |
|
22 |
#include <QComboBox> |
|
311 | 23 |
#include <QCheckBox> |
184 | 24 |
#include <QLabel> |
25 |
#include <QToolBox> |
|
26 |
#include <QLineEdit> |
|
27 |
#include <QListWidget> |
|
28 |
#include <QApplication> |
|
231 | 29 |
#include <QSpinBox> |
452 | 30 |
#include <QTextEdit> |
636 | 31 |
#include <QRadioButton> |
665 | 32 |
#include <QTableView> |
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
33 |
#include <QMessageBox> |
673 | 34 |
#include <QHeaderView> |
1252 | 35 |
#include <QTabWidget> |
1377 | 36 |
#include <QTextBrowser> |
184 | 37 |
|
38 |
#include "pages.h" |
|
39 |
#include "sdlkeys.h" |
|
40 |
#include "hwconsts.h" |
|
41 |
#include "gamecfgwidget.h" |
|
42 |
#include "teamselect.h" |
|
43 |
#include "gamecfgwidget.h" |
|
44 |
#include "SquareLabel.h" |
|
45 |
#include "mapContainer.h" |
|
187 | 46 |
#include "about.h" |
297 | 47 |
#include "fpsedit.h" |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
48 |
#include "netserverslist.h" |
412 | 49 |
#include "netudpwidget.h" |
461 | 50 |
#include "chatwidget.h" |
579 | 51 |
#include "playrecordpage.h" |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
603
diff
changeset
|
52 |
#include "selectWeapon.h" |
1192 | 53 |
#include "igbox.h" |
1238
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
54 |
#include "hats.h" |
184 | 55 |
|
684 | 56 |
PageMain::PageMain(QWidget* parent) : |
57 |
AbstractPage(parent) |
|
184 | 58 |
{ |
59 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
1148 | 60 |
//pageLayout->setColumnStretch(0, 1); |
61 |
//pageLayout->setColumnStretch(1, 2); |
|
62 |
//pageLayout->setColumnStretch(2, 1); |
|
184 | 63 |
|
1199 | 64 |
//QPushButton* btnLogo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); |
65 |
//pageLayout->setAlignment(btnLogo, Qt::AlignHCenter); |
|
1148 | 66 |
pageLayout->setRowStretch(0, 1); |
1150 | 67 |
pageLayout->setRowStretch(1, 1); |
68 |
pageLayout->setRowStretch(2, 0); |
|
69 |
pageLayout->setRowStretch(3, 1); |
|
1199 | 70 |
pageLayout->setRowStretch(4, 1); |
184 | 71 |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1151
diff
changeset
|
72 |
BtnSinglePlayer = addButton(":/res/LocalPlay.png", pageLayout, 2, 0, 1, 2, true); |
1150 | 73 |
pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter); |
184 | 74 |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1151
diff
changeset
|
75 |
BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true); |
1150 | 76 |
pageLayout->setAlignment(BtnNet, Qt::AlignHCenter); |
579 | 77 |
|
1199 | 78 |
BtnSetup = addButton(":/res/Settings.png", pageLayout, 4, 3, true); |
184 | 79 |
|
1199 | 80 |
//BtnInfo = addButton(":/res/About.png", pageLayout, 3, 1, 1, 2, true); |
81 |
BtnInfo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); |
|
1212 | 82 |
BtnInfo->setStyleSheet("border: transparent;background: transparent;"); |
1150 | 83 |
pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); |
1199 | 84 |
//pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); |
184 | 85 |
|
1199 | 86 |
BtnExit = addButton(":/res/Exit.png", pageLayout, 4, 0, 1, 1, true); |
184 | 87 |
} |
88 |
||
788
00720357601f
- Get rid of PageSimpleGame, now pressing 'quick game' just starts round
unc0rr
parents:
730
diff
changeset
|
89 |
PageEditTeam::PageEditTeam(QWidget* parent) : |
692 | 90 |
AbstractPage(parent) |
184 | 91 |
{ |
92 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
1252 | 93 |
QTabWidget * tbw = new QTabWidget(this); |
1389 | 94 |
QWidget * page1 = new QWidget(this); |
95 |
QWidget * page2 = new QWidget(this); |
|
1252 | 96 |
tbw->addTab(page1, tr("General")); |
97 |
tbw->addTab(page2, tr("Advanced")); |
|
98 |
pageLayout->addWidget(tbw, 0, 0, 1, 3); |
|
99 |
BtnTeamDiscard = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
|
100 |
BtnTeamSave = addButton(":/res/Save.png", pageLayout, 1, 2, true);; |
|
184 | 101 |
|
1252 | 102 |
QHBoxLayout * page1Layout = new QHBoxLayout(page1); |
103 |
page1Layout->setAlignment(Qt::AlignTop); |
|
104 |
QGridLayout * page2Layout = new QGridLayout(page2); |
|
105 |
||
106 |
// ====== Page 1 ====== |
|
107 |
QVBoxLayout * vbox1 = new QVBoxLayout(); |
|
108 |
QVBoxLayout * vbox2 = new QVBoxLayout(); |
|
109 |
QVBoxLayout * vbox3 = new QVBoxLayout(); |
|
110 |
page1Layout->addLayout(vbox1); |
|
111 |
page1Layout->addLayout(vbox2); |
|
112 |
page1Layout->addLayout(vbox3); |
|
113 |
||
588 | 114 |
GBoxHedgehogs = new QGroupBox(this); |
184 | 115 |
GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members")); |
116 |
GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
117 |
QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs); |
|
1238
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
118 |
|
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
119 |
HatsModel * hatsModel = new HatsModel(GBoxHedgehogs); |
184 | 120 |
for(int i = 0; i < 8; i++) |
121 |
{ |
|
122 |
HHNameEdit[i] = new QLineEdit(GBoxHedgehogs); |
|
1216
df1b19976e28
Allow team and hh name length be up to 64 letters length
unc0rr
parents:
1212
diff
changeset
|
123 |
HHNameEdit[i]->setMaxLength(64); |
1238
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
124 |
HHNameEdit[i]->setMinimumWidth(120); |
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
125 |
GBHLayout->addWidget(HHNameEdit[i], i, 0); |
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
126 |
|
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
127 |
HHHats[i] = new QComboBox(GBoxHedgehogs); |
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
128 |
HHHats[i]->setModel(hatsModel); |
1282 | 129 |
HHHats[i]->setIconSize(QSize(32, 37)); |
130 |
//HHHats[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); |
|
1239 | 131 |
//HHHats[i]->setModelColumn(1); |
1240 | 132 |
//HHHats[i]->setMinimumWidth(132); |
1238
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
133 |
GBHLayout->addWidget(HHHats[i], i, 1); |
184 | 134 |
} |
1252 | 135 |
vbox1->addWidget(GBoxHedgehogs); |
136 |
||
137 |
||
1288
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
138 |
GBoxTeam = new QGroupBox(this); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
139 |
GBoxTeam->setTitle(QGroupBox::tr("Team")); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
140 |
GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
141 |
QVBoxLayout * GBTLayout = new QVBoxLayout(GBoxTeam); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
142 |
TeamNameEdit = new QLineEdit(GBoxTeam); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
143 |
TeamNameEdit->setMaxLength(64); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
144 |
GBTLayout->addWidget(TeamNameEdit); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
145 |
vbox2->addWidget(GBoxTeam); |
1252 | 146 |
|
1290 | 147 |
CBTeamLvl = new QComboBox(GBoxTeam); |
1287 | 148 |
CBTeamLvl->setIconSize(QSize(32, 32)); |
149 |
CBTeamLvl->addItem(QIcon(":/res/botlevels/0.png"), QComboBox::tr("Human")); |
|
150 |
for(int i = 5; i > 0; i--) |
|
151 |
CBTeamLvl->addItem( |
|
152 |
QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)), |
|
153 |
QString("%1 %2").arg(QComboBox::tr("Level")).arg(i) |
|
154 |
); |
|
1288
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
155 |
GBTLayout->addWidget(CBTeamLvl); |
1287 | 156 |
|
1290 | 157 |
CBGrave = new QComboBox(GBoxTeam); |
1288
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
158 |
CBGrave->setMaxCount(65535); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
159 |
CBGrave->setIconSize(QSize(32, 32)); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
160 |
GBTLayout->addWidget(CBGrave); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
161 |
|
1252 | 162 |
GBoxFort = new QGroupBox(this); |
163 |
GBoxFort->setTitle(QGroupBox::tr("Fort")); |
|
164 |
QGridLayout * GBFLayout = new QGridLayout(GBoxFort); |
|
165 |
CBFort = new QComboBox(GBoxFort); |
|
166 |
CBFort->setMaxCount(65535); |
|
167 |
GBFLayout->addWidget(CBFort, 0, 0); |
|
168 |
FortPreview = new SquareLabel(GBoxFort); |
|
169 |
FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
170 |
FortPreview->setPixmap(QPixmap()); |
|
171 |
GBFLayout->addWidget(FortPreview, 1, 0); |
|
172 |
vbox3->addWidget(GBoxFort); |
|
173 |
||
174 |
QDir tmpdir; |
|
175 |
tmpdir.cd(datadir->absolutePath()); |
|
176 |
tmpdir.cd("Forts"); |
|
177 |
tmpdir.setFilter(QDir::Files); |
|
178 |
||
1287 | 179 |
connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &))); |
1252 | 180 |
CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1")); |
1287 | 181 |
|
1252 | 182 |
tmpdir.cd("../Graphics/Graves"); |
183 |
QStringList list = tmpdir.entryList(QStringList("*.png")); |
|
184 |
for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
|
185 |
{ |
|
1287 | 186 |
QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + *it); |
187 |
QIcon icon(pix.copy(0, 0, 32, 32)); |
|
188 |
CBGrave->addItem(icon, (*it).replace(QRegExp("^(.*)\\.png"), "\\1")); |
|
1252 | 189 |
} |
190 |
||
191 |
vbox1->addStretch(); |
|
192 |
vbox2->addStretch(); |
|
193 |
// vbox3->addStretch(); |
|
194 |
||
195 |
// ====== Page 2 ====== |
|
588 | 196 |
GBoxBinds = new QGroupBox(this); |
184 | 197 |
GBoxBinds->setTitle(QGroupBox::tr("Key binds")); |
198 |
QGridLayout * GBBLayout = new QGridLayout(GBoxBinds); |
|
199 |
BindsBox = new QToolBox(GBoxBinds); |
|
200 |
BindsBox->setLineWidth(0); |
|
201 |
GBBLayout->addWidget(BindsBox); |
|
1389 | 202 |
page_A = new QWidget(this); |
184 | 203 |
BindsBox->addItem(page_A, QToolBox::tr("Actions")); |
1389 | 204 |
page_W = new QWidget(this); |
184 | 205 |
BindsBox->addItem(page_W, QToolBox::tr("Weapons")); |
1389 | 206 |
page_WP = new QWidget(this); |
184 | 207 |
BindsBox->addItem(page_WP, QToolBox::tr("Weapon properties")); |
1389 | 208 |
page_O = new QWidget(this); |
184 | 209 |
BindsBox->addItem(page_O, QToolBox::tr("Other")); |
1252 | 210 |
page2Layout->addWidget(GBoxBinds, 0, 0); |
184 | 211 |
|
212 |
QStringList binds; |
|
213 |
for(int i = 0; strlen(sdlkeys[i][1]) > 0; i++) |
|
214 |
{ |
|
215 |
binds << sdlkeys[i][1]; |
|
216 |
} |
|
217 |
||
218 |
quint16 widind = 0, i = 0; |
|
219 |
while (i < BINDS_NUMBER) { |
|
220 |
quint16 num = 0; |
|
1389 | 221 |
QWidget * curW = BindsBox->widget(widind); |
222 |
QGridLayout * pagelayout = new QGridLayout(curW); |
|
184 | 223 |
do { |
1389 | 224 |
LBind[i] = new QLabel(curW); |
184 | 225 |
LBind[i]->setText(QApplication::translate("binds", cbinds[i].name)); |
226 |
LBind[i]->setAlignment(Qt::AlignRight); |
|
227 |
pagelayout->addWidget(LBind[i], num, 0); |
|
1389 | 228 |
CBBind[i] = new QComboBox(curW); |
184 | 229 |
CBBind[i]->addItems(binds); |
230 |
pagelayout->addWidget(CBBind[i], num, 1); |
|
231 |
num++; |
|
232 |
} while (!cbinds[i++].chwidget); |
|
1389 | 233 |
pagelayout->addWidget(new QWidget(curW), num, 0, 1, 2); |
184 | 234 |
widind++; |
235 |
} |
|
236 |
} |
|
237 |
||
238 |
void PageEditTeam::CBFort_activated(const QString & fortname) |
|
239 |
{ |
|
240 |
QPixmap pix(datadir->absolutePath() + "/Forts/" + fortname + "L.png"); |
|
241 |
FortPreview->setPixmap(pix); |
|
242 |
} |
|
243 |
||
1287 | 244 |
PageMultiplayer::PageMultiplayer(QWidget* parent) : |
692 | 245 |
AbstractPage(parent) |
184 | 246 |
{ |
247 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
248 |
||
1218 | 249 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); |
187 | 250 |
|
184 | 251 |
gameCFG = new GameCFGWidget(this); |
252 |
pageLayout->addWidget(gameCFG, 0, 0, 1, 2); |
|
696 | 253 |
|
1218 | 254 |
pageLayout->setRowStretch(1, 1); |
255 |
||
184 | 256 |
teamsSelect = new TeamSelWidget(this); |
1218 | 257 |
pageLayout->addWidget(teamsSelect, 0, 2, 2, 2); |
184 | 258 |
|
1218 | 259 |
BtnStartMPGame = addButton(tr("Start"), pageLayout, 2, 3); |
184 | 260 |
} |
261 |
||
1249
b6670a6ea2d0
Remove 25pix margin on every page, so exit button is almost in the same place on all pages
unc0rr
parents:
1240
diff
changeset
|
262 |
PageOptions::PageOptions(QWidget* parent) : |
692 | 263 |
AbstractPage(parent) |
184 | 264 |
{ |
265 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
427 | 266 |
pageLayout->setColumnStretch(0, 100); |
267 |
pageLayout->setColumnStretch(1, 100); |
|
268 |
pageLayout->setColumnStretch(2, 100); |
|
269 |
pageLayout->setRowStretch(0, 0); |
|
270 |
pageLayout->setRowStretch(1, 0); |
|
719 | 271 |
pageLayout->setRowStretch(2, 0); |
272 |
pageLayout->setRowStretch(3, 100); |
|
273 |
pageLayout->setRowStretch(4, 0); |
|
427 | 274 |
|
1198 | 275 |
|
276 |
QGroupBox * gbTwoBoxes = new QGroupBox(this); |
|
277 |
pageLayout->addWidget(gbTwoBoxes, 0, 0, 1, 3); |
|
278 |
QHBoxLayout * gbTBLayout = new QHBoxLayout(gbTwoBoxes); |
|
279 |
{ |
|
280 |
teamsBox = new IconedGroupBox(this); |
|
281 |
teamsBox->setIcon(QIcon(":/res/teamicon.png")); |
|
282 |
teamsBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
283 |
teamsBox->setTitle(QGroupBox::tr("Teams")); |
|
284 |
||
285 |
QGridLayout * GBTlayout = new QGridLayout(teamsBox); |
|
286 |
||
287 |
BtnNewTeam = addButton(tr("New team"), GBTlayout, 1, 0); |
|
288 |
||
289 |
CBTeamName = new QComboBox(teamsBox); |
|
290 |
GBTlayout->addWidget(CBTeamName, 0, 0, 1, 2); |
|
184 | 291 |
|
1198 | 292 |
BtnEditTeam = addButton(tr("Edit team"), GBTlayout, 1, 1); |
1199 | 293 |
|
294 |
labelNN = new QLabel(teamsBox); |
|
295 |
labelNN->setText(QLabel::tr("Net nick")); |
|
296 |
GBTlayout->addWidget(labelNN, 2, 0, 1, 2); |
|
297 |
||
298 |
editNetNick = new QLineEdit(teamsBox); |
|
299 |
editNetNick->setMaxLength(20); |
|
300 |
editNetNick->setText(QLineEdit::tr("unnamed")); |
|
301 |
GBTlayout->addWidget(editNetNick, 3, 0, 1, 2); |
|
302 |
||
1198 | 303 |
gbTBLayout->addWidget(teamsBox); |
304 |
} |
|
184 | 305 |
|
1198 | 306 |
{ |
307 |
IconedGroupBox* groupWeapons = new IconedGroupBox(this); |
|
1199 | 308 |
groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
1198 | 309 |
groupWeapons->setIcon(QIcon(":/res/weaponsicon.png")); |
1199 | 310 |
//groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
1198 | 311 |
groupWeapons->setTitle(QGroupBox::tr("Weapons")); |
312 |
QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons); |
|
184 | 313 |
|
1198 | 314 |
WeaponsButt = addButton(tr("Weapons set"), WeaponsLayout, 1, 0); |
315 |
WeaponsName = new QComboBox(this); |
|
316 |
WeaponsLayout->addWidget(WeaponsName, 0, 0, 1, 2); |
|
317 |
WeaponEdit = addButton(tr("Edit"), WeaponsLayout, 1, 1); |
|
318 |
gbTBLayout->addWidget(groupWeapons); |
|
319 |
} |
|
184 | 320 |
|
1193 | 321 |
AGGroupBox = new IconedGroupBox(this); |
322 |
AGGroupBox->setIcon(QIcon(":/res/graphicsicon.png")); |
|
184 | 323 |
AGGroupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
324 |
AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options")); |
|
693 | 325 |
pageLayout->addWidget(AGGroupBox, 2, 1); |
184 | 326 |
|
427 | 327 |
QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox); |
436 | 328 |
QHBoxLayout * GBAreslayout = new QHBoxLayout(0); |
427 | 329 |
QLabel * resolution = new QLabel(AGGroupBox); |
330 |
resolution->setText(QLabel::tr("Resolution")); |
|
331 |
GBAreslayout->addWidget(resolution); |
|
332 |
||
184 | 333 |
CBResolution = new QComboBox(AGGroupBox); |
427 | 334 |
GBAreslayout->addWidget(CBResolution); |
335 |
GBAlayout->addLayout(GBAreslayout); |
|
336 |
||
436 | 337 |
QHBoxLayout * GBAfpslayout = new QHBoxLayout(0); |
427 | 338 |
QLabel * maxfps = new QLabel(AGGroupBox); |
339 |
maxfps->setText(QLabel::tr("FPS limit")); |
|
340 |
GBAfpslayout->addWidget(maxfps); |
|
341 |
GBAlayout->addLayout(GBAfpslayout); |
|
184 | 342 |
|
343 |
CBFullscreen = new QCheckBox(AGGroupBox); |
|
344 |
CBFullscreen->setText(QCheckBox::tr("Fullscreen")); |
|
427 | 345 |
GBAlayout->addWidget(CBFullscreen); |
184 | 346 |
|
1162 | 347 |
CBFrontendFullscreen = new QCheckBox(AGGroupBox); |
348 |
CBFrontendFullscreen->setText(QCheckBox::tr("Frontend fullscreen")); |
|
349 |
GBAlayout->addWidget(CBFrontendFullscreen); |
|
350 |
||
1157 | 351 |
CBEnableSound = new QCheckBox(AGGroupBox); |
184 | 352 |
CBEnableSound->setText(QCheckBox::tr("Enable sound")); |
427 | 353 |
GBAlayout->addWidget(CBEnableSound); |
184 | 354 |
|
1157 | 355 |
CBEnableMusic = new QCheckBox(AGGroupBox); |
1129 | 356 |
CBEnableMusic->setText(QCheckBox::tr("Enable music")); |
357 |
GBAlayout->addWidget(CBEnableMusic); |
|
358 |
||
297 | 359 |
CBShowFPS = new QCheckBox(AGGroupBox); |
360 |
CBShowFPS->setText(QCheckBox::tr("Show FPS")); |
|
427 | 361 |
GBAlayout->addWidget(CBShowFPS); |
297 | 362 |
|
529 | 363 |
CBAltDamage = new QCheckBox(AGGroupBox); |
364 |
CBAltDamage->setText(QCheckBox::tr("Alternative damage show")); |
|
365 |
GBAlayout->addWidget(CBAltDamage); |
|
366 |
||
297 | 367 |
fpsedit = new FPSEdit(AGGroupBox); |
427 | 368 |
GBAfpslayout->addWidget(fpsedit); |
184 | 369 |
|
1157 | 370 |
BtnSaveOptions = addButton(":/res/Save.png", pageLayout, 4, 2, true); |
184 | 371 |
|
1153 | 372 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true); |
184 | 373 |
} |
374 |
||
1153 | 375 |
PageNet::PageNet(QWidget* parent) : AbstractPage(parent) |
184 | 376 |
{ |
377 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
378 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
379 |
pageLayout->setColumnStretch(0, 1); |
|
380 |
pageLayout->setColumnStretch(1, 1); |
|
617 | 381 |
pageLayout->setColumnStretch(2, 1); |
421 | 382 |
|
383 |
BtnNetSvrStart = new QPushButton(this); |
|
384 |
BtnNetSvrStart->setFont(*font14); |
|
385 |
BtnNetSvrStart->setText(QPushButton::tr("Start server")); |
|
617 | 386 |
pageLayout->addWidget(BtnNetSvrStart, 3, 2); |
184 | 387 |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
388 |
ConnGroupBox = new QGroupBox(this); |
421 | 389 |
ConnGroupBox->setTitle(QGroupBox::tr("Net game")); |
390 |
pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3); |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
391 |
GBClayout = new QGridLayout(ConnGroupBox); |
646 | 392 |
GBClayout->setColumnStretch(0, 1); |
421 | 393 |
GBClayout->setColumnStretch(1, 1); |
394 |
GBClayout->setColumnStretch(2, 1); |
|
184 | 395 |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
396 |
BtnNetConnect = new QPushButton(ConnGroupBox); |
184 | 397 |
BtnNetConnect->setFont(*font14); |
398 |
BtnNetConnect->setText(QPushButton::tr("Connect")); |
|
646 | 399 |
GBClayout->addWidget(BtnNetConnect, 2, 2); |
416 | 400 |
|
665 | 401 |
tvServersList = new QTableView(ConnGroupBox); |
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
402 |
tvServersList->setSelectionBehavior(QAbstractItemView::SelectRows); |
665 | 403 |
GBClayout->addWidget(tvServersList, 1, 0, 1, 3); |
421 | 404 |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
405 |
BtnUpdateSList = new QPushButton(ConnGroupBox); |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
406 |
BtnUpdateSList->setFont(*font14); |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
407 |
BtnUpdateSList->setText(QPushButton::tr("Update")); |
646 | 408 |
GBClayout->addWidget(BtnUpdateSList, 2, 0); |
314 | 409 |
|
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
410 |
BtnSpecifyServer = new QPushButton(ConnGroupBox); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
411 |
BtnSpecifyServer->setFont(*font14); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
412 |
BtnSpecifyServer->setText(QPushButton::tr("Specify")); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
413 |
GBClayout->addWidget(BtnSpecifyServer, 2, 1); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
414 |
|
1153 | 415 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true); |
636 | 416 |
|
668 | 417 |
connect(BtnNetConnect, SIGNAL(clicked()), this, SLOT(slotConnect())); |
184 | 418 |
} |
419 |
||
646 | 420 |
void PageNet::updateServersList() |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
421 |
{ |
1310 | 422 |
tvServersList->setModel(new HWNetUdpModel(tvServersList)); |
659 | 423 |
|
673 | 424 |
tvServersList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
425 |
||
665 | 426 |
static_cast<HWNetServersModel *>(tvServersList->model())->updateList(); |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
427 |
|
665 | 428 |
connect(BtnUpdateSList, SIGNAL(clicked()), static_cast<HWNetServersModel *>(tvServersList->model()), SLOT(updateList())); |
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
429 |
connect(tvServersList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotConnect())); |
646 | 430 |
} |
431 |
||
432 |
void PageNet::slotConnect() |
|
433 |
{ |
|
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
434 |
HWNetServersModel * model = static_cast<HWNetServersModel *>(tvServersList->model()); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
435 |
QModelIndex mi = tvServersList->currentIndex(); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
436 |
if(!mi.isValid()) |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
437 |
{ |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
438 |
QMessageBox::information(this, tr("Error"), tr("Please, select server from the list above")); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
439 |
return; |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
440 |
} |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
441 |
QString host = model->index(mi.row(), 1).data().toString(); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
442 |
quint16 port = model->index(mi.row(), 2).data().toUInt(); |
672
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
671
diff
changeset
|
443 |
|
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
671
diff
changeset
|
444 |
emit connectClicked(host, port); |
646 | 445 |
} |
446 |
||
1153 | 447 |
PageNetServer::PageNetServer(QWidget* parent) : AbstractPage(parent) |
646 | 448 |
{ |
449 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
450 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
451 |
pageLayout->setColumnStretch(0, 1); |
|
452 |
pageLayout->setColumnStretch(1, 1); |
|
453 |
pageLayout->setColumnStretch(2, 1); |
|
454 |
||
675 | 455 |
pageLayout->setRowStretch(0, 1); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
456 |
pageLayout->setRowStretch(1, 0); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
457 |
|
1153 | 458 |
BtnBack =addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
646 | 459 |
|
460 |
BtnStart = new QPushButton(this); |
|
461 |
BtnStart->setFont(*font14); |
|
462 |
BtnStart->setText(QPushButton::tr("Start")); |
|
675 | 463 |
pageLayout->addWidget(BtnStart, 1, 2); |
464 |
||
465 |
QWidget * wg = new QWidget(this); |
|
466 |
pageLayout->addWidget(wg, 0, 0, 1, 3); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
467 |
|
675 | 468 |
QGridLayout * wgLayout = new QGridLayout(wg); |
469 |
wgLayout->setColumnStretch(0, 1); |
|
470 |
wgLayout->setColumnStretch(1, 3); |
|
471 |
wgLayout->setColumnStretch(2, 1); |
|
472 |
||
473 |
wgLayout->setRowStretch(0, 0); |
|
474 |
wgLayout->setRowStretch(1, 1); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
475 |
|
675 | 476 |
QGroupBox * gb = new QGroupBox(wg); |
477 |
wgLayout->addWidget(gb, 0, 1); |
|
478 |
||
479 |
QGridLayout * gbLayout = new QGridLayout(gb); |
|
480 |
||
481 |
labelSD = new QLabel(gb); |
|
482 |
labelSD->setText(QLabel::tr("Server name:")); |
|
483 |
gbLayout->addWidget(labelSD, 0, 0); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
484 |
|
675 | 485 |
leServerDescr = new QLineEdit(gb); |
486 |
gbLayout->addWidget(leServerDescr, 0, 1); |
|
487 |
||
488 |
labelPort = new QLabel(gb); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
489 |
labelPort->setText(QLabel::tr("Server port:")); |
675 | 490 |
gbLayout->addWidget(labelPort, 1, 0); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
491 |
|
675 | 492 |
sbPort = new QSpinBox(gb); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
493 |
sbPort->setMinimum(0); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
494 |
sbPort->setMaximum(65535); |
675 | 495 |
gbLayout->addWidget(sbPort, 1, 1); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
496 |
|
675 | 497 |
BtnDefault = new QPushButton(gb); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
498 |
BtnDefault->setText(QPushButton::tr("default")); |
675 | 499 |
gbLayout->addWidget(BtnDefault, 1, 2); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
500 |
|
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
501 |
connect(BtnDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort())); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
502 |
} |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
503 |
|
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
504 |
void PageNetServer::setDefaultPort() |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
505 |
{ |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
506 |
sbPort->setValue(46631); |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
507 |
} |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
508 |
|
1153 | 509 |
PageNetGame::PageNetGame(QWidget* parent) : AbstractPage(parent) |
184 | 510 |
{ |
511 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
512 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
452 | 513 |
pageLayout->setSizeConstraint(QLayout::SetMinimumSize); |
461 | 514 |
//pageLayout->setSpacing(1); |
463 | 515 |
pageLayout->setColumnStretch(0, 50); |
516 |
pageLayout->setColumnStretch(1, 50); |
|
322 | 517 |
|
461 | 518 |
// chatwidget |
519 |
pChatWidget = new HWChatWidget(this); |
|
520 |
pageLayout->addWidget(pChatWidget, 1, 0); |
|
464 | 521 |
pageLayout->setRowStretch(1, 100); |
453 | 522 |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
323
diff
changeset
|
523 |
pGameCFG = new GameCFGWidget(this); |
322 | 524 |
pageLayout->addWidget(pGameCFG, 0, 0); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
323
diff
changeset
|
525 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
323
diff
changeset
|
526 |
pNetTeamsWidget = new TeamSelWidget(this); |
373 | 527 |
pNetTeamsWidget->setAcceptOuter(true); |
461 | 528 |
pageLayout->addWidget(pNetTeamsWidget, 0, 1, 2, 1); |
184 | 529 |
|
1153 | 530 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); |
184 | 531 |
|
646 | 532 |
BtnGo = new QPushButton(this); |
184 | 533 |
BtnGo->setFont(*font14); |
534 |
BtnGo->setText(QPushButton::tr("Go!")); |
|
492 | 535 |
BtnGo->setEnabled(false); |
461 | 536 |
pageLayout->addWidget(BtnGo, 2, 1); |
184 | 537 |
} |
187 | 538 |
|
1153 | 539 |
PageInfo::PageInfo(QWidget* parent) : AbstractPage(parent) |
187 | 540 |
{ |
541 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
542 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
543 |
pageLayout->setColumnStretch(0, 1); |
|
544 |
pageLayout->setColumnStretch(1, 1); |
|
545 |
pageLayout->setColumnStretch(2, 1); |
|
546 |
||
1153 | 547 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
187 | 548 |
|
549 |
about = new About(this); |
|
550 |
pageLayout->addWidget(about, 0, 0, 1, 3); |
|
551 |
} |
|
306 | 552 |
|
1153 | 553 |
PageGameStats::PageGameStats(QWidget* parent) : AbstractPage(parent) |
306 | 554 |
{ |
555 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
556 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
557 |
pageLayout->setColumnStretch(0, 1); |
|
558 |
pageLayout->setColumnStretch(1, 1); |
|
559 |
pageLayout->setColumnStretch(2, 1); |
|
560 |
||
1153 | 561 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
306 | 562 |
|
307 | 563 |
labelGameStats = new QLabel(this); |
564 |
labelGameStats->setTextFormat(Qt::RichText); |
|
565 |
pageLayout->addWidget(labelGameStats, 0, 0, 1, 3); |
|
306 | 566 |
} |
586 | 567 |
|
1150 | 568 |
PageSinglePlayer::PageSinglePlayer(QWidget* parent) : AbstractPage(parent) |
586 | 569 |
{ |
570 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
571 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
1252 | 572 |
// pageLayout->setColumnStretch(0, 1); |
573 |
// pageLayout->setColumnStretch(1, 2); |
|
574 |
// pageLayout->setColumnStretch(2, 1); |
|
588 | 575 |
pageLayout->setRowStretch(0, 1); |
1150 | 576 |
pageLayout->setRowStretch(6, 1); |
586 | 577 |
|
1150 | 578 |
BtnSimpleGamePage = addButton(tr("Simple Game"), pageLayout, 1, 1); |
579 |
BtnTrainPage = addButton(tr("Training"), pageLayout, 2, 1); |
|
580 |
BtnMultiplayer = addButton(tr("Multiplayer"), pageLayout, 3, 1); |
|
581 |
BtnLoad = addButton(tr("Saved games"), pageLayout, 4, 1); |
|
582 |
BtnDemos = addButton(tr("Demos"), pageLayout, 5, 1); |
|
586 | 583 |
|
1153 | 584 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 7, 0, true); |
586 | 585 |
} |
586 |
||
1153 | 587 |
PageTraining::PageTraining(QWidget* parent) : AbstractPage(parent) |
587 | 588 |
{ |
589 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
590 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
591 |
pageLayout->setColumnStretch(0, 1); |
|
592 |
pageLayout->setColumnStretch(1, 2); |
|
593 |
pageLayout->setColumnStretch(2, 1); |
|
594 |
||
595 |
BtnStartTrain = new QPushButton(this); |
|
596 |
BtnStartTrain->setFont(*font14); |
|
597 |
BtnStartTrain->setText(QPushButton::tr("Go!")); |
|
598 |
pageLayout->addWidget(BtnStartTrain, 1, 2); |
|
599 |
||
1153 | 600 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
587 | 601 |
} |
602 |
||
923
b3d097097b54
Use default ammostore string size for weapons number instead of predefined const
unc0rr
parents:
788
diff
changeset
|
603 |
PageSelectWeapon::PageSelectWeapon(QWidget* parent) : |
684 | 604 |
AbstractPage(parent) |
600 | 605 |
{ |
606 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
923
b3d097097b54
Use default ammostore string size for weapons number instead of predefined const
unc0rr
parents:
788
diff
changeset
|
607 |
|
1168 | 608 |
pWeapons = new SelWeaponWidget(cDefaultAmmoStore->size() - 10, this); |
718 | 609 |
pageLayout->addWidget(pWeapons, 0, 0, 1, 4); |
600 | 610 |
|
1168 | 611 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
730 | 612 |
BtnDefault = addButton(tr("Default"), pageLayout, 1, 1); |
613 |
BtnDelete = addButton(tr("Delete"), pageLayout, 1, 2); |
|
1168 | 614 |
BtnSave = addButton(":/res/Save.png", pageLayout, 1, 3, true); |
600 | 615 |
} |
616 |
||
1249
b6670a6ea2d0
Remove 25pix margin on every page, so exit button is almost in the same place on all pages
unc0rr
parents:
1240
diff
changeset
|
617 |
PageInGame::PageInGame(QWidget* parent) : |
686 | 618 |
AbstractPage(parent) |
619 |
{ |
|
620 |
QLabel * label = new QLabel(this); |
|
621 |
label->setText("In game..."); |
|
622 |
} |
|
1311 | 623 |
|
624 |
PageRoomsList::PageRoomsList(QWidget* parent) : |
|
625 |
AbstractPage(parent) |
|
626 |
{ |
|
1312 | 627 |
QGridLayout * pageLayout = new QGridLayout(this); |
1314 | 628 |
|
629 |
roomName = new QLineEdit(this); |
|
1334
b58afaadf7ae
Send team removal message to others in room when client disconnects
unc0rr
parents:
1315
diff
changeset
|
630 |
roomName->setMaxLength(60); |
1314 | 631 |
pageLayout->addWidget(roomName, 0, 0); |
1312 | 632 |
roomsList = new QListWidget(this); |
1314 | 633 |
pageLayout->addWidget(roomsList, 1, 0, 3, 1); |
1377 | 634 |
serverMessage = new QTextBrowser(this); |
635 |
serverMessage->setOpenExternalLinks(true); |
|
636 |
pageLayout->addWidget(serverMessage, 4, 0, 1, 2); |
|
1312 | 637 |
|
1377 | 638 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 5, 0, true); |
1312 | 639 |
BtnCreate = addButton(tr("Create"), pageLayout, 0, 1); |
640 |
BtnJoin = addButton(tr("Join"), pageLayout, 1, 1); |
|
641 |
BtnRefresh = addButton(tr("Refresh"), pageLayout, 2, 1); |
|
1314 | 642 |
|
643 |
connect(BtnCreate, SIGNAL(clicked()), this, SLOT(onCreateClick())); |
|
644 |
connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick())); |
|
1315 | 645 |
connect(BtnRefresh, SIGNAL(clicked()), this, SLOT(onRefreshClick())); |
1314 | 646 |
connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick())); |
1311 | 647 |
} |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
648 |
|
1377 | 649 |
|
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
650 |
void PageRoomsList::setRoomsList(const QStringList & list) |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
651 |
{ |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
652 |
roomsList->clear(); |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
653 |
roomsList->addItems(list); |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
654 |
roomsList->sortItems(); |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
655 |
} |
1314 | 656 |
|
657 |
void PageRoomsList::onCreateClick() |
|
658 |
{ |
|
659 |
if (roomName->text().size()) |
|
660 |
emit askForCreateRoom(roomName->text()); |
|
661 |
else |
|
662 |
QMessageBox::critical(this, |
|
663 |
tr("Error"), |
|
1315 | 664 |
tr("Please, enter room name"), |
1314 | 665 |
tr("OK")); |
666 |
} |
|
667 |
||
668 |
void PageRoomsList::onJoinClick() |
|
669 |
{ |
|
670 |
QListWidgetItem * curritem = roomsList->currentItem(); |
|
671 |
if (!curritem) |
|
672 |
{ |
|
673 |
QMessageBox::critical(this, |
|
674 |
tr("Error"), |
|
675 |
tr("Please, select room from the list"), |
|
676 |
tr("OK")); |
|
677 |
return ; |
|
678 |
} |
|
679 |
emit askForJoinRoom(curritem->data(Qt::DisplayRole).toString()); |
|
680 |
} |
|
681 |
||
1315 | 682 |
void PageRoomsList::onRefreshClick() |
683 |
{ |
|
684 |
emit askForRoomList(); |
|
685 |
} |
|
686 |