26 #include "pagenetgame.h" |
26 #include "pagenetgame.h" |
27 #include "gamecfgwidget.h" |
27 #include "gamecfgwidget.h" |
28 #include "teamselect.h" |
28 #include "teamselect.h" |
29 #include "chatwidget.h" |
29 #include "chatwidget.h" |
30 |
30 |
|
31 const int cutoffHeight = 688; /* Don't make this number below 605, or else it'll |
|
32 let the GameCFGWidget shrink too much before switching to tabbed mode. */ |
|
33 |
31 QLayout * PageNetGame::bodyLayoutDefinition() |
34 QLayout * PageNetGame::bodyLayoutDefinition() |
32 { |
35 { |
33 QGridLayout * pageLayout = new QGridLayout(); |
36 QGridLayout * pageLayout = new QGridLayout(); |
34 pageLayout->setSizeConstraint(QLayout::SetMinimumSize); |
37 pageLayout->setSizeConstraint(QLayout::SetMinimumSize); |
35 //pageLayout->setSpacing(1); |
38 pageLayout->setColumnStretch(0, 1); |
36 pageLayout->setColumnStretch(0, 50); |
39 pageLayout->setColumnStretch(1, 1); |
37 pageLayout->setColumnStretch(1, 50); |
40 pageLayout->setRowStretch(0, 0); |
38 |
41 pageLayout->setRowStretch(1, 0); |
39 // chatwidget |
42 pageLayout->setRowStretch(2, 1); |
|
43 |
|
44 // Room config |
|
45 |
|
46 QHBoxLayout * roomConfigLayout = new QHBoxLayout(); |
|
47 pageLayout->addLayout(roomConfigLayout, 0, 0, 1, 2); |
|
48 roomConfigLayout->setSpacing(0); |
|
49 |
|
50 leRoomName = new HistoryLineEdit(this, 10); |
|
51 leRoomName->setMaxLength(60); |
|
52 leRoomName->setMinimumWidth(400); |
|
53 leRoomName->setMaximumWidth(600); |
|
54 leRoomName->setFixedHeight(30); |
|
55 leRoomName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
56 roomConfigLayout->addWidget(leRoomName, 100); |
|
57 |
|
58 QLabel * lblRoomName = new QLabel(tr("Room name: "), leRoomName); |
|
59 lblRoomName->setStyleSheet("font: 12px; font-weight: bold;"); |
|
60 lblRoomName->setStyleSheet(QString("font: 12px; font-weight: bold; background: none; margin-left: -%1px; margin-top: 8px;").arg(lblRoomName->width() - 20)); |
|
61 leRoomName->setStyleSheet(QString("font: 12px; border-right: 0; padding-left: %1px; padding-bottom: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px;").arg(lblRoomName->width() - 14)); |
|
62 |
|
63 BtnUpdate = new QPushButton(); |
|
64 BtnUpdate->setEnabled(false); |
|
65 BtnUpdate->setText(tr("Update")); |
|
66 BtnUpdate->setFixedHeight(leRoomName->height() - 0); |
|
67 BtnUpdate->setStyleSheet("border-top-left-radius: 0px; border-bottom-left-radius: 0px; padding: auto 4px;"); |
|
68 roomConfigLayout->addWidget(BtnUpdate, 0); |
|
69 |
|
70 lblRoomNameReadOnly = new QLabel(); |
|
71 lblRoomNameReadOnly->setMinimumWidth(400); |
|
72 lblRoomNameReadOnly->setMaximumWidth(600); |
|
73 lblRoomNameReadOnly->setFixedHeight(30); |
|
74 lblRoomNameReadOnly->setObjectName("labelLikeLineEdit"); |
|
75 lblRoomNameReadOnly->setStyleSheet("font: 12px;"); |
|
76 lblRoomNameReadOnly->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
77 lblRoomNameReadOnly->setVisible(false); |
|
78 roomConfigLayout->addWidget(lblRoomNameReadOnly, 100); |
|
79 |
|
80 roomConfigLayout->addSpacing(10); |
|
81 |
|
82 BtnMaster = new QPushButton(); |
|
83 BtnMaster->setText(tr("Room controls")); |
|
84 BtnMaster->setFixedHeight(leRoomName->height() - 0); |
|
85 BtnMaster->setStyleSheet("QPushButton { padding: auto 4px; } QPushButton:pressed { background-color: #ffcc00; border-color: #ffcc00; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; color: #11084A; }"); |
|
86 roomConfigLayout->addWidget(BtnMaster, 0); |
|
87 |
|
88 roomConfigLayout->addStretch(1); |
|
89 |
|
90 // Game config |
|
91 |
|
92 pGameCFG = new GameCFGWidget(this); |
|
93 pageLayout->addWidget(pGameCFG, 1, 0); |
|
94 |
|
95 // Teams |
|
96 |
|
97 pNetTeamsWidget = new TeamSelWidget(this); |
|
98 pNetTeamsWidget->setAcceptOuter(true); |
|
99 pNetTeamsWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
100 pageLayout->addWidget(pNetTeamsWidget, 1, 1); |
|
101 |
|
102 // Chat |
|
103 |
40 chatWidget = new HWChatWidget(this, true); |
104 chatWidget = new HWChatWidget(this, true); |
41 chatWidget->setShowFollow(false); // don't show follow in nicks' context menus |
105 chatWidget->setShowFollow(false); // don't show follow in nicks' context menus |
42 chatWidget->setIgnoreListKick(true); // kick ignored players automatically |
106 chatWidget->setIgnoreListKick(true); // kick ignored players automatically |
|
107 chatWidget->setMinimumHeight(50); |
|
108 chatWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); |
43 pageLayout->addWidget(chatWidget, 2, 0, 1, 2); |
109 pageLayout->addWidget(chatWidget, 2, 0, 1, 2); |
44 pageLayout->setRowStretch(1, 100); |
|
45 pageLayout->setRowStretch(2, 100); |
|
46 |
|
47 pGameCFG = new GameCFGWidget(this); |
|
48 pageLayout->addWidget(pGameCFG, 0, 0); |
|
49 |
|
50 btnSetup = new QPushButton(this); |
|
51 btnSetup->setText(QPushButton::tr("Setup")); |
|
52 pageLayout->addWidget(btnSetup, 1, 0); |
|
53 |
|
54 pNetTeamsWidget = new TeamSelWidget(this); |
|
55 pNetTeamsWidget->setAcceptOuter(true); |
|
56 pageLayout->addWidget(pNetTeamsWidget, 0, 1, 2, 1); |
|
57 |
110 |
58 return pageLayout; |
111 return pageLayout; |
59 } |
112 } |
60 |
113 |
|
114 QLayout * PageNetGame::footerLayoutLeftDefinition() |
|
115 { |
|
116 QHBoxLayout * bottomLeftLayout = new QHBoxLayout(); |
|
117 |
|
118 btnSetup = addButton(":/res/Settings.png", bottomLeftLayout, 0, true); |
|
119 btnSetup->setWhatsThis(tr("Edit game preferences")); |
|
120 |
|
121 return bottomLeftLayout; |
|
122 } |
|
123 |
61 QLayout * PageNetGame::footerLayoutDefinition() |
124 QLayout * PageNetGame::footerLayoutDefinition() |
62 { |
125 { |
63 QHBoxLayout * bottomLayout = new QHBoxLayout; |
126 QHBoxLayout * bottomLayout = new QHBoxLayout; |
64 |
127 |
65 leRoomName = new HistoryLineEdit(this,10); |
128 // Ready button |
66 leRoomName->setMaxLength(60); |
129 |
67 leRoomName->setMinimumWidth(200); |
|
68 leRoomName->setMaximumWidth(400); |
|
69 |
|
70 //Button to signify whether the player is ready to start playing |
|
71 BtnGo = new QPushButton(this); |
130 BtnGo = new QPushButton(this); |
72 BtnGo->setToolTip(QPushButton::tr("Ready")); |
|
73 BtnGo->setIcon(QIcon(":/res/lightbulb_off.png")); |
131 BtnGo->setIcon(QIcon(":/res/lightbulb_off.png")); |
74 BtnGo->setIconSize(QSize(25, 34)); |
132 BtnGo->setIconSize(QSize(25, 34)); |
75 BtnGo->setMinimumWidth(50); |
133 BtnGo->setMinimumWidth(50); |
76 BtnGo->setMinimumHeight(50); |
134 BtnGo->setMinimumHeight(50); |
77 |
135 |
78 bottomLayout->addWidget(leRoomName); |
|
79 BtnUpdate = addButton(QAction::tr("Update"), bottomLayout, 1); |
|
80 |
|
81 bottomLayout->addStretch(); |
136 bottomLayout->addStretch(); |
82 bottomLayout->addWidget(BtnGo); |
137 bottomLayout->addWidget(BtnGo); |
83 |
138 |
84 BtnMaster = addButton(tr("Control"), bottomLayout, 3); |
139 // Start button |
85 bottomLayout->insertStretch(3, 100); |
140 |
86 |
141 const QIcon& lp = QIcon(":/res/Start.png"); |
87 BtnStart = addButton(QAction::tr("Start"), bottomLayout, 3); |
142 QSize sz = lp.actualSize(QSize(65535, 65535)); |
|
143 BtnStart = new QPushButton(); |
|
144 BtnStart->setText(tr("Start")); |
|
145 BtnStart->setMinimumWidth(sz.width() + 60); |
|
146 BtnStart->setIcon(lp); |
|
147 BtnStart->setFixedHeight(50); |
|
148 BtnStart->setIconSize(sz); |
|
149 BtnStart->setFlat(true); |
|
150 BtnStart->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
|
151 bottomLayout->addWidget(BtnStart); |
88 |
152 |
89 return bottomLayout; |
153 return bottomLayout; |
90 } |
154 } |
91 |
155 |
92 void PageNetGame::connectSignals() |
156 void PageNetGame::connectSignals() |
93 { |
157 { |
94 connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked())); |
158 connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked())); |
95 |
159 |
96 connect(BtnUpdate, SIGNAL(clicked()), this, SLOT(onUpdateClick())); |
160 connect(BtnUpdate, SIGNAL(clicked()), this, SLOT(onUpdateClick())); |
|
161 connect(leRoomName, SIGNAL(returnPressed()), this, SLOT(onUpdateClick())); |
|
162 |
|
163 connect(leRoomName, SIGNAL(textChanged(const QString &)), this, SLOT(onRoomNameEdited())); |
97 } |
164 } |
98 |
165 |
99 PageNetGame::PageNetGame(QWidget* parent) : AbstractPage(parent) |
166 PageNetGame::PageNetGame(QWidget* parent) : AbstractPage(parent) |
100 { |
167 { |
101 initPage(); |
168 initPage(); |