author | Wuzzy <Wuzzy2@mail.ru> |
Mon, 01 Apr 2019 23:15:18 +0200 | |
changeset 14758 | 123aaa2bf4b5 |
parent 12845 | b63ec501490b |
permissions | -rw-r--r-- |
8456 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
8456 | 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 |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
8456 | 17 |
*/ |
18 |
||
19 |
#include <QDialog> |
|
20 |
#include <QVBoxLayout> |
|
21 |
#include <QHBoxLayout> |
|
22 |
#include <QPushButton> |
|
23 |
#include <QLineEdit> |
|
24 |
#include <QLabel> |
|
25 |
#include <QDebug> |
|
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
26 |
#include <QCheckBox> |
8456 | 27 |
|
28 |
#include "roomnameprompt.h" |
|
29 |
||
30 |
RoomNamePrompt::RoomNamePrompt(QWidget* parent, const QString & roomName) : QDialog(parent) |
|
31 |
{ |
|
32 |
setModal(true); |
|
33 |
setWindowFlags(Qt::Sheet); |
|
34 |
setWindowModality(Qt::WindowModal); |
|
11490
fb7817a5c2b1
Add window titles for title-less windows
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
35 |
setWindowTitle(tr("Create room")); |
8456 | 36 |
setMinimumSize(360, 130); |
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
37 |
resize(360, 180); |
8456 | 38 |
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); |
39 |
||
40 |
// Layout |
|
41 |
QVBoxLayout * dialogLayout = new QVBoxLayout(this); |
|
42 |
||
43 |
// Label |
|
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
44 |
label = new QLabel(tr("Enter a name for your room."), this); |
8456 | 45 |
label->setWordWrap(true); |
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
46 |
dialogLayout->addWidget(label); |
8456 | 47 |
|
48 |
// Input box |
|
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
49 |
leRoomName = new QLineEdit(this); |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
50 |
leRoomName->setText(roomName); |
12845
b63ec501490b
At the very least we should match the gameserver length which seems to be 40, not 60
nemo
parents:
11490
diff
changeset
|
51 |
//leRoomName->setMaxLength(59); // It didn't like 60 :( |
b63ec501490b
At the very least we should match the gameserver length which seems to be 40, not 60
nemo
parents:
11490
diff
changeset
|
52 |
leRoomName->setMaxLength(40); |
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
53 |
leRoomName->setStyleSheet("QLineEdit { padding: 3px; }"); |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
54 |
leRoomName->selectAll(); |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
55 |
dialogLayout->addWidget(leRoomName); |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
56 |
|
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
57 |
cbSetPassword = new QCheckBox(this); |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
58 |
cbSetPassword->setText(tr("set password")); |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
59 |
dialogLayout->addWidget(cbSetPassword); |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
60 |
|
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
61 |
lePassword = new QLineEdit(this); |
9547 | 62 |
lePassword->setMaxLength(30); |
63 |
lePassword->setStyleSheet("QLineEdit { padding: 3px; }"); |
|
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
64 |
lePassword->setEnabled(false); |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
65 |
dialogLayout->addWidget(lePassword); |
8456 | 66 |
|
67 |
dialogLayout->addStretch(1); |
|
68 |
||
69 |
// Buttons |
|
70 |
QHBoxLayout * buttonLayout = new QHBoxLayout(); |
|
71 |
buttonLayout->addStretch(1); |
|
72 |
dialogLayout->addLayout(buttonLayout); |
|
73 |
||
74 |
QPushButton * btnCancel = new QPushButton(tr("Cancel")); |
|
75 |
QPushButton * btnOkay = new QPushButton(tr("Create room")); |
|
76 |
connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject())); |
|
77 |
connect(btnOkay, SIGNAL(clicked()), this, SLOT(accept())); |
|
9163
67334acaaac7
port all Q_WS_* to Q_OS_* so that we are forward compatible with Qt5
koda
parents:
9080
diff
changeset
|
78 |
#ifdef Q_OS_MAC |
8622
2045bdf1b11b
Resolves issue 528. Fixed platform-specific order of buttons on seed prompt and new room prompt. Fixed height of back button on all pages -- now aligns to bottom. On pagemain, feedback and dlc buttons no longer fixed size.
dag10
parents:
8456
diff
changeset
|
79 |
buttonLayout->addWidget(btnCancel); |
2045bdf1b11b
Resolves issue 528. Fixed platform-specific order of buttons on seed prompt and new room prompt. Fixed height of back button on all pages -- now aligns to bottom. On pagemain, feedback and dlc buttons no longer fixed size.
dag10
parents:
8456
diff
changeset
|
80 |
buttonLayout->addWidget(btnOkay); |
2045bdf1b11b
Resolves issue 528. Fixed platform-specific order of buttons on seed prompt and new room prompt. Fixed height of back button on all pages -- now aligns to bottom. On pagemain, feedback and dlc buttons no longer fixed size.
dag10
parents:
8456
diff
changeset
|
81 |
#else |
2045bdf1b11b
Resolves issue 528. Fixed platform-specific order of buttons on seed prompt and new room prompt. Fixed height of back button on all pages -- now aligns to bottom. On pagemain, feedback and dlc buttons no longer fixed size.
dag10
parents:
8456
diff
changeset
|
82 |
buttonLayout->addWidget(btnOkay); |
2045bdf1b11b
Resolves issue 528. Fixed platform-specific order of buttons on seed prompt and new room prompt. Fixed height of back button on all pages -- now aligns to bottom. On pagemain, feedback and dlc buttons no longer fixed size.
dag10
parents:
8456
diff
changeset
|
83 |
buttonLayout->addWidget(btnCancel); |
2045bdf1b11b
Resolves issue 528. Fixed platform-specific order of buttons on seed prompt and new room prompt. Fixed height of back button on all pages -- now aligns to bottom. On pagemain, feedback and dlc buttons no longer fixed size.
dag10
parents:
8456
diff
changeset
|
84 |
#endif |
8456 | 85 |
btnOkay->setDefault(true); |
86 |
||
87 |
setStyleSheet("QPushButton { padding: 5px; }"); |
|
88 |
||
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
89 |
connect(cbSetPassword, SIGNAL(toggled(bool)), this, SLOT(checkBoxToggled())); |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
90 |
} |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
91 |
|
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
92 |
QString RoomNamePrompt::getRoomName() |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
93 |
{ |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
94 |
return leRoomName->text(); |
8456 | 95 |
} |
96 |
||
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
97 |
QString RoomNamePrompt::getPassword() |
8456 | 98 |
{ |
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
99 |
return lePassword->text(); |
8456 | 100 |
} |
9541
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
101 |
|
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
102 |
void RoomNamePrompt::checkBoxToggled() |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
103 |
{ |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
104 |
lePassword->setEnabled(cbSetPassword->isChecked()); |
312bb4384f33
- Frontend finally learns how to create passworded room
unc0rr
parents:
9163
diff
changeset
|
105 |
} |