Allow customization of colors in ui, store custom colors in config
authorunc0rr
Wed, 15 Aug 2012 23:30:23 +0400
changeset 7541 e51b11349637
parent 7539 c6ffbc6530e3
child 7543 a0dc770538e1
Allow customization of colors in ui, store custom colors in config
QTfrontend/gameuiconfig.cpp
QTfrontend/ui/page/pageoptions.cpp
QTfrontend/ui/page/pageoptions.h
--- a/QTfrontend/gameuiconfig.cpp	Wed Aug 15 16:25:24 2012 +0400
+++ b/QTfrontend/gameuiconfig.cpp	Wed Aug 15 23:30:23 2012 +0400
@@ -22,6 +22,7 @@
 #include <QDesktopWidget>
 #include <QInputDialog>
 #include <QCryptographicHash>
+#include <QStandardItemModel>
 
 #include "gameuiconfig.h"
 #include "hwform.h"
@@ -30,6 +31,7 @@
 #include "hwconsts.h"
 #include "fpsedit.h"
 #include "HWApplication.h"
+#include "DataManager.h"
 
 GameUIConfig::GameUIConfig(HWForm * FormWidgets, const QString & fileName)
     : QSettings(fileName, QSettings::IniFormat)
@@ -108,6 +110,12 @@
     depth = HWApplication::desktop()->depth();
     if (depth < 16) depth = 16;
     else if (depth > 16) depth = 32;
+
+    { // load colors
+        QStandardItemModel * model = DataManager::instance().colorsModel();
+        for(int i = model->rowCount() - 1; i >= 0; --i)
+            model->item(i)->setData(QColor(value(QString("colors/color%1").arg(i), model->item(i)->data().value<QColor>()).value<QColor>()));
+    }
 }
 
 QStringList GameUIConfig::GetTeamsList()
@@ -182,6 +190,13 @@
 #ifdef SPARKLE_ENABLED
     setValue("misc/autoUpdate", isAutoUpdateEnabled());
 #endif
+
+    { // save colors
+        QStandardItemModel * model = DataManager::instance().colorsModel();
+        for(int i = model->rowCount() - 1; i >= 0; --i)
+            setValue(QString("colors/color%1").arg(i), model->item(i)->data());
+    }
+
     Form->gameSettings->sync();
 }
 
--- a/QTfrontend/ui/page/pageoptions.cpp	Wed Aug 15 16:25:24 2012 +0400
+++ b/QTfrontend/ui/page/pageoptions.cpp	Wed Aug 15 23:30:23 2012 +0400
@@ -28,368 +28,397 @@
 #include <QTextBrowser>
 #include <QTableWidget>
 #include <QSlider>
+#include <QSignalMapper>
+#include <QColorDialog>
+#include <QStandardItemModel>
 
 #include "pageoptions.h"
 #include "hwconsts.h"
 #include "fpsedit.h"
 #include "igbox.h"
+#include "DataManager.h"
 
 // TODO cleanup
 QLayout * PageOptions::bodyLayoutDefinition()
 {
-    QGridLayout * pageLayout = new QGridLayout();
-    pageLayout->setColumnStretch(0, 100);
-    pageLayout->setColumnStretch(1, 100);
-    pageLayout->setColumnStretch(2, 100);
-    pageLayout->setRowStretch(0, 0);
-    //pageLayout->setRowStretch(1, 100);
-    pageLayout->setRowStretch(2, 0);
-    pageLayout->setContentsMargins(7, 7, 7, 0);
-    pageLayout->setSpacing(0);
+    QVBoxLayout * pageLayout = new QVBoxLayout();
 
+    QTabWidget * tabs = new QTabWidget(this);
+    pageLayout->addWidget(tabs);
+    QWidget * page1 = new QWidget(this);
+    QWidget * page2 = new QWidget(this);
+    tabs->addTab(page1, tr("General"));
+    tabs->addTab(page2, tr("Advanced"));
+
+    { // page 1
+        QGridLayout * page1Layout = new QGridLayout(page1);
+        //gbTBLayout->setMargin(0);
+        page1Layout->setSpacing(0);
+        page1Layout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
 
-    QGroupBox * gbTwoBoxes = new QGroupBox(this);
-    pageLayout->addWidget(gbTwoBoxes, 0, 0, 1, 3);
-    QGridLayout * gbTBLayout = new QGridLayout(gbTwoBoxes);
-    gbTBLayout->setMargin(0);
-    gbTBLayout->setSpacing(0);
-    gbTBLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
-
-    QPixmap pmNew(":/res/new.png");
-    QPixmap pmEdit(":/res/edit.png");
-    QPixmap pmDelete(":/res/delete.png");
+        QPixmap pmNew(":/res/new.png");
+        QPixmap pmEdit(":/res/edit.png");
+        QPixmap pmDelete(":/res/delete.png");
 
-    {
-        teamsBox = new IconedGroupBox(this);
-        //teamsBox->setContentTopPadding(0);
-        //teamsBox->setAttribute(Qt::WA_PaintOnScreen, true);
-        teamsBox->setIcon(QIcon(":/res/teamicon.png"));
-        teamsBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-        teamsBox->setTitle(QGroupBox::tr("Teams"));
+        {
+            teamsBox = new IconedGroupBox(this);
+            //teamsBox->setContentTopPadding(0);
+            //teamsBox->setAttribute(Qt::WA_PaintOnScreen, true);
+            teamsBox->setIcon(QIcon(":/res/teamicon.png"));
+            teamsBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+            teamsBox->setTitle(QGroupBox::tr("Teams"));
 
-        QGridLayout * GBTlayout = new QGridLayout(teamsBox);
+            QGridLayout * GBTlayout = new QGridLayout(teamsBox);
 
-        CBTeamName = new QComboBox(teamsBox);
-        GBTlayout->addWidget(CBTeamName, 0, 0);
+            CBTeamName = new QComboBox(teamsBox);
+            GBTlayout->addWidget(CBTeamName, 0, 0);
 
-        BtnNewTeam = new QPushButton(teamsBox);
-        BtnNewTeam->setToolTip(tr("New team"));
-        BtnNewTeam->setIconSize(pmNew.size());
-        BtnNewTeam->setIcon(pmNew);
-        BtnNewTeam->setMaximumWidth(pmNew.width() + 6);
-        connect(BtnNewTeam, SIGNAL(clicked()), this, SIGNAL(newTeamRequested()));
-        GBTlayout->addWidget(BtnNewTeam, 0, 1);
+            BtnNewTeam = new QPushButton(teamsBox);
+            BtnNewTeam->setToolTip(tr("New team"));
+            BtnNewTeam->setIconSize(pmNew.size());
+            BtnNewTeam->setIcon(pmNew);
+            BtnNewTeam->setMaximumWidth(pmNew.width() + 6);
+            connect(BtnNewTeam, SIGNAL(clicked()), this, SIGNAL(newTeamRequested()));
+            GBTlayout->addWidget(BtnNewTeam, 0, 1);
 
-        BtnEditTeam = new QPushButton(teamsBox);
-        BtnEditTeam->setToolTip(tr("Edit team"));
-        BtnEditTeam->setIconSize(pmEdit.size());
-        BtnEditTeam->setIcon(pmEdit);
-        BtnEditTeam->setMaximumWidth(pmEdit.width() + 6);
-        connect(BtnEditTeam, SIGNAL(clicked()), this, SLOT(requestEditSelectedTeam()));
-        GBTlayout->addWidget(BtnEditTeam, 0, 2);
+            BtnEditTeam = new QPushButton(teamsBox);
+            BtnEditTeam->setToolTip(tr("Edit team"));
+            BtnEditTeam->setIconSize(pmEdit.size());
+            BtnEditTeam->setIcon(pmEdit);
+            BtnEditTeam->setMaximumWidth(pmEdit.width() + 6);
+            connect(BtnEditTeam, SIGNAL(clicked()), this, SLOT(requestEditSelectedTeam()));
+            GBTlayout->addWidget(BtnEditTeam, 0, 2);
 
-        BtnDeleteTeam = new QPushButton(teamsBox);
-        BtnDeleteTeam->setToolTip(tr("Delete team"));
-        BtnDeleteTeam->setIconSize(pmDelete.size());
-        BtnDeleteTeam->setIcon(pmDelete);
-        BtnDeleteTeam->setMaximumWidth(pmDelete.width() + 6);
-        connect(BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(requestDeleteSelectedTeam()));
-        GBTlayout->addWidget(BtnDeleteTeam, 0, 3);
-
-        LblNoEditTeam = new QLabel(teamsBox);
-        LblNoEditTeam->setText(tr("You can't edit teams from team selection. Go back to main menu to add, edit or delete teams."));
-        LblNoEditTeam->setWordWrap(true);
-        LblNoEditTeam->setVisible(false);
-        GBTlayout->addWidget(LblNoEditTeam, 0, 0);
+            BtnDeleteTeam = new QPushButton(teamsBox);
+            BtnDeleteTeam->setToolTip(tr("Delete team"));
+            BtnDeleteTeam->setIconSize(pmDelete.size());
+            BtnDeleteTeam->setIcon(pmDelete);
+            BtnDeleteTeam->setMaximumWidth(pmDelete.width() + 6);
+            connect(BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(requestDeleteSelectedTeam()));
+            GBTlayout->addWidget(BtnDeleteTeam, 0, 3);
 
-        gbTBLayout->addWidget(teamsBox, 0, 0);
-    }
-
-    {
-        IconedGroupBox* groupWeapons = new IconedGroupBox(this);
+            LblNoEditTeam = new QLabel(teamsBox);
+            LblNoEditTeam->setText(tr("You can't edit teams from team selection. Go back to main menu to add, edit or delete teams."));
+            LblNoEditTeam->setWordWrap(true);
+            LblNoEditTeam->setVisible(false);
+            GBTlayout->addWidget(LblNoEditTeam, 0, 0);
 
-        //groupWeapons->setContentTopPadding(0);
-        //groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
-        groupWeapons->setIcon(QIcon(":/res/weaponsicon.png"));
-        groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-        groupWeapons->setTitle(QGroupBox::tr("Schemes and Weapons"));
-        QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons);
+            page1Layout->addWidget(teamsBox, 0, 0);
+        }
 
-        QLabel* SchemeLabel = new QLabel(groupWeapons);
-        SchemeLabel->setText(QLabel::tr("Game scheme"));
-        WeaponsLayout->addWidget(SchemeLabel, 1, 0);
+        {
+            IconedGroupBox* groupWeapons = new IconedGroupBox(this);
 
-        SchemesName = new QComboBox(groupWeapons);
-        WeaponsLayout->addWidget(SchemesName, 1, 1);
+            //groupWeapons->setContentTopPadding(0);
+            //groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+            groupWeapons->setIcon(QIcon(":/res/weaponsicon.png"));
+            groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+            groupWeapons->setTitle(QGroupBox::tr("Schemes and Weapons"));
+            QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons);
 
-        SchemeNew = new QPushButton(groupWeapons);
-        SchemeNew->setWhatsThis(tr("New scheme"));
-        SchemeNew->setIconSize(pmNew.size());
-        SchemeNew->setIcon(pmNew);
-        SchemeNew->setMaximumWidth(pmNew.width() + 6);
-        WeaponsLayout->addWidget(SchemeNew, 1, 2);
+            QLabel* SchemeLabel = new QLabel(groupWeapons);
+            SchemeLabel->setText(QLabel::tr("Game scheme"));
+            WeaponsLayout->addWidget(SchemeLabel, 1, 0);
 
-        SchemeEdit = new QPushButton(groupWeapons);
-        SchemeEdit->setWhatsThis(tr("Edit scheme"));
-        SchemeEdit->setIconSize(pmEdit.size());
-        SchemeEdit->setIcon(pmEdit);
-        SchemeEdit->setMaximumWidth(pmEdit.width() + 6);
-        WeaponsLayout->addWidget(SchemeEdit, 1, 3);
+            SchemesName = new QComboBox(groupWeapons);
+            WeaponsLayout->addWidget(SchemesName, 1, 1);
 
-        SchemeDelete = new QPushButton(groupWeapons);
-        SchemeDelete->setWhatsThis(tr("Delete scheme"));
-        SchemeDelete->setIconSize(pmDelete.size());
-        SchemeDelete->setIcon(pmDelete);
-        SchemeDelete->setMaximumWidth(pmDelete.width() + 6);
-        WeaponsLayout->addWidget(SchemeDelete, 1, 4);
+            SchemeNew = new QPushButton(groupWeapons);
+            SchemeNew->setWhatsThis(tr("New scheme"));
+            SchemeNew->setIconSize(pmNew.size());
+            SchemeNew->setIcon(pmNew);
+            SchemeNew->setMaximumWidth(pmNew.width() + 6);
+            WeaponsLayout->addWidget(SchemeNew, 1, 2);
 
-        QLabel* WeaponLabel = new QLabel(groupWeapons);
-        WeaponLabel->setText(QLabel::tr("Weapons"));
-        WeaponsLayout->addWidget(WeaponLabel, 2, 0);
-
-        WeaponsName = new QComboBox(groupWeapons);
-        WeaponsLayout->addWidget(WeaponsName, 2, 1);
-
-        WeaponNew = new QPushButton(groupWeapons);
-        WeaponNew->setWhatsThis(tr("New weapon set"));
-        WeaponNew->setIconSize(pmNew.size());
-        WeaponNew->setIcon(pmNew);
-        WeaponNew->setMaximumWidth(pmNew.width() + 6);
-        WeaponsLayout->addWidget(WeaponNew, 2, 2);
+            SchemeEdit = new QPushButton(groupWeapons);
+            SchemeEdit->setWhatsThis(tr("Edit scheme"));
+            SchemeEdit->setIconSize(pmEdit.size());
+            SchemeEdit->setIcon(pmEdit);
+            SchemeEdit->setMaximumWidth(pmEdit.width() + 6);
+            WeaponsLayout->addWidget(SchemeEdit, 1, 3);
 
-        WeaponEdit = new QPushButton(groupWeapons);
-        WeaponEdit->setWhatsThis(tr("Edit weapon set"));
-        WeaponEdit->setIconSize(pmEdit.size());
-        WeaponEdit->setIcon(pmEdit);
-        WeaponEdit->setMaximumWidth(pmEdit.width() + 6);
-        WeaponsLayout->addWidget(WeaponEdit, 2, 3);
+            SchemeDelete = new QPushButton(groupWeapons);
+            SchemeDelete->setWhatsThis(tr("Delete scheme"));
+            SchemeDelete->setIconSize(pmDelete.size());
+            SchemeDelete->setIcon(pmDelete);
+            SchemeDelete->setMaximumWidth(pmDelete.width() + 6);
+            WeaponsLayout->addWidget(SchemeDelete, 1, 4);
 
-        WeaponDelete = new QPushButton(groupWeapons);
-        WeaponDelete->setWhatsThis(tr("Delete weapon set"));
-        WeaponDelete->setIconSize(pmDelete.size());
-        WeaponDelete->setIcon(pmDelete);
-        WeaponDelete->setMaximumWidth(pmDelete.width() + 6);
-        WeaponsLayout->addWidget(WeaponDelete, 2, 4);
+            QLabel* WeaponLabel = new QLabel(groupWeapons);
+            WeaponLabel->setText(QLabel::tr("Weapons"));
+            WeaponsLayout->addWidget(WeaponLabel, 2, 0);
 
-        WeaponTooltip = new QCheckBox(this);
-        WeaponTooltip->setText(QCheckBox::tr("Show ammo menu tooltips"));
-        WeaponsLayout->addWidget(WeaponTooltip, 3, 0, 1, 4);
-
-        gbTBLayout->addWidget(groupWeapons, 1, 0);
-    }
+            WeaponsName = new QComboBox(groupWeapons);
+            WeaponsLayout->addWidget(WeaponsName, 2, 1);
 
-    {
-        IconedGroupBox* groupMisc = new IconedGroupBox(this);
-        //groupMisc->setContentTopPadding(0);
-        groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
-        groupMisc->setIcon(QIcon(":/res/miscicon.png"));
-        //groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-        groupMisc->setTitle(QGroupBox::tr("Misc"));
-        QGridLayout * MiscLayout = new QGridLayout(groupMisc);
+            WeaponNew = new QPushButton(groupWeapons);
+            WeaponNew->setWhatsThis(tr("New weapon set"));
+            WeaponNew->setIconSize(pmNew.size());
+            WeaponNew->setIcon(pmNew);
+            WeaponNew->setMaximumWidth(pmNew.width() + 6);
+            WeaponsLayout->addWidget(WeaponNew, 2, 2);
 
-        // Label for "Language"
-        QLabel *labelLanguage = new QLabel(groupMisc);
-        labelLanguage->setText(QLabel::tr("Locale") + " *");
-        MiscLayout->addWidget(labelLanguage, 0, 0);
+            WeaponEdit = new QPushButton(groupWeapons);
+            WeaponEdit->setWhatsThis(tr("Edit weapon set"));
+            WeaponEdit->setIconSize(pmEdit.size());
+            WeaponEdit->setIcon(pmEdit);
+            WeaponEdit->setMaximumWidth(pmEdit.width() + 6);
+            WeaponsLayout->addWidget(WeaponEdit, 2, 3);
 
-        // List of installed languages
-        CBLanguage = new QComboBox(groupMisc);
-        QDir tmpdir;
-        tmpdir.cd(cfgdir->absolutePath());
-        tmpdir.cd("Data/Locale");
-        tmpdir.setFilter(QDir::Files);
-        QStringList locs = tmpdir.entryList(QStringList("hedgewars_*.qm"));
-        CBLanguage->addItem(QComboBox::tr("(System default)"), QString(""));
-        for(int i = 0; i < locs.count(); i++)
-        {
-            QLocale loc(locs[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1"));
-            CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name());
+            WeaponDelete = new QPushButton(groupWeapons);
+            WeaponDelete->setWhatsThis(tr("Delete weapon set"));
+            WeaponDelete->setIconSize(pmDelete.size());
+            WeaponDelete->setIcon(pmDelete);
+            WeaponDelete->setMaximumWidth(pmDelete.width() + 6);
+            WeaponsLayout->addWidget(WeaponDelete, 2, 4);
+
+            WeaponTooltip = new QCheckBox(this);
+            WeaponTooltip->setText(QCheckBox::tr("Show ammo menu tooltips"));
+            WeaponsLayout->addWidget(WeaponTooltip, 3, 0, 1, 4);
+
+            page1Layout->addWidget(groupWeapons, 1, 0);
         }
 
-        tmpdir.cd(datadir->absolutePath());
-        tmpdir.cd("Locale");
-        tmpdir.setFilter(QDir::Files);
-        QStringList tmplist = tmpdir.entryList(QStringList("hedgewars_*.qm"));
-        for(int i = 0; i < tmplist.count(); i++)
         {
-            if (locs.contains(tmplist[i])) continue;
-            QLocale loc(tmplist[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1"));
-            CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name());
+            IconedGroupBox* groupMisc = new IconedGroupBox(this);
+            //groupMisc->setContentTopPadding(0);
+            groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
+            groupMisc->setIcon(QIcon(":/res/miscicon.png"));
+            //groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+            groupMisc->setTitle(QGroupBox::tr("Misc"));
+            QGridLayout * MiscLayout = new QGridLayout(groupMisc);
+
+            // Label for "Language"
+            QLabel *labelLanguage = new QLabel(groupMisc);
+            labelLanguage->setText(QLabel::tr("Locale") + " *");
+            MiscLayout->addWidget(labelLanguage, 0, 0);
+
+            // List of installed languages
+            CBLanguage = new QComboBox(groupMisc);
+            QDir tmpdir;
+            tmpdir.cd(cfgdir->absolutePath());
+            tmpdir.cd("Data/Locale");
+            tmpdir.setFilter(QDir::Files);
+            QStringList locs = tmpdir.entryList(QStringList("hedgewars_*.qm"));
+            CBLanguage->addItem(QComboBox::tr("(System default)"), QString(""));
+            for(int i = 0; i < locs.count(); i++)
+            {
+                QLocale loc(locs[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1"));
+                CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name());
+            }
+
+            tmpdir.cd(datadir->absolutePath());
+            tmpdir.cd("Locale");
+            tmpdir.setFilter(QDir::Files);
+            QStringList tmplist = tmpdir.entryList(QStringList("hedgewars_*.qm"));
+            for(int i = 0; i < tmplist.count(); i++)
+            {
+                if (locs.contains(tmplist[i])) continue;
+                QLocale loc(tmplist[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1"));
+                CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name());
+            }
+
+            MiscLayout->addWidget(CBLanguage, 0, 1);
+
+            // Label and field for net nick
+            labelNN = new QLabel(groupMisc);
+            labelNN->setText(QLabel::tr("Nickname"));
+            MiscLayout->addWidget(labelNN, 1, 0);
+
+            editNetNick = new QLineEdit(groupMisc);
+            editNetNick->setMaxLength(20);
+            editNetNick->setText(QLineEdit::tr("anonymous"));
+            MiscLayout->addWidget(editNetNick, 1, 1);
+
+            // checkbox and field for password
+            CBSavePassword = new QCheckBox(groupMisc);
+            CBSavePassword->setText(QCheckBox::tr("Save password"));
+            MiscLayout->addWidget(CBSavePassword, 2, 0);
+
+            editNetPassword = new QLineEdit(groupMisc);
+            editNetPassword->setEchoMode(QLineEdit::Password);
+            MiscLayout->addWidget(editNetPassword, 2, 1);
+
+            CBNameWithDate = new QCheckBox(groupMisc);
+            CBNameWithDate->setText(QCheckBox::tr("Append date and time to record file name"));
+            MiscLayout->addWidget(CBNameWithDate, 5, 0, 1, 2);
+
+            BtnAssociateFiles = new QPushButton(groupMisc);
+            BtnAssociateFiles->setText(QPushButton::tr("Associate file extensions"));
+            BtnAssociateFiles->setVisible(!custom_data && !custom_config);
+            MiscLayout->addWidget(BtnAssociateFiles, 6, 0, 1, 2);
+
+    #ifdef __APPLE__
+    #ifdef SPARKLE_ENABLED
+            CBAutoUpdate = new QCheckBox(groupMisc);
+            CBAutoUpdate->setText(QCheckBox::tr("Check for updates at startup"));
+            MiscLayout->addWidget(CBAutoUpdate, 7, 0, 1, 3);
+    #endif
+    #endif
+            page1Layout->addWidget(groupMisc, 2, 0);
         }
 
-        MiscLayout->addWidget(CBLanguage, 0, 1);
+        {
+            AGGroupBox = new IconedGroupBox(this);
+            //AGGroupBox->setContentTopPadding(0);
+            AGGroupBox->setIcon(QIcon(":/res/graphicsicon.png"));
+            //AGGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
+            AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options"));
+
+            QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox);
+            QHBoxLayout * GBAreslayout = new QHBoxLayout(0);
+            QHBoxLayout * GBAstereolayout = new QHBoxLayout(0);
+            QHBoxLayout * GBAqualayout = new QHBoxLayout(0);
 
-        // Label and field for net nick
-        labelNN = new QLabel(groupMisc);
-        labelNN->setText(QLabel::tr("Nickname"));
-        MiscLayout->addWidget(labelNN, 1, 0);
+            CBFrontendFullscreen = new QCheckBox(AGGroupBox);
+            CBFrontendFullscreen->setText(QCheckBox::tr("Frontend fullscreen"));
+            GBAlayout->addWidget(CBFrontendFullscreen);
+
+            CBFrontendEffects = new QCheckBox(AGGroupBox);
+            CBFrontendEffects->setText(QCheckBox::tr("Frontend effects"));
+            GBAlayout->addWidget(CBFrontendEffects);
+
+            CBEnableFrontendSound = new QCheckBox(AGGroupBox);
+            CBEnableFrontendSound->setText(QCheckBox::tr("Enable frontend sounds"));
+            GBAlayout->addWidget(CBEnableFrontendSound);
+
+            CBEnableFrontendMusic = new QCheckBox(AGGroupBox);
+            CBEnableFrontendMusic->setText(QCheckBox::tr("Enable frontend music"));
+            GBAlayout->addWidget(CBEnableFrontendMusic);
 
-        editNetNick = new QLineEdit(groupMisc);
-        editNetNick->setMaxLength(20);
-        editNetNick->setText(QLineEdit::tr("anonymous"));
-        MiscLayout->addWidget(editNetNick, 1, 1);
+            QFrame * hr = new QFrame(AGGroupBox);
+            hr->setFrameStyle(QFrame::HLine);
+            hr->setLineWidth(3);
+            hr->setFixedHeight(10);
+            GBAlayout->addWidget(hr);
+
+            QLabel * resolution = new QLabel(AGGroupBox);
+            resolution->setText(QLabel::tr("Resolution"));
+            GBAreslayout->addWidget(resolution);
+
+            CBResolution = new QComboBox(AGGroupBox);
+            GBAreslayout->addWidget(CBResolution);
+            GBAlayout->addLayout(GBAreslayout);
 
-        // checkbox and field for password
-        CBSavePassword = new QCheckBox(groupMisc);
-        CBSavePassword->setText(QCheckBox::tr("Save password"));
-        MiscLayout->addWidget(CBSavePassword, 2, 0);
+            CBFullscreen = new QCheckBox(AGGroupBox);
+            CBFullscreen->setText(QCheckBox::tr("Fullscreen"));
+            GBAreslayout->addWidget(CBFullscreen);
+
+            QLabel * quality = new QLabel(AGGroupBox);
+            quality->setText(QLabel::tr("Quality"));
+            quality->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+            GBAqualayout->addWidget(quality);
+
+            SLQuality = new QSlider(Qt::Horizontal, AGGroupBox);
+            SLQuality->setTickPosition(QSlider::TicksBelow);
+            SLQuality->setMaximum(5);
+            SLQuality->setMinimum(0);
+            SLQuality->setFixedWidth(150);
+            GBAqualayout->addWidget(SLQuality);
+            GBAlayout->addLayout(GBAqualayout);
+
+            QLabel * stereo = new QLabel(AGGroupBox);
+            stereo->setText(QLabel::tr("Stereo rendering"));
+            GBAstereolayout->addWidget(stereo);
 
-        editNetPassword = new QLineEdit(groupMisc);
-        editNetPassword->setEchoMode(QLineEdit::Password);
-        MiscLayout->addWidget(editNetPassword, 2, 1);
+            CBStereoMode = new QComboBox(AGGroupBox);
+            CBStereoMode->addItem(QComboBox::tr("Disabled"));
+            CBStereoMode->addItem(QComboBox::tr("Red/Cyan"));
+            CBStereoMode->addItem(QComboBox::tr("Cyan/Red"));
+            CBStereoMode->addItem(QComboBox::tr("Red/Blue"));
+            CBStereoMode->addItem(QComboBox::tr("Blue/Red"));
+            CBStereoMode->addItem(QComboBox::tr("Red/Green"));
+            CBStereoMode->addItem(QComboBox::tr("Green/Red"));
+            CBStereoMode->addItem(QComboBox::tr("Side-by-side"));
+            CBStereoMode->addItem(QComboBox::tr("Top-Bottom"));
+            CBStereoMode->addItem(QComboBox::tr("Wiggle"));
+            CBStereoMode->addItem(QComboBox::tr("Red/Cyan grayscale"));
+            CBStereoMode->addItem(QComboBox::tr("Cyan/Red grayscale"));
+            CBStereoMode->addItem(QComboBox::tr("Red/Blue grayscale"));
+            CBStereoMode->addItem(QComboBox::tr("Blue/Red grayscale"));
+            CBStereoMode->addItem(QComboBox::tr("Red/Green grayscale"));
+            CBStereoMode->addItem(QComboBox::tr("Green/Red grayscale"));
 
-        CBNameWithDate = new QCheckBox(groupMisc);
-        CBNameWithDate->setText(QCheckBox::tr("Append date and time to record file name"));
-        MiscLayout->addWidget(CBNameWithDate, 5, 0, 1, 2);
+            GBAstereolayout->addWidget(CBStereoMode);
+            GBAlayout->addLayout(GBAstereolayout);
+
+            QHBoxLayout * GBAfpslayout = new QHBoxLayout(0);
+            QLabel * maxfps = new QLabel(AGGroupBox);
+            maxfps->setText(QLabel::tr("FPS limit"));
+            GBAfpslayout->addWidget(maxfps);
+            GBAlayout->addLayout(GBAfpslayout);
+            fpsedit = new FPSEdit(AGGroupBox);
+            GBAfpslayout->addWidget(fpsedit);
+
+            CBShowFPS = new QCheckBox(AGGroupBox);
+            CBShowFPS->setText(QCheckBox::tr("Show FPS"));
+            GBAfpslayout->addWidget(CBShowFPS);
 
-        BtnAssociateFiles = new QPushButton(groupMisc);
-        BtnAssociateFiles->setText(QPushButton::tr("Associate file extensions"));
-        BtnAssociateFiles->setVisible(!custom_data && !custom_config);
-        MiscLayout->addWidget(BtnAssociateFiles, 6, 0, 1, 2);
+            hr = new QFrame(AGGroupBox);
+            hr->setFrameStyle(QFrame::HLine);
+            hr->setLineWidth(3);
+            hr->setFixedHeight(10);
+            GBAlayout->addWidget(hr);
+
+            QGridLayout * GBAvollayout = new QGridLayout();
+            QLabel * vol = new QLabel(AGGroupBox);
+            vol->setText(QLabel::tr("Initial sound volume"));
+            GBAvollayout->addWidget(vol, 0, 0, 1, 2);
+            GBAlayout->addLayout(GBAvollayout);
+            volumeBox = new QSpinBox(AGGroupBox);
+            volumeBox->setRange(0, 100);
+            volumeBox->setSingleStep(5);
+            GBAvollayout->addWidget(volumeBox, 0, 2);
 
-#ifdef __APPLE__
-#ifdef SPARKLE_ENABLED
-        CBAutoUpdate = new QCheckBox(groupMisc);
-        CBAutoUpdate->setText(QCheckBox::tr("Check for updates at startup"));
-        MiscLayout->addWidget(CBAutoUpdate, 7, 0, 1, 3);
-#endif
-#endif
-        gbTBLayout->addWidget(groupMisc, 2, 0);
+            CBEnableSound = new QCheckBox(AGGroupBox);
+            CBEnableSound->setText(QCheckBox::tr("Enable sound"));
+            GBAvollayout->addWidget(CBEnableSound, 1, 0, 1, 1);
+
+            CBEnableMusic = new QCheckBox(AGGroupBox);
+            CBEnableMusic->setText(QCheckBox::tr("Enable music"));
+            GBAvollayout->addWidget(CBEnableMusic, 1, 1, 1, 2);
+
+            GBAvollayout->setSizeConstraint(QLayout::SetMinimumSize);
+
+            hr = new QFrame(AGGroupBox);
+            hr->setFrameStyle(QFrame::HLine);
+            hr->setLineWidth(3);
+            hr->setFixedHeight(10);
+            GBAlayout->addWidget(hr);
+
+            CBAltDamage = new QCheckBox(AGGroupBox);
+            CBAltDamage->setText(QCheckBox::tr("Alternative damage show"));
+            GBAlayout->addWidget(CBAltDamage);
+
+            page1Layout->addWidget(AGGroupBox, 0, 1, 3, 1);
+        }
     }
 
-    {
-        AGGroupBox = new IconedGroupBox(this);
-        //AGGroupBox->setContentTopPadding(0);
-        AGGroupBox->setIcon(QIcon(":/res/graphicsicon.png"));
-        //AGGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
-        AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options"));
-
-        QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox);
-        QHBoxLayout * GBAreslayout = new QHBoxLayout(0);
-        QHBoxLayout * GBAstereolayout = new QHBoxLayout(0);
-        QHBoxLayout * GBAqualayout = new QHBoxLayout(0);
-
-        CBFrontendFullscreen = new QCheckBox(AGGroupBox);
-        CBFrontendFullscreen->setText(QCheckBox::tr("Frontend fullscreen"));
-        GBAlayout->addWidget(CBFrontendFullscreen);
-
-        CBFrontendEffects = new QCheckBox(AGGroupBox);
-        CBFrontendEffects->setText(QCheckBox::tr("Frontend effects"));
-        GBAlayout->addWidget(CBFrontendEffects);
-
-        CBEnableFrontendSound = new QCheckBox(AGGroupBox);
-        CBEnableFrontendSound->setText(QCheckBox::tr("Enable frontend sounds"));
-        GBAlayout->addWidget(CBEnableFrontendSound);
-
-        CBEnableFrontendMusic = new QCheckBox(AGGroupBox);
-        CBEnableFrontendMusic->setText(QCheckBox::tr("Enable frontend music"));
-        GBAlayout->addWidget(CBEnableFrontendMusic);
+    { // page 2
+        QGridLayout * page2Layout = new QGridLayout(page2);
 
-        QFrame * hr = new QFrame(AGGroupBox);
-        hr->setFrameStyle(QFrame::HLine);
-        hr->setLineWidth(3);
-        hr->setFixedHeight(10);
-        GBAlayout->addWidget(hr);
-
-        QLabel * resolution = new QLabel(AGGroupBox);
-        resolution->setText(QLabel::tr("Resolution"));
-        GBAreslayout->addWidget(resolution);
-
-        CBResolution = new QComboBox(AGGroupBox);
-        GBAreslayout->addWidget(CBResolution);
-        GBAlayout->addLayout(GBAreslayout);
+        IconedGroupBox * gbColors = new IconedGroupBox(this);
+        //gbColors->setIcon(QIcon(":/res/teamicon.png"));
+        gbColors->setTitle(QGroupBox::tr("Custom colors"));
+        page2Layout->addWidget(gbColors, 0, 0, 1, 3);
+        QVBoxLayout * gbCLayout = new QVBoxLayout(gbColors);
 
-        CBFullscreen = new QCheckBox(AGGroupBox);
-        CBFullscreen->setText(QCheckBox::tr("Fullscreen"));
-        GBAreslayout->addWidget(CBFullscreen);
-
-        QLabel * quality = new QLabel(AGGroupBox);
-        quality->setText(QLabel::tr("Quality"));
-        quality->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-        GBAqualayout->addWidget(quality);
+        QSignalMapper * mapper = new QSignalMapper(this);
 
-        SLQuality = new QSlider(Qt::Horizontal, AGGroupBox);
-        SLQuality->setTickPosition(QSlider::TicksBelow);
-        SLQuality->setMaximum(5);
-        SLQuality->setMinimum(0);
-        SLQuality->setFixedWidth(150);
-        GBAqualayout->addWidget(SLQuality);
-        GBAlayout->addLayout(GBAqualayout);
-
-        QLabel * stereo = new QLabel(AGGroupBox);
-        stereo->setText(QLabel::tr("Stereo rendering"));
-        GBAstereolayout->addWidget(stereo);
+        QStandardItemModel * model = DataManager::instance().colorsModel();
 
-        CBStereoMode = new QComboBox(AGGroupBox);
-        CBStereoMode->addItem(QComboBox::tr("Disabled"));
-        CBStereoMode->addItem(QComboBox::tr("Red/Cyan"));
-        CBStereoMode->addItem(QComboBox::tr("Cyan/Red"));
-        CBStereoMode->addItem(QComboBox::tr("Red/Blue"));
-        CBStereoMode->addItem(QComboBox::tr("Blue/Red"));
-        CBStereoMode->addItem(QComboBox::tr("Red/Green"));
-        CBStereoMode->addItem(QComboBox::tr("Green/Red"));
-        CBStereoMode->addItem(QComboBox::tr("Side-by-side"));
-        CBStereoMode->addItem(QComboBox::tr("Top-Bottom"));
-        CBStereoMode->addItem(QComboBox::tr("Wiggle"));
-        CBStereoMode->addItem(QComboBox::tr("Red/Cyan grayscale"));
-        CBStereoMode->addItem(QComboBox::tr("Cyan/Red grayscale"));
-        CBStereoMode->addItem(QComboBox::tr("Red/Blue grayscale"));
-        CBStereoMode->addItem(QComboBox::tr("Blue/Red grayscale"));
-        CBStereoMode->addItem(QComboBox::tr("Red/Green grayscale"));
-        CBStereoMode->addItem(QComboBox::tr("Green/Red grayscale"));
-
-        GBAstereolayout->addWidget(CBStereoMode);
-        GBAlayout->addLayout(GBAstereolayout);
-
-        QHBoxLayout * GBAfpslayout = new QHBoxLayout(0);
-        QLabel * maxfps = new QLabel(AGGroupBox);
-        maxfps->setText(QLabel::tr("FPS limit"));
-        GBAfpslayout->addWidget(maxfps);
-        GBAlayout->addLayout(GBAfpslayout);
-        fpsedit = new FPSEdit(AGGroupBox);
-        GBAfpslayout->addWidget(fpsedit);
-
-        CBShowFPS = new QCheckBox(AGGroupBox);
-        CBShowFPS->setText(QCheckBox::tr("Show FPS"));
-        GBAfpslayout->addWidget(CBShowFPS);
+        connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(onColorModelDataChanged(QModelIndex,QModelIndex)));
+        for(int i = 0; i < model->rowCount(); ++i)
+        {
+            QPushButton * btn = new QPushButton(this);
+            gbCLayout->addWidget(btn);
+            btn->setStyleSheet(QString("background: %1").arg(model->item(i)->data().value<QColor>().name()));
+            m_colorButtons.append(btn);
+            connect(btn, SIGNAL(clicked()), mapper, SLOT(map()));
+            mapper->setMapping(btn, i);
+        }
 
-        hr = new QFrame(AGGroupBox);
-        hr->setFrameStyle(QFrame::HLine);
-        hr->setLineWidth(3);
-        hr->setFixedHeight(10);
-        GBAlayout->addWidget(hr);
-
-        QGridLayout * GBAvollayout = new QGridLayout();
-        QLabel * vol = new QLabel(AGGroupBox);
-        vol->setText(QLabel::tr("Initial sound volume"));
-        GBAvollayout->addWidget(vol, 0, 0, 1, 2);
-        GBAlayout->addLayout(GBAvollayout);
-        volumeBox = new QSpinBox(AGGroupBox);
-        volumeBox->setRange(0, 100);
-        volumeBox->setSingleStep(5);
-        GBAvollayout->addWidget(volumeBox, 0, 2);
-
-        CBEnableSound = new QCheckBox(AGGroupBox);
-        CBEnableSound->setText(QCheckBox::tr("Enable sound"));
-        GBAvollayout->addWidget(CBEnableSound, 1, 0, 1, 1);
-
-        CBEnableMusic = new QCheckBox(AGGroupBox);
-        CBEnableMusic->setText(QCheckBox::tr("Enable music"));
-        GBAvollayout->addWidget(CBEnableMusic, 1, 1, 1, 2);
-
-        GBAvollayout->setSizeConstraint(QLayout::SetMinimumSize);
-
-        hr = new QFrame(AGGroupBox);
-        hr->setFrameStyle(QFrame::HLine);
-        hr->setLineWidth(3);
-        hr->setFixedHeight(10);
-        GBAlayout->addWidget(hr);
-
-        CBAltDamage = new QCheckBox(AGGroupBox);
-        CBAltDamage->setText(QCheckBox::tr("Alternative damage show"));
-        GBAlayout->addWidget(CBAltDamage);
-
-        gbTBLayout->addWidget(AGGroupBox, 0, 1, 3, 1);
+        connect(mapper, SIGNAL(mapped(int)), this, SLOT(colorButtonClicked(int)));
     }
 
     previousQuality = this->SLQuality->value();
@@ -499,3 +528,25 @@
     CBTeamName->setVisible(enabled);
     LblNoEditTeam->setVisible(!enabled);
 }
+
+void PageOptions::colorButtonClicked(int i)
+{
+    if(i < 0 || i >= m_colorButtons.size())
+        return;
+
+    QPalette p = m_colorButtons[i]->palette();
+    QColor c = QColorDialog::getColor(p.color(QPalette::Button));
+
+    if(c.isValid())
+    {
+        DataManager::instance().colorsModel()->item(i)->setData(c);
+        m_colorButtons[i]->setStyleSheet(QString("background: %1").arg(c.name()));
+    }
+}
+
+void PageOptions::onColorModelDataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight)
+{
+    QStandardItemModel * model = DataManager::instance().colorsModel();
+
+    m_colorButtons[topLeft.row()]->setStyleSheet(QString("background: %1").arg(model->item(topLeft.row())->data().value<QColor>().name()));
+}
--- a/QTfrontend/ui/page/pageoptions.h	Wed Aug 15 16:25:24 2012 +0400
+++ b/QTfrontend/ui/page/pageoptions.h	Wed Aug 15 23:30:23 2012 +0400
@@ -23,6 +23,7 @@
 
 class FPSEdit;
 class IconedGroupBox;
+class QSignalMapper;
 
 class PageOptions : public AbstractPage
 {
@@ -91,6 +92,7 @@
         QPushButton *BtnNewTeam;
         QPushButton *BtnEditTeam;
         QPushButton *BtnDeleteTeam;
+        QList<QPushButton *> m_colorButtons;
 
     private slots:
         void forceFullscreen(int index);
@@ -101,6 +103,8 @@
         void requestEditSelectedTeam();
         void requestDeleteSelectedTeam();
         void savePwdChanged(int state);
+        void colorButtonClicked(int i);
+        void onColorModelDataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
 };
 
 #endif