update settings

This commit is contained in:
RickyRister 2026-07-22 23:56:22 -07:00
parent 6fd1248453
commit e0eb3278c9
6 changed files with 32 additions and 11 deletions

View file

@ -1396,10 +1396,14 @@ void SettingsCache::setShowTotalSelectionCount(QT_STATE_CHANGED_T _showTotalSele
settings->setValue("interface/showpersistentselectioncount", showTotalSelectionCount); settings->setValue("interface/showpersistentselectioncount", showTotalSelectionCount);
} }
void SettingsCache::setTallyType(TallyType value) void SettingsCache::setTallyType(int value)
{ {
tallyType = static_cast<int>(value); if (tallyType == value) {
settings->setValue("interface/tallyType", tallyType); return;
}
tallyType = value;
settings->setValue("interface/tallyType", value);
emit tallyTypeChanged(value); emit tallyTypeChanged(value);
} }

View file

@ -7,7 +7,6 @@
#ifndef SETTINGSCACHE_H #ifndef SETTINGSCACHE_H
#define SETTINGSCACHE_H #define SETTINGSCACHE_H
#include "../../game_graphics/tally/tally.h"
#include "../../interface/card_picture_loader/card_picture_loader_cache_method.h" #include "../../interface/card_picture_loader/card_picture_loader_cache_method.h"
#include "../../interface/card_picture_loader/card_picture_loader_local_schemes.h" #include "../../interface/card_picture_loader/card_picture_loader_local_schemes.h"
#include "shortcuts_settings.h" #include "shortcuts_settings.h"
@ -198,7 +197,7 @@ signals:
void useTearOffMenusChanged(bool state); void useTearOffMenusChanged(bool state);
void roundCardCornersChanged(bool roundCardCorners); void roundCardCornersChanged(bool roundCardCorners);
void keepGameChatFocusChanged(bool value); void keepGameChatFocusChanged(bool value);
void tallyTypeChanged(TallyType type); void tallyTypeChanged(int type);
private: private:
QSettings *settings; QSettings *settings;
@ -481,9 +480,9 @@ public:
{ {
return showTotalSelectionCount; return showTotalSelectionCount;
} }
[[nodiscard]] TallyType getTallyType() const [[nodiscard]] int getTallyType() const
{ {
return static_cast<TallyType>(tallyType); return tallyType;
} }
[[nodiscard]] bool getNotificationsEnabled() const [[nodiscard]] bool getNotificationsEnabled() const
{ {
@ -1183,6 +1182,6 @@ public slots:
void setRoundCardCorners(bool _roundCardCorners); void setRoundCardCorners(bool _roundCardCorners);
void setShowDragSelectionCount(QT_STATE_CHANGED_T _showDragSelectionCount); void setShowDragSelectionCount(QT_STATE_CHANGED_T _showDragSelectionCount);
void setShowTotalSelectionCount(QT_STATE_CHANGED_T _showTotalSelectionCount); void setShowTotalSelectionCount(QT_STATE_CHANGED_T _showTotalSelectionCount);
void setTallyType(TallyType value); void setTallyType(int value);
}; };
#endif #endif

View file

@ -248,7 +248,7 @@ void GameView::updateTotalSelectionCount(const QSize &viewSize)
totalCountLabel->show(); totalCountLabel->show();
} }
TallyType tallyType = SettingsCache::instance().getTallyType(); TallyType tallyType = Tally::intToType(SettingsCache::instance().getTallyType());
GameScene *gameScene = static_cast<GameScene *>(scene()); GameScene *gameScene = static_cast<GameScene *>(scene());
QList<TallyRow> entries = Tally::compute(gameScene->selectedCards(), tallyType); QList<TallyRow> entries = Tally::compute(gameScene->selectedCards(), tallyType);

View file

@ -21,14 +21,14 @@ TallyMenu::TallyMenu()
QAction *TallyMenu::createTallyAction(TallyType tallyType) QAction *TallyMenu::createTallyAction(TallyType tallyType)
{ {
TallyType currentType = SettingsCache::instance().getTallyType(); TallyType currentType = Tally::intToType(SettingsCache::instance().getTallyType());
QAction *action = new QAction(this); QAction *action = new QAction(this);
action->setCheckable(true); action->setCheckable(true);
action->setChecked(tallyType == currentType); action->setChecked(tallyType == currentType);
connect(action, &QAction::triggered, &SettingsCache::instance(), connect(action, &QAction::triggered, &SettingsCache::instance(),
[tallyType] { SettingsCache::instance().setTallyType(tallyType); }); [tallyType] { SettingsCache::instance().setTallyType(static_cast<int>(tallyType)); });
actionGroup->addAction(action); actionGroup->addAction(action);

View file

@ -2,6 +2,16 @@
#include "subtype_tally.h" #include "subtype_tally.h"
TallyType Tally::intToType(int value)
{
// remember to change this whenever you add a new member
if (value < static_cast<int>(TallyType::None) || value >= static_cast<int>(TallyType::Subtypes)) {
return TallyType::None;
}
return static_cast<TallyType>(value);
}
QList<TallyRow> Tally::compute(const QList<CardItem *> &cards, const TallyType type) QList<TallyRow> Tally::compute(const QList<CardItem *> &cards, const TallyType type)
{ {
switch (type) { switch (type) {

View file

@ -25,6 +25,14 @@ enum class TallyType
namespace Tally namespace Tally
{ {
/**
* Safely converts an int into the corresponding TallyType.
*
* @param value The int value
* @return The TallyType. Returns TallyType::None if the value is not within range
*/
TallyType intToType(int value);
/** /**
* @brief Analyzes the selected cards according to the tally type and builds the resulting tally rows. * @brief Analyzes the selected cards according to the tally type and builds the resulting tally rows.
* This forwards the cards to the code for that tally type. * This forwards the cards to the code for that tally type.