[Settings] Split cache_settings monolith into multiple SettingsManager sub-classes (#7050)

* [Settings] Split cache_settings into multiple files

Took 9 minutes

Took 4 minutes

* [Settings] Fwd declare settings classes in cache_settings

Took 15 minutes

* Fix oracle includes.

Took 8 minutes

* Address comments, fix windows CI

Took 8 minutes

* fix copy constructor visibility

Took 3 minutes

* lint

Took 2 minutes

* Fix native format tests.

Took 5 minutes

* Remove test header guard

Took 4 seconds

* Remove tests invalid in CI environ

Took 24 seconds

* Adjust to rebase.

Took 11 minutes

* Change settings file name.

Took 8 minutes

---------

Co-authored-by: Lukas Brübach <lukas.bruebach@bdosecurity.de>
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-07-27 11:25:39 +02:00 committed by GitHub
parent cf0b453e75
commit 12f0f59453
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
166 changed files with 5589 additions and 3066 deletions

View file

@ -3,16 +3,28 @@ set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(HEADERS
libcockatrice/settings/cache_storage_settings.h
libcockatrice/settings/card_database_settings.h
libcockatrice/settings/card_override_settings.h
libcockatrice/settings/cards_display_settings.h
libcockatrice/settings/chat_settings.h
libcockatrice/settings/debug_settings.h
libcockatrice/settings/download_settings.h
libcockatrice/settings/game_filters_settings.h
libcockatrice/settings/game_settings.h
libcockatrice/settings/interface_settings.h
libcockatrice/settings/layouts_settings.h
libcockatrice/settings/message_settings.h
libcockatrice/settings/paths_settings.h
libcockatrice/settings/personal_settings.h
libcockatrice/settings/recents_settings.h
libcockatrice/settings/servers_settings.h
libcockatrice/settings/settings_manager.h
libcockatrice/settings/settings_migration.h
libcockatrice/settings/sound_settings.h
libcockatrice/settings/tabs_settings.h
libcockatrice/settings/updates_settings.h
libcockatrice/settings/visual_deck_storage_settings.h
)
if(Qt6_FOUND)
@ -24,16 +36,28 @@ endif()
add_library(
libcockatrice_settings STATIC
${MOC_SOURCES}
libcockatrice/settings/cache_storage_settings.cpp
libcockatrice/settings/card_database_settings.cpp
libcockatrice/settings/card_override_settings.cpp
libcockatrice/settings/cards_display_settings.cpp
libcockatrice/settings/chat_settings.cpp
libcockatrice/settings/debug_settings.cpp
libcockatrice/settings/download_settings.cpp
libcockatrice/settings/game_filters_settings.cpp
libcockatrice/settings/game_settings.cpp
libcockatrice/settings/interface_settings.cpp
libcockatrice/settings/layouts_settings.cpp
libcockatrice/settings/message_settings.cpp
libcockatrice/settings/paths_settings.cpp
libcockatrice/settings/personal_settings.cpp
libcockatrice/settings/recents_settings.cpp
libcockatrice/settings/servers_settings.cpp
libcockatrice/settings/settings_manager.cpp
libcockatrice/settings/settings_migration.cpp
libcockatrice/settings/sound_settings.cpp
libcockatrice/settings/tabs_settings.cpp
libcockatrice/settings/updates_settings.cpp
libcockatrice/settings/visual_deck_storage_settings.cpp
)
target_include_directories(

View file

@ -0,0 +1,62 @@
#include "cache_storage_settings.h"
CacheStorageSettings::CacheStorageSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "cache_storage.ini", "personal", QString(), parent)
{
}
int CacheStorageSettings::getPixmapCacheSize() const
{
return getValue("pixmapCacheSize", QString(), QString(), PIXMAPCACHE_SIZE_DEFAULT).toInt();
}
int CacheStorageSettings::getNetworkCacheSizeInMB() const
{
return getValue("networkCacheSize", QString(), QString(), NETWORK_CACHE_SIZE_DEFAULT).toInt();
}
int CacheStorageSettings::getRedirectCacheTtl() const
{
return getValue("redirectCacheTtl", QString(), QString(), NETWORK_REDIRECT_CACHE_TTL_DEFAULT).toInt();
}
int CacheStorageSettings::getCardPictureLoaderCacheMethod() const
{
return getValue("cardPictureLoaderCacheMethod", QString(), QString(), 0).toInt();
}
int CacheStorageSettings::getLocalCardImageStorageNamingScheme() const
{
return getValue("localCardImageStorageNamingScheme", QString(), QString(), LOCAL_CARD_IMAGE_NAMING_SCHEME_DEFAULT)
.toInt();
}
void CacheStorageSettings::setPixmapCacheSize(int _pixmapCacheSize)
{
setValue(_pixmapCacheSize, "pixmapCacheSize");
emit pixmapCacheSizeChanged(_pixmapCacheSize);
}
void CacheStorageSettings::setNetworkCacheSizeInMB(int _networkCacheSize)
{
setValue(_networkCacheSize, "networkCacheSize");
emit networkCacheSizeChanged(_networkCacheSize);
}
void CacheStorageSettings::setNetworkRedirectCacheTtl(int _redirectCacheTtl)
{
setValue(_redirectCacheTtl, "redirectCacheTtl");
emit redirectCacheTtlChanged(_redirectCacheTtl);
}
void CacheStorageSettings::setCardImageCacheMethod(int _cardImageCachingMethod)
{
setValue(_cardImageCachingMethod, "cardPictureLoaderCacheMethod");
emit cardPictureLoaderCacheMethodChanged(_cardImageCachingMethod);
}
void CacheStorageSettings::setLocalCardImageStorageNamingScheme(int _localCardImageStorageNamingScheme)
{
setValue(_localCardImageStorageNamingScheme, "localCardImageStorageNamingScheme");
emit localCardImageStorageNamingSchemeChanged(_localCardImageStorageNamingScheme);
}

View file

@ -0,0 +1,57 @@
#ifndef CACHE_STORAGE_SETTINGS_H
#define CACHE_STORAGE_SETTINGS_H
#include "settings_manager.h"
#include <libcockatrice/interfaces/interface_cache_storage_settings_provider.h>
// In MB (Increments of 64)
#define PIXMAPCACHE_SIZE_DEFAULT 2048
#define PIXMAPCACHE_SIZE_MIN 64
#define PIXMAPCACHE_SIZE_MAX 4096
// In MB
constexpr int NETWORK_CACHE_SIZE_DEFAULT = 1024 * 4; // 4 GB
constexpr int NETWORK_CACHE_SIZE_MIN = 1; // 1 MB
constexpr int NETWORK_CACHE_SIZE_MAX = 1024 * 1024; // 1 TB
#define LOCAL_CARD_IMAGE_NAMING_SCHEME_DEFAULT 6
// In Days
#define NETWORK_REDIRECT_CACHE_TTL_DEFAULT 30
#define NETWORK_REDIRECT_CACHE_TTL_MIN 1
#define NETWORK_REDIRECT_CACHE_TTL_MAX 90
class CacheStorageSettings : public SettingsManager, public ICacheStorageSettingsProvider
{
Q_OBJECT
friend class SettingsCache;
public:
[[nodiscard]] int getPixmapCacheSize() const override;
[[nodiscard]] int getNetworkCacheSizeInMB() const override;
[[nodiscard]] int getRedirectCacheTtl() const override;
[[nodiscard]] int getCardPictureLoaderCacheMethod() const;
[[nodiscard]] int getLocalCardImageStorageNamingScheme() const;
void setPixmapCacheSize(int _pixmapCacheSize);
void setNetworkCacheSizeInMB(int _networkCacheSize);
void setNetworkRedirectCacheTtl(int _redirectCacheTtl);
void setCardImageCacheMethod(int _cardImageCachingMethod);
void setLocalCardImageStorageNamingScheme(int _scheme);
signals:
void pixmapCacheSizeChanged(int newSizeInMBs);
void networkCacheSizeChanged(int newSizeInMBs);
void redirectCacheTtlChanged(int newTtl);
void cardPictureLoaderCacheMethodChanged(int cardPictureLoaderCacheMethod);
void localCardImageStorageNamingSchemeChanged(int localCardImageStorageNamingScheme);
public:
explicit CacheStorageSettings(const QString &settingPath, QObject *parent = nullptr);
private:
CacheStorageSettings(const CacheStorageSettings & /*other*/);
};
#endif // CACHE_STORAGE_SETTINGS_H

View file

@ -0,0 +1,193 @@
#include "cards_display_settings.h"
CardsDisplaySettings::CardsDisplaySettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "cards_display.ini", "cards", QString(), parent)
{
}
bool CardsDisplaySettings::getDisplayCardNames() const
{
return getValue("displaycardnames", QString(), QString(), true).toBool();
}
bool CardsDisplaySettings::getRoundCardCorners() const
{
return getValue("roundcardcorners", QString(), QString(), true).toBool();
}
bool CardsDisplaySettings::getOverrideAllCardArtWithPersonalPreference() const
{
return getValue("overrideallcardartwithpersonalpreference", QString(), QString(), false).toBool();
}
bool CardsDisplaySettings::getBumpSetsWithCardsInDeckToTop() const
{
return getValue("bumpsetswithcardsindecktotop", QString(), QString(), true).toBool();
}
int CardsDisplaySettings::getPrintingSelectorSortOrder() const
{
return getValue("printingselectorsortorder", QString(), QString(), 1).toInt();
}
int CardsDisplaySettings::getPrintingSelectorCardSize() const
{
return getValue("printingselectorcardsize", QString(), QString(), 100).toInt();
}
bool CardsDisplaySettings::getIncludeRebalancedCards() const
{
return getValue("includerebalancedcards", QString(), QString(), true).toBool();
}
bool CardsDisplaySettings::getPrintingSelectorNavigationButtonsVisible() const
{
return getValue("printingselectornavigationbuttonsvisible", QString(), QString(), true).toBool();
}
bool CardsDisplaySettings::getDeckEditorBannerCardComboBoxVisible() const
{
return getValue("deckeditorbannercardcomboboxvisible", "interface", QString(), true).toBool();
}
bool CardsDisplaySettings::getDeckEditorTagsWidgetVisible() const
{
return getValue("deckeditortagswidgetvisible", "interface", QString(), true).toBool();
}
bool CardsDisplaySettings::getTapAnimation() const
{
return getValue("tapanimation", QString(), QString(), true).toBool();
}
bool CardsDisplaySettings::getAutoRotateSidewaysLayoutCards() const
{
return getValue("autorotatesidewayslayoutcards", QString(), QString(), true).toBool();
}
bool CardsDisplaySettings::getScaleCards() const
{
return getValue("scaleCards", QString(), QString(), true).toBool();
}
int CardsDisplaySettings::getStackCardOverlapPercent() const
{
return getValue("verticalCardOverlapPercent", QString(), QString(), 33).toInt();
}
int CardsDisplaySettings::getCardInfoViewMode() const
{
return getValue("cardinfoviewmode", QString(), QString(), 0).toInt();
}
bool CardsDisplaySettings::getShowShortcuts() const
{
return getValue("showshortcuts", "menu", QString(), true).toBool();
}
bool CardsDisplaySettings::getShowGameSelectorFilterToolbar() const
{
return getValue("showgameselectorfiltertoolbar", "menu", QString(), true).toBool();
}
void CardsDisplaySettings::setDisplayCardNames(bool _displayCardNames)
{
setValue(_displayCardNames, "displaycardnames");
emit displayCardNamesChanged();
}
void CardsDisplaySettings::setRoundCardCorners(bool _roundCardCorners)
{
if (_roundCardCorners == getRoundCardCorners()) {
return;
}
setValue(_roundCardCorners, "roundcardcorners");
emit roundCardCornersChanged(_roundCardCorners);
}
void CardsDisplaySettings::setOverrideAllCardArtWithPersonalPreference(bool _overrideAllCardArt)
{
setValue(_overrideAllCardArt, "overrideallcardartwithpersonalpreference");
emit overrideAllCardArtWithPersonalPreferenceChanged(_overrideAllCardArt);
}
void CardsDisplaySettings::setBumpSetsWithCardsInDeckToTop(bool _bumpSetsWithCardsInDeckToTop)
{
setValue(_bumpSetsWithCardsInDeckToTop, "bumpsetswithcardsindecktotop");
emit bumpSetsWithCardsInDeckToTopChanged();
}
void CardsDisplaySettings::setPrintingSelectorSortOrder(int _printingSelectorSortOrder)
{
setValue(_printingSelectorSortOrder, "printingselectorsortorder");
emit printingSelectorSortOrderChanged();
}
void CardsDisplaySettings::setPrintingSelectorCardSize(int _printingSelectorCardSize)
{
setValue(_printingSelectorCardSize, "printingselectorcardsize");
emit printingSelectorCardSizeChanged();
}
void CardsDisplaySettings::setIncludeRebalancedCards(bool _includeRebalancedCards)
{
if (_includeRebalancedCards == getIncludeRebalancedCards()) {
return;
}
setValue(_includeRebalancedCards, "includerebalancedcards");
emit includeRebalancedCardsChanged(_includeRebalancedCards);
}
void CardsDisplaySettings::setPrintingSelectorNavigationButtonsVisible(bool _navigationButtonsVisible)
{
setValue(_navigationButtonsVisible, "printingselectornavigationbuttonsvisible");
emit printingSelectorNavigationButtonsVisibleChanged();
}
void CardsDisplaySettings::setDeckEditorBannerCardComboBoxVisible(bool _deckEditorBannerCardComboBoxVisible)
{
setValue(_deckEditorBannerCardComboBoxVisible, "deckeditorbannercardcomboboxvisible", "interface");
emit deckEditorBannerCardComboBoxVisibleChanged(_deckEditorBannerCardComboBoxVisible);
}
void CardsDisplaySettings::setDeckEditorTagsWidgetVisible(bool _deckEditorTagsWidgetVisible)
{
setValue(_deckEditorTagsWidgetVisible, "deckeditortagswidgetvisible", "interface");
emit deckEditorTagsWidgetVisibleChanged(_deckEditorTagsWidgetVisible);
}
void CardsDisplaySettings::setTapAnimation(bool _tapAnimation)
{
setValue(_tapAnimation, "tapanimation");
}
void CardsDisplaySettings::setAutoRotateSidewaysLayoutCards(bool _autoRotateSidewaysLayoutCards)
{
setValue(_autoRotateSidewaysLayoutCards, "autorotatesidewayslayoutcards");
}
void CardsDisplaySettings::setCardScaling(bool _scaleCards)
{
setValue(_scaleCards, "scaleCards");
}
void CardsDisplaySettings::setStackCardOverlapPercent(int _verticalCardOverlapPercent)
{
setValue(_verticalCardOverlapPercent, "verticalCardOverlapPercent");
}
void CardsDisplaySettings::setCardInfoViewMode(int _viewMode)
{
setValue(_viewMode, "cardinfoviewmode");
}
void CardsDisplaySettings::setShowShortcuts(bool _showShortcuts)
{
setValue(_showShortcuts, "showshortcuts", "menu");
}
void CardsDisplaySettings::setShowGameSelectorFilterToolbar(bool _showGameSelectorFilterToolbar)
{
setValue(_showGameSelectorFilterToolbar, "showgameselectorfiltertoolbar", "menu");
emit showGameSelectorFilterToolbarChanged(_showGameSelectorFilterToolbar);
}

View file

@ -0,0 +1,68 @@
#ifndef CARDS_DISPLAY_SETTINGS_H
#define CARDS_DISPLAY_SETTINGS_H
#include "settings_manager.h"
#include <libcockatrice/interfaces/interface_cards_display_settings_provider.h>
class CardsDisplaySettings : public SettingsManager, public ICardsDisplaySettingsProvider
{
Q_OBJECT
friend class SettingsCache;
public:
[[nodiscard]] bool getDisplayCardNames() const override;
[[nodiscard]] bool getRoundCardCorners() const override;
[[nodiscard]] bool getOverrideAllCardArtWithPersonalPreference() const override;
[[nodiscard]] bool getBumpSetsWithCardsInDeckToTop() const override;
[[nodiscard]] int getPrintingSelectorSortOrder() const override;
[[nodiscard]] int getPrintingSelectorCardSize() const override;
[[nodiscard]] bool getIncludeRebalancedCards() const override;
[[nodiscard]] bool getPrintingSelectorNavigationButtonsVisible() const override;
[[nodiscard]] bool getDeckEditorBannerCardComboBoxVisible() const override;
[[nodiscard]] bool getDeckEditorTagsWidgetVisible() const override;
[[nodiscard]] bool getTapAnimation() const override;
[[nodiscard]] bool getAutoRotateSidewaysLayoutCards() const override;
[[nodiscard]] bool getScaleCards() const override;
[[nodiscard]] int getStackCardOverlapPercent() const override;
[[nodiscard]] int getCardInfoViewMode() const override;
[[nodiscard]] bool getShowShortcuts() const override;
[[nodiscard]] bool getShowGameSelectorFilterToolbar() const override;
void setDisplayCardNames(bool _displayCardNames);
void setRoundCardCorners(bool _roundCardCorners);
void setOverrideAllCardArtWithPersonalPreference(bool _overrideAllCardArt);
void setBumpSetsWithCardsInDeckToTop(bool _bumpSetsWithCardsInDeckToTop);
void setPrintingSelectorSortOrder(int _printingSelectorSortOrder);
void setPrintingSelectorCardSize(int _printingSelectorCardSize);
void setIncludeRebalancedCards(bool _includeRebalancedCards);
void setPrintingSelectorNavigationButtonsVisible(bool _navigationButtonsVisible);
void setDeckEditorBannerCardComboBoxVisible(bool _deckEditorBannerCardComboBoxVisible);
void setDeckEditorTagsWidgetVisible(bool _deckEditorTagsWidgetVisible);
void setTapAnimation(bool _tapAnimation);
void setAutoRotateSidewaysLayoutCards(bool _autoRotateSidewaysLayoutCards);
void setCardScaling(bool _scaleCards);
void setStackCardOverlapPercent(int _verticalCardOverlapPercent);
void setCardInfoViewMode(int _viewMode);
void setShowShortcuts(bool _showShortcuts);
void setShowGameSelectorFilterToolbar(bool _showGameSelectorFilterToolbar);
signals:
void displayCardNamesChanged();
void roundCardCornersChanged(bool roundCardCorners);
void overrideAllCardArtWithPersonalPreferenceChanged(bool _overrideAllCardArtWithPersonalPreference);
void bumpSetsWithCardsInDeckToTopChanged();
void printingSelectorSortOrderChanged();
void printingSelectorCardSizeChanged();
void includeRebalancedCardsChanged(bool _includeRebalancedCards);
void printingSelectorNavigationButtonsVisibleChanged();
void deckEditorBannerCardComboBoxVisibleChanged(bool _visible);
void deckEditorTagsWidgetVisibleChanged(bool _visible);
void showGameSelectorFilterToolbarChanged(bool state);
private:
explicit CardsDisplaySettings(const QString &settingPath, QObject *parent = nullptr);
CardsDisplaySettings(const CardsDisplaySettings & /*other*/);
};
#endif // CARDS_DISPLAY_SETTINGS_H

View file

@ -0,0 +1,137 @@
#include "chat_settings.h"
ChatSettings::ChatSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "chat.ini", "chat", QString(), parent)
{
}
bool ChatSettings::getChatMention() const
{
return getValue("mention", QString(), QString(), true).toBool();
}
bool ChatSettings::getChatMentionCompleter() const
{
return getValue("mentioncompleter", QString(), QString(), true).toBool();
}
QString ChatSettings::getChatMentionColor() const
{
return getValue("mentioncolor", QString(), QString(), "A6120D").toString();
}
QString ChatSettings::getChatHighlightColor() const
{
return getValue("highlightcolor", QString(), QString(), "A6120D").toString();
}
bool ChatSettings::getChatMentionForeground() const
{
return getValue("mentionforeground", QString(), QString(), true).toBool();
}
bool ChatSettings::getChatHighlightForeground() const
{
return getValue("highlightforeground", QString(), QString(), true).toBool();
}
bool ChatSettings::getIgnoreUnregisteredUsers() const
{
return getValue("ignore_unregistered").toBool();
}
bool ChatSettings::getIgnoreUnregisteredUserMessages() const
{
return getValue("ignore_unregistered_messages").toBool();
}
bool ChatSettings::getIgnoreNonBuddyUserMessages() const
{
return getValue("ignore_nonbuddy_messages").toBool();
}
bool ChatSettings::getShowMessagePopup() const
{
return getValue("showmessagepopups", QString(), QString(), true).toBool();
}
bool ChatSettings::getShowMentionPopup() const
{
return getValue("showmentionpopups", QString(), QString(), true).toBool();
}
bool ChatSettings::getRoomHistory() const
{
return getValue("roomhistory", QString(), QString(), true).toBool();
}
QString ChatSettings::getHighlightWords() const
{
return getValue("highlightwords").toString();
}
void ChatSettings::setChatMention(bool _chatMention)
{
setValue(_chatMention, "mention");
}
void ChatSettings::setChatMentionCompleter(bool _chatMentionCompleter)
{
setValue(_chatMentionCompleter, "mentioncompleter");
emit chatMentionCompleterChanged();
}
void ChatSettings::setChatMentionColor(const QString &_chatMentionColor)
{
setValue(_chatMentionColor, "mentioncolor");
}
void ChatSettings::setChatHighlightColor(const QString &_chatHighlightColor)
{
setValue(_chatHighlightColor, "highlightcolor");
}
void ChatSettings::setChatMentionForeground(bool _chatMentionForeground)
{
setValue(_chatMentionForeground, "mentionforeground");
}
void ChatSettings::setChatHighlightForeground(bool _chatHighlightForeground)
{
setValue(_chatHighlightForeground, "highlightforeground");
}
void ChatSettings::setIgnoreUnregisteredUsers(bool _ignoreUnregisteredUsers)
{
setValue(_ignoreUnregisteredUsers, "ignore_unregistered");
}
void ChatSettings::setIgnoreUnregisteredUserMessages(bool _ignoreUnregisteredUserMessages)
{
setValue(_ignoreUnregisteredUserMessages, "ignore_unregistered_messages");
}
void ChatSettings::setIgnoreNonBuddyUserMessages(bool _ignoreNonBuddyUserMessages)
{
setValue(_ignoreNonBuddyUserMessages, "ignore_nonbuddy_messages");
}
void ChatSettings::setShowMessagePopups(bool _showMessagePopups)
{
setValue(_showMessagePopups, "showmessagepopups");
}
void ChatSettings::setShowMentionPopups(bool _showMentionPopups)
{
setValue(_showMentionPopups, "showmentionpopups");
}
void ChatSettings::setRoomHistory(bool _roomHistory)
{
setValue(_roomHistory, "roomhistory");
}
void ChatSettings::setHighlightWords(const QString &_highlightWords)
{
setValue(_highlightWords, "highlightwords");
}

View file

@ -0,0 +1,52 @@
#ifndef CHAT_SETTINGS_H
#define CHAT_SETTINGS_H
#include "settings_manager.h"
#include <libcockatrice/interfaces/interface_chat_settings_provider.h>
class ChatSettings : public SettingsManager, public IChatSettingsProvider
{
Q_OBJECT
friend class SettingsCache;
public:
[[nodiscard]] bool getChatMention() const override;
[[nodiscard]] bool getChatMentionCompleter() const override;
[[nodiscard]] QString getChatMentionColor() const override;
[[nodiscard]] QString getChatHighlightColor() const override;
[[nodiscard]] bool getChatMentionForeground() const override;
[[nodiscard]] bool getChatHighlightForeground() const override;
[[nodiscard]] bool getIgnoreUnregisteredUsers() const override;
[[nodiscard]] bool getIgnoreUnregisteredUserMessages() const override;
[[nodiscard]] bool getIgnoreNonBuddyUserMessages() const override;
[[nodiscard]] bool getShowMessagePopup() const override;
[[nodiscard]] bool getShowMentionPopup() const override;
[[nodiscard]] bool getRoomHistory() const override;
[[nodiscard]] QString getHighlightWords() const override;
void setChatMention(bool _chatMention);
void setChatMentionCompleter(bool _chatMentionCompleter);
void setChatMentionColor(const QString &_chatMentionColor);
void setChatHighlightColor(const QString &_chatHighlightColor);
void setChatMentionForeground(bool _chatMentionForeground);
void setChatHighlightForeground(bool _chatHighlightForeground);
void setIgnoreUnregisteredUsers(bool _ignoreUnregisteredUsers);
void setIgnoreUnregisteredUserMessages(bool _ignoreUnregisteredUserMessages);
void setIgnoreNonBuddyUserMessages(bool _ignoreNonBuddyUserMessages);
void setShowMessagePopups(bool _showMessagePopups);
void setShowMentionPopups(bool _showMentionPopups);
void setRoomHistory(bool _roomHistory);
void setHighlightWords(const QString &_highlightWords);
signals:
void chatMentionCompleterChanged();
public:
explicit ChatSettings(const QString &settingPath, QObject *parent = nullptr);
private:
ChatSettings(const ChatSettings & /*other*/);
};
#endif // CHAT_SETTINGS_H

View file

@ -0,0 +1,166 @@
#include "game_settings.h"
GameSettings::GameSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "game.ini", QString(), QString(), parent)
{
}
QString GameSettings::getGameDescription() const
{
return getValue("gamedescription", "game").toString();
}
int GameSettings::getMaxPlayers() const
{
return getValue("maxplayers", "game", QString(), 2).toInt();
}
QString GameSettings::getGameTypes() const
{
return getValue("gametypes", "game").toString();
}
bool GameSettings::getOnlyBuddies() const
{
return getValue("onlybuddies", "game").toBool();
}
bool GameSettings::getOnlyRegistered() const
{
return getValue("onlyregistered", "game").toBool();
}
bool GameSettings::getSpectatorsAllowed() const
{
return getValue("spectatorsallowed", "game").toBool();
}
bool GameSettings::getSpectatorsNeedPassword() const
{
return getValue("spectatorsneedpassword", "game").toBool();
}
bool GameSettings::getSpectatorsCanTalk() const
{
return getValue("spectatorscantalk", "game").toBool();
}
bool GameSettings::getSpectatorsCanSeeEverything() const
{
return getValue("spectatorscanseeeverything", "game").toBool();
}
bool GameSettings::getCreateGameAsSpectator() const
{
return getValue("creategameasspectator", "game").toBool();
}
int GameSettings::getDefaultStartingLifeTotal() const
{
return getValue("defaultstartinglifetotal", "game", QString(), 20).toInt();
}
bool GameSettings::getShareDecklistsOnLoad() const
{
return getValue("sharedecklistsonload", "game").toBool();
}
bool GameSettings::getRememberGameSettings() const
{
return getValue("remembergamesettings", "game", QString(), true).toBool();
}
bool GameSettings::getLocalGameRememberSettings() const
{
return getValue("remembersettings", "localgameoptions").toBool();
}
int GameSettings::getLocalGameMaxPlayers() const
{
return getValue("maxplayers", "localgameoptions", QString(), 1).toInt();
}
int GameSettings::getLocalGameStartingLifeTotal() const
{
return getValue("startinglifetotal", "localgameoptions", QString(), 20).toInt();
}
void GameSettings::setGameDescription(const QString &_gameDescription)
{
setValue(_gameDescription, "gamedescription", "game");
}
void GameSettings::setMaxPlayers(int _maxPlayers)
{
setValue(_maxPlayers, "maxplayers", "game");
}
void GameSettings::setGameTypes(const QString &_gameTypes)
{
setValue(_gameTypes, "gametypes", "game");
}
void GameSettings::setOnlyBuddies(bool _onlyBuddies)
{
setValue(_onlyBuddies, "onlybuddies", "game");
}
void GameSettings::setOnlyRegistered(bool _onlyRegistered)
{
setValue(_onlyRegistered, "onlyregistered", "game");
}
void GameSettings::setSpectatorsAllowed(bool _spectatorsAllowed)
{
setValue(_spectatorsAllowed, "spectatorsallowed", "game");
}
void GameSettings::setSpectatorsNeedPassword(bool _spectatorsNeedPassword)
{
setValue(_spectatorsNeedPassword, "spectatorsneedpassword", "game");
}
void GameSettings::setSpectatorsCanTalk(bool _spectatorsCanTalk)
{
setValue(_spectatorsCanTalk, "spectatorscantalk", "game");
}
void GameSettings::setSpectatorsCanSeeEverything(bool _spectatorsCanSeeEverything)
{
setValue(_spectatorsCanSeeEverything, "spectatorscanseeeverything", "game");
}
void GameSettings::setCreateGameAsSpectator(bool _createGameAsSpectator)
{
setValue(_createGameAsSpectator, "creategameasspectator", "game");
}
void GameSettings::setDefaultStartingLifeTotal(int _defaultStartingLifeTotal)
{
setValue(_defaultStartingLifeTotal, "defaultstartinglifetotal", "game");
}
void GameSettings::setShareDecklistsOnLoad(bool _shareDecklistsOnLoad)
{
setValue(_shareDecklistsOnLoad, "sharedecklistsonload", "game");
}
void GameSettings::setRememberGameSettings(bool _rememberGameSettings)
{
setValue(_rememberGameSettings, "remembergamesettings", "game");
}
void GameSettings::setLocalGameRememberSettings(bool value)
{
setValue(value, "remembersettings", "localgameoptions");
}
void GameSettings::setLocalGameMaxPlayers(int value)
{
setValue(value, "maxplayers", "localgameoptions");
}
void GameSettings::setLocalGameStartingLifeTotal(int value)
{
setValue(value, "startinglifetotal", "localgameoptions");
}

View file

@ -0,0 +1,55 @@
#ifndef GAME_SETTINGS_H
#define GAME_SETTINGS_H
#include "settings_manager.h"
#include <libcockatrice/interfaces/interface_game_settings_provider.h>
class GameSettings : public SettingsManager, public IGameSettingsProvider
{
Q_OBJECT
friend class SettingsCache;
public:
[[nodiscard]] QString getGameDescription() const override;
[[nodiscard]] int getMaxPlayers() const override;
[[nodiscard]] QString getGameTypes() const override;
[[nodiscard]] bool getOnlyBuddies() const override;
[[nodiscard]] bool getOnlyRegistered() const override;
[[nodiscard]] bool getSpectatorsAllowed() const override;
[[nodiscard]] bool getSpectatorsNeedPassword() const override;
[[nodiscard]] bool getSpectatorsCanTalk() const override;
[[nodiscard]] bool getSpectatorsCanSeeEverything() const override;
[[nodiscard]] bool getCreateGameAsSpectator() const override;
[[nodiscard]] int getDefaultStartingLifeTotal() const override;
[[nodiscard]] bool getShareDecklistsOnLoad() const override;
[[nodiscard]] bool getRememberGameSettings() const override;
[[nodiscard]] bool getLocalGameRememberSettings() const override;
[[nodiscard]] int getLocalGameMaxPlayers() const override;
[[nodiscard]] int getLocalGameStartingLifeTotal() const override;
void setGameDescription(const QString &_gameDescription);
void setMaxPlayers(int _maxPlayers);
void setGameTypes(const QString &_gameTypes);
void setOnlyBuddies(bool _onlyBuddies);
void setOnlyRegistered(bool _onlyRegistered);
void setSpectatorsAllowed(bool _spectatorsAllowed);
void setSpectatorsNeedPassword(bool _spectatorsNeedPassword);
void setSpectatorsCanTalk(bool _spectatorsCanTalk);
void setSpectatorsCanSeeEverything(bool _spectatorsCanSeeEverything);
void setCreateGameAsSpectator(bool _createGameAsSpectator);
void setDefaultStartingLifeTotal(int _defaultStartingLifeTotal);
void setShareDecklistsOnLoad(bool _shareDecklistsOnLoad);
void setRememberGameSettings(bool _rememberGameSettings);
void setLocalGameRememberSettings(bool value);
void setLocalGameMaxPlayers(int value);
void setLocalGameStartingLifeTotal(int value);
public:
explicit GameSettings(const QString &settingPath, QObject *parent = nullptr);
private:
GameSettings(const GameSettings & /*other*/);
};
#endif // GAME_SETTINGS_H

View file

@ -0,0 +1,317 @@
#include "interface_settings.h"
InterfaceSettings::InterfaceSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "interface.ini", "interface", QString(), parent)
{
}
bool InterfaceSettings::getUseTearOffMenus() const
{
return getValue("usetearoffmenus", QString(), QString(), true).toBool();
}
int InterfaceSettings::getCardViewInitialRowsMax() const
{
return getValue("cardViewInitialRowsMax", QString(), QString(), 14).toInt();
}
int InterfaceSettings::getCardViewExpandedRowsMax() const
{
return getValue("cardViewExpandedRowsMax", QString(), QString(), 20).toInt();
}
bool InterfaceSettings::getCloseEmptyCardView() const
{
return getValue("closeEmptyCardView", QString(), QString(), true).toBool();
}
bool InterfaceSettings::getFocusCardViewSearchBar() const
{
return getValue("focusCardViewSearchBar", QString(), QString(), true).toBool();
}
bool InterfaceSettings::getKeepGameChatFocus() const
{
return getValue("keepGameChatFocus", QString(), QString(), false).toBool();
}
bool InterfaceSettings::getNotificationsEnabled() const
{
return getValue("notificationsenabled", QString(), QString(), true).toBool();
}
bool InterfaceSettings::getSpectatorNotificationsEnabled() const
{
return getValue("specnotificationsenabled", QString(), QString(), false).toBool();
}
bool InterfaceSettings::getBuddyConnectNotificationsEnabled() const
{
return getValue("buddyconnectnotificationsenabled", QString(), QString(), true).toBool();
}
bool InterfaceSettings::getDoubleClickToPlay() const
{
return getValue("doubleclicktoplay", QString(), QString(), true).toBool();
}
bool InterfaceSettings::getClickPlaysAllSelected() const
{
return getValue("clickPlaysAllSelected", QString(), QString(), true).toBool();
}
bool InterfaceSettings::getPlayToStack() const
{
return getValue("playtostack", QString(), QString(), true).toBool();
}
bool InterfaceSettings::getDoNotDeleteArrowsInSubPhases() const
{
return getValue("doNotDeleteArrowsInSubPhases", QString(), QString(), true).toBool();
}
int InterfaceSettings::getStartingHandSize() const
{
return getValue("startinghandsize", QString(), QString(), 7).toInt();
}
bool InterfaceSettings::getAnnotateTokens() const
{
return getValue("annotatetokens", QString(), QString(), false).toBool();
}
bool InterfaceSettings::getShowDragSelectionCount() const
{
return getValue("showlassoselectioncount", QString(), QString(), true).toBool();
}
bool InterfaceSettings::getShowTotalSelectionCount() const
{
return getValue("showpersistentselectioncount", QString(), QString(), true).toBool();
}
int InterfaceSettings::getTallyType() const
{
return getValue("tallyType", QString(), QString(), 0).toInt();
}
bool InterfaceSettings::getHorizontalHand() const
{
return getValue("horizontal", "hand", QString(), true).toBool();
}
bool InterfaceSettings::getInvertVerticalCoordinate() const
{
return getValue("invert_vertical", "table", QString(), false).toBool();
}
int InterfaceSettings::getMinPlayersForMultiColumnLayout() const
{
return getValue("min_players_multicolumn", QString(), QString(), 4).toInt();
}
bool InterfaceSettings::getOpenDeckInNewTab() const
{
return getValue("openDeckInNewTab", "editor", QString(), false).toBool();
}
int InterfaceSettings::getRewindBufferingMs() const
{
return getValue("rewindBufferingMs", "replay", QString(), 200).toInt();
}
qreal InterfaceSettings::getFastForwardSpeed() const
{
return getValue("fastForwardSpeed", "replay", QString(), 10).toReal();
}
bool InterfaceSettings::getStyleUserList() const
{
return getValue("styleUserList", "appearance", QString(), true).toBool();
}
bool InterfaceSettings::getLeftJustified() const
{
return getValue("leftjustified", QString(), QString(), false).toBool();
}
int InterfaceSettings::getZoneViewGroupByIndex() const
{
return getValue("groupby", "zoneview", QString(), 1).toInt();
}
int InterfaceSettings::getZoneViewSortByIndex() const
{
return getValue("sortby", "zoneview", QString(), 1).toInt();
}
bool InterfaceSettings::getZoneViewPileView() const
{
return getValue("pileview", "zoneview", QString(), true).toBool();
}
QString InterfaceSettings::getKnownMissingFeatures()
{
return getValue("knownmissingfeatures", QString(), QString(), "").toString();
}
void InterfaceSettings::setUseTearOffMenus(bool _useTearOffMenus)
{
setValue(_useTearOffMenus, "usetearoffmenus");
emit useTearOffMenusChanged(_useTearOffMenus);
}
void InterfaceSettings::setCardViewInitialRowsMax(int _cardViewInitialRowsMax)
{
setValue(_cardViewInitialRowsMax, "cardViewInitialRowsMax");
}
void InterfaceSettings::setCardViewExpandedRowsMax(int value)
{
setValue(value, "cardViewExpandedRowsMax");
}
void InterfaceSettings::setCloseEmptyCardView(bool value)
{
setValue(value, "closeEmptyCardView");
}
void InterfaceSettings::setFocusCardViewSearchBar(bool value)
{
setValue(value, "focusCardViewSearchBar");
}
void InterfaceSettings::setKeepGameChatFocus(bool value)
{
setValue(value, "keepGameChatFocus");
emit keepGameChatFocusChanged(value);
}
void InterfaceSettings::setNotificationsEnabled(bool _notificationsEnabled)
{
setValue(_notificationsEnabled, "notificationsenabled");
}
void InterfaceSettings::setSpectatorNotificationsEnabled(bool _spectatorNotificationsEnabled)
{
setValue(_spectatorNotificationsEnabled, "specnotificationsenabled");
}
void InterfaceSettings::setBuddyConnectNotificationsEnabled(bool _buddyConnectNotificationsEnabled)
{
setValue(_buddyConnectNotificationsEnabled, "buddyconnectnotificationsenabled");
}
void InterfaceSettings::setDoubleClickToPlay(bool _doubleClickToPlay)
{
setValue(_doubleClickToPlay, "doubleclicktoplay");
}
void InterfaceSettings::setClickPlaysAllSelected(bool _clickPlaysAllSelected)
{
setValue(_clickPlaysAllSelected, "clickPlaysAllSelected");
}
void InterfaceSettings::setPlayToStack(bool _playToStack)
{
setValue(_playToStack, "playtostack");
}
void InterfaceSettings::setDoNotDeleteArrowsInSubPhases(bool _doNotDeleteArrowsInSubPhases)
{
setValue(_doNotDeleteArrowsInSubPhases, "doNotDeleteArrowsInSubPhases");
}
void InterfaceSettings::setStartingHandSize(int _startingHandSize)
{
setValue(_startingHandSize, "startinghandsize");
}
void InterfaceSettings::setAnnotateTokens(bool _annotateTokens)
{
setValue(_annotateTokens, "annotatetokens");
}
void InterfaceSettings::setShowDragSelectionCount(bool _showDragSelectionCount)
{
setValue(_showDragSelectionCount, "showlassoselectioncount");
}
void InterfaceSettings::setShowTotalSelectionCount(bool _showTotalSelectionCount)
{
setValue(_showTotalSelectionCount, "showpersistentselectioncount");
}
void InterfaceSettings::setTallyType(int value)
{
if (getTallyType() == value) {
return;
}
setValue(value, "tallyType");
emit tallyTypeChanged(value);
}
void InterfaceSettings::setHorizontalHand(bool _horizontalHand)
{
setValue(_horizontalHand, "horizontal", "hand");
emit horizontalHandChanged();
}
void InterfaceSettings::setInvertVerticalCoordinate(bool _invertVerticalCoordinate)
{
setValue(_invertVerticalCoordinate, "invert_vertical", "table");
emit invertVerticalCoordinateChanged();
}
void InterfaceSettings::setMinPlayersForMultiColumnLayout(int _minPlayersForMultiColumnLayout)
{
setValue(_minPlayersForMultiColumnLayout, "min_players_multicolumn");
emit minPlayersForMultiColumnLayoutChanged();
}
void InterfaceSettings::setOpenDeckInNewTab(bool _openDeckInNewTab)
{
setValue(_openDeckInNewTab, "openDeckInNewTab", "editor");
}
void InterfaceSettings::setRewindBufferingMs(int _rewindBufferingMs)
{
setValue(_rewindBufferingMs, "rewindBufferingMs", "replay");
}
void InterfaceSettings::setFastForwardSpeed(qreal _value)
{
setValue(_value, "fastForwardSpeed", "replay");
}
void InterfaceSettings::setStyleUserList(bool _styleUserList)
{
setValue(_styleUserList, "styleUserList", "appearance");
emit styleUserListChanged();
}
void InterfaceSettings::setLeftJustified(bool _leftJustified)
{
setValue(_leftJustified, "leftjustified");
emit handJustificationChanged();
}
void InterfaceSettings::setZoneViewGroupByIndex(int _zoneViewGroupByIndex)
{
setValue(_zoneViewGroupByIndex, "groupby", "zoneview");
}
void InterfaceSettings::setZoneViewSortByIndex(int _zoneViewSortByIndex)
{
setValue(_zoneViewSortByIndex, "sortby", "zoneview");
}
void InterfaceSettings::setZoneViewPileView(bool _zoneViewPileView)
{
setValue(_zoneViewPileView, "pileview", "zoneview");
}
void InterfaceSettings::setKnownMissingFeatures(const QString &_knownMissingFeatures)
{
setValue(_knownMissingFeatures, "knownmissingfeatures");
}

View file

@ -0,0 +1,91 @@
#ifndef INTERFACE_SETTINGS_H
#define INTERFACE_SETTINGS_H
#include "settings_manager.h"
#include <libcockatrice/interfaces/interface_interface_settings_provider.h>
class InterfaceSettings : public SettingsManager, public IInterfaceSettingsProvider
{
Q_OBJECT
friend class SettingsCache;
public:
[[nodiscard]] bool getUseTearOffMenus() const override;
[[nodiscard]] int getCardViewInitialRowsMax() const override;
[[nodiscard]] int getCardViewExpandedRowsMax() const override;
[[nodiscard]] bool getCloseEmptyCardView() const override;
[[nodiscard]] bool getFocusCardViewSearchBar() const override;
[[nodiscard]] bool getKeepGameChatFocus() const override;
[[nodiscard]] bool getNotificationsEnabled() const override;
[[nodiscard]] bool getSpectatorNotificationsEnabled() const override;
[[nodiscard]] bool getBuddyConnectNotificationsEnabled() const override;
[[nodiscard]] bool getDoubleClickToPlay() const override;
[[nodiscard]] bool getClickPlaysAllSelected() const override;
[[nodiscard]] bool getPlayToStack() const override;
[[nodiscard]] bool getDoNotDeleteArrowsInSubPhases() const override;
[[nodiscard]] int getStartingHandSize() const override;
[[nodiscard]] bool getAnnotateTokens() const override;
[[nodiscard]] bool getShowDragSelectionCount() const override;
[[nodiscard]] bool getShowTotalSelectionCount() const override;
[[nodiscard]] int getTallyType() const override;
[[nodiscard]] bool getHorizontalHand() const override;
[[nodiscard]] bool getInvertVerticalCoordinate() const override;
[[nodiscard]] int getMinPlayersForMultiColumnLayout() const override;
[[nodiscard]] bool getOpenDeckInNewTab() const override;
[[nodiscard]] int getRewindBufferingMs() const override;
[[nodiscard]] qreal getFastForwardSpeed() const override;
[[nodiscard]] bool getStyleUserList() const override;
[[nodiscard]] bool getLeftJustified() const override;
[[nodiscard]] int getZoneViewGroupByIndex() const override;
[[nodiscard]] int getZoneViewSortByIndex() const override;
[[nodiscard]] bool getZoneViewPileView() const override;
[[nodiscard]] QString getKnownMissingFeatures() override;
void setUseTearOffMenus(bool _useTearOffMenus);
void setCardViewInitialRowsMax(int _cardViewInitialRowsMax);
void setCardViewExpandedRowsMax(int value);
void setCloseEmptyCardView(bool value);
void setFocusCardViewSearchBar(bool value);
void setKeepGameChatFocus(bool value);
void setNotificationsEnabled(bool _notificationsEnabled);
void setSpectatorNotificationsEnabled(bool _spectatorNotificationsEnabled);
void setBuddyConnectNotificationsEnabled(bool _buddyConnectNotificationsEnabled);
void setDoubleClickToPlay(bool _doubleClickToPlay);
void setClickPlaysAllSelected(bool _clickPlaysAllSelected);
void setPlayToStack(bool _playToStack);
void setDoNotDeleteArrowsInSubPhases(bool _doNotDeleteArrowsInSubPhases);
void setStartingHandSize(int _startingHandSize);
void setAnnotateTokens(bool _annotateTokens);
void setShowDragSelectionCount(bool _showDragSelectionCount);
void setShowTotalSelectionCount(bool _showTotalSelectionCount);
void setTallyType(int value);
void setHorizontalHand(bool _horizontalHand);
void setInvertVerticalCoordinate(bool _invertVerticalCoordinate);
void setMinPlayersForMultiColumnLayout(int _minPlayersForMultiColumnLayout);
void setOpenDeckInNewTab(bool _openDeckInNewTab);
void setRewindBufferingMs(int _rewindBufferingMs);
void setFastForwardSpeed(qreal _value);
void setStyleUserList(bool _styleUserList);
void setLeftJustified(bool _leftJustified);
void setZoneViewGroupByIndex(int _zoneViewGroupByIndex);
void setZoneViewSortByIndex(int _zoneViewSortByIndex);
void setZoneViewPileView(bool _zoneViewPileView);
void setKnownMissingFeatures(const QString &_knownMissingFeatures);
signals:
void useTearOffMenusChanged(bool state);
void keepGameChatFocusChanged(bool value);
void horizontalHandChanged();
void invertVerticalCoordinateChanged();
void minPlayersForMultiColumnLayoutChanged();
void styleUserListChanged();
void handJustificationChanged();
void tallyTypeChanged(int type);
private:
explicit InterfaceSettings(const QString &settingPath, QObject *parent = nullptr);
InterfaceSettings(const InterfaceSettings & /*other*/);
};
#endif // INTERFACE_SETTINGS_H

View file

@ -0,0 +1,120 @@
#include "paths_settings.h"
#include <QDir>
#include <QFile>
PathsSettings::PathsSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "paths.ini", "paths", QString(), parent)
{
}
QString PathsSettings::getDeckPath() const
{
return getValue("decks").toString();
}
QString PathsSettings::getFiltersPath() const
{
return getValue("filters").toString();
}
QString PathsSettings::getReplaysPath() const
{
return getValue("replays").toString();
}
QString PathsSettings::getPicsPath() const
{
return getValue("pics").toString();
}
QString PathsSettings::getCustomPicsPath() const
{
return getValue("custompics").toString();
}
QString PathsSettings::getThemesPath() const
{
return getValue("themes").toString();
}
QString PathsSettings::getCardDatabasePath() const
{
return getValue("carddatabase").toString();
}
QString PathsSettings::getCustomCardDatabasePath() const
{
return getValue("customsets").toString();
}
QString PathsSettings::getTokenDatabasePath() const
{
return getValue("tokendatabase").toString();
}
QString PathsSettings::getSpoilerCardDatabasePath() const
{
return getValue("spoilerdatabase").toString();
}
QString PathsSettings::getRedirectCachePath() const
{
return getValue("redirects").toString();
}
void PathsSettings::setDeckPath(const QString &_deckPath)
{
setValue(_deckPath, "decks");
}
void PathsSettings::setFiltersPath(const QString &_filtersPath)
{
setValue(_filtersPath, "filters");
}
void PathsSettings::setReplaysPath(const QString &_replaysPath)
{
setValue(_replaysPath, "replays");
}
void PathsSettings::setPicsPath(const QString &_picsPath)
{
setValue(_picsPath, "pics");
emit picsPathChanged();
}
void PathsSettings::setCustomPicsPath(const QString &_customPicsPath)
{
setValue(_customPicsPath, "custompics");
}
void PathsSettings::setThemesPath(const QString &_themesPath)
{
setValue(_themesPath, "themes");
emit themeChanged();
}
void PathsSettings::setCardDatabasePath(const QString &_cardDatabasePath)
{
setValue(_cardDatabasePath, "carddatabase");
emit cardDatabasePathChanged();
}
void PathsSettings::setCustomCardDatabasePath(const QString &_customCardDatabasePath)
{
setValue(_customCardDatabasePath, "customsets");
emit cardDatabasePathChanged();
}
void PathsSettings::setTokenDatabasePath(const QString &_tokenDatabasePath)
{
setValue(_tokenDatabasePath, "tokendatabase");
emit cardDatabasePathChanged();
}
void PathsSettings::setSpoilerDatabasePath(const QString &_spoilerDatabasePath)
{
setValue(_spoilerDatabasePath, "spoilerdatabase");
emit cardDatabasePathChanged();
}

View file

@ -0,0 +1,47 @@
#ifndef PATHS_SETTINGS_H
#define PATHS_SETTINGS_H
#include "settings_manager.h"
#include <libcockatrice/interfaces/interface_paths_settings_provider.h>
class PathsSettings : public SettingsManager, public IPathsSettingsProvider
{
Q_OBJECT
friend class SettingsCache;
public:
[[nodiscard]] QString getDeckPath() const override;
[[nodiscard]] QString getFiltersPath() const override;
[[nodiscard]] QString getReplaysPath() const override;
[[nodiscard]] QString getPicsPath() const override;
[[nodiscard]] QString getCustomPicsPath() const override;
[[nodiscard]] QString getThemesPath() const override;
[[nodiscard]] QString getCardDatabasePath() const override;
[[nodiscard]] QString getCustomCardDatabasePath() const override;
[[nodiscard]] QString getTokenDatabasePath() const override;
[[nodiscard]] QString getSpoilerCardDatabasePath() const override;
[[nodiscard]] QString getRedirectCachePath() const override;
void setDeckPath(const QString &_deckPath);
void setFiltersPath(const QString &_filtersPath);
void setReplaysPath(const QString &_replaysPath);
void setPicsPath(const QString &_picsPath);
void setCustomPicsPath(const QString &_customPicsPath);
void setThemesPath(const QString &_themesPath);
void setCardDatabasePath(const QString &_cardDatabasePath);
void setCustomCardDatabasePath(const QString &_customCardDatabasePath);
void setTokenDatabasePath(const QString &_tokenDatabasePath);
void setSpoilerDatabasePath(const QString &_spoilerDatabasePath);
signals:
void cardDatabasePathChanged();
void picsPathChanged();
void themeChanged();
private:
explicit PathsSettings(const QString &settingPath, QObject *parent = nullptr);
PathsSettings(const PathsSettings & /*other*/);
};
#endif // PATHS_SETTINGS_H

View file

@ -0,0 +1,173 @@
#include "personal_settings.h"
PersonalSettings::PersonalSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "personal.ini", "personal", QString(), parent)
{
}
QString PersonalSettings::getLang() const
{
return getValue("lang", QString(), QString(), QString()).toString();
}
QString PersonalSettings::getClientID()
{
return getValue("clientid", QString(), QString(), "notset").toString();
}
QString PersonalSettings::getClientVersion()
{
return getValue("clientversion", QString(), QString(), "notset").toString();
}
int PersonalSettings::getKeepAlive() const
{
return getValue("keepalive", QString(), QString(), 3).toInt();
}
int PersonalSettings::getTimeOut() const
{
return getValue("timeout", QString(), QString(), 5).toInt();
}
bool PersonalSettings::getPicDownload() const
{
return getValue("picturedownload", QString(), QString(), true).toBool();
}
bool PersonalSettings::getShowStatusBar() const
{
return getValue("showStatusBar", QString(), QString(), false).toBool();
}
int PersonalSettings::getMaxFontSize() const
{
return getValue("maxfontsize", "game", QString(), 12).toInt();
}
QString PersonalSettings::getHighlightWords() const
{
return getValue("highlightWords", QString(), QString(), "").toString();
}
QString PersonalSettings::getHomeTabBackgroundSource() const
{
return getValue("background", "home", QString(), "themed").toString();
}
int PersonalSettings::getHomeTabBackgroundShuffleFrequency() const
{
return getValue("shuffleTimer", "home/background", QString(), 0).toInt();
}
bool PersonalSettings::getHomeTabDisplayCardName() const
{
return getValue("displayCardName", "home/background", QString(), true).toBool();
}
bool PersonalSettings::getShowTipsOnStartup() const
{
return getValue("showTips", "tipOfDay", QString(), true).toBool();
}
QList<int> PersonalSettings::getSeenTips() const
{
QList<int> tips;
auto tipValues = getValue("seenTips", "tipOfDay", QString()).toList();
for (const auto &tipNumber : tipValues) {
tips.append(tipNumber.toInt());
}
return tips;
}
bool PersonalSettings::getDownloadSpoilersStatus() const
{
return getValue("downloadspoilers", QString(), QString(), false).toBool();
}
void PersonalSettings::setLang(const QString &_lang)
{
setValue(_lang, "lang");
emit langChanged();
}
void PersonalSettings::setClientID(const QString &_clientID)
{
setValue(_clientID, "clientid");
}
void PersonalSettings::setClientVersion(const QString &_clientVersion)
{
setValue(_clientVersion, "clientversion");
}
void PersonalSettings::setPicDownload(bool _picDownload)
{
setValue(_picDownload, "picturedownload");
emit picDownloadChanged();
}
void PersonalSettings::setShowStatusBar(bool value)
{
setValue(value, "showStatusBar");
emit showStatusBarChanged(value);
}
void PersonalSettings::setMaxFontSize(int _max)
{
setValue(_max, "maxfontsize", "game");
}
QString PersonalSettings::getThemeName() const
{
return getValue("themeName", QString(), QString()).toString();
}
void PersonalSettings::setThemeName(const QString &_themeName)
{
setValue(_themeName, "themeName");
emit themeNameChanged();
}
void PersonalSettings::setHighlightWords(const QString &_highlightWords)
{
setValue(_highlightWords, "highlightWords");
}
void PersonalSettings::setHomeTabBackgroundSource(const QString &_backgroundSource)
{
setValue(_backgroundSource, "background", "home");
emit homeTabBackgroundSourceChanged();
}
void PersonalSettings::setHomeTabBackgroundShuffleFrequency(int _frequency)
{
setValue(_frequency, "shuffleTimer", "home/background");
emit homeTabBackgroundShuffleFrequencyChanged();
}
void PersonalSettings::setHomeTabDisplayCardName(bool _displayCardName)
{
setValue(_displayCardName, "displayCardName", "home/background");
emit homeTabDisplayCardNameChanged();
}
void PersonalSettings::setShowTipsOnStartup(bool _showTipsOnStartup)
{
setValue(_showTipsOnStartup, "showTips", "tipOfDay");
}
void PersonalSettings::setSeenTips(const QList<int> &_seenTips)
{
QList<QVariant> storedTipList;
for (auto tipNumber : _seenTips) {
storedTipList.append(tipNumber);
}
setValue(QVariant::fromValue(storedTipList), "seenTips", "tipOfDay");
}
void PersonalSettings::setDownloadSpoilerStatus(bool _spoilerStatus)
{
setValue(_spoilerStatus, "downloadspoilers");
emit downloadSpoilerStatusChanged();
}

View file

@ -0,0 +1,65 @@
#ifndef PERSONAL_SETTINGS_H
#define PERSONAL_SETTINGS_H
#include "settings_manager.h"
#include <QDate>
#include <QList>
#include <libcockatrice/interfaces/interface_personal_settings_provider.h>
class PersonalSettings : public SettingsManager, public IPersonalSettingsProvider
{
Q_OBJECT
friend class SettingsCache;
public:
[[nodiscard]] QString getLang() const override;
[[nodiscard]] QString getClientID() override;
[[nodiscard]] QString getClientVersion() override;
[[nodiscard]] int getKeepAlive() const override;
[[nodiscard]] int getTimeOut() const override;
[[nodiscard]] bool getPicDownload() const override;
[[nodiscard]] bool getShowStatusBar() const override;
[[nodiscard]] int getMaxFontSize() const override;
[[nodiscard]] QString getHighlightWords() const override;
[[nodiscard]] QString getHomeTabBackgroundSource() const override;
[[nodiscard]] int getHomeTabBackgroundShuffleFrequency() const override;
[[nodiscard]] QString getThemeName() const;
void setThemeName(const QString &_themeName);
[[nodiscard]] bool getHomeTabDisplayCardName() const override;
[[nodiscard]] bool getShowTipsOnStartup() const override;
[[nodiscard]] QList<int> getSeenTips() const override;
[[nodiscard]] bool getDownloadSpoilersStatus() const override;
void setLang(const QString &_lang);
void setClientID(const QString &_clientID);
void setClientVersion(const QString &_clientVersion);
void setPicDownload(bool _picDownload);
void setShowStatusBar(bool value);
void setMaxFontSize(int _max);
void setHighlightWords(const QString &_highlightWords);
void setHomeTabBackgroundSource(const QString &_backgroundSource);
void setHomeTabBackgroundShuffleFrequency(int _frequency);
void setHomeTabDisplayCardName(bool _displayCardName);
void setShowTipsOnStartup(bool _showTipsOnStartup);
void setSeenTips(const QList<int> &_seenTips);
void setDownloadSpoilerStatus(bool _spoilerStatus);
signals:
void langChanged();
void themeNameChanged();
void picDownloadChanged();
void showStatusBarChanged(bool state);
void homeTabBackgroundSourceChanged();
void homeTabBackgroundShuffleFrequencyChanged();
void homeTabDisplayCardNameChanged();
void downloadSpoilerStatusChanged();
public:
explicit PersonalSettings(const QString &settingPath, QObject *parent = nullptr);
private:
PersonalSettings(const PersonalSettings & /*other*/);
};
#endif // PERSONAL_SETTINGS_H

View file

@ -138,21 +138,55 @@ QVariant SettingsManager::getValue(const QString &name, const QString &group, co
{
auto settings = getSettings();
if (!group.isEmpty()) {
settings.beginGroup(group);
QString effectiveGroup = group.isEmpty() ? defaultGroup : group;
QString effectiveSubGroup = subGroup.isEmpty() ? defaultSubGroup : subGroup;
if (!effectiveGroup.isEmpty()) {
settings.beginGroup(effectiveGroup);
}
if (!subGroup.isEmpty()) {
settings.beginGroup(subGroup);
if (!effectiveSubGroup.isEmpty()) {
settings.beginGroup(effectiveSubGroup);
}
QVariant value = settings.value(name);
if (!subGroup.isEmpty()) {
if (!effectiveSubGroup.isEmpty()) {
settings.endGroup();
}
if (!group.isEmpty()) {
if (!effectiveGroup.isEmpty()) {
settings.endGroup();
}
return value;
}
QVariant SettingsManager::getValue(const QString &name,
const QString &group,
const QString &subGroup,
const QVariant &defaultValue) const
{
auto settings = getSettings();
QString effectiveGroup = group.isEmpty() ? defaultGroup : group;
QString effectiveSubGroup = subGroup.isEmpty() ? defaultSubGroup : subGroup;
if (!effectiveGroup.isEmpty()) {
settings.beginGroup(effectiveGroup);
}
if (!effectiveSubGroup.isEmpty()) {
settings.beginGroup(effectiveSubGroup);
}
QVariant value = settings.value(name, defaultValue);
if (!effectiveSubGroup.isEmpty()) {
settings.endGroup();
}
if (!effectiveGroup.isEmpty()) {
settings.endGroup();
}

View file

@ -23,6 +23,8 @@ public:
QVariant getValue(const QString &name) const;
QVariant getValue(const QString &name, const QString &group, const QString &subGroup = QString()) const;
QVariant
getValue(const QString &name, const QString &group, const QString &subGroup, const QVariant &defaultValue) const;
void batchWrite(std::function<void(QSettings &)> batchWriteFunction);
void sync();

View file

@ -0,0 +1,519 @@
#include "settings_migration.h"
#include <QFile>
#include <QMap>
#include <QSettings>
#include <QStringList>
static const QString MIGRATION_SENTINEL_KEY = QStringLiteral("migration/perfile_complete");
static void migrateTabsSettings(const QString &settingsPath, QSettings &globalIni)
{
if (!globalIni.contains("tabs/visualDeckStorage") && !globalIni.contains("tabs/server") &&
!globalIni.contains("tabs/account") && !globalIni.contains("tabs/deckStorage") &&
!globalIni.contains("tabs/replays") && !globalIni.contains("tabs/admin") && !globalIni.contains("tabs/log")) {
return;
}
QSettings tabsIni(settingsPath + "tabs.ini", QSettings::IniFormat);
tabsIni.setValue("tabs/visualDeckStorage", globalIni.value("tabs/visualDeckStorage", true));
tabsIni.setValue("tabs/server", globalIni.value("tabs/server", true));
tabsIni.setValue("tabs/account", globalIni.value("tabs/account", true));
tabsIni.setValue("tabs/deckStorage", globalIni.value("tabs/deckStorage", true));
tabsIni.setValue("tabs/replays", globalIni.value("tabs/replays", true));
tabsIni.setValue("tabs/admin", globalIni.value("tabs/admin", true));
tabsIni.setValue("tabs/log", globalIni.value("tabs/log", true));
}
static void migrateSoundSettings(const QString &settingsPath, QSettings &globalIni)
{
if (!globalIni.contains("sound/enabled") && !globalIni.contains("sound/theme") &&
!globalIni.contains("sound/mastervolume")) {
return;
}
QSettings soundIni(settingsPath + "sound.ini", QSettings::IniFormat);
soundIni.setValue("sound/enabled", globalIni.value("sound/enabled", false));
soundIni.setValue("sound/theme", globalIni.value("sound/theme"));
soundIni.setValue("sound/mastervolume", globalIni.value("sound/mastervolume", 100));
}
static void migrateGameSettings(const QString &settingsPath, QSettings &globalIni)
{
bool hasGameKeys = false;
globalIni.beginGroup("game");
if (!globalIni.childKeys().isEmpty()) {
hasGameKeys = true;
}
QStringList gameKeys = globalIni.childKeys();
globalIni.endGroup();
globalIni.beginGroup("localgameoptions");
if (!globalIni.childKeys().isEmpty()) {
hasGameKeys = true;
}
QStringList localGameKeys = globalIni.childKeys();
globalIni.endGroup();
if (!hasGameKeys) {
return;
}
QSettings gameIni(settingsPath + "game.ini", QSettings::IniFormat);
for (const auto &key : gameKeys) {
if (key == "maxfontsize") {
continue;
}
gameIni.setValue("game/" + key, globalIni.value("game/" + key));
}
for (const auto &key : localGameKeys) {
gameIni.setValue("localgameoptions/" + key, globalIni.value("localgameoptions/" + key));
}
}
static void migrateChatSettings(const QString &settingsPath, QSettings &globalIni)
{
globalIni.beginGroup("chat");
QStringList chatKeys = globalIni.childKeys();
globalIni.endGroup();
if (chatKeys.isEmpty()) {
return;
}
QSettings chatIni(settingsPath + "chat.ini", QSettings::IniFormat);
for (const auto &key : chatKeys) {
chatIni.setValue("chat/" + key, globalIni.value("chat/" + key));
}
}
static void migrateCacheStorageSettings(const QString &settingsPath, QSettings &globalIni)
{
const QStringList cacheKeys = {"personal/pixmapCacheSize", "personal/networkCacheSize", "personal/redirectCacheTtl",
"personal/cardPictureLoaderCacheMethod",
"personal/localCardImageStorageNamingScheme"};
bool hasAny = false;
for (const auto &key : cacheKeys) {
if (globalIni.contains(key)) {
hasAny = true;
break;
}
}
if (!hasAny) {
return;
}
QSettings cacheStorageIni(settingsPath + "cache_storage.ini", QSettings::IniFormat);
for (const auto &key : cacheKeys) {
if (globalIni.contains(key)) {
cacheStorageIni.setValue(key, globalIni.value(key));
}
}
}
static void migrateUpdatesSettings(const QString &settingsPath, QSettings &globalIni)
{
const QMap<QString, QString> updateKeyMap = {
{"personal/startupUpdateCheck", "updates/startupUpdateCheck"},
{"personal/startupCardUpdateCheckPromptForUpdate", "updates/startupCardUpdateCheckPromptForUpdate"},
{"personal/startupCardUpdateCheckAlwaysUpdate", "updates/startupCardUpdateCheckAlwaysUpdate"},
{"personal/cardUpdateCheckInterval", "updates/cardUpdateCheckInterval"},
{"personal/lastCardUpdateCheck", "updates/lastCardUpdateCheck"},
{"personal/alwaysEnableNewSets", "updates/alwaysEnableNewSets"},
{"personal/updatenotification", "updates/updatenotification"},
{"personal/newversionnotification", "updates/newversionnotification"},
{"personal/updatereleasechannel", "updates/updatereleasechannel"},
};
bool hasAny = false;
for (auto it = updateKeyMap.constBegin(); it != updateKeyMap.constEnd(); ++it) {
if (globalIni.contains(it.key())) {
hasAny = true;
break;
}
}
if (!hasAny) {
return;
}
QSettings updatesIni(settingsPath + "updates.ini", QSettings::IniFormat);
for (auto it = updateKeyMap.constBegin(); it != updateKeyMap.constEnd(); ++it) {
if (globalIni.contains(it.key())) {
updatesIni.setValue(it.value(), globalIni.value(it.key()));
}
}
}
static void migratePersonalSettings(const QString &settingsPath, QSettings &globalIni)
{
const QStringList personalRootKeys = {"personal/lang", "personal/highlightWords"};
const QMap<QString, QString> personalKeyMap = {
{"theme/name", "personal/themeName"},
{"personal/clientid", "personal/clientid"},
{"personal/clientversion", "personal/clientversion"},
{"personal/keepalive", "personal/keepalive"},
{"personal/timeout", "personal/timeout"},
{"personal/picturedownload", "personal/picturedownload"},
{"personal/showStatusBar", "personal/showStatusBar"},
{"game/maxfontsize", "game/maxfontsize"},
{"personal/downloadspoilers", "personal/downloadspoilers"},
};
const QStringList homeKeys = {"home/background", "home/background/shuffleTimer", "home/background/displayCardName"};
const QStringList tipKeys = {"tipOfDay/showTips", "tipOfDay/seenTips"};
bool hasAny = false;
for (const auto &key : personalRootKeys) {
if (globalIni.contains(key)) {
hasAny = true;
}
}
for (auto it = personalKeyMap.constBegin(); it != personalKeyMap.constEnd(); ++it) {
if (globalIni.contains(it.key())) {
hasAny = true;
}
}
for (const auto &key : homeKeys) {
if (globalIni.contains(key)) {
hasAny = true;
}
}
for (const auto &key : tipKeys) {
if (globalIni.contains(key)) {
hasAny = true;
}
}
if (!hasAny) {
return;
}
QSettings personalIni(settingsPath + "personal.ini", QSettings::IniFormat);
for (const auto &key : personalRootKeys) {
if (globalIni.contains(key)) {
personalIni.setValue(key, globalIni.value(key));
}
}
for (auto it = personalKeyMap.constBegin(); it != personalKeyMap.constEnd(); ++it) {
if (globalIni.contains(it.key())) {
personalIni.setValue(it.value(), globalIni.value(it.key()));
}
}
for (const auto &key : homeKeys) {
if (globalIni.contains(key)) {
personalIni.setValue(key, globalIni.value(key));
}
}
for (const auto &key : tipKeys) {
if (globalIni.contains(key)) {
personalIni.setValue(key, globalIni.value(key));
}
}
}
static void migrateCardsDisplaySettings(const QString &settingsPath, QSettings &globalIni)
{
const QStringList cardsRootKeys = {
"cards/displaycardnames",
"cards/roundcardcorners",
"cards/overrideallcardartwithpersonalpreference",
"cards/bumpsetswithcardsindecktotop",
"cards/printingselectorsortorder",
"cards/printingselectorcardsize",
"cards/includerebalancedcards",
"cards/printingselectornavigationbuttonsvisible",
"cards/tapanimation",
"cards/autorotatesidewayslayoutcards",
"cards/scaleCards",
"cards/verticalCardOverlapPercent",
"cards/cardinfoviewmode",
};
const QStringList cardsInterfaceKeys = {"interface/deckeditorbannercardcomboboxvisible",
"interface/deckeditortagswidgetvisible"};
const QStringList menuKeys = {"menu/showshortcuts", "menu/showgameselectorfiltertoolbar"};
bool hasAny = false;
for (const auto &key : cardsRootKeys) {
if (globalIni.contains(key)) {
hasAny = true;
}
}
for (const auto &key : cardsInterfaceKeys) {
if (globalIni.contains(key)) {
hasAny = true;
}
}
for (const auto &key : menuKeys) {
if (globalIni.contains(key)) {
hasAny = true;
}
}
if (!hasAny) {
return;
}
QSettings cardsIni(settingsPath + "cards_display.ini", QSettings::IniFormat);
for (const auto &key : cardsRootKeys) {
if (globalIni.contains(key)) {
cardsIni.setValue(key, globalIni.value(key));
}
}
for (const auto &key : cardsInterfaceKeys) {
if (globalIni.contains(key)) {
cardsIni.setValue(key, globalIni.value(key));
}
}
for (const auto &key : menuKeys) {
if (globalIni.contains(key)) {
cardsIni.setValue(key, globalIni.value(key));
}
}
}
static void migrateInterfaceSettings(const QString &settingsPath, QSettings &globalIni)
{
const QStringList interfaceRootKeys = {
"interface/usetearoffmenus",
"interface/cardViewInitialRowsMax",
"interface/cardViewExpandedRowsMax",
"interface/closeEmptyCardView",
"interface/focusCardViewSearchBar",
"interface/keepGameChatFocus",
"interface/notificationsenabled",
"interface/specnotificationsenabled",
"interface/buddyconnectnotificationsenabled",
"interface/doubleclicktoplay",
"interface/clickPlaysAllSelected",
"interface/playtostack",
"interface/doNotDeleteArrowsInSubPhases",
"interface/startinghandsize",
"interface/annotatetokens",
"interface/showlassoselectioncount",
"interface/showpersistentselectioncount",
"interface/showsubtypeselectiontally",
"interface/leftjustified",
"interface/min_players_multicolumn",
"interface/knownmissingfeatures",
};
const QStringList interfaceSubKeys = {
"hand/horizontal", "table/invert_vertical", "editor/openDeckInNewTab", "replay/rewindBufferingMs",
"appearance/styleUserList", "zoneview/groupby", "zoneview/sortby", "zoneview/pileview"};
bool hasAny = false;
for (const auto &key : interfaceRootKeys) {
if (globalIni.contains(key)) {
hasAny = true;
}
}
for (const auto &key : interfaceSubKeys) {
if (globalIni.contains(key)) {
hasAny = true;
}
}
if (!hasAny) {
return;
}
QSettings interfaceIni(settingsPath + "interface.ini", QSettings::IniFormat);
for (const auto &key : interfaceRootKeys) {
if (globalIni.contains(key)) {
interfaceIni.setValue(key, globalIni.value(key));
}
}
for (const auto &key : interfaceSubKeys) {
if (globalIni.contains(key)) {
interfaceIni.setValue(key, globalIni.value(key));
}
}
}
static void migratePathsSettings(const QString &settingsPath, QSettings &globalIni)
{
globalIni.beginGroup("paths");
QStringList pathsKeys = globalIni.childKeys();
globalIni.endGroup();
if (pathsKeys.isEmpty()) {
return;
}
QSettings pathsIni(settingsPath + "paths.ini", QSettings::IniFormat);
for (const auto &key : pathsKeys) {
pathsIni.setValue("paths/" + key, globalIni.value("paths/" + key));
}
}
static void migrateVisualDeckStorageSettings(const QString &settingsPath, QSettings &globalIni)
{
const QStringList vdsKeys = {"interface/visualdeckstoragecardsize",
"interface/visualdeckstoragesortingorder",
"interface/visualdeckstorageshowfolders",
"interface/visualdeckstorageshowtagfilter",
"interface/visualdeckstoragedefaulttagslist",
"interface/visualdeckstoragesearchfoldernames",
"interface/visualdeckstorageshowcoloridentity",
"interface/visualdeckstorageshowbannercardcombobox",
"interface/visualdeckstorageshowtagsondeckpreviews",
"interface/visualdeckstoragedrawunusedcoloridentities",
"interface/visualdeckstorageunusedcoloridentitiesopacity",
"interface/visualdeckstoragetooltiptype",
"interface/visualdeckstoragepromptforconversion",
"interface/visualdeckstoragealwaysconvert",
"interface/visualdeckstorageingame",
"interface/visualdeckstorageselectionanimation",
"interface/defaultDeckEditorType",
"interface/visualdatabasedisplayfiltertomostrecentsetsenabled",
"interface/visualdatabasedisplayfiltertomostrecentsetsamount",
"interface/visualdeckeditorsamplehandsize",
"interface/visualdeckeditorcardsize",
"interface/visualdatabasedisplaycardsize",
"interface/edhreccardsize",
"interface/archidektpreviewsize"};
bool hasAny = false;
for (const auto &key : vdsKeys) {
if (globalIni.contains(key)) {
hasAny = true;
}
}
if (!hasAny) {
return;
}
QSettings vdsIni(settingsPath + "visual_deck_storage.ini", QSettings::IniFormat);
for (const auto &key : vdsKeys) {
if (globalIni.contains(key)) {
vdsIni.setValue(key, globalIni.value(key));
}
}
}
static void migrateLegacySets(const QString &settingsPath)
{
QSettings legacySetting;
legacySetting.beginGroup("sets");
QStringList groups = legacySetting.childGroups();
if (groups.isEmpty()) {
legacySetting.endGroup();
return;
}
QSettings cardDbIni(settingsPath + "cardDatabase.ini", QSettings::IniFormat);
for (const auto &shortName : groups) {
legacySetting.beginGroup(shortName);
cardDbIni.setValue("sets/" + shortName + "/sortkey", legacySetting.value("sortkey"));
cardDbIni.setValue("sets/" + shortName + "/enabled", legacySetting.value("enabled"));
cardDbIni.setValue("sets/" + shortName + "/isknown", legacySetting.value("isknown"));
legacySetting.endGroup();
}
legacySetting.endGroup();
}
static void migrateLegacyServers(const QString &settingsPath)
{
QSettings legacySetting;
legacySetting.beginGroup("server");
QStringList keys = legacySetting.allKeys();
if (keys.isEmpty()) {
legacySetting.endGroup();
return;
}
QSettings serversIni(settingsPath + "servers.ini", QSettings::IniFormat);
serversIni.setValue("server/previoushostlogin", legacySetting.value("previoushostlogin"));
serversIni.setValue("server/previoushosts", legacySetting.value("previoushosts"));
serversIni.setValue("server/auto_connect", legacySetting.value("auto_connect"));
serversIni.setValue("server/fphostname", legacySetting.value("fphostname"));
serversIni.setValue("server/fpport", legacySetting.value("fpport"));
serversIni.setValue("server/fpplayername", legacySetting.value("fpplayername"));
legacySetting.endGroup();
}
static void migrateLegacyMessages(const QString &settingsPath)
{
QSettings legacySetting;
legacySetting.beginGroup("messages");
QStringList keys = legacySetting.allKeys();
if (keys.isEmpty()) {
legacySetting.endGroup();
return;
}
QSettings messageIni(settingsPath + "messages.ini", QSettings::IniFormat);
for (const auto &key : keys) {
if (key == "count") {
messageIni.setValue("messages/count", legacySetting.value("count"));
} else {
messageIni.setValue("messages/" + key, legacySetting.value(key));
}
}
legacySetting.endGroup();
}
static void migrateLegacyGameFilters(const QString &settingsPath)
{
QSettings legacySetting;
legacySetting.beginGroup("filter_games");
QStringList keys = legacySetting.allKeys();
if (keys.isEmpty()) {
legacySetting.endGroup();
return;
}
QSettings filtersIni(settingsPath + "gamefilters.ini", QSettings::IniFormat);
for (const auto &key : keys) {
filtersIni.setValue("filter_games/" + key, legacySetting.value(key));
}
legacySetting.endGroup();
}
bool SettingsMigration::migrateLegacySettings(const QString &settingsPath)
{
QSettings personalIni(settingsPath + "personal.ini", QSettings::IniFormat);
if (personalIni.value("migration/legacy_complete", false).toBool()) {
return false;
}
migrateLegacySets(settingsPath);
migrateLegacyServers(settingsPath);
migrateLegacyMessages(settingsPath);
migrateLegacyGameFilters(settingsPath);
personalIni.setValue("migration/legacy_complete", true);
personalIni.sync();
return true;
}
bool SettingsMigration::migrateSettingsFromGlobalIni(const QString &settingsPath)
{
if (!QFile::exists(settingsPath + "global.ini")) {
return false;
}
QSettings globalIni(settingsPath + "global.ini", QSettings::IniFormat);
if (globalIni.value(MIGRATION_SENTINEL_KEY, false).toBool()) {
// If a user runs an older Cockatrice build that writes to global.ini (non-sentinel keys)
// and then upgrades back, those new keys will be silently ignored. Re-migrate them.
globalIni.sync();
auto allKeys = globalIni.allKeys();
allKeys.removeAll(MIGRATION_SENTINEL_KEY);
if (allKeys.isEmpty()) {
return false;
}
}
migrateTabsSettings(settingsPath, globalIni);
migrateSoundSettings(settingsPath, globalIni);
migrateGameSettings(settingsPath, globalIni);
migrateChatSettings(settingsPath, globalIni);
migrateCacheStorageSettings(settingsPath, globalIni);
migrateUpdatesSettings(settingsPath, globalIni);
migratePersonalSettings(settingsPath, globalIni);
migrateCardsDisplaySettings(settingsPath, globalIni);
migrateInterfaceSettings(settingsPath, globalIni);
migratePathsSettings(settingsPath, globalIni);
migrateVisualDeckStorageSettings(settingsPath, globalIni);
QFile::remove(settingsPath + "global.ini.old");
QFile::rename(settingsPath + "global.ini", settingsPath + "global.ini.old");
QSettings newGlobalIni(settingsPath + "global.ini", QSettings::IniFormat);
newGlobalIni.setValue(MIGRATION_SENTINEL_KEY, true);
newGlobalIni.sync();
return true;
}

View file

@ -0,0 +1,13 @@
#ifndef SETTINGS_MIGRATION_H
#define SETTINGS_MIGRATION_H
#include <QString>
class SettingsMigration
{
public:
static bool migrateSettingsFromGlobalIni(const QString &settingsPath);
static bool migrateLegacySettings(const QString &settingsPath);
};
#endif // SETTINGS_MIGRATION_H

View file

@ -0,0 +1,39 @@
#include "sound_settings.h"
SoundSettings::SoundSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "sound.ini", "sound", QString(), parent)
{
}
bool SoundSettings::getSoundEnabled() const
{
return getValue("enabled", QString(), QString(), false).toBool();
}
QString SoundSettings::getSoundThemeName() const
{
return getValue("theme", QString(), QString()).toString();
}
int SoundSettings::getMasterVolume() const
{
return getValue("mastervolume", QString(), QString(), 100).toInt();
}
void SoundSettings::setSoundEnabled(bool _soundEnabled)
{
setValue(_soundEnabled, "enabled");
emit soundEnabledChanged();
}
void SoundSettings::setSoundThemeName(const QString &_soundThemeName)
{
setValue(_soundThemeName, "theme");
emit soundThemeChanged();
}
void SoundSettings::setMasterVolume(int _masterVolume)
{
setValue(_masterVolume, "mastervolume");
emit masterVolumeChanged(_masterVolume);
}

View file

@ -0,0 +1,34 @@
#ifndef SOUND_SETTINGS_H
#define SOUND_SETTINGS_H
#include "settings_manager.h"
#include <libcockatrice/interfaces/interface_sound_settings_provider.h>
class SoundSettings : public SettingsManager, public ISoundSettingsProvider
{
Q_OBJECT
friend class SettingsCache;
public:
[[nodiscard]] bool getSoundEnabled() const override;
[[nodiscard]] QString getSoundThemeName() const override;
[[nodiscard]] int getMasterVolume() const override;
void setSoundEnabled(bool _soundEnabled);
void setSoundThemeName(const QString &_soundThemeName);
void setMasterVolume(int _masterVolume);
signals:
void soundEnabledChanged();
void soundThemeChanged();
void masterVolumeChanged(int value);
public:
explicit SoundSettings(const QString &settingPath, QObject *parent = nullptr);
private:
SoundSettings(const SoundSettings & /*other*/);
};
#endif // SOUND_SETTINGS_H

View file

@ -0,0 +1,76 @@
#include "tabs_settings.h"
TabsSettings::TabsSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "tabs.ini", "tabs", QString(), parent)
{
}
bool TabsSettings::getTabVisualDeckStorageOpen() const
{
return getValue("visualDeckStorage", QString(), QString(), true).toBool();
}
bool TabsSettings::getTabServerOpen() const
{
return getValue("server", QString(), QString(), true).toBool();
}
bool TabsSettings::getTabAccountOpen() const
{
return getValue("account", QString(), QString(), true).toBool();
}
bool TabsSettings::getTabDeckStorageOpen() const
{
return getValue("deckStorage", QString(), QString(), true).toBool();
}
bool TabsSettings::getTabReplaysOpen() const
{
return getValue("replays", QString(), QString(), true).toBool();
}
bool TabsSettings::getTabAdminOpen() const
{
return getValue("admin", QString(), QString(), true).toBool();
}
bool TabsSettings::getTabLogOpen() const
{
return getValue("log", QString(), QString(), true).toBool();
}
void TabsSettings::setTabVisualDeckStorageOpen(bool value)
{
setValue(value, "visualDeckStorage");
}
void TabsSettings::setTabServerOpen(bool value)
{
setValue(value, "server");
}
void TabsSettings::setTabAccountOpen(bool value)
{
setValue(value, "account");
}
void TabsSettings::setTabDeckStorageOpen(bool value)
{
setValue(value, "deckStorage");
}
void TabsSettings::setTabReplaysOpen(bool value)
{
setValue(value, "replays");
}
void TabsSettings::setTabAdminOpen(bool value)
{
setValue(value, "admin");
}
void TabsSettings::setTabLogOpen(bool value)
{
setValue(value, "log");
}

View file

@ -0,0 +1,37 @@
#ifndef TABS_SETTINGS_H
#define TABS_SETTINGS_H
#include "settings_manager.h"
#include <libcockatrice/interfaces/interface_tabs_settings_provider.h>
class TabsSettings : public SettingsManager, public ITabsSettingsProvider
{
Q_OBJECT
friend class SettingsCache;
public:
[[nodiscard]] bool getTabVisualDeckStorageOpen() const override;
[[nodiscard]] bool getTabServerOpen() const override;
[[nodiscard]] bool getTabAccountOpen() const override;
[[nodiscard]] bool getTabDeckStorageOpen() const override;
[[nodiscard]] bool getTabReplaysOpen() const override;
[[nodiscard]] bool getTabAdminOpen() const override;
[[nodiscard]] bool getTabLogOpen() const override;
void setTabVisualDeckStorageOpen(bool value);
void setTabServerOpen(bool value);
void setTabAccountOpen(bool value);
void setTabDeckStorageOpen(bool value);
void setTabReplaysOpen(bool value);
void setTabAdminOpen(bool value);
void setTabLogOpen(bool value);
public:
explicit TabsSettings(const QString &settingPath, QObject *parent = nullptr);
private:
TabsSettings(const TabsSettings & /*other*/);
};
#endif // TABS_SETTINGS_H

View file

@ -0,0 +1,104 @@
#include "updates_settings.h"
#include <QDateTime>
UpdatesSettings::UpdatesSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "updates.ini", "updates", QString(), parent)
{
}
bool UpdatesSettings::getCheckUpdatesOnStartup() const
{
return getValue("startupUpdateCheck", QString(), QString(), true).toBool();
}
bool UpdatesSettings::getStartupCardUpdateCheckPromptForUpdate()
{
return getValue("startupCardUpdateCheckPromptForUpdate", QString(), QString(), true).toBool();
}
bool UpdatesSettings::getStartupCardUpdateCheckAlwaysUpdate()
{
return getValue("startupCardUpdateCheckAlwaysUpdate", QString(), QString(), false).toBool();
}
int UpdatesSettings::getCardUpdateCheckInterval() const
{
return getValue("cardUpdateCheckInterval", QString(), QString(), 7).toInt();
}
QDate UpdatesSettings::getLastCardUpdateCheck() const
{
return getValue("lastCardUpdateCheck", QString(), QString(), QDateTime::currentDateTime().date()).toDate();
}
bool UpdatesSettings::getCardUpdateCheckRequired() const
{
return getLastCardUpdateCheck().daysTo(QDateTime::currentDateTime().date()) >= getCardUpdateCheckInterval() &&
getLastCardUpdateCheck() != QDateTime::currentDateTime().date();
}
bool UpdatesSettings::getAlwaysEnableNewSets() const
{
return getValue("alwaysEnableNewSets", QString(), QString(), false).toBool();
}
bool UpdatesSettings::getNotifyAboutUpdates() const
{
return getValue("updatenotification", QString(), QString(), true).toBool();
}
bool UpdatesSettings::getNotifyAboutNewVersion() const
{
return getValue("newversionnotification", QString(), QString(), true).toBool();
}
int UpdatesSettings::getUpdateReleaseChannelIndex() const
{
return getValue("updatereleasechannel", QString(), QString(), 0).toInt();
}
void UpdatesSettings::setCheckUpdatesOnStartup(bool value)
{
setValue(value, "startupUpdateCheck");
}
void UpdatesSettings::setStartupCardUpdateCheckPromptForUpdate(bool value)
{
setValue(value, "startupCardUpdateCheckPromptForUpdate");
}
void UpdatesSettings::setStartupCardUpdateCheckAlwaysUpdate(bool value)
{
setValue(value, "startupCardUpdateCheckAlwaysUpdate");
}
void UpdatesSettings::setCardUpdateCheckInterval(int value)
{
setValue(value, "cardUpdateCheckInterval");
}
void UpdatesSettings::setLastCardUpdateCheck(QDate value)
{
setValue(value, "lastCardUpdateCheck");
}
void UpdatesSettings::setAlwaysEnableNewSets(bool value)
{
setValue(value, "alwaysEnableNewSets");
}
void UpdatesSettings::setNotifyAboutUpdates(bool _notifyaboutupdate)
{
setValue(_notifyaboutupdate, "updatenotification");
}
void UpdatesSettings::setNotifyAboutNewVersion(bool _notifyaboutnewversion)
{
setValue(_notifyaboutnewversion, "newversionnotification");
}
void UpdatesSettings::setUpdateReleaseChannelIndex(int value)
{
setValue(value, "updatereleasechannel");
}

View file

@ -0,0 +1,43 @@
#ifndef UPDATES_SETTINGS_H
#define UPDATES_SETTINGS_H
#include "settings_manager.h"
#include <QDate>
#include <libcockatrice/interfaces/interface_updates_settings_provider.h>
class UpdatesSettings : public SettingsManager, public IUpdatesSettingsProvider
{
Q_OBJECT
friend class SettingsCache;
public:
[[nodiscard]] bool getCheckUpdatesOnStartup() const override;
[[nodiscard]] bool getStartupCardUpdateCheckPromptForUpdate() override;
[[nodiscard]] bool getStartupCardUpdateCheckAlwaysUpdate() override;
[[nodiscard]] int getCardUpdateCheckInterval() const override;
[[nodiscard]] QDate getLastCardUpdateCheck() const override;
[[nodiscard]] bool getCardUpdateCheckRequired() const override;
[[nodiscard]] bool getAlwaysEnableNewSets() const override;
[[nodiscard]] bool getNotifyAboutUpdates() const override;
[[nodiscard]] bool getNotifyAboutNewVersion() const override;
[[nodiscard]] int getUpdateReleaseChannelIndex() const override;
void setCheckUpdatesOnStartup(bool value);
void setStartupCardUpdateCheckPromptForUpdate(bool value);
void setStartupCardUpdateCheckAlwaysUpdate(bool value);
void setCardUpdateCheckInterval(int value);
void setLastCardUpdateCheck(QDate value);
void setAlwaysEnableNewSets(bool value);
void setNotifyAboutUpdates(bool _notifyaboutupdate);
void setNotifyAboutNewVersion(bool _notifyaboutnewversion);
void setUpdateReleaseChannelIndex(int value);
public:
explicit UpdatesSettings(const QString &settingPath, QObject *parent = nullptr);
private:
UpdatesSettings(const UpdatesSettings & /*other*/);
};
#endif // UPDATES_SETTINGS_H

View file

@ -0,0 +1,348 @@
#include "visual_deck_storage_settings.h"
namespace
{
QStringList defaultTags = {
// Strategies
"🏃️ Aggro",
"🧙‍️ Control",
"⚔️ Midrange",
"🌀 Combo",
"🪓 Mill",
"🔒 Stax",
"🗺️ Landfall",
"🛡️ Pillowfort",
"🌱 Ramp",
"⚡ Storm",
"💀 Aristocrats",
"☠️ Reanimator",
"👹 Sacrifice",
"🔥 Burn",
"🌟 Lifegain",
"🔮 Spellslinger",
"👥 Tokens",
"🎭 Blink",
"⏳ Time Manipulation",
"🌍 Domain",
"💫 Proliferate",
"📜 Saga",
"🎲 Chaos",
"🪄 Auras",
"🔫 Pingers",
// Themes
"👑 Monarch",
"🚀 Vehicles",
"💉 Infect",
"🩸 Madness",
"🌀 Morph",
// Card Types
"⚔️ Creature",
"💎 Artifact",
"🌔 Enchantment",
"📖 Sorcery",
"⚡ Instant",
"🌌 Planeswalker",
"🌏 Land",
"🪄 Aura",
// Kindred Types
"🐉 Kindred",
"🧙 Humans",
"⚔️ Soldiers",
"🛡️ Knights",
"🎻 Bards",
"🧝 Elves",
"🌲 Dryads",
"😇 Angels",
"🎩 Wizards",
"🧛 Vampires",
"🦴 Skeletons",
"💀 Zombies",
"👹 Demons",
"👾 Eldrazi",
"🐉 Dragons",
"🐠 Merfolk",
"🦁 Cats",
"🐺 Wolves",
"🐺 Werewolves",
"🦇 Bats",
"🐀 Rats",
"🦅 Birds",
"🦗 Insects",
"🍄 Fungus",
"🐚 Sea Creatures",
"🐗 Boars",
"🦊 Foxes",
"🦄 Unicorns",
"🐘 Elephants",
"🐻 Bears",
"🦏 Rhinos",
"🦂 Scorpions",
};
}
VisualDeckStorageSettings::VisualDeckStorageSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "visual_deck_storage.ini", "interface", QString(), parent)
{
}
int VisualDeckStorageSettings::getVisualDeckStorageSortingOrder() const
{
return getValue("visualdeckstoragesortingorder", QString(), QString(), 0).toInt();
}
bool VisualDeckStorageSettings::getVisualDeckStorageShowFolders() const
{
return getValue("visualdeckstorageshowfolders", QString(), QString(), true).toBool();
}
bool VisualDeckStorageSettings::getVisualDeckStorageShowTagFilter() const
{
return getValue("visualdeckstorageshowtagfilter", QString(), QString(), true).toBool();
}
QStringList VisualDeckStorageSettings::getVisualDeckStorageDefaultTagsList() const
{
return getValue("visualdeckstoragedefaulttagslist", QString(), QString(), QVariant::fromValue(defaultTags))
.toStringList();
}
bool VisualDeckStorageSettings::getVisualDeckStorageSearchFolderNames() const
{
return getValue("visualdeckstoragesearchfoldernames", QString(), QString(), true).toBool();
}
bool VisualDeckStorageSettings::getVisualDeckStorageShowColorIdentity() const
{
return getValue("visualdeckstorageshowcoloridentity", QString(), QString(), true).toBool();
}
bool VisualDeckStorageSettings::getVisualDeckStorageShowBannerCardComboBox() const
{
return getValue("visualdeckstorageshowbannercardcombobox", QString(), QString(), true).toBool();
}
bool VisualDeckStorageSettings::getVisualDeckStorageShowTagsOnDeckPreviews() const
{
return getValue("visualdeckstorageshowtagsondeckpreviews", QString(), QString(), true).toBool();
}
int VisualDeckStorageSettings::getVisualDeckStorageCardSize() const
{
return getValue("visualdeckstoragecardsize", QString(), QString(), 100).toInt();
}
bool VisualDeckStorageSettings::getVisualDeckStorageDrawUnusedColorIdentities() const
{
return getValue("visualdeckstoragedrawunusedcoloridentities", QString(), QString(), true).toBool();
}
int VisualDeckStorageSettings::getVisualDeckStorageUnusedColorIdentitiesOpacity() const
{
return getValue("visualdeckstorageunusedcoloridentitiesopacity", QString(), QString(), 15).toInt();
}
int VisualDeckStorageSettings::getVisualDeckStorageTooltipType() const
{
return getValue("visualdeckstoragetooltiptype", QString(), QString(), 0).toInt();
}
bool VisualDeckStorageSettings::getVisualDeckStoragePromptForConversion() const
{
return getValue("visualdeckstoragepromptforconversion", QString(), QString(), true).toBool();
}
bool VisualDeckStorageSettings::getVisualDeckStorageAlwaysConvert() const
{
return getValue("visualdeckstoragealwaysconvert", QString(), QString(), false).toBool();
}
bool VisualDeckStorageSettings::getVisualDeckStorageInGame() const
{
return getValue("visualdeckstorageingame", QString(), QString(), true).toBool();
}
bool VisualDeckStorageSettings::getVisualDeckStorageSelectionAnimation() const
{
return getValue("visualdeckstorageselectionanimation", QString(), QString(), true).toBool();
}
int VisualDeckStorageSettings::getVisualDeckEditorCardSize() const
{
return getValue("visualdeckeditorcardsize", QString(), QString(), 100).toInt();
}
int VisualDeckStorageSettings::getVisualDeckEditorSampleHandSize() const
{
return getValue("visualdeckeditorsamplehandsize", QString(), QString(), 7).toInt();
}
int VisualDeckStorageSettings::getVisualDatabaseDisplayCardSize() const
{
return getValue("visualdatabasedisplaycardsize", QString(), QString(), 100).toInt();
}
bool VisualDeckStorageSettings::getVisualDatabaseDisplayFilterToMostRecentSetsEnabled() const
{
return getValue("visualdatabasedisplayfiltertomostrecentsetsenabled", QString(), QString(), false).toBool();
}
int VisualDeckStorageSettings::getVisualDatabaseDisplayFilterToMostRecentSetsAmount() const
{
return getValue("visualdatabasedisplayfiltertomostrecentsetsamount", QString(), QString(), 10).toInt();
}
int VisualDeckStorageSettings::getEDHRecCardSize() const
{
return getValue("edhreccardsize", QString(), QString(), 100).toInt();
}
int VisualDeckStorageSettings::getArchidektPreviewSize() const
{
return getValue("archidektpreviewsize", QString(), QString(), 100).toInt();
}
int VisualDeckStorageSettings::getDefaultDeckEditorType() const
{
return getValue("defaultDeckEditorType", QString(), QString(), 1).toInt();
}
void VisualDeckStorageSettings::setVisualDeckStorageSortingOrder(int _sortingOrder)
{
setValue(_sortingOrder, "visualdeckstoragesortingorder");
}
void VisualDeckStorageSettings::setVisualDeckStorageShowFolders(bool value)
{
setValue(value, "visualdeckstorageshowfolders");
}
void VisualDeckStorageSettings::setVisualDeckStorageShowTagFilter(bool _showTags)
{
setValue(_showTags, "visualdeckstorageshowtagfilter");
emit visualDeckStorageShowTagFilterChanged(_showTags);
}
void VisualDeckStorageSettings::setVisualDeckStorageDefaultTagsList(QStringList _defaultTagsList)
{
setValue(QVariant::fromValue(_defaultTagsList), "visualdeckstoragedefaulttagslist");
emit visualDeckStorageDefaultTagsListChanged();
}
void VisualDeckStorageSettings::setVisualDeckStorageSearchFolderNames(bool value)
{
setValue(value, "visualdeckstoragesearchfoldernames");
}
void VisualDeckStorageSettings::setVisualDeckStorageShowColorIdentity(bool value)
{
setValue(value, "visualdeckstorageshowcoloridentity");
emit visualDeckStorageShowColorIdentityChanged(value);
}
void VisualDeckStorageSettings::setVisualDeckStorageShowBannerCardComboBox(bool _showBannerCardComboBox)
{
setValue(_showBannerCardComboBox, "visualdeckstorageshowbannercardcombobox");
emit visualDeckStorageShowBannerCardComboBoxChanged(_showBannerCardComboBox);
}
void VisualDeckStorageSettings::setVisualDeckStorageShowTagsOnDeckPreviews(bool _showTags)
{
setValue(_showTags, "visualdeckstorageshowtagsondeckpreviews");
emit visualDeckStorageShowTagsOnDeckPreviewsChanged(_showTags);
}
void VisualDeckStorageSettings::setVisualDeckStorageCardSize(int _cardSize)
{
setValue(_cardSize, "visualdeckstoragecardsize");
emit visualDeckStorageCardSizeChanged();
}
void VisualDeckStorageSettings::setVisualDeckStorageDrawUnusedColorIdentities(bool _draw)
{
setValue(_draw, "visualdeckstoragedrawunusedcoloridentities");
emit visualDeckStorageDrawUnusedColorIdentitiesChanged(_draw);
}
void VisualDeckStorageSettings::setVisualDeckStorageUnusedColorIdentitiesOpacity(int _opacity)
{
setValue(_opacity, "visualdeckstorageunusedcoloridentitiesopacity");
emit visualDeckStorageUnusedColorIdentitiesOpacityChanged(_opacity);
}
void VisualDeckStorageSettings::setVisualDeckStorageTooltipType(int value)
{
setValue(value, "visualdeckstoragetooltiptype");
}
void VisualDeckStorageSettings::setVisualDeckStoragePromptForConversion(bool _prompt)
{
setValue(_prompt, "visualdeckstoragepromptforconversion");
}
void VisualDeckStorageSettings::setVisualDeckStorageAlwaysConvert(bool _always)
{
setValue(_always, "visualdeckstoragealwaysconvert");
}
void VisualDeckStorageSettings::setVisualDeckStorageInGame(bool enabled)
{
setValue(enabled, "visualdeckstorageingame");
emit visualDeckStorageInGameChanged(enabled);
}
void VisualDeckStorageSettings::setVisualDeckStorageSelectionAnimation(bool enabled)
{
setValue(enabled, "visualdeckstorageselectionanimation");
emit visualDeckStorageSelectionAnimationChanged(enabled);
}
void VisualDeckStorageSettings::setVisualDeckEditorCardSize(int _cardSize)
{
setValue(_cardSize, "visualdeckeditorcardsize");
emit visualDeckEditorCardSizeChanged();
}
void VisualDeckStorageSettings::setVisualDeckEditorSampleHandSize(int _amount)
{
setValue(_amount, "visualdeckeditorsamplehandsize");
emit visualDeckEditorSampleHandSizeAmountChanged(_amount);
}
void VisualDeckStorageSettings::setVisualDatabaseDisplayCardSize(int _cardSize)
{
setValue(_cardSize, "visualdatabasedisplaycardsize");
emit visualDatabaseDisplayCardSizeChanged();
}
void VisualDeckStorageSettings::setVisualDatabaseDisplayFilterToMostRecentSetsEnabled(bool _enabled)
{
setValue(_enabled, "visualdatabasedisplayfiltertomostrecentsetsenabled");
emit visualDatabaseDisplayFilterToMostRecentSetsEnabledChanged(_enabled);
}
void VisualDeckStorageSettings::setVisualDatabaseDisplayFilterToMostRecentSetsAmount(int _amount)
{
setValue(_amount, "visualdatabasedisplayfiltertomostrecentsetsamount");
emit visualDatabaseDisplayFilterToMostRecentSetsAmountChanged(_amount);
}
void VisualDeckStorageSettings::setEDHRecCardSize(int _edhrecCardSize)
{
setValue(_edhrecCardSize, "edhreccardsize");
emit edhRecCardSizeChanged();
}
void VisualDeckStorageSettings::setArchidektPreviewCardSize(int _archidektPreviewCardSize)
{
setValue(_archidektPreviewCardSize, "archidektpreviewsize");
emit archidektPreviewSizeChanged();
}
void VisualDeckStorageSettings::setDefaultDeckEditorType(int value)
{
setValue(value, "defaultDeckEditorType");
}

View file

@ -0,0 +1,91 @@
#ifndef VISUAL_DECK_STORAGE_SETTINGS_H
#define VISUAL_DECK_STORAGE_SETTINGS_H
#include "settings_manager.h"
#include <QStringList>
#include <libcockatrice/interfaces/interface_visual_deck_storage_settings_provider.h>
class VisualDeckStorageSettings : public SettingsManager, public IVisualDeckStorageSettingsProvider
{
Q_OBJECT
friend class SettingsCache;
public:
[[nodiscard]] int getVisualDeckStorageSortingOrder() const override;
[[nodiscard]] bool getVisualDeckStorageShowFolders() const override;
[[nodiscard]] bool getVisualDeckStorageShowTagFilter() const override;
[[nodiscard]] QStringList getVisualDeckStorageDefaultTagsList() const override;
[[nodiscard]] bool getVisualDeckStorageSearchFolderNames() const override;
[[nodiscard]] bool getVisualDeckStorageShowColorIdentity() const override;
[[nodiscard]] bool getVisualDeckStorageShowBannerCardComboBox() const override;
[[nodiscard]] bool getVisualDeckStorageShowTagsOnDeckPreviews() const override;
[[nodiscard]] int getVisualDeckStorageCardSize() const override;
[[nodiscard]] bool getVisualDeckStorageDrawUnusedColorIdentities() const override;
[[nodiscard]] int getVisualDeckStorageUnusedColorIdentitiesOpacity() const override;
[[nodiscard]] int getVisualDeckStorageTooltipType() const override;
[[nodiscard]] bool getVisualDeckStoragePromptForConversion() const override;
[[nodiscard]] bool getVisualDeckStorageAlwaysConvert() const override;
[[nodiscard]] bool getVisualDeckStorageInGame() const override;
[[nodiscard]] bool getVisualDeckStorageSelectionAnimation() const override;
[[nodiscard]] int getVisualDeckEditorCardSize() const override;
[[nodiscard]] int getVisualDeckEditorSampleHandSize() const override;
[[nodiscard]] int getVisualDatabaseDisplayCardSize() const override;
[[nodiscard]] bool getVisualDatabaseDisplayFilterToMostRecentSetsEnabled() const override;
[[nodiscard]] int getVisualDatabaseDisplayFilterToMostRecentSetsAmount() const override;
[[nodiscard]] int getEDHRecCardSize() const override;
[[nodiscard]] int getArchidektPreviewSize() const override;
[[nodiscard]] int getDefaultDeckEditorType() const override;
void setVisualDeckStorageSortingOrder(int _sortingOrder);
void setVisualDeckStorageShowFolders(bool value);
void setVisualDeckStorageShowTagFilter(bool _showTags);
void setVisualDeckStorageDefaultTagsList(QStringList _defaultTagsList);
void setVisualDeckStorageSearchFolderNames(bool value);
void setVisualDeckStorageShowColorIdentity(bool value);
void setVisualDeckStorageShowBannerCardComboBox(bool _showBannerCardComboBox);
void setVisualDeckStorageShowTagsOnDeckPreviews(bool _showTags);
void setVisualDeckStorageCardSize(int _cardSize);
void setVisualDeckStorageDrawUnusedColorIdentities(bool _draw);
void setVisualDeckStorageUnusedColorIdentitiesOpacity(int _opacity);
void setVisualDeckStorageTooltipType(int value);
void setVisualDeckStoragePromptForConversion(bool _prompt);
void setVisualDeckStorageAlwaysConvert(bool _always);
void setVisualDeckStorageInGame(bool enabled);
void setVisualDeckStorageSelectionAnimation(bool enabled);
void setVisualDeckEditorCardSize(int _cardSize);
void setVisualDeckEditorSampleHandSize(int _amount);
void setVisualDatabaseDisplayCardSize(int _cardSize);
void setVisualDatabaseDisplayFilterToMostRecentSetsEnabled(bool _enabled);
void setVisualDatabaseDisplayFilterToMostRecentSetsAmount(int _amount);
void setEDHRecCardSize(int _edhrecCardSize);
void setArchidektPreviewCardSize(int _archidektPreviewCardSize);
void setDefaultDeckEditorType(int value);
signals:
void visualDeckStorageShowTagFilterChanged(bool _visible);
void visualDeckStorageDefaultTagsListChanged();
void visualDeckStorageShowColorIdentityChanged(bool _visible);
void visualDeckStorageShowBannerCardComboBoxChanged(bool _visible);
void visualDeckStorageShowTagsOnDeckPreviewsChanged(bool _visible);
void visualDeckStorageCardSizeChanged();
void visualDeckStorageDrawUnusedColorIdentitiesChanged(bool _visible);
void visualDeckStorageUnusedColorIdentitiesOpacityChanged(bool value);
void visualDeckStorageInGameChanged(bool enabled);
void visualDeckStorageSelectionAnimationChanged(bool enabled);
void visualDatabaseDisplayFilterToMostRecentSetsEnabledChanged(bool enabled);
void visualDatabaseDisplayFilterToMostRecentSetsAmountChanged(int amount);
void visualDeckEditorSampleHandSizeAmountChanged(int amount);
void visualDeckEditorCardSizeChanged();
void visualDatabaseDisplayCardSizeChanged();
void edhRecCardSizeChanged();
void archidektPreviewSizeChanged();
public:
explicit VisualDeckStorageSettings(const QString &settingPath, QObject *parent = nullptr);
private:
VisualDeckStorageSettings(const VisualDeckStorageSettings & /*other*/);
};
#endif // VISUAL_DECK_STORAGE_SETTINGS_H