QTfrontend/ui/page/pageoptions.cpp
changeset 7541 e51b11349637
parent 7153 f0d055645ab2
child 7630 13fa53bb3134
equal deleted inserted replaced
7539:c6ffbc6530e3 7541:e51b11349637
    26 #include <QLineEdit>
    26 #include <QLineEdit>
    27 #include <QSpinBox>
    27 #include <QSpinBox>
    28 #include <QTextBrowser>
    28 #include <QTextBrowser>
    29 #include <QTableWidget>
    29 #include <QTableWidget>
    30 #include <QSlider>
    30 #include <QSlider>
       
    31 #include <QSignalMapper>
       
    32 #include <QColorDialog>
       
    33 #include <QStandardItemModel>
    31 
    34 
    32 #include "pageoptions.h"
    35 #include "pageoptions.h"
    33 #include "hwconsts.h"
    36 #include "hwconsts.h"
    34 #include "fpsedit.h"
    37 #include "fpsedit.h"
    35 #include "igbox.h"
    38 #include "igbox.h"
       
    39 #include "DataManager.h"
    36 
    40 
    37 // TODO cleanup
    41 // TODO cleanup
    38 QLayout * PageOptions::bodyLayoutDefinition()
    42 QLayout * PageOptions::bodyLayoutDefinition()
    39 {
    43 {
    40     QGridLayout * pageLayout = new QGridLayout();
    44     QVBoxLayout * pageLayout = new QVBoxLayout();
    41     pageLayout->setColumnStretch(0, 100);
    45 
    42     pageLayout->setColumnStretch(1, 100);
    46     QTabWidget * tabs = new QTabWidget(this);
    43     pageLayout->setColumnStretch(2, 100);
    47     pageLayout->addWidget(tabs);
    44     pageLayout->setRowStretch(0, 0);
    48     QWidget * page1 = new QWidget(this);
    45     //pageLayout->setRowStretch(1, 100);
    49     QWidget * page2 = new QWidget(this);
    46     pageLayout->setRowStretch(2, 0);
    50     tabs->addTab(page1, tr("General"));
    47     pageLayout->setContentsMargins(7, 7, 7, 0);
    51     tabs->addTab(page2, tr("Advanced"));
    48     pageLayout->setSpacing(0);
    52 
    49 
    53     { // page 1
    50 
    54         QGridLayout * page1Layout = new QGridLayout(page1);
    51     QGroupBox * gbTwoBoxes = new QGroupBox(this);
    55         //gbTBLayout->setMargin(0);
    52     pageLayout->addWidget(gbTwoBoxes, 0, 0, 1, 3);
    56         page1Layout->setSpacing(0);
    53     QGridLayout * gbTBLayout = new QGridLayout(gbTwoBoxes);
    57         page1Layout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
    54     gbTBLayout->setMargin(0);
    58 
    55     gbTBLayout->setSpacing(0);
    59         QPixmap pmNew(":/res/new.png");
    56     gbTBLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
    60         QPixmap pmEdit(":/res/edit.png");
    57 
    61         QPixmap pmDelete(":/res/delete.png");
    58     QPixmap pmNew(":/res/new.png");
    62 
    59     QPixmap pmEdit(":/res/edit.png");
    63         {
    60     QPixmap pmDelete(":/res/delete.png");
    64             teamsBox = new IconedGroupBox(this);
    61 
    65             //teamsBox->setContentTopPadding(0);
    62     {
    66             //teamsBox->setAttribute(Qt::WA_PaintOnScreen, true);
    63         teamsBox = new IconedGroupBox(this);
    67             teamsBox->setIcon(QIcon(":/res/teamicon.png"));
    64         //teamsBox->setContentTopPadding(0);
    68             teamsBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    65         //teamsBox->setAttribute(Qt::WA_PaintOnScreen, true);
    69             teamsBox->setTitle(QGroupBox::tr("Teams"));
    66         teamsBox->setIcon(QIcon(":/res/teamicon.png"));
    70 
    67         teamsBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    71             QGridLayout * GBTlayout = new QGridLayout(teamsBox);
    68         teamsBox->setTitle(QGroupBox::tr("Teams"));
    72 
    69 
    73             CBTeamName = new QComboBox(teamsBox);
    70         QGridLayout * GBTlayout = new QGridLayout(teamsBox);
    74             GBTlayout->addWidget(CBTeamName, 0, 0);
    71 
    75 
    72         CBTeamName = new QComboBox(teamsBox);
    76             BtnNewTeam = new QPushButton(teamsBox);
    73         GBTlayout->addWidget(CBTeamName, 0, 0);
    77             BtnNewTeam->setToolTip(tr("New team"));
    74 
    78             BtnNewTeam->setIconSize(pmNew.size());
    75         BtnNewTeam = new QPushButton(teamsBox);
    79             BtnNewTeam->setIcon(pmNew);
    76         BtnNewTeam->setToolTip(tr("New team"));
    80             BtnNewTeam->setMaximumWidth(pmNew.width() + 6);
    77         BtnNewTeam->setIconSize(pmNew.size());
    81             connect(BtnNewTeam, SIGNAL(clicked()), this, SIGNAL(newTeamRequested()));
    78         BtnNewTeam->setIcon(pmNew);
    82             GBTlayout->addWidget(BtnNewTeam, 0, 1);
    79         BtnNewTeam->setMaximumWidth(pmNew.width() + 6);
    83 
    80         connect(BtnNewTeam, SIGNAL(clicked()), this, SIGNAL(newTeamRequested()));
    84             BtnEditTeam = new QPushButton(teamsBox);
    81         GBTlayout->addWidget(BtnNewTeam, 0, 1);
    85             BtnEditTeam->setToolTip(tr("Edit team"));
    82 
    86             BtnEditTeam->setIconSize(pmEdit.size());
    83         BtnEditTeam = new QPushButton(teamsBox);
    87             BtnEditTeam->setIcon(pmEdit);
    84         BtnEditTeam->setToolTip(tr("Edit team"));
    88             BtnEditTeam->setMaximumWidth(pmEdit.width() + 6);
    85         BtnEditTeam->setIconSize(pmEdit.size());
    89             connect(BtnEditTeam, SIGNAL(clicked()), this, SLOT(requestEditSelectedTeam()));
    86         BtnEditTeam->setIcon(pmEdit);
    90             GBTlayout->addWidget(BtnEditTeam, 0, 2);
    87         BtnEditTeam->setMaximumWidth(pmEdit.width() + 6);
    91 
    88         connect(BtnEditTeam, SIGNAL(clicked()), this, SLOT(requestEditSelectedTeam()));
    92             BtnDeleteTeam = new QPushButton(teamsBox);
    89         GBTlayout->addWidget(BtnEditTeam, 0, 2);
    93             BtnDeleteTeam->setToolTip(tr("Delete team"));
    90 
    94             BtnDeleteTeam->setIconSize(pmDelete.size());
    91         BtnDeleteTeam = new QPushButton(teamsBox);
    95             BtnDeleteTeam->setIcon(pmDelete);
    92         BtnDeleteTeam->setToolTip(tr("Delete team"));
    96             BtnDeleteTeam->setMaximumWidth(pmDelete.width() + 6);
    93         BtnDeleteTeam->setIconSize(pmDelete.size());
    97             connect(BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(requestDeleteSelectedTeam()));
    94         BtnDeleteTeam->setIcon(pmDelete);
    98             GBTlayout->addWidget(BtnDeleteTeam, 0, 3);
    95         BtnDeleteTeam->setMaximumWidth(pmDelete.width() + 6);
    99 
    96         connect(BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(requestDeleteSelectedTeam()));
   100             LblNoEditTeam = new QLabel(teamsBox);
    97         GBTlayout->addWidget(BtnDeleteTeam, 0, 3);
   101             LblNoEditTeam->setText(tr("You can't edit teams from team selection. Go back to main menu to add, edit or delete teams."));
    98 
   102             LblNoEditTeam->setWordWrap(true);
    99         LblNoEditTeam = new QLabel(teamsBox);
   103             LblNoEditTeam->setVisible(false);
   100         LblNoEditTeam->setText(tr("You can't edit teams from team selection. Go back to main menu to add, edit or delete teams."));
   104             GBTlayout->addWidget(LblNoEditTeam, 0, 0);
   101         LblNoEditTeam->setWordWrap(true);
   105 
   102         LblNoEditTeam->setVisible(false);
   106             page1Layout->addWidget(teamsBox, 0, 0);
   103         GBTlayout->addWidget(LblNoEditTeam, 0, 0);
   107         }
   104 
   108 
   105         gbTBLayout->addWidget(teamsBox, 0, 0);
   109         {
       
   110             IconedGroupBox* groupWeapons = new IconedGroupBox(this);
       
   111 
       
   112             //groupWeapons->setContentTopPadding(0);
       
   113             //groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
       
   114             groupWeapons->setIcon(QIcon(":/res/weaponsicon.png"));
       
   115             groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
       
   116             groupWeapons->setTitle(QGroupBox::tr("Schemes and Weapons"));
       
   117             QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons);
       
   118 
       
   119             QLabel* SchemeLabel = new QLabel(groupWeapons);
       
   120             SchemeLabel->setText(QLabel::tr("Game scheme"));
       
   121             WeaponsLayout->addWidget(SchemeLabel, 1, 0);
       
   122 
       
   123             SchemesName = new QComboBox(groupWeapons);
       
   124             WeaponsLayout->addWidget(SchemesName, 1, 1);
       
   125 
       
   126             SchemeNew = new QPushButton(groupWeapons);
       
   127             SchemeNew->setWhatsThis(tr("New scheme"));
       
   128             SchemeNew->setIconSize(pmNew.size());
       
   129             SchemeNew->setIcon(pmNew);
       
   130             SchemeNew->setMaximumWidth(pmNew.width() + 6);
       
   131             WeaponsLayout->addWidget(SchemeNew, 1, 2);
       
   132 
       
   133             SchemeEdit = new QPushButton(groupWeapons);
       
   134             SchemeEdit->setWhatsThis(tr("Edit scheme"));
       
   135             SchemeEdit->setIconSize(pmEdit.size());
       
   136             SchemeEdit->setIcon(pmEdit);
       
   137             SchemeEdit->setMaximumWidth(pmEdit.width() + 6);
       
   138             WeaponsLayout->addWidget(SchemeEdit, 1, 3);
       
   139 
       
   140             SchemeDelete = new QPushButton(groupWeapons);
       
   141             SchemeDelete->setWhatsThis(tr("Delete scheme"));
       
   142             SchemeDelete->setIconSize(pmDelete.size());
       
   143             SchemeDelete->setIcon(pmDelete);
       
   144             SchemeDelete->setMaximumWidth(pmDelete.width() + 6);
       
   145             WeaponsLayout->addWidget(SchemeDelete, 1, 4);
       
   146 
       
   147             QLabel* WeaponLabel = new QLabel(groupWeapons);
       
   148             WeaponLabel->setText(QLabel::tr("Weapons"));
       
   149             WeaponsLayout->addWidget(WeaponLabel, 2, 0);
       
   150 
       
   151             WeaponsName = new QComboBox(groupWeapons);
       
   152             WeaponsLayout->addWidget(WeaponsName, 2, 1);
       
   153 
       
   154             WeaponNew = new QPushButton(groupWeapons);
       
   155             WeaponNew->setWhatsThis(tr("New weapon set"));
       
   156             WeaponNew->setIconSize(pmNew.size());
       
   157             WeaponNew->setIcon(pmNew);
       
   158             WeaponNew->setMaximumWidth(pmNew.width() + 6);
       
   159             WeaponsLayout->addWidget(WeaponNew, 2, 2);
       
   160 
       
   161             WeaponEdit = new QPushButton(groupWeapons);
       
   162             WeaponEdit->setWhatsThis(tr("Edit weapon set"));
       
   163             WeaponEdit->setIconSize(pmEdit.size());
       
   164             WeaponEdit->setIcon(pmEdit);
       
   165             WeaponEdit->setMaximumWidth(pmEdit.width() + 6);
       
   166             WeaponsLayout->addWidget(WeaponEdit, 2, 3);
       
   167 
       
   168             WeaponDelete = new QPushButton(groupWeapons);
       
   169             WeaponDelete->setWhatsThis(tr("Delete weapon set"));
       
   170             WeaponDelete->setIconSize(pmDelete.size());
       
   171             WeaponDelete->setIcon(pmDelete);
       
   172             WeaponDelete->setMaximumWidth(pmDelete.width() + 6);
       
   173             WeaponsLayout->addWidget(WeaponDelete, 2, 4);
       
   174 
       
   175             WeaponTooltip = new QCheckBox(this);
       
   176             WeaponTooltip->setText(QCheckBox::tr("Show ammo menu tooltips"));
       
   177             WeaponsLayout->addWidget(WeaponTooltip, 3, 0, 1, 4);
       
   178 
       
   179             page1Layout->addWidget(groupWeapons, 1, 0);
       
   180         }
       
   181 
       
   182         {
       
   183             IconedGroupBox* groupMisc = new IconedGroupBox(this);
       
   184             //groupMisc->setContentTopPadding(0);
       
   185             groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
       
   186             groupMisc->setIcon(QIcon(":/res/miscicon.png"));
       
   187             //groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
       
   188             groupMisc->setTitle(QGroupBox::tr("Misc"));
       
   189             QGridLayout * MiscLayout = new QGridLayout(groupMisc);
       
   190 
       
   191             // Label for "Language"
       
   192             QLabel *labelLanguage = new QLabel(groupMisc);
       
   193             labelLanguage->setText(QLabel::tr("Locale") + " *");
       
   194             MiscLayout->addWidget(labelLanguage, 0, 0);
       
   195 
       
   196             // List of installed languages
       
   197             CBLanguage = new QComboBox(groupMisc);
       
   198             QDir tmpdir;
       
   199             tmpdir.cd(cfgdir->absolutePath());
       
   200             tmpdir.cd("Data/Locale");
       
   201             tmpdir.setFilter(QDir::Files);
       
   202             QStringList locs = tmpdir.entryList(QStringList("hedgewars_*.qm"));
       
   203             CBLanguage->addItem(QComboBox::tr("(System default)"), QString(""));
       
   204             for(int i = 0; i < locs.count(); i++)
       
   205             {
       
   206                 QLocale loc(locs[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1"));
       
   207                 CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name());
       
   208             }
       
   209 
       
   210             tmpdir.cd(datadir->absolutePath());
       
   211             tmpdir.cd("Locale");
       
   212             tmpdir.setFilter(QDir::Files);
       
   213             QStringList tmplist = tmpdir.entryList(QStringList("hedgewars_*.qm"));
       
   214             for(int i = 0; i < tmplist.count(); i++)
       
   215             {
       
   216                 if (locs.contains(tmplist[i])) continue;
       
   217                 QLocale loc(tmplist[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1"));
       
   218                 CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name());
       
   219             }
       
   220 
       
   221             MiscLayout->addWidget(CBLanguage, 0, 1);
       
   222 
       
   223             // Label and field for net nick
       
   224             labelNN = new QLabel(groupMisc);
       
   225             labelNN->setText(QLabel::tr("Nickname"));
       
   226             MiscLayout->addWidget(labelNN, 1, 0);
       
   227 
       
   228             editNetNick = new QLineEdit(groupMisc);
       
   229             editNetNick->setMaxLength(20);
       
   230             editNetNick->setText(QLineEdit::tr("anonymous"));
       
   231             MiscLayout->addWidget(editNetNick, 1, 1);
       
   232 
       
   233             // checkbox and field for password
       
   234             CBSavePassword = new QCheckBox(groupMisc);
       
   235             CBSavePassword->setText(QCheckBox::tr("Save password"));
       
   236             MiscLayout->addWidget(CBSavePassword, 2, 0);
       
   237 
       
   238             editNetPassword = new QLineEdit(groupMisc);
       
   239             editNetPassword->setEchoMode(QLineEdit::Password);
       
   240             MiscLayout->addWidget(editNetPassword, 2, 1);
       
   241 
       
   242             CBNameWithDate = new QCheckBox(groupMisc);
       
   243             CBNameWithDate->setText(QCheckBox::tr("Append date and time to record file name"));
       
   244             MiscLayout->addWidget(CBNameWithDate, 5, 0, 1, 2);
       
   245 
       
   246             BtnAssociateFiles = new QPushButton(groupMisc);
       
   247             BtnAssociateFiles->setText(QPushButton::tr("Associate file extensions"));
       
   248             BtnAssociateFiles->setVisible(!custom_data && !custom_config);
       
   249             MiscLayout->addWidget(BtnAssociateFiles, 6, 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, 7, 0, 1, 3);
       
   256     #endif
       
   257     #endif
       
   258             page1Layout->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             GBAreslayout->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 
       
   342             GBAstereolayout->addWidget(CBStereoMode);
       
   343             GBAlayout->addLayout(GBAstereolayout);
       
   344 
       
   345             QHBoxLayout * GBAfpslayout = new QHBoxLayout(0);
       
   346             QLabel * maxfps = new QLabel(AGGroupBox);
       
   347             maxfps->setText(QLabel::tr("FPS limit"));
       
   348             GBAfpslayout->addWidget(maxfps);
       
   349             GBAlayout->addLayout(GBAfpslayout);
       
   350             fpsedit = new FPSEdit(AGGroupBox);
       
   351             GBAfpslayout->addWidget(fpsedit);
       
   352 
       
   353             CBShowFPS = new QCheckBox(AGGroupBox);
       
   354             CBShowFPS->setText(QCheckBox::tr("Show FPS"));
       
   355             GBAfpslayout->addWidget(CBShowFPS);
       
   356 
       
   357             hr = new QFrame(AGGroupBox);
       
   358             hr->setFrameStyle(QFrame::HLine);
       
   359             hr->setLineWidth(3);
       
   360             hr->setFixedHeight(10);
       
   361             GBAlayout->addWidget(hr);
       
   362 
       
   363             QGridLayout * GBAvollayout = new QGridLayout();
       
   364             QLabel * vol = new QLabel(AGGroupBox);
       
   365             vol->setText(QLabel::tr("Initial sound volume"));
       
   366             GBAvollayout->addWidget(vol, 0, 0, 1, 2);
       
   367             GBAlayout->addLayout(GBAvollayout);
       
   368             volumeBox = new QSpinBox(AGGroupBox);
       
   369             volumeBox->setRange(0, 100);
       
   370             volumeBox->setSingleStep(5);
       
   371             GBAvollayout->addWidget(volumeBox, 0, 2);
       
   372 
       
   373             CBEnableSound = new QCheckBox(AGGroupBox);
       
   374             CBEnableSound->setText(QCheckBox::tr("Enable sound"));
       
   375             GBAvollayout->addWidget(CBEnableSound, 1, 0, 1, 1);
       
   376 
       
   377             CBEnableMusic = new QCheckBox(AGGroupBox);
       
   378             CBEnableMusic->setText(QCheckBox::tr("Enable music"));
       
   379             GBAvollayout->addWidget(CBEnableMusic, 1, 1, 1, 2);
       
   380 
       
   381             GBAvollayout->setSizeConstraint(QLayout::SetMinimumSize);
       
   382 
       
   383             hr = new QFrame(AGGroupBox);
       
   384             hr->setFrameStyle(QFrame::HLine);
       
   385             hr->setLineWidth(3);
       
   386             hr->setFixedHeight(10);
       
   387             GBAlayout->addWidget(hr);
       
   388 
       
   389             CBAltDamage = new QCheckBox(AGGroupBox);
       
   390             CBAltDamage->setText(QCheckBox::tr("Alternative damage show"));
       
   391             GBAlayout->addWidget(CBAltDamage);
       
   392 
       
   393             page1Layout->addWidget(AGGroupBox, 0, 1, 3, 1);
       
   394         }
   106     }
   395     }
   107 
   396 
   108     {
   397     { // page 2
   109         IconedGroupBox* groupWeapons = new IconedGroupBox(this);
   398         QGridLayout * page2Layout = new QGridLayout(page2);
   110 
   399 
   111         //groupWeapons->setContentTopPadding(0);
   400         IconedGroupBox * gbColors = new IconedGroupBox(this);
   112         //groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   401         //gbColors->setIcon(QIcon(":/res/teamicon.png"));
   113         groupWeapons->setIcon(QIcon(":/res/weaponsicon.png"));
   402         gbColors->setTitle(QGroupBox::tr("Custom colors"));
   114         groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
   403         page2Layout->addWidget(gbColors, 0, 0, 1, 3);
   115         groupWeapons->setTitle(QGroupBox::tr("Schemes and Weapons"));
   404         QVBoxLayout * gbCLayout = new QVBoxLayout(gbColors);
   116         QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons);
   405 
   117 
   406         QSignalMapper * mapper = new QSignalMapper(this);
   118         QLabel* SchemeLabel = new QLabel(groupWeapons);
   407 
   119         SchemeLabel->setText(QLabel::tr("Game scheme"));
   408         QStandardItemModel * model = DataManager::instance().colorsModel();
   120         WeaponsLayout->addWidget(SchemeLabel, 1, 0);
   409 
   121 
   410         connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(onColorModelDataChanged(QModelIndex,QModelIndex)));
   122         SchemesName = new QComboBox(groupWeapons);
   411         for(int i = 0; i < model->rowCount(); ++i)
   123         WeaponsLayout->addWidget(SchemesName, 1, 1);
       
   124 
       
   125         SchemeNew = new QPushButton(groupWeapons);
       
   126         SchemeNew->setWhatsThis(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->setWhatsThis(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->setWhatsThis(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->setWhatsThis(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->setWhatsThis(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->setWhatsThis(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::MinimumExpanding);
       
   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         // Label for "Language"
       
   191         QLabel *labelLanguage = new QLabel(groupMisc);
       
   192         labelLanguage->setText(QLabel::tr("Locale") + " *");
       
   193         MiscLayout->addWidget(labelLanguage, 0, 0);
       
   194 
       
   195         // List of installed languages
       
   196         CBLanguage = new QComboBox(groupMisc);
       
   197         QDir tmpdir;
       
   198         tmpdir.cd(cfgdir->absolutePath());
       
   199         tmpdir.cd("Data/Locale");
       
   200         tmpdir.setFilter(QDir::Files);
       
   201         QStringList locs = tmpdir.entryList(QStringList("hedgewars_*.qm"));
       
   202         CBLanguage->addItem(QComboBox::tr("(System default)"), QString(""));
       
   203         for(int i = 0; i < locs.count(); i++)
       
   204         {
   412         {
   205             QLocale loc(locs[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1"));
   413             QPushButton * btn = new QPushButton(this);
   206             CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name());
   414             gbCLayout->addWidget(btn);
       
   415             btn->setStyleSheet(QString("background: %1").arg(model->item(i)->data().value<QColor>().name()));
       
   416             m_colorButtons.append(btn);
       
   417             connect(btn, SIGNAL(clicked()), mapper, SLOT(map()));
       
   418             mapper->setMapping(btn, i);
   207         }
   419         }
   208 
   420 
   209         tmpdir.cd(datadir->absolutePath());
   421         connect(mapper, SIGNAL(mapped(int)), this, SLOT(colorButtonClicked(int)));
   210         tmpdir.cd("Locale");
       
   211         tmpdir.setFilter(QDir::Files);
       
   212         QStringList tmplist = tmpdir.entryList(QStringList("hedgewars_*.qm"));
       
   213         for(int i = 0; i < tmplist.count(); i++)
       
   214         {
       
   215             if (locs.contains(tmplist[i])) continue;
       
   216             QLocale loc(tmplist[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1"));
       
   217             CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name());
       
   218         }
       
   219 
       
   220         MiscLayout->addWidget(CBLanguage, 0, 1);
       
   221 
       
   222         // Label and field for net nick
       
   223         labelNN = new QLabel(groupMisc);
       
   224         labelNN->setText(QLabel::tr("Nickname"));
       
   225         MiscLayout->addWidget(labelNN, 1, 0);
       
   226 
       
   227         editNetNick = new QLineEdit(groupMisc);
       
   228         editNetNick->setMaxLength(20);
       
   229         editNetNick->setText(QLineEdit::tr("anonymous"));
       
   230         MiscLayout->addWidget(editNetNick, 1, 1);
       
   231 
       
   232         // checkbox and field for password
       
   233         CBSavePassword = new QCheckBox(groupMisc);
       
   234         CBSavePassword->setText(QCheckBox::tr("Save password"));
       
   235         MiscLayout->addWidget(CBSavePassword, 2, 0);
       
   236 
       
   237         editNetPassword = new QLineEdit(groupMisc);
       
   238         editNetPassword->setEchoMode(QLineEdit::Password);
       
   239         MiscLayout->addWidget(editNetPassword, 2, 1);
       
   240 
       
   241         CBNameWithDate = new QCheckBox(groupMisc);
       
   242         CBNameWithDate->setText(QCheckBox::tr("Append date and time to record file name"));
       
   243         MiscLayout->addWidget(CBNameWithDate, 5, 0, 1, 2);
       
   244 
       
   245         BtnAssociateFiles = new QPushButton(groupMisc);
       
   246         BtnAssociateFiles->setText(QPushButton::tr("Associate file extensions"));
       
   247         BtnAssociateFiles->setVisible(!custom_data && !custom_config);
       
   248         MiscLayout->addWidget(BtnAssociateFiles, 6, 0, 1, 2);
       
   249 
       
   250 #ifdef __APPLE__
       
   251 #ifdef SPARKLE_ENABLED
       
   252         CBAutoUpdate = new QCheckBox(groupMisc);
       
   253         CBAutoUpdate->setText(QCheckBox::tr("Check for updates at startup"));
       
   254         MiscLayout->addWidget(CBAutoUpdate, 7, 0, 1, 3);
       
   255 #endif
       
   256 #endif
       
   257         gbTBLayout->addWidget(groupMisc, 2, 0);
       
   258     }
       
   259 
       
   260     {
       
   261         AGGroupBox = new IconedGroupBox(this);
       
   262         //AGGroupBox->setContentTopPadding(0);
       
   263         AGGroupBox->setIcon(QIcon(":/res/graphicsicon.png"));
       
   264         //AGGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
       
   265         AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options"));
       
   266 
       
   267         QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox);
       
   268         QHBoxLayout * GBAreslayout = new QHBoxLayout(0);
       
   269         QHBoxLayout * GBAstereolayout = new QHBoxLayout(0);
       
   270         QHBoxLayout * GBAqualayout = new QHBoxLayout(0);
       
   271 
       
   272         CBFrontendFullscreen = new QCheckBox(AGGroupBox);
       
   273         CBFrontendFullscreen->setText(QCheckBox::tr("Frontend fullscreen"));
       
   274         GBAlayout->addWidget(CBFrontendFullscreen);
       
   275 
       
   276         CBFrontendEffects = new QCheckBox(AGGroupBox);
       
   277         CBFrontendEffects->setText(QCheckBox::tr("Frontend effects"));
       
   278         GBAlayout->addWidget(CBFrontendEffects);
       
   279 
       
   280         CBEnableFrontendSound = new QCheckBox(AGGroupBox);
       
   281         CBEnableFrontendSound->setText(QCheckBox::tr("Enable frontend sounds"));
       
   282         GBAlayout->addWidget(CBEnableFrontendSound);
       
   283 
       
   284         CBEnableFrontendMusic = new QCheckBox(AGGroupBox);
       
   285         CBEnableFrontendMusic->setText(QCheckBox::tr("Enable frontend music"));
       
   286         GBAlayout->addWidget(CBEnableFrontendMusic);
       
   287 
       
   288         QFrame * hr = new QFrame(AGGroupBox);
       
   289         hr->setFrameStyle(QFrame::HLine);
       
   290         hr->setLineWidth(3);
       
   291         hr->setFixedHeight(10);
       
   292         GBAlayout->addWidget(hr);
       
   293 
       
   294         QLabel * resolution = new QLabel(AGGroupBox);
       
   295         resolution->setText(QLabel::tr("Resolution"));
       
   296         GBAreslayout->addWidget(resolution);
       
   297 
       
   298         CBResolution = new QComboBox(AGGroupBox);
       
   299         GBAreslayout->addWidget(CBResolution);
       
   300         GBAlayout->addLayout(GBAreslayout);
       
   301 
       
   302         CBFullscreen = new QCheckBox(AGGroupBox);
       
   303         CBFullscreen->setText(QCheckBox::tr("Fullscreen"));
       
   304         GBAreslayout->addWidget(CBFullscreen);
       
   305 
       
   306         QLabel * quality = new QLabel(AGGroupBox);
       
   307         quality->setText(QLabel::tr("Quality"));
       
   308         quality->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
       
   309         GBAqualayout->addWidget(quality);
       
   310 
       
   311         SLQuality = new QSlider(Qt::Horizontal, AGGroupBox);
       
   312         SLQuality->setTickPosition(QSlider::TicksBelow);
       
   313         SLQuality->setMaximum(5);
       
   314         SLQuality->setMinimum(0);
       
   315         SLQuality->setFixedWidth(150);
       
   316         GBAqualayout->addWidget(SLQuality);
       
   317         GBAlayout->addLayout(GBAqualayout);
       
   318 
       
   319         QLabel * stereo = new QLabel(AGGroupBox);
       
   320         stereo->setText(QLabel::tr("Stereo rendering"));
       
   321         GBAstereolayout->addWidget(stereo);
       
   322 
       
   323         CBStereoMode = new QComboBox(AGGroupBox);
       
   324         CBStereoMode->addItem(QComboBox::tr("Disabled"));
       
   325         CBStereoMode->addItem(QComboBox::tr("Red/Cyan"));
       
   326         CBStereoMode->addItem(QComboBox::tr("Cyan/Red"));
       
   327         CBStereoMode->addItem(QComboBox::tr("Red/Blue"));
       
   328         CBStereoMode->addItem(QComboBox::tr("Blue/Red"));
       
   329         CBStereoMode->addItem(QComboBox::tr("Red/Green"));
       
   330         CBStereoMode->addItem(QComboBox::tr("Green/Red"));
       
   331         CBStereoMode->addItem(QComboBox::tr("Side-by-side"));
       
   332         CBStereoMode->addItem(QComboBox::tr("Top-Bottom"));
       
   333         CBStereoMode->addItem(QComboBox::tr("Wiggle"));
       
   334         CBStereoMode->addItem(QComboBox::tr("Red/Cyan grayscale"));
       
   335         CBStereoMode->addItem(QComboBox::tr("Cyan/Red grayscale"));
       
   336         CBStereoMode->addItem(QComboBox::tr("Red/Blue grayscale"));
       
   337         CBStereoMode->addItem(QComboBox::tr("Blue/Red grayscale"));
       
   338         CBStereoMode->addItem(QComboBox::tr("Red/Green grayscale"));
       
   339         CBStereoMode->addItem(QComboBox::tr("Green/Red grayscale"));
       
   340 
       
   341         GBAstereolayout->addWidget(CBStereoMode);
       
   342         GBAlayout->addLayout(GBAstereolayout);
       
   343 
       
   344         QHBoxLayout * GBAfpslayout = new QHBoxLayout(0);
       
   345         QLabel * maxfps = new QLabel(AGGroupBox);
       
   346         maxfps->setText(QLabel::tr("FPS limit"));
       
   347         GBAfpslayout->addWidget(maxfps);
       
   348         GBAlayout->addLayout(GBAfpslayout);
       
   349         fpsedit = new FPSEdit(AGGroupBox);
       
   350         GBAfpslayout->addWidget(fpsedit);
       
   351 
       
   352         CBShowFPS = new QCheckBox(AGGroupBox);
       
   353         CBShowFPS->setText(QCheckBox::tr("Show FPS"));
       
   354         GBAfpslayout->addWidget(CBShowFPS);
       
   355 
       
   356         hr = new QFrame(AGGroupBox);
       
   357         hr->setFrameStyle(QFrame::HLine);
       
   358         hr->setLineWidth(3);
       
   359         hr->setFixedHeight(10);
       
   360         GBAlayout->addWidget(hr);
       
   361 
       
   362         QGridLayout * GBAvollayout = new QGridLayout();
       
   363         QLabel * vol = new QLabel(AGGroupBox);
       
   364         vol->setText(QLabel::tr("Initial sound volume"));
       
   365         GBAvollayout->addWidget(vol, 0, 0, 1, 2);
       
   366         GBAlayout->addLayout(GBAvollayout);
       
   367         volumeBox = new QSpinBox(AGGroupBox);
       
   368         volumeBox->setRange(0, 100);
       
   369         volumeBox->setSingleStep(5);
       
   370         GBAvollayout->addWidget(volumeBox, 0, 2);
       
   371 
       
   372         CBEnableSound = new QCheckBox(AGGroupBox);
       
   373         CBEnableSound->setText(QCheckBox::tr("Enable sound"));
       
   374         GBAvollayout->addWidget(CBEnableSound, 1, 0, 1, 1);
       
   375 
       
   376         CBEnableMusic = new QCheckBox(AGGroupBox);
       
   377         CBEnableMusic->setText(QCheckBox::tr("Enable music"));
       
   378         GBAvollayout->addWidget(CBEnableMusic, 1, 1, 1, 2);
       
   379 
       
   380         GBAvollayout->setSizeConstraint(QLayout::SetMinimumSize);
       
   381 
       
   382         hr = new QFrame(AGGroupBox);
       
   383         hr->setFrameStyle(QFrame::HLine);
       
   384         hr->setLineWidth(3);
       
   385         hr->setFixedHeight(10);
       
   386         GBAlayout->addWidget(hr);
       
   387 
       
   388         CBAltDamage = new QCheckBox(AGGroupBox);
       
   389         CBAltDamage->setText(QCheckBox::tr("Alternative damage show"));
       
   390         GBAlayout->addWidget(CBAltDamage);
       
   391 
       
   392         gbTBLayout->addWidget(AGGroupBox, 0, 1, 3, 1);
       
   393     }
   422     }
   394 
   423 
   395     previousQuality = this->SLQuality->value();
   424     previousQuality = this->SLQuality->value();
   396     previousResolutionIndex = this->CBResolution->currentIndex();
   425     previousResolutionIndex = this->CBResolution->currentIndex();
   397     previousFullscreenValue = this->CBFullscreen->isChecked();
   426     previousFullscreenValue = this->CBFullscreen->isChecked();
   497     BtnEditTeam->setVisible(enabled);
   526     BtnEditTeam->setVisible(enabled);
   498     BtnDeleteTeam->setVisible(enabled);
   527     BtnDeleteTeam->setVisible(enabled);
   499     CBTeamName->setVisible(enabled);
   528     CBTeamName->setVisible(enabled);
   500     LblNoEditTeam->setVisible(!enabled);
   529     LblNoEditTeam->setVisible(!enabled);
   501 }
   530 }
       
   531 
       
   532 void PageOptions::colorButtonClicked(int i)
       
   533 {
       
   534     if(i < 0 || i >= m_colorButtons.size())
       
   535         return;
       
   536 
       
   537     QPalette p = m_colorButtons[i]->palette();
       
   538     QColor c = QColorDialog::getColor(p.color(QPalette::Button));
       
   539 
       
   540     if(c.isValid())
       
   541     {
       
   542         DataManager::instance().colorsModel()->item(i)->setData(c);
       
   543         m_colorButtons[i]->setStyleSheet(QString("background: %1").arg(c.name()));
       
   544     }
       
   545 }
       
   546 
       
   547 void PageOptions::onColorModelDataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight)
       
   548 {
       
   549     QStandardItemModel * model = DataManager::instance().colorsModel();
       
   550 
       
   551     m_colorButtons[topLeft.row()]->setStyleSheet(QString("background: %1").arg(model->item(topLeft.row())->data().value<QColor>().name()));
       
   552 }