QTfrontend/ui/page/pagemain.cpp
author unc0rr
Fri, 04 Jan 2013 21:44:40 +0400
branchflibqtfrontend
changeset 8363 0b4ac686fc44
parent 8361 2831c1403666
permissions -rw-r--r--
Merge from default
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: 6759
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
 */
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6586
diff changeset
    18
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
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: 5763
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 <QLabel>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    23
#include <QTime>
8363
0b4ac686fc44 Merge from default
unc0rr
parents: 8361
diff changeset
    24
#include <QTextStream>
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: 5078
diff changeset
    26
#include "pagemain.h"
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    27
#include "hwconsts.h"
5205
78138ae93820 some headers cleanup and rename of stats and playrecord pages for consistency
koda
parents: 5204
diff changeset
    28
#include "hwform.h"
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    29
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: 5763
diff changeset
    30
QLayout * PageMain::bodyLayoutDefinition()
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    31
{
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: 5763
diff changeset
    32
    QGridLayout * pageLayout = new QGridLayout();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    33
    //pageLayout->setColumnStretch(0, 1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    34
    //pageLayout->setColumnStretch(1, 2);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    35
    //pageLayout->setColumnStretch(2, 1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    36
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    37
    //QPushButton* btnLogo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    38
    //pageLayout->setAlignment(btnLogo, Qt::AlignHCenter);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    39
    pageLayout->setRowStretch(0, 1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    40
    pageLayout->setRowStretch(1, 1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    41
    pageLayout->setRowStretch(2, 0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    42
    pageLayout->setRowStretch(3, 1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    43
    pageLayout->setRowStretch(4, 1);
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: 5763
diff changeset
    44
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    45
    BtnSinglePlayer = addButton(":/res/LocalPlay.png", pageLayout, 2, 0, 1, 2, true);
6478
752d4fb5e376 cleanup and example
koda
parents: 6477
diff changeset
    46
    BtnSinglePlayer->setToolTip(tr("Local Game"));
752d4fb5e376 cleanup and example
koda
parents: 6477
diff changeset
    47
    BtnSinglePlayer->setWhatsThis(tr("Play a game on a single computer"));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    48
    pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    49
8318
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    50
    //BtnNet = addButton(":/res/NetworkPlay.png", (QBoxLayout*)netLayout, 1, true);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    51
    BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true);
6478
752d4fb5e376 cleanup and example
koda
parents: 6477
diff changeset
    52
    BtnNet->setToolTip(tr("Network Game"));
752d4fb5e376 cleanup and example
koda
parents: 6477
diff changeset
    53
    BtnNet->setWhatsThis(tr("Play a game across a network"));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    54
    pageLayout->setAlignment(BtnNet, Qt::AlignHCenter);
8318
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    55
    connect(BtnNet, SIGNAL(clicked()), this, SLOT(toggleNetworkChoice()));
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    56
    
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    57
    originalNetworkIcon = BtnNet->icon();
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    58
    disabledNetworkIcon = QIcon(":/res/NetworkPlayDisabled.png");
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    59
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    60
    //QWidget *netLayoutWidget = new QWidget();
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    61
    QVBoxLayout *netLayout = new QVBoxLayout(BtnNet);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    62
    //pageLayout->addWidget(netLayoutWidget, 2, 2, 1, 2);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    63
    //netLayoutWidget->setStyleSheet("background: green;");
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    64
    //netLayoutWidget->setFixedSize(314, 260);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    65
    netLayout->setSpacing(20);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    66
    netLayout->setAlignment(Qt::AlignHCenter);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    67
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    68
    BtnNetLocal = addButton("Play local network game", (QBoxLayout*)netLayout, 0, false);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    69
    BtnNetLocal->setToolTip(tr("Play a local network game"));
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    70
    BtnNetLocal->setWhatsThis(tr("Play a game across a local area network"));
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    71
    BtnNetLocal->setFixedSize(BtnNet->width() - 50, 60);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    72
    BtnNetLocal->setVisible(false);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    73
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    74
    BtnNetOfficial = addButton("Play official network game", (QBoxLayout*)netLayout, 0, false);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    75
    BtnNetOfficial->setToolTip(tr("Play a network game"));
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    76
    BtnNetOfficial->setWhatsThis(tr("Play a game on an official server"));
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    77
    BtnNetOfficial->setFixedSize(BtnNet->width() - 50, 60);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
    78
    BtnNetOfficial->setVisible(false);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    79
6169
582f9f61b972 fix overlapping issue in main menu
sheepluva
parents: 6060
diff changeset
    80
    // button order matters for overlapping (what's on top and what isn't)
582f9f61b972 fix overlapping issue in main menu
sheepluva
parents: 6060
diff changeset
    81
    BtnInfo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true);
582f9f61b972 fix overlapping issue in main menu
sheepluva
parents: 6060
diff changeset
    82
    BtnInfo->setStyleSheet("border: transparent;background: transparent;");
6478
752d4fb5e376 cleanup and example
koda
parents: 6477
diff changeset
    83
    //BtnInfo->setToolTip(tr("Credits")); //tooltip looks horrible with transparent background buttons
752d4fb5e376 cleanup and example
koda
parents: 6477
diff changeset
    84
    BtnInfo->setWhatsThis(tr("Read about who is behind the Hedgewars Project"));
6169
582f9f61b972 fix overlapping issue in main menu
sheepluva
parents: 6060
diff changeset
    85
    pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter);
582f9f61b972 fix overlapping issue in main menu
sheepluva
parents: 6060
diff changeset
    86
6582
d32b5fde9ea6 move the feedback button in a nicer position
koda
parents: 6561
diff changeset
    87
    BtnFeedback = addButton("Feedback", pageLayout, 4, 0, 1, 4, false);
8277
cd2bae15a9a3 hides the 'email' prompt on the feedback page (as that doesn't work, so it's a misleading/useless feature), makes the "please add your email" text a little nicer and more noticeable, and makes the "feedback" and "downloadable content" buttons on the main menu a little bit larger, and more clickable.
Drew Gottlieb
parents: 8176
diff changeset
    88
    BtnFeedback->setFixedSize(86, 27);
6759
700504a608ff bug #370
nemo
parents: 6700
diff changeset
    89
    BtnFeedback->setWhatsThis(tr("Leave a feedback here reporting issues, suggesting features or just saying how you like Hedgewars"));
6582
d32b5fde9ea6 move the feedback button in a nicer position
koda
parents: 6561
diff changeset
    90
    pageLayout->setAlignment(BtnFeedback, Qt::AlignHCenter);
d32b5fde9ea6 move the feedback button in a nicer position
koda
parents: 6561
diff changeset
    91
d32b5fde9ea6 move the feedback button in a nicer position
koda
parents: 6561
diff changeset
    92
    BtnDataDownload = addButton(tr("Downloadable Content"), pageLayout, 5, 0, 1, 4, false);
8277
cd2bae15a9a3 hides the 'email' prompt on the feedback page (as that doesn't work, so it's a misleading/useless feature), makes the "please add your email" text a little nicer and more noticeable, and makes the "feedback" and "downloadable content" buttons on the main menu a little bit larger, and more clickable.
Drew Gottlieb
parents: 8176
diff changeset
    93
    BtnDataDownload->setFixedSize(176, 27);
6478
752d4fb5e376 cleanup and example
koda
parents: 6477
diff changeset
    94
    //BtnDataDownload->setToolTip(tr(Downloadable Content"));
752d4fb5e376 cleanup and example
koda
parents: 6477
diff changeset
    95
    BtnDataDownload->setWhatsThis(tr("Access the user created content downloadable from our website"));
5763
d7a887c7e2d0 Add a crappy button to encourage artists to make another one. Restore Info page.
nemo
parents: 5646
diff changeset
    96
    pageLayout->setAlignment(BtnDataDownload, Qt::AlignHCenter);
d7a887c7e2d0 Add a crappy button to encourage artists to make another one. Restore Info page.
nemo
parents: 5646
diff changeset
    97
6577
9e49e6a8585b disable the glitchy exit sound
bovi
parents: 6561
diff changeset
    98
    // disable exit button sound
9e49e6a8585b disable the glitchy exit sound
bovi
parents: 6561
diff changeset
    99
    btnBack->isSoundEnabled = false;
9e49e6a8585b disable the glitchy exit sound
bovi
parents: 6561
diff changeset
   100
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: 5763
diff changeset
   101
    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: 5763
diff changeset
   102
}
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: 5763
diff changeset
   103
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: 5763
diff changeset
   104
QLayout * PageMain::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: 5763
diff changeset
   105
{
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: 5763
diff changeset
   106
    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: 5763
diff changeset
   107
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   108
    mainNote = new QLabel(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   109
    mainNote->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   110
    mainNote->setWordWrap(true);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6586
diff changeset
   111
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: 5763
diff changeset
   112
    bottomLayout->addWidget(mainNote, 0);
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: 5763
diff changeset
   113
    bottomLayout->setStretch(0,1);
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: 5763
diff changeset
   114
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   115
    btnBack->setWhatsThis(tr("Exit game"));
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents: 6952
diff changeset
   116
7617
0ac281e1b58b Make ffmpeg optional for frontend
unc0rr
parents: 7235
diff changeset
   117
#ifdef VIDEOREC
7643
97b98bcfd056 Differentiate videos from demos - navigating between them was too confusing. BTW, why is this on the front page, instead of next to the demos button?
nemo
parents: 7620
diff changeset
   118
    BtnVideos = addButton(":/res/Videos.png", bottomLayout, 1, true);
7620
fa3bc79dc0b8 remove a redundant assignment; whitespace fixes
sheepluva
parents: 7617
diff changeset
   119
    BtnVideos->setWhatsThis(tr("Manage videos recorded from game"));
7617
0ac281e1b58b Make ffmpeg optional for frontend
unc0rr
parents: 7235
diff changeset
   120
#endif
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents: 6952
diff changeset
   121
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents: 6952
diff changeset
   122
    BtnSetup = addButton(":/res/Settings.png", bottomLayout, 2, true);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   123
    BtnSetup->setWhatsThis(tr("Edit game preferences"));
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents: 6952
diff changeset
   124
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: 5763
diff changeset
   125
    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: 5763
diff changeset
   126
}
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: 5763
diff changeset
   127
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: 5763
diff changeset
   128
void PageMain::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: 5763
diff changeset
   129
{
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: 5763
diff changeset
   130
    //TODO
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: 5763
diff changeset
   131
}
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: 5763
diff changeset
   132
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: 5763
diff changeset
   133
PageMain::PageMain(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: 5763
diff changeset
   134
{
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: 5763
diff changeset
   135
    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: 5763
diff changeset
   136
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: 5763
diff changeset
   137
    if(frontendEffects) setAttribute(Qt::WA_NoSystemBackground, true);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   138
    mainNote->setOpenExternalLinks(true);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   139
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   140
    if(!isDevBuild)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   141
    {
6477
ad5741c252b9 GCI task: describez
Oranger
parents: 6169
diff changeset
   142
        setDefautDescription(QLabel::tr("Tip: ") + randomTip());
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: 5763
diff changeset
   143
    }
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: 5763
diff changeset
   144
    else
6477
ad5741c252b9 GCI task: describez
Oranger
parents: 6169
diff changeset
   145
    {
8176
556e7027e9e1 shorten tip
koda
parents: 8048
diff changeset
   146
        setDefautDescription(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game, while some features might be broken or incomplete!"));
6477
ad5741c252b9 GCI task: describez
Oranger
parents: 6169
diff changeset
   147
    }
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: 5763
diff changeset
   148
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: 5763
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: 5763
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: 5763
diff changeset
   151
QString PageMain::randomTip() const
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: 5763
diff changeset
   152
{
8361
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   153
#ifdef _WIN32
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   154
    int platform = 1;
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   155
#elif defined __APPLE__
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   156
    int platform = 2;
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   157
#else
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   158
    int platform = 3;
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   159
#endif
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: 5763
diff changeset
   160
    QStringList Tips;
8361
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   161
    QFile file(":/res/xml/tips.xml");
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   162
    file.open(QIODevice::ReadOnly);
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   163
    QTextStream in(&file);
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   164
    QString line = in.readLine();
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   165
    int tip_platform = 0;
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   166
    while (!line.isNull()) {
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   167
        if(line.contains("<windows-only>", Qt::CaseSensitive))
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   168
            tip_platform = 1;
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   169
        if(line.contains("<mac-only>", Qt::CaseSensitive))
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   170
            tip_platform = 2;
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   171
        if(line.contains("<linux-only>", Qt::CaseSensitive))
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   172
            tip_platform = 3;
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   173
        if(line.contains("</windows-only>", Qt::CaseSensitive) || 
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   174
                line.contains("</mac-only>", Qt::CaseSensitive) || 
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   175
                line.contains("</linux-only>", Qt::CaseSensitive)) {
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   176
            tip_platform = 0;
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   177
        }
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   178
        QStringList split_string = line.split(QRegExp("</?tip>"));
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   179
        if((tip_platform == platform || tip_platform == 0) && split_string.size() != 1)
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   180
            Tips << tr(split_string[1].toLatin1().data(), "Tips");
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   181
        line = in.readLine();
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   182
    }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6586
diff changeset
   183
    // The following tip will require links to app store entries first.
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6586
diff changeset
   184
    //Tips << tr("Want to play Hedgewars any time? Grab the Mobile version for %1 and %2.", "Tips").arg("").arg("");
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6586
diff changeset
   185
    // the ios version is located here: http://itunes.apple.com/us/app/hedgewars/id391234866
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   186
8361
2831c1403666 Tips are now loaded from an xml file.
martin_bede
parents: 8318
diff changeset
   187
    file.close();
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6586
diff changeset
   188
    return Tips[QTime(0, 0, 0).secsTo(QTime::currentTime()) % Tips.length()];
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   189
}
8318
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
   190
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
   191
void PageMain::toggleNetworkChoice()
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
   192
{
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
   193
    bool visible = BtnNetLocal->isVisible();
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
   194
    BtnNetLocal->setVisible(!visible);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
   195
    BtnNetOfficial->setVisible(!visible);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
   196
    if (visible)    BtnNet->setIcon(originalNetworkIcon);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
   197
    else            BtnNet->setIcon(disabledNetworkIcon);
e2c01fbf36c0 GCI2012: Beautify Network Page
dag10
parents: 8277
diff changeset
   198
}