mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-15 23:12:14 -07:00
Make setting into an enum
This commit is contained in:
parent
c6fcb5be1d
commit
f046c26b04
8 changed files with 47 additions and 23 deletions
|
|
@ -814,10 +814,19 @@ void TabSupervisor::talkLeft(TabMessage *tab)
|
||||||
*/
|
*/
|
||||||
void TabSupervisor::openDeckInNewTab(const DeckLoader *deckToOpen)
|
void TabSupervisor::openDeckInNewTab(const DeckLoader *deckToOpen)
|
||||||
{
|
{
|
||||||
if (SettingsCache::instance().getOpenInVisualDeckEditor()) {
|
int type = SettingsCache::instance().getDefaultDeckEditorType();
|
||||||
addVisualDeckEditorTab(deckToOpen);
|
switch (type) {
|
||||||
} else {
|
case ClassicDeckEditor:
|
||||||
addDeckEditorTab(deckToOpen);
|
addDeckEditorTab(deckToOpen);
|
||||||
|
break;
|
||||||
|
case VisualDeckEditor:
|
||||||
|
addVisualDeckEditorTab(deckToOpen);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qCWarning(TabSupervisorLog) << "Unknown DeckEditorType [" << type
|
||||||
|
<< "]; opening ClassicDeckEditor as fallback";
|
||||||
|
addDeckEditorTab(deckToOpen);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,14 @@ protected:
|
||||||
class TabSupervisor : public QTabWidget
|
class TabSupervisor : public QTabWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum DeckEditorType
|
||||||
|
{
|
||||||
|
ClassicDeckEditor,
|
||||||
|
VisualDeckEditor
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ServerInfo_User *userInfo;
|
ServerInfo_User *userInfo;
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "../client/network/release_channel.h"
|
#include "../client/network/release_channel.h"
|
||||||
#include "../client/network/spoiler_background_updater.h"
|
#include "../client/network/spoiler_background_updater.h"
|
||||||
#include "../client/sound_engine.h"
|
#include "../client/sound_engine.h"
|
||||||
|
#include "../client/tabs/tab_supervisor.h"
|
||||||
#include "../client/ui/picture_loader/picture_loader.h"
|
#include "../client/ui/picture_loader/picture_loader.h"
|
||||||
#include "../client/ui/theme_manager.h"
|
#include "../client/ui/theme_manager.h"
|
||||||
#include "../deck/custom_line_edit.h"
|
#include "../deck/custom_line_edit.h"
|
||||||
|
|
@ -681,10 +682,6 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
connect(&visualDeckStorageSelectionAnimationCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
|
connect(&visualDeckStorageSelectionAnimationCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
|
||||||
&SettingsCache::setVisualDeckStorageSelectionAnimation);
|
&SettingsCache::setVisualDeckStorageSelectionAnimation);
|
||||||
|
|
||||||
openInVisualDeckEditorCheckBox.setChecked(SettingsCache::instance().getOpenInVisualDeckEditor());
|
|
||||||
connect(&openInVisualDeckEditorCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
|
|
||||||
&SettingsCache::setOpenInVisualDeckEditor);
|
|
||||||
|
|
||||||
visualDeckStoragePromptForConversionSelector.addItem(""); // these will be set in retranslateUI
|
visualDeckStoragePromptForConversionSelector.addItem(""); // these will be set in retranslateUI
|
||||||
visualDeckStoragePromptForConversionSelector.addItem("");
|
visualDeckStoragePromptForConversionSelector.addItem("");
|
||||||
visualDeckStoragePromptForConversionSelector.addItem("");
|
visualDeckStoragePromptForConversionSelector.addItem("");
|
||||||
|
|
@ -703,13 +700,20 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
index == visualDeckStoragePromptForConversionIndexAlways);
|
index == visualDeckStoragePromptForConversionIndexAlways);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
defaultDeckEditorTypeSelector.addItem(""); // these will be set in retranslateUI
|
||||||
|
defaultDeckEditorTypeSelector.addItem("");
|
||||||
|
defaultDeckEditorTypeSelector.setCurrentIndex(SettingsCache::instance().getDefaultDeckEditorType());
|
||||||
|
connect(&defaultDeckEditorTypeSelector, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
|
&SettingsCache::instance(), &SettingsCache::setDefaultDeckEditorType);
|
||||||
|
|
||||||
auto *deckEditorGrid = new QGridLayout;
|
auto *deckEditorGrid = new QGridLayout;
|
||||||
deckEditorGrid->addWidget(&openDeckInNewTabCheckBox, 0, 0);
|
deckEditorGrid->addWidget(&openDeckInNewTabCheckBox, 0, 0);
|
||||||
deckEditorGrid->addWidget(&visualDeckStorageInGameCheckBox, 1, 0);
|
deckEditorGrid->addWidget(&visualDeckStorageInGameCheckBox, 1, 0);
|
||||||
deckEditorGrid->addWidget(&visualDeckStorageSelectionAnimationCheckBox, 2, 0);
|
deckEditorGrid->addWidget(&visualDeckStorageSelectionAnimationCheckBox, 2, 0);
|
||||||
deckEditorGrid->addWidget(&openInVisualDeckEditorCheckBox, 3, 0);
|
deckEditorGrid->addWidget(&visualDeckStoragePromptForConversionLabel, 3, 0);
|
||||||
deckEditorGrid->addWidget(&visualDeckStoragePromptForConversionLabel, 4, 0);
|
deckEditorGrid->addWidget(&visualDeckStoragePromptForConversionSelector, 3, 1);
|
||||||
deckEditorGrid->addWidget(&visualDeckStoragePromptForConversionSelector, 4, 1);
|
deckEditorGrid->addWidget(&defaultDeckEditorTypeLabel, 4, 0);
|
||||||
|
deckEditorGrid->addWidget(&defaultDeckEditorTypeSelector, 4, 1);
|
||||||
|
|
||||||
deckEditorGroupBox = new QGroupBox;
|
deckEditorGroupBox = new QGroupBox;
|
||||||
deckEditorGroupBox->setLayout(deckEditorGrid);
|
deckEditorGroupBox->setLayout(deckEditorGrid);
|
||||||
|
|
@ -771,7 +775,6 @@ void UserInterfaceSettingsPage::retranslateUi()
|
||||||
openDeckInNewTabCheckBox.setText(tr("Open deck in new tab by default"));
|
openDeckInNewTabCheckBox.setText(tr("Open deck in new tab by default"));
|
||||||
visualDeckStorageInGameCheckBox.setText(tr("Use visual deck storage in game lobby"));
|
visualDeckStorageInGameCheckBox.setText(tr("Use visual deck storage in game lobby"));
|
||||||
visualDeckStorageSelectionAnimationCheckBox.setText(tr("Use selection animation for Visual Deck Storage"));
|
visualDeckStorageSelectionAnimationCheckBox.setText(tr("Use selection animation for Visual Deck Storage"));
|
||||||
openInVisualDeckEditorCheckBox.setText(tr("Open decks in visual deck editor"));
|
|
||||||
visualDeckStoragePromptForConversionLabel.setText(
|
visualDeckStoragePromptForConversionLabel.setText(
|
||||||
tr("When adding a tag in the visual deck storage to a .txt deck:"));
|
tr("When adding a tag in the visual deck storage to a .txt deck:"));
|
||||||
visualDeckStoragePromptForConversionSelector.setItemText(visualDeckStoragePromptForConversionIndexNone,
|
visualDeckStoragePromptForConversionSelector.setItemText(visualDeckStoragePromptForConversionIndexNone,
|
||||||
|
|
@ -780,6 +783,9 @@ void UserInterfaceSettingsPage::retranslateUi()
|
||||||
tr("ask to convert to .cod"));
|
tr("ask to convert to .cod"));
|
||||||
visualDeckStoragePromptForConversionSelector.setItemText(visualDeckStoragePromptForConversionIndexAlways,
|
visualDeckStoragePromptForConversionSelector.setItemText(visualDeckStoragePromptForConversionIndexAlways,
|
||||||
tr("always convert to .cod"));
|
tr("always convert to .cod"));
|
||||||
|
defaultDeckEditorTypeLabel.setText(tr("Default deck editor type"));
|
||||||
|
defaultDeckEditorTypeSelector.setItemText(TabSupervisor::ClassicDeckEditor, tr("Classic Deck Editor"));
|
||||||
|
defaultDeckEditorTypeSelector.setItemText(TabSupervisor::VisualDeckEditor, tr("Visual Deck Editor"));
|
||||||
replayGroupBox->setTitle(tr("Replay settings"));
|
replayGroupBox->setTitle(tr("Replay settings"));
|
||||||
rewindBufferingMsLabel.setText(tr("Buffer time for backwards skip via shortcut:"));
|
rewindBufferingMsLabel.setText(tr("Buffer time for backwards skip via shortcut:"));
|
||||||
rewindBufferingMsBox.setSuffix(" ms");
|
rewindBufferingMsBox.setSuffix(" ms");
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,8 @@ private:
|
||||||
QComboBox visualDeckStoragePromptForConversionSelector;
|
QComboBox visualDeckStoragePromptForConversionSelector;
|
||||||
QCheckBox visualDeckStorageInGameCheckBox;
|
QCheckBox visualDeckStorageInGameCheckBox;
|
||||||
QCheckBox visualDeckStorageSelectionAnimationCheckBox;
|
QCheckBox visualDeckStorageSelectionAnimationCheckBox;
|
||||||
QCheckBox openInVisualDeckEditorCheckBox;
|
QLabel defaultDeckEditorTypeLabel;
|
||||||
|
QComboBox defaultDeckEditorTypeSelector;
|
||||||
QLabel rewindBufferingMsLabel;
|
QLabel rewindBufferingMsLabel;
|
||||||
QSpinBox rewindBufferingMsBox;
|
QSpinBox rewindBufferingMsBox;
|
||||||
QGroupBox *generalGroupBox;
|
QGroupBox *generalGroupBox;
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,7 @@ SettingsCache::SettingsCache()
|
||||||
visualDeckStorageInGame = settings->value("interface/visualdeckstorageingame", true).toBool();
|
visualDeckStorageInGame = settings->value("interface/visualdeckstorageingame", true).toBool();
|
||||||
visualDeckStorageSelectionAnimation =
|
visualDeckStorageSelectionAnimation =
|
||||||
settings->value("interface/visualdeckstorageselectionanimation", true).toBool();
|
settings->value("interface/visualdeckstorageselectionanimation", true).toBool();
|
||||||
openInVisualDeckEditor = settings->value("interface/openInVisualDeckEditor", true).toBool();
|
defaultDeckEditorType = settings->value("interface/defaultDeckEditorType", 1).toInt();
|
||||||
visualDatabaseDisplayFilterToMostRecentSetsEnabled =
|
visualDatabaseDisplayFilterToMostRecentSetsEnabled =
|
||||||
settings->value("interface/visualdatabasedisplayfiltertomostrecentsetsenabled", true).toBool();
|
settings->value("interface/visualdatabasedisplayfiltertomostrecentsetsenabled", true).toBool();
|
||||||
visualDatabaseDisplayFilterToMostRecentSetsAmount =
|
visualDatabaseDisplayFilterToMostRecentSetsAmount =
|
||||||
|
|
@ -792,10 +792,10 @@ void SettingsCache::setVisualDeckStorageSelectionAnimation(QT_STATE_CHANGED_T va
|
||||||
emit visualDeckStorageSelectionAnimationChanged(visualDeckStorageSelectionAnimation);
|
emit visualDeckStorageSelectionAnimationChanged(visualDeckStorageSelectionAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsCache::setOpenInVisualDeckEditor(QT_STATE_CHANGED_T value)
|
void SettingsCache::setDefaultDeckEditorType(int value)
|
||||||
{
|
{
|
||||||
openInVisualDeckEditor = value;
|
defaultDeckEditorType = value;
|
||||||
settings->setValue("interface/openInVisualDeckEditor", openInVisualDeckEditor);
|
settings->setValue("interface/defaultDeckEditorType", defaultDeckEditorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsCache::setVisualDatabaseDisplayFilterToMostRecentSetsEnabled(QT_STATE_CHANGED_T _enabled)
|
void SettingsCache::setVisualDatabaseDisplayFilterToMostRecentSetsEnabled(QT_STATE_CHANGED_T _enabled)
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ private:
|
||||||
bool visualDeckStorageAlwaysConvert;
|
bool visualDeckStorageAlwaysConvert;
|
||||||
bool visualDeckStorageInGame;
|
bool visualDeckStorageInGame;
|
||||||
bool visualDeckStorageSelectionAnimation;
|
bool visualDeckStorageSelectionAnimation;
|
||||||
bool openInVisualDeckEditor;
|
int defaultDeckEditorType;
|
||||||
bool visualDatabaseDisplayFilterToMostRecentSetsEnabled;
|
bool visualDatabaseDisplayFilterToMostRecentSetsEnabled;
|
||||||
int visualDatabaseDisplayFilterToMostRecentSetsAmount;
|
int visualDatabaseDisplayFilterToMostRecentSetsAmount;
|
||||||
bool horizontalHand;
|
bool horizontalHand;
|
||||||
|
|
@ -489,9 +489,9 @@ public:
|
||||||
{
|
{
|
||||||
return visualDeckStorageSelectionAnimation;
|
return visualDeckStorageSelectionAnimation;
|
||||||
}
|
}
|
||||||
bool getOpenInVisualDeckEditor() const
|
int getDefaultDeckEditorType() const
|
||||||
{
|
{
|
||||||
return openInVisualDeckEditor;
|
return defaultDeckEditorType;
|
||||||
}
|
}
|
||||||
bool getVisualDatabaseDisplayFilterToMostRecentSetsEnabled() const
|
bool getVisualDatabaseDisplayFilterToMostRecentSetsEnabled() const
|
||||||
{
|
{
|
||||||
|
|
@ -844,7 +844,7 @@ public slots:
|
||||||
void setVisualDeckStorageAlwaysConvert(bool _visualDeckStorageAlwaysConvert);
|
void setVisualDeckStorageAlwaysConvert(bool _visualDeckStorageAlwaysConvert);
|
||||||
void setVisualDeckStorageInGame(QT_STATE_CHANGED_T value);
|
void setVisualDeckStorageInGame(QT_STATE_CHANGED_T value);
|
||||||
void setVisualDeckStorageSelectionAnimation(QT_STATE_CHANGED_T value);
|
void setVisualDeckStorageSelectionAnimation(QT_STATE_CHANGED_T value);
|
||||||
void setOpenInVisualDeckEditor(QT_STATE_CHANGED_T value);
|
void setDefaultDeckEditorType(int value);
|
||||||
void setVisualDatabaseDisplayFilterToMostRecentSetsEnabled(QT_STATE_CHANGED_T _enabled);
|
void setVisualDatabaseDisplayFilterToMostRecentSetsEnabled(QT_STATE_CHANGED_T _enabled);
|
||||||
void setVisualDatabaseDisplayFilterToMostRecentSetsAmount(int _amount);
|
void setVisualDatabaseDisplayFilterToMostRecentSetsAmount(int _amount);
|
||||||
void setHorizontalHand(QT_STATE_CHANGED_T _horizontalHand);
|
void setHorizontalHand(QT_STATE_CHANGED_T _horizontalHand);
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,7 @@ void SettingsCache::setVisualDeckStorageInGame(QT_STATE_CHANGED_T /* value */)
|
||||||
void SettingsCache::setVisualDeckStorageSelectionAnimation(QT_STATE_CHANGED_T /* value */)
|
void SettingsCache::setVisualDeckStorageSelectionAnimation(QT_STATE_CHANGED_T /* value */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void SettingsCache::setOpenInVisualDeckEditor(QT_STATE_CHANGED_T /* value */)
|
void SettingsCache::setDefaultDeckEditorType(int /* value */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void SettingsCache::setVisualDatabaseDisplayFilterToMostRecentSetsEnabled(QT_STATE_CHANGED_T /* _enabled */)
|
void SettingsCache::setVisualDatabaseDisplayFilterToMostRecentSetsEnabled(QT_STATE_CHANGED_T /* _enabled */)
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,7 @@ void SettingsCache::setVisualDeckStorageInGame(QT_STATE_CHANGED_T /* value */)
|
||||||
void SettingsCache::setVisualDeckStorageSelectionAnimation(QT_STATE_CHANGED_T /* value */)
|
void SettingsCache::setVisualDeckStorageSelectionAnimation(QT_STATE_CHANGED_T /* value */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void SettingsCache::setOpenInVisualDeckEditor(QT_STATE_CHANGED_T /* value */)
|
void SettingsCache::setDefaultDeckEditorType(int /* value */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void SettingsCache::setVisualDatabaseDisplayFilterToMostRecentSetsEnabled(QT_STATE_CHANGED_T /* _enabled */)
|
void SettingsCache::setVisualDatabaseDisplayFilterToMostRecentSetsEnabled(QT_STATE_CHANGED_T /* _enabled */)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue