From 4b45ba46f46ab49be91dce0fe5062192a3566409 Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Fri, 16 Jan 2015 01:34:03 +0100 Subject: [PATCH 1/6] Refactored General Settings Tab ~ Removed some heap allocs ~ Remaining heap allocs are needed. ~ Unrolled "one line" declarations in header ~ restructured logic in GeneralSettingsPage Refactored Appearance Tab - removed some heap allocs - removed setting of zone view, its not needed here, its configurable in real time, in game. --- cockatrice/src/dlg_settings.cpp | 164 ++++++++++++++------------------ cockatrice/src/dlg_settings.h | 57 ++++++++--- 2 files changed, 113 insertions(+), 108 deletions(-) diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index fab52dde..1ed173e5 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -29,18 +29,16 @@ GeneralSettingsPage::GeneralSettingsPage() { - languageLabel = new QLabel; - languageBox = new QComboBox; - QString setLanguage = settingsCache->getLang(); QStringList qmFiles = findQmFiles(); for (int i = 0; i < qmFiles.size(); 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"))) - languageBox->setCurrentIndex(i); + languageBox.setCurrentIndex(i); } +<<<<<<< HEAD picDownloadCheckBox = new QCheckBox; picDownloadCheckBox->setChecked(settingsCache->getPicDownload()); @@ -58,68 +56,73 @@ GeneralSettingsPage::GeneralSettingsPage() pixmapCacheEdit->setSingleStep(64); pixmapCacheEdit->setValue(settingsCache->getPixmapCacheSize()); 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()); +>>>>>>> 0b02c2b... Refactored General Settings Tab - connect(languageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(languageBoxChanged(int))); - connect(picDownloadCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownload(int))); - connect(picDownloadHqCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownloadHq(int))); - connect(pixmapCacheEdit, SIGNAL(valueChanged(int)), settingsCache, SLOT(setPixmapCacheSize(int))); + connect(&clearDownloadedPicsButton, SIGNAL(clicked()), this, SLOT(clearDownloadedPicsButtonClicked())); + connect(&languageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(languageBoxChanged(int))); + connect(&picDownloadCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownload(int))); + connect(&picDownloadHqCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownloadHq(int))); + connect(&pixmapCacheEdit, SIGNAL(valueChanged(int)), settingsCache, SLOT(setPixmapCacheSize(int))); QGridLayout *personalGrid = new QGridLayout; - personalGrid->addWidget(languageLabel, 0, 0); - personalGrid->addWidget(languageBox, 0, 1); - personalGrid->addWidget(pixmapCacheLabel, 1, 0, 1, 1); - personalGrid->addWidget(pixmapCacheEdit, 1, 1, 1, 1); - personalGrid->addWidget(picDownloadCheckBox, 2, 0, 1, 2); - personalGrid->addWidget(picDownloadHqCheckBox, 3, 0, 1, 2); - personalGrid->addWidget(clearDownloadedPicsButton, 4, 0, 1, 1); + personalGrid->addWidget(&languageLabel, 0, 0); + personalGrid->addWidget(&languageBox, 0, 1); + personalGrid->addWidget(&pixmapCacheLabel, 1, 0, 1, 1); + personalGrid->addWidget(&pixmapCacheEdit, 1, 1, 1, 1); + personalGrid->addWidget(&picDownloadCheckBox, 2, 0, 1, 2); + personalGrid->addWidget(&picDownloadHqCheckBox, 3, 0, 1, 2); + personalGrid->addWidget(&clearDownloadedPicsButton, 4, 0, 1, 1); personalGroupBox = new QGroupBox; personalGroupBox->setLayout(personalGrid); - deckPathLabel = new QLabel; deckPathEdit = new QLineEdit(settingsCache->getDeckPath()); deckPathEdit->setReadOnly(true); QPushButton *deckPathButton = new QPushButton("..."); connect(deckPathButton, SIGNAL(clicked()), this, SLOT(deckPathButtonClicked())); - replaysPathLabel = new QLabel; replaysPathEdit = new QLineEdit(settingsCache->getReplaysPath()); replaysPathEdit->setReadOnly(true); QPushButton *replaysPathButton = new QPushButton("..."); connect(replaysPathButton, SIGNAL(clicked()), this, SLOT(replaysPathButtonClicked())); - picsPathLabel = new QLabel; picsPathEdit = new QLineEdit(settingsCache->getPicsPath()); picsPathEdit->setReadOnly(true); QPushButton *picsPathButton = new QPushButton("..."); connect(picsPathButton, SIGNAL(clicked()), this, SLOT(picsPathButtonClicked())); - cardDatabasePathLabel = new QLabel; cardDatabasePathEdit = new QLineEdit(settingsCache->getCardDatabasePath()); cardDatabasePathEdit->setReadOnly(true); QPushButton *cardDatabasePathButton = new QPushButton("..."); connect(cardDatabasePathButton, SIGNAL(clicked()), this, SLOT(cardDatabasePathButtonClicked())); - tokenDatabasePathLabel = new QLabel; tokenDatabasePathEdit = new QLineEdit(settingsCache->getTokenDatabasePath()); tokenDatabasePathEdit->setReadOnly(true); QPushButton *tokenDatabasePathButton = new QPushButton("..."); connect(tokenDatabasePathButton, SIGNAL(clicked()), this, SLOT(tokenDatabasePathButtonClicked())); QGridLayout *pathsGrid = new QGridLayout; - pathsGrid->addWidget(deckPathLabel, 0, 0); + pathsGrid->addWidget(&deckPathLabel, 0, 0); pathsGrid->addWidget(deckPathEdit, 0, 1); pathsGrid->addWidget(deckPathButton, 0, 2); - pathsGrid->addWidget(replaysPathLabel, 1, 0); + pathsGrid->addWidget(&replaysPathLabel, 1, 0); pathsGrid->addWidget(replaysPathEdit, 1, 1); pathsGrid->addWidget(replaysPathButton, 1, 2); - pathsGrid->addWidget(picsPathLabel, 2, 0); + pathsGrid->addWidget(&picsPathLabel, 2, 0); pathsGrid->addWidget(picsPathEdit, 2, 1); pathsGrid->addWidget(picsPathButton, 2, 2); - pathsGrid->addWidget(cardDatabasePathLabel, 3, 0); + pathsGrid->addWidget(&cardDatabasePathLabel, 3, 0); pathsGrid->addWidget(cardDatabasePathEdit, 3, 1); pathsGrid->addWidget(cardDatabasePathButton, 3, 2); - pathsGrid->addWidget(tokenDatabasePathLabel, 4, 0); + pathsGrid->addWidget(&tokenDatabasePathLabel, 4, 0); pathsGrid->addWidget(tokenDatabasePathEdit, 4, 1); pathsGrid->addWidget(tokenDatabasePathButton, 4, 2); pathsGroupBox = new QGroupBox; @@ -224,30 +227,29 @@ void GeneralSettingsPage::tokenDatabasePathButtonClicked() void GeneralSettingsPage::languageBoxChanged(int index) { - settingsCache->setLang(languageBox->itemData(index).toString()); + settingsCache->setLang(languageBox.itemData(index).toString()); } void GeneralSettingsPage::retranslateUi() { personalGroupBox->setTitle(tr("Personal settings")); - languageLabel->setText(tr("Language:")); - picDownloadCheckBox->setText(tr("Download card pictures on the fly")); - picDownloadHqCheckBox->setText(tr("Download high-quality card pictures")); + languageLabel.setText(tr("Language:")); + picDownloadCheckBox.setText(tr("Download card pictures on the fly")); + picDownloadHqCheckBox.setText(tr("Download high-quality card pictures")); pathsGroupBox->setTitle(tr("Paths")); - deckPathLabel->setText(tr("Decks directory:")); - replaysPathLabel->setText(tr("Replays directory:")); - picsPathLabel->setText(tr("Pictures directory:")); - cardDatabasePathLabel->setText(tr("Card database:")); - tokenDatabasePathLabel->setText(tr("Token database:")); - pixmapCacheLabel->setText(tr("Picture cache size:")); - clearDownloadedPicsButton->setText(tr("Reset/Clear Downloaded Pictures")); + deckPathLabel.setText(tr("Decks directory:")); + replaysPathLabel.setText(tr("Replays directory:")); + picsPathLabel.setText(tr("Pictures directory:")); + cardDatabasePathLabel.setText(tr("Card database:")); + tokenDatabasePathLabel.setText(tr("Token database:")); + pixmapCacheLabel.setText(tr("Picture cache size:")); + clearDownloadedPicsButton.setText(tr("Reset/Clear Downloaded Pictures")); } AppearanceSettingsPage::AppearanceSettingsPage() { QIcon deleteIcon(":/resources/icon_delete.svg"); - handBgLabel = new QLabel; handBgEdit = new QLineEdit(settingsCache->getHandBgPath()); handBgEdit->setReadOnly(true); QPushButton *handBgClearButton = new QPushButton(deleteIcon, QString()); @@ -255,7 +257,6 @@ AppearanceSettingsPage::AppearanceSettingsPage() QPushButton *handBgButton = new QPushButton("..."); connect(handBgButton, SIGNAL(clicked()), this, SLOT(handBgButtonClicked())); - stackBgLabel = new QLabel; stackBgEdit = new QLineEdit(settingsCache->getStackBgPath()); stackBgEdit->setReadOnly(true); QPushButton *stackBgClearButton = new QPushButton(deleteIcon, QString()); @@ -263,7 +264,6 @@ AppearanceSettingsPage::AppearanceSettingsPage() QPushButton *stackBgButton = new QPushButton("..."); connect(stackBgButton, SIGNAL(clicked()), this, SLOT(stackBgButtonClicked())); - tableBgLabel = new QLabel; tableBgEdit = new QLineEdit(settingsCache->getTableBgPath()); tableBgEdit->setReadOnly(true); QPushButton *tableBgClearButton = new QPushButton(deleteIcon, QString()); @@ -271,7 +271,6 @@ AppearanceSettingsPage::AppearanceSettingsPage() QPushButton *tableBgButton = new QPushButton("..."); connect(tableBgButton, SIGNAL(clicked()), this, SLOT(tableBgButtonClicked())); - playerAreaBgLabel = new QLabel; playerAreaBgEdit = new QLineEdit(settingsCache->getPlayerBgPath()); playerAreaBgEdit->setReadOnly(true); QPushButton *playerAreaBgClearButton = new QPushButton(deleteIcon, QString()); @@ -279,7 +278,6 @@ AppearanceSettingsPage::AppearanceSettingsPage() QPushButton *playerAreaBgButton = new QPushButton("..."); connect(playerAreaBgButton, SIGNAL(clicked()), this, SLOT(playerAreaBgButtonClicked())); - cardBackPicturePathLabel = new QLabel; cardBackPicturePathEdit = new QLineEdit(settingsCache->getCardBackPicturePath()); cardBackPicturePathEdit->setReadOnly(true); QPushButton *cardBackPicturePathClearButton = new QPushButton(deleteIcon, QString()); @@ -288,23 +286,23 @@ AppearanceSettingsPage::AppearanceSettingsPage() connect(cardBackPicturePathButton, SIGNAL(clicked()), this, SLOT(cardBackPicturePathButtonClicked())); QGridLayout *zoneBgGrid = new QGridLayout; - zoneBgGrid->addWidget(handBgLabel, 0, 0); + zoneBgGrid->addWidget(&handBgLabel, 0, 0); zoneBgGrid->addWidget(handBgEdit, 0, 1); zoneBgGrid->addWidget(handBgClearButton, 0, 2); zoneBgGrid->addWidget(handBgButton, 0, 3); - zoneBgGrid->addWidget(stackBgLabel, 1, 0); + zoneBgGrid->addWidget(&stackBgLabel, 1, 0); zoneBgGrid->addWidget(stackBgEdit, 1, 1); zoneBgGrid->addWidget(stackBgClearButton, 1, 2); zoneBgGrid->addWidget(stackBgButton, 1, 3); - zoneBgGrid->addWidget(tableBgLabel, 2, 0); + zoneBgGrid->addWidget(&tableBgLabel, 2, 0); zoneBgGrid->addWidget(tableBgEdit, 2, 1); zoneBgGrid->addWidget(tableBgClearButton, 2, 2); zoneBgGrid->addWidget(tableBgButton, 2, 3); - zoneBgGrid->addWidget(playerAreaBgLabel, 3, 0); + zoneBgGrid->addWidget(&playerAreaBgLabel, 3, 0); zoneBgGrid->addWidget(playerAreaBgEdit, 3, 1); zoneBgGrid->addWidget(playerAreaBgClearButton, 3, 2); zoneBgGrid->addWidget(playerAreaBgButton, 3, 3); - zoneBgGrid->addWidget(cardBackPicturePathLabel, 4, 0); + zoneBgGrid->addWidget(&cardBackPicturePathLabel, 4, 0); zoneBgGrid->addWidget(cardBackPicturePathEdit, 4, 1); zoneBgGrid->addWidget(cardBackPicturePathClearButton, 4, 2); zoneBgGrid->addWidget(cardBackPicturePathButton, 4, 3); @@ -312,65 +310,45 @@ AppearanceSettingsPage::AppearanceSettingsPage() zoneBgGroupBox = new QGroupBox; zoneBgGroupBox->setLayout(zoneBgGrid); - displayCardNamesCheckBox = new QCheckBox; - displayCardNamesCheckBox->setChecked(settingsCache->getDisplayCardNames()); - connect(displayCardNamesCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDisplayCardNames(int))); + displayCardNamesCheckBox.setChecked(settingsCache->getDisplayCardNames()); + connect(&displayCardNamesCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDisplayCardNames(int))); QGridLayout *cardsGrid = new QGridLayout; - cardsGrid->addWidget(displayCardNamesCheckBox, 0, 0, 1, 2); + cardsGrid->addWidget(&displayCardNamesCheckBox, 0, 0, 1, 2); cardsGroupBox = new QGroupBox; cardsGroupBox->setLayout(cardsGrid); - horizontalHandCheckBox = new QCheckBox; - horizontalHandCheckBox->setChecked(settingsCache->getHorizontalHand()); - connect(horizontalHandCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setHorizontalHand(int))); + horizontalHandCheckBox.setChecked(settingsCache->getHorizontalHand()); + connect(&horizontalHandCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setHorizontalHand(int))); QGridLayout *handGrid = new QGridLayout; - handGrid->addWidget(horizontalHandCheckBox, 0, 0, 1, 2); + handGrid->addWidget(&horizontalHandCheckBox, 0, 0, 1, 2); handGroupBox = new QGroupBox; handGroupBox->setLayout(handGrid); - invertVerticalCoordinateCheckBox = new QCheckBox; - invertVerticalCoordinateCheckBox->setChecked(settingsCache->getInvertVerticalCoordinate()); - connect(invertVerticalCoordinateCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setInvertVerticalCoordinate(int))); + invertVerticalCoordinateCheckBox.setChecked(settingsCache->getInvertVerticalCoordinate()); + connect(&invertVerticalCoordinateCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setInvertVerticalCoordinate(int))); - minPlayersForMultiColumnLayoutLabel = new QLabel; - minPlayersForMultiColumnLayoutEdit = new QSpinBox; - minPlayersForMultiColumnLayoutEdit->setMinimum(2); - minPlayersForMultiColumnLayoutEdit->setValue(settingsCache->getMinPlayersForMultiColumnLayout()); - connect(minPlayersForMultiColumnLayoutEdit, SIGNAL(valueChanged(int)), settingsCache, SLOT(setMinPlayersForMultiColumnLayout(int))); - minPlayersForMultiColumnLayoutLabel->setBuddy(minPlayersForMultiColumnLayoutEdit); + minPlayersForMultiColumnLayoutEdit.setMinimum(2); + minPlayersForMultiColumnLayoutEdit.setValue(settingsCache->getMinPlayersForMultiColumnLayout()); + connect(&minPlayersForMultiColumnLayoutEdit, SIGNAL(valueChanged(int)), settingsCache, SLOT(setMinPlayersForMultiColumnLayout(int))); + minPlayersForMultiColumnLayoutLabel.setBuddy(&minPlayersForMultiColumnLayoutEdit); QGridLayout *tableGrid = new QGridLayout; - tableGrid->addWidget(invertVerticalCoordinateCheckBox, 0, 0, 1, 2); - tableGrid->addWidget(minPlayersForMultiColumnLayoutLabel, 1, 0, 1, 1); - tableGrid->addWidget(minPlayersForMultiColumnLayoutEdit, 1, 1, 1, 1); + tableGrid->addWidget(&invertVerticalCoordinateCheckBox, 0, 0, 1, 2); + tableGrid->addWidget(&minPlayersForMultiColumnLayoutLabel, 1, 0, 1, 1); + tableGrid->addWidget(&minPlayersForMultiColumnLayoutEdit, 1, 1, 1, 1); tableGroupBox = new QGroupBox; 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; mainLayout->addWidget(zoneBgGroupBox); mainLayout->addWidget(cardsGroupBox); mainLayout->addWidget(handGroupBox); mainLayout->addWidget(tableGroupBox); - mainLayout->addWidget(zoneViewGroupBox); setLayout(mainLayout); } @@ -378,25 +356,21 @@ AppearanceSettingsPage::AppearanceSettingsPage() void AppearanceSettingsPage::retranslateUi() { zoneBgGroupBox->setTitle(tr("Zone background pictures")); - handBgLabel->setText(tr("Hand background:")); - stackBgLabel->setText(tr("Stack background:")); - tableBgLabel->setText(tr("Table background:")); - playerAreaBgLabel->setText(tr("Player info background:")); - cardBackPicturePathLabel->setText(tr("Card back:")); + handBgLabel.setText(tr("Hand background:")); + stackBgLabel.setText(tr("Stack background:")); + tableBgLabel.setText(tr("Table background:")); + playerAreaBgLabel.setText(tr("Player info background:")); + cardBackPicturePathLabel.setText(tr("Card back:")); 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")); - horizontalHandCheckBox->setText(tr("Display hand horizontally (wastes space)")); + horizontalHandCheckBox.setText(tr("Display hand horizontally (wastes space)")); tableGroupBox->setTitle(tr("Table grid layout")); - invertVerticalCoordinateCheckBox->setText(tr("Invert vertical coordinate")); - 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")); + invertVerticalCoordinateCheckBox.setText(tr("Invert vertical coordinate")); + minPlayersForMultiColumnLayoutLabel.setText(tr("Minimum player count for multi-column layout:")); } void AppearanceSettingsPage::handBgClearButtonClicked() diff --git a/cockatrice/src/dlg_settings.h b/cockatrice/src/dlg_settings.h index c74a5f94..20b12067 100644 --- a/cockatrice/src/dlg_settings.h +++ b/cockatrice/src/dlg_settings.h @@ -1,7 +1,13 @@ #ifndef DLG_SETTINGS_H #define DLG_SETTINGS_H +#include +#include #include +#include +#include +#include +#include class CardDatabase; class QListWidget; @@ -39,14 +45,25 @@ private slots: private: QStringList findQmFiles(); QString languageName(const QString &qmFile); - QLineEdit *deckPathEdit, *replaysPathEdit, *picsPathEdit, *cardDatabasePathEdit, *tokenDatabasePathEdit; - QSpinBox *pixmapCacheEdit; - QGroupBox *personalGroupBox, *pathsGroupBox; - QComboBox *languageBox; - QCheckBox *picDownloadCheckBox; - QCheckBox *picDownloadHqCheckBox; - QLabel *languageLabel, *deckPathLabel, *replaysPathLabel, *picsPathLabel, *cardDatabasePathLabel, *tokenDatabasePathLabel, *pixmapCacheLabel; - QPushButton *clearDownloadedPicsButton; + QLineEdit *deckPathEdit; + QLineEdit *replaysPathEdit; + QLineEdit *picsPathEdit; + QLineEdit *cardDatabasePathEdit; + QLineEdit *tokenDatabasePathEdit; + QSpinBox pixmapCacheEdit; + QGroupBox *personalGroupBox; + 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 { @@ -69,11 +86,25 @@ signals: void playerAreaBgChanged(const QString &path); void cardBackPicturePathChanged(const QString &path); private: - QLabel *handBgLabel, *stackBgLabel, *tableBgLabel, *playerAreaBgLabel, *cardBackPicturePathLabel, *minPlayersForMultiColumnLayoutLabel; - QLineEdit *handBgEdit, *stackBgEdit, *tableBgEdit, *playerAreaBgEdit, *cardBackPicturePathEdit; - QCheckBox *displayCardNamesCheckBox, *horizontalHandCheckBox, *invertVerticalCoordinateCheckBox, *zoneViewSortByNameCheckBox, *zoneViewSortByTypeCheckBox; - QGroupBox *zoneBgGroupBox, *cardsGroupBox, *handGroupBox, *tableGroupBox, *zoneViewGroupBox; - QSpinBox *minPlayersForMultiColumnLayoutEdit; + QLabel handBgLabel; + QLabel stackBgLabel; + QLabel tableBgLabel; + QLabel playerAreaBgLabel; + 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: AppearanceSettingsPage(); void retranslateUi(); From 98e84f0d632fe3a2c29af10037de75527c17186c Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Sat, 17 Jan 2015 17:11:14 +0100 Subject: [PATCH 2/6] Fixed some merge issues --- cockatrice/src/dlg_settings.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index 1ed173e5..b3d9b1b8 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -38,25 +38,18 @@ GeneralSettingsPage::GeneralSettingsPage() languageBox.setCurrentIndex(i); } -<<<<<<< HEAD - 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 = new QSpinBox; - pixmapCacheEdit->setMinimum(PIXMAPCACHE_SIZE_MIN); + pixmapCacheEdit.setMinimum(PIXMAPCACHE_SIZE_MIN); // 2047 is the max value to avoid overflowing of QPixmapCache::setCacheLimit(int size) - pixmapCacheEdit->setMaximum(PIXMAPCACHE_SIZE_MAX); - pixmapCacheEdit->setSingleStep(64); - pixmapCacheEdit->setValue(settingsCache->getPixmapCacheSize()); - pixmapCacheEdit->setSuffix(" MB"); -======= + pixmapCacheEdit.setMaximum(PIXMAPCACHE_SIZE_MAX); + pixmapCacheEdit.setSingleStep(64); + pixmapCacheEdit.setValue(settingsCache->getPixmapCacheSize()); + pixmapCacheEdit.setSuffix(" MB"); pixmapCacheEdit.setMinimum(64); pixmapCacheEdit.setMaximum(8192); pixmapCacheEdit.setSingleStep(64); @@ -64,7 +57,6 @@ GeneralSettingsPage::GeneralSettingsPage() pixmapCacheEdit.setSuffix(" MB"); picDownloadHqCheckBox.setChecked(settingsCache->getPicDownloadHq()); picDownloadCheckBox.setChecked(settingsCache->getPicDownload()); ->>>>>>> 0b02c2b... Refactored General Settings Tab connect(&clearDownloadedPicsButton, SIGNAL(clicked()), this, SLOT(clearDownloadedPicsButtonClicked())); connect(&languageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(languageBoxChanged(int))); From a599fa1a6338d58b09e26fa48c58faf75e9c0384 Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Sat, 17 Jan 2015 17:30:24 +0100 Subject: [PATCH 3/6] Removed manual sizing replaced the resize(x, y) to "pack" the widgets. It saves space and makes the settings tighter. --- cockatrice/src/dlg_settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index b3d9b1b8..61cefb6f 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -698,7 +698,7 @@ DlgSettings::DlgSettings(QWidget *parent) retranslateUi(); - resize(800, 450); + adjustSize(); } void DlgSettings::createIcons() From 5cf801eb949f615f36adc8cd8e84bc744bd376aa Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Sat, 17 Jan 2015 17:50:04 +0100 Subject: [PATCH 4/6] Refactored User Interface tab - removed heap allocs --- cockatrice/src/dlg_settings.cpp | 59 ++++++++++++++------------------- cockatrice/src/dlg_settings.h | 18 +++++----- 2 files changed, 35 insertions(+), 42 deletions(-) diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index 61cefb6f..5fd809ed 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -449,63 +449,54 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage() { QIcon deleteIcon(":/resources/icon_delete.svg"); - notificationsEnabledCheckBox = new QCheckBox; - notificationsEnabledCheckBox->setChecked(settingsCache->getNotificationsEnabled()); - connect(notificationsEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setNotificationsEnabled(int))); + notificationsEnabledCheckBox.setChecked(settingsCache->getNotificationsEnabled()); + connect(¬ificationsEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setNotificationsEnabled(int))); - doubleClickToPlayCheckBox = new QCheckBox; - doubleClickToPlayCheckBox->setChecked(settingsCache->getDoubleClickToPlay()); - connect(doubleClickToPlayCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDoubleClickToPlay(int))); + doubleClickToPlayCheckBox.setChecked(settingsCache->getDoubleClickToPlay()); + connect(&doubleClickToPlayCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDoubleClickToPlay(int))); - playToStackCheckBox = new QCheckBox; - playToStackCheckBox->setChecked(settingsCache->getPlayToStack()); - connect(playToStackCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPlayToStack(int))); + playToStackCheckBox.setChecked(settingsCache->getPlayToStack()); + connect(&playToStackCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPlayToStack(int))); QGridLayout *generalGrid = new QGridLayout; - generalGrid->addWidget(notificationsEnabledCheckBox, 0, 0); - generalGrid->addWidget(doubleClickToPlayCheckBox, 1, 0); - generalGrid->addWidget(playToStackCheckBox, 2, 0); + generalGrid->addWidget(¬ificationsEnabledCheckBox, 0, 0); + generalGrid->addWidget(&doubleClickToPlayCheckBox, 1, 0); + generalGrid->addWidget(&playToStackCheckBox, 2, 0); generalGroupBox = new QGroupBox; generalGroupBox->setLayout(generalGrid); - tapAnimationCheckBox = new QCheckBox; - tapAnimationCheckBox->setChecked(settingsCache->getTapAnimation()); - connect(tapAnimationCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setTapAnimation(int))); + tapAnimationCheckBox.setChecked(settingsCache->getTapAnimation()); + connect(&tapAnimationCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setTapAnimation(int))); - soundEnabledCheckBox = new QCheckBox; - soundEnabledCheckBox->setChecked(settingsCache->getSoundEnabled()); - connect(soundEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setSoundEnabled(int))); + soundEnabledCheckBox.setChecked(settingsCache->getSoundEnabled()); + connect(&soundEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setSoundEnabled(int))); - soundPathLabel = new QLabel; soundPathEdit = new QLineEdit(settingsCache->getSoundPath()); soundPathEdit->setReadOnly(true); QPushButton *soundPathClearButton = new QPushButton(deleteIcon, QString()); connect(soundPathClearButton, SIGNAL(clicked()), this, SLOT(soundPathClearButtonClicked())); QPushButton *soundPathButton = new QPushButton("..."); 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; - soundGrid->addWidget(soundEnabledCheckBox, 0, 0, 1, 4); - soundGrid->addWidget(soundPathLabel, 1, 0); + soundGrid->addWidget(&soundEnabledCheckBox, 0, 0, 1, 4); + soundGrid->addWidget(&soundPathLabel, 1, 0); soundGrid->addWidget(soundPathEdit, 1, 1); soundGrid->addWidget(soundPathClearButton, 1, 2); soundGrid->addWidget(soundPathButton, 1, 3); - soundGrid->addWidget(soundTestButton, 2, 1); + soundGrid->addWidget(&soundTestButton, 2, 1); soundGroupBox = new QGroupBox; soundGroupBox->setLayout(soundGrid); QGridLayout *animationGrid = new QGridLayout; - animationGrid->addWidget(tapAnimationCheckBox, 0, 0); + animationGrid->addWidget(&tapAnimationCheckBox, 0, 0); animationGroupBox = new QGroupBox; animationGroupBox->setLayout(animationGrid); - - QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(generalGroupBox); mainLayout->addWidget(animationGroupBox); @@ -517,14 +508,14 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage() void UserInterfaceSettingsPage::retranslateUi() { generalGroupBox->setTitle(tr("General interface settings")); - notificationsEnabledCheckBox->setText(tr("Enable notifications in taskbar")); - 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")); + notificationsEnabledCheckBox.setText(tr("Enable notifications in taskbar")); + 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")); animationGroupBox->setTitle(tr("Animation settings")); - tapAnimationCheckBox->setText(tr("&Tap/untap animation")); - soundEnabledCheckBox->setText(tr("Enable &sounds")); - soundPathLabel->setText(tr("Path to sounds directory:")); - soundTestButton->setText(tr("Test system sound engine")); + tapAnimationCheckBox.setText(tr("&Tap/untap animation")); + soundEnabledCheckBox.setText(tr("Enable &sounds")); + soundPathLabel.setText(tr("Path to sounds directory:")); + soundTestButton.setText(tr("Test system sound engine")); soundGroupBox->setTitle(tr("Sound settings")); } diff --git a/cockatrice/src/dlg_settings.h b/cockatrice/src/dlg_settings.h index 20b12067..f366c4be 100644 --- a/cockatrice/src/dlg_settings.h +++ b/cockatrice/src/dlg_settings.h @@ -118,15 +118,17 @@ private slots: signals: void soundPathChanged(); private: - QCheckBox *notificationsEnabledCheckBox; - QCheckBox *doubleClickToPlayCheckBox; - QCheckBox *playToStackCheckBox; - QCheckBox *tapAnimationCheckBox; - QCheckBox *soundEnabledCheckBox; - QLabel *soundPathLabel; + QCheckBox notificationsEnabledCheckBox; + QCheckBox doubleClickToPlayCheckBox; + QCheckBox playToStackCheckBox; + QCheckBox tapAnimationCheckBox; + QCheckBox soundEnabledCheckBox; + QLabel soundPathLabel; QLineEdit *soundPathEdit; - QGroupBox *generalGroupBox, *animationGroupBox, *soundGroupBox; - QPushButton *soundTestButton; + QGroupBox *generalGroupBox; + QGroupBox *animationGroupBox; + QGroupBox *soundGroupBox; + QPushButton soundTestButton; public: UserInterfaceSettingsPage(); void retranslateUi(); From d02d3ed521daa6bbdb030dfff889dde695af7135 Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Sat, 17 Jan 2015 17:55:13 +0100 Subject: [PATCH 5/6] Refactored Deck Editor tab - removed heap allocation --- cockatrice/src/dlg_settings.cpp | 9 ++++----- cockatrice/src/dlg_settings.h | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index 5fd809ed..2dae4baa 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -537,14 +537,13 @@ void UserInterfaceSettingsPage::soundPathButtonClicked() DeckEditorSettingsPage::DeckEditorSettingsPage() { - priceTagsCheckBox = new QCheckBox; - priceTagsCheckBox->setChecked(settingsCache->getPriceTagFeature()); - connect(priceTagsCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPriceTagFeature(int))); + priceTagsCheckBox.setChecked(settingsCache->getPriceTagFeature()); + connect(&priceTagsCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPriceTagFeature(int))); connect(this, SIGNAL(priceTagSourceChanged(int)), settingsCache, SLOT(setPriceTagSource(int))); QGridLayout *generalGrid = new QGridLayout; - generalGrid->addWidget(priceTagsCheckBox, 0, 0); + generalGrid->addWidget(&priceTagsCheckBox, 0, 0); generalGroupBox = new QGroupBox; generalGroupBox->setLayout(generalGrid); @@ -557,7 +556,7 @@ DeckEditorSettingsPage::DeckEditorSettingsPage() 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")); } diff --git a/cockatrice/src/dlg_settings.h b/cockatrice/src/dlg_settings.h index f366c4be..2939911e 100644 --- a/cockatrice/src/dlg_settings.h +++ b/cockatrice/src/dlg_settings.h @@ -144,8 +144,7 @@ private slots: signals: void priceTagSourceChanged(int _priceTagSource); private: - QCheckBox *priceTagsCheckBox; - QRadioButton *priceTagSource0, *priceTagSource1; + QCheckBox priceTagsCheckBox; QGroupBox *generalGroupBox; }; From d59e1f135d045a02f548c4f42ee19c3a32ad5b07 Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Sat, 17 Jan 2015 18:04:06 +0100 Subject: [PATCH 6/6] Refactored Chat Settings tab - removed heap alloc --- cockatrice/src/dlg_settings.cpp | 9 ++++----- cockatrice/src/dlg_settings.h | 5 +++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index 2dae4baa..1e216e63 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -572,11 +572,10 @@ void DeckEditorSettingsPage::radioPriceTagSourceClicked(bool checked) MessagesSettingsPage::MessagesSettingsPage() { - chatMentionCheckBox = new QCheckBox; - chatMentionCheckBox->setChecked(settingsCache->getChatMention()); - connect(chatMentionCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setChatMention(int))); + chatMentionCheckBox.setChecked(settingsCache->getChatMention()); + connect(&chatMentionCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setChatMention(int))); QGridLayout *chatGrid = new QGridLayout; - chatGrid->addWidget(chatMentionCheckBox, 0, 0); + chatGrid->addWidget(&chatMentionCheckBox, 0, 0); chatGroupBox = new QGroupBox; chatGroupBox->setLayout(chatGrid); @@ -646,7 +645,7 @@ void MessagesSettingsPage::retranslateUi() aAdd->setText(tr("&Add")); aRemove->setText(tr("&Remove")); 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")); } diff --git a/cockatrice/src/dlg_settings.h b/cockatrice/src/dlg_settings.h index 2939911e..b6fd730e 100644 --- a/cockatrice/src/dlg_settings.h +++ b/cockatrice/src/dlg_settings.h @@ -158,8 +158,9 @@ private slots: void actRemove(); private: QListWidget *messageList; - QAction *aAdd, *aRemove; - QCheckBox *chatMentionCheckBox; + QAction *aAdd; + QAction *aRemove; + QCheckBox chatMentionCheckBox; QGroupBox *chatGroupBox; QGroupBox *messageShortcuts;