QTfrontend/ui/page/pagenetgame.cpp
author dag10
Mon, 21 Jan 2013 00:30:18 -0500
changeset 8415 02acf6b92f52
parent 8382 67e257b98422
child 8424 225ede46e3dc
permissions -rw-r--r--
Moved room name edit box from footer to top of page. Also shows room name when in slave mode. Temporarily increased HWForm's min height from 580 to 610.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     1
/*
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
6952
7f70f37bbf08 license header year range adjustments
sheepluva
parents: 6929
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     4
 *
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     8
 *
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    12
 * GNU General Public License for more details.
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    13
 *
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    17
 */
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    18
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    19
#include <QGridLayout>
6171
8627698134b6 fix layout of net page
sheepluva
parents: 6165
diff changeset
    20
#include <QHBoxLayout>
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    21
#include <QPushButton>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    22
#include <QAction>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    23
#include <QMenu>
5126
50803f3403a5 Frontend: room rename
claymore
parents: 5078
diff changeset
    24
#include <QMessageBox>
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    25
5204
e1a5f4d5d86a split pages.h into several header files
koda
parents: 5126
diff changeset
    26
#include "pagenetgame.h"
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    27
#include "gamecfgwidget.h"
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    28
#include "teamselect.h"
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    29
#include "chatwidget.h"
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    30
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    31
QLayout * PageNetGame::bodyLayoutDefinition()
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    32
{
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    33
    QGridLayout * pageLayout = new QGridLayout();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    34
    pageLayout->setSizeConstraint(QLayout::SetMinimumSize);
8415
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    35
    pageLayout->setColumnStretch(0, 1);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    36
    pageLayout->setColumnStretch(1, 1);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    37
    pageLayout->setRowStretch(0, 0);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    38
    pageLayout->setRowStretch(1, 1);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    39
    pageLayout->setRowStretch(2, 1);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    40
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    41
    // Room config
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    42
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    43
    QHBoxLayout * roomConfigLayout = new QHBoxLayout();
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    44
    pageLayout->addLayout(roomConfigLayout, 0, 0, 1, 2);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    45
    roomConfigLayout->setSpacing(0);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    46
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    47
    leRoomName = new HistoryLineEdit(this, 10);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    48
    leRoomName->setMaxLength(60);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    49
    leRoomName->setMinimumWidth(400);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    50
    leRoomName->setMaximumWidth(600);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    51
    leRoomName->setFixedHeight(30);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    52
    leRoomName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    53
    roomConfigLayout->addWidget(leRoomName, 100);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    54
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    55
    QLabel * lblRoomName = new QLabel(tr("Room name: "), leRoomName);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    56
    lblRoomName->setStyleSheet("font: 12px; font-weight: bold;");
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    57
    lblRoomName->setStyleSheet(QString("font: 12px; font-weight: bold; background: none; margin-left: -%1px; margin-top: 8px;").arg(lblRoomName->width() - 20));
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    58
    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));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    59
8415
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    60
    BtnUpdate = new QPushButton();
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    61
    BtnUpdate->setEnabled(false);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    62
    BtnUpdate->setText(tr("Update"));
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    63
    BtnUpdate->setFixedHeight(leRoomName->height() - 0);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    64
    BtnUpdate->setStyleSheet("border-top-left-radius: 0px; border-bottom-left-radius: 0px; padding: auto 4px;");
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    65
    roomConfigLayout->addWidget(BtnUpdate, 0);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    66
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    67
    lblRoomNameReadOnly = new QLabel();
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    68
    lblRoomNameReadOnly->setMinimumWidth(400);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    69
    lblRoomNameReadOnly->setMaximumWidth(600);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    70
    lblRoomNameReadOnly->setFixedHeight(30);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    71
    lblRoomNameReadOnly->setObjectName("labelLikeLineEdit");
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    72
    lblRoomNameReadOnly->setStyleSheet("font: 12px;");
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    73
    lblRoomNameReadOnly->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    74
    lblRoomNameReadOnly->setVisible(false);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    75
    roomConfigLayout->addWidget(lblRoomNameReadOnly, 100);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    76
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    77
    roomConfigLayout->addSpacing(10);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    78
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    79
    BtnMaster = new QPushButton();
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    80
    BtnMaster->setText(tr("Room controls"));
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    81
    BtnMaster->setFixedHeight(leRoomName->height() - 0);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    82
    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; }");
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    83
    roomConfigLayout->addWidget(BtnMaster, 0);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    84
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    85
    roomConfigLayout->addStretch(1);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    86
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    87
    // Game config
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    88
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    89
    pGameCFG = new GameCFGWidget(this);
8415
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    90
    pageLayout->addWidget(pGameCFG, 1, 0);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    91
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    92
    // Teams
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    93
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    94
    pNetTeamsWidget = new TeamSelWidget(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    95
    pNetTeamsWidget->setAcceptOuter(true);
8377
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
    96
    pNetTeamsWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
8415
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    97
    pageLayout->addWidget(pNetTeamsWidget, 1, 1, 1, 1);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    98
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
    99
    // Chat
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   100
    
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   101
    chatWidget = new HWChatWidget(this, true);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   102
    chatWidget->setShowFollow(false); // don't show follow in nicks' context menus
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   103
    chatWidget->setIgnoreListKick(true); // kick ignored players automatically
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   104
    pageLayout->addWidget(chatWidget, 2, 0, 1, 2);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   105
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   106
    return pageLayout;
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   107
}
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   108
8377
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   109
QLayout * PageNetGame::footerLayoutLeftDefinition()
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   110
{
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   111
    QHBoxLayout * bottomLeftLayout = new QHBoxLayout();
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   112
    
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   113
    btnSetup = addButton(":/res/Settings.png", bottomLeftLayout, 0, true);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   114
    btnSetup->setWhatsThis(tr("Edit game preferences"));
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   115
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   116
    return bottomLeftLayout;
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   117
}
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   118
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   119
QLayout * PageNetGame::footerLayoutDefinition()
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   120
{
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   121
    QHBoxLayout * bottomLayout = new QHBoxLayout;
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   122
8415
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   123
    // Ready button
5126
50803f3403a5 Frontend: room rename
claymore
parents: 5078
diff changeset
   124
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   125
    BtnGo = new QPushButton(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   126
    BtnGo->setIcon(QIcon(":/res/lightbulb_off.png"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   127
    BtnGo->setIconSize(QSize(25, 34));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   128
    BtnGo->setMinimumWidth(50);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   129
    BtnGo->setMinimumHeight(50);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   130
6173
6cb88fec7a79 fix netgame layout issues, I think all layout issues caused by page refactoring are fixed now, if you find any more let me know
sheepluva
parents: 6171
diff changeset
   131
    bottomLayout->addStretch();
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   132
    bottomLayout->addWidget(BtnGo);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   133
8415
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   134
    // Start button
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   135
8377
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   136
    const QIcon& lp = QIcon(":/res/Start.png");
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   137
    QSize sz = lp.actualSize(QSize(65535, 65535));
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   138
    BtnStart = new QPushButton();
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   139
    BtnStart->setText(tr("Start"));
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   140
    BtnStart->setMinimumWidth(sz.width() + 60);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   141
    BtnStart->setIcon(lp);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   142
    BtnStart->setFixedHeight(50);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   143
    BtnStart->setIconSize(sz);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   144
    BtnStart->setFlat(true);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   145
    BtnStart->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
869f80966a77 GCI2012: Improve Game Configuration Widget
dag10
parents: 8179
diff changeset
   146
    bottomLayout->addWidget(BtnStart);
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   147
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   148
    return bottomLayout;
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   149
}
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   150
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   151
void PageNetGame::connectSignals()
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   152
{
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   153
    connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked()));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   154
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   155
    connect(BtnUpdate, SIGNAL(clicked()), this, SLOT(onUpdateClick()));
8415
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   156
    connect(leRoomName, SIGNAL(returnPressed()), this, SLOT(onUpdateClick()));
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   157
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   158
    connect(leRoomName, SIGNAL(textChanged(const QString &)), this, SLOT(onRoomNameEdited()));
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   159
}
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   160
8179
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7853
diff changeset
   161
PageNetGame::PageNetGame(QWidget* parent) : AbstractPage(parent)
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   162
{
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   163
    initPage();
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   164
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   165
    QMenu * menu = new QMenu(BtnMaster);
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   166
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   167
    restrictJoins = new QAction(QAction::tr("Restrict Joins"), menu);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   168
    restrictJoins->setCheckable(true);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   169
    restrictTeamAdds = new QAction(QAction::tr("Restrict Team Additions"), menu);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   170
    restrictTeamAdds->setCheckable(true);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   171
    menu->addAction(restrictJoins);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   172
    menu->addAction(restrictTeamAdds);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   173
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   174
    BtnMaster->setMenu(menu);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   175
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   176
6180
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   177
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   178
void PageNetGame::displayError(const QString & message)
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   179
{
8179
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7853
diff changeset
   180
    chatWidget->displayError(message);
6180
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   181
}
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   182
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   183
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   184
void PageNetGame::displayNotice(const QString & message)
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   185
{
8179
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7853
diff changeset
   186
    chatWidget->displayNotice(message);
6180
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   187
}
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   188
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   189
void PageNetGame::displayWarning(const QString & message)
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   190
{
8179
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7853
diff changeset
   191
    chatWidget->displayWarning(message);
6180
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   192
}
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   193
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6173
diff changeset
   194
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   195
void PageNetGame::setReadyStatus(bool isReady)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   196
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   197
    if(isReady)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   198
        BtnGo->setIcon(QIcon(":/res/lightbulb_on.png"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   199
    else
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   200
        BtnGo->setIcon(QIcon(":/res/lightbulb_off.png"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   201
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   202
8415
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   203
void PageNetGame::onRoomNameEdited()
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   204
{
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   205
    BtnUpdate->setEnabled(true);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   206
}
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   207
5126
50803f3403a5 Frontend: room rename
claymore
parents: 5078
diff changeset
   208
void PageNetGame::onUpdateClick()
50803f3403a5 Frontend: room rename
claymore
parents: 5078
diff changeset
   209
{
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   210
    if (!leRoomName->text().trimmed().isEmpty())
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   211
    {
5126
50803f3403a5 Frontend: room rename
claymore
parents: 5078
diff changeset
   212
        emit askForUpdateRoomName(leRoomName->text());
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   213
        leRoomName->rememberCurrentText();
8415
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   214
        BtnUpdate->setEnabled(false);
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   215
    }
5126
50803f3403a5 Frontend: room rename
claymore
parents: 5078
diff changeset
   216
    else
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   217
    {
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   218
        leRoomName->clear();
7794
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7720
diff changeset
   219
        QMessageBox roomMsg(this);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7720
diff changeset
   220
        roomMsg.setIcon(QMessageBox::Warning);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7720
diff changeset
   221
        roomMsg.setWindowTitle(QMessageBox::tr("Netgame - Error"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7720
diff changeset
   222
        roomMsg.setText(QMessageBox::tr("Please enter room name"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7720
diff changeset
   223
        roomMsg.setWindowModality(Qt::WindowModal);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7720
diff changeset
   224
        roomMsg.exec();
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   225
    }
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   226
}
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   227
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   228
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   229
void PageNetGame::setRoomName(const QString & roomName)
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   230
{
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   231
    leRoomName->setText(roomName);
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   232
    leRoomName->rememberCurrentText();
8415
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   233
    lblRoomNameReadOnly->setText(roomName);
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   234
    BtnUpdate->setEnabled(false);
5126
50803f3403a5 Frontend: room rename
claymore
parents: 5078
diff changeset
   235
}
50803f3403a5 Frontend: room rename
claymore
parents: 5078
diff changeset
   236
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   237
void PageNetGame::setMasterMode(bool isMaster)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   238
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   239
    BtnMaster->setVisible(isMaster);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   240
    BtnStart->setVisible(isMaster);
5126
50803f3403a5 Frontend: room rename
claymore
parents: 5078
diff changeset
   241
    BtnUpdate->setVisible(isMaster);
50803f3403a5 Frontend: room rename
claymore
parents: 5078
diff changeset
   242
    leRoomName->setVisible(isMaster);
8415
02acf6b92f52 Moved room name edit box from footer to top of page. Also shows room name when in slave mode.
dag10
parents: 8382
diff changeset
   243
    lblRoomNameReadOnly->setVisible(!isMaster);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   244
}
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents: 6060
diff changeset
   245
6227
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6200
diff changeset
   246
void PageNetGame::setUser(const QString & nickname)
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6200
diff changeset
   247
{
8179
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7853
diff changeset
   248
    chatWidget->setUser(nickname);
6227
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6200
diff changeset
   249
}