diff --git a/libcockatrice_settings/libcockatrice/settings/layouts_settings.cpp b/libcockatrice_settings/libcockatrice/settings/layouts_settings.cpp index 97629d385..f5e6da0c2 100644 --- a/libcockatrice_settings/libcockatrice/settings/layouts_settings.cpp +++ b/libcockatrice_settings/libcockatrice/settings/layouts_settings.cpp @@ -1,218 +1,228 @@ #include "layouts_settings.h" +const static QString STATE_PROP = "state"; +const static QString GEOMETRY_PROP = "geometry"; +const static QString SIZE_PROP = "widgetSize"; + +const static QString GROUP_DECK_EDITOR = "deckEditor"; +const static QString GROUP_DECK_EDITOR_DB = "deckEditorDb"; +const static QString GROUP_SETS_DIALOG = "setsDialog"; +const static QString GROUP_GAME_PLAY_AREA = "gamePlayArea"; +const static QString GROUP_REPLAY_PLAY_AREA = "replayPlayArea"; + LayoutsSettings::LayoutsSettings(const QString &settingPath, QObject *parent) - : SettingsManager(settingPath + "layouts.ini", "layouts", QString(), parent) + : SettingsManager(settingPath + "layouts.ini", QString(), QString(), parent) { } const QByteArray LayoutsSettings::getDeckEditorLayoutState() { - return getValue("layouts/deckEditor_state").toByteArray(); + return getValue(STATE_PROP, GROUP_DECK_EDITOR).toByteArray(); } void LayoutsSettings::setDeckEditorLayoutState(const QByteArray &value) { - setValue(value, "layouts/deckEditor_state"); + setValue(value, STATE_PROP, GROUP_DECK_EDITOR); } const QByteArray LayoutsSettings::getDeckEditorGeometry() { - return getValue("layouts/deckEditor_geometry").toByteArray(); + return getValue(GEOMETRY_PROP, GROUP_DECK_EDITOR).toByteArray(); } void LayoutsSettings::setDeckEditorGeometry(const QByteArray &value) { - setValue(value, "layouts/deckEditor_geometry"); + setValue(value, GEOMETRY_PROP, GROUP_DECK_EDITOR); } QSize LayoutsSettings::getDeckEditorCardDatabaseSize() { - QVariant previous = getValue("layouts/deckEditor_CardDatabaseSize"); + QVariant previous = getValue("cardDatabase", GROUP_DECK_EDITOR, SIZE_PROP); return previous == QVariant() ? QSize(500, 500) : previous.toSize(); } void LayoutsSettings::setDeckEditorCardDatabaseSize(const QSize &value) { - setValue(value, "layouts/deckEditor_CardDatabaseSize"); + setValue(value, "cardDatabase", GROUP_DECK_EDITOR, SIZE_PROP); } QSize LayoutsSettings::getDeckEditorCardSize() { - QVariant previous = getValue("layouts/deckEditor_CardSize"); + QVariant previous = getValue("card", GROUP_DECK_EDITOR, SIZE_PROP); return previous == QVariant() ? QSize(250, 500) : previous.toSize(); } void LayoutsSettings::setDeckEditorCardSize(const QSize &value) { - setValue(value, "layouts/deckEditor_CardSize"); + setValue(value, "card", GROUP_DECK_EDITOR, SIZE_PROP); } QSize LayoutsSettings::getDeckEditorDeckSize() { - QVariant previous = getValue("layouts/deckEditor_DeckSize"); + QVariant previous = getValue("deck", GROUP_DECK_EDITOR, SIZE_PROP); return previous == QVariant() ? QSize(250, 360) : previous.toSize(); } void LayoutsSettings::setDeckEditorDeckSize(const QSize &value) { - setValue(value, "layouts/deckEditor_DeckSize"); + setValue(value, "deck", GROUP_DECK_EDITOR, SIZE_PROP); } QSize LayoutsSettings::getDeckEditorPrintingSelectorSize() { - QVariant previous = getValue("layouts/deckEditor_PrintingSelectorSize"); + QVariant previous = getValue("printingSelector", GROUP_DECK_EDITOR, SIZE_PROP); return previous == QVariant() ? QSize(525, 250) : previous.toSize(); } void LayoutsSettings::setDeckEditorPrintingSelectorSize(const QSize &value) { - setValue(value, "layouts/deckEditor_PrintingSelectorSize"); + setValue(value, "printingSelector", GROUP_DECK_EDITOR, SIZE_PROP); } QSize LayoutsSettings::getDeckEditorFilterSize() { - QVariant previous = getValue("layouts/deckEditor_FilterSize"); + QVariant previous = getValue("filter", GROUP_DECK_EDITOR, SIZE_PROP); return previous == QVariant() ? QSize(250, 250) : previous.toSize(); } void LayoutsSettings::setDeckEditorFilterSize(const QSize &value) { - setValue(value, "layouts/deckEditor_FilterSize"); + setValue(value, "filter", GROUP_DECK_EDITOR, SIZE_PROP); } const QByteArray LayoutsSettings::getDeckEditorDbHeaderState() { - return getValue("layouts/deckEditorDbHeader_state").toByteArray(); + return getValue(STATE_PROP, GROUP_DECK_EDITOR_DB, "header").toByteArray(); } void LayoutsSettings::setDeckEditorDbHeaderState(const QByteArray &value) { - setValue(value, "layouts/deckEditorDbHeader_state"); + setValue(value, STATE_PROP, GROUP_DECK_EDITOR_DB, "header"); } const QByteArray LayoutsSettings::getSetsDialogHeaderState() { - return getValue("layouts/setsDialogHeader_state").toByteArray(); + return getValue(STATE_PROP, GROUP_SETS_DIALOG, "header").toByteArray(); } void LayoutsSettings::setSetsDialogHeaderState(const QByteArray &value) { - setValue(value, "layouts/setsDialogHeader_state"); + setValue(value, STATE_PROP, GROUP_SETS_DIALOG, "header"); } void LayoutsSettings::setGamePlayAreaGeometry(const QByteArray &value) { - setValue(value, "layouts/gameplayarea_geometry"); + setValue(value, GEOMETRY_PROP, GROUP_GAME_PLAY_AREA); } void LayoutsSettings::setGamePlayAreaState(const QByteArray &value) { - setValue(value, "layouts/gameplayarea_state"); + setValue(value, STATE_PROP, GROUP_GAME_PLAY_AREA); } const QByteArray LayoutsSettings::getGamePlayAreaLayoutState() { - return getValue("layouts/gameplayarea_state").toByteArray(); + return getValue(STATE_PROP, GROUP_GAME_PLAY_AREA).toByteArray(); } const QByteArray LayoutsSettings::getGamePlayAreaGeometry() { - return getValue("layouts/gameplayarea_geometry").toByteArray(); + return getValue(GEOMETRY_PROP, GROUP_GAME_PLAY_AREA).toByteArray(); } const QSize LayoutsSettings::getGameCardInfoSize() { - QVariant previous = getValue("layouts/gameplayarea_CardInfoSize"); + QVariant previous = getValue("cardInfo", GROUP_GAME_PLAY_AREA, SIZE_PROP); return previous == QVariant() ? QSize(250, 360) : previous.toSize(); } void LayoutsSettings::setGameCardInfoSize(const QSize &value) { - setValue(value, "layouts/gameplayarea_CardInfoSize"); + setValue(value, "cardInfo", GROUP_GAME_PLAY_AREA, SIZE_PROP); } const QSize LayoutsSettings::getGameMessageLayoutSize() { - QVariant previous = getValue("layouts/gameplayarea_MessageLayoutSize"); + QVariant previous = getValue("messageLayout", GROUP_GAME_PLAY_AREA, SIZE_PROP); return previous == QVariant() ? QSize(250, 250) : previous.toSize(); } void LayoutsSettings::setGameMessageLayoutSize(const QSize &value) { - setValue(value, "layouts/gameplayarea_MessageLayoutSize"); + setValue(value, "messageLayout", GROUP_GAME_PLAY_AREA, SIZE_PROP); } const QSize LayoutsSettings::getGamePlayerListSize() { - QVariant previous = getValue("layouts/gameplayarea_PlayerListSize"); + QVariant previous = getValue("playerList", GROUP_GAME_PLAY_AREA, SIZE_PROP); return previous == QVariant() ? QSize(250, 50) : previous.toSize(); } void LayoutsSettings::setGamePlayerListSize(const QSize &value) { - setValue(value, "layouts/gameplayarea_PlayerListSize"); + setValue(value, "playerList", GROUP_GAME_PLAY_AREA, SIZE_PROP); } void LayoutsSettings::setReplayPlayAreaGeometry(const QByteArray &value) { - setValue(value, "layouts/replayplayarea_geometry"); + setValue(value, GEOMETRY_PROP, GROUP_REPLAY_PLAY_AREA); } void LayoutsSettings::setReplayPlayAreaState(const QByteArray &value) { - setValue(value, "layouts/replayplayarea_state"); + setValue(value, STATE_PROP, GROUP_REPLAY_PLAY_AREA); } const QByteArray LayoutsSettings::getReplayPlayAreaLayoutState() { - return getValue("layouts/replayplayarea_state").toByteArray(); + return getValue(STATE_PROP, GROUP_REPLAY_PLAY_AREA).toByteArray(); } const QByteArray LayoutsSettings::getReplayPlayAreaGeometry() { - return getValue("layouts/replayplayarea_geometry").toByteArray(); + return getValue(GEOMETRY_PROP, GROUP_REPLAY_PLAY_AREA).toByteArray(); } const QSize LayoutsSettings::getReplayCardInfoSize() { - QVariant previous = getValue("layouts/replayplayarea_CardInfoSize"); + QVariant previous = getValue("cardInfo", GROUP_REPLAY_PLAY_AREA, SIZE_PROP); return previous == QVariant() ? QSize(250, 360) : previous.toSize(); } void LayoutsSettings::setReplayCardInfoSize(const QSize &value) { - setValue(value, "layouts/replayplayarea_CardInfoSize"); + setValue(value, "cardInfo", GROUP_REPLAY_PLAY_AREA, SIZE_PROP); } const QSize LayoutsSettings::getReplayMessageLayoutSize() { - QVariant previous = getValue("layouts/replayplayarea_MessageLayoutSize"); + QVariant previous = getValue("messageLayout", GROUP_REPLAY_PLAY_AREA, SIZE_PROP); return previous == QVariant() ? QSize(250, 200) : previous.toSize(); } void LayoutsSettings::setReplayMessageLayoutSize(const QSize &value) { - setValue(value, "layouts/replayplayarea_MessageLayoutSize"); + setValue(value, "messageLayout", GROUP_REPLAY_PLAY_AREA, SIZE_PROP); } const QSize LayoutsSettings::getReplayPlayerListSize() { - QVariant previous = getValue("layouts/replayplayarea_PlayerListSize"); + QVariant previous = getValue("playerList", GROUP_REPLAY_PLAY_AREA, SIZE_PROP); return previous == QVariant() ? QSize(250, 50) : previous.toSize(); } void LayoutsSettings::setReplayPlayerListSize(const QSize &value) { - setValue(value, "layouts/replayplayarea_PlayerListSize"); + setValue(value, "playerList", GROUP_REPLAY_PLAY_AREA, SIZE_PROP); } const QSize LayoutsSettings::getReplayReplaySize() { - QVariant previous = getValue("layouts/replayplayarea_ReplaySize"); + QVariant previous = getValue("replay", GROUP_REPLAY_PLAY_AREA, SIZE_PROP); return previous == QVariant() ? QSize(900, 100) : previous.toSize(); } void LayoutsSettings::setReplayReplaySize(const QSize &value) { - setValue(value, "layouts/replayplayarea_ReplaySize"); + setValue(value, "replay", GROUP_REPLAY_PLAY_AREA, SIZE_PROP); }