QTfrontend/ui/page/pagenetserver.cpp
author sheepluva
Fri, 15 Mar 2013 11:12:42 +0100
changeset 8731 924840dad6a0
parent 8609 3f6c08223aa1
child 8747 878aa4c92424
permissions -rw-r--r--
fix compilation with clang. fixes issue #553 - thanks to julien for reporting and to drew for the first part of the fix
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5080
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     1
/*
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
6952
7f70f37bbf08 license header year range adjustments
sheepluva
parents: 6700
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
5080
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     4
 *
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     8
 *
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    12
 * GNU General Public License for more details.
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    13
 *
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    17
 */
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    18
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    19
#include <QGridLayout>
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
    20
#include <QHBoxLayout>
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
    21
#include <QVBoxLayout>
5080
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    22
#include <QPushButton>
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    23
#include <QGroupBox>
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    24
#include <QLabel>
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    25
#include <QLineEdit>
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    26
#include <QSpinBox>
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    27
5204
e1a5f4d5d86a split pages.h into several header files
koda
parents: 5080
diff changeset
    28
#include "pagenetserver.h"
8609
3f6c08223aa1 use NETGAME_DEFAULT_PORT macro across frontend sources
koda
parents: 6952
diff changeset
    29
#include "hwconsts.h"
5080
2e29c1e1c9cd I forgot to add this file.
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 * PageNetServer::bodyLayoutDefinition()
5080
2e29c1e1c9cd I forgot to add this file.
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
    QVBoxLayout * pageLayout = new QVBoxLayout();
5080
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    34
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    35
    QWidget * wg = new QWidget(this);
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
    36
    pageLayout->addWidget(wg);
5080
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    37
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    38
    QGridLayout * wgLayout = new QGridLayout(wg);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    39
    wgLayout->setColumnStretch(0, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    40
    wgLayout->setColumnStretch(1, 3);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    41
    wgLayout->setColumnStretch(2, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    42
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    43
    wgLayout->setRowStretch(0, 0);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    44
    wgLayout->setRowStretch(1, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    45
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    46
    QGroupBox * gb = new QGroupBox(wg);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    47
    wgLayout->addWidget(gb, 0, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    48
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    49
    QGridLayout * gbLayout = new QGridLayout(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    50
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    51
    labelSD = new QLabel(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    52
    labelSD->setText(QLabel::tr("Server name:"));
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    53
    gbLayout->addWidget(labelSD, 0, 0);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    54
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    55
    leServerDescr = new QLineEdit(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    56
    gbLayout->addWidget(leServerDescr, 0, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    57
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    58
    labelPort = new QLabel(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    59
    labelPort->setText(QLabel::tr("Server port:"));
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    60
    gbLayout->addWidget(labelPort, 1, 0);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    61
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    62
    sbPort = new QSpinBox(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    63
    sbPort->setMinimum(0);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    64
    sbPort->setMaximum(65535);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    65
    gbLayout->addWidget(sbPort, 1, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    66
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    67
    BtnDefault = new QPushButton(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    68
    BtnDefault->setText(QPushButton::tr("default"));
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    69
    gbLayout->addWidget(BtnDefault, 1, 2);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    70
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
    71
    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
    72
}
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
    73
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
    74
QLayout * PageNetServer::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
    75
{
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
    76
    QHBoxLayout * bottomLayout = new QHBoxLayout();
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
    77
6171
8627698134b6 fix layout of net page
sheepluva
parents: 6060
diff changeset
    78
    BtnStart = formattedButton(QPushButton::tr("Start"));
8627698134b6 fix layout of net page
sheepluva
parents: 6060
diff changeset
    79
    BtnStart->setMinimumWidth(180);
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
    80
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
    81
    bottomLayout->addStretch();
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
    82
    bottomLayout->addWidget(BtnStart);
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
    83
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
    84
    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
    85
}
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
    86
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
    87
void PageNetServer::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
    88
{
5080
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    89
    connect(BtnDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort()));
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    90
}
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    91
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
    92
PageNetServer::PageNetServer(QWidget* parent) : AbstractPage(parent)
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
    93
{
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
    94
    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
    95
}
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
    96
5080
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    97
void PageNetServer::setDefaultPort()
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    98
{
8609
3f6c08223aa1 use NETGAME_DEFAULT_PORT macro across frontend sources
koda
parents: 6952
diff changeset
    99
    sbPort->setValue(NETGAME_DEFAULT_PORT);
5080
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   100
}