Merge pull request #556 from poixen/settings_dlg_refactorings

Refactored Settings Tab
This commit is contained in:
Gavin Bisesi 2015-01-20 11:39:25 -05:00
commit 931b420323
2 changed files with 166 additions and 178 deletions

View file

@ -29,97 +29,92 @@
GeneralSettingsPage::GeneralSettingsPage() GeneralSettingsPage::GeneralSettingsPage()
{ {
languageLabel = new QLabel;
languageBox = new QComboBox;
QString setLanguage = settingsCache->getLang(); QString setLanguage = settingsCache->getLang();
QStringList qmFiles = findQmFiles(); QStringList qmFiles = findQmFiles();
for (int i = 0; i < qmFiles.size(); i++) { for (int i = 0; i < qmFiles.size(); i++) {
QString langName = languageName(qmFiles[i]); QString langName = languageName(qmFiles[i]);
languageBox->addItem(langName, qmFiles[i]); languageBox.addItem(langName, qmFiles[i]);
if ((qmFiles[i] == setLanguage) || (setLanguage.isEmpty() && langName == tr("English"))) if ((qmFiles[i] == setLanguage) || (setLanguage.isEmpty() && langName == tr("English")))
languageBox->setCurrentIndex(i); languageBox.setCurrentIndex(i);
} }
picDownloadCheckBox = new QCheckBox; picDownloadCheckBox.setChecked(settingsCache->getPicDownload());
picDownloadCheckBox->setChecked(settingsCache->getPicDownload());
clearDownloadedPicsButton = new QPushButton(); connect(&clearDownloadedPicsButton, SIGNAL(clicked()), this, SLOT(clearDownloadedPicsButtonClicked()));
connect(clearDownloadedPicsButton, SIGNAL(clicked()), this, SLOT(clearDownloadedPicsButtonClicked()));
picDownloadHqCheckBox = new QCheckBox; picDownloadHqCheckBox.setChecked(settingsCache->getPicDownloadHq());
picDownloadHqCheckBox->setChecked(settingsCache->getPicDownloadHq());
pixmapCacheLabel = new QLabel; pixmapCacheEdit.setMinimum(PIXMAPCACHE_SIZE_MIN);
pixmapCacheEdit = new QSpinBox;
pixmapCacheEdit->setMinimum(PIXMAPCACHE_SIZE_MIN);
// 2047 is the max value to avoid overflowing of QPixmapCache::setCacheLimit(int size) // 2047 is the max value to avoid overflowing of QPixmapCache::setCacheLimit(int size)
pixmapCacheEdit->setMaximum(PIXMAPCACHE_SIZE_MAX); pixmapCacheEdit.setMaximum(PIXMAPCACHE_SIZE_MAX);
pixmapCacheEdit->setSingleStep(64); pixmapCacheEdit.setSingleStep(64);
pixmapCacheEdit->setValue(settingsCache->getPixmapCacheSize()); pixmapCacheEdit.setValue(settingsCache->getPixmapCacheSize());
pixmapCacheEdit->setSuffix(" MB"); pixmapCacheEdit.setSuffix(" MB");
pixmapCacheEdit.setMinimum(64);
pixmapCacheEdit.setMaximum(8192);
pixmapCacheEdit.setSingleStep(64);
pixmapCacheEdit.setValue(settingsCache->getPixmapCacheSize());
pixmapCacheEdit.setSuffix(" MB");
picDownloadHqCheckBox.setChecked(settingsCache->getPicDownloadHq());
picDownloadCheckBox.setChecked(settingsCache->getPicDownload());
connect(languageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(languageBoxChanged(int))); connect(&clearDownloadedPicsButton, SIGNAL(clicked()), this, SLOT(clearDownloadedPicsButtonClicked()));
connect(picDownloadCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownload(int))); connect(&languageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(languageBoxChanged(int)));
connect(picDownloadHqCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownloadHq(int))); connect(&picDownloadCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownload(int)));
connect(pixmapCacheEdit, SIGNAL(valueChanged(int)), settingsCache, SLOT(setPixmapCacheSize(int))); connect(&picDownloadHqCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownloadHq(int)));
connect(&pixmapCacheEdit, SIGNAL(valueChanged(int)), settingsCache, SLOT(setPixmapCacheSize(int)));
QGridLayout *personalGrid = new QGridLayout; QGridLayout *personalGrid = new QGridLayout;
personalGrid->addWidget(languageLabel, 0, 0); personalGrid->addWidget(&languageLabel, 0, 0);
personalGrid->addWidget(languageBox, 0, 1); personalGrid->addWidget(&languageBox, 0, 1);
personalGrid->addWidget(pixmapCacheLabel, 1, 0, 1, 1); personalGrid->addWidget(&pixmapCacheLabel, 1, 0, 1, 1);
personalGrid->addWidget(pixmapCacheEdit, 1, 1, 1, 1); personalGrid->addWidget(&pixmapCacheEdit, 1, 1, 1, 1);
personalGrid->addWidget(picDownloadCheckBox, 2, 0, 1, 2); personalGrid->addWidget(&picDownloadCheckBox, 2, 0, 1, 2);
personalGrid->addWidget(picDownloadHqCheckBox, 3, 0, 1, 2); personalGrid->addWidget(&picDownloadHqCheckBox, 3, 0, 1, 2);
personalGrid->addWidget(clearDownloadedPicsButton, 4, 0, 1, 1); personalGrid->addWidget(&clearDownloadedPicsButton, 4, 0, 1, 1);
personalGroupBox = new QGroupBox; personalGroupBox = new QGroupBox;
personalGroupBox->setLayout(personalGrid); personalGroupBox->setLayout(personalGrid);
deckPathLabel = new QLabel;
deckPathEdit = new QLineEdit(settingsCache->getDeckPath()); deckPathEdit = new QLineEdit(settingsCache->getDeckPath());
deckPathEdit->setReadOnly(true); deckPathEdit->setReadOnly(true);
QPushButton *deckPathButton = new QPushButton("..."); QPushButton *deckPathButton = new QPushButton("...");
connect(deckPathButton, SIGNAL(clicked()), this, SLOT(deckPathButtonClicked())); connect(deckPathButton, SIGNAL(clicked()), this, SLOT(deckPathButtonClicked()));
replaysPathLabel = new QLabel;
replaysPathEdit = new QLineEdit(settingsCache->getReplaysPath()); replaysPathEdit = new QLineEdit(settingsCache->getReplaysPath());
replaysPathEdit->setReadOnly(true); replaysPathEdit->setReadOnly(true);
QPushButton *replaysPathButton = new QPushButton("..."); QPushButton *replaysPathButton = new QPushButton("...");
connect(replaysPathButton, SIGNAL(clicked()), this, SLOT(replaysPathButtonClicked())); connect(replaysPathButton, SIGNAL(clicked()), this, SLOT(replaysPathButtonClicked()));
picsPathLabel = new QLabel;
picsPathEdit = new QLineEdit(settingsCache->getPicsPath()); picsPathEdit = new QLineEdit(settingsCache->getPicsPath());
picsPathEdit->setReadOnly(true); picsPathEdit->setReadOnly(true);
QPushButton *picsPathButton = new QPushButton("..."); QPushButton *picsPathButton = new QPushButton("...");
connect(picsPathButton, SIGNAL(clicked()), this, SLOT(picsPathButtonClicked())); connect(picsPathButton, SIGNAL(clicked()), this, SLOT(picsPathButtonClicked()));
cardDatabasePathLabel = new QLabel;
cardDatabasePathEdit = new QLineEdit(settingsCache->getCardDatabasePath()); cardDatabasePathEdit = new QLineEdit(settingsCache->getCardDatabasePath());
cardDatabasePathEdit->setReadOnly(true); cardDatabasePathEdit->setReadOnly(true);
QPushButton *cardDatabasePathButton = new QPushButton("..."); QPushButton *cardDatabasePathButton = new QPushButton("...");
connect(cardDatabasePathButton, SIGNAL(clicked()), this, SLOT(cardDatabasePathButtonClicked())); connect(cardDatabasePathButton, SIGNAL(clicked()), this, SLOT(cardDatabasePathButtonClicked()));
tokenDatabasePathLabel = new QLabel;
tokenDatabasePathEdit = new QLineEdit(settingsCache->getTokenDatabasePath()); tokenDatabasePathEdit = new QLineEdit(settingsCache->getTokenDatabasePath());
tokenDatabasePathEdit->setReadOnly(true); tokenDatabasePathEdit->setReadOnly(true);
QPushButton *tokenDatabasePathButton = new QPushButton("..."); QPushButton *tokenDatabasePathButton = new QPushButton("...");
connect(tokenDatabasePathButton, SIGNAL(clicked()), this, SLOT(tokenDatabasePathButtonClicked())); connect(tokenDatabasePathButton, SIGNAL(clicked()), this, SLOT(tokenDatabasePathButtonClicked()));
QGridLayout *pathsGrid = new QGridLayout; QGridLayout *pathsGrid = new QGridLayout;
pathsGrid->addWidget(deckPathLabel, 0, 0); pathsGrid->addWidget(&deckPathLabel, 0, 0);
pathsGrid->addWidget(deckPathEdit, 0, 1); pathsGrid->addWidget(deckPathEdit, 0, 1);
pathsGrid->addWidget(deckPathButton, 0, 2); pathsGrid->addWidget(deckPathButton, 0, 2);
pathsGrid->addWidget(replaysPathLabel, 1, 0); pathsGrid->addWidget(&replaysPathLabel, 1, 0);
pathsGrid->addWidget(replaysPathEdit, 1, 1); pathsGrid->addWidget(replaysPathEdit, 1, 1);
pathsGrid->addWidget(replaysPathButton, 1, 2); pathsGrid->addWidget(replaysPathButton, 1, 2);
pathsGrid->addWidget(picsPathLabel, 2, 0); pathsGrid->addWidget(&picsPathLabel, 2, 0);
pathsGrid->addWidget(picsPathEdit, 2, 1); pathsGrid->addWidget(picsPathEdit, 2, 1);
pathsGrid->addWidget(picsPathButton, 2, 2); pathsGrid->addWidget(picsPathButton, 2, 2);
pathsGrid->addWidget(cardDatabasePathLabel, 3, 0); pathsGrid->addWidget(&cardDatabasePathLabel, 3, 0);
pathsGrid->addWidget(cardDatabasePathEdit, 3, 1); pathsGrid->addWidget(cardDatabasePathEdit, 3, 1);
pathsGrid->addWidget(cardDatabasePathButton, 3, 2); pathsGrid->addWidget(cardDatabasePathButton, 3, 2);
pathsGrid->addWidget(tokenDatabasePathLabel, 4, 0); pathsGrid->addWidget(&tokenDatabasePathLabel, 4, 0);
pathsGrid->addWidget(tokenDatabasePathEdit, 4, 1); pathsGrid->addWidget(tokenDatabasePathEdit, 4, 1);
pathsGrid->addWidget(tokenDatabasePathButton, 4, 2); pathsGrid->addWidget(tokenDatabasePathButton, 4, 2);
pathsGroupBox = new QGroupBox; pathsGroupBox = new QGroupBox;
@ -224,30 +219,29 @@ void GeneralSettingsPage::tokenDatabasePathButtonClicked()
void GeneralSettingsPage::languageBoxChanged(int index) void GeneralSettingsPage::languageBoxChanged(int index)
{ {
settingsCache->setLang(languageBox->itemData(index).toString()); settingsCache->setLang(languageBox.itemData(index).toString());
} }
void GeneralSettingsPage::retranslateUi() void GeneralSettingsPage::retranslateUi()
{ {
personalGroupBox->setTitle(tr("Personal settings")); personalGroupBox->setTitle(tr("Personal settings"));
languageLabel->setText(tr("Language:")); languageLabel.setText(tr("Language:"));
picDownloadCheckBox->setText(tr("Download card pictures on the fly")); picDownloadCheckBox.setText(tr("Download card pictures on the fly"));
picDownloadHqCheckBox->setText(tr("Download high-quality card pictures")); picDownloadHqCheckBox.setText(tr("Download high-quality card pictures"));
pathsGroupBox->setTitle(tr("Paths")); pathsGroupBox->setTitle(tr("Paths"));
deckPathLabel->setText(tr("Decks directory:")); deckPathLabel.setText(tr("Decks directory:"));
replaysPathLabel->setText(tr("Replays directory:")); replaysPathLabel.setText(tr("Replays directory:"));
picsPathLabel->setText(tr("Pictures directory:")); picsPathLabel.setText(tr("Pictures directory:"));
cardDatabasePathLabel->setText(tr("Card database:")); cardDatabasePathLabel.setText(tr("Card database:"));
tokenDatabasePathLabel->setText(tr("Token database:")); tokenDatabasePathLabel.setText(tr("Token database:"));
pixmapCacheLabel->setText(tr("Picture cache size:")); pixmapCacheLabel.setText(tr("Picture cache size:"));
clearDownloadedPicsButton->setText(tr("Reset/Clear Downloaded Pictures")); clearDownloadedPicsButton.setText(tr("Reset/Clear Downloaded Pictures"));
} }
AppearanceSettingsPage::AppearanceSettingsPage() AppearanceSettingsPage::AppearanceSettingsPage()
{ {
QIcon deleteIcon(":/resources/icon_delete.svg"); QIcon deleteIcon(":/resources/icon_delete.svg");
handBgLabel = new QLabel;
handBgEdit = new QLineEdit(settingsCache->getHandBgPath()); handBgEdit = new QLineEdit(settingsCache->getHandBgPath());
handBgEdit->setReadOnly(true); handBgEdit->setReadOnly(true);
QPushButton *handBgClearButton = new QPushButton(deleteIcon, QString()); QPushButton *handBgClearButton = new QPushButton(deleteIcon, QString());
@ -255,7 +249,6 @@ AppearanceSettingsPage::AppearanceSettingsPage()
QPushButton *handBgButton = new QPushButton("..."); QPushButton *handBgButton = new QPushButton("...");
connect(handBgButton, SIGNAL(clicked()), this, SLOT(handBgButtonClicked())); connect(handBgButton, SIGNAL(clicked()), this, SLOT(handBgButtonClicked()));
stackBgLabel = new QLabel;
stackBgEdit = new QLineEdit(settingsCache->getStackBgPath()); stackBgEdit = new QLineEdit(settingsCache->getStackBgPath());
stackBgEdit->setReadOnly(true); stackBgEdit->setReadOnly(true);
QPushButton *stackBgClearButton = new QPushButton(deleteIcon, QString()); QPushButton *stackBgClearButton = new QPushButton(deleteIcon, QString());
@ -263,7 +256,6 @@ AppearanceSettingsPage::AppearanceSettingsPage()
QPushButton *stackBgButton = new QPushButton("..."); QPushButton *stackBgButton = new QPushButton("...");
connect(stackBgButton, SIGNAL(clicked()), this, SLOT(stackBgButtonClicked())); connect(stackBgButton, SIGNAL(clicked()), this, SLOT(stackBgButtonClicked()));
tableBgLabel = new QLabel;
tableBgEdit = new QLineEdit(settingsCache->getTableBgPath()); tableBgEdit = new QLineEdit(settingsCache->getTableBgPath());
tableBgEdit->setReadOnly(true); tableBgEdit->setReadOnly(true);
QPushButton *tableBgClearButton = new QPushButton(deleteIcon, QString()); QPushButton *tableBgClearButton = new QPushButton(deleteIcon, QString());
@ -271,7 +263,6 @@ AppearanceSettingsPage::AppearanceSettingsPage()
QPushButton *tableBgButton = new QPushButton("..."); QPushButton *tableBgButton = new QPushButton("...");
connect(tableBgButton, SIGNAL(clicked()), this, SLOT(tableBgButtonClicked())); connect(tableBgButton, SIGNAL(clicked()), this, SLOT(tableBgButtonClicked()));
playerAreaBgLabel = new QLabel;
playerAreaBgEdit = new QLineEdit(settingsCache->getPlayerBgPath()); playerAreaBgEdit = new QLineEdit(settingsCache->getPlayerBgPath());
playerAreaBgEdit->setReadOnly(true); playerAreaBgEdit->setReadOnly(true);
QPushButton *playerAreaBgClearButton = new QPushButton(deleteIcon, QString()); QPushButton *playerAreaBgClearButton = new QPushButton(deleteIcon, QString());
@ -279,7 +270,6 @@ AppearanceSettingsPage::AppearanceSettingsPage()
QPushButton *playerAreaBgButton = new QPushButton("..."); QPushButton *playerAreaBgButton = new QPushButton("...");
connect(playerAreaBgButton, SIGNAL(clicked()), this, SLOT(playerAreaBgButtonClicked())); connect(playerAreaBgButton, SIGNAL(clicked()), this, SLOT(playerAreaBgButtonClicked()));
cardBackPicturePathLabel = new QLabel;
cardBackPicturePathEdit = new QLineEdit(settingsCache->getCardBackPicturePath()); cardBackPicturePathEdit = new QLineEdit(settingsCache->getCardBackPicturePath());
cardBackPicturePathEdit->setReadOnly(true); cardBackPicturePathEdit->setReadOnly(true);
QPushButton *cardBackPicturePathClearButton = new QPushButton(deleteIcon, QString()); QPushButton *cardBackPicturePathClearButton = new QPushButton(deleteIcon, QString());
@ -288,23 +278,23 @@ AppearanceSettingsPage::AppearanceSettingsPage()
connect(cardBackPicturePathButton, SIGNAL(clicked()), this, SLOT(cardBackPicturePathButtonClicked())); connect(cardBackPicturePathButton, SIGNAL(clicked()), this, SLOT(cardBackPicturePathButtonClicked()));
QGridLayout *zoneBgGrid = new QGridLayout; QGridLayout *zoneBgGrid = new QGridLayout;
zoneBgGrid->addWidget(handBgLabel, 0, 0); zoneBgGrid->addWidget(&handBgLabel, 0, 0);
zoneBgGrid->addWidget(handBgEdit, 0, 1); zoneBgGrid->addWidget(handBgEdit, 0, 1);
zoneBgGrid->addWidget(handBgClearButton, 0, 2); zoneBgGrid->addWidget(handBgClearButton, 0, 2);
zoneBgGrid->addWidget(handBgButton, 0, 3); zoneBgGrid->addWidget(handBgButton, 0, 3);
zoneBgGrid->addWidget(stackBgLabel, 1, 0); zoneBgGrid->addWidget(&stackBgLabel, 1, 0);
zoneBgGrid->addWidget(stackBgEdit, 1, 1); zoneBgGrid->addWidget(stackBgEdit, 1, 1);
zoneBgGrid->addWidget(stackBgClearButton, 1, 2); zoneBgGrid->addWidget(stackBgClearButton, 1, 2);
zoneBgGrid->addWidget(stackBgButton, 1, 3); zoneBgGrid->addWidget(stackBgButton, 1, 3);
zoneBgGrid->addWidget(tableBgLabel, 2, 0); zoneBgGrid->addWidget(&tableBgLabel, 2, 0);
zoneBgGrid->addWidget(tableBgEdit, 2, 1); zoneBgGrid->addWidget(tableBgEdit, 2, 1);
zoneBgGrid->addWidget(tableBgClearButton, 2, 2); zoneBgGrid->addWidget(tableBgClearButton, 2, 2);
zoneBgGrid->addWidget(tableBgButton, 2, 3); zoneBgGrid->addWidget(tableBgButton, 2, 3);
zoneBgGrid->addWidget(playerAreaBgLabel, 3, 0); zoneBgGrid->addWidget(&playerAreaBgLabel, 3, 0);
zoneBgGrid->addWidget(playerAreaBgEdit, 3, 1); zoneBgGrid->addWidget(playerAreaBgEdit, 3, 1);
zoneBgGrid->addWidget(playerAreaBgClearButton, 3, 2); zoneBgGrid->addWidget(playerAreaBgClearButton, 3, 2);
zoneBgGrid->addWidget(playerAreaBgButton, 3, 3); zoneBgGrid->addWidget(playerAreaBgButton, 3, 3);
zoneBgGrid->addWidget(cardBackPicturePathLabel, 4, 0); zoneBgGrid->addWidget(&cardBackPicturePathLabel, 4, 0);
zoneBgGrid->addWidget(cardBackPicturePathEdit, 4, 1); zoneBgGrid->addWidget(cardBackPicturePathEdit, 4, 1);
zoneBgGrid->addWidget(cardBackPicturePathClearButton, 4, 2); zoneBgGrid->addWidget(cardBackPicturePathClearButton, 4, 2);
zoneBgGrid->addWidget(cardBackPicturePathButton, 4, 3); zoneBgGrid->addWidget(cardBackPicturePathButton, 4, 3);
@ -312,65 +302,45 @@ AppearanceSettingsPage::AppearanceSettingsPage()
zoneBgGroupBox = new QGroupBox; zoneBgGroupBox = new QGroupBox;
zoneBgGroupBox->setLayout(zoneBgGrid); zoneBgGroupBox->setLayout(zoneBgGrid);
displayCardNamesCheckBox = new QCheckBox; displayCardNamesCheckBox.setChecked(settingsCache->getDisplayCardNames());
displayCardNamesCheckBox->setChecked(settingsCache->getDisplayCardNames()); connect(&displayCardNamesCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDisplayCardNames(int)));
connect(displayCardNamesCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDisplayCardNames(int)));
QGridLayout *cardsGrid = new QGridLayout; QGridLayout *cardsGrid = new QGridLayout;
cardsGrid->addWidget(displayCardNamesCheckBox, 0, 0, 1, 2); cardsGrid->addWidget(&displayCardNamesCheckBox, 0, 0, 1, 2);
cardsGroupBox = new QGroupBox; cardsGroupBox = new QGroupBox;
cardsGroupBox->setLayout(cardsGrid); cardsGroupBox->setLayout(cardsGrid);
horizontalHandCheckBox = new QCheckBox; horizontalHandCheckBox.setChecked(settingsCache->getHorizontalHand());
horizontalHandCheckBox->setChecked(settingsCache->getHorizontalHand()); connect(&horizontalHandCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setHorizontalHand(int)));
connect(horizontalHandCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setHorizontalHand(int)));
QGridLayout *handGrid = new QGridLayout; QGridLayout *handGrid = new QGridLayout;
handGrid->addWidget(horizontalHandCheckBox, 0, 0, 1, 2); handGrid->addWidget(&horizontalHandCheckBox, 0, 0, 1, 2);
handGroupBox = new QGroupBox; handGroupBox = new QGroupBox;
handGroupBox->setLayout(handGrid); handGroupBox->setLayout(handGrid);
invertVerticalCoordinateCheckBox = new QCheckBox; invertVerticalCoordinateCheckBox.setChecked(settingsCache->getInvertVerticalCoordinate());
invertVerticalCoordinateCheckBox->setChecked(settingsCache->getInvertVerticalCoordinate()); connect(&invertVerticalCoordinateCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setInvertVerticalCoordinate(int)));
connect(invertVerticalCoordinateCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setInvertVerticalCoordinate(int)));
minPlayersForMultiColumnLayoutLabel = new QLabel; minPlayersForMultiColumnLayoutEdit.setMinimum(2);
minPlayersForMultiColumnLayoutEdit = new QSpinBox; minPlayersForMultiColumnLayoutEdit.setValue(settingsCache->getMinPlayersForMultiColumnLayout());
minPlayersForMultiColumnLayoutEdit->setMinimum(2); connect(&minPlayersForMultiColumnLayoutEdit, SIGNAL(valueChanged(int)), settingsCache, SLOT(setMinPlayersForMultiColumnLayout(int)));
minPlayersForMultiColumnLayoutEdit->setValue(settingsCache->getMinPlayersForMultiColumnLayout()); minPlayersForMultiColumnLayoutLabel.setBuddy(&minPlayersForMultiColumnLayoutEdit);
connect(minPlayersForMultiColumnLayoutEdit, SIGNAL(valueChanged(int)), settingsCache, SLOT(setMinPlayersForMultiColumnLayout(int)));
minPlayersForMultiColumnLayoutLabel->setBuddy(minPlayersForMultiColumnLayoutEdit);
QGridLayout *tableGrid = new QGridLayout; QGridLayout *tableGrid = new QGridLayout;
tableGrid->addWidget(invertVerticalCoordinateCheckBox, 0, 0, 1, 2); tableGrid->addWidget(&invertVerticalCoordinateCheckBox, 0, 0, 1, 2);
tableGrid->addWidget(minPlayersForMultiColumnLayoutLabel, 1, 0, 1, 1); tableGrid->addWidget(&minPlayersForMultiColumnLayoutLabel, 1, 0, 1, 1);
tableGrid->addWidget(minPlayersForMultiColumnLayoutEdit, 1, 1, 1, 1); tableGrid->addWidget(&minPlayersForMultiColumnLayoutEdit, 1, 1, 1, 1);
tableGroupBox = new QGroupBox; tableGroupBox = new QGroupBox;
tableGroupBox->setLayout(tableGrid); tableGroupBox->setLayout(tableGrid);
zoneViewSortByNameCheckBox = new QCheckBox;
zoneViewSortByNameCheckBox->setChecked(settingsCache->getZoneViewSortByName());
connect(zoneViewSortByNameCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setZoneViewSortByName(int)));
zoneViewSortByTypeCheckBox = new QCheckBox;
zoneViewSortByTypeCheckBox->setChecked(settingsCache->getZoneViewSortByType());
connect(zoneViewSortByTypeCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setZoneViewSortByType(int)));
QGridLayout *zoneViewGrid = new QGridLayout;
zoneViewGrid->addWidget(zoneViewSortByNameCheckBox, 0, 0, 1, 2);
zoneViewGrid->addWidget(zoneViewSortByTypeCheckBox, 1, 0, 1, 2);
zoneViewGroupBox = new QGroupBox;
zoneViewGroupBox->setLayout(zoneViewGrid);
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(zoneBgGroupBox); mainLayout->addWidget(zoneBgGroupBox);
mainLayout->addWidget(cardsGroupBox); mainLayout->addWidget(cardsGroupBox);
mainLayout->addWidget(handGroupBox); mainLayout->addWidget(handGroupBox);
mainLayout->addWidget(tableGroupBox); mainLayout->addWidget(tableGroupBox);
mainLayout->addWidget(zoneViewGroupBox);
setLayout(mainLayout); setLayout(mainLayout);
} }
@ -378,25 +348,21 @@ AppearanceSettingsPage::AppearanceSettingsPage()
void AppearanceSettingsPage::retranslateUi() void AppearanceSettingsPage::retranslateUi()
{ {
zoneBgGroupBox->setTitle(tr("Zone background pictures")); zoneBgGroupBox->setTitle(tr("Zone background pictures"));
handBgLabel->setText(tr("Hand background:")); handBgLabel.setText(tr("Hand background:"));
stackBgLabel->setText(tr("Stack background:")); stackBgLabel.setText(tr("Stack background:"));
tableBgLabel->setText(tr("Table background:")); tableBgLabel.setText(tr("Table background:"));
playerAreaBgLabel->setText(tr("Player info background:")); playerAreaBgLabel.setText(tr("Player info background:"));
cardBackPicturePathLabel->setText(tr("Card back:")); cardBackPicturePathLabel.setText(tr("Card back:"));
cardsGroupBox->setTitle(tr("Card rendering")); cardsGroupBox->setTitle(tr("Card rendering"));
displayCardNamesCheckBox->setText(tr("Display card names on cards having a picture")); displayCardNamesCheckBox.setText(tr("Display card names on cards having a picture"));
handGroupBox->setTitle(tr("Hand layout")); handGroupBox->setTitle(tr("Hand layout"));
horizontalHandCheckBox->setText(tr("Display hand horizontally (wastes space)")); horizontalHandCheckBox.setText(tr("Display hand horizontally (wastes space)"));
tableGroupBox->setTitle(tr("Table grid layout")); tableGroupBox->setTitle(tr("Table grid layout"));
invertVerticalCoordinateCheckBox->setText(tr("Invert vertical coordinate")); invertVerticalCoordinateCheckBox.setText(tr("Invert vertical coordinate"));
minPlayersForMultiColumnLayoutLabel->setText(tr("Minimum player count for multi-column layout:")); minPlayersForMultiColumnLayoutLabel.setText(tr("Minimum player count for multi-column layout:"));
zoneViewGroupBox->setTitle(tr("Zone view layout"));
zoneViewSortByNameCheckBox->setText(tr("Sort by name"));
zoneViewSortByTypeCheckBox->setText(tr("Sort by type"));
} }
void AppearanceSettingsPage::handBgClearButtonClicked() void AppearanceSettingsPage::handBgClearButtonClicked()
@ -483,63 +449,54 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
{ {
QIcon deleteIcon(":/resources/icon_delete.svg"); QIcon deleteIcon(":/resources/icon_delete.svg");
notificationsEnabledCheckBox = new QCheckBox; notificationsEnabledCheckBox.setChecked(settingsCache->getNotificationsEnabled());
notificationsEnabledCheckBox->setChecked(settingsCache->getNotificationsEnabled()); connect(&notificationsEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setNotificationsEnabled(int)));
connect(notificationsEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setNotificationsEnabled(int)));
doubleClickToPlayCheckBox = new QCheckBox; doubleClickToPlayCheckBox.setChecked(settingsCache->getDoubleClickToPlay());
doubleClickToPlayCheckBox->setChecked(settingsCache->getDoubleClickToPlay()); connect(&doubleClickToPlayCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDoubleClickToPlay(int)));
connect(doubleClickToPlayCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDoubleClickToPlay(int)));
playToStackCheckBox = new QCheckBox; playToStackCheckBox.setChecked(settingsCache->getPlayToStack());
playToStackCheckBox->setChecked(settingsCache->getPlayToStack()); connect(&playToStackCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPlayToStack(int)));
connect(playToStackCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPlayToStack(int)));
QGridLayout *generalGrid = new QGridLayout; QGridLayout *generalGrid = new QGridLayout;
generalGrid->addWidget(notificationsEnabledCheckBox, 0, 0); generalGrid->addWidget(&notificationsEnabledCheckBox, 0, 0);
generalGrid->addWidget(doubleClickToPlayCheckBox, 1, 0); generalGrid->addWidget(&doubleClickToPlayCheckBox, 1, 0);
generalGrid->addWidget(playToStackCheckBox, 2, 0); generalGrid->addWidget(&playToStackCheckBox, 2, 0);
generalGroupBox = new QGroupBox; generalGroupBox = new QGroupBox;
generalGroupBox->setLayout(generalGrid); generalGroupBox->setLayout(generalGrid);
tapAnimationCheckBox = new QCheckBox; tapAnimationCheckBox.setChecked(settingsCache->getTapAnimation());
tapAnimationCheckBox->setChecked(settingsCache->getTapAnimation()); connect(&tapAnimationCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setTapAnimation(int)));
connect(tapAnimationCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setTapAnimation(int)));
soundEnabledCheckBox = new QCheckBox; soundEnabledCheckBox.setChecked(settingsCache->getSoundEnabled());
soundEnabledCheckBox->setChecked(settingsCache->getSoundEnabled()); connect(&soundEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setSoundEnabled(int)));
connect(soundEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setSoundEnabled(int)));
soundPathLabel = new QLabel;
soundPathEdit = new QLineEdit(settingsCache->getSoundPath()); soundPathEdit = new QLineEdit(settingsCache->getSoundPath());
soundPathEdit->setReadOnly(true); soundPathEdit->setReadOnly(true);
QPushButton *soundPathClearButton = new QPushButton(deleteIcon, QString()); QPushButton *soundPathClearButton = new QPushButton(deleteIcon, QString());
connect(soundPathClearButton, SIGNAL(clicked()), this, SLOT(soundPathClearButtonClicked())); connect(soundPathClearButton, SIGNAL(clicked()), this, SLOT(soundPathClearButtonClicked()));
QPushButton *soundPathButton = new QPushButton("..."); QPushButton *soundPathButton = new QPushButton("...");
connect(soundPathButton, SIGNAL(clicked()), this, SLOT(soundPathButtonClicked())); connect(soundPathButton, SIGNAL(clicked()), this, SLOT(soundPathButtonClicked()));
soundTestButton = new QPushButton(); connect(&soundTestButton, SIGNAL(clicked()), soundEngine, SLOT(cuckoo()));
connect(soundTestButton, SIGNAL(clicked()), soundEngine, SLOT(cuckoo()));
QGridLayout *soundGrid = new QGridLayout; QGridLayout *soundGrid = new QGridLayout;
soundGrid->addWidget(soundEnabledCheckBox, 0, 0, 1, 4); soundGrid->addWidget(&soundEnabledCheckBox, 0, 0, 1, 4);
soundGrid->addWidget(soundPathLabel, 1, 0); soundGrid->addWidget(&soundPathLabel, 1, 0);
soundGrid->addWidget(soundPathEdit, 1, 1); soundGrid->addWidget(soundPathEdit, 1, 1);
soundGrid->addWidget(soundPathClearButton, 1, 2); soundGrid->addWidget(soundPathClearButton, 1, 2);
soundGrid->addWidget(soundPathButton, 1, 3); soundGrid->addWidget(soundPathButton, 1, 3);
soundGrid->addWidget(soundTestButton, 2, 1); soundGrid->addWidget(&soundTestButton, 2, 1);
soundGroupBox = new QGroupBox; soundGroupBox = new QGroupBox;
soundGroupBox->setLayout(soundGrid); soundGroupBox->setLayout(soundGrid);
QGridLayout *animationGrid = new QGridLayout; QGridLayout *animationGrid = new QGridLayout;
animationGrid->addWidget(tapAnimationCheckBox, 0, 0); animationGrid->addWidget(&tapAnimationCheckBox, 0, 0);
animationGroupBox = new QGroupBox; animationGroupBox = new QGroupBox;
animationGroupBox->setLayout(animationGrid); animationGroupBox->setLayout(animationGrid);
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(generalGroupBox); mainLayout->addWidget(generalGroupBox);
mainLayout->addWidget(animationGroupBox); mainLayout->addWidget(animationGroupBox);
@ -551,14 +508,14 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
void UserInterfaceSettingsPage::retranslateUi() void UserInterfaceSettingsPage::retranslateUi()
{ {
generalGroupBox->setTitle(tr("General interface settings")); generalGroupBox->setTitle(tr("General interface settings"));
notificationsEnabledCheckBox->setText(tr("Enable notifications in taskbar")); notificationsEnabledCheckBox.setText(tr("Enable notifications in taskbar"));
doubleClickToPlayCheckBox->setText(tr("&Double-click cards to play them (instead of single-click)")); doubleClickToPlayCheckBox.setText(tr("&Double-click cards to play them (instead of single-click)"));
playToStackCheckBox->setText(tr("&Play all nonlands onto the stack (not the battlefield) by default")); playToStackCheckBox.setText(tr("&Play all nonlands onto the stack (not the battlefield) by default"));
animationGroupBox->setTitle(tr("Animation settings")); animationGroupBox->setTitle(tr("Animation settings"));
tapAnimationCheckBox->setText(tr("&Tap/untap animation")); tapAnimationCheckBox.setText(tr("&Tap/untap animation"));
soundEnabledCheckBox->setText(tr("Enable &sounds")); soundEnabledCheckBox.setText(tr("Enable &sounds"));
soundPathLabel->setText(tr("Path to sounds directory:")); soundPathLabel.setText(tr("Path to sounds directory:"));
soundTestButton->setText(tr("Test system sound engine")); soundTestButton.setText(tr("Test system sound engine"));
soundGroupBox->setTitle(tr("Sound settings")); soundGroupBox->setTitle(tr("Sound settings"));
} }
@ -580,14 +537,13 @@ void UserInterfaceSettingsPage::soundPathButtonClicked()
DeckEditorSettingsPage::DeckEditorSettingsPage() DeckEditorSettingsPage::DeckEditorSettingsPage()
{ {
priceTagsCheckBox = new QCheckBox; priceTagsCheckBox.setChecked(settingsCache->getPriceTagFeature());
priceTagsCheckBox->setChecked(settingsCache->getPriceTagFeature()); connect(&priceTagsCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPriceTagFeature(int)));
connect(priceTagsCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPriceTagFeature(int)));
connect(this, SIGNAL(priceTagSourceChanged(int)), settingsCache, SLOT(setPriceTagSource(int))); connect(this, SIGNAL(priceTagSourceChanged(int)), settingsCache, SLOT(setPriceTagSource(int)));
QGridLayout *generalGrid = new QGridLayout; QGridLayout *generalGrid = new QGridLayout;
generalGrid->addWidget(priceTagsCheckBox, 0, 0); generalGrid->addWidget(&priceTagsCheckBox, 0, 0);
generalGroupBox = new QGroupBox; generalGroupBox = new QGroupBox;
generalGroupBox->setLayout(generalGrid); generalGroupBox->setLayout(generalGrid);
@ -600,7 +556,7 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
void DeckEditorSettingsPage::retranslateUi() void DeckEditorSettingsPage::retranslateUi()
{ {
priceTagsCheckBox->setText(tr("Enable &price tag feature from deckbrew.com")); priceTagsCheckBox.setText(tr("Enable &price tag feature from deckbrew.com"));
generalGroupBox->setTitle(tr("General")); generalGroupBox->setTitle(tr("General"));
} }
@ -616,11 +572,10 @@ void DeckEditorSettingsPage::radioPriceTagSourceClicked(bool checked)
MessagesSettingsPage::MessagesSettingsPage() MessagesSettingsPage::MessagesSettingsPage()
{ {
chatMentionCheckBox = new QCheckBox; chatMentionCheckBox.setChecked(settingsCache->getChatMention());
chatMentionCheckBox->setChecked(settingsCache->getChatMention()); connect(&chatMentionCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setChatMention(int)));
connect(chatMentionCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setChatMention(int)));
QGridLayout *chatGrid = new QGridLayout; QGridLayout *chatGrid = new QGridLayout;
chatGrid->addWidget(chatMentionCheckBox, 0, 0); chatGrid->addWidget(&chatMentionCheckBox, 0, 0);
chatGroupBox = new QGroupBox; chatGroupBox = new QGroupBox;
chatGroupBox->setLayout(chatGrid); chatGroupBox->setLayout(chatGrid);
@ -690,7 +645,7 @@ void MessagesSettingsPage::retranslateUi()
aAdd->setText(tr("&Add")); aAdd->setText(tr("&Add"));
aRemove->setText(tr("&Remove")); aRemove->setText(tr("&Remove"));
chatGroupBox->setTitle(tr("Chat settings")); chatGroupBox->setTitle(tr("Chat settings"));
chatMentionCheckBox->setText(tr("Enable chat mentions ('@yourusername' in chat log will be highlighted)")); chatMentionCheckBox.setText(tr("Enable chat mentions ('@yourusername' in chat log will be highlighted)"));
messageShortcuts->setTitle(tr("In-game message macros")); messageShortcuts->setTitle(tr("In-game message macros"));
} }
@ -732,7 +687,7 @@ DlgSettings::DlgSettings(QWidget *parent)
retranslateUi(); retranslateUi();
resize(800, 450); adjustSize();
} }
void DlgSettings::createIcons() void DlgSettings::createIcons()

View file

@ -1,7 +1,13 @@
#ifndef DLG_SETTINGS_H #ifndef DLG_SETTINGS_H
#define DLG_SETTINGS_H #define DLG_SETTINGS_H
#include <QComboBox>
#include <QCheckBox>
#include <QDialog> #include <QDialog>
#include <QGroupBox>
#include <QLabel>
#include <QPushButton>
#include <QSpinBox>
class CardDatabase; class CardDatabase;
class QListWidget; class QListWidget;
@ -39,14 +45,25 @@ private slots:
private: private:
QStringList findQmFiles(); QStringList findQmFiles();
QString languageName(const QString &qmFile); QString languageName(const QString &qmFile);
QLineEdit *deckPathEdit, *replaysPathEdit, *picsPathEdit, *cardDatabasePathEdit, *tokenDatabasePathEdit; QLineEdit *deckPathEdit;
QSpinBox *pixmapCacheEdit; QLineEdit *replaysPathEdit;
QGroupBox *personalGroupBox, *pathsGroupBox; QLineEdit *picsPathEdit;
QComboBox *languageBox; QLineEdit *cardDatabasePathEdit;
QCheckBox *picDownloadCheckBox; QLineEdit *tokenDatabasePathEdit;
QCheckBox *picDownloadHqCheckBox; QSpinBox pixmapCacheEdit;
QLabel *languageLabel, *deckPathLabel, *replaysPathLabel, *picsPathLabel, *cardDatabasePathLabel, *tokenDatabasePathLabel, *pixmapCacheLabel; QGroupBox *personalGroupBox;
QPushButton *clearDownloadedPicsButton; QGroupBox *pathsGroupBox;
QComboBox languageBox;
QCheckBox picDownloadCheckBox;
QCheckBox picDownloadHqCheckBox;
QLabel languageLabel;
QLabel pixmapCacheLabel;
QLabel deckPathLabel;
QLabel replaysPathLabel;
QLabel picsPathLabel;
QLabel cardDatabasePathLabel;
QLabel tokenDatabasePathLabel;
QPushButton clearDownloadedPicsButton;
}; };
class AppearanceSettingsPage : public AbstractSettingsPage { class AppearanceSettingsPage : public AbstractSettingsPage {
@ -69,11 +86,25 @@ signals:
void playerAreaBgChanged(const QString &path); void playerAreaBgChanged(const QString &path);
void cardBackPicturePathChanged(const QString &path); void cardBackPicturePathChanged(const QString &path);
private: private:
QLabel *handBgLabel, *stackBgLabel, *tableBgLabel, *playerAreaBgLabel, *cardBackPicturePathLabel, *minPlayersForMultiColumnLayoutLabel; QLabel handBgLabel;
QLineEdit *handBgEdit, *stackBgEdit, *tableBgEdit, *playerAreaBgEdit, *cardBackPicturePathEdit; QLabel stackBgLabel;
QCheckBox *displayCardNamesCheckBox, *horizontalHandCheckBox, *invertVerticalCoordinateCheckBox, *zoneViewSortByNameCheckBox, *zoneViewSortByTypeCheckBox; QLabel tableBgLabel;
QGroupBox *zoneBgGroupBox, *cardsGroupBox, *handGroupBox, *tableGroupBox, *zoneViewGroupBox; QLabel playerAreaBgLabel;
QSpinBox *minPlayersForMultiColumnLayoutEdit; QLabel cardBackPicturePathLabel;
QLabel minPlayersForMultiColumnLayoutLabel;
QLineEdit *handBgEdit;
QLineEdit *stackBgEdit;
QLineEdit *tableBgEdit;
QLineEdit *playerAreaBgEdit;
QLineEdit *cardBackPicturePathEdit;
QCheckBox displayCardNamesCheckBox;
QCheckBox horizontalHandCheckBox;
QCheckBox invertVerticalCoordinateCheckBox;
QGroupBox *zoneBgGroupBox;
QGroupBox *cardsGroupBox;
QGroupBox *handGroupBox;
QGroupBox *tableGroupBox;
QSpinBox minPlayersForMultiColumnLayoutEdit;
public: public:
AppearanceSettingsPage(); AppearanceSettingsPage();
void retranslateUi(); void retranslateUi();
@ -87,15 +118,17 @@ private slots:
signals: signals:
void soundPathChanged(); void soundPathChanged();
private: private:
QCheckBox *notificationsEnabledCheckBox; QCheckBox notificationsEnabledCheckBox;
QCheckBox *doubleClickToPlayCheckBox; QCheckBox doubleClickToPlayCheckBox;
QCheckBox *playToStackCheckBox; QCheckBox playToStackCheckBox;
QCheckBox *tapAnimationCheckBox; QCheckBox tapAnimationCheckBox;
QCheckBox *soundEnabledCheckBox; QCheckBox soundEnabledCheckBox;
QLabel *soundPathLabel; QLabel soundPathLabel;
QLineEdit *soundPathEdit; QLineEdit *soundPathEdit;
QGroupBox *generalGroupBox, *animationGroupBox, *soundGroupBox; QGroupBox *generalGroupBox;
QPushButton *soundTestButton; QGroupBox *animationGroupBox;
QGroupBox *soundGroupBox;
QPushButton soundTestButton;
public: public:
UserInterfaceSettingsPage(); UserInterfaceSettingsPage();
void retranslateUi(); void retranslateUi();
@ -111,8 +144,7 @@ private slots:
signals: signals:
void priceTagSourceChanged(int _priceTagSource); void priceTagSourceChanged(int _priceTagSource);
private: private:
QCheckBox *priceTagsCheckBox; QCheckBox priceTagsCheckBox;
QRadioButton *priceTagSource0, *priceTagSource1;
QGroupBox *generalGroupBox; QGroupBox *generalGroupBox;
}; };
@ -126,8 +158,9 @@ private slots:
void actRemove(); void actRemove();
private: private:
QListWidget *messageList; QListWidget *messageList;
QAction *aAdd, *aRemove; QAction *aAdd;
QCheckBox *chatMentionCheckBox; QAction *aRemove;
QCheckBox chatMentionCheckBox;
QGroupBox *chatGroupBox; QGroupBox *chatGroupBox;
QGroupBox *messageShortcuts; QGroupBox *messageShortcuts;