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);
}
void SettingsCache::setTallyType(TallyType value)
void SettingsCache::setTallyType(int value)
{
tallyType = static_cast<int>(value);
settings->setValue("interface/tallyType", tallyType);
if (tallyType == value) {
return;
}
tallyType = value;
settings->setValue("interface/tallyType", value);
emit tallyTypeChanged(value);
}

View file

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

View file

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

View file

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

View file

@ -2,6 +2,16 @@
#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)
{
switch (type) {

View file

@ -25,6 +25,14 @@ enum class TallyType
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.
* This forwards the cards to the code for that tally type.