QTfrontend/input_ip.cpp
author nemo
Sun, 12 Jun 2011 14:45:26 -0400
changeset 5237 963d787a25c2
parent 4976 088d40d8aba2
permissions -rw-r--r--
If 2 or more resolutions are available, use the 2nd in the list. This should (usually) be smaller than the desktop resolution, which should reduce noob fail (not realising part of interface is obscured)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
653
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
     1
/*
1066
1f1b3686a2b0 Update copyright headers a bit
unc0rr
parents: 883
diff changeset
     2
 * Hedgewars, a free turn based strategy game
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 3236
diff changeset
     3
 * Copyright (c) 2007-2011 Andrey Korotaev <unC0Rr@gmail.com>
653
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
     4
 *
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
     8
 *
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    12
 * GNU General Public License for more details.
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    13
 *
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    17
 */
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    18
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    19
#include <QLineEdit>
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    20
#include <QSpinBox>
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    21
#include <QPushButton>
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    22
#include <QGridLayout>
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    23
#include <QLabel>
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    24
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    25
#include "input_ip.h"
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    26
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    27
HWHostPortDialog::HWHostPortDialog(QWidget* parent) : QDialog(parent)
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    28
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    29
    QGridLayout * layout = new QGridLayout(this);
653
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    30
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    31
    QLabel * lbHost = new QLabel(this);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    32
    lbHost->setText(QLabel::tr("Host:"));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    33
    layout->addWidget(lbHost, 0, 0);
653
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    34
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    35
    QLabel * lbPort = new QLabel(this);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    36
    lbPort->setText(QLabel::tr("Port:"));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    37
    layout->addWidget(lbPort, 1, 0);
653
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    38
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    39
    leHost = new QLineEdit(this);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    40
    layout->addWidget(leHost, 0, 1, 1, 2);
653
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    41
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    42
    sbPort = new QSpinBox(this);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    43
    sbPort->setMinimum(0);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    44
    sbPort->setMaximum(65535);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    45
    layout->addWidget(sbPort, 1, 1, 1, 2);
653
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    46
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    47
    pbDefault = new QPushButton(this);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    48
    pbDefault->setText(QPushButton::tr("default"));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    49
    layout->addWidget(pbDefault, 1, 3);
653
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    50
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    51
    pbOK = new QPushButton(this);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    52
    pbOK->setText(QPushButton::tr("OK"));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    53
    pbOK->setDefault(true);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    54
    layout->addWidget(pbOK, 3, 1);
653
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    55
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    56
    pbCancel = new QPushButton(this);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    57
    pbCancel->setText(QPushButton::tr("Cancel"));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    58
    layout->addWidget(pbCancel, 3, 2);
653
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    59
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    60
    connect(pbOK, SIGNAL(clicked()), this, SLOT(accept()));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    61
    connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject()));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    62
    connect(pbDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort()));
653
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    63
}
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    64
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    65
void HWHostPortDialog::setDefaultPort()
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    66
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 1066
diff changeset
    67
    sbPort->setValue(46631);
653
4f44fc06ca45 Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
diff changeset
    68
}