diff --git a/.ci/release_template.md b/.ci/release_template.md
index 0e6c05165..b0924b92a 100644
--- a/.ci/release_template.md
+++ b/.ci/release_template.md
@@ -27,6 +27,8 @@ Available pre-compiled binaries for installation:
We are also packaged in Arch Linux's official extra repository, courtesy of @FFY00.
General Linux support is available via a flatpak package at Flathub!
+
+We provide a Docker image for "Servatrice" in GHCR. You can docker pull it or use our Docker Compose files!
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 1e278a418..fc25af67f 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -2,19 +2,18 @@
version: 2
updates:
- # # Enable version updates for git submodules
- # Not yet possible to bump only on tags or releases, see:
+ # Enable version updates for git submodules
+ # If SemVer is used, updates will happen to new releases only (not HEAD)
# https://github.com/dependabot/dependabot-core/issues/1639
# https://github.com/dependabot/dependabot-core/issues/2192
- # Alternative: Action that updates submodule and can be manually run on demand (workflow_dispatch)
- # - package-ecosystem: "gitsubmodule"
- # # Look for `.gitmodules` in the `root` directory
- # directory: "/"
- # # Check for updates once a month
- # schedule:
- # interval: "monthly"
- # # Limit the amout of open PR's (default = 5, disabled = 0, security updates are not impacted)
- # open-pull-requests-limit: 1
+ - package-ecosystem: "gitsubmodule"
+ # Look for `.gitmodules` in the `root` directory
+ directory: "/"
+ # Check for updates once a month
+ schedule:
+ interval: "monthly"
+ # Limit the amout of open PR's (default = 5, disabled = 0, security updates are not impacted)
+ open-pull-requests-limit: 2
# # Enable version updates for Docker
# Not yet possible to bump from one LTS version to the next and skip others, see:
diff --git a/.github/workflows/desktop-build.yml b/.github/workflows/desktop-build.yml
index 02c3f7aec..820044059 100644
--- a/.github/workflows/desktop-build.yml
+++ b/.github/workflows/desktop-build.yml
@@ -341,7 +341,7 @@ jobs:
- name: Add msbuild to PATH
if: matrix.os == 'Windows'
id: add-msbuild
- uses: microsoft/setup-msbuild@v2
+ uses: microsoft/setup-msbuild@v3
with:
msbuild-architecture: x64
diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml
index 2a4aab1ea..cdcf77e97 100644
--- a/.github/workflows/docker-release.yml
+++ b/.github/workflows/docker-release.yml
@@ -48,7 +48,7 @@ jobs:
- name: Login to GitHub Container Registry
if: github.ref_type == 'tag'
- uses: docker/login-action@v3
+ uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
diff --git a/cockatrice/src/client/settings/card_counter_settings.cpp b/cockatrice/src/client/settings/card_counter_settings.cpp
index 71ce4cfc6..399365c99 100644
--- a/cockatrice/src/client/settings/card_counter_settings.cpp
+++ b/cockatrice/src/client/settings/card_counter_settings.cpp
@@ -11,6 +11,8 @@ CardCounterSettings::CardCounterSettings(const QString &settingsPath, QObject *p
void CardCounterSettings::setColor(int counterId, const QColor &color)
{
+ QSettings settings = getSettings();
+
QString key = QString("cards/counters/%1/color").arg(counterId);
if (settings.value(key).value() == color)
@@ -36,7 +38,7 @@ QColor CardCounterSettings::color(int counterId) const
defaultColor = QColor::fromHsv(h, s, v);
}
- return settings.value(QString("cards/counters/%1/color").arg(counterId), defaultColor).value();
+ return getSettings().value(QString("cards/counters/%1/color").arg(counterId), defaultColor).value();
}
QString CardCounterSettings::displayName(int counterId) const
diff --git a/cockatrice/src/client/settings/shortcuts_settings.h b/cockatrice/src/client/settings/shortcuts_settings.h
index 51615745b..1de73c165 100644
--- a/cockatrice/src/client/settings/shortcuts_settings.h
+++ b/cockatrice/src/client/settings/shortcuts_settings.h
@@ -501,7 +501,7 @@ private:
{"Player/aUntapAll", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Untap All"),
parseSequenceString("Ctrl+U"),
ShortcutGroup::Playing_Area)},
- {"Player/aDoesntUntap", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Toggle Untap"),
+ {"Player/aDoesntUntap", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Toggle Skip Untapping"),
parseSequenceString("Alt+U"),
ShortcutGroup::Playing_Area)},
{"Player/aFlip", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Turn Card Over"),
@@ -563,6 +563,9 @@ private:
{"Player/aMoveToTopLibrary", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Top of Library"),
parseSequenceString(""),
ShortcutGroup::Move_selected)},
+ {"Player/aMoveToTable", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Battlefield"),
+ parseSequenceString(""),
+ ShortcutGroup::Move_selected)},
{"Player/aViewHand",
ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Hand"), parseSequenceString(""), ShortcutGroup::View)},
{"Player/aViewGraveyard",
diff --git a/cockatrice/src/game/board/abstract_counter.h b/cockatrice/src/game/board/abstract_counter.h
index ea13cb00f..074650d54 100644
--- a/cockatrice/src/game/board/abstract_counter.h
+++ b/cockatrice/src/game/board/abstract_counter.h
@@ -8,6 +8,7 @@
#define COUNTER_H
#include "../../interface/widgets/menus/tearoff_menu.h"
+#include "../player/menu/abstract_player_component.h"
#include
#include
@@ -18,7 +19,7 @@ class QKeyEvent;
class QMenu;
class QString;
-class AbstractCounter : public QObject, public QGraphicsItem
+class AbstractCounter : public QObject, public QGraphicsItem, public AbstractPlayerComponent
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
@@ -56,10 +57,10 @@ public:
QGraphicsItem *parent = nullptr);
~AbstractCounter() override;
- void retranslateUi();
+ void retranslateUi() override;
void setValue(int _value);
- void setShortcutsActive();
- void setShortcutsInactive();
+ void setShortcutsActive() override;
+ void setShortcutsInactive() override;
void delCounter();
QMenu *getMenu() const
diff --git a/cockatrice/src/game/board/card_item.cpp b/cockatrice/src/game/board/card_item.cpp
index 62de4a02e..cf3c7db20 100644
--- a/cockatrice/src/game/board/card_item.cpp
+++ b/cockatrice/src/game/board/card_item.cpp
@@ -460,6 +460,9 @@ void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
bool CardItem::animationEvent()
{
+ if (owner == nullptr) {
+ return false;
+ }
int rotation = ROTATION_DEGREES_PER_FRAME;
bool animationIncomplete = true;
if (!tapped)
diff --git a/cockatrice/src/game/player/card_menu_action_type.h b/cockatrice/src/game/player/card_menu_action_type.h
index aec6d6397..1b63674fa 100644
--- a/cockatrice/src/game/player/card_menu_action_type.h
+++ b/cockatrice/src/game/player/card_menu_action_type.h
@@ -9,17 +9,20 @@
enum CardMenuActionType
{
+ // Per-card attribute actions (must be <= cmClone for cardMenuAction() dispatch)
cmTap,
cmUntap,
cmDoesntUntap,
cmFlip,
cmPeek,
cmClone,
+ // Move actions (must be > cmClone for cardMenuAction() dispatch)
cmMoveToTopLibrary,
cmMoveToBottomLibrary,
cmMoveToHand,
cmMoveToGraveyard,
- cmMoveToExile
+ cmMoveToExile,
+ cmMoveToTable
};
#endif // COCKATRICE_CARD_MENU_ACTION_TYPE_H
diff --git a/cockatrice/src/game/player/menu/abstract_player_component.h b/cockatrice/src/game/player/menu/abstract_player_component.h
new file mode 100644
index 000000000..989300d41
--- /dev/null
+++ b/cockatrice/src/game/player/menu/abstract_player_component.h
@@ -0,0 +1,32 @@
+/**
+ * @file abstract_player_component.h
+ * @ingroup GameMenusPlayers
+ * @brief Polymorphic interface for player-bound UI components managed by PlayerMenu.
+ */
+
+#ifndef COCKATRICE_ABSTRACT_PLAYER_COMPONENT_H
+#define COCKATRICE_ABSTRACT_PLAYER_COMPONENT_H
+
+/**
+ * @brief Interface for player-bound UI components that need shortcut and translation lifecycle management.
+ *
+ * Not a QObject — avoids diamond inheritance with Qt's MOC. Each concrete component
+ * inherits QObject through its Qt base class (QMenu, TearOffMenu, QGraphicsItem, etc.)
+ * and this interface through regular multiple inheritance.
+ */
+class AbstractPlayerComponent
+{
+public:
+ virtual ~AbstractPlayerComponent() = default;
+
+ /// Bind keyboard shortcuts. Called when this player gains focus.
+ virtual void setShortcutsActive() = 0;
+
+ /// Unbind keyboard shortcuts. Called when this player loses focus.
+ virtual void setShortcutsInactive() = 0;
+
+ /// Retranslate all user-visible strings. Called on language change.
+ virtual void retranslateUi() = 0;
+};
+
+#endif // COCKATRICE_ABSTRACT_PLAYER_COMPONENT_H
diff --git a/cockatrice/src/game/player/menu/card_menu.cpp b/cockatrice/src/game/player/menu/card_menu.cpp
index cd77c2968..66ca5e46b 100644
--- a/cockatrice/src/game/player/menu/card_menu.cpp
+++ b/cockatrice/src/game/player/menu/card_menu.cpp
@@ -35,6 +35,8 @@ CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive
connect(aTap, &QAction::triggered, playerActions, &PlayerActions::cardMenuAction);
aDoesntUntap = new QAction(this);
aDoesntUntap->setData(cmDoesntUntap);
+ aDoesntUntap->setCheckable(true);
+ aDoesntUntap->setChecked(card != nullptr && card->getDoesntUntap());
connect(aDoesntUntap, &QAction::triggered, playerActions, &PlayerActions::cardMenuAction);
aAttach = new QAction(this);
connect(aAttach, &QAction::triggered, playerActions, &PlayerActions::actAttach);
@@ -108,6 +110,7 @@ CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive
if (revealedCard) {
addAction(aHide);
+ addSeparator();
addAction(aClone);
addSeparator();
addAction(aSelectAll);
@@ -146,16 +149,14 @@ void CardMenu::createTableMenu(bool canModifyCard)
{
// Card is on the battlefield
if (!canModifyCard) {
- addRelatedCardView();
- addRelatedCardActions();
-
- addSeparator();
addAction(aDrawArrow);
addSeparator();
addAction(aClone);
addSeparator();
addAction(aSelectAll);
addAction(aSelectRow);
+ addRelatedCardView();
+ addRelatedCardActions();
return;
}
@@ -165,10 +166,9 @@ void CardMenu::createTableMenu(bool canModifyCard)
if (card->getFaceDown()) {
addAction(aPeek);
}
-
- addRelatedCardView();
- addRelatedCardActions();
-
+ addSeparator();
+ addAction(aClone);
+ addMenu(new MoveMenu(player));
addSeparator();
addAction(aAttach);
if (card->getAttachedTo()) {
@@ -179,9 +179,6 @@ void CardMenu::createTableMenu(bool canModifyCard)
addMenu(new PtMenu(player));
addAction(aSetAnnotation);
addSeparator();
- addAction(aClone);
- addMenu(new MoveMenu(player));
- addSeparator();
addAction(aSelectAll);
addAction(aSelectRow);
@@ -197,27 +194,34 @@ void CardMenu::createTableMenu(bool canModifyCard)
}
addSeparator();
addMenu(mCardCounters);
+ addRelatedCardView();
+ addRelatedCardActions();
}
void CardMenu::createStackMenu(bool canModifyCard)
{
// Card is on the stack
- if (canModifyCard) {
- addAction(aAttach);
- addAction(aDrawArrow);
- addSeparator();
- addAction(aClone);
- addMenu(new MoveMenu(player));
- addSeparator();
- addAction(aSelectAll);
- } else {
+ if (!canModifyCard) {
addAction(aDrawArrow);
addSeparator();
addAction(aClone);
addSeparator();
addAction(aSelectAll);
+ addRelatedCardView();
+ addRelatedCardActions();
+ return;
}
+ addAction(aPlay);
+ addAction(aPlayFacedown);
+ addSeparator();
+ addAction(aClone);
+ addMenu(new MoveMenu(player));
+ addSeparator();
+ addAction(aAttach);
+ addAction(aDrawArrow);
+ addSeparator();
+ addAction(aSelectAll);
addRelatedCardView();
addRelatedCardActions();
}
@@ -225,29 +229,29 @@ void CardMenu::createStackMenu(bool canModifyCard)
void CardMenu::createGraveyardOrExileMenu(bool canModifyCard)
{
// Card is in the graveyard or exile
- if (canModifyCard) {
- addAction(aPlay);
- addAction(aPlayFacedown);
-
- addSeparator();
- addAction(aClone);
- addMenu(new MoveMenu(player));
- addSeparator();
- addAction(aSelectAll);
- addAction(aSelectColumn);
-
- addSeparator();
- addAction(aAttach);
+ if (!canModifyCard) {
addAction(aDrawArrow);
- } else {
+ addSeparator();
addAction(aClone);
addSeparator();
addAction(aSelectAll);
addAction(aSelectColumn);
- addSeparator();
- addAction(aDrawArrow);
+ addRelatedCardView();
+ addRelatedCardActions();
+ return;
}
+ addAction(aPlay);
+ addAction(aPlayFacedown);
+ addSeparator();
+ addAction(aClone);
+ addMenu(new MoveMenu(player));
+ addSeparator();
+ addAction(aAttach);
+ addAction(aDrawArrow);
+ addSeparator();
+ addAction(aSelectAll);
+ addAction(aSelectColumn);
addRelatedCardView();
addRelatedCardActions();
}
@@ -257,12 +261,11 @@ void CardMenu::createHandOrCustomZoneMenu(bool canModifyCard)
if (!canModifyCard) {
addAction(aDrawArrow);
addSeparator();
- addRelatedCardView();
- addRelatedCardActions();
- addSeparator();
addAction(aClone);
addSeparator();
addAction(aSelectAll);
+ addRelatedCardView();
+ addRelatedCardActions();
return;
}
@@ -449,7 +452,7 @@ void CardMenu::retranslateUi()
aRevealToAll->setText(tr("&All players"));
//: Turn sideways or back again
aTap->setText(tr("&Tap / Untap"));
- aDoesntUntap->setText(tr("Toggle &normal untapping"));
+ aDoesntUntap->setText(tr("Skip &untapping"));
//: Turn face up/face down
aFlip->setText(tr("T&urn Over")); // Only the user facing names in client got renamed to "turn over"
// All code and proto bits are still unchanged (flip) for compatibility reasons
diff --git a/cockatrice/src/game/player/menu/custom_zone_menu.h b/cockatrice/src/game/player/menu/custom_zone_menu.h
index 0944029f4..c4e66754e 100644
--- a/cockatrice/src/game/player/menu/custom_zone_menu.h
+++ b/cockatrice/src/game/player/menu/custom_zone_menu.h
@@ -7,15 +7,23 @@
#ifndef COCKATRICE_CUSTOM_ZONE_MENU_H
#define COCKATRICE_CUSTOM_ZONE_MENU_H
+#include "abstract_player_component.h"
+
#include
class Player;
-class CustomZoneMenu : public QMenu
+class CustomZoneMenu : public QMenu, public AbstractPlayerComponent
{
Q_OBJECT
public:
explicit CustomZoneMenu(Player *player);
- void retranslateUi();
+ void retranslateUi() override;
+ void setShortcutsActive() override
+ {
+ }
+ void setShortcutsInactive() override
+ {
+ }
private:
Player *player;
diff --git a/cockatrice/src/game/player/menu/grave_menu.h b/cockatrice/src/game/player/menu/grave_menu.h
index faaf497b6..429173afa 100644
--- a/cockatrice/src/game/player/menu/grave_menu.h
+++ b/cockatrice/src/game/player/menu/grave_menu.h
@@ -8,12 +8,13 @@
#define COCKATRICE_GRAVE_MENU_H
#include "../../../interface/widgets/menus/tearoff_menu.h"
+#include "abstract_player_component.h"
#include
#include
class Player;
-class GraveyardMenu : public TearOffMenu
+class GraveyardMenu : public TearOffMenu, public AbstractPlayerComponent
{
Q_OBJECT
signals:
@@ -25,9 +26,9 @@ public:
void createViewActions();
void populateRevealRandomMenuWithActivePlayers();
void onRevealRandomTriggered();
- void retranslateUi();
- void setShortcutsActive();
- void setShortcutsInactive();
+ void retranslateUi() override;
+ void setShortcutsActive() override;
+ void setShortcutsInactive() override;
QMenu *mRevealRandomGraveyardCard = nullptr;
QMenu *moveGraveMenu = nullptr;
diff --git a/cockatrice/src/game/player/menu/hand_menu.h b/cockatrice/src/game/player/menu/hand_menu.h
index 51e071a62..76434cc98 100644
--- a/cockatrice/src/game/player/menu/hand_menu.h
+++ b/cockatrice/src/game/player/menu/hand_menu.h
@@ -8,6 +8,7 @@
#define COCKATRICE_HAND_MENU_H
#include "../../../interface/widgets/menus/tearoff_menu.h"
+#include "abstract_player_component.h"
#include
#include
@@ -15,7 +16,7 @@
class Player;
class PlayerActions;
-class HandMenu : public TearOffMenu
+class HandMenu : public TearOffMenu, public AbstractPlayerComponent
{
Q_OBJECT
@@ -31,9 +32,9 @@ public:
return mRevealRandomHandCard;
}
- void retranslateUi();
- void setShortcutsActive();
- void setShortcutsInactive();
+ void retranslateUi() override;
+ void setShortcutsActive() override;
+ void setShortcutsInactive() override;
private slots:
void populateRevealHandMenuWithActivePlayers();
diff --git a/cockatrice/src/game/player/menu/library_menu.h b/cockatrice/src/game/player/menu/library_menu.h
index c0883107c..444e8f516 100644
--- a/cockatrice/src/game/player/menu/library_menu.h
+++ b/cockatrice/src/game/player/menu/library_menu.h
@@ -8,6 +8,7 @@
#define COCKATRICE_LIBRARY_MENU_H
#include "../../../interface/widgets/menus/tearoff_menu.h"
+#include "abstract_player_component.h"
#include
#include
@@ -15,7 +16,7 @@
class Player;
class PlayerActions;
-class LibraryMenu : public TearOffMenu
+class LibraryMenu : public TearOffMenu, public AbstractPlayerComponent
{
Q_OBJECT
public slots:
@@ -28,15 +29,15 @@ public:
void createShuffleActions();
void createMoveActions();
void createViewActions();
- void retranslateUi();
+ void retranslateUi() override;
void populateRevealLibraryMenuWithActivePlayers();
void populateLendLibraryMenuWithActivePlayers();
void populateRevealTopCardMenuWithActivePlayers();
void onRevealLibraryTriggered();
void onLendLibraryTriggered();
void onRevealTopCardTriggered();
- void setShortcutsActive();
- void setShortcutsInactive();
+ void setShortcutsActive() override;
+ void setShortcutsInactive() override;
[[nodiscard]] bool isAlwaysRevealTopCardChecked() const
{
diff --git a/cockatrice/src/game/player/menu/move_menu.cpp b/cockatrice/src/game/player/menu/move_menu.cpp
index d27e16009..91e2d8d10 100644
--- a/cockatrice/src/game/player/menu/move_menu.cpp
+++ b/cockatrice/src/game/player/menu/move_menu.cpp
@@ -11,6 +11,8 @@ MoveMenu::MoveMenu(Player *player) : QMenu(tr("Move to"))
aMoveToBottomLibrary = new QAction(this);
aMoveToBottomLibrary->setData(cmMoveToBottomLibrary);
aMoveToXfromTopOfLibrary = new QAction(this);
+ aMoveToTable = new QAction(this);
+ aMoveToTable->setData(cmMoveToTable);
aMoveToGraveyard = new QAction(this);
aMoveToHand = new QAction(this);
aMoveToHand->setData(cmMoveToHand);
@@ -22,6 +24,7 @@ MoveMenu::MoveMenu(Player *player) : QMenu(tr("Move to"))
connect(aMoveToBottomLibrary, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
connect(aMoveToXfromTopOfLibrary, &QAction::triggered, player->getPlayerActions(),
&PlayerActions::actMoveCardXCardsFromTop);
+ connect(aMoveToTable, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
connect(aMoveToHand, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
connect(aMoveToGraveyard, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
connect(aMoveToExile, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
@@ -30,6 +33,8 @@ MoveMenu::MoveMenu(Player *player) : QMenu(tr("Move to"))
addAction(aMoveToXfromTopOfLibrary);
addAction(aMoveToBottomLibrary);
addSeparator();
+ addAction(aMoveToTable);
+ addSeparator();
addAction(aMoveToHand);
addSeparator();
addAction(aMoveToGraveyard);
@@ -47,6 +52,7 @@ void MoveMenu::setShortcutsActive()
aMoveToTopLibrary->setShortcuts(shortcuts.getShortcut("Player/aMoveToTopLibrary"));
aMoveToBottomLibrary->setShortcuts(shortcuts.getShortcut("Player/aMoveToBottomLibrary"));
+ aMoveToTable->setShortcuts(shortcuts.getShortcut("Player/aMoveToTable"));
aMoveToHand->setShortcuts(shortcuts.getShortcut("Player/aMoveToHand"));
aMoveToGraveyard->setShortcuts(shortcuts.getShortcut("Player/aMoveToGraveyard"));
aMoveToExile->setShortcuts(shortcuts.getShortcut("Player/aMoveToExile"));
@@ -57,7 +63,8 @@ void MoveMenu::retranslateUi()
aMoveToTopLibrary->setText(tr("&Top of library in random order"));
aMoveToXfromTopOfLibrary->setText(tr("X cards from the top of library..."));
aMoveToBottomLibrary->setText(tr("&Bottom of library in random order"));
+ aMoveToTable->setText(tr("T&able"));
aMoveToHand->setText(tr("&Hand"));
aMoveToGraveyard->setText(tr("&Graveyard"));
aMoveToExile->setText(tr("&Exile"));
-}
\ No newline at end of file
+}
diff --git a/cockatrice/src/game/player/menu/move_menu.h b/cockatrice/src/game/player/menu/move_menu.h
index 5bf657fa4..dc39cb6a5 100644
--- a/cockatrice/src/game/player/menu/move_menu.h
+++ b/cockatrice/src/game/player/menu/move_menu.h
@@ -23,6 +23,7 @@ public:
QAction *aMoveToBottomLibrary = nullptr;
QAction *aMoveToHand = nullptr;
+ QAction *aMoveToTable = nullptr;
QAction *aMoveToGraveyard = nullptr;
QAction *aMoveToExile = nullptr;
};
diff --git a/cockatrice/src/game/player/menu/player_menu.cpp b/cockatrice/src/game/player/menu/player_menu.cpp
index 3016a727f..7786ec3fc 100644
--- a/cockatrice/src/game/player/menu/player_menu.cpp
+++ b/cockatrice/src/game/player/menu/player_menu.cpp
@@ -15,33 +15,24 @@ PlayerMenu::PlayerMenu(Player *_player) : player(_player)
playerMenu = new TearOffMenu();
if (player->getPlayerInfo()->getLocalOrJudge()) {
- handMenu = new HandMenu(player, player->getPlayerActions(), playerMenu);
- playerMenu->addMenu(handMenu);
-
- libraryMenu = new LibraryMenu(player, playerMenu);
- playerMenu->addMenu(libraryMenu);
+ handMenu = addManagedMenu(player, player->getPlayerActions(), playerMenu);
+ libraryMenu = addManagedMenu(player, playerMenu);
} else {
handMenu = nullptr;
libraryMenu = nullptr;
}
- graveMenu = new GraveyardMenu(player, playerMenu);
- playerMenu->addMenu(graveMenu);
-
- rfgMenu = new RfgMenu(player, playerMenu);
- playerMenu->addMenu(rfgMenu);
+ graveMenu = addManagedMenu(player, playerMenu);
+ rfgMenu = addManagedMenu(player, playerMenu);
if (player->getPlayerInfo()->getLocalOrJudge()) {
- sideboardMenu = new SideboardMenu(player, playerMenu);
- playerMenu->addMenu(sideboardMenu);
-
- customZonesMenu = new CustomZoneMenu(player);
- playerMenu->addMenu(customZonesMenu);
+ sideboardMenu = addManagedMenu(player, playerMenu);
+ customZonesMenu = addManagedMenu(player);
playerMenu->addSeparator();
countersMenu = playerMenu->addMenu(QString());
- utilityMenu = new UtilityMenu(player, playerMenu);
+ utilityMenu = createManagedComponent(player, playerMenu);
} else {
sideboardMenu = nullptr;
customZonesMenu = nullptr;
@@ -50,8 +41,7 @@ PlayerMenu::PlayerMenu(Player *_player) : player(_player)
}
if (player->getPlayerInfo()->getLocal()) {
- sayMenu = new SayMenu(player);
- playerMenu->addMenu(sayMenu);
+ sayMenu = addManagedMenu(player);
} else {
sayMenu = nullptr;
}
@@ -99,40 +89,18 @@ void PlayerMenu::retranslateUi()
{
playerMenu->setTitle(tr("Player \"%1\"").arg(player->getPlayerInfo()->getName()));
- if (handMenu) {
- handMenu->retranslateUi();
- }
- if (libraryMenu) {
- libraryMenu->retranslateUi();
- }
-
- graveMenu->retranslateUi();
- rfgMenu->retranslateUi();
-
- if (sideboardMenu) {
- sideboardMenu->retranslateUi();
+ for (auto *component : managedComponents) {
+ component->retranslateUi();
}
if (countersMenu) {
countersMenu->setTitle(tr("&Counters"));
}
- if (customZonesMenu) {
- customZonesMenu->retranslateUi();
- }
-
QMapIterator counterIterator(player->getCounters());
while (counterIterator.hasNext()) {
counterIterator.next().value()->retranslateUi();
}
-
- if (utilityMenu) {
- utilityMenu->retranslateUi();
- }
-
- if (sayMenu) {
- sayMenu->setTitle(tr("S&ay"));
- }
}
void PlayerMenu::refreshShortcuts()
@@ -153,52 +121,29 @@ void PlayerMenu::setShortcutsActive()
{
shortcutsActive = true;
- if (handMenu) {
- handMenu->setShortcutsActive();
- }
- if (libraryMenu) {
- libraryMenu->setShortcutsActive();
- }
- graveMenu->setShortcutsActive();
- // No shortcuts for RfgMenu yet
-
- if (sideboardMenu) {
- sideboardMenu->setShortcutsActive();
+ for (auto *component : managedComponents) {
+ component->setShortcutsActive();
}
+ // Counters implement AbstractPlayerComponent but are iterated via Player::counters
+ // (the authoritative source) rather than managedComponents to avoid a redundant
+ // list that must stay in sync with the map.
QMapIterator counterIterator(player->getCounters());
while (counterIterator.hasNext()) {
counterIterator.next().value()->setShortcutsActive();
}
-
- if (utilityMenu) {
- utilityMenu->setShortcutsActive();
- }
}
void PlayerMenu::setShortcutsInactive()
{
shortcutsActive = false;
- if (handMenu) {
- handMenu->setShortcutsInactive();
- }
- if (libraryMenu) {
- libraryMenu->setShortcutsInactive();
- }
- graveMenu->setShortcutsInactive();
- // No shortcuts for RfgMenu yet
-
- if (sideboardMenu) {
- sideboardMenu->setShortcutsInactive();
+ for (auto *component : managedComponents) {
+ component->setShortcutsInactive();
}
QMapIterator counterIterator(player->getCounters());
while (counterIterator.hasNext()) {
counterIterator.next().value()->setShortcutsInactive();
}
-
- if (utilityMenu) {
- utilityMenu->setShortcutsInactive();
- }
}
\ No newline at end of file
diff --git a/cockatrice/src/game/player/menu/player_menu.h b/cockatrice/src/game/player/menu/player_menu.h
index 882bfedc5..5fce27158 100644
--- a/cockatrice/src/game/player/menu/player_menu.h
+++ b/cockatrice/src/game/player/menu/player_menu.h
@@ -1,7 +1,7 @@
/**
* @file player_menu.h
* @ingroup GameMenusPlayers
- * @brief TODO: Document this.
+ * @brief Orchestrates lifecycle management for all player-bound UI components.
*/
#ifndef COCKATRICE_PLAYER_MENU_H
@@ -18,6 +18,7 @@
#include "sideboard_menu.h"
#include "utility_menu.h"
+#include
#include
#include
@@ -37,6 +38,7 @@ private slots:
public:
PlayerMenu(Player *player);
+ /// Lifecycle methods: delegate to all managedComponents, plus counters separately via player->getCounters().
void retranslateUi();
QMenu *updateCardMenu(const CardItem *card);
@@ -66,7 +68,9 @@ public:
return shortcutsActive;
}
+ /// Delegates to all managedComponents, plus counters separately.
void setShortcutsActive();
+ /// Delegates to all managedComponents, plus counters separately.
void setShortcutsInactive();
private:
@@ -82,9 +86,26 @@ private:
SayMenu *sayMenu;
CustomZoneMenu *customZonesMenu;
- bool shortcutsActive;
+ /// Drives AbstractPlayerComponent lifecycle delegation. Counters are iterated separately via player->getCounters().
+ QList managedComponents;
+ bool shortcutsActive = false;
- void initSayMenu();
+ /// Creates component, adds it as a submenu of playerMenu, and registers in managedComponents.
+ template MenuT *addManagedMenu(Args &&...args)
+ {
+ auto *menu = new MenuT(std::forward(args)...);
+ playerMenu->addMenu(menu);
+ managedComponents.append(menu);
+ return menu;
+ }
+
+ /// Creates component and registers in managedComponents, but does NOT add it as a submenu.
+ template ComponentT *createManagedComponent(Args &&...args)
+ {
+ auto *component = new ComponentT(std::forward(args)...);
+ managedComponents.append(component);
+ return component;
+ }
};
#endif // COCKATRICE_PLAYER_MENU_H
diff --git a/cockatrice/src/game/player/menu/rfg_menu.h b/cockatrice/src/game/player/menu/rfg_menu.h
index 0b4623d2a..8f79b2f4a 100644
--- a/cockatrice/src/game/player/menu/rfg_menu.h
+++ b/cockatrice/src/game/player/menu/rfg_menu.h
@@ -8,19 +8,26 @@
#define COCKATRICE_RFG_MENU_H
#include "../../../interface/widgets/menus/tearoff_menu.h"
+#include "abstract_player_component.h"
#include
#include
class Player;
-class RfgMenu : public TearOffMenu
+class RfgMenu : public TearOffMenu, public AbstractPlayerComponent
{
Q_OBJECT
public:
explicit RfgMenu(Player *player, QWidget *parent = nullptr);
void createMoveActions();
void createViewActions();
- void retranslateUi();
+ void retranslateUi() override;
+ void setShortcutsActive() override
+ {
+ }
+ void setShortcutsInactive() override
+ {
+ }
QMenu *moveRfgMenu = nullptr;
diff --git a/cockatrice/src/game/player/menu/say_menu.cpp b/cockatrice/src/game/player/menu/say_menu.cpp
index 3c4802aa5..116fba49a 100644
--- a/cockatrice/src/game/player/menu/say_menu.cpp
+++ b/cockatrice/src/game/player/menu/say_menu.cpp
@@ -8,6 +8,31 @@ SayMenu::SayMenu(Player *_player) : player(_player)
{
connect(&SettingsCache::instance().messages(), &MessageSettings::messageMacrosChanged, this, &SayMenu::initSayMenu);
initSayMenu();
+ retranslateUi();
+}
+
+void SayMenu::retranslateUi()
+{
+ setTitle(tr("S&ay"));
+}
+
+void SayMenu::setShortcutsActive()
+{
+ shortcutsActive = true;
+
+ const auto menuActions = actions();
+ for (int i = 0; i < menuActions.size() && i < 10; ++i) {
+ menuActions[i]->setShortcut(QKeySequence("Ctrl+" + QString::number((i + 1) % 10)));
+ }
+}
+
+void SayMenu::setShortcutsInactive()
+{
+ shortcutsActive = false;
+
+ for (auto *action : actions()) {
+ action->setShortcut(QKeySequence());
+ }
}
void SayMenu::initSayMenu()
@@ -19,10 +44,11 @@ void SayMenu::initSayMenu()
for (int i = 0; i < count; ++i) {
auto *newAction = new QAction(SettingsCache::instance().messages().getMessageAt(i), this);
- if (i < 10) {
- newAction->setShortcut(QKeySequence("Ctrl+" + QString::number((i + 1) % 10)));
- }
connect(newAction, &QAction::triggered, player->getPlayerActions(), &PlayerActions::actSayMessage);
addAction(newAction);
}
-}
\ No newline at end of file
+
+ if (shortcutsActive) {
+ setShortcutsActive();
+ }
+}
diff --git a/cockatrice/src/game/player/menu/say_menu.h b/cockatrice/src/game/player/menu/say_menu.h
index 5dbde2277..fadf5f368 100644
--- a/cockatrice/src/game/player/menu/say_menu.h
+++ b/cockatrice/src/game/player/menu/say_menu.h
@@ -7,18 +7,27 @@
#ifndef COCKATRICE_SAY_MENU_H
#define COCKATRICE_SAY_MENU_H
+#include "abstract_player_component.h"
+
#include
class Player;
-class SayMenu : public QMenu
+class SayMenu : public QMenu, public AbstractPlayerComponent
{
Q_OBJECT
public:
explicit SayMenu(Player *player);
+
+ void retranslateUi() override;
+ void setShortcutsActive() override;
+ void setShortcutsInactive() override;
+
+private slots:
void initSayMenu();
private:
Player *player;
+ bool shortcutsActive = false;
};
#endif // COCKATRICE_SAY_MENU_H
diff --git a/cockatrice/src/game/player/menu/sideboard_menu.h b/cockatrice/src/game/player/menu/sideboard_menu.h
index 22d5a2d69..4a77d1b52 100644
--- a/cockatrice/src/game/player/menu/sideboard_menu.h
+++ b/cockatrice/src/game/player/menu/sideboard_menu.h
@@ -7,18 +7,20 @@
#ifndef COCKATRICE_SIDEBOARD_MENU_H
#define COCKATRICE_SIDEBOARD_MENU_H
+#include "abstract_player_component.h"
+
#include
class Player;
-class SideboardMenu : public QMenu
+class SideboardMenu : public QMenu, public AbstractPlayerComponent
{
Q_OBJECT
public:
explicit SideboardMenu(Player *player, QMenu *playerMenu);
- void retranslateUi();
- void setShortcutsActive();
- void setShortcutsInactive();
+ void retranslateUi() override;
+ void setShortcutsActive() override;
+ void setShortcutsInactive() override;
private:
Player *player;
diff --git a/cockatrice/src/game/player/menu/utility_menu.h b/cockatrice/src/game/player/menu/utility_menu.h
index ff57e7252..f6577d7d1 100644
--- a/cockatrice/src/game/player/menu/utility_menu.h
+++ b/cockatrice/src/game/player/menu/utility_menu.h
@@ -7,17 +7,19 @@
#ifndef COCKATRICE_UTILITY_MENU_H
#define COCKATRICE_UTILITY_MENU_H
+#include "abstract_player_component.h"
+
#include
class Player;
-class UtilityMenu : public QMenu
+class UtilityMenu : public QMenu, public AbstractPlayerComponent
{
Q_OBJECT
public slots:
void populatePredefinedTokensMenu();
- void retranslateUi();
- void setShortcutsActive();
- void setShortcutsInactive();
+ void retranslateUi() override;
+ void setShortcutsActive() override;
+ void setShortcutsInactive() override;
public:
explicit UtilityMenu(Player *player, QMenu *playerMenu);
diff --git a/cockatrice/src/game/player/player_actions.cpp b/cockatrice/src/game/player/player_actions.cpp
index 287231402..ca0967636 100644
--- a/cockatrice/src/game/player/player_actions.cpp
+++ b/cockatrice/src/game/player/player_actions.cpp
@@ -64,7 +64,7 @@ void PlayerActions::playCard(CardItem *card, bool faceDown)
int tableRow = info.getUiAttributes().tableRow;
bool playToStack = SettingsCache::instance().getPlayToStack();
QString currentZone = card->getZone()->getName();
- if (currentZone == ZoneNames::STACK && tableRow == 3) {
+ if (!faceDown && currentZone == ZoneNames::STACK && tableRow == 3) {
cmd.set_target_zone(ZoneNames::GRAVE);
cmd.set_x(0);
cmd.set_y(0);
@@ -75,7 +75,7 @@ void PlayerActions::playCard(CardItem *card, bool faceDown)
cmd.set_y(0);
} else {
tableRow = faceDown ? 2 : info.getUiAttributes().tableRow;
- QPoint gridPoint = QPoint(-1, TableZone::clampValidTableRow(2 - tableRow));
+ QPoint gridPoint = QPoint(-1, TableZone::tableRowToGridY(tableRow));
cardToMove->set_face_down(faceDown);
if (!faceDown) {
cardToMove->set_pt(info.getPowTough().toStdString());
@@ -114,12 +114,7 @@ void PlayerActions::playCardToTable(const CardItem *card, bool faceDown)
const CardInfo &info = exactCard.getInfo();
int tableRow = faceDown ? 2 : info.getUiAttributes().tableRow;
- // default instant/sorcery cards to the noncreatures row
- if (tableRow > 2) {
- tableRow = 1;
- }
-
- QPoint gridPoint = QPoint(-1, TableZone::clampValidTableRow(2 - tableRow));
+ QPoint gridPoint = QPoint(-1, TableZone::tableRowToGridY(tableRow));
cardToMove->set_face_down(faceDown);
if (!faceDown) {
cardToMove->set_pt(info.getPowTough().toStdString());
@@ -866,7 +861,7 @@ void PlayerActions::actCreateToken()
ExactCard correctedCard = CardDatabaseManager::query()->guessCard({lastTokenInfo.name, lastTokenInfo.providerId});
if (correctedCard) {
lastTokenInfo.name = correctedCard.getName();
- lastTokenTableRow = TableZone::clampValidTableRow(2 - correctedCard.getInfo().getUiAttributes().tableRow);
+ lastTokenTableRow = TableZone::tableRowToGridY(correctedCard.getInfo().getUiAttributes().tableRow);
if (lastTokenInfo.pt.isEmpty()) {
lastTokenInfo.pt = correctedCard.getInfo().getPowTough();
}
@@ -917,7 +912,7 @@ void PlayerActions::setLastToken(CardInfoPtr cardInfo)
.providerId =
SettingsCache::instance().cardOverrides().getCardPreferenceOverride(cardInfo->getName())};
- lastTokenTableRow = TableZone::clampValidTableRow(2 - cardInfo->getUiAttributes().tableRow);
+ lastTokenTableRow = TableZone::tableRowToGridY(cardInfo->getUiAttributes().tableRow);
utilityMenu->setAndEnableCreateAnotherTokenAction(tr("C&reate another %1 token").arg(lastTokenInfo.name));
}
@@ -1085,9 +1080,7 @@ void PlayerActions::createCard(const CardItem *sourceCard,
return;
}
- // get the target token's location
- // TODO: Define this QPoint into its own function along with the one below
- QPoint gridPoint = QPoint(-1, TableZone::clampValidTableRow(2 - cardInfo->getUiAttributes().tableRow));
+ QPoint gridPoint = QPoint(-1, TableZone::tableRowToGridY(cardInfo->getUiAttributes().tableRow));
// create the token for the related card
Command_CreateToken cmd;
@@ -1930,6 +1923,34 @@ void PlayerActions::cardMenuAction()
commandList.append(cmd);
break;
}
+ case cmMoveToTable: {
+ // Each card needs its own command because table row, pt, and cipt vary per card
+ for (const auto &card : cardList) {
+ auto *cmd = new Command_MoveCard;
+ cmd->set_start_player_id(startPlayerId);
+ cmd->set_start_zone(startZone.toStdString());
+ cmd->set_target_player_id(player->getPlayerInfo()->getId());
+ cmd->set_target_zone(ZoneNames::TABLE);
+ cmd->set_x(-1);
+
+ CardToMove *ctm = cmd->mutable_cards_to_move()->add_card();
+ ctm->set_card_id(card->getId());
+ ctm->set_face_down(false);
+
+ int tableRow = 0;
+ ExactCard exactCard = card->getCard();
+ if (exactCard) {
+ const CardInfo &info = exactCard.getInfo();
+ tableRow = info.getUiAttributes().tableRow;
+ ctm->set_pt(info.getPowTough().toStdString());
+ ctm->set_tapped(info.getUiAttributes().cipt);
+ }
+
+ cmd->set_y(TableZone::tableRowToGridY(tableRow));
+ commandList.append(cmd);
+ }
+ break;
+ }
default:
break;
}
diff --git a/cockatrice/src/game/zones/table_zone.cpp b/cockatrice/src/game/zones/table_zone.cpp
index b6ac2150b..2a382fafe 100644
--- a/cockatrice/src/game/zones/table_zone.cpp
+++ b/cockatrice/src/game/zones/table_zone.cpp
@@ -382,3 +382,11 @@ int TableZone::clampValidTableRow(const int row)
return TABLEROWS - 1;
return row;
}
+
+int TableZone::tableRowToGridY(int tableRow)
+{
+ if (tableRow > 2) {
+ tableRow = 1;
+ }
+ return clampValidTableRow(2 - tableRow);
+}
diff --git a/cockatrice/src/game/zones/table_zone.h b/cockatrice/src/game/zones/table_zone.h
index 61eb48d7b..7a53a9eb4 100644
--- a/cockatrice/src/game/zones/table_zone.h
+++ b/cockatrice/src/game/zones/table_zone.h
@@ -151,6 +151,13 @@ public:
static int clampValidTableRow(const int row);
+ /**
+ * Converts a card's logical table row (0=creatures, 1=noncreatures, 2=lands)
+ * to the corresponding grid Y coordinate. Cards with tableRow > 2 (e.g.,
+ * instants/sorceries) default to the noncreatures row.
+ */
+ static int tableRowToGridY(int tableRow);
+
/**
Resizes the TableZone in case CardItems are within or
outside of the TableZone constraints.
diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_local_game_options.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_local_game_options.cpp
index a9adfd907..d2d291556 100644
--- a/cockatrice/src/interface/widgets/dialogs/dlg_local_game_options.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/dlg_local_game_options.cpp
@@ -28,8 +28,8 @@ DlgLocalGameOptions::DlgLocalGameOptions(QWidget *parent) : QDialog(parent)
startingLifeTotalLabel = new QLabel(tr("Starting life total:"), this);
startingLifeTotalEdit = new QSpinBox(this);
- startingLifeTotalEdit->setMinimum(1);
- startingLifeTotalEdit->setMaximum(99999);
+ startingLifeTotalEdit->setMinimum(-999999999);
+ startingLifeTotalEdit->setMaximum(999999999);
startingLifeTotalEdit->setValue(20);
startingLifeTotalLabel->setBuddy(startingLifeTotalEdit);
diff --git a/cockatrice/src/interface/widgets/general/display/banner_widget.cpp b/cockatrice/src/interface/widgets/general/display/banner_widget.cpp
index f03869a4d..5de5457ea 100644
--- a/cockatrice/src/interface/widgets/general/display/banner_widget.cpp
+++ b/cockatrice/src/interface/widgets/general/display/banner_widget.cpp
@@ -7,8 +7,8 @@
#include
#include
-BannerWidget::BannerWidget(QWidget *parent, const QString &text, Qt::Orientation orientation, int transparency)
- : QWidget(parent), gradientOrientation(orientation), transparency(qBound(0, transparency, 100))
+BannerWidget::BannerWidget(QWidget *parent, const QString &text, Qt::Orientation orientation, int transparency_)
+ : QWidget(parent), gradientOrientation(orientation), transparency(qBound(0, transparency_, 100))
{
auto layout = new QHBoxLayout(this);
@@ -18,7 +18,12 @@ BannerWidget::BannerWidget(QWidget *parent, const QString &text, Qt::Orientation
// Create the banner label and set properties
bannerLabel = new QLabel(text, this);
bannerLabel->setAlignment(Qt::AlignCenter);
- bannerLabel->setStyleSheet("font-size: 24px; font-weight: bold; color: white;");
+
+ QString textColor;
+ if (transparency > 50) {
+ textColor = " color: white;";
+ }
+ bannerLabel->setStyleSheet("font-size: 24px; font-weight: bold;" + textColor);
layout->addWidget(iconLabel);
layout->addWidget(bannerLabel);
diff --git a/doc/doxygen/theme b/doc/doxygen/theme
index 1f3620084..d52eafe3e 160000
--- a/doc/doxygen/theme
+++ b/doc/doxygen/theme
@@ -1 +1 @@
-Subproject commit 1f3620084ff75734ed192101acf40e9dff01d848
+Subproject commit d52eafe3e9303399fda15661f3d7bb8fe3d7eabc
diff --git a/libcockatrice_interfaces/libcockatrice/interfaces/interface_card_set_priority_controller.h b/libcockatrice_interfaces/libcockatrice/interfaces/interface_card_set_priority_controller.h
index 46a5897f7..b8fbbc74a 100644
--- a/libcockatrice_interfaces/libcockatrice/interfaces/interface_card_set_priority_controller.h
+++ b/libcockatrice_interfaces/libcockatrice/interfaces/interface_card_set_priority_controller.h
@@ -12,9 +12,9 @@ public:
virtual void setEnabled(QString shortName, bool enabled) = 0;
virtual void setIsKnown(QString shortName, bool isknown) = 0;
- virtual unsigned int getSortKey(QString shortName) = 0;
- virtual bool isEnabled(QString shortName) = 0;
- virtual bool isKnown(QString shortName) = 0;
+ virtual unsigned int getSortKey(QString shortName) const = 0;
+ virtual bool isEnabled(QString shortName) const = 0;
+ virtual bool isKnown(QString shortName) const = 0;
};
#endif // COCKATRICE_INTERFACE_CARD_SET_PRIORITY_CONTROLLER_H
diff --git a/libcockatrice_interfaces/libcockatrice/interfaces/noop_card_set_priority_controller.h b/libcockatrice_interfaces/libcockatrice/interfaces/noop_card_set_priority_controller.h
index 949ab5a91..e5027648c 100644
--- a/libcockatrice_interfaces/libcockatrice/interfaces/noop_card_set_priority_controller.h
+++ b/libcockatrice_interfaces/libcockatrice/interfaces/noop_card_set_priority_controller.h
@@ -16,15 +16,15 @@ public:
{
}
- unsigned int getSortKey(QString /* shortName */) override
+ unsigned int getSortKey(QString /* shortName */) const override
{
return 0;
}
- bool isEnabled(QString /* shortName */) override
+ bool isEnabled(QString /* shortName */) const override
{
return true;
}
- bool isKnown(QString /* shortName */) override
+ bool isKnown(QString /* shortName */) const override
{
return true;
}
diff --git a/libcockatrice_settings/libcockatrice/settings/card_database_settings.cpp b/libcockatrice_settings/libcockatrice/settings/card_database_settings.cpp
index 79738f1cd..26a91a4dd 100644
--- a/libcockatrice_settings/libcockatrice/settings/card_database_settings.cpp
+++ b/libcockatrice_settings/libcockatrice/settings/card_database_settings.cpp
@@ -20,17 +20,17 @@ void CardDatabaseSettings::setIsKnown(QString shortName, bool isknown)
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();
}
-bool CardDatabaseSettings::isEnabled(QString shortName)
+bool CardDatabaseSettings::isEnabled(QString shortName) const
{
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();
}
diff --git a/libcockatrice_settings/libcockatrice/settings/card_database_settings.h b/libcockatrice_settings/libcockatrice/settings/card_database_settings.h
index 9a176a99b..bb946ea80 100644
--- a/libcockatrice_settings/libcockatrice/settings/card_database_settings.h
+++ b/libcockatrice_settings/libcockatrice/settings/card_database_settings.h
@@ -22,9 +22,9 @@ public:
void setEnabled(QString shortName, bool enabled) override;
void setIsKnown(QString shortName, bool isknown) override;
- unsigned int getSortKey(QString shortName) override;
- bool isEnabled(QString shortName) override;
- bool isKnown(QString shortName) override;
+ unsigned int getSortKey(QString shortName) const override;
+ bool isEnabled(QString shortName) const override;
+ bool isKnown(QString shortName) const override;
private:
explicit CardDatabaseSettings(const QString &settingPath, QObject *parent = nullptr);
diff --git a/libcockatrice_settings/libcockatrice/settings/card_override_settings.cpp b/libcockatrice_settings/libcockatrice/settings/card_override_settings.cpp
index 894358be6..a61a4693b 100644
--- a/libcockatrice_settings/libcockatrice/settings/card_override_settings.cpp
+++ b/libcockatrice_settings/libcockatrice/settings/card_override_settings.cpp
@@ -15,7 +15,7 @@ void CardOverrideSettings::deleteCardPreferenceOverride(const QString &cardName)
deleteValue(cardName);
}
-QString CardOverrideSettings::getCardPreferenceOverride(const QString &cardName)
+QString CardOverrideSettings::getCardPreferenceOverride(const QString &cardName) const
{
return getValue(cardName).toString();
}
\ No newline at end of file
diff --git a/libcockatrice_settings/libcockatrice/settings/card_override_settings.h b/libcockatrice_settings/libcockatrice/settings/card_override_settings.h
index d5ee0287b..3d9db4e65 100644
--- a/libcockatrice_settings/libcockatrice/settings/card_override_settings.h
+++ b/libcockatrice_settings/libcockatrice/settings/card_override_settings.h
@@ -22,7 +22,7 @@ public:
void deleteCardPreferenceOverride(const QString &cardName);
- QString getCardPreferenceOverride(const QString &cardName);
+ QString getCardPreferenceOverride(const QString &cardName) const;
private:
explicit CardOverrideSettings(const QString &settingPath, QObject *parent = nullptr);
diff --git a/libcockatrice_settings/libcockatrice/settings/debug_settings.cpp b/libcockatrice_settings/libcockatrice/settings/debug_settings.cpp
index 084696dc1..5bf6eca30 100644
--- a/libcockatrice_settings/libcockatrice/settings/debug_settings.cpp
+++ b/libcockatrice_settings/libcockatrice/settings/debug_settings.cpp
@@ -11,22 +11,22 @@ DebugSettings::DebugSettings(const QString &settingPath, QObject *parent)
}
}
-bool DebugSettings::getShowCardId()
+bool DebugSettings::getShowCardId() const
{
return getValue("showCardId").toBool();
}
-bool DebugSettings::getLocalGameOnStartup()
+bool DebugSettings::getLocalGameOnStartup() const
{
return getValue("onStartup", "localgame").toBool();
}
-int DebugSettings::getLocalGamePlayerCount()
+int DebugSettings::getLocalGamePlayerCount() const
{
return getValue("playerCount", "localgame").toInt();
}
-QString DebugSettings::getDeckPathForPlayer(const QString &playerName)
+QString DebugSettings::getDeckPathForPlayer(const QString &playerName) const
{
return getValue(playerName, "localgame", "deck").toString();
}
\ No newline at end of file
diff --git a/libcockatrice_settings/libcockatrice/settings/debug_settings.h b/libcockatrice_settings/libcockatrice/settings/debug_settings.h
index 2087b16b3..30cdd5fa5 100644
--- a/libcockatrice_settings/libcockatrice/settings/debug_settings.h
+++ b/libcockatrice_settings/libcockatrice/settings/debug_settings.h
@@ -17,12 +17,12 @@ class DebugSettings : public SettingsManager
DebugSettings(const DebugSettings & /*other*/);
public:
- bool getShowCardId();
+ bool getShowCardId() const;
- bool getLocalGameOnStartup();
- int getLocalGamePlayerCount();
+ bool getLocalGameOnStartup() const;
+ int getLocalGamePlayerCount() const;
- QString getDeckPathForPlayer(const QString &playerName);
+ QString getDeckPathForPlayer(const QString &playerName) const;
};
#endif // DEBUG_SETTINGS_H
diff --git a/libcockatrice_settings/libcockatrice/settings/download_settings.cpp b/libcockatrice_settings/libcockatrice/settings/download_settings.cpp
index ad4b81ec5..66525a598 100644
--- a/libcockatrice_settings/libcockatrice/settings/download_settings.cpp
+++ b/libcockatrice_settings/libcockatrice/settings/download_settings.cpp
@@ -18,7 +18,7 @@ void DownloadSettings::setDownloadUrls(const QStringList &downloadURLs)
setValue(QVariant::fromValue(downloadURLs), "urls");
}
-QStringList DownloadSettings::getAllURLs()
+QStringList DownloadSettings::getAllURLs() const
{
return getValue("urls").toStringList();
}
diff --git a/libcockatrice_settings/libcockatrice/settings/download_settings.h b/libcockatrice_settings/libcockatrice/settings/download_settings.h
index ed3634ea1..b7442301e 100644
--- a/libcockatrice_settings/libcockatrice/settings/download_settings.h
+++ b/libcockatrice_settings/libcockatrice/settings/download_settings.h
@@ -19,7 +19,7 @@ class DownloadSettings : public SettingsManager
public:
explicit DownloadSettings(const QString &, QObject *);
- QStringList getAllURLs();
+ QStringList getAllURLs() const;
void setDownloadUrls(const QStringList &downloadURLs);
void resetToDefaultURLs();
};
diff --git a/libcockatrice_settings/libcockatrice/settings/game_filters_settings.cpp b/libcockatrice_settings/libcockatrice/settings/game_filters_settings.cpp
index e5db3010d..4f5bf52ee 100644
--- a/libcockatrice_settings/libcockatrice/settings/game_filters_settings.cpp
+++ b/libcockatrice_settings/libcockatrice/settings/game_filters_settings.cpp
@@ -8,11 +8,11 @@ GameFiltersSettings::GameFiltersSettings(const QString &settingPath, QObject *pa
{
}
-/*
+/**
* The game type might contain special characters, so to use it in
* 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();
}
@@ -22,7 +22,7 @@ void GameFiltersSettings::setHideBuddiesOnlyGames(bool hide)
setValue(hide, "hide_buddies_only_games");
}
-bool GameFiltersSettings::isHideBuddiesOnlyGames()
+bool GameFiltersSettings::isHideBuddiesOnlyGames() const
{
QVariant previous = getValue("hide_buddies_only_games");
return previous == QVariant() ? false : previous.toBool();
@@ -33,7 +33,7 @@ void GameFiltersSettings::setHideFullGames(bool hide)
setValue(hide, "hide_full_games");
}
-bool GameFiltersSettings::isHideFullGames()
+bool GameFiltersSettings::isHideFullGames() const
{
QVariant previous = getValue("hide_full_games");
return previous == QVariant() ? false : previous.toBool();
@@ -44,7 +44,7 @@ void GameFiltersSettings::setHideGamesThatStarted(bool hide)
setValue(hide, "hide_games_that_started");
}
-bool GameFiltersSettings::isHideGamesThatStarted()
+bool GameFiltersSettings::isHideGamesThatStarted() const
{
QVariant previous = getValue("hide_games_that_started");
return previous == QVariant() ? false : previous.toBool();
@@ -55,7 +55,7 @@ void GameFiltersSettings::setHidePasswordProtectedGames(bool hide)
setValue(hide, "hide_password_protected_games");
}
-bool GameFiltersSettings::isHidePasswordProtectedGames()
+bool GameFiltersSettings::isHidePasswordProtectedGames() const
{
QVariant previous = getValue("hide_password_protected_games");
return previous == QVariant() ? false : previous.toBool();
@@ -66,7 +66,7 @@ void GameFiltersSettings::setHideIgnoredUserGames(bool hide)
setValue(hide, "hide_ignored_user_games");
}
-bool GameFiltersSettings::isHideIgnoredUserGames()
+bool GameFiltersSettings::isHideIgnoredUserGames() const
{
QVariant previous = getValue("hide_ignored_user_games");
return previous == QVariant() ? true : previous.toBool();
@@ -77,7 +77,7 @@ void GameFiltersSettings::setHideNotBuddyCreatedGames(bool hide)
setValue(hide, "hide_not_buddy_created_games");
}
-bool GameFiltersSettings::isHideNotBuddyCreatedGames()
+bool GameFiltersSettings::isHideNotBuddyCreatedGames() const
{
QVariant previous = getValue("hide_not_buddy_created_games");
return previous == QVariant() ? false : previous.toBool();
@@ -88,7 +88,7 @@ void GameFiltersSettings::setHideOpenDecklistGames(bool hide)
setValue(hide, "hide_open_decklist_games");
}
-bool GameFiltersSettings::isHideOpenDecklistGames()
+bool GameFiltersSettings::isHideOpenDecklistGames() const
{
QVariant previous = getValue("hide_open_decklist_games");
return previous == QVariant() ? false : previous.toBool();
@@ -99,7 +99,7 @@ void GameFiltersSettings::setGameNameFilter(QString gameName)
setValue(gameName, "game_name_filter");
}
-QString GameFiltersSettings::getGameNameFilter()
+QString GameFiltersSettings::getGameNameFilter() const
{
return getValue("game_name_filter").toString();
}
@@ -109,7 +109,7 @@ void GameFiltersSettings::setCreatorNameFilters(QStringList creatorName)
setValue(creatorName, "creator_name_filter");
}
-QStringList GameFiltersSettings::getCreatorNameFilters()
+QStringList GameFiltersSettings::getCreatorNameFilters() const
{
return getValue("creator_name_filter").toStringList();
}
@@ -119,7 +119,7 @@ void GameFiltersSettings::setMinPlayers(int min)
setValue(min, "min_players");
}
-int GameFiltersSettings::getMinPlayers()
+int GameFiltersSettings::getMinPlayers() const
{
QVariant previous = getValue("min_players");
return previous == QVariant() ? 1 : previous.toInt();
@@ -130,7 +130,7 @@ void GameFiltersSettings::setMaxPlayers(int max)
setValue(max, "max_players");
}
-int GameFiltersSettings::getMaxPlayers()
+int GameFiltersSettings::getMaxPlayers() const
{
QVariant previous = getValue("max_players");
return previous == QVariant() ? 99 : previous.toInt();
@@ -141,7 +141,7 @@ void GameFiltersSettings::setMaxGameAge(const QTime &maxGameAge)
setValue(maxGameAge, "max_game_age_time");
}
-QTime GameFiltersSettings::getMaxGameAge()
+QTime GameFiltersSettings::getMaxGameAge() const
{
QVariant previous = getValue("max_game_age_time");
return previous.toTime();
@@ -157,7 +157,7 @@ void GameFiltersSettings::setGameHashedTypeEnabled(QString gametypeHASHED, bool
setValue(enabled, gametypeHASHED);
}
-bool GameFiltersSettings::isGameTypeEnabled(QString gametype)
+bool GameFiltersSettings::isGameTypeEnabled(QString gametype) const
{
QVariant previous = getValue("game_type/" + hashGameType(gametype));
return previous == QVariant() ? false : previous.toBool();
@@ -168,7 +168,7 @@ void GameFiltersSettings::setShowOnlyIfSpectatorsCanWatch(bool show)
setValue(show, "show_only_if_spectators_can_watch");
}
-bool GameFiltersSettings::isShowOnlyIfSpectatorsCanWatch()
+bool GameFiltersSettings::isShowOnlyIfSpectatorsCanWatch() const
{
QVariant previous = getValue("show_only_if_spectators_can_watch");
return previous == QVariant() ? false : previous.toBool();
@@ -179,7 +179,7 @@ void GameFiltersSettings::setShowSpectatorPasswordProtected(bool show)
setValue(show, "show_spectator_password_protected");
}
-bool GameFiltersSettings::isShowSpectatorPasswordProtected()
+bool GameFiltersSettings::isShowSpectatorPasswordProtected() const
{
QVariant previous = getValue("show_spectator_password_protected");
return previous == QVariant() ? false : previous.toBool();
@@ -190,7 +190,7 @@ void GameFiltersSettings::setShowOnlyIfSpectatorsCanChat(bool show)
setValue(show, "show_only_if_spectators_can_chat");
}
-bool GameFiltersSettings::isShowOnlyIfSpectatorsCanChat()
+bool GameFiltersSettings::isShowOnlyIfSpectatorsCanChat() const
{
QVariant previous = getValue("show_only_if_spectators_can_chat");
return previous == QVariant() ? false : previous.toBool();
@@ -201,7 +201,7 @@ void GameFiltersSettings::setShowOnlyIfSpectatorsCanSeeHands(bool show)
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");
return previous == QVariant() ? false : previous.toBool();
diff --git a/libcockatrice_settings/libcockatrice/settings/game_filters_settings.h b/libcockatrice_settings/libcockatrice/settings/game_filters_settings.h
index 45e9b7441..c0e60551a 100644
--- a/libcockatrice_settings/libcockatrice/settings/game_filters_settings.h
+++ b/libcockatrice_settings/libcockatrice/settings/game_filters_settings.h
@@ -16,23 +16,23 @@ class GameFiltersSettings : public SettingsManager
friend class SettingsCache;
public:
- bool isHideBuddiesOnlyGames();
- bool isHideFullGames();
- bool isHideGamesThatStarted();
- bool isHidePasswordProtectedGames();
- bool isHideIgnoredUserGames();
- bool isHideNotBuddyCreatedGames();
- bool isHideOpenDecklistGames();
- QString getGameNameFilter();
- QStringList getCreatorNameFilters();
- int getMinPlayers();
- int getMaxPlayers();
- QTime getMaxGameAge();
- bool isGameTypeEnabled(QString gametype);
- bool isShowOnlyIfSpectatorsCanWatch();
- bool isShowSpectatorPasswordProtected();
- bool isShowOnlyIfSpectatorsCanChat();
- bool isShowOnlyIfSpectatorsCanSeeHands();
+ bool isHideBuddiesOnlyGames() const;
+ bool isHideFullGames() const;
+ bool isHideGamesThatStarted() const;
+ bool isHidePasswordProtectedGames() const;
+ bool isHideIgnoredUserGames() const;
+ bool isHideNotBuddyCreatedGames() const;
+ bool isHideOpenDecklistGames() const;
+ QString getGameNameFilter() const;
+ QStringList getCreatorNameFilters() const;
+ int getMinPlayers() const;
+ int getMaxPlayers() const;
+ QTime getMaxGameAge() const;
+ bool isGameTypeEnabled(QString gametype) const;
+ bool isShowOnlyIfSpectatorsCanWatch() const;
+ bool isShowSpectatorPasswordProtected() const;
+ bool isShowOnlyIfSpectatorsCanChat() const;
+ bool isShowOnlyIfSpectatorsCanSeeHands() const;
void setHideBuddiesOnlyGames(bool hide);
void setHideIgnoredUserGames(bool hide);
@@ -56,8 +56,6 @@ public:
private:
explicit GameFiltersSettings(const QString &settingPath, QObject *parent = nullptr);
GameFiltersSettings(const GameFiltersSettings & /*other*/);
-
- [[nodiscard]] QString hashGameType(const QString &gameType) const;
};
#endif // GAMEFILTERSSETTINGS_H
diff --git a/libcockatrice_settings/libcockatrice/settings/layouts_settings.cpp b/libcockatrice_settings/libcockatrice/settings/layouts_settings.cpp
index f7704cbc7..e914dc2d8 100644
--- a/libcockatrice_settings/libcockatrice/settings/layouts_settings.cpp
+++ b/libcockatrice_settings/libcockatrice/settings/layouts_settings.cpp
@@ -23,12 +23,12 @@ void LayoutsSettings::setMainWindowGeometry(const QByteArray &value)
setValue(value, GEOMETRY_PROP, GROUP_MAIN_WINDOW);
}
-QByteArray LayoutsSettings::getMainWindowGeometry()
+QByteArray LayoutsSettings::getMainWindowGeometry() const
{
return getValue(GEOMETRY_PROP, GROUP_MAIN_WINDOW).toByteArray();
}
-QByteArray LayoutsSettings::getDeckEditorLayoutState()
+QByteArray LayoutsSettings::getDeckEditorLayoutState() const
{
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);
}
-QByteArray LayoutsSettings::getDeckEditorGeometry()
+QByteArray LayoutsSettings::getDeckEditorGeometry() const
{
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);
}
-QByteArray LayoutsSettings::getVisualDeckEditorLayoutState()
+QByteArray LayoutsSettings::getVisualDeckEditorLayoutState() const
{
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);
}
-QByteArray LayoutsSettings::getVisualDeckEditorGeometry()
+QByteArray LayoutsSettings::getVisualDeckEditorGeometry() const
{
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);
}
-QByteArray LayoutsSettings::getDeckEditorDbHeaderState()
+QByteArray LayoutsSettings::getDeckEditorDbHeaderState() const
{
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");
}
-QByteArray LayoutsSettings::getSetsDialogHeaderState()
+QByteArray LayoutsSettings::getSetsDialogHeaderState() const
{
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);
}
-QByteArray LayoutsSettings::getSetsDialogGeometry()
+QByteArray LayoutsSettings::getSetsDialogGeometry() const
{
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);
}
-QByteArray LayoutsSettings::getTokenDialogGeometry()
+QByteArray LayoutsSettings::getTokenDialogGeometry() const
{
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);
}
-QByteArray LayoutsSettings::getGamePlayAreaLayoutState()
+QByteArray LayoutsSettings::getGamePlayAreaLayoutState() const
{
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();
}
@@ -138,12 +138,12 @@ void LayoutsSettings::setReplayPlayAreaState(const QByteArray &value)
setValue(value, STATE_PROP, GROUP_REPLAY_PLAY_AREA);
}
-QByteArray LayoutsSettings::getReplayPlayAreaLayoutState()
+QByteArray LayoutsSettings::getReplayPlayAreaLayoutState() const
{
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();
}
diff --git a/libcockatrice_settings/libcockatrice/settings/layouts_settings.h b/libcockatrice_settings/libcockatrice/settings/layouts_settings.h
index cab9a456e..5353ce15a 100644
--- a/libcockatrice_settings/libcockatrice/settings/layouts_settings.h
+++ b/libcockatrice_settings/libcockatrice/settings/layouts_settings.h
@@ -36,24 +36,24 @@ public:
void setReplayPlayAreaGeometry(const QByteArray &value);
void setReplayPlayAreaState(const QByteArray &value);
- QByteArray getMainWindowGeometry();
+ QByteArray getMainWindowGeometry() const;
- QByteArray getDeckEditorLayoutState();
- QByteArray getDeckEditorGeometry();
+ QByteArray getDeckEditorLayoutState() const;
+ QByteArray getDeckEditorGeometry() const;
- QByteArray getVisualDeckEditorLayoutState();
- QByteArray getVisualDeckEditorGeometry();
+ QByteArray getVisualDeckEditorLayoutState() const;
+ QByteArray getVisualDeckEditorGeometry() const;
- QByteArray getDeckEditorDbHeaderState();
- QByteArray getSetsDialogHeaderState();
- QByteArray getSetsDialogGeometry();
- QByteArray getTokenDialogGeometry();
+ QByteArray getDeckEditorDbHeaderState() const;
+ QByteArray getSetsDialogHeaderState() const;
+ QByteArray getSetsDialogGeometry() const;
+ QByteArray getTokenDialogGeometry() const;
- QByteArray getGamePlayAreaLayoutState();
- QByteArray getGamePlayAreaGeometry();
+ QByteArray getGamePlayAreaLayoutState() const;
+ QByteArray getGamePlayAreaGeometry() const;
- QByteArray getReplayPlayAreaLayoutState();
- QByteArray getReplayPlayAreaGeometry();
+ QByteArray getReplayPlayAreaLayoutState() const;
+ QByteArray getReplayPlayAreaGeometry() const;
signals:
public slots:
diff --git a/libcockatrice_settings/libcockatrice/settings/message_settings.cpp b/libcockatrice_settings/libcockatrice/settings/message_settings.cpp
index 761c94484..50da39df6 100644
--- a/libcockatrice_settings/libcockatrice/settings/message_settings.cpp
+++ b/libcockatrice_settings/libcockatrice/settings/message_settings.cpp
@@ -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();
}
-int MessageSettings::getCount()
+int MessageSettings::getCount() const
{
return getValue("count").toInt();
}
diff --git a/libcockatrice_settings/libcockatrice/settings/message_settings.h b/libcockatrice_settings/libcockatrice/settings/message_settings.h
index 265c455e1..ec70027af 100644
--- a/libcockatrice_settings/libcockatrice/settings/message_settings.h
+++ b/libcockatrice_settings/libcockatrice/settings/message_settings.h
@@ -15,8 +15,8 @@ class MessageSettings : public SettingsManager
friend class SettingsCache;
public:
- int getCount();
- QString getMessageAt(int index);
+ int getCount() const;
+ QString getMessageAt(int index) const;
void setCount(int count);
void setMessageAt(int index, QString message);
diff --git a/libcockatrice_settings/libcockatrice/settings/recents_settings.cpp b/libcockatrice_settings/libcockatrice/settings/recents_settings.cpp
index e64dd7494..76bc4069e 100644
--- a/libcockatrice_settings/libcockatrice/settings/recents_settings.cpp
+++ b/libcockatrice_settings/libcockatrice/settings/recents_settings.cpp
@@ -7,7 +7,7 @@ RecentsSettings::RecentsSettings(const QString &settingPath, QObject *parent)
{
}
-QStringList RecentsSettings::getRecentlyOpenedDeckPaths()
+QStringList RecentsSettings::getRecentlyOpenedDeckPaths() const
{
return getValue("deckpaths").toStringList();
}
@@ -31,7 +31,7 @@ void RecentsSettings::updateRecentlyOpenedDeckPaths(const QString &deckPath)
emit recentlyOpenedDeckPathsChanged();
}
-QString RecentsSettings::getLatestDeckDirPath()
+QString RecentsSettings::getLatestDeckDirPath() const
{
return getValue("latestDeckDir", "dirs").toString();
}
diff --git a/libcockatrice_settings/libcockatrice/settings/recents_settings.h b/libcockatrice_settings/libcockatrice/settings/recents_settings.h
index 23c8f1a9f..3aebff334 100644
--- a/libcockatrice_settings/libcockatrice/settings/recents_settings.h
+++ b/libcockatrice_settings/libcockatrice/settings/recents_settings.h
@@ -18,11 +18,11 @@ class RecentsSettings : public SettingsManager
RecentsSettings(const RecentsSettings & /*other*/);
public:
- QStringList getRecentlyOpenedDeckPaths();
+ QStringList getRecentlyOpenedDeckPaths() const;
void clearRecentlyOpenedDeckPaths();
void updateRecentlyOpenedDeckPaths(const QString &deckPath);
- QString getLatestDeckDirPath();
+ QString getLatestDeckDirPath() const;
void setLatestDeckDirPath(const QString &dirPath);
signals:
diff --git a/libcockatrice_settings/libcockatrice/settings/servers_settings.cpp b/libcockatrice_settings/libcockatrice/settings/servers_settings.cpp
index 5f69f47c9..0140182be 100644
--- a/libcockatrice_settings/libcockatrice/settings/servers_settings.cpp
+++ b/libcockatrice_settings/libcockatrice/settings/servers_settings.cpp
@@ -13,7 +13,7 @@ void ServersSettings::setPreviousHostLogin(int previous)
setValue(previous, "previoushostlogin");
}
-int ServersSettings::getPreviousHostLogin()
+int ServersSettings::getPreviousHostLogin() const
{
QVariant previous = getValue("previoushostlogin");
return previous == QVariant() ? 1 : previous.toInt();
@@ -24,7 +24,7 @@ void ServersSettings::setPreviousHostList(QStringList list)
setValue(list, "previoushosts");
}
-QStringList ServersSettings::getPreviousHostList()
+QStringList ServersSettings::getPreviousHostList() const
{
return getValue("previoushosts").toStringList();
}
@@ -48,13 +48,13 @@ QString ServersSettings::getSite(QString defaultSite)
return site == QVariant() ? std::move(defaultSite) : site.toString();
}
-QString ServersSettings::getPrevioushostName()
+QString ServersSettings::getPrevioushostName() const
{
QVariant value = getValue("previoushostName");
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();
@@ -65,14 +65,14 @@ int ServersSettings::getPrevioushostindex(const QString &saveName)
return -1;
}
-QString ServersSettings::getHostname(QString defaultHost)
+QString ServersSettings::getHostname(QString defaultHost) const
{
int index = getPrevioushostindex(getPrevioushostName());
QVariant hostname = getValue(QString("server%1").arg(index), "server", "server_details");
return hostname == QVariant() ? std::move(defaultHost) : hostname.toString();
}
-QString ServersSettings::getPort(QString defaultPort)
+QString ServersSettings::getPort(QString defaultPort) const
{
int index = getPrevioushostindex(getPrevioushostName());
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();
}
-QString ServersSettings::getPlayerName(QString defaultName)
+QString ServersSettings::getPlayerName(QString defaultName) const
{
int index = getPrevioushostindex(getPrevioushostName());
QVariant name = getValue(QString("username%1").arg(index), "server", "server_details");
@@ -98,7 +98,7 @@ QString ServersSettings::getPassword()
return QString();
}
-bool ServersSettings::getSavePassword()
+bool ServersSettings::getSavePassword() const
{
int index = getPrevioushostindex(getPrevioushostName());
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");
}
-int ServersSettings::getAutoConnect()
+int ServersSettings::getAutoConnect() const
{
QVariant autoconnect = getValue("auto_connect");
return autoconnect == QVariant() ? 0 : autoconnect.toInt();
@@ -121,7 +121,7 @@ void ServersSettings::setFPHostName(QString hostname)
setValue(hostname, "fphostname");
}
-QString ServersSettings::getFPHostname(QString defaultHost)
+QString ServersSettings::getFPHostname(QString defaultHost) const
{
QVariant hostname = getValue("fphostname");
return hostname == QVariant() ? std::move(defaultHost) : hostname.toString();
@@ -132,7 +132,7 @@ void ServersSettings::setFPPort(QString port)
setValue(port, "fpport");
}
-QString ServersSettings::getFPPort(QString defaultPort)
+QString ServersSettings::getFPPort(QString defaultPort) const
{
QVariant port = getValue("fpport");
return port == QVariant() ? std::move(defaultPort) : port.toString();
@@ -143,7 +143,7 @@ void ServersSettings::setFPPlayerName(QString playerName)
setValue(playerName, "fpplayername");
}
-QString ServersSettings::getFPPlayerName(QString defaultName)
+QString ServersSettings::getFPPlayerName(QString defaultName) const
{
QVariant name = getValue("fpplayername");
return name == QVariant() ? std::move(defaultName) : name.toString();
@@ -154,7 +154,7 @@ void ServersSettings::setClearDebugLogStatus(bool abIsChecked)
setValue(abIsChecked, "save_debug_log");
}
-bool ServersSettings::getClearDebugLogStatus(bool abDefaultValue)
+bool ServersSettings::getClearDebugLogStatus(bool abDefaultValue) const
{
QVariant cbFlushLog = getValue("save_debug_log");
return cbFlushLog == QVariant() ? abDefaultValue : cbFlushLog.toBool();
diff --git a/libcockatrice_settings/libcockatrice/settings/servers_settings.h b/libcockatrice_settings/libcockatrice/settings/servers_settings.h
index 4d92c4647..22603a356 100644
--- a/libcockatrice_settings/libcockatrice/settings/servers_settings.h
+++ b/libcockatrice_settings/libcockatrice/settings/servers_settings.h
@@ -22,21 +22,21 @@ class ServersSettings : public SettingsManager
friend class SettingsCache;
public:
- int getPreviousHostLogin();
- int getPrevioushostindex(const QString &);
- QStringList getPreviousHostList();
- QString getPrevioushostName();
- QString getHostname(QString defaultHost = SERVERSETTINGS_DEFAULT_HOST);
- QString getPort(QString defaultPort = SERVERSETTINGS_DEFAULT_PORT);
- QString getPlayerName(QString defaultName = "");
- QString getFPHostname(QString defaultHost = SERVERSETTINGS_DEFAULT_HOST);
- QString getFPPort(QString defaultPort = SERVERSETTINGS_DEFAULT_PORT);
- QString getFPPlayerName(QString defaultName = "");
+ int getPreviousHostLogin() const;
+ int getPrevioushostindex(const QString &) const;
+ QStringList getPreviousHostList() const;
+ QString getPrevioushostName() const;
+ QString getHostname(QString defaultHost = SERVERSETTINGS_DEFAULT_HOST) const;
+ QString getPort(QString defaultPort = SERVERSETTINGS_DEFAULT_PORT) const;
+ QString getPlayerName(QString defaultName = "") const;
+ QString getFPHostname(QString defaultHost = SERVERSETTINGS_DEFAULT_HOST) const;
+ QString getFPPort(QString defaultPort = SERVERSETTINGS_DEFAULT_PORT) const;
+ QString getFPPlayerName(QString defaultName = "") const;
QString getPassword();
QString getSaveName(QString defaultname = "");
QString getSite(QString defaultName = "");
- bool getSavePassword();
- int getAutoConnect();
+ bool getSavePassword() const;
+ int getAutoConnect() const;
void setPreviousHostLogin(int previous);
void setPrevioushostName(const QString &);
@@ -67,7 +67,7 @@ public:
QString port = QString(),
QString site = QString());
void setClearDebugLogStatus(bool abIsChecked);
- bool getClearDebugLogStatus(bool abDefaultValue);
+ bool getClearDebugLogStatus(bool abDefaultValue) const;
private:
explicit ServersSettings(const QString &settingPath, QObject *parent = nullptr);
diff --git a/libcockatrice_settings/libcockatrice/settings/settings_manager.cpp b/libcockatrice_settings/libcockatrice/settings/settings_manager.cpp
index ede5a2027..2d4f1c441 100644
--- a/libcockatrice_settings/libcockatrice/settings/settings_manager.cpp
+++ b/libcockatrice_settings/libcockatrice/settings/settings_manager.cpp
@@ -1,16 +1,22 @@
#include "settings_manager.h"
-SettingsManager::SettingsManager(const QString &settingPath,
+SettingsManager::SettingsManager(const QString &_settingPath,
const QString &_defaultGroup,
const QString &_defaultSubGroup,
QObject *parent)
- : QObject(parent), settings(settingPath, QSettings::IniFormat), defaultGroup(_defaultGroup),
- defaultSubGroup(_defaultSubGroup)
+ : QObject(parent), settingPath(_settingPath), defaultGroup(_defaultGroup), defaultSubGroup(_defaultSubGroup)
{
}
+QSettings SettingsManager::getSettings() const
+{
+ return QSettings(settingPath, QSettings::IniFormat);
+}
+
void SettingsManager::setValue(const QVariant &value, const QString &name)
{
+ auto settings = getSettings();
+
if (!defaultGroup.isEmpty()) {
settings.beginGroup(defaultGroup);
}
@@ -35,6 +41,8 @@ void SettingsManager::setValue(const QVariant &value,
const QString &group,
const QString &subGroup)
{
+ auto settings = getSettings();
+
if (!group.isEmpty()) {
settings.beginGroup(group);
}
@@ -56,6 +64,8 @@ void SettingsManager::setValue(const QVariant &value,
void SettingsManager::deleteValue(const QString &name)
{
+ auto settings = getSettings();
+
if (!defaultGroup.isEmpty()) {
settings.beginGroup(defaultGroup);
}
@@ -77,6 +87,8 @@ void SettingsManager::deleteValue(const QString &name)
void SettingsManager::deleteValue(const QString &name, const QString &group, const QString &subGroup)
{
+ auto settings = getSettings();
+
if (!group.isEmpty()) {
settings.beginGroup(group);
}
@@ -96,8 +108,10 @@ 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();
+
if (!defaultGroup.isEmpty()) {
settings.beginGroup(defaultGroup);
}
@@ -119,8 +133,10 @@ QVariant SettingsManager::getValue(const QString &name)
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();
+
if (!group.isEmpty()) {
settings.beginGroup(group);
}
@@ -147,5 +163,7 @@ QVariant SettingsManager::getValue(const QString &name, const QString &group, co
*/
void SettingsManager::sync()
{
+ auto settings = getSettings();
+
settings.sync();
}
\ No newline at end of file
diff --git a/libcockatrice_settings/libcockatrice/settings/settings_manager.h b/libcockatrice_settings/libcockatrice/settings/settings_manager.h
index 3592d8f8c..ad828f089 100644
--- a/libcockatrice_settings/libcockatrice/settings/settings_manager.h
+++ b/libcockatrice_settings/libcockatrice/settings/settings_manager.h
@@ -19,14 +19,17 @@ public:
const QString &defaultGroup = QString(),
const QString &defaultSubGroup = QString(),
QObject *parent = nullptr);
- QVariant getValue(const QString &name);
- QVariant getValue(const QString &name, const QString &group, const QString &subGroup = QString());
+ QVariant getValue(const QString &name) const;
+ QVariant getValue(const QString &name, const QString &group, const QString &subGroup = QString()) const;
void sync();
protected:
- QSettings settings;
+ QString settingPath;
QString defaultGroup;
QString defaultSubGroup;
+
+ QSettings getSettings() const;
+
void setValue(const QVariant &value, const QString &name);
void
setValue(const QVariant &value, const QString &name, const QString &group, const QString &subGroup = QString());
diff --git a/libcockatrice_utility/libcockatrice/utility/peglib.h b/libcockatrice_utility/libcockatrice/utility/peglib.h
index 6a5b87b2d..3ae6040c4 100644
--- a/libcockatrice_utility/libcockatrice/utility/peglib.h
+++ b/libcockatrice_utility/libcockatrice/utility/peglib.h
@@ -1,4 +1,4 @@
-//
+//
// peglib.h
//
// Copyright (c) 2022 Yuji Hirose. All rights reserved.
@@ -17,6 +17,7 @@
#include
#include
+#include
#include
#include
#if __has_include()
@@ -30,6 +31,7 @@
#include