QTfrontend/pagenetserver.cpp
author koda
Sun, 25 Sep 2011 03:32:07 +0200
changeset 6021 652a199d4f38
parent 6009 14f6fc9869f2
child 6042 8b5345758f62
permissions -rw-r--r--
some hopefully harmless experiments
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
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5204
diff changeset
    39
5080
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    40
    BtnBack =addButton(":/res/Exit.png", pageLayout, 1, 0, true);
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5204
diff changeset
    41
    connect(BtnBack, SIGNAL(clicked()), this, SIGNAL(goBack()));
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5204
diff changeset
    42
5080
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    43
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    44
    BtnStart = new QPushButton(this);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    45
    BtnStart->setFont(*font14);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    46
    BtnStart->setText(QPushButton::tr("Start"));
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    47
    pageLayout->addWidget(BtnStart, 1, 2);
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
    QWidget * wg = new QWidget(this);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    50
    pageLayout->addWidget(wg, 0, 0, 1, 3);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    51
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    52
    QGridLayout * wgLayout = new QGridLayout(wg);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    53
    wgLayout->setColumnStretch(0, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    54
    wgLayout->setColumnStretch(1, 3);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    55
    wgLayout->setColumnStretch(2, 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
    wgLayout->setRowStretch(0, 0);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    58
    wgLayout->setRowStretch(1, 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
    QGroupBox * gb = new QGroupBox(wg);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    61
    wgLayout->addWidget(gb, 0, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    62
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    63
    QGridLayout * gbLayout = new QGridLayout(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    64
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    65
    labelSD = new QLabel(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    66
    labelSD->setText(QLabel::tr("Server name:"));
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    67
    gbLayout->addWidget(labelSD, 0, 0);
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
    leServerDescr = new QLineEdit(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    70
    gbLayout->addWidget(leServerDescr, 0, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    71
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    72
    labelPort = new QLabel(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    73
    labelPort->setText(QLabel::tr("Server port:"));
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    74
    gbLayout->addWidget(labelPort, 1, 0);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    75
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    76
    sbPort = new QSpinBox(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    77
    sbPort->setMinimum(0);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    78
    sbPort->setMaximum(65535);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    79
    gbLayout->addWidget(sbPort, 1, 1);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    80
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    81
    BtnDefault = new QPushButton(gb);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    82
    BtnDefault->setText(QPushButton::tr("default"));
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    83
    gbLayout->addWidget(BtnDefault, 1, 2);
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
    connect(BtnDefault, SIGNAL(clicked()), this, SLOT(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
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    88
void PageNetServer::setDefaultPort()
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    89
{
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    90
    sbPort->setValue(46631);
2e29c1e1c9cd I forgot to add this file.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    91
}