author | koda |
Fri, 11 Oct 2013 17:43:13 +0200 | |
branch | webgl |
changeset 9521 | 8054d9d775fd |
parent 9163 | 67334acaaac7 |
child 9541 | 312bb4384f33 |
permissions | -rw-r--r-- |
8456 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
9080 | 3 |
* Copyright (c) 2004-2013 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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
19 |
#include <QDialog> |
|
20 |
#include <QVBoxLayout> |
|
21 |
#include <QHBoxLayout> |
|
22 |
#include <QPushButton> |
|
23 |
#include <QLineEdit> |
|
24 |
#include <QLabel> |
|
25 |
#include <QDebug> |
|
26 |
||
27 |
#include "roomnameprompt.h" |
|
28 |
||
29 |
RoomNamePrompt::RoomNamePrompt(QWidget* parent, const QString & roomName) : QDialog(parent) |
|
30 |
{ |
|
31 |
setModal(true); |
|
32 |
setWindowFlags(Qt::Sheet); |
|
33 |
setWindowModality(Qt::WindowModal); |
|
34 |
setMinimumSize(360, 130); |
|
35 |
resize(360, 130); |
|
36 |
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); |
|
37 |
||
38 |
// Layout |
|
39 |
QVBoxLayout * dialogLayout = new QVBoxLayout(this); |
|
40 |
||
41 |
// Label |
|
42 |
label = new QLabel(tr("Enter a name for your room.")); |
|
43 |
label->setWordWrap(true); |
|
44 |
dialogLayout->addWidget(label, 0); |
|
45 |
||
46 |
// Input box |
|
47 |
editBox = new QLineEdit(); |
|
48 |
editBox->setText(roomName); |
|
49 |
editBox->setMaxLength(59); // It didn't like 60 :( |
|
50 |
editBox->setStyleSheet("QLineEdit { padding: 3px; }"); |
|
51 |
editBox->selectAll(); |
|
52 |
dialogLayout->addWidget(editBox, 1); |
|
53 |
||
54 |
dialogLayout->addStretch(1); |
|
55 |
||
56 |
// Buttons |
|
57 |
QHBoxLayout * buttonLayout = new QHBoxLayout(); |
|
58 |
buttonLayout->addStretch(1); |
|
59 |
dialogLayout->addLayout(buttonLayout); |
|
60 |
||
61 |
QPushButton * btnCancel = new QPushButton(tr("Cancel")); |
|
62 |
QPushButton * btnOkay = new QPushButton(tr("Create room")); |
|
63 |
connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject())); |
|
64 |
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
|
65 |
#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
|
66 |
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
|
67 |
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
|
68 |
#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
|
69 |
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
|
70 |
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
|
71 |
#endif |
8456 | 72 |
btnOkay->setDefault(true); |
73 |
||
74 |
setStyleSheet("QPushButton { padding: 5px; }"); |
|
75 |
||
76 |
connect(btnOkay, SIGNAL(clicked()), this, SLOT(setRoomName())); |
|
77 |
} |
|
78 |
||
79 |
void RoomNamePrompt::setRoomName() |
|
80 |
{ |
|
81 |
emit roomNameChosen(editBox->text()); |
|
82 |
} |