[SettingsManager] Make setting getters const (#6748)

* [SettingsManager] Make setting getters const

* remove hashGameType from header
This commit is contained in:
RickyRister 2026-03-27 10:13:25 -07:00 committed by GitHub
parent d8e3807ec5
commit 34a5b8b9ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 124 additions and 126 deletions

View file

@ -12,9 +12,9 @@ public:
virtual void setEnabled(QString shortName, bool enabled) = 0; virtual void setEnabled(QString shortName, bool enabled) = 0;
virtual void setIsKnown(QString shortName, bool isknown) = 0; virtual void setIsKnown(QString shortName, bool isknown) = 0;
virtual unsigned int getSortKey(QString shortName) = 0; virtual unsigned int getSortKey(QString shortName) const = 0;
virtual bool isEnabled(QString shortName) = 0; virtual bool isEnabled(QString shortName) const = 0;
virtual bool isKnown(QString shortName) = 0; virtual bool isKnown(QString shortName) const = 0;
}; };
#endif // COCKATRICE_INTERFACE_CARD_SET_PRIORITY_CONTROLLER_H #endif // COCKATRICE_INTERFACE_CARD_SET_PRIORITY_CONTROLLER_H

View file

@ -16,15 +16,15 @@ public:
{ {
} }
unsigned int getSortKey(QString /* shortName */) override unsigned int getSortKey(QString /* shortName */) const override
{ {
return 0; return 0;
} }
bool isEnabled(QString /* shortName */) override bool isEnabled(QString /* shortName */) const override
{ {
return true; return true;
} }
bool isKnown(QString /* shortName */) override bool isKnown(QString /* shortName */) const override
{ {
return true; return true;
} }

View file

@ -20,17 +20,17 @@ void CardDatabaseSettings::setIsKnown(QString shortName, bool isknown)
setValue(isknown, "isknown", "sets", std::move(shortName)); setValue(isknown, "isknown", "sets", std::move(shortName));
} }
unsigned int CardDatabaseSettings::getSortKey(QString shortName) unsigned int CardDatabaseSettings::getSortKey(QString shortName) const
{ {
return getValue("sortkey", "sets", std::move(shortName)).toUInt(); return getValue("sortkey", "sets", std::move(shortName)).toUInt();
} }
bool CardDatabaseSettings::isEnabled(QString shortName) bool CardDatabaseSettings::isEnabled(QString shortName) const
{ {
return getValue("enabled", "sets", std::move(shortName)).toBool(); return getValue("enabled", "sets", std::move(shortName)).toBool();
} }
bool CardDatabaseSettings::isKnown(QString shortName) bool CardDatabaseSettings::isKnown(QString shortName) const
{ {
return getValue("isknown", "sets", std::move(shortName)).toBool(); return getValue("isknown", "sets", std::move(shortName)).toBool();
} }

View file

@ -22,9 +22,9 @@ public:
void setEnabled(QString shortName, bool enabled) override; void setEnabled(QString shortName, bool enabled) override;
void setIsKnown(QString shortName, bool isknown) override; void setIsKnown(QString shortName, bool isknown) override;
unsigned int getSortKey(QString shortName) override; unsigned int getSortKey(QString shortName) const override;
bool isEnabled(QString shortName) override; bool isEnabled(QString shortName) const override;
bool isKnown(QString shortName) override; bool isKnown(QString shortName) const override;
private: private:
explicit CardDatabaseSettings(const QString &settingPath, QObject *parent = nullptr); explicit CardDatabaseSettings(const QString &settingPath, QObject *parent = nullptr);

View file

@ -15,7 +15,7 @@ void CardOverrideSettings::deleteCardPreferenceOverride(const QString &cardName)
deleteValue(cardName); deleteValue(cardName);
} }
QString CardOverrideSettings::getCardPreferenceOverride(const QString &cardName) QString CardOverrideSettings::getCardPreferenceOverride(const QString &cardName) const
{ {
return getValue(cardName).toString(); return getValue(cardName).toString();
} }

View file

@ -22,7 +22,7 @@ public:
void deleteCardPreferenceOverride(const QString &cardName); void deleteCardPreferenceOverride(const QString &cardName);
QString getCardPreferenceOverride(const QString &cardName); QString getCardPreferenceOverride(const QString &cardName) const;
private: private:
explicit CardOverrideSettings(const QString &settingPath, QObject *parent = nullptr); explicit CardOverrideSettings(const QString &settingPath, QObject *parent = nullptr);

View file

@ -11,22 +11,22 @@ DebugSettings::DebugSettings(const QString &settingPath, QObject *parent)
} }
} }
bool DebugSettings::getShowCardId() bool DebugSettings::getShowCardId() const
{ {
return getValue("showCardId").toBool(); return getValue("showCardId").toBool();
} }
bool DebugSettings::getLocalGameOnStartup() bool DebugSettings::getLocalGameOnStartup() const
{ {
return getValue("onStartup", "localgame").toBool(); return getValue("onStartup", "localgame").toBool();
} }
int DebugSettings::getLocalGamePlayerCount() int DebugSettings::getLocalGamePlayerCount() const
{ {
return getValue("playerCount", "localgame").toInt(); return getValue("playerCount", "localgame").toInt();
} }
QString DebugSettings::getDeckPathForPlayer(const QString &playerName) QString DebugSettings::getDeckPathForPlayer(const QString &playerName) const
{ {
return getValue(playerName, "localgame", "deck").toString(); return getValue(playerName, "localgame", "deck").toString();
} }

View file

@ -17,12 +17,12 @@ class DebugSettings : public SettingsManager
DebugSettings(const DebugSettings & /*other*/); DebugSettings(const DebugSettings & /*other*/);
public: public:
bool getShowCardId(); bool getShowCardId() const;
bool getLocalGameOnStartup(); bool getLocalGameOnStartup() const;
int getLocalGamePlayerCount(); int getLocalGamePlayerCount() const;
QString getDeckPathForPlayer(const QString &playerName); QString getDeckPathForPlayer(const QString &playerName) const;
}; };
#endif // DEBUG_SETTINGS_H #endif // DEBUG_SETTINGS_H

View file

@ -18,7 +18,7 @@ void DownloadSettings::setDownloadUrls(const QStringList &downloadURLs)
setValue(QVariant::fromValue(downloadURLs), "urls"); setValue(QVariant::fromValue(downloadURLs), "urls");
} }
QStringList DownloadSettings::getAllURLs() QStringList DownloadSettings::getAllURLs() const
{ {
return getValue("urls").toStringList(); return getValue("urls").toStringList();
} }

View file

@ -19,7 +19,7 @@ class DownloadSettings : public SettingsManager
public: public:
explicit DownloadSettings(const QString &, QObject *); explicit DownloadSettings(const QString &, QObject *);
QStringList getAllURLs(); QStringList getAllURLs() const;
void setDownloadUrls(const QStringList &downloadURLs); void setDownloadUrls(const QStringList &downloadURLs);
void resetToDefaultURLs(); void resetToDefaultURLs();
}; };

View file

@ -8,11 +8,11 @@ GameFiltersSettings::GameFiltersSettings(const QString &settingPath, QObject *pa
{ {
} }
/* /**
* The game type might contain special characters, so to use it in * The game type might contain special characters, so to use it in
* QSettings we just hash it. * QSettings we just hash it.
*/ */
QString GameFiltersSettings::hashGameType(const QString &gameType) const static QString hashGameType(const QString &gameType)
{ {
return QCryptographicHash::hash(gameType.toUtf8(), QCryptographicHash::Md5).toHex(); return QCryptographicHash::hash(gameType.toUtf8(), QCryptographicHash::Md5).toHex();
} }
@ -22,7 +22,7 @@ void GameFiltersSettings::setHideBuddiesOnlyGames(bool hide)
setValue(hide, "hide_buddies_only_games"); setValue(hide, "hide_buddies_only_games");
} }
bool GameFiltersSettings::isHideBuddiesOnlyGames() bool GameFiltersSettings::isHideBuddiesOnlyGames() const
{ {
QVariant previous = getValue("hide_buddies_only_games"); QVariant previous = getValue("hide_buddies_only_games");
return previous == QVariant() ? false : previous.toBool(); return previous == QVariant() ? false : previous.toBool();
@ -33,7 +33,7 @@ void GameFiltersSettings::setHideFullGames(bool hide)
setValue(hide, "hide_full_games"); setValue(hide, "hide_full_games");
} }
bool GameFiltersSettings::isHideFullGames() bool GameFiltersSettings::isHideFullGames() const
{ {
QVariant previous = getValue("hide_full_games"); QVariant previous = getValue("hide_full_games");
return previous == QVariant() ? false : previous.toBool(); return previous == QVariant() ? false : previous.toBool();
@ -44,7 +44,7 @@ void GameFiltersSettings::setHideGamesThatStarted(bool hide)
setValue(hide, "hide_games_that_started"); setValue(hide, "hide_games_that_started");
} }
bool GameFiltersSettings::isHideGamesThatStarted() bool GameFiltersSettings::isHideGamesThatStarted() const
{ {
QVariant previous = getValue("hide_games_that_started"); QVariant previous = getValue("hide_games_that_started");
return previous == QVariant() ? false : previous.toBool(); return previous == QVariant() ? false : previous.toBool();
@ -55,7 +55,7 @@ void GameFiltersSettings::setHidePasswordProtectedGames(bool hide)
setValue(hide, "hide_password_protected_games"); setValue(hide, "hide_password_protected_games");
} }
bool GameFiltersSettings::isHidePasswordProtectedGames() bool GameFiltersSettings::isHidePasswordProtectedGames() const
{ {
QVariant previous = getValue("hide_password_protected_games"); QVariant previous = getValue("hide_password_protected_games");
return previous == QVariant() ? false : previous.toBool(); return previous == QVariant() ? false : previous.toBool();
@ -66,7 +66,7 @@ void GameFiltersSettings::setHideIgnoredUserGames(bool hide)
setValue(hide, "hide_ignored_user_games"); setValue(hide, "hide_ignored_user_games");
} }
bool GameFiltersSettings::isHideIgnoredUserGames() bool GameFiltersSettings::isHideIgnoredUserGames() const
{ {
QVariant previous = getValue("hide_ignored_user_games"); QVariant previous = getValue("hide_ignored_user_games");
return previous == QVariant() ? true : previous.toBool(); return previous == QVariant() ? true : previous.toBool();
@ -77,7 +77,7 @@ void GameFiltersSettings::setHideNotBuddyCreatedGames(bool hide)
setValue(hide, "hide_not_buddy_created_games"); setValue(hide, "hide_not_buddy_created_games");
} }
bool GameFiltersSettings::isHideNotBuddyCreatedGames() bool GameFiltersSettings::isHideNotBuddyCreatedGames() const
{ {
QVariant previous = getValue("hide_not_buddy_created_games"); QVariant previous = getValue("hide_not_buddy_created_games");
return previous == QVariant() ? false : previous.toBool(); return previous == QVariant() ? false : previous.toBool();
@ -88,7 +88,7 @@ void GameFiltersSettings::setHideOpenDecklistGames(bool hide)
setValue(hide, "hide_open_decklist_games"); setValue(hide, "hide_open_decklist_games");
} }
bool GameFiltersSettings::isHideOpenDecklistGames() bool GameFiltersSettings::isHideOpenDecklistGames() const
{ {
QVariant previous = getValue("hide_open_decklist_games"); QVariant previous = getValue("hide_open_decklist_games");
return previous == QVariant() ? false : previous.toBool(); return previous == QVariant() ? false : previous.toBool();
@ -99,7 +99,7 @@ void GameFiltersSettings::setGameNameFilter(QString gameName)
setValue(gameName, "game_name_filter"); setValue(gameName, "game_name_filter");
} }
QString GameFiltersSettings::getGameNameFilter() QString GameFiltersSettings::getGameNameFilter() const
{ {
return getValue("game_name_filter").toString(); return getValue("game_name_filter").toString();
} }
@ -109,7 +109,7 @@ void GameFiltersSettings::setCreatorNameFilters(QStringList creatorName)
setValue(creatorName, "creator_name_filter"); setValue(creatorName, "creator_name_filter");
} }
QStringList GameFiltersSettings::getCreatorNameFilters() QStringList GameFiltersSettings::getCreatorNameFilters() const
{ {
return getValue("creator_name_filter").toStringList(); return getValue("creator_name_filter").toStringList();
} }
@ -119,7 +119,7 @@ void GameFiltersSettings::setMinPlayers(int min)
setValue(min, "min_players"); setValue(min, "min_players");
} }
int GameFiltersSettings::getMinPlayers() int GameFiltersSettings::getMinPlayers() const
{ {
QVariant previous = getValue("min_players"); QVariant previous = getValue("min_players");
return previous == QVariant() ? 1 : previous.toInt(); return previous == QVariant() ? 1 : previous.toInt();
@ -130,7 +130,7 @@ void GameFiltersSettings::setMaxPlayers(int max)
setValue(max, "max_players"); setValue(max, "max_players");
} }
int GameFiltersSettings::getMaxPlayers() int GameFiltersSettings::getMaxPlayers() const
{ {
QVariant previous = getValue("max_players"); QVariant previous = getValue("max_players");
return previous == QVariant() ? 99 : previous.toInt(); return previous == QVariant() ? 99 : previous.toInt();
@ -141,7 +141,7 @@ void GameFiltersSettings::setMaxGameAge(const QTime &maxGameAge)
setValue(maxGameAge, "max_game_age_time"); setValue(maxGameAge, "max_game_age_time");
} }
QTime GameFiltersSettings::getMaxGameAge() QTime GameFiltersSettings::getMaxGameAge() const
{ {
QVariant previous = getValue("max_game_age_time"); QVariant previous = getValue("max_game_age_time");
return previous.toTime(); return previous.toTime();
@ -157,7 +157,7 @@ void GameFiltersSettings::setGameHashedTypeEnabled(QString gametypeHASHED, bool
setValue(enabled, gametypeHASHED); setValue(enabled, gametypeHASHED);
} }
bool GameFiltersSettings::isGameTypeEnabled(QString gametype) bool GameFiltersSettings::isGameTypeEnabled(QString gametype) const
{ {
QVariant previous = getValue("game_type/" + hashGameType(gametype)); QVariant previous = getValue("game_type/" + hashGameType(gametype));
return previous == QVariant() ? false : previous.toBool(); return previous == QVariant() ? false : previous.toBool();
@ -168,7 +168,7 @@ void GameFiltersSettings::setShowOnlyIfSpectatorsCanWatch(bool show)
setValue(show, "show_only_if_spectators_can_watch"); setValue(show, "show_only_if_spectators_can_watch");
} }
bool GameFiltersSettings::isShowOnlyIfSpectatorsCanWatch() bool GameFiltersSettings::isShowOnlyIfSpectatorsCanWatch() const
{ {
QVariant previous = getValue("show_only_if_spectators_can_watch"); QVariant previous = getValue("show_only_if_spectators_can_watch");
return previous == QVariant() ? false : previous.toBool(); return previous == QVariant() ? false : previous.toBool();
@ -179,7 +179,7 @@ void GameFiltersSettings::setShowSpectatorPasswordProtected(bool show)
setValue(show, "show_spectator_password_protected"); setValue(show, "show_spectator_password_protected");
} }
bool GameFiltersSettings::isShowSpectatorPasswordProtected() bool GameFiltersSettings::isShowSpectatorPasswordProtected() const
{ {
QVariant previous = getValue("show_spectator_password_protected"); QVariant previous = getValue("show_spectator_password_protected");
return previous == QVariant() ? false : previous.toBool(); return previous == QVariant() ? false : previous.toBool();
@ -190,7 +190,7 @@ void GameFiltersSettings::setShowOnlyIfSpectatorsCanChat(bool show)
setValue(show, "show_only_if_spectators_can_chat"); setValue(show, "show_only_if_spectators_can_chat");
} }
bool GameFiltersSettings::isShowOnlyIfSpectatorsCanChat() bool GameFiltersSettings::isShowOnlyIfSpectatorsCanChat() const
{ {
QVariant previous = getValue("show_only_if_spectators_can_chat"); QVariant previous = getValue("show_only_if_spectators_can_chat");
return previous == QVariant() ? false : previous.toBool(); return previous == QVariant() ? false : previous.toBool();
@ -201,7 +201,7 @@ void GameFiltersSettings::setShowOnlyIfSpectatorsCanSeeHands(bool show)
setValue(show, "show_only_if_spectators_can_see_hands"); setValue(show, "show_only_if_spectators_can_see_hands");
} }
bool GameFiltersSettings::isShowOnlyIfSpectatorsCanSeeHands() bool GameFiltersSettings::isShowOnlyIfSpectatorsCanSeeHands() const
{ {
QVariant previous = getValue("show_only_if_spectators_can_see_hands"); QVariant previous = getValue("show_only_if_spectators_can_see_hands");
return previous == QVariant() ? false : previous.toBool(); return previous == QVariant() ? false : previous.toBool();

View file

@ -16,23 +16,23 @@ class GameFiltersSettings : public SettingsManager
friend class SettingsCache; friend class SettingsCache;
public: public:
bool isHideBuddiesOnlyGames(); bool isHideBuddiesOnlyGames() const;
bool isHideFullGames(); bool isHideFullGames() const;
bool isHideGamesThatStarted(); bool isHideGamesThatStarted() const;
bool isHidePasswordProtectedGames(); bool isHidePasswordProtectedGames() const;
bool isHideIgnoredUserGames(); bool isHideIgnoredUserGames() const;
bool isHideNotBuddyCreatedGames(); bool isHideNotBuddyCreatedGames() const;
bool isHideOpenDecklistGames(); bool isHideOpenDecklistGames() const;
QString getGameNameFilter(); QString getGameNameFilter() const;
QStringList getCreatorNameFilters(); QStringList getCreatorNameFilters() const;
int getMinPlayers(); int getMinPlayers() const;
int getMaxPlayers(); int getMaxPlayers() const;
QTime getMaxGameAge(); QTime getMaxGameAge() const;
bool isGameTypeEnabled(QString gametype); bool isGameTypeEnabled(QString gametype) const;
bool isShowOnlyIfSpectatorsCanWatch(); bool isShowOnlyIfSpectatorsCanWatch() const;
bool isShowSpectatorPasswordProtected(); bool isShowSpectatorPasswordProtected() const;
bool isShowOnlyIfSpectatorsCanChat(); bool isShowOnlyIfSpectatorsCanChat() const;
bool isShowOnlyIfSpectatorsCanSeeHands(); bool isShowOnlyIfSpectatorsCanSeeHands() const;
void setHideBuddiesOnlyGames(bool hide); void setHideBuddiesOnlyGames(bool hide);
void setHideIgnoredUserGames(bool hide); void setHideIgnoredUserGames(bool hide);
@ -56,8 +56,6 @@ public:
private: private:
explicit GameFiltersSettings(const QString &settingPath, QObject *parent = nullptr); explicit GameFiltersSettings(const QString &settingPath, QObject *parent = nullptr);
GameFiltersSettings(const GameFiltersSettings & /*other*/); GameFiltersSettings(const GameFiltersSettings & /*other*/);
[[nodiscard]] QString hashGameType(const QString &gameType) const;
}; };
#endif // GAMEFILTERSSETTINGS_H #endif // GAMEFILTERSSETTINGS_H

View file

@ -23,12 +23,12 @@ void LayoutsSettings::setMainWindowGeometry(const QByteArray &value)
setValue(value, GEOMETRY_PROP, GROUP_MAIN_WINDOW); setValue(value, GEOMETRY_PROP, GROUP_MAIN_WINDOW);
} }
QByteArray LayoutsSettings::getMainWindowGeometry() QByteArray LayoutsSettings::getMainWindowGeometry() const
{ {
return getValue(GEOMETRY_PROP, GROUP_MAIN_WINDOW).toByteArray(); return getValue(GEOMETRY_PROP, GROUP_MAIN_WINDOW).toByteArray();
} }
QByteArray LayoutsSettings::getDeckEditorLayoutState() QByteArray LayoutsSettings::getDeckEditorLayoutState() const
{ {
return getValue(STATE_PROP, GROUP_DECK_EDITOR).toByteArray(); return getValue(STATE_PROP, GROUP_DECK_EDITOR).toByteArray();
} }
@ -38,7 +38,7 @@ void LayoutsSettings::setDeckEditorLayoutState(const QByteArray &value)
setValue(value, STATE_PROP, GROUP_DECK_EDITOR); setValue(value, STATE_PROP, GROUP_DECK_EDITOR);
} }
QByteArray LayoutsSettings::getDeckEditorGeometry() QByteArray LayoutsSettings::getDeckEditorGeometry() const
{ {
return getValue(GEOMETRY_PROP, GROUP_DECK_EDITOR).toByteArray(); return getValue(GEOMETRY_PROP, GROUP_DECK_EDITOR).toByteArray();
} }
@ -48,7 +48,7 @@ void LayoutsSettings::setDeckEditorGeometry(const QByteArray &value)
setValue(value, GEOMETRY_PROP, GROUP_DECK_EDITOR); setValue(value, GEOMETRY_PROP, GROUP_DECK_EDITOR);
} }
QByteArray LayoutsSettings::getVisualDeckEditorLayoutState() QByteArray LayoutsSettings::getVisualDeckEditorLayoutState() const
{ {
return getValue(STATE_PROP, GROUP_VISUAL_DECK_EDITOR).toByteArray(); return getValue(STATE_PROP, GROUP_VISUAL_DECK_EDITOR).toByteArray();
} }
@ -58,7 +58,7 @@ void LayoutsSettings::setVisualDeckEditorLayoutState(const QByteArray &value)
setValue(value, STATE_PROP, GROUP_VISUAL_DECK_EDITOR); setValue(value, STATE_PROP, GROUP_VISUAL_DECK_EDITOR);
} }
QByteArray LayoutsSettings::getVisualDeckEditorGeometry() QByteArray LayoutsSettings::getVisualDeckEditorGeometry() const
{ {
return getValue(GEOMETRY_PROP, GROUP_VISUAL_DECK_EDITOR).toByteArray(); return getValue(GEOMETRY_PROP, GROUP_VISUAL_DECK_EDITOR).toByteArray();
} }
@ -68,7 +68,7 @@ void LayoutsSettings::setVisualDeckEditorGeometry(const QByteArray &value)
setValue(value, GEOMETRY_PROP, GROUP_VISUAL_DECK_EDITOR); setValue(value, GEOMETRY_PROP, GROUP_VISUAL_DECK_EDITOR);
} }
QByteArray LayoutsSettings::getDeckEditorDbHeaderState() QByteArray LayoutsSettings::getDeckEditorDbHeaderState() const
{ {
return getValue(STATE_PROP, GROUP_DECK_EDITOR_DB, "header").toByteArray(); return getValue(STATE_PROP, GROUP_DECK_EDITOR_DB, "header").toByteArray();
} }
@ -78,7 +78,7 @@ void LayoutsSettings::setDeckEditorDbHeaderState(const QByteArray &value)
setValue(value, STATE_PROP, GROUP_DECK_EDITOR_DB, "header"); setValue(value, STATE_PROP, GROUP_DECK_EDITOR_DB, "header");
} }
QByteArray LayoutsSettings::getSetsDialogHeaderState() QByteArray LayoutsSettings::getSetsDialogHeaderState() const
{ {
return getValue(STATE_PROP, GROUP_SETS_DIALOG, "header").toByteArray(); return getValue(STATE_PROP, GROUP_SETS_DIALOG, "header").toByteArray();
} }
@ -93,7 +93,7 @@ void LayoutsSettings::setSetsDialogGeometry(const QByteArray &value)
setValue(value, GEOMETRY_PROP, GROUP_SETS_DIALOG); setValue(value, GEOMETRY_PROP, GROUP_SETS_DIALOG);
} }
QByteArray LayoutsSettings::getSetsDialogGeometry() QByteArray LayoutsSettings::getSetsDialogGeometry() const
{ {
return getValue(GEOMETRY_PROP, GROUP_SETS_DIALOG).toByteArray(); return getValue(GEOMETRY_PROP, GROUP_SETS_DIALOG).toByteArray();
} }
@ -103,7 +103,7 @@ void LayoutsSettings::setTokenDialogGeometry(const QByteArray &value)
setValue(value, GEOMETRY_PROP, GROUP_TOKEN_DIALOG); setValue(value, GEOMETRY_PROP, GROUP_TOKEN_DIALOG);
} }
QByteArray LayoutsSettings::getTokenDialogGeometry() QByteArray LayoutsSettings::getTokenDialogGeometry() const
{ {
return getValue(GEOMETRY_PROP, GROUP_TOKEN_DIALOG).toByteArray(); return getValue(GEOMETRY_PROP, GROUP_TOKEN_DIALOG).toByteArray();
} }
@ -118,12 +118,12 @@ void LayoutsSettings::setGamePlayAreaState(const QByteArray &value)
setValue(value, STATE_PROP, GROUP_GAME_PLAY_AREA); setValue(value, STATE_PROP, GROUP_GAME_PLAY_AREA);
} }
QByteArray LayoutsSettings::getGamePlayAreaLayoutState() QByteArray LayoutsSettings::getGamePlayAreaLayoutState() const
{ {
return getValue(STATE_PROP, GROUP_GAME_PLAY_AREA).toByteArray(); return getValue(STATE_PROP, GROUP_GAME_PLAY_AREA).toByteArray();
} }
QByteArray LayoutsSettings::getGamePlayAreaGeometry() QByteArray LayoutsSettings::getGamePlayAreaGeometry() const
{ {
return getValue(GEOMETRY_PROP, GROUP_GAME_PLAY_AREA).toByteArray(); return getValue(GEOMETRY_PROP, GROUP_GAME_PLAY_AREA).toByteArray();
} }
@ -138,12 +138,12 @@ void LayoutsSettings::setReplayPlayAreaState(const QByteArray &value)
setValue(value, STATE_PROP, GROUP_REPLAY_PLAY_AREA); setValue(value, STATE_PROP, GROUP_REPLAY_PLAY_AREA);
} }
QByteArray LayoutsSettings::getReplayPlayAreaLayoutState() QByteArray LayoutsSettings::getReplayPlayAreaLayoutState() const
{ {
return getValue(STATE_PROP, GROUP_REPLAY_PLAY_AREA).toByteArray(); return getValue(STATE_PROP, GROUP_REPLAY_PLAY_AREA).toByteArray();
} }
QByteArray LayoutsSettings::getReplayPlayAreaGeometry() QByteArray LayoutsSettings::getReplayPlayAreaGeometry() const
{ {
return getValue(GEOMETRY_PROP, GROUP_REPLAY_PLAY_AREA).toByteArray(); return getValue(GEOMETRY_PROP, GROUP_REPLAY_PLAY_AREA).toByteArray();
} }

View file

@ -36,24 +36,24 @@ public:
void setReplayPlayAreaGeometry(const QByteArray &value); void setReplayPlayAreaGeometry(const QByteArray &value);
void setReplayPlayAreaState(const QByteArray &value); void setReplayPlayAreaState(const QByteArray &value);
QByteArray getMainWindowGeometry(); QByteArray getMainWindowGeometry() const;
QByteArray getDeckEditorLayoutState(); QByteArray getDeckEditorLayoutState() const;
QByteArray getDeckEditorGeometry(); QByteArray getDeckEditorGeometry() const;
QByteArray getVisualDeckEditorLayoutState(); QByteArray getVisualDeckEditorLayoutState() const;
QByteArray getVisualDeckEditorGeometry(); QByteArray getVisualDeckEditorGeometry() const;
QByteArray getDeckEditorDbHeaderState(); QByteArray getDeckEditorDbHeaderState() const;
QByteArray getSetsDialogHeaderState(); QByteArray getSetsDialogHeaderState() const;
QByteArray getSetsDialogGeometry(); QByteArray getSetsDialogGeometry() const;
QByteArray getTokenDialogGeometry(); QByteArray getTokenDialogGeometry() const;
QByteArray getGamePlayAreaLayoutState(); QByteArray getGamePlayAreaLayoutState() const;
QByteArray getGamePlayAreaGeometry(); QByteArray getGamePlayAreaGeometry() const;
QByteArray getReplayPlayAreaLayoutState(); QByteArray getReplayPlayAreaLayoutState() const;
QByteArray getReplayPlayAreaGeometry(); QByteArray getReplayPlayAreaGeometry() const;
signals: signals:
public slots: public slots:

View file

@ -5,12 +5,12 @@ MessageSettings::MessageSettings(const QString &settingPath, QObject *parent)
{ {
} }
QString MessageSettings::getMessageAt(int index) QString MessageSettings::getMessageAt(int index) const
{ {
return getValue(QString("msg%1").arg(index)).toString(); return getValue(QString("msg%1").arg(index)).toString();
} }
int MessageSettings::getCount() int MessageSettings::getCount() const
{ {
return getValue("count").toInt(); return getValue("count").toInt();
} }

View file

@ -15,8 +15,8 @@ class MessageSettings : public SettingsManager
friend class SettingsCache; friend class SettingsCache;
public: public:
int getCount(); int getCount() const;
QString getMessageAt(int index); QString getMessageAt(int index) const;
void setCount(int count); void setCount(int count);
void setMessageAt(int index, QString message); void setMessageAt(int index, QString message);

View file

@ -7,7 +7,7 @@ RecentsSettings::RecentsSettings(const QString &settingPath, QObject *parent)
{ {
} }
QStringList RecentsSettings::getRecentlyOpenedDeckPaths() QStringList RecentsSettings::getRecentlyOpenedDeckPaths() const
{ {
return getValue("deckpaths").toStringList(); return getValue("deckpaths").toStringList();
} }
@ -31,7 +31,7 @@ void RecentsSettings::updateRecentlyOpenedDeckPaths(const QString &deckPath)
emit recentlyOpenedDeckPathsChanged(); emit recentlyOpenedDeckPathsChanged();
} }
QString RecentsSettings::getLatestDeckDirPath() QString RecentsSettings::getLatestDeckDirPath() const
{ {
return getValue("latestDeckDir", "dirs").toString(); return getValue("latestDeckDir", "dirs").toString();
} }

View file

@ -18,11 +18,11 @@ class RecentsSettings : public SettingsManager
RecentsSettings(const RecentsSettings & /*other*/); RecentsSettings(const RecentsSettings & /*other*/);
public: public:
QStringList getRecentlyOpenedDeckPaths(); QStringList getRecentlyOpenedDeckPaths() const;
void clearRecentlyOpenedDeckPaths(); void clearRecentlyOpenedDeckPaths();
void updateRecentlyOpenedDeckPaths(const QString &deckPath); void updateRecentlyOpenedDeckPaths(const QString &deckPath);
QString getLatestDeckDirPath(); QString getLatestDeckDirPath() const;
void setLatestDeckDirPath(const QString &dirPath); void setLatestDeckDirPath(const QString &dirPath);
signals: signals:

View file

@ -13,7 +13,7 @@ void ServersSettings::setPreviousHostLogin(int previous)
setValue(previous, "previoushostlogin"); setValue(previous, "previoushostlogin");
} }
int ServersSettings::getPreviousHostLogin() int ServersSettings::getPreviousHostLogin() const
{ {
QVariant previous = getValue("previoushostlogin"); QVariant previous = getValue("previoushostlogin");
return previous == QVariant() ? 1 : previous.toInt(); return previous == QVariant() ? 1 : previous.toInt();
@ -24,7 +24,7 @@ void ServersSettings::setPreviousHostList(QStringList list)
setValue(list, "previoushosts"); setValue(list, "previoushosts");
} }
QStringList ServersSettings::getPreviousHostList() QStringList ServersSettings::getPreviousHostList() const
{ {
return getValue("previoushosts").toStringList(); return getValue("previoushosts").toStringList();
} }
@ -48,13 +48,13 @@ QString ServersSettings::getSite(QString defaultSite)
return site == QVariant() ? std::move(defaultSite) : site.toString(); return site == QVariant() ? std::move(defaultSite) : site.toString();
} }
QString ServersSettings::getPrevioushostName() QString ServersSettings::getPrevioushostName() const
{ {
QVariant value = getValue("previoushostName"); QVariant value = getValue("previoushostName");
return value == QVariant() ? "Rooster Ranges" : value.toString(); return value == QVariant() ? "Rooster Ranges" : value.toString();
} }
int ServersSettings::getPrevioushostindex(const QString &saveName) int ServersSettings::getPrevioushostindex(const QString &saveName) const
{ {
int size = getValue("totalServers", "server", "server_details").toInt(); int size = getValue("totalServers", "server", "server_details").toInt();
@ -65,14 +65,14 @@ int ServersSettings::getPrevioushostindex(const QString &saveName)
return -1; return -1;
} }
QString ServersSettings::getHostname(QString defaultHost) QString ServersSettings::getHostname(QString defaultHost) const
{ {
int index = getPrevioushostindex(getPrevioushostName()); int index = getPrevioushostindex(getPrevioushostName());
QVariant hostname = getValue(QString("server%1").arg(index), "server", "server_details"); QVariant hostname = getValue(QString("server%1").arg(index), "server", "server_details");
return hostname == QVariant() ? std::move(defaultHost) : hostname.toString(); return hostname == QVariant() ? std::move(defaultHost) : hostname.toString();
} }
QString ServersSettings::getPort(QString defaultPort) QString ServersSettings::getPort(QString defaultPort) const
{ {
int index = getPrevioushostindex(getPrevioushostName()); int index = getPrevioushostindex(getPrevioushostName());
QVariant port = getValue(QString("port%1").arg(index), "server", "server_details"); QVariant port = getValue(QString("port%1").arg(index), "server", "server_details");
@ -80,7 +80,7 @@ QString ServersSettings::getPort(QString defaultPort)
return port == QVariant() ? std::move(defaultPort) : port.toString(); return port == QVariant() ? std::move(defaultPort) : port.toString();
} }
QString ServersSettings::getPlayerName(QString defaultName) QString ServersSettings::getPlayerName(QString defaultName) const
{ {
int index = getPrevioushostindex(getPrevioushostName()); int index = getPrevioushostindex(getPrevioushostName());
QVariant name = getValue(QString("username%1").arg(index), "server", "server_details"); QVariant name = getValue(QString("username%1").arg(index), "server", "server_details");
@ -98,7 +98,7 @@ QString ServersSettings::getPassword()
return QString(); return QString();
} }
bool ServersSettings::getSavePassword() bool ServersSettings::getSavePassword() const
{ {
int index = getPrevioushostindex(getPrevioushostName()); int index = getPrevioushostindex(getPrevioushostName());
bool save = getValue(QString("savePassword%1").arg(index), "server", "server_details").toBool(); bool save = getValue(QString("savePassword%1").arg(index), "server", "server_details").toBool();
@ -110,7 +110,7 @@ void ServersSettings::setAutoConnect(int autoconnect)
setValue(autoconnect, "auto_connect"); setValue(autoconnect, "auto_connect");
} }
int ServersSettings::getAutoConnect() int ServersSettings::getAutoConnect() const
{ {
QVariant autoconnect = getValue("auto_connect"); QVariant autoconnect = getValue("auto_connect");
return autoconnect == QVariant() ? 0 : autoconnect.toInt(); return autoconnect == QVariant() ? 0 : autoconnect.toInt();
@ -121,7 +121,7 @@ void ServersSettings::setFPHostName(QString hostname)
setValue(hostname, "fphostname"); setValue(hostname, "fphostname");
} }
QString ServersSettings::getFPHostname(QString defaultHost) QString ServersSettings::getFPHostname(QString defaultHost) const
{ {
QVariant hostname = getValue("fphostname"); QVariant hostname = getValue("fphostname");
return hostname == QVariant() ? std::move(defaultHost) : hostname.toString(); return hostname == QVariant() ? std::move(defaultHost) : hostname.toString();
@ -132,7 +132,7 @@ void ServersSettings::setFPPort(QString port)
setValue(port, "fpport"); setValue(port, "fpport");
} }
QString ServersSettings::getFPPort(QString defaultPort) QString ServersSettings::getFPPort(QString defaultPort) const
{ {
QVariant port = getValue("fpport"); QVariant port = getValue("fpport");
return port == QVariant() ? std::move(defaultPort) : port.toString(); return port == QVariant() ? std::move(defaultPort) : port.toString();
@ -143,7 +143,7 @@ void ServersSettings::setFPPlayerName(QString playerName)
setValue(playerName, "fpplayername"); setValue(playerName, "fpplayername");
} }
QString ServersSettings::getFPPlayerName(QString defaultName) QString ServersSettings::getFPPlayerName(QString defaultName) const
{ {
QVariant name = getValue("fpplayername"); QVariant name = getValue("fpplayername");
return name == QVariant() ? std::move(defaultName) : name.toString(); return name == QVariant() ? std::move(defaultName) : name.toString();
@ -154,7 +154,7 @@ void ServersSettings::setClearDebugLogStatus(bool abIsChecked)
setValue(abIsChecked, "save_debug_log"); setValue(abIsChecked, "save_debug_log");
} }
bool ServersSettings::getClearDebugLogStatus(bool abDefaultValue) bool ServersSettings::getClearDebugLogStatus(bool abDefaultValue) const
{ {
QVariant cbFlushLog = getValue("save_debug_log"); QVariant cbFlushLog = getValue("save_debug_log");
return cbFlushLog == QVariant() ? abDefaultValue : cbFlushLog.toBool(); return cbFlushLog == QVariant() ? abDefaultValue : cbFlushLog.toBool();

View file

@ -22,21 +22,21 @@ class ServersSettings : public SettingsManager
friend class SettingsCache; friend class SettingsCache;
public: public:
int getPreviousHostLogin(); int getPreviousHostLogin() const;
int getPrevioushostindex(const QString &); int getPrevioushostindex(const QString &) const;
QStringList getPreviousHostList(); QStringList getPreviousHostList() const;
QString getPrevioushostName(); QString getPrevioushostName() const;
QString getHostname(QString defaultHost = SERVERSETTINGS_DEFAULT_HOST); QString getHostname(QString defaultHost = SERVERSETTINGS_DEFAULT_HOST) const;
QString getPort(QString defaultPort = SERVERSETTINGS_DEFAULT_PORT); QString getPort(QString defaultPort = SERVERSETTINGS_DEFAULT_PORT) const;
QString getPlayerName(QString defaultName = ""); QString getPlayerName(QString defaultName = "") const;
QString getFPHostname(QString defaultHost = SERVERSETTINGS_DEFAULT_HOST); QString getFPHostname(QString defaultHost = SERVERSETTINGS_DEFAULT_HOST) const;
QString getFPPort(QString defaultPort = SERVERSETTINGS_DEFAULT_PORT); QString getFPPort(QString defaultPort = SERVERSETTINGS_DEFAULT_PORT) const;
QString getFPPlayerName(QString defaultName = ""); QString getFPPlayerName(QString defaultName = "") const;
QString getPassword(); QString getPassword();
QString getSaveName(QString defaultname = ""); QString getSaveName(QString defaultname = "");
QString getSite(QString defaultName = ""); QString getSite(QString defaultName = "");
bool getSavePassword(); bool getSavePassword() const;
int getAutoConnect(); int getAutoConnect() const;
void setPreviousHostLogin(int previous); void setPreviousHostLogin(int previous);
void setPrevioushostName(const QString &); void setPrevioushostName(const QString &);
@ -67,7 +67,7 @@ public:
QString port = QString(), QString port = QString(),
QString site = QString()); QString site = QString());
void setClearDebugLogStatus(bool abIsChecked); void setClearDebugLogStatus(bool abIsChecked);
bool getClearDebugLogStatus(bool abDefaultValue); bool getClearDebugLogStatus(bool abDefaultValue) const;
private: private:
explicit ServersSettings(const QString &settingPath, QObject *parent = nullptr); explicit ServersSettings(const QString &settingPath, QObject *parent = nullptr);

View file

@ -108,7 +108,7 @@ void SettingsManager::deleteValue(const QString &name, const QString &group, con
} }
} }
QVariant SettingsManager::getValue(const QString &name) QVariant SettingsManager::getValue(const QString &name) const
{ {
auto settings = getSettings(); auto settings = getSettings();
@ -133,7 +133,7 @@ QVariant SettingsManager::getValue(const QString &name)
return value; return value;
} }
QVariant SettingsManager::getValue(const QString &name, const QString &group, const QString &subGroup) QVariant SettingsManager::getValue(const QString &name, const QString &group, const QString &subGroup) const
{ {
auto settings = getSettings(); auto settings = getSettings();

View file

@ -19,8 +19,8 @@ public:
const QString &defaultGroup = QString(), const QString &defaultGroup = QString(),
const QString &defaultSubGroup = QString(), const QString &defaultSubGroup = QString(),
QObject *parent = nullptr); QObject *parent = nullptr);
QVariant getValue(const QString &name); QVariant getValue(const QString &name) const;
QVariant getValue(const QString &name, const QString &group, const QString &subGroup = QString()); QVariant getValue(const QString &name, const QString &group, const QString &subGroup = QString()) const;
void sync(); void sync();
protected: protected: