QTfrontend/ui/page/pageoptions.cpp
changeset 6060 fdfc01419815
parent 6042 8b5345758f62
child 6217 ef53ba841791
equal deleted inserted replaced
6059:ddf020d0941a 6060:fdfc01419815
       
     1 /*
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License as published by
       
     7  * the Free Software Foundation; version 2 of the License
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program; if not, write to the Free Software
       
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
       
    17  */
       
    18 
       
    19 #include <QGridLayout>
       
    20 #include <QHBoxLayout>
       
    21 #include <QPushButton>
       
    22 #include <QGroupBox>
       
    23 #include <QComboBox>
       
    24 #include <QCheckBox>
       
    25 #include <QLabel>
       
    26 #include <QLineEdit>
       
    27 #include <QSpinBox>
       
    28 #include <QTextBrowser>
       
    29 #include <QTableWidget>
       
    30 #include <QSlider>
       
    31 
       
    32 #include "pageoptions.h"
       
    33 #include "hwconsts.h"
       
    34 #include "fpsedit.h"
       
    35 #include "igbox.h"
       
    36 
       
    37 // TODO cleanup
       
    38 QLayout * PageOptions::bodyLayoutDefinition()
       
    39 {
       
    40     QGridLayout * pageLayout = new QGridLayout();
       
    41     pageLayout->setColumnStretch(0, 100);
       
    42     pageLayout->setColumnStretch(1, 100);
       
    43     pageLayout->setColumnStretch(2, 100);
       
    44     pageLayout->setRowStretch(0, 0);
       
    45     //pageLayout->setRowStretch(1, 100);
       
    46     pageLayout->setRowStretch(2, 0);
       
    47     pageLayout->setContentsMargins(7, 7, 7, 0);
       
    48     pageLayout->setSpacing(0);
       
    49 
       
    50 
       
    51     QGroupBox * gbTwoBoxes = new QGroupBox(this);
       
    52     pageLayout->addWidget(gbTwoBoxes, 0, 0, 1, 3);
       
    53     QGridLayout * gbTBLayout = new QGridLayout(gbTwoBoxes);
       
    54     gbTBLayout->setMargin(0);
       
    55     gbTBLayout->setSpacing(0);
       
    56     gbTBLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
       
    57 
       
    58     QPixmap pmNew(":/res/new.png");
       
    59     QPixmap pmEdit(":/res/edit.png");
       
    60     QPixmap pmDelete(":/res/delete.png");
       
    61 
       
    62         {
       
    63             teamsBox = new IconedGroupBox(this);
       
    64             //teamsBox->setContentTopPadding(0);
       
    65             //teamsBox->setAttribute(Qt::WA_PaintOnScreen, true);
       
    66             teamsBox->setIcon(QIcon(":/res/teamicon.png"));
       
    67             teamsBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
       
    68             teamsBox->setTitle(QGroupBox::tr("Teams"));
       
    69 
       
    70             QGridLayout * GBTlayout = new QGridLayout(teamsBox);
       
    71 
       
    72             CBTeamName = new QComboBox(teamsBox);
       
    73             GBTlayout->addWidget(CBTeamName, 0, 0);
       
    74 
       
    75             BtnNewTeam = new QPushButton(teamsBox);
       
    76             BtnNewTeam->setToolTip(tr("New team"));
       
    77             BtnNewTeam->setIconSize(pmNew.size());
       
    78             BtnNewTeam->setIcon(pmNew);
       
    79             BtnNewTeam->setMaximumWidth(pmNew.width() + 6);
       
    80             connect(BtnNewTeam, SIGNAL(clicked()), this, SIGNAL(newTeamRequested()));
       
    81             GBTlayout->addWidget(BtnNewTeam, 0, 1);
       
    82 
       
    83             BtnEditTeam = new QPushButton(teamsBox);
       
    84             BtnEditTeam->setToolTip(tr("Edit team"));
       
    85             BtnEditTeam->setIconSize(pmEdit.size());
       
    86             BtnEditTeam->setIcon(pmEdit);
       
    87             BtnEditTeam->setMaximumWidth(pmEdit.width() + 6);
       
    88             connect(BtnEditTeam, SIGNAL(clicked()), this, SLOT(requestEditSelectedTeam()));
       
    89             GBTlayout->addWidget(BtnEditTeam, 0, 2);
       
    90 
       
    91             BtnDeleteTeam = new QPushButton(teamsBox);
       
    92             BtnDeleteTeam->setToolTip(tr("Delete team"));
       
    93             BtnDeleteTeam->setIconSize(pmDelete.size());
       
    94             BtnDeleteTeam->setIcon(pmDelete);
       
    95             BtnDeleteTeam->setMaximumWidth(pmDelete.width() + 6);
       
    96             connect(BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(requestDeleteSelectedTeam()));
       
    97             GBTlayout->addWidget(BtnDeleteTeam, 0, 3);
       
    98 
       
    99             LblNoEditTeam = new QLabel(teamsBox);
       
   100             LblNoEditTeam->setText(tr("You can't edit teams from team selection. Go back to main menu to add, edit or delete teams."));
       
   101             LblNoEditTeam->setWordWrap(true);
       
   102             LblNoEditTeam->setVisible(false);
       
   103             GBTlayout->addWidget(LblNoEditTeam, 0, 0);
       
   104 
       
   105             gbTBLayout->addWidget(teamsBox, 0, 0);
       
   106         }
       
   107 
       
   108         {
       
   109             IconedGroupBox* groupWeapons = new IconedGroupBox(this);
       
   110             
       
   111             //groupWeapons->setContentTopPadding(0);
       
   112             //groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
       
   113             groupWeapons->setIcon(QIcon(":/res/weaponsicon.png"));
       
   114             groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
       
   115             groupWeapons->setTitle(QGroupBox::tr("Schemes and Weapons"));
       
   116             QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons);
       
   117 
       
   118             QLabel* SchemeLabel = new QLabel(groupWeapons);
       
   119             SchemeLabel->setText(QLabel::tr("Game scheme"));
       
   120             WeaponsLayout->addWidget(SchemeLabel, 1, 0);
       
   121 
       
   122             SchemesName = new QComboBox(groupWeapons);
       
   123             WeaponsLayout->addWidget(SchemesName, 1, 1);
       
   124 
       
   125             SchemeNew = new QPushButton(groupWeapons);
       
   126             SchemeNew->setToolTip(tr("New scheme"));
       
   127             SchemeNew->setIconSize(pmNew.size());
       
   128             SchemeNew->setIcon(pmNew);
       
   129             SchemeNew->setMaximumWidth(pmNew.width() + 6);
       
   130             WeaponsLayout->addWidget(SchemeNew, 1, 2);
       
   131 
       
   132             SchemeEdit = new QPushButton(groupWeapons);
       
   133             SchemeEdit->setToolTip(tr("Edit scheme"));
       
   134             SchemeEdit->setIconSize(pmEdit.size());
       
   135             SchemeEdit->setIcon(pmEdit);
       
   136             SchemeEdit->setMaximumWidth(pmEdit.width() + 6);
       
   137             WeaponsLayout->addWidget(SchemeEdit, 1, 3);
       
   138 
       
   139             SchemeDelete = new QPushButton(groupWeapons);
       
   140             SchemeDelete->setToolTip(tr("Delete scheme"));
       
   141             SchemeDelete->setIconSize(pmDelete.size());
       
   142             SchemeDelete->setIcon(pmDelete);
       
   143             SchemeDelete->setMaximumWidth(pmDelete.width() + 6);
       
   144             WeaponsLayout->addWidget(SchemeDelete, 1, 4);
       
   145 
       
   146             QLabel* WeaponLabel = new QLabel(groupWeapons);
       
   147             WeaponLabel->setText(QLabel::tr("Weapons"));
       
   148             WeaponsLayout->addWidget(WeaponLabel, 2, 0);
       
   149 
       
   150             WeaponsName = new QComboBox(groupWeapons);
       
   151             WeaponsLayout->addWidget(WeaponsName, 2, 1);
       
   152 
       
   153             WeaponNew = new QPushButton(groupWeapons);
       
   154             WeaponNew->setToolTip(tr("New weapon set"));
       
   155             WeaponNew->setIconSize(pmNew.size());
       
   156             WeaponNew->setIcon(pmNew);
       
   157             WeaponNew->setMaximumWidth(pmNew.width() + 6);
       
   158             WeaponsLayout->addWidget(WeaponNew, 2, 2);
       
   159 
       
   160             WeaponEdit = new QPushButton(groupWeapons);
       
   161             WeaponEdit->setToolTip(tr("Edit weapon set"));
       
   162             WeaponEdit->setIconSize(pmEdit.size());
       
   163             WeaponEdit->setIcon(pmEdit);
       
   164             WeaponEdit->setMaximumWidth(pmEdit.width() + 6);
       
   165             WeaponsLayout->addWidget(WeaponEdit, 2, 3);
       
   166 
       
   167             WeaponDelete = new QPushButton(groupWeapons);
       
   168             WeaponDelete->setToolTip(tr("Delete weapon set"));
       
   169             WeaponDelete->setIconSize(pmDelete.size());
       
   170             WeaponDelete->setIcon(pmDelete);
       
   171             WeaponDelete->setMaximumWidth(pmDelete.width() + 6);
       
   172             WeaponsLayout->addWidget(WeaponDelete, 2, 4);
       
   173 
       
   174             WeaponTooltip = new QCheckBox(this);
       
   175             WeaponTooltip->setText(QCheckBox::tr("Show ammo menu tooltips"));
       
   176             WeaponsLayout->addWidget(WeaponTooltip, 3, 0, 1, 4);
       
   177 
       
   178             gbTBLayout->addWidget(groupWeapons, 1, 0);
       
   179         }
       
   180 
       
   181         {
       
   182             IconedGroupBox* groupMisc = new IconedGroupBox(this);
       
   183             //groupMisc->setContentTopPadding(0);
       
   184             groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
       
   185             groupMisc->setIcon(QIcon(":/res/miscicon.png"));
       
   186             //groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
       
   187             groupMisc->setTitle(QGroupBox::tr("Misc"));
       
   188             QGridLayout * MiscLayout = new QGridLayout(groupMisc);
       
   189 
       
   190             labelNN = new QLabel(groupMisc);
       
   191             labelNN->setText(QLabel::tr("Net nick"));
       
   192             MiscLayout->addWidget(labelNN, 0, 0);
       
   193 
       
   194             editNetNick = new QLineEdit(groupMisc);
       
   195             editNetNick->setMaxLength(20);
       
   196             editNetNick->setText(QLineEdit::tr("unnamed"));
       
   197             connect(editNetNick, SIGNAL(editingFinished()), this, SLOT(trimNetNick()));
       
   198             MiscLayout->addWidget(editNetNick, 0, 1);
       
   199             
       
   200             labelNetPassword = new QLabel(groupMisc);
       
   201             labelNetPassword->setText(QLabel::tr("Password"));
       
   202             MiscLayout->addWidget(labelNetPassword, 1, 0);
       
   203             
       
   204             editNetPassword = new QLineEdit(groupMisc);
       
   205             editNetPassword->setEchoMode(QLineEdit::Password);
       
   206             MiscLayout->addWidget(editNetPassword, 1, 1);
       
   207 
       
   208             QLabel *labelLanguage = new QLabel(groupMisc);
       
   209             labelLanguage->setText(QLabel::tr("Locale") + " *");
       
   210             MiscLayout->addWidget(labelLanguage, 2, 0);
       
   211 
       
   212             CBLanguage = new QComboBox(groupMisc);
       
   213             QDir tmpdir;
       
   214             tmpdir.cd(cfgdir->absolutePath());
       
   215             tmpdir.cd("Data/Locale");
       
   216             tmpdir.setFilter(QDir::Files);
       
   217             QStringList locs = tmpdir.entryList(QStringList("hedgewars_*.qm"));
       
   218             CBLanguage->addItem(QComboBox::tr("(System default)"), QString(""));
       
   219             for(int i = 0; i < locs.count(); i++)
       
   220             {
       
   221                 QLocale loc(locs[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1"));
       
   222                 CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name());
       
   223             }
       
   224 
       
   225             tmpdir.cd(datadir->absolutePath());
       
   226             tmpdir.cd("Locale");
       
   227             tmpdir.setFilter(QDir::Files);
       
   228             QStringList tmplist = tmpdir.entryList(QStringList("hedgewars_*.qm"));
       
   229             for(int i = 0; i < tmplist.count(); i++)
       
   230             {
       
   231                 if (locs.contains(tmplist[i])) continue;
       
   232                 QLocale loc(tmplist[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1"));
       
   233                 CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name());
       
   234             }
       
   235 
       
   236             MiscLayout->addWidget(CBLanguage, 2, 1);
       
   237 
       
   238             CBAltDamage = new QCheckBox(groupMisc);
       
   239             CBAltDamage->setText(QCheckBox::tr("Alternative damage show"));
       
   240             MiscLayout->addWidget(CBAltDamage, 3, 0, 1, 2);
       
   241 
       
   242             CBNameWithDate = new QCheckBox(groupMisc);
       
   243             CBNameWithDate->setText(QCheckBox::tr("Append date and time to record file name"));
       
   244             MiscLayout->addWidget(CBNameWithDate, 4, 0, 1, 2);
       
   245 
       
   246             BtnAssociateFiles = new QPushButton(groupMisc);
       
   247             BtnAssociateFiles->setText(QPushButton::tr("Associate file extensions"));
       
   248             BtnAssociateFiles->setEnabled(!custom_data && !custom_config);
       
   249             MiscLayout->addWidget(BtnAssociateFiles, 5, 0, 1, 2);
       
   250 
       
   251 #ifdef __APPLE__
       
   252 #ifdef SPARKLE_ENABLED
       
   253             CBAutoUpdate = new QCheckBox(groupMisc);
       
   254             CBAutoUpdate->setText(QCheckBox::tr("Check for updates at startup"));
       
   255             MiscLayout->addWidget(CBAutoUpdate, 6, 0, 1, 3);
       
   256 #endif
       
   257 #endif
       
   258             gbTBLayout->addWidget(groupMisc, 2, 0);
       
   259         }
       
   260 
       
   261         {
       
   262             AGGroupBox = new IconedGroupBox(this);
       
   263             //AGGroupBox->setContentTopPadding(0);
       
   264             AGGroupBox->setIcon(QIcon(":/res/graphicsicon.png"));
       
   265             //AGGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
       
   266             AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options"));
       
   267 
       
   268             QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox);
       
   269             QHBoxLayout * GBAreslayout = new QHBoxLayout(0);
       
   270             QHBoxLayout * GBAstereolayout = new QHBoxLayout(0);
       
   271             QHBoxLayout * GBAqualayout = new QHBoxLayout(0);
       
   272 
       
   273             CBFrontendFullscreen = new QCheckBox(AGGroupBox);
       
   274             CBFrontendFullscreen->setText(QCheckBox::tr("Frontend fullscreen"));
       
   275             GBAlayout->addWidget(CBFrontendFullscreen);
       
   276 
       
   277             CBFrontendEffects = new QCheckBox(AGGroupBox);
       
   278             CBFrontendEffects->setText(QCheckBox::tr("Frontend effects") + " *");
       
   279             GBAlayout->addWidget(CBFrontendEffects);
       
   280 
       
   281             CBEnableFrontendSound = new QCheckBox(AGGroupBox);
       
   282             CBEnableFrontendSound->setText(QCheckBox::tr("Enable frontend sounds"));
       
   283             GBAlayout->addWidget(CBEnableFrontendSound);
       
   284 
       
   285             CBEnableFrontendMusic = new QCheckBox(AGGroupBox);
       
   286             CBEnableFrontendMusic->setText(QCheckBox::tr("Enable frontend music"));
       
   287             GBAlayout->addWidget(CBEnableFrontendMusic);
       
   288 
       
   289             QFrame * hr = new QFrame(AGGroupBox);
       
   290             hr->setFrameStyle(QFrame::HLine);
       
   291             hr->setLineWidth(3);
       
   292             hr->setFixedHeight(10);
       
   293             GBAlayout->addWidget(hr);
       
   294 
       
   295             QLabel * resolution = new QLabel(AGGroupBox);
       
   296             resolution->setText(QLabel::tr("Resolution"));
       
   297             GBAreslayout->addWidget(resolution);
       
   298 
       
   299             CBResolution = new QComboBox(AGGroupBox);
       
   300             GBAreslayout->addWidget(CBResolution);
       
   301             GBAlayout->addLayout(GBAreslayout);
       
   302 
       
   303             CBFullscreen = new QCheckBox(AGGroupBox);
       
   304             CBFullscreen->setText(QCheckBox::tr("Fullscreen"));
       
   305             GBAlayout->addWidget(CBFullscreen);
       
   306 
       
   307             QLabel * quality = new QLabel(AGGroupBox);
       
   308             quality->setText(QLabel::tr("Quality"));
       
   309             quality->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
       
   310             GBAqualayout->addWidget(quality);
       
   311             
       
   312             SLQuality = new QSlider(Qt::Horizontal, AGGroupBox);
       
   313             SLQuality->setTickPosition(QSlider::TicksBelow);
       
   314             SLQuality->setMaximum(5);
       
   315             SLQuality->setMinimum(0);
       
   316             SLQuality->setFixedWidth(150);
       
   317             GBAqualayout->addWidget(SLQuality);
       
   318             GBAlayout->addLayout(GBAqualayout);
       
   319 
       
   320             QLabel * stereo = new QLabel(AGGroupBox);
       
   321             stereo->setText(QLabel::tr("Stereo rendering"));
       
   322             GBAstereolayout->addWidget(stereo);
       
   323 
       
   324             CBStereoMode = new QComboBox(AGGroupBox);
       
   325             CBStereoMode->addItem(QComboBox::tr("Disabled"));
       
   326             CBStereoMode->addItem(QComboBox::tr("Red/Cyan"));
       
   327             CBStereoMode->addItem(QComboBox::tr("Cyan/Red"));
       
   328             CBStereoMode->addItem(QComboBox::tr("Red/Blue"));
       
   329             CBStereoMode->addItem(QComboBox::tr("Blue/Red"));
       
   330             CBStereoMode->addItem(QComboBox::tr("Red/Green"));
       
   331             CBStereoMode->addItem(QComboBox::tr("Green/Red"));
       
   332             CBStereoMode->addItem(QComboBox::tr("Side-by-side"));
       
   333             CBStereoMode->addItem(QComboBox::tr("Top-Bottom"));
       
   334             CBStereoMode->addItem(QComboBox::tr("Wiggle"));
       
   335             CBStereoMode->addItem(QComboBox::tr("Red/Cyan grayscale"));
       
   336             CBStereoMode->addItem(QComboBox::tr("Cyan/Red grayscale"));
       
   337             CBStereoMode->addItem(QComboBox::tr("Red/Blue grayscale"));
       
   338             CBStereoMode->addItem(QComboBox::tr("Blue/Red grayscale"));
       
   339             CBStereoMode->addItem(QComboBox::tr("Red/Green grayscale"));
       
   340             CBStereoMode->addItem(QComboBox::tr("Green/Red grayscale"));
       
   341             connect(CBStereoMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceFullscreen(int)));
       
   342 
       
   343             GBAstereolayout->addWidget(CBStereoMode);
       
   344             GBAlayout->addLayout(GBAstereolayout);
       
   345 
       
   346             hr = new QFrame(AGGroupBox);
       
   347             hr->setFrameStyle(QFrame::HLine);
       
   348             hr->setLineWidth(3);
       
   349             hr->setFixedHeight(10);
       
   350             GBAlayout->addWidget(hr);
       
   351 
       
   352             QHBoxLayout * GBAvollayout = new QHBoxLayout(0);
       
   353             QLabel * vol = new QLabel(AGGroupBox);
       
   354             vol->setText(QLabel::tr("Initial sound volume"));
       
   355             GBAvollayout->addWidget(vol);
       
   356             GBAlayout->addLayout(GBAvollayout);
       
   357             volumeBox = new QSpinBox(AGGroupBox);
       
   358             volumeBox->setRange(0, 100);
       
   359             volumeBox->setSingleStep(5);
       
   360             GBAvollayout->addWidget(volumeBox);
       
   361 
       
   362             CBEnableSound = new QCheckBox(AGGroupBox);
       
   363             CBEnableSound->setText(QCheckBox::tr("Enable sound"));
       
   364             GBAlayout->addWidget(CBEnableSound);
       
   365 
       
   366             CBEnableMusic = new QCheckBox(AGGroupBox);
       
   367             CBEnableMusic->setText(QCheckBox::tr("Enable music"));
       
   368             GBAlayout->addWidget(CBEnableMusic);
       
   369 
       
   370             hr = new QFrame(AGGroupBox);
       
   371             hr->setFrameStyle(QFrame::HLine);
       
   372             hr->setLineWidth(3);
       
   373             hr->setFixedHeight(10);
       
   374             GBAlayout->addWidget(hr);
       
   375 
       
   376             QHBoxLayout * GBAfpslayout = new QHBoxLayout(0);
       
   377             QLabel * maxfps = new QLabel(AGGroupBox);
       
   378             maxfps->setText(QLabel::tr("FPS limit"));
       
   379             GBAfpslayout->addWidget(maxfps);
       
   380             GBAlayout->addLayout(GBAfpslayout);
       
   381             fpsedit = new FPSEdit(AGGroupBox);
       
   382             GBAfpslayout->addWidget(fpsedit);
       
   383 
       
   384             CBShowFPS = new QCheckBox(AGGroupBox);
       
   385             CBShowFPS->setText(QCheckBox::tr("Show FPS"));
       
   386             GBAlayout->addWidget(CBShowFPS);
       
   387 
       
   388             hr = new QFrame(AGGroupBox);
       
   389             hr->setFrameStyle(QFrame::HLine);
       
   390             hr->setLineWidth(3);
       
   391             hr->setFixedHeight(10);
       
   392             GBAlayout->addWidget(hr);
       
   393 
       
   394             QLabel *restartNote = new QLabel(this);
       
   395             restartNote->setText(QString("* ") + QLabel::tr("Restart game to apply"));
       
   396             restartNote->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
       
   397             GBAlayout->addWidget(restartNote);
       
   398 
       
   399             gbTBLayout->addWidget(AGGroupBox, 0, 1, 3, 1);
       
   400         }
       
   401 
       
   402     previousQuality = this->SLQuality->value();
       
   403     previousResolutionIndex = this->CBResolution->currentIndex();
       
   404     previousFullscreenValue = this->CBFullscreen->isChecked();
       
   405 
       
   406     return pageLayout;
       
   407 }
       
   408 
       
   409 QLayout * PageOptions::footerLayoutDefinition()
       
   410 {
       
   411     QHBoxLayout * bottomLayout = new QHBoxLayout();
       
   412     btnSave = addButton(":/res/Save.png", bottomLayout, 0, true);
       
   413     btnSave->setStyleSheet("QPushButton{margin: 24px 0 0 0;}");
       
   414     bottomLayout->setAlignment(btnSave, Qt::AlignRight | Qt::AlignBottom);
       
   415     return bottomLayout;
       
   416 }
       
   417 
       
   418 void PageOptions::connectSignals()
       
   419 {
       
   420     connect(CBResolution, SIGNAL(currentIndexChanged(int)), this, SLOT(setResolution(int)));
       
   421     connect(CBFullscreen, SIGNAL(stateChanged(int)), this, SLOT(setFullscreen(int)));
       
   422     connect(SLQuality, SIGNAL(valueChanged(int)), this, SLOT(setQuality(int)));
       
   423 }
       
   424 
       
   425 PageOptions::PageOptions(QWidget* parent) : AbstractPage(parent)
       
   426 {
       
   427     initPage();
       
   428 }
       
   429 
       
   430 void PageOptions::forceFullscreen(int index)
       
   431 {
       
   432     bool forced = (index == 7 || index == 8 || index == 9);
       
   433 
       
   434     if (index != 0) {
       
   435         this->SLQuality->setValue(this->SLQuality->maximum());
       
   436         this->SLQuality->setEnabled(false);
       
   437         this->CBFullscreen->setEnabled(!forced);
       
   438         this->CBFullscreen->setChecked(forced ? true : previousFullscreenValue);
       
   439         this->CBResolution->setCurrentIndex(forced ? 0 : previousResolutionIndex);
       
   440     } else {
       
   441         this->SLQuality->setEnabled(true);
       
   442         this->CBFullscreen->setEnabled(true);
       
   443         this->SLQuality->setValue(previousQuality);
       
   444         this->CBFullscreen->setChecked(previousFullscreenValue);
       
   445         this->CBResolution->setCurrentIndex(previousResolutionIndex);
       
   446     }
       
   447 }
       
   448 
       
   449 void PageOptions::setQuality(int value)
       
   450 {
       
   451     int index = this->CBStereoMode->currentIndex();
       
   452     if (index == 0)
       
   453         previousQuality = this->SLQuality->value();
       
   454 }
       
   455 
       
   456 void PageOptions::setFullscreen(int state)
       
   457 {
       
   458     int index = this->CBStereoMode->currentIndex();
       
   459     if (index != 7 && index != 8 && index != 9)
       
   460         previousFullscreenValue = this->CBFullscreen->isChecked();
       
   461 }
       
   462 
       
   463 void PageOptions::setResolution(int state)
       
   464 {
       
   465     int index = this->CBStereoMode->currentIndex();
       
   466     if (index != 7 && index != 8 && index != 9)
       
   467         previousResolutionIndex = this->CBResolution->currentIndex();
       
   468 }
       
   469 
       
   470 void PageOptions::trimNetNick()
       
   471 {
       
   472     editNetNick->setText(editNetNick->text().trimmed());
       
   473 }
       
   474 
       
   475 void PageOptions::requestEditSelectedTeam()
       
   476 {
       
   477     emit editTeamRequested(CBTeamName->currentText());
       
   478 }
       
   479 
       
   480 void PageOptions::requestDeleteSelectedTeam()
       
   481 {
       
   482     emit deleteTeamRequested(CBTeamName->currentText());
       
   483 }
       
   484 
       
   485 void PageOptions::setTeamOptionsEnabled(bool enabled)
       
   486 {
       
   487     BtnNewTeam->setVisible(enabled);
       
   488     BtnEditTeam->setVisible(enabled);
       
   489     BtnDeleteTeam->setVisible(enabled);
       
   490     CBTeamName->setVisible(enabled);
       
   491     LblNoEditTeam->setVisible(!enabled);
       
   492 }