QTfrontend/pagenetserver.cpp
author nemo
Sun, 11 Sep 2011 21:32:49 -0400
changeset 5872 454f246fe4c5
parent 5204 e1a5f4d5d86a
child 6009 14f6fc9869f2
permissions -rw-r--r--
uh, that was just so I could look at the flame more closely, wasn't supposed to be checked in
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
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     3
 * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
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>
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    20
#include <QPushButton>
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    21
#include <QGroupBox>
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    22
#include <QLabel>
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    23
#include <QLineEdit>
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    24
#include <QSpinBox>
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    25
5204
e1a5f4d5d86a split pages.h into several header files
koda
parents: 5080
diff changeset
    26
#include "pagenetserver.h"
5080
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    27
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    28
PageNetServer::PageNetServer(QWidget* parent) : AbstractPage(parent)
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    29
{
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    30
    QFont * font14 = new QFont("MS Shell Dlg", 14);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    31
    QGridLayout * pageLayout = new QGridLayout(this);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    32
    pageLayout->setColumnStretch(0, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    33
    pageLayout->setColumnStretch(1, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    34
    pageLayout->setColumnStretch(2, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    35
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    36
    pageLayout->setRowStretch(0, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    37
    pageLayout->setRowStretch(1, 0);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    38
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    39
    BtnBack =addButton(":/res/Exit.png", pageLayout, 1, 0, true);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    40
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    41
    BtnStart = new QPushButton(this);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    42
    BtnStart->setFont(*font14);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    43
    BtnStart->setText(QPushButton::tr("Start"));
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    44
    pageLayout->addWidget(BtnStart, 1, 2);
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
    QWidget * wg = new QWidget(this);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    47
    pageLayout->addWidget(wg, 0, 0, 1, 3);
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 * wgLayout = new QGridLayout(wg);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    50
    wgLayout->setColumnStretch(0, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    51
    wgLayout->setColumnStretch(1, 3);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    52
    wgLayout->setColumnStretch(2, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    53
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    54
    wgLayout->setRowStretch(0, 0);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    55
    wgLayout->setRowStretch(1, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    56
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    57
    QGroupBox * gb = new QGroupBox(wg);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    58
    wgLayout->addWidget(gb, 0, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    59
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    60
    QGridLayout * gbLayout = new QGridLayout(gb);
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
    labelSD = new QLabel(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    63
    labelSD->setText(QLabel::tr("Server name:"));
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    64
    gbLayout->addWidget(labelSD, 0, 0);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    65
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    66
    leServerDescr = new QLineEdit(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    67
    gbLayout->addWidget(leServerDescr, 0, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    68
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    69
    labelPort = new QLabel(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    70
    labelPort->setText(QLabel::tr("Server port:"));
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    71
    gbLayout->addWidget(labelPort, 1, 0);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    72
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    73
    sbPort = new QSpinBox(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    74
    sbPort->setMinimum(0);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    75
    sbPort->setMaximum(65535);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    76
    gbLayout->addWidget(sbPort, 1, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    77
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    78
    BtnDefault = new QPushButton(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    79
    BtnDefault->setText(QPushButton::tr("default"));
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    80
    gbLayout->addWidget(BtnDefault, 1, 2);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    81
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    82
    connect(BtnDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort()));
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    83
}
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    84
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    85
void PageNetServer::setDefaultPort()
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    86
{
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    87
    sbPort->setValue(46631);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    88
}