Don't use Qt pointers.

Took 1 hour 7 minutes
This commit is contained in:
Lukas Brübach 2025-11-07 13:23:46 +01:00
parent 930e4ae98d
commit fc6ffffcb9
125 changed files with 764 additions and 813 deletions

View file

@ -22,7 +22,7 @@
SpoilerBackgroundUpdater::SpoilerBackgroundUpdater(QObject *apParent) : QObject(apParent), cardUpdateProcess(nullptr) SpoilerBackgroundUpdater::SpoilerBackgroundUpdater(QObject *apParent) : QObject(apParent), cardUpdateProcess(nullptr)
{ {
isSpoilerDownloadEnabled = SettingsCache::instance()->getDownloadSpoilersStatus(); isSpoilerDownloadEnabled = SettingsCache::instance().getDownloadSpoilersStatus();
if (isSpoilerDownloadEnabled) { if (isSpoilerDownloadEnabled) {
// Start the process of checking if we're in spoiler season // Start the process of checking if we're in spoiler season
// File exists means we're in spoiler season // File exists means we're in spoiler season
@ -74,7 +74,7 @@ void SpoilerBackgroundUpdater::actDownloadFinishedSpoilersFile()
bool SpoilerBackgroundUpdater::deleteSpoilerFile() bool SpoilerBackgroundUpdater::deleteSpoilerFile()
{ {
QString fileName = SettingsCache::instance()->getSpoilerCardDatabasePath(); QString fileName = SettingsCache::instance().getSpoilerCardDatabasePath();
QFileInfo fi(fileName); QFileInfo fi(fileName);
QDir fileDir(fi.path()); QDir fileDir(fi.path());
QFile file(fileName); QFile file(fileName);
@ -125,7 +125,7 @@ void SpoilerBackgroundUpdater::actCheckIfSpoilerSeasonEnabled()
bool SpoilerBackgroundUpdater::saveDownloadedFile(QByteArray data) bool SpoilerBackgroundUpdater::saveDownloadedFile(QByteArray data)
{ {
QString fileName = SettingsCache::instance()->getSpoilerCardDatabasePath(); QString fileName = SettingsCache::instance().getSpoilerCardDatabasePath();
QFileInfo fi(fileName); QFileInfo fi(fileName);
QDir fileDir(fi.path()); QDir fileDir(fi.path());

View file

@ -9,7 +9,7 @@ ClientUpdateChecker::ClientUpdateChecker(QObject *parent) : QObject(parent)
void ClientUpdateChecker::check() void ClientUpdateChecker::check()
{ {
auto releaseChannel = SettingsCache::instance()->getUpdateReleaseChannel(); auto releaseChannel = SettingsCache::instance().getUpdateReleaseChannel();
finishedCheckConnection = finishedCheckConnection =
connect(releaseChannel, &ReleaseChannel::finishedCheck, this, &ClientUpdateChecker::actFinishedCheck); connect(releaseChannel, &ReleaseChannel::finishedCheck, this, &ClientUpdateChecker::actFinishedCheck);

View file

@ -14,19 +14,11 @@
#include <libcockatrice/settings/card_override_settings.h> #include <libcockatrice/settings/card_override_settings.h>
#include <utility> #include <utility>
QSharedPointer<SettingsCache> SettingsCache::settingsInstance = nullptr; Q_GLOBAL_STATIC(SettingsCache, settingsCache)
QSharedPointer<SettingsCache> SettingsCache::instance() SettingsCache &SettingsCache::instance()
{ {
if (!settingsInstance) { return *settingsCache; // returns a QT managed singleton reference
settingsInstance.reset(new SettingsCache()); // default real instance
}
return settingsInstance;
}
void SettingsCache::setInstance(QSharedPointer<SettingsCache> newInstance)
{
settingsInstance = newInstance;
} }
QString SettingsCache::getDataPath() QString SettingsCache::getDataPath()
@ -184,7 +176,7 @@ SettingsCache::SettingsCache()
QString settingsPath = getSettingsPath(); QString settingsPath = getSettingsPath();
settings = new QSettings(settingsPath + "global.ini", QSettings::IniFormat, this); settings = new QSettings(settingsPath + "global.ini", QSettings::IniFormat, this);
shortcutsSettings = new ShortcutsSettings(settingsPath, this); shortcutsSettings = new ShortcutsSettings(settingsPath, this);
cardDatabaseSettings = QSharedPointer<CardDatabaseSettings>(new CardDatabaseSettings(settingsPath, this)); cardDatabaseSettings = new CardDatabaseSettings(settingsPath, this);
serversSettings = new ServersSettings(settingsPath, this); serversSettings = new ServersSettings(settingsPath, this);
messageSettings = new MessageSettings(settingsPath, this); messageSettings = new MessageSettings(settingsPath, this);
gameFiltersSettings = new GameFiltersSettings(settingsPath, this); gameFiltersSettings = new GameFiltersSettings(settingsPath, this);

View file

@ -188,7 +188,7 @@ signals:
private: private:
QSettings *settings; QSettings *settings;
ShortcutsSettings *shortcutsSettings; ShortcutsSettings *shortcutsSettings;
QSharedPointer<CardDatabaseSettings> cardDatabaseSettings; CardDatabaseSettings *cardDatabaseSettings;
ServersSettings *serversSettings; ServersSettings *serversSettings;
MessageSettings *messageSettings; MessageSettings *messageSettings;
GameFiltersSettings *gameFiltersSettings; GameFiltersSettings *gameFiltersSettings;
@ -325,11 +325,8 @@ private:
bool roundCardCorners; bool roundCardCorners;
bool showStatusBar; bool showStatusBar;
explicit SettingsCache();
static QSharedPointer<SettingsCache> settingsInstance;
public: public:
SettingsCache();
QString getDataPath(); QString getDataPath();
QString getSettingsPath(); QString getSettingsPath();
QString getCachePath() const; QString getCachePath() const;
@ -895,7 +892,7 @@ public:
{ {
return *shortcutsSettings; return *shortcutsSettings;
} }
QSharedPointer<CardDatabaseSettings> cardDatabase() const CardDatabaseSettings *cardDatabase() const
{ {
return cardDatabaseSettings; return cardDatabaseSettings;
} }
@ -946,8 +943,7 @@ public:
return roundCardCorners; return roundCardCorners;
} }
static QSharedPointer<SettingsCache> instance(); static SettingsCache &instance();
static void setInstance(QSharedPointer<SettingsCache> newInstance);
void resetPaths(); void resetPaths();
public slots: public slots:

View file

@ -59,7 +59,7 @@ ShortcutTreeView::ShortcutTreeView(QWidget *parent) : QTreeView(parent)
expandAll(); expandAll();
connect(&SettingsCache::instance()->shortcuts(), &ShortcutsSettings::shortCutChanged, this, connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&ShortcutTreeView::refreshShortcuts); &ShortcutTreeView::refreshShortcuts);
} }
@ -67,10 +67,10 @@ void ShortcutTreeView::populateShortcutsModel()
{ {
QHash<QString, QStandardItem *> parentItems; QHash<QString, QStandardItem *> parentItems;
QStandardItem *curParent = nullptr; QStandardItem *curParent = nullptr;
for (const auto &key : SettingsCache::instance()->shortcuts().getAllShortcutKeys()) { for (const auto &key : SettingsCache::instance().shortcuts().getAllShortcutKeys()) {
QString name = SettingsCache::instance()->shortcuts().getShortcut(key).getName(); QString name = SettingsCache::instance().shortcuts().getShortcut(key).getName();
QString group = SettingsCache::instance()->shortcuts().getShortcut(key).getGroupName(); QString group = SettingsCache::instance().shortcuts().getShortcut(key).getGroupName();
QString shortcut = SettingsCache::instance()->shortcuts().getShortcutString(key); QString shortcut = SettingsCache::instance().shortcuts().getShortcutString(key);
if (parentItems.contains(group)) { if (parentItems.contains(group)) {
curParent = parentItems.value(group); curParent = parentItems.value(group);
@ -110,7 +110,7 @@ static void loopOverModel(QAbstractItemModel *model, const QModelIndex &parent =
if (model->hasChildren(friendlyNameIndex)) { if (model->hasChildren(friendlyNameIndex)) {
const auto childIndex = model->index(0, 2, friendlyNameIndex); const auto childIndex = model->index(0, 2, friendlyNameIndex);
const auto key = model->data(childIndex).toString(); const auto key = model->data(childIndex).toString();
const auto shortcutGroupName = SettingsCache::instance()->shortcuts().getShortcut(key).getGroupName(); const auto shortcutGroupName = SettingsCache::instance().shortcuts().getShortcut(key).getGroupName();
model->setData(friendlyNameIndex, shortcutGroupName); model->setData(friendlyNameIndex, shortcutGroupName);
loopOverModel(model, friendlyNameIndex); loopOverModel(model, friendlyNameIndex);
@ -119,8 +119,8 @@ static void loopOverModel(QAbstractItemModel *model, const QModelIndex &parent =
const auto keyIndex = model->index(r, 2, parent); const auto keyIndex = model->index(r, 2, parent);
const auto key = model->data(keyIndex).toString(); const auto key = model->data(keyIndex).toString();
const auto shortcutKey = SettingsCache::instance()->shortcuts().getShortcut(key).getName(); const auto shortcutKey = SettingsCache::instance().shortcuts().getShortcut(key).getName();
const auto shortcutSequence = SettingsCache::instance()->shortcuts().getShortcutString(key); const auto shortcutSequence = SettingsCache::instance().shortcuts().getShortcutString(key);
model->setData(friendlyNameIndex, shortcutKey); model->setData(friendlyNameIndex, shortcutKey);
model->setData(shortcutSequenceIndex, shortcutSequence); model->setData(shortcutSequenceIndex, shortcutSequence);
} }

View file

@ -15,9 +15,8 @@
SoundEngine::SoundEngine(QObject *parent) : QObject(parent), audioOutput(nullptr), player(nullptr) SoundEngine::SoundEngine(QObject *parent) : QObject(parent), audioOutput(nullptr), player(nullptr)
{ {
ensureThemeDirectoryExists(); ensureThemeDirectoryExists();
connect(SettingsCache::instance().get(), &SettingsCache::soundThemeChanged, this, &SoundEngine::themeChangedSlot); connect(&SettingsCache::instance(), &SettingsCache::soundThemeChanged, this, &SoundEngine::themeChangedSlot);
connect(SettingsCache::instance().get(), &SettingsCache::soundEnabledChanged, this, connect(&SettingsCache::instance(), &SettingsCache::soundEnabledChanged, this, &SoundEngine::soundEnabledChanged);
&SoundEngine::soundEnabledChanged);
soundEnabledChanged(); soundEnabledChanged();
themeChangedSlot(); themeChangedSlot();
@ -37,7 +36,7 @@ SoundEngine::~SoundEngine()
void SoundEngine::soundEnabledChanged() void SoundEngine::soundEnabledChanged()
{ {
if (SettingsCache::instance()->getSoundEnabled()) { if (SettingsCache::instance().getSoundEnabled()) {
qCInfo(SoundEngineLog) << "SoundEngine: enabling sound with" << audioData.size() << "sounds"; qCInfo(SoundEngineLog) << "SoundEngine: enabling sound with" << audioData.size() << "sounds";
if (!player) { if (!player) {
player = new QMediaPlayer; player = new QMediaPlayer;
@ -71,7 +70,7 @@ void SoundEngine::playSound(const QString &fileName)
} }
player->stop(); player->stop();
int volumeSliderValue = SettingsCache::instance()->getMasterVolume(); int volumeSliderValue = SettingsCache::instance().getMasterVolume();
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
player->audioOutput()->setVolume(qreal(volumeSliderValue) / 100); player->audioOutput()->setVolume(qreal(volumeSliderValue) / 100);
player->setSource(QUrl::fromLocalFile(audioData[fileName])); player->setSource(QUrl::fromLocalFile(audioData[fileName]));
@ -89,10 +88,10 @@ void SoundEngine::testSound()
void SoundEngine::ensureThemeDirectoryExists() void SoundEngine::ensureThemeDirectoryExists()
{ {
if (SettingsCache::instance()->getSoundThemeName().isEmpty() || if (SettingsCache::instance().getSoundThemeName().isEmpty() ||
!getAvailableThemes().contains(SettingsCache::instance()->getSoundThemeName())) { !getAvailableThemes().contains(SettingsCache::instance().getSoundThemeName())) {
qCInfo(SoundEngineLog) << "Sounds theme name not set, setting default value"; qCInfo(SoundEngineLog) << "Sounds theme name not set, setting default value";
SettingsCache::instance()->setSoundThemeName(DEFAULT_THEME_NAME); SettingsCache::instance().setSoundThemeName(DEFAULT_THEME_NAME);
} }
} }
@ -103,7 +102,7 @@ QStringMap &SoundEngine::getAvailableThemes()
// load themes from user profile dir // load themes from user profile dir
dir.setPath(SettingsCache::instance()->getDataPath() + "/sounds"); dir.setPath(SettingsCache::instance().getDataPath() + "/sounds");
for (const QString &themeName : dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name)) { for (const QString &themeName : dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name)) {
if (!availableThemes.contains(themeName)) if (!availableThemes.contains(themeName))
@ -131,7 +130,7 @@ QStringMap &SoundEngine::getAvailableThemes()
void SoundEngine::themeChangedSlot() void SoundEngine::themeChangedSlot()
{ {
QString themeName = SettingsCache::instance()->getSoundThemeName(); QString themeName = SettingsCache::instance().getSoundThemeName();
qCInfo(SoundEngineLog) << "Sound theme changed:" << themeName; qCInfo(SoundEngineLog) << "Sound theme changed:" << themeName;
QDir dir = getAvailableThemes().value(themeName); QDir dir = getAvailableThemes().value(themeName);

View file

@ -9,7 +9,7 @@ class SettingsCardPreferenceProvider : public ICardPreferenceProvider
public: public:
QString getCardPreferenceOverride(const QString &cardName) const override QString getCardPreferenceOverride(const QString &cardName) const override
{ {
return SettingsCache::instance()->cardOverrides().getCardPreferenceOverride(cardName); return SettingsCache::instance().cardOverrides().getCardPreferenceOverride(cardName);
} }
}; };

View file

@ -34,13 +34,12 @@ AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item,
setCacheMode(DeviceCoordinateCache); setCacheMode(DeviceCoordinateCache);
connect(SettingsCache::instance().get(), &SettingsCache::roundCardCornersChanged, this, connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) {
[this](bool _roundCardCorners) { Q_UNUSED(_roundCardCorners);
Q_UNUSED(_roundCardCorners);
prepareGeometryChange(); prepareGeometryChange();
update(); update();
}); });
connect(item, &QObject::destroyed, this, &AbstractCardDragItem::deleteLater); connect(item, &QObject::destroyed, this, &AbstractCardDragItem::deleteLater);
} }
@ -48,7 +47,7 @@ AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item,
QPainterPath AbstractCardDragItem::shape() const QPainterPath AbstractCardDragItem::shape() const
{ {
QPainterPath shape; QPainterPath shape;
qreal cardCornerRadius = SettingsCache::instance()->getRoundCardCorners() ? 0.05 * CARD_WIDTH : 0.0; qreal cardCornerRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * CARD_WIDTH : 0.0;
shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius); shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius);
return shape; return shape;
} }

View file

@ -20,16 +20,15 @@ AbstractCardItem::AbstractCardItem(QGraphicsItem *parent, const CardRef &cardRef
setFlag(ItemIsSelectable); setFlag(ItemIsSelectable);
setCacheMode(DeviceCoordinateCache); setCacheMode(DeviceCoordinateCache);
connect(SettingsCache::instance().get(), &SettingsCache::displayCardNamesChanged, this, [this] { update(); }); connect(&SettingsCache::instance(), &SettingsCache::displayCardNamesChanged, this, [this] { update(); });
refreshCardInfo(); refreshCardInfo();
connect(SettingsCache::instance().get(), &SettingsCache::roundCardCornersChanged, this, connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) {
[this](bool _roundCardCorners) { Q_UNUSED(_roundCardCorners);
Q_UNUSED(_roundCardCorners);
prepareGeometryChange(); prepareGeometryChange();
update(); update();
}); });
} }
AbstractCardItem::~AbstractCardItem() AbstractCardItem::~AbstractCardItem()
@ -45,7 +44,7 @@ QRectF AbstractCardItem::boundingRect() const
QPainterPath AbstractCardItem::shape() const QPainterPath AbstractCardItem::shape() const
{ {
QPainterPath shape; QPainterPath shape;
qreal cardCornerRadius = SettingsCache::instance()->getRoundCardCorners() ? 0.05 * CARD_WIDTH : 0.0; qreal cardCornerRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * CARD_WIDTH : 0.0;
shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius); shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius);
return shape; return shape;
} }
@ -95,7 +94,7 @@ QSizeF AbstractCardItem::getTranslatedSize(QPainter *painter) const
void AbstractCardItem::transformPainter(QPainter *painter, const QSizeF &translatedSize, int angle) void AbstractCardItem::transformPainter(QPainter *painter, const QSizeF &translatedSize, int angle)
{ {
const int MAX_FONT_SIZE = SettingsCache::instance()->getMaxFontSize(); const int MAX_FONT_SIZE = SettingsCache::instance().getMaxFontSize();
const int fontSize = std::max(9, MAX_FONT_SIZE); const int fontSize = std::max(9, MAX_FONT_SIZE);
QRectF totalBoundingRect = painter->combinedTransform().mapRect(boundingRect()); QRectF totalBoundingRect = painter->combinedTransform().mapRect(boundingRect());
@ -144,7 +143,7 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
painter->drawPath(shape()); painter->drawPath(shape());
} }
if (translatedPixmap.isNull() || SettingsCache::instance()->getDisplayCardNames() || facedown) { if (translatedPixmap.isNull() || SettingsCache::instance().getDisplayCardNames() || facedown) {
painter->save(); painter->save();
transformPainter(painter, translatedSize, angle); transformPainter(painter, translatedSize, angle);
painter->setPen(Qt::white); painter->setPen(Qt::white);
@ -155,7 +154,7 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
nameStr = "# " + QString::number(id); nameStr = "# " + QString::number(id);
else { else {
QString prefix = ""; QString prefix = "";
if (SettingsCache::instance()->debug().getShowCardId()) { if (SettingsCache::instance().debug().getShowCardId()) {
prefix = "#" + QString::number(id) + " "; prefix = "#" + QString::number(id) + " ";
} }
nameStr = prefix + cardRef.name; nameStr = prefix + cardRef.name;
@ -216,7 +215,7 @@ void AbstractCardItem::setHovered(bool _hovered)
processHoverEvent(); processHoverEvent();
isHovered = _hovered; isHovered = _hovered;
setZValue(_hovered ? 2000000004 : realZValue); setZValue(_hovered ? 2000000004 : realZValue);
setScale(_hovered && SettingsCache::instance()->getScaleCards() ? 1.1 : 1); setScale(_hovered && SettingsCache::instance().getScaleCards() ? 1.1 : 1);
setTransformOriginPoint(_hovered ? CARD_WIDTH / 2 : 0, _hovered ? CARD_HEIGHT / 2 : 0); setTransformOriginPoint(_hovered ? CARD_WIDTH / 2 : 0, _hovered ? CARD_HEIGHT / 2 : 0);
update(); update();
} }
@ -268,7 +267,7 @@ void AbstractCardItem::setTapped(bool _tapped, bool canAnimate)
return; return;
tapped = _tapped; tapped = _tapped;
if (SettingsCache::instance()->getTapAnimation() && canAnimate) if (SettingsCache::instance().getTapAnimation() && canAnimate)
static_cast<GameScene *>(scene())->registerAnimationItem(this); static_cast<GameScene *>(scene())->registerAnimationItem(this);
else { else {
tapAngle = tapped ? 90 : 0; tapAngle = tapped ? 90 : 0;

View file

@ -57,7 +57,7 @@ AbstractCounter::AbstractCounter(Player *_player,
menu = nullptr; menu = nullptr;
} }
connect(&SettingsCache::instance().get()->shortcuts(), &ShortcutsSettings::shortCutChanged, this, connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&AbstractCounter::refreshShortcuts); &AbstractCounter::refreshShortcuts);
refreshShortcuts(); refreshShortcuts();
retranslateUi(); retranslateUi();
@ -88,7 +88,7 @@ void AbstractCounter::setShortcutsActive()
if (!player->getPlayerInfo()->getLocal()) { if (!player->getPlayerInfo()->getLocal()) {
return; return;
} }
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
if (name == "life") { if (name == "life") {
shortcutActive = true; shortcutActive = true;
aSet->setShortcuts(shortcuts.getShortcut("Player/aSet")); aSet->setShortcuts(shortcuts.getShortcut("Player/aSet"));

View file

@ -238,12 +238,12 @@ void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (startZone->getName().compare("hand") == 0) { if (startZone->getName().compare("hand") == 0) {
startCard->playCard(false); startCard->playCard(false);
CardInfoPtr ci = startCard->getCard().getCardPtr(); CardInfoPtr ci = startCard->getCard().getCardPtr();
if (ci && ((!SettingsCache::instance()->getPlayToStack() && ci->getTableRow() == 3) || if (ci && ((!SettingsCache::instance().getPlayToStack() && ci->getTableRow() == 3) ||
(SettingsCache::instance()->getPlayToStack() && ci->getTableRow() != 0 && (SettingsCache::instance().getPlayToStack() && ci->getTableRow() != 0 &&
startCard->getZone()->getName().toStdString() != "stack"))) startCard->getZone()->getName().toStdString() != "stack")))
cmd.set_start_zone("stack"); cmd.set_start_zone("stack");
else else
cmd.set_start_zone(SettingsCache::instance()->getPlayToStack() ? "stack" : "table"); cmd.set_start_zone(SettingsCache::instance().getPlayToStack() ? "stack" : "table");
} }
player->getPlayerActions()->sendGameCommand(cmd); player->getPlayerActions()->sendGameCommand(cmd);
} }

View file

@ -25,11 +25,10 @@ CardItem::CardItem(Player *_owner, QGraphicsItem *parent, const CardRef &cardRef
{ {
owner->addCard(this); owner->addCard(this);
connect(&SettingsCache::instance().get()->cardCounters(), &CardCounterSettings::colorChanged, this, connect(&SettingsCache::instance().cardCounters(), &CardCounterSettings::colorChanged, this, [this](int counterId) {
[this](int counterId) { if (counters.contains(counterId))
if (counters.contains(counterId)) update();
update(); });
});
} }
void CardItem::prepareDelete() void CardItem::prepareDelete()
@ -72,7 +71,7 @@ void CardItem::retranslateUi()
void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
auto &cardCounterSettings = SettingsCache::instance()->cardCounters(); auto &cardCounterSettings = SettingsCache::instance().cardCounters();
painter->save(); painter->save();
AbstractCardItem::paint(painter, option, widget); AbstractCardItem::paint(painter, option, widget);
@ -380,7 +379,7 @@ void CardItem::playCard(bool faceDown)
if (tz) if (tz)
emit tz->toggleTapped(); emit tz->toggleTapped();
else { else {
if (SettingsCache::instance()->getClickPlaysAllSelected()) { if (SettingsCache::instance().getClickPlaysAllSelected()) {
faceDown ? zone->getPlayer()->getPlayerActions()->actPlayFacedown() faceDown ? zone->getPlayer()->getPlayerActions()->actPlayFacedown()
: zone->getPlayer()->getPlayerActions()->actPlay(); : zone->getPlayer()->getPlayerActions()->actPlay();
} else { } else {
@ -410,7 +409,7 @@ static bool isUnwritableRevealZone(CardZoneLogic *zone)
void CardItem::handleClickedToPlay(bool shiftHeld) void CardItem::handleClickedToPlay(bool shiftHeld)
{ {
if (isUnwritableRevealZone(zone)) { if (isUnwritableRevealZone(zone)) {
if (SettingsCache::instance()->getClickPlaysAllSelected()) { if (SettingsCache::instance().getClickPlaysAllSelected()) {
zone->getPlayer()->getPlayerActions()->actHide(); zone->getPlayer()->getPlayerActions()->actHide();
} else { } else {
zone->removeCard(this); zone->removeCard(this);
@ -432,7 +431,7 @@ void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
} }
} }
} else if ((event->modifiers() != Qt::AltModifier) && (event->button() == Qt::LeftButton) && } else if ((event->modifiers() != Qt::AltModifier) && (event->button() == Qt::LeftButton) &&
(!SettingsCache::instance()->getDoubleClickToPlay())) { (!SettingsCache::instance().getDoubleClickToPlay())) {
handleClickedToPlay(event->modifiers().testFlag(Qt::ShiftModifier)); handleClickedToPlay(event->modifiers().testFlag(Qt::ShiftModifier));
} }
@ -445,7 +444,7 @@ void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{ {
if ((event->modifiers() != Qt::AltModifier) && (event->buttons() == Qt::LeftButton) && if ((event->modifiers() != Qt::AltModifier) && (event->buttons() == Qt::LeftButton) &&
(SettingsCache::instance()->getDoubleClickToPlay())) { (SettingsCache::instance().getDoubleClickToPlay())) {
handleClickedToPlay(event->modifiers().testFlag(Qt::ShiftModifier)); handleClickedToPlay(event->modifiers().testFlag(Qt::ShiftModifier));
} }
event->accept(); event->accept();

View file

@ -73,12 +73,11 @@ DeckViewCard::DeckViewCard(QGraphicsItem *parent, const CardRef &cardRef, const
{ {
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
connect(SettingsCache::instance().get(), &SettingsCache::roundCardCornersChanged, this, connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) {
[this](bool _roundCardCorners) { Q_UNUSED(_roundCardCorners);
Q_UNUSED(_roundCardCorners);
update(); update();
}); });
} }
DeckViewCard::~DeckViewCard() DeckViewCard::~DeckViewCard()
@ -96,7 +95,7 @@ void DeckViewCard::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
pen.setJoinStyle(Qt::MiterJoin); pen.setJoinStyle(Qt::MiterJoin);
pen.setColor(originZone == DECK_ZONE_MAIN ? Qt::green : Qt::red); pen.setColor(originZone == DECK_ZONE_MAIN ? Qt::green : Qt::red);
painter->setPen(pen); painter->setPen(pen);
qreal cardRadius = SettingsCache::instance()->getRoundCardCorners() ? 0.05 * (CARD_WIDTH - 3) : 0.0; qreal cardRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * (CARD_WIDTH - 3) : 0.0;
painter->drawRoundedRect(QRectF(1.5, 1.5, CARD_WIDTH - 3., CARD_HEIGHT - 3.), cardRadius, cardRadius); painter->drawRoundedRect(QRectF(1.5, 1.5, CARD_WIDTH - 3., CARD_HEIGHT - 3.), cardRadius, cardRadius);
painter->restore(); painter->restore();
} }

View file

@ -95,11 +95,11 @@ DeckViewContainer::DeckViewContainer(int _playerId, TabGame *parent)
setLayout(deckViewLayout); setLayout(deckViewLayout);
retranslateUi(); retranslateUi();
connect(&SettingsCache::instance().get()->shortcuts(), &ShortcutsSettings::shortCutChanged, this, connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&DeckViewContainer::refreshShortcuts); &DeckViewContainer::refreshShortcuts);
refreshShortcuts(); refreshShortcuts();
connect(SettingsCache::instance().get(), &SettingsCache::visualDeckStorageInGameChanged, this, connect(&SettingsCache::instance(), &SettingsCache::visualDeckStorageInGameChanged, this,
&DeckViewContainer::setVisualDeckStorageExists); &DeckViewContainer::setVisualDeckStorageExists);
switchToDeckSelectView(); switchToDeckSelectView();
@ -142,7 +142,7 @@ static void setVisibility(QPushButton *button, bool visible)
void DeckViewContainer::switchToDeckSelectView() void DeckViewContainer::switchToDeckSelectView()
{ {
if (SettingsCache::instance()->getVisualDeckStorageInGame()) { if (SettingsCache::instance().getVisualDeckStorageInGame()) {
deckView->setHidden(true); deckView->setHidden(true);
tryCreateVisualDeckStorageWidget(); tryCreateVisualDeckStorageWidget();
@ -203,13 +203,13 @@ void DeckViewContainer::updateSideboardLockButtonText()
sideboardLockButton->setText(tr("Sideboard locked")); sideboardLockButton->setText(tr("Sideboard locked"));
} }
// setting text on a button removes its shortcut // setting text on a button removes its shortcut
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
sideboardLockButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/sideboardLockButton")); sideboardLockButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/sideboardLockButton"));
} }
void DeckViewContainer::refreshShortcuts() void DeckViewContainer::refreshShortcuts()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
loadLocalButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/loadLocalButton")); loadLocalButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/loadLocalButton"));
loadRemoteButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/loadRemoteButton")); loadRemoteButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/loadRemoteButton"));
loadFromClipboardButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/loadFromClipboardButton")); loadFromClipboardButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/loadFromClipboardButton"));

View file

@ -91,7 +91,7 @@ DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *pa
chooseTokenFromDeckRadioButton = new QRadioButton(tr("Show tokens from this &deck")); chooseTokenFromDeckRadioButton = new QRadioButton(tr("Show tokens from this &deck"));
connect(chooseTokenFromDeckRadioButton, &QRadioButton::toggled, this, &DlgCreateToken::actChooseTokenFromDeck); connect(chooseTokenFromDeckRadioButton, &QRadioButton::toggled, this, &DlgCreateToken::actChooseTokenFromDeck);
QByteArray deckHeaderState = SettingsCache::instance()->layouts().getDeckEditorDbHeaderState(); QByteArray deckHeaderState = SettingsCache::instance().layouts().getDeckEditorDbHeaderState();
chooseTokenView = new QTreeView; chooseTokenView = new QTreeView;
chooseTokenView->setModel(cardDatabaseDisplayModel); chooseTokenView->setModel(cardDatabaseDisplayModel);
chooseTokenView->setUniformRowHeights(true); chooseTokenView->setUniformRowHeights(true);
@ -151,13 +151,13 @@ DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *pa
setWindowTitle(tr("Create token")); setWindowTitle(tr("Create token"));
resize(600, 500); resize(600, 500);
restoreGeometry(SettingsCache::instance()->getTokenDialogGeometry()); restoreGeometry(SettingsCache::instance().getTokenDialogGeometry());
} }
void DlgCreateToken::closeEvent(QCloseEvent *event) void DlgCreateToken::closeEvent(QCloseEvent *event)
{ {
event->accept(); event->accept();
SettingsCache::instance()->setTokenDialogGeometry(saveGeometry()); SettingsCache::instance().setTokenDialogGeometry(saveGeometry());
} }
void DlgCreateToken::faceDownCheckBoxToggled(bool checked) void DlgCreateToken::faceDownCheckBoxToggled(bool checked)
@ -190,7 +190,7 @@ void DlgCreateToken::tokenSelectionChanged(const QModelIndex &current, const QMo
const QChar cardColor = cardInfo->getColorChar(); const QChar cardColor = cardInfo->getColorChar();
colorEdit->setCurrentIndex(colorEdit->findData(cardColor, Qt::UserRole, Qt::MatchFixedString)); colorEdit->setCurrentIndex(colorEdit->findData(cardColor, Qt::UserRole, Qt::MatchFixedString));
ptEdit->setText(cardInfo->getPowTough()); ptEdit->setText(cardInfo->getPowTough());
if (SettingsCache::instance()->getAnnotateTokens()) if (SettingsCache::instance().getAnnotateTokens())
annotationEdit->setText(cardInfo->getText()); annotationEdit->setText(cardInfo->getText());
} else { } else {
nameEdit->setText(""); nameEdit->setText("");
@ -234,13 +234,13 @@ void DlgCreateToken::actChooseTokenFromDeck(bool checked)
void DlgCreateToken::actOk() void DlgCreateToken::actOk()
{ {
SettingsCache::instance()->setTokenDialogGeometry(saveGeometry()); SettingsCache::instance().setTokenDialogGeometry(saveGeometry());
accept(); accept();
} }
void DlgCreateToken::actReject() void DlgCreateToken::actReject()
{ {
SettingsCache::instance()->setTokenDialogGeometry(saveGeometry()); SettingsCache::instance().setTokenDialogGeometry(saveGeometry());
reject(); reject();
} }
@ -252,5 +252,5 @@ TokenInfo DlgCreateToken::getTokenInfo() const
.annotation = annotationEdit->text(), .annotation = annotationEdit->text(),
.destroy = destroyCheckBox->isChecked(), .destroy = destroyCheckBox->isChecked(),
.faceDown = faceDownCheckBox->isChecked(), .faceDown = faceDownCheckBox->isChecked(),
.providerId = SettingsCache::instance()->cardOverrides().getCardPreferenceOverride(nameEdit->text())}; .providerId = SettingsCache::instance().cardOverrides().getCardPreferenceOverride(nameEdit->text())};
} }

View file

@ -31,7 +31,7 @@ GameScene::GameScene(PhasesToolbar *_phasesToolbar, QObject *parent)
{ {
animationTimer = new QBasicTimer; animationTimer = new QBasicTimer;
addItem(phasesToolbar); addItem(phasesToolbar);
connect(SettingsCache::instance().get(), &SettingsCache::minPlayersForMultiColumnLayoutChanged, this, connect(&SettingsCache::instance(), &SettingsCache::minPlayersForMultiColumnLayoutChanged, this,
&GameScene::rearrange); &GameScene::rearrange);
rearrange(); rearrange();
@ -206,7 +206,7 @@ QList<Player *> GameScene::rotatePlayers(const QList<Player *> &activePlayers, i
int GameScene::determineColumnCount(int playerCount) int GameScene::determineColumnCount(int playerCount)
{ {
return playerCount < SettingsCache::instance()->getMinPlayersForMultiColumnLayout() ? 1 : 2; return playerCount < SettingsCache::instance().getMinPlayersForMultiColumnLayout() ? 1 : 2;
} }
/** /**

View file

@ -24,7 +24,7 @@ GameView::GameView(GameScene *scene, QWidget *parent) : QGraphicsView(scene, par
connect(aCloseMostRecentZoneView, &QAction::triggered, scene, &GameScene::closeMostRecentZoneView); connect(aCloseMostRecentZoneView, &QAction::triggered, scene, &GameScene::closeMostRecentZoneView);
addAction(aCloseMostRecentZoneView); addAction(aCloseMostRecentZoneView);
connect(&SettingsCache::instance()->shortcuts(), &ShortcutsSettings::shortCutChanged, this, connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&GameView::refreshShortcuts); &GameView::refreshShortcuts);
refreshShortcuts(); refreshShortcuts();
rubberBand = new QRubberBand(QRubberBand::Rectangle, this); rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
@ -67,5 +67,5 @@ void GameView::stopRubberBand()
void GameView::refreshShortcuts() void GameView::refreshShortcuts()
{ {
aCloseMostRecentZoneView->setShortcuts( aCloseMostRecentZoneView->setShortcuts(
SettingsCache::instance()->shortcuts().getShortcut("Player/aCloseMostRecentZoneView")); SettingsCache::instance().shortcuts().getShortcut("Player/aCloseMostRecentZoneView"));
} }

View file

@ -645,7 +645,7 @@ void MessageLogWidget::logSetCardCounter(Player *player, QString cardName, int c
finalStr = tr("%1 removes %2 \"%3\" counter(s) from %4 (now %5).", "", delta); finalStr = tr("%1 removes %2 \"%3\" counter(s) from %4 (now %5).", "", delta);
} }
auto &cardCounterSettings = SettingsCache::instance()->cardCounters(); auto &cardCounterSettings = SettingsCache::instance().cardCounters();
appendHtmlServerMessage(finalStr.arg(sanitizeHtml(player->getPlayerInfo()->getName())) appendHtmlServerMessage(finalStr.arg(sanitizeHtml(player->getPlayerInfo()->getName()))
.arg("<font class=\"blue\">" + QString::number(delta) + "</font>") .arg("<font class=\"blue\">" + QString::number(delta) + "</font>")
.arg(cardCounterSettings.displayName(counterId)) .arg(cardCounterSettings.displayName(counterId))

View file

@ -414,7 +414,7 @@ void CardMenu::addRelatedCardActions()
if (createRelatedCards) { if (createRelatedCards) {
if (shortcutsActive) { if (shortcutsActive) {
createRelatedCards->setShortcuts( createRelatedCards->setShortcuts(
SettingsCache::instance()->shortcuts().getShortcut("Player/aCreateRelatedTokens")); SettingsCache::instance().shortcuts().getShortcut("Player/aCreateRelatedTokens"));
} }
connect(createRelatedCards, &QAction::triggered, player->getPlayerActions(), connect(createRelatedCards, &QAction::triggered, player->getPlayerActions(),
&PlayerActions::actCreateAllRelatedCards); &PlayerActions::actCreateAllRelatedCards);
@ -447,7 +447,7 @@ void CardMenu::retranslateUi()
mCardCounters->setTitle(tr("Ca&rd counters")); mCardCounters->setTitle(tr("Ca&rd counters"));
auto &cardCounterSettings = SettingsCache::instance()->cardCounters(); auto &cardCounterSettings = SettingsCache::instance().cardCounters();
for (int i = 0; i < aAddCounter.size(); ++i) { for (int i = 0; i < aAddCounter.size(); ++i) {
aAddCounter[i]->setText(tr("&Add counter (%1)").arg(cardCounterSettings.displayName(i))); aAddCounter[i]->setText(tr("&Add counter (%1)").arg(cardCounterSettings.displayName(i)));
@ -462,7 +462,7 @@ void CardMenu::retranslateUi()
void CardMenu::setShortcutsActive() void CardMenu::setShortcutsActive()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aHide->setShortcuts(shortcuts.getShortcut("Player/aHide")); aHide->setShortcuts(shortcuts.getShortcut("Player/aHide"));
aPlay->setShortcuts(shortcuts.getShortcut("Player/aPlay")); aPlay->setShortcuts(shortcuts.getShortcut("Player/aPlay"));

View file

@ -112,7 +112,7 @@ void GraveyardMenu::retranslateUi()
void GraveyardMenu::setShortcutsActive() void GraveyardMenu::setShortcutsActive()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aViewGraveyard->setShortcuts(shortcuts.getShortcut("Player/aViewGraveyard")); aViewGraveyard->setShortcuts(shortcuts.getShortcut("Player/aViewGraveyard"));
} }

View file

@ -89,7 +89,7 @@ void HandMenu::retranslateUi()
void HandMenu::setShortcutsActive() void HandMenu::setShortcutsActive()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aViewHand->setShortcuts(shortcuts.getShortcut("Player/aViewHand")); aViewHand->setShortcuts(shortcuts.getShortcut("Player/aViewHand"));
aSortHand->setShortcuts(shortcuts.getShortcut("Player/aSortHand")); aSortHand->setShortcuts(shortcuts.getShortcut("Player/aSortHand"));
aMulligan->setShortcuts(shortcuts.getShortcut("Player/aMulligan")); aMulligan->setShortcuts(shortcuts.getShortcut("Player/aMulligan"));

View file

@ -318,7 +318,7 @@ void LibraryMenu::onRevealTopCardTriggered()
void LibraryMenu::setShortcutsActive() void LibraryMenu::setShortcutsActive()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aViewLibrary->setShortcuts(shortcuts.getShortcut("Player/aViewLibrary")); aViewLibrary->setShortcuts(shortcuts.getShortcut("Player/aViewLibrary"));
aViewTopCards->setShortcuts(shortcuts.getShortcut("Player/aViewTopCards")); aViewTopCards->setShortcuts(shortcuts.getShortcut("Player/aViewTopCards"));

View file

@ -43,7 +43,7 @@ MoveMenu::MoveMenu(Player *player) : QMenu(tr("Move to"))
void MoveMenu::setShortcutsActive() void MoveMenu::setShortcutsActive()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aMoveToTopLibrary->setShortcuts(shortcuts.getShortcut("Player/aMoveToTopLibrary")); aMoveToTopLibrary->setShortcuts(shortcuts.getShortcut("Player/aMoveToTopLibrary"));
aMoveToBottomLibrary->setShortcuts(shortcuts.getShortcut("Player/aMoveToBottomLibrary")); aMoveToBottomLibrary->setShortcuts(shortcuts.getShortcut("Player/aMoveToBottomLibrary"));

View file

@ -57,7 +57,7 @@ PlayerMenu::PlayerMenu(Player *_player) : player(_player)
sayMenu = nullptr; sayMenu = nullptr;
} }
connect(&SettingsCache::instance().get()->shortcuts(), &ShortcutsSettings::shortCutChanged, this, connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&PlayerMenu::refreshShortcuts); &PlayerMenu::refreshShortcuts);
refreshShortcuts(); refreshShortcuts();

View file

@ -63,7 +63,7 @@ void PtMenu::retranslateUi()
void PtMenu::setShortcutsActive() void PtMenu::setShortcutsActive()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aIncP->setShortcuts(shortcuts.getShortcut("Player/aIncP")); aIncP->setShortcuts(shortcuts.getShortcut("Player/aIncP"));
aDecP->setShortcuts(shortcuts.getShortcut("Player/aDecP")); aDecP->setShortcuts(shortcuts.getShortcut("Player/aDecP"));

View file

@ -6,8 +6,7 @@
SayMenu::SayMenu(Player *_player) : player(_player) SayMenu::SayMenu(Player *_player) : player(_player)
{ {
connect(&SettingsCache::instance().get()->messages(), &MessageSettings::messageMacrosChanged, this, connect(&SettingsCache::instance().messages(), &MessageSettings::messageMacrosChanged, this, &SayMenu::initSayMenu);
&SayMenu::initSayMenu);
initSayMenu(); initSayMenu();
} }
@ -15,11 +14,11 @@ void SayMenu::initSayMenu()
{ {
clear(); clear();
int count = SettingsCache::instance()->messages().getCount(); int count = SettingsCache::instance().messages().getCount();
setEnabled(count > 0); setEnabled(count > 0);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
auto *newAction = new QAction(SettingsCache::instance()->messages().getMessageAt(i), this); auto *newAction = new QAction(SettingsCache::instance().messages().getMessageAt(i), this);
if (i < 10) { if (i < 10) {
newAction->setShortcut(QKeySequence("Ctrl+" + QString::number((i + 1) % 10))); newAction->setShortcut(QKeySequence("Ctrl+" + QString::number((i + 1) % 10)));
} }

View file

@ -22,7 +22,7 @@ void SideboardMenu::retranslateUi()
void SideboardMenu::setShortcutsActive() void SideboardMenu::setShortcutsActive()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aViewSideboard->setShortcuts(shortcuts.getShortcut("Player/aViewSideboard")); aViewSideboard->setShortcuts(shortcuts.getShortcut("Player/aViewSideboard"));
} }

View file

@ -94,7 +94,7 @@ void UtilityMenu::retranslateUi()
void UtilityMenu::setShortcutsActive() void UtilityMenu::setShortcutsActive()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
if (player->getPlayerInfo()->getLocalOrJudge()) { if (player->getPlayerInfo()->getLocalOrJudge()) {
aIncrementAllCardCounters->setShortcuts(shortcuts.getShortcut("Player/aIncrementAllCardCounters")); aIncrementAllCardCounters->setShortcuts(shortcuts.getShortcut("Player/aIncrementAllCardCounters"));

View file

@ -60,7 +60,7 @@ void PlayerActions::playCard(CardItem *card, bool faceDown)
const CardInfo &info = exactCard.getInfo(); const CardInfo &info = exactCard.getInfo();
int tableRow = info.getTableRow(); int tableRow = info.getTableRow();
bool playToStack = SettingsCache::instance()->getPlayToStack(); bool playToStack = SettingsCache::instance().getPlayToStack();
QString currentZone = card->getZone()->getName(); QString currentZone = card->getZone()->getName();
if (currentZone == "stack" && tableRow == 3) { if (currentZone == "stack" && tableRow == 3) {
cmd.set_target_zone("grave"); cmd.set_target_zone("grave");
@ -280,7 +280,7 @@ void PlayerActions::actDrawCard()
void PlayerActions::actMulligan() void PlayerActions::actMulligan()
{ {
int startSize = SettingsCache::instance()->getStartingHandSize(); int startSize = SettingsCache::instance().getStartingHandSize();
int handSize = player->getHandZone()->getCards().size(); int handSize = player->getHandZone()->getCards().size();
int deckSize = player->getDeckZone()->getCards().size() + handSize; // hand is shuffled back into the deck int deckSize = player->getDeckZone()->getCards().size() + handSize; // hand is shuffled back into the deck
bool ok; bool ok;
@ -302,7 +302,7 @@ void PlayerActions::actMulligan()
} }
sendGameCommand(cmd); sendGameCommand(cmd);
if (startSize != number) { if (startSize != number) {
SettingsCache::instance()->setStartingHandSize(number); SettingsCache::instance().setStartingHandSize(number);
} }
} }
@ -878,10 +878,10 @@ void PlayerActions::setLastToken(CardInfoPtr cardInfo)
lastTokenInfo = {.name = cardInfo->getName(), lastTokenInfo = {.name = cardInfo->getName(),
.color = cardInfo->getColors().isEmpty() ? QString() : cardInfo->getColors().left(1).toLower(), .color = cardInfo->getColors().isEmpty() ? QString() : cardInfo->getColors().left(1).toLower(),
.pt = cardInfo->getPowTough(), .pt = cardInfo->getPowTough(),
.annotation = SettingsCache::instance()->getAnnotateTokens() ? cardInfo->getText() : "", .annotation = SettingsCache::instance().getAnnotateTokens() ? cardInfo->getText() : "",
.destroy = true, .destroy = true,
.providerId = .providerId =
SettingsCache::instance()->cardOverrides().getCardPreferenceOverride(cardInfo->getName())}; SettingsCache::instance().cardOverrides().getCardPreferenceOverride(cardInfo->getName())};
lastTokenTableRow = TableZone::clampValidTableRow(2 - cardInfo->getTableRow()); lastTokenTableRow = TableZone::clampValidTableRow(2 - cardInfo->getTableRow());
@ -1072,7 +1072,7 @@ void PlayerActions::createCard(const CardItem *sourceCard,
} }
cmd.set_pt(cardInfo->getPowTough().toStdString()); cmd.set_pt(cardInfo->getPowTough().toStdString());
if (SettingsCache::instance()->getAnnotateTokens()) { if (SettingsCache::instance().getAnnotateTokens()) {
cmd.set_annotation(cardInfo->getText().toStdString()); cmd.set_annotation(cardInfo->getText().toStdString());
} else { } else {
cmd.set_annotation(""); cmd.set_annotation("");

View file

@ -5,9 +5,9 @@
PlayerGraphicsItem::PlayerGraphicsItem(Player *_player) : player(_player) PlayerGraphicsItem::PlayerGraphicsItem(Player *_player) : player(_player)
{ {
connect(SettingsCache::instance().get(), &SettingsCache::horizontalHandChanged, this, connect(&SettingsCache::instance(), &SettingsCache::horizontalHandChanged, this,
&PlayerGraphicsItem::rearrangeZones); &PlayerGraphicsItem::rearrangeZones);
connect(SettingsCache::instance().get(), &SettingsCache::handJustificationChanged, this, connect(&SettingsCache::instance(), &SettingsCache::handJustificationChanged, this,
&PlayerGraphicsItem::rearrangeZones); &PlayerGraphicsItem::rearrangeZones);
connect(player, &Player::rearrangeCounters, this, &PlayerGraphicsItem::rearrangeCounters); connect(player, &Player::rearrangeCounters, this, &PlayerGraphicsItem::rearrangeCounters);
@ -92,7 +92,7 @@ qreal PlayerGraphicsItem::getMinimumWidth() const
{ {
qreal result = tableZoneGraphicsItem->getMinimumWidth() + CARD_HEIGHT + 15 + counterAreaWidth + qreal result = tableZoneGraphicsItem->getMinimumWidth() + CARD_HEIGHT + 15 + counterAreaWidth +
stackZoneGraphicsItem->boundingRect().width(); stackZoneGraphicsItem->boundingRect().width();
if (!SettingsCache::instance()->getHorizontalHand()) { if (!SettingsCache::instance().getHorizontalHand()) {
result += handZoneGraphicsItem->boundingRect().width(); result += handZoneGraphicsItem->boundingRect().width();
} }
return result; return result;
@ -109,7 +109,7 @@ void PlayerGraphicsItem::processSceneSizeChange(int newPlayerWidth)
// Extend table (and hand, if horizontal) to accommodate the new player width. // Extend table (and hand, if horizontal) to accommodate the new player width.
qreal tableWidth = qreal tableWidth =
newPlayerWidth - CARD_HEIGHT - 15 - counterAreaWidth - stackZoneGraphicsItem->boundingRect().width(); newPlayerWidth - CARD_HEIGHT - 15 - counterAreaWidth - stackZoneGraphicsItem->boundingRect().width();
if (!SettingsCache::instance()->getHorizontalHand()) { if (!SettingsCache::instance().getHorizontalHand()) {
tableWidth -= handZoneGraphicsItem->boundingRect().width(); tableWidth -= handZoneGraphicsItem->boundingRect().width();
} }
@ -148,7 +148,7 @@ void PlayerGraphicsItem::rearrangeCounters()
void PlayerGraphicsItem::rearrangeZones() void PlayerGraphicsItem::rearrangeZones()
{ {
QPointF base = QPointF(CARD_HEIGHT + counterAreaWidth + 15, 0); QPointF base = QPointF(CARD_HEIGHT + counterAreaWidth + 15, 0);
if (SettingsCache::instance()->getHorizontalHand()) { if (SettingsCache::instance().getHorizontalHand()) {
if (mirrored) { if (mirrored) {
if (player->getHandZone()->contentsKnown()) { if (player->getHandZone()->contentsKnown()) {
player->getPlayerInfo()->setHandVisible(true); player->getPlayerInfo()->setHandVisible(true);
@ -199,7 +199,7 @@ void PlayerGraphicsItem::updateBoundingRect()
{ {
prepareGeometryChange(); prepareGeometryChange();
qreal width = CARD_HEIGHT + 15 + counterAreaWidth + stackZoneGraphicsItem->boundingRect().width(); qreal width = CARD_HEIGHT + 15 + counterAreaWidth + stackZoneGraphicsItem->boundingRect().width();
if (SettingsCache::instance()->getHorizontalHand()) { if (SettingsCache::instance().getHorizontalHand()) {
qreal handHeight = qreal handHeight =
player->getPlayerInfo()->getHandVisible() ? handZoneGraphicsItem->boundingRect().height() : 0; player->getPlayerInfo()->getHandVisible() ? handZoneGraphicsItem->boundingRect().height() : 0;
bRect = QRectF(0, 0, width + tableZoneGraphicsItem->boundingRect().width(), bRect = QRectF(0, 0, width + tableZoneGraphicsItem->boundingRect().width(),

View file

@ -28,7 +28,7 @@ void HandZone::handleDropEvent(const QList<CardDragItem *> &dragItems,
{ {
QPoint point = dropPoint + scenePos().toPoint(); QPoint point = dropPoint + scenePos().toPoint();
int x = -1; int x = -1;
if (SettingsCache::instance()->getHorizontalHand()) { if (SettingsCache::instance().getHorizontalHand()) {
for (x = 0; x < getLogic()->getCards().size(); x++) for (x = 0; x < getLogic()->getCards().size(); x++)
if (point.x() < static_cast<CardItem *>(getLogic()->getCards().at(x))->scenePos().x()) if (point.x() < static_cast<CardItem *>(getLogic()->getCards().at(x))->scenePos().x())
break; break;
@ -54,7 +54,7 @@ void HandZone::handleDropEvent(const QList<CardDragItem *> &dragItems,
QRectF HandZone::boundingRect() const QRectF HandZone::boundingRect() const
{ {
if (SettingsCache::instance()->getHorizontalHand()) if (SettingsCache::instance().getHorizontalHand())
return QRectF(0, 0, width, CARD_HEIGHT + 10); return QRectF(0, 0, width, CARD_HEIGHT + 10);
else else
return QRectF(0, 0, 100, zoneHeight); return QRectF(0, 0, 100, zoneHeight);
@ -70,8 +70,8 @@ void HandZone::reorganizeCards()
{ {
if (!getLogic()->getCards().isEmpty()) { if (!getLogic()->getCards().isEmpty()) {
const int cardCount = getLogic()->getCards().size(); const int cardCount = getLogic()->getCards().size();
if (SettingsCache::instance()->getHorizontalHand()) { if (SettingsCache::instance().getHorizontalHand()) {
bool leftJustified = SettingsCache::instance()->getLeftJustified(); bool leftJustified = SettingsCache::instance().getLeftJustified();
qreal cardWidth = getLogic()->getCards().at(0)->boundingRect().width(); qreal cardWidth = getLogic()->getCards().at(0)->boundingRect().width();
const int xPadding = leftJustified ? cardWidth * 1.4 : 5; const int xPadding = leftJustified ? cardWidth * 1.4 : 5;
qreal totalWidth = qreal totalWidth =
@ -122,7 +122,7 @@ void HandZone::sortHand()
void HandZone::setWidth(qreal _width) void HandZone::setWidth(qreal _width)
{ {
if (SettingsCache::instance()->getHorizontalHand()) { if (SettingsCache::instance().getHorizontalHand()) {
prepareGeometryChange(); prepareGeometryChange();
width = _width; width = _width;
reorganizeCards(); reorganizeCards();

View file

@ -57,7 +57,7 @@ bool ZoneViewZoneLogic::prepareAddCard(int x)
// autoclose check is done both here and in removeCard // autoclose check is done both here and in removeCard
if (cards.isEmpty() && !doInsert && SettingsCache::instance()->getCloseEmptyCardView()) { if (cards.isEmpty() && !doInsert && SettingsCache::instance().getCloseEmptyCardView()) {
emit closeView(); emit closeView();
} }
@ -144,7 +144,7 @@ void ZoneViewZoneLogic::removeCard(int position, bool toNewZone)
// card gets dragged within the view. // card gets dragged within the view.
// Another autoclose check is done in prepareAddCard so that the view autocloses if the last card was moved to an // Another autoclose check is done in prepareAddCard so that the view autocloses if the last card was moved to an
// unrevealed portion of the same zone. // unrevealed portion of the same zone.
if (cards.isEmpty() && SettingsCache::instance()->getCloseEmptyCardView() && toNewZone) { if (cards.isEmpty() && SettingsCache::instance().getCloseEmptyCardView() && toNewZone) {
emit closeView(); emit closeView();
return; return;
} }

View file

@ -22,13 +22,12 @@ PileZone::PileZone(PileZoneLogic *_logic, QGraphicsItem *parent) : CardZone(_log
.rotate(90) .rotate(90)
.translate((float)-CARD_WIDTH / 2, (float)-CARD_HEIGHT / 2)); .translate((float)-CARD_WIDTH / 2, (float)-CARD_HEIGHT / 2));
connect(SettingsCache::instance().get(), &SettingsCache::roundCardCornersChanged, this, connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) {
[this](bool _roundCardCorners) { Q_UNUSED(_roundCardCorners);
Q_UNUSED(_roundCardCorners);
prepareGeometryChange(); prepareGeometryChange();
update(); update();
}); });
} }
QRectF PileZone::boundingRect() const QRectF PileZone::boundingRect() const
@ -39,7 +38,7 @@ QRectF PileZone::boundingRect() const
QPainterPath PileZone::shape() const QPainterPath PileZone::shape() const
{ {
QPainterPath shape; QPainterPath shape;
qreal cardCornerRadius = SettingsCache::instance()->getRoundCardCorners() ? 0.05 * CARD_WIDTH : 0.0; qreal cardCornerRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * CARD_WIDTH : 0.0;
shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius); shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius);
return shape; return shape;
} }

View file

@ -9,7 +9,7 @@
qreal divideCardSpaceInZone(qreal index, int cardCount, qreal totalHeight, qreal cardHeight, bool reverse) qreal divideCardSpaceInZone(qreal index, int cardCount, qreal totalHeight, qreal cardHeight, bool reverse)
{ {
qreal cardMinOverlap = cardHeight * SettingsCache::instance()->getStackCardOverlapPercent() / 100; qreal cardMinOverlap = cardHeight * SettingsCache::instance().getStackCardOverlapPercent() / 100;
qreal desiredHeight = cardHeight * cardCount - cardMinOverlap * (cardCount - 1); qreal desiredHeight = cardHeight * cardCount - cardMinOverlap * (cardCount - 1);
qreal y; qreal y;
if (desiredHeight > totalHeight) { if (desiredHeight > totalHeight) {

View file

@ -25,7 +25,7 @@ TableZone::TableZone(TableZoneLogic *_logic, QGraphicsItem *parent) : SelectZone
connect(_logic, &TableZoneLogic::contentSizeChanged, this, &TableZone::resizeToContents); connect(_logic, &TableZoneLogic::contentSizeChanged, this, &TableZone::resizeToContents);
connect(_logic, &TableZoneLogic::toggleTapped, this, &TableZone::toggleTapped); connect(_logic, &TableZoneLogic::toggleTapped, this, &TableZone::toggleTapped);
connect(themeManager, &ThemeManager::themeChanged, this, &TableZone::updateBg); connect(themeManager, &ThemeManager::themeChanged, this, &TableZone::updateBg);
connect(SettingsCache::instance().get(), &SettingsCache::invertVerticalCoordinateChanged, this, connect(&SettingsCache::instance(), &SettingsCache::invertVerticalCoordinateChanged, this,
&TableZone::reorganizeCards); &TableZone::reorganizeCards);
updateBg(); updateBg();
@ -51,9 +51,9 @@ QRectF TableZone::boundingRect() const
bool TableZone::isInverted() const bool TableZone::isInverted() const
{ {
return ((getLogic()->getPlayer()->getGraphicsItem()->getMirrored() && return ((getLogic()->getPlayer()->getGraphicsItem()->getMirrored() &&
!SettingsCache::instance()->getInvertVerticalCoordinate()) || !SettingsCache::instance().getInvertVerticalCoordinate()) ||
(!getLogic()->getPlayer()->getGraphicsItem()->getMirrored() && (!getLogic()->getPlayer()->getGraphicsItem()->getMirrored() &&
SettingsCache::instance()->getInvertVerticalCoordinate())); SettingsCache::instance().getInvertVerticalCoordinate()));
} }
void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)

View file

@ -56,7 +56,7 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
connect(help, &QAction::triggered, this, [this] { createSearchSyntaxHelpWindow(&searchEdit); }); connect(help, &QAction::triggered, this, [this] { createSearchSyntaxHelpWindow(&searchEdit); });
if (SettingsCache::instance()->getFocusCardViewSearchBar()) { if (SettingsCache::instance().getFocusCardViewSearchBar()) {
this->setActive(true); this->setActive(true);
searchEdit.setFocus(); searchEdit.setFocus();
} }
@ -144,9 +144,9 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
connect(&sortBySelector, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, connect(&sortBySelector, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ZoneViewWidget::processSortBy); &ZoneViewWidget::processSortBy);
connect(&pileViewCheckBox, &QCheckBox::QT_STATE_CHANGED, this, &ZoneViewWidget::processSetPileView); connect(&pileViewCheckBox, &QCheckBox::QT_STATE_CHANGED, this, &ZoneViewWidget::processSetPileView);
groupBySelector.setCurrentIndex(SettingsCache::instance()->getZoneViewGroupByIndex()); groupBySelector.setCurrentIndex(SettingsCache::instance().getZoneViewGroupByIndex());
sortBySelector.setCurrentIndex(SettingsCache::instance()->getZoneViewSortByIndex()); sortBySelector.setCurrentIndex(SettingsCache::instance().getZoneViewSortByIndex());
pileViewCheckBox.setChecked(SettingsCache::instance()->getZoneViewPileView()); pileViewCheckBox.setChecked(SettingsCache::instance().getZoneViewPileView());
if (CardList::NoSort == static_cast<CardList::SortOption>(groupBySelector.currentData().toInt())) { if (CardList::NoSort == static_cast<CardList::SortOption>(groupBySelector.currentData().toInt())) {
pileViewCheckBox.setEnabled(false); pileViewCheckBox.setEnabled(false);
@ -176,7 +176,7 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
void ZoneViewWidget::processGroupBy(int index) void ZoneViewWidget::processGroupBy(int index)
{ {
auto option = static_cast<CardList::SortOption>(groupBySelector.itemData(index).toInt()); auto option = static_cast<CardList::SortOption>(groupBySelector.itemData(index).toInt());
SettingsCache::instance()->setZoneViewGroupByIndex(index); SettingsCache::instance().setZoneViewGroupByIndex(index);
zone->setGroupBy(option); zone->setGroupBy(option);
// disable pile view checkbox if we're not grouping by anything // disable pile view checkbox if we're not grouping by anything
@ -200,13 +200,13 @@ void ZoneViewWidget::processSortBy(int index)
return; return;
} }
SettingsCache::instance()->setZoneViewSortByIndex(index); SettingsCache::instance().setZoneViewSortByIndex(index);
zone->setSortBy(option); zone->setSortBy(option);
} }
void ZoneViewWidget::processSetPileView(QT_STATE_CHANGED_T value) void ZoneViewWidget::processSetPileView(QT_STATE_CHANGED_T value)
{ {
SettingsCache::instance()->setZoneViewPileView(value); SettingsCache::instance().setZoneViewPileView(value);
zone->setPileView(value); zone->setPileView(value);
} }
@ -301,7 +301,7 @@ static qreal rowsToHeight(int rows)
**/ **/
static qreal calcMaxInitialHeight() static qreal calcMaxInitialHeight()
{ {
return rowsToHeight(SettingsCache::instance()->getCardViewInitialRowsMax()); return rowsToHeight(SettingsCache::instance().getCardViewInitialRowsMax());
} }
/** /**
@ -379,7 +379,7 @@ void ZoneViewWidget::initStyleOption(QStyleOption *option) const
void ZoneViewWidget::expandWindow() void ZoneViewWidget::expandWindow()
{ {
qreal maxInitialHeight = calcMaxInitialHeight(); qreal maxInitialHeight = calcMaxInitialHeight();
qreal maxExpandedHeight = rowsToHeight(SettingsCache::instance()->getCardViewExpandedRowsMax()); qreal maxExpandedHeight = rowsToHeight(SettingsCache::instance().getCardViewExpandedRowsMax());
qreal height = rect().height() - extraHeight - 10; qreal height = rect().height() - extraHeight - 10;
qreal maxHeight = maximumHeight() - extraHeight - 10; qreal maxHeight = maximumHeight() - extraHeight - 10;

View file

@ -25,9 +25,8 @@
CardPictureLoader::CardPictureLoader() : QObject(nullptr) CardPictureLoader::CardPictureLoader() : QObject(nullptr)
{ {
worker = new CardPictureLoaderWorker; worker = new CardPictureLoaderWorker;
connect(SettingsCache::instance().get(), &SettingsCache::picsPathChanged, this, connect(&SettingsCache::instance(), &SettingsCache::picsPathChanged, this, &CardPictureLoader::picsPathChanged);
&CardPictureLoader::picsPathChanged); connect(&SettingsCache::instance(), &SettingsCache::picDownloadChanged, this,
connect(SettingsCache::instance().get(), &SettingsCache::picDownloadChanged, this,
&CardPictureLoader::picDownloadChanged); &CardPictureLoader::picDownloadChanged);
connect(worker, &CardPictureLoaderWorker::imageLoaded, this, &CardPictureLoader::imageLoaded); connect(worker, &CardPictureLoaderWorker::imageLoaded, this, &CardPictureLoader::imageLoaded);
@ -217,7 +216,7 @@ void CardPictureLoader::picsPathChanged()
bool CardPictureLoader::hasCustomArt() bool CardPictureLoader::hasCustomArt()
{ {
auto picsPath = SettingsCache::instance()->getPicsPath(); auto picsPath = SettingsCache::instance().getPicsPath();
QDirIterator it(picsPath, QDir::Dirs | QDir::NoDotAndDotDot); QDirIterator it(picsPath, QDir::Dirs | QDir::NoDotAndDotDot);
// Check if there is at least one non-directory file in the pics path, other // Check if there is at least one non-directory file in the pics path, other

View file

@ -10,11 +10,11 @@
static constexpr int REFRESH_INTERVAL_MS = 10 * 1000; static constexpr int REFRESH_INTERVAL_MS = 10 * 1000;
CardPictureLoaderLocal::CardPictureLoaderLocal(QObject *parent) CardPictureLoaderLocal::CardPictureLoaderLocal(QObject *parent)
: QObject(parent), picsPath(SettingsCache::instance()->getPicsPath()), : QObject(parent), picsPath(SettingsCache::instance().getPicsPath()),
customPicsPath(SettingsCache::instance()->getCustomPicsPath()) customPicsPath(SettingsCache::instance().getCustomPicsPath())
{ {
// Hook up signals to settings // Hook up signals to settings
connect(SettingsCache::instance().get(), &SettingsCache::picsPathChanged, this, connect(&SettingsCache::instance(), &SettingsCache::picsPathChanged, this,
&CardPictureLoaderLocal::picsPathChanged); &CardPictureLoaderLocal::picsPathChanged);
refreshIndex(); refreshIndex();
@ -150,6 +150,6 @@ QImage CardPictureLoaderLocal::tryLoadCardImageFromDisk(const QString &setName,
void CardPictureLoaderLocal::picsPathChanged() void CardPictureLoaderLocal::picsPathChanged()
{ {
picsPath = SettingsCache::instance()->getPicsPath(); picsPath = SettingsCache::instance().getPicsPath();
customPicsPath = SettingsCache::instance()->getCustomPicsPath(); customPicsPath = SettingsCache::instance().getCustomPicsPath();
} }

View file

@ -15,7 +15,7 @@
static constexpr int MAX_REQUESTS_PER_SEC = 10; static constexpr int MAX_REQUESTS_PER_SEC = 10;
CardPictureLoaderWorker::CardPictureLoaderWorker() CardPictureLoaderWorker::CardPictureLoaderWorker()
: QObject(nullptr), picDownload(SettingsCache::instance()->getPicDownload()), requestQuota(MAX_REQUESTS_PER_SEC) : QObject(nullptr), picDownload(SettingsCache::instance().getPicDownload()), requestQuota(MAX_REQUESTS_PER_SEC)
{ {
networkManager = new QNetworkAccessManager(this); networkManager = new QNetworkAccessManager(this);
// We need a timeout to ensure requests don't hang indefinitely in case of // We need a timeout to ensure requests don't hang indefinitely in case of
@ -25,18 +25,18 @@ CardPictureLoaderWorker::CardPictureLoaderWorker()
networkManager->setTransferTimeout(); networkManager->setTransferTimeout();
#endif #endif
cache = new QNetworkDiskCache(this); cache = new QNetworkDiskCache(this);
cache->setCacheDirectory(SettingsCache::instance()->getNetworkCachePath()); cache->setCacheDirectory(SettingsCache::instance().getNetworkCachePath());
cache->setMaximumCacheSize(1024L * 1024L * cache->setMaximumCacheSize(1024L * 1024L *
static_cast<qint64>(SettingsCache::instance()->getNetworkCacheSizeInMB())); static_cast<qint64>(SettingsCache::instance().getNetworkCacheSizeInMB()));
// Note: the settings is in MB, but QNetworkDiskCache uses bytes // Note: the settings is in MB, but QNetworkDiskCache uses bytes
connect(SettingsCache::instance().get(), &SettingsCache::networkCacheSizeChanged, this, connect(&SettingsCache::instance(), &SettingsCache::networkCacheSizeChanged, this,
[this](int newSizeInMB) { cache->setMaximumCacheSize(1024L * 1024L * static_cast<qint64>(newSizeInMB)); }); [this](int newSizeInMB) { cache->setMaximumCacheSize(1024L * 1024L * static_cast<qint64>(newSizeInMB)); });
networkManager->setCache(cache); networkManager->setCache(cache);
// Use a ManualRedirectPolicy since we keep track of redirects in picDownloadFinished // Use a ManualRedirectPolicy since we keep track of redirects in picDownloadFinished
// We can't use NoLessSafeRedirectPolicy because it is not applied with AlwaysCache // We can't use NoLessSafeRedirectPolicy because it is not applied with AlwaysCache
networkManager->setRedirectPolicy(QNetworkRequest::ManualRedirectPolicy); networkManager->setRedirectPolicy(QNetworkRequest::ManualRedirectPolicy);
cacheFilePath = SettingsCache::instance()->getRedirectCachePath() + REDIRECT_CACHE_FILENAME; cacheFilePath = SettingsCache::instance().getRedirectCachePath() + REDIRECT_CACHE_FILENAME;
loadRedirectCache(); loadRedirectCache();
cleanStaleEntries(); cleanStaleEntries();
@ -223,7 +223,7 @@ void CardPictureLoaderWorker::cleanStaleEntries()
auto it = redirectCache.begin(); auto it = redirectCache.begin();
while (it != redirectCache.end()) { while (it != redirectCache.end()) {
if (it.value().second.addDays(SettingsCache::instance()->getRedirectCacheTtl()) < now) { if (it.value().second.addDays(SettingsCache::instance().getRedirectCacheTtl()) < now) {
it = redirectCache.erase(it); // Remove stale entry it = redirectCache.erase(it); // Remove stale entry
} else { } else {
++it; ++it;

View file

@ -18,7 +18,7 @@ static const QStringList MD5_BLACKLIST = {"db0c48db407a907c16ade38de048a441"};
CardPictureLoaderWorkerWork::CardPictureLoaderWorkerWork(const CardPictureLoaderWorker *worker, const ExactCard &toLoad) CardPictureLoaderWorkerWork::CardPictureLoaderWorkerWork(const CardPictureLoaderWorker *worker, const ExactCard &toLoad)
: QObject(nullptr), cardToDownload(CardPictureToLoad(toLoad)), : QObject(nullptr), cardToDownload(CardPictureToLoad(toLoad)),
picDownload(SettingsCache::instance()->getPicDownload()) picDownload(SettingsCache::instance().getPicDownload())
{ {
// Hook up signals to the orchestrator // Hook up signals to the orchestrator
connect(this, &CardPictureLoaderWorkerWork::requestImageDownload, worker, &CardPictureLoaderWorker::queueRequest); connect(this, &CardPictureLoaderWorkerWork::requestImageDownload, worker, &CardPictureLoaderWorker::queueRequest);
@ -30,7 +30,7 @@ CardPictureLoaderWorkerWork::CardPictureLoaderWorkerWork(const CardPictureLoader
&CardPictureLoaderWorker::imageRequestSucceeded); &CardPictureLoaderWorker::imageRequestSucceeded);
// Hook up signals to settings // Hook up signals to settings
connect(SettingsCache::instance().get(), SIGNAL(picDownloadChanged()), this, SLOT(picDownloadChanged())); connect(&SettingsCache::instance(), SIGNAL(picDownloadChanged()), this, SLOT(picDownloadChanged()));
startNextPicDownload(); startNextPicDownload();
} }
@ -219,5 +219,5 @@ void CardPictureLoaderWorkerWork::concludeImageLoad(const QImage &image)
void CardPictureLoaderWorkerWork::picDownloadChanged() void CardPictureLoaderWorkerWork::picDownloadChanged()
{ {
picDownload = SettingsCache::instance()->getPicDownload(); picDownload = SettingsCache::instance().getPicDownload();
} }

View file

@ -10,7 +10,7 @@
#include <libcockatrice/card/set/card_set_comparator.h> #include <libcockatrice/card/set/card_set_comparator.h>
CardPictureToLoad::CardPictureToLoad(const ExactCard &_card) CardPictureToLoad::CardPictureToLoad(const ExactCard &_card)
: card(_card), urlTemplates(SettingsCache::instance()->downloads().getAllURLs()) : card(_card), urlTemplates(SettingsCache::instance().downloads().getAllURLs())
{ {
if (card) { if (card) {
sortedSets = extractSetsSorted(card); sortedSets = extractSetsSorted(card);
@ -34,12 +34,12 @@ QList<CardSetPtr> CardPictureToLoad::extractSetsSorted(const ExactCard &card)
} }
} }
if (sortedSets.empty()) { if (sortedSets.empty()) {
sortedSets << CardSet::newInstance(SettingsCache::instance()->cardDatabase(), "", "", "", QDate()); sortedSets << CardSet::newInstance(SettingsCache::instance().cardDatabase(), "", "", "", QDate());
} }
std::sort(sortedSets.begin(), sortedSets.end(), SetPriorityComparator()); std::sort(sortedSets.begin(), sortedSets.end(), SetPriorityComparator());
// If the user hasn't disabled arts other than their personal preference... // If the user hasn't disabled arts other than their personal preference...
if (!SettingsCache::instance()->getOverrideAllCardArtWithPersonalPreference()) { if (!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
// If the pixmapCacheKey corresponds to a specific set, we have to try to load it first. // If the pixmapCacheKey corresponds to a specific set, we have to try to load it first.
qsizetype setIndex = sortedSets.indexOf(card.getPrinting().getSet()); qsizetype setIndex = sortedSets.indexOf(card.getPrinting().getSet());
if (setIndex > 0) { // we don't need to move the set if it's already first if (setIndex > 0) { // we don't need to move the set if it's already first

View file

@ -24,16 +24,16 @@ static const QStringList DEFAULT_RESOURCE_PATHS = {":/resources"};
ThemeManager::ThemeManager(QObject *parent) : QObject(parent) ThemeManager::ThemeManager(QObject *parent) : QObject(parent)
{ {
ensureThemeDirectoryExists(); ensureThemeDirectoryExists();
connect(SettingsCache::instance().get(), &SettingsCache::themeChanged, this, &ThemeManager::themeChangedSlot); connect(&SettingsCache::instance(), &SettingsCache::themeChanged, this, &ThemeManager::themeChangedSlot);
themeChangedSlot(); themeChangedSlot();
} }
void ThemeManager::ensureThemeDirectoryExists() void ThemeManager::ensureThemeDirectoryExists()
{ {
if (SettingsCache::instance()->getThemeName().isEmpty() || if (SettingsCache::instance().getThemeName().isEmpty() ||
!getAvailableThemes().contains(SettingsCache::instance()->getThemeName())) { !getAvailableThemes().contains(SettingsCache::instance().getThemeName())) {
qCInfo(ThemeManagerLog) << "Theme name not set, setting default value"; qCInfo(ThemeManagerLog) << "Theme name not set, setting default value";
SettingsCache::instance()->setThemeName(NONE_THEME_NAME); SettingsCache::instance().setThemeName(NONE_THEME_NAME);
} }
} }
@ -46,7 +46,7 @@ QStringMap &ThemeManager::getAvailableThemes()
availableThemes.insert(NONE_THEME_NAME, QString()); availableThemes.insert(NONE_THEME_NAME, QString());
// load themes from user profile dir // load themes from user profile dir
dir.setPath(SettingsCache::instance()->getThemesPath()); dir.setPath(SettingsCache::instance().getThemesPath());
for (QString themeName : dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name)) { for (QString themeName : dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name)) {
if (!availableThemes.contains(themeName)) { if (!availableThemes.contains(themeName)) {
@ -104,7 +104,7 @@ QBrush ThemeManager::loadExtraBrush(QString fileName, QBrush &fallbackBrush)
void ThemeManager::themeChangedSlot() void ThemeManager::themeChangedSlot()
{ {
QString themeName = SettingsCache::instance()->getThemeName(); QString themeName = SettingsCache::instance().getThemeName();
qCInfo(ThemeManagerLog) << "Theme changed:" << themeName; qCInfo(ThemeManagerLog) << "Theme changed:" << themeName;
QString dirPath = getAvailableThemes().value(themeName); QString dirPath = getAvailableThemes().value(themeName);

View file

@ -27,7 +27,7 @@ ColorIdentityWidget::ColorIdentityWidget(QWidget *parent, CardInfoPtr _card) : Q
populateManaSymbolWidgets(); populateManaSymbolWidgets();
} }
connect(SettingsCache::instance().get(), &SettingsCache::visualDeckStorageDrawUnusedColorIdentitiesChanged, this, connect(&SettingsCache::instance(), &SettingsCache::visualDeckStorageDrawUnusedColorIdentitiesChanged, this,
&ColorIdentityWidget::toggleUnusedVisibility); &ColorIdentityWidget::toggleUnusedVisibility);
} }
@ -42,7 +42,7 @@ ColorIdentityWidget::ColorIdentityWidget(QWidget *parent, QString _manaCost)
populateManaSymbolWidgets(); populateManaSymbolWidgets();
connect(SettingsCache::instance().get(), &SettingsCache::visualDeckStorageDrawUnusedColorIdentitiesChanged, this, connect(&SettingsCache::instance(), &SettingsCache::visualDeckStorageDrawUnusedColorIdentitiesChanged, this,
&ColorIdentityWidget::toggleUnusedVisibility); &ColorIdentityWidget::toggleUnusedVisibility);
} }
@ -52,7 +52,7 @@ void ColorIdentityWidget::populateManaSymbolWidgets()
QString fullColorIdentity = "WUBRG"; QString fullColorIdentity = "WUBRG";
QStringList symbols = parseColorIdentity(manaCost); // Parse mana cost string QStringList symbols = parseColorIdentity(manaCost); // Parse mana cost string
if (SettingsCache::instance()->getVisualDeckStorageDrawUnusedColorIdentities()) { if (SettingsCache::instance().getVisualDeckStorageDrawUnusedColorIdentities()) {
for (const QString symbol : fullColorIdentity) { for (const QString symbol : fullColorIdentity) {
auto *manaSymbol = new ManaSymbolWidget(this, symbol, symbols.contains(symbol)); auto *manaSymbol = new ManaSymbolWidget(this, symbol, symbols.contains(symbol));
layout->addWidget(manaSymbol); layout->addWidget(manaSymbol);

View file

@ -16,7 +16,7 @@ ManaSymbolWidget::ManaSymbolWidget(QWidget *parent, QString _symbol, bool _isAct
setGraphicsEffect(opacityEffect); setGraphicsEffect(opacityEffect);
updateOpacity(); updateOpacity();
connect(SettingsCache::instance().get(), &SettingsCache::visualDeckStorageUnusedColorIdentitiesOpacityChanged, this, connect(&SettingsCache::instance(), &SettingsCache::visualDeckStorageUnusedColorIdentitiesOpacityChanged, this,
&ManaSymbolWidget::updateOpacity); &ManaSymbolWidget::updateOpacity);
} }
@ -42,8 +42,7 @@ void ManaSymbolWidget::updateOpacity()
opacity = isActive ? 1.0 : 0.5; opacity = isActive ? 1.0 : 0.5;
} else { } else {
// It's just for display, they can do whatever they want. // It's just for display, they can do whatever they want.
opacity = opacity = isActive ? 1.0 : SettingsCache::instance().getVisualDeckStorageUnusedColorIdentitiesOpacity() / 100.0;
isActive ? 1.0 : SettingsCache::instance()->getVisualDeckStorageUnusedColorIdentitiesOpacity() / 100.0;
} }
opacityEffect->setOpacity(opacity); opacityEffect->setOpacity(opacity);
} }

View file

@ -61,7 +61,7 @@ CardInfoFrameWidget::CardInfoFrameWidget(QWidget *parent)
tab3Layout->addWidget(splitter); tab3Layout->addWidget(splitter);
tab3->setLayout(tab3Layout); tab3->setLayout(tab3Layout);
setViewMode(SettingsCache::instance()->getCardInfoViewMode()); setViewMode(SettingsCache::instance().getCardInfoViewMode());
} }
void CardInfoFrameWidget::retranslateUi() void CardInfoFrameWidget::retranslateUi()
@ -128,7 +128,7 @@ void CardInfoFrameWidget::setViewMode(int mode)
refreshLayout(); refreshLayout();
SettingsCache::instance()->setCardInfoViewMode(mode); SettingsCache::instance().setCardInfoViewMode(mode);
} }
static bool hasTransformation(const CardInfo &info) static bool hasTransformation(const CardInfo &info)

View file

@ -18,12 +18,11 @@ CardInfoPictureEnlargedWidget::CardInfoPictureEnlargedWidget(QWidget *parent) :
setWindowFlags(Qt::ToolTip); // Keeps this widget on top of everything setWindowFlags(Qt::ToolTip); // Keeps this widget on top of everything
setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_TranslucentBackground);
connect(SettingsCache::instance().get(), &SettingsCache::roundCardCornersChanged, this, connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) {
[this](bool _roundCardCorners) { Q_UNUSED(_roundCardCorners);
Q_UNUSED(_roundCardCorners);
update(); update();
}); });
} }
/** /**
@ -87,7 +86,7 @@ void CardInfoPictureEnlargedWidget::paintEvent(QPaintEvent *event)
// Define the radius for rounded corners // Define the radius for rounded corners
// Adjust the radius as needed for rounded corners // Adjust the radius as needed for rounded corners
qreal radius = SettingsCache::instance()->getRoundCardCorners() ? 0.05 * scaledSize.width() : 0.; qreal radius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * scaledSize.width() : 0.;
QStylePainter painter(this); QStylePainter painter(this);
// Fill the background with transparent color to ensure rounded corners are rendered properly // Fill the background with transparent color to ensure rounded corners are rendered properly

View file

@ -58,12 +58,11 @@ CardInfoPictureWidget::CardInfoPictureWidget(QWidget *parent, const bool _hoverT
animation->setStartValue(originalPos); animation->setStartValue(originalPos);
animation->setEndValue(originalPos - QPoint(0, animationOffset)); animation->setEndValue(originalPos - QPoint(0, animationOffset));
connect(SettingsCache::instance().get(), &SettingsCache::roundCardCornersChanged, this, connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) {
[this](bool _roundCardCorners) { Q_UNUSED(_roundCardCorners);
Q_UNUSED(_roundCardCorners);
update(); update();
}); });
} }
/** /**
@ -183,7 +182,7 @@ void CardInfoPictureWidget::paintEvent(QPaintEvent *event)
} }
QPixmap transformedPixmap = resizedPixmap; // Default pixmap QPixmap transformedPixmap = resizedPixmap; // Default pixmap
if (SettingsCache::instance()->getAutoRotateSidewaysLayoutCards()) { if (SettingsCache::instance().getAutoRotateSidewaysLayoutCards()) {
if (exactCard.getInfo().getLandscapeOrientation()) { if (exactCard.getInfo().getLandscapeOrientation()) {
// Rotate pixmap 90 degrees to the left // Rotate pixmap 90 degrees to the left
QTransform transform; QTransform transform;
@ -213,8 +212,7 @@ void CardInfoPictureWidget::paintEvent(QPaintEvent *event)
// Compute rounded corner radius // Compute rounded corner radius
// Ensure consistent rounding // Ensure consistent rounding
qreal radius = qreal radius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * static_cast<qreal>(targetRect.width()) : 0.;
SettingsCache::instance()->getRoundCardCorners() ? 0.05 * static_cast<qreal>(targetRect.width()) : 0.;
// Draw the pixmap with rounded corners // Draw the pixmap with rounded corners
QStylePainter painter(this); QStylePainter painter(this);

View file

@ -40,7 +40,7 @@ DeckPreviewCardPictureWidget::DeckPreviewCardPictureWidget(QWidget *parent,
singleClickTimer = new QTimer(this); singleClickTimer = new QTimer(this);
singleClickTimer->setSingleShot(true); singleClickTimer->setSingleShot(true);
connect(singleClickTimer, &QTimer::timeout, this, [this]() { emit imageClicked(lastMouseEvent, this); }); connect(singleClickTimer, &QTimer::timeout, this, [this]() { emit imageClicked(lastMouseEvent, this); });
connect(SettingsCache::instance().get(), &SettingsCache::visualDeckStorageSelectionAnimationChanged, this, connect(&SettingsCache::instance(), &SettingsCache::visualDeckStorageSelectionAnimationChanged, this,
&CardInfoPictureWidget::setRaiseOnEnterEnabled); &CardInfoPictureWidget::setRaiseOnEnterEnabled);
} }

View file

@ -83,7 +83,7 @@ DeckEditorDatabaseDisplayWidget::DeckEditorDatabaseDisplayWidget(AbstractTabDeck
&DeckEditorDatabaseDisplayWidget::updateCard); &DeckEditorDatabaseDisplayWidget::updateCard);
connect(databaseView, &QTreeView::doubleClicked, this, &DeckEditorDatabaseDisplayWidget::actAddCardToMainDeck); connect(databaseView, &QTreeView::doubleClicked, this, &DeckEditorDatabaseDisplayWidget::actAddCardToMainDeck);
QByteArray dbHeaderState = SettingsCache::instance()->layouts().getDeckEditorDbHeaderState(); QByteArray dbHeaderState = SettingsCache::instance().layouts().getDeckEditorDbHeaderState();
if (dbHeaderState.isNull()) { if (dbHeaderState.isNull()) {
// first run // first run
databaseView->setColumnWidth(0, 200); databaseView->setColumnWidth(0, 200);
@ -189,7 +189,7 @@ void DeckEditorDatabaseDisplayWidget::databaseCustomMenu(QPoint point)
QAction *addToDeck, *addToSideboard, *selectPrinting, *edhRecCommander, *edhRecCard; QAction *addToDeck, *addToSideboard, *selectPrinting, *edhRecCommander, *edhRecCard;
addToDeck = menu.addAction(tr("Add to Deck")); addToDeck = menu.addAction(tr("Add to Deck"));
addToSideboard = menu.addAction(tr("Add to Sideboard")); addToSideboard = menu.addAction(tr("Add to Sideboard"));
if (!SettingsCache::instance()->getOverrideAllCardArtWithPersonalPreference()) { if (!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
selectPrinting = menu.addAction(tr("Select Printing")); selectPrinting = menu.addAction(tr("Select Printing"));
connect(selectPrinting, &QAction::triggered, this, [this, card] { deckEditor->showPrintingSelector(); }); connect(selectPrinting, &QAction::triggered, this, [this, card] { deckEditor->showPrintingSelector(); });
} }
@ -232,7 +232,7 @@ void DeckEditorDatabaseDisplayWidget::copyDatabaseCellContents()
void DeckEditorDatabaseDisplayWidget::saveDbHeaderState() void DeckEditorDatabaseDisplayWidget::saveDbHeaderState()
{ {
SettingsCache::instance()->layouts().setDeckEditorDbHeaderState(databaseView->header()->saveState()); SettingsCache::instance().layouts().setDeckEditorDbHeaderState(databaseView->header()->saveState());
} }
void DeckEditorDatabaseDisplayWidget::setFilterTree(FilterTree *filterTree) void DeckEditorDatabaseDisplayWidget::setFilterTree(FilterTree *filterTree)

View file

@ -63,18 +63,18 @@ void DeckEditorDeckDockWidget::createDeckDock()
showBannerCardCheckBox = new QCheckBox(); showBannerCardCheckBox = new QCheckBox();
showBannerCardCheckBox->setObjectName("showBannerCardCheckBox"); showBannerCardCheckBox->setObjectName("showBannerCardCheckBox");
showBannerCardCheckBox->setChecked(SettingsCache::instance()->getDeckEditorBannerCardComboBoxVisible()); showBannerCardCheckBox->setChecked(SettingsCache::instance().getDeckEditorBannerCardComboBoxVisible());
connect(showBannerCardCheckBox, &QCheckBox::QT_STATE_CHANGED, SettingsCache::instance().get(), connect(showBannerCardCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setDeckEditorBannerCardComboBoxVisible); &SettingsCache::setDeckEditorBannerCardComboBoxVisible);
connect(SettingsCache::instance().get(), &SettingsCache::deckEditorBannerCardComboBoxVisibleChanged, this, connect(&SettingsCache::instance(), &SettingsCache::deckEditorBannerCardComboBoxVisibleChanged, this,
&DeckEditorDeckDockWidget::updateShowBannerCardComboBox); &DeckEditorDeckDockWidget::updateShowBannerCardComboBox);
showTagsWidgetCheckBox = new QCheckBox(); showTagsWidgetCheckBox = new QCheckBox();
showTagsWidgetCheckBox->setObjectName("showTagsWidgetCheckBox"); showTagsWidgetCheckBox->setObjectName("showTagsWidgetCheckBox");
showTagsWidgetCheckBox->setChecked(SettingsCache::instance()->getDeckEditorTagsWidgetVisible()); showTagsWidgetCheckBox->setChecked(SettingsCache::instance().getDeckEditorTagsWidgetVisible());
connect(showTagsWidgetCheckBox, &QCheckBox::QT_STATE_CHANGED, SettingsCache::instance().get(), connect(showTagsWidgetCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setDeckEditorTagsWidgetVisible); &SettingsCache::setDeckEditorTagsWidgetVisible);
connect(SettingsCache::instance().get(), &SettingsCache::deckEditorTagsWidgetVisibleChanged, this, connect(&SettingsCache::instance(), &SettingsCache::deckEditorTagsWidgetVisibleChanged, this,
&DeckEditorDeckDockWidget::updateShowTagsWidget); &DeckEditorDeckDockWidget::updateShowTagsWidget);
quickSettingsWidget->addSettingsWidget(showBannerCardCheckBox); quickSettingsWidget->addSettingsWidget(showBannerCardCheckBox);
@ -91,7 +91,7 @@ void DeckEditorDeckDockWidget::createDeckDock()
bannerCardLabel = new QLabel(); bannerCardLabel = new QLabel();
bannerCardLabel->setObjectName("bannerCardLabel"); bannerCardLabel->setObjectName("bannerCardLabel");
bannerCardLabel->setText(tr("Banner Card")); bannerCardLabel->setText(tr("Banner Card"));
bannerCardLabel->setHidden(!SettingsCache::instance()->getDeckEditorBannerCardComboBoxVisible()); bannerCardLabel->setHidden(!SettingsCache::instance().getDeckEditorBannerCardComboBoxVisible());
bannerCardComboBox = new QComboBox(this); bannerCardComboBox = new QComboBox(this);
connect(deckModel, &DeckListModel::dataChanged, this, [this]() { connect(deckModel, &DeckListModel::dataChanged, this, [this]() {
// Delay the update to avoid race conditions // Delay the update to avoid race conditions
@ -99,10 +99,10 @@ void DeckEditorDeckDockWidget::createDeckDock()
}); });
connect(bannerCardComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(bannerCardComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DeckEditorDeckDockWidget::setBannerCard); &DeckEditorDeckDockWidget::setBannerCard);
bannerCardComboBox->setHidden(!SettingsCache::instance()->getDeckEditorBannerCardComboBoxVisible()); bannerCardComboBox->setHidden(!SettingsCache::instance().getDeckEditorBannerCardComboBoxVisible());
deckTagsDisplayWidget = new DeckPreviewDeckTagsDisplayWidget(this, deckModel->getDeckList()); deckTagsDisplayWidget = new DeckPreviewDeckTagsDisplayWidget(this, deckModel->getDeckList());
deckTagsDisplayWidget->setHidden(!SettingsCache::instance()->getDeckEditorTagsWidgetVisible()); deckTagsDisplayWidget->setHidden(!SettingsCache::instance().getDeckEditorTagsWidgetVisible());
activeGroupCriteriaLabel = new QLabel(this); activeGroupCriteriaLabel = new QLabel(this);
@ -577,7 +577,7 @@ void DeckEditorDeckDockWidget::offsetCountAtIndex(const QModelIndex &idx, int of
void DeckEditorDeckDockWidget::decklistCustomMenu(QPoint point) void DeckEditorDeckDockWidget::decklistCustomMenu(QPoint point)
{ {
if (!SettingsCache::instance()->getOverrideAllCardArtWithPersonalPreference()) { if (!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
QMenu menu; QMenu menu;
QAction *selectPrinting = menu.addAction(tr("Select Printing")); QAction *selectPrinting = menu.addAction(tr("Select Printing"));
@ -589,7 +589,7 @@ void DeckEditorDeckDockWidget::decklistCustomMenu(QPoint point)
void DeckEditorDeckDockWidget::refreshShortcuts() void DeckEditorDeckDockWidget::refreshShortcuts()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aRemoveCard->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aRemoveCard")); aRemoveCard->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aRemoveCard"));
aIncrement->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aIncrement")); aIncrement->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aIncrement"));
aDecrement->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aDecrement")); aDecrement->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aDecrement"));

View file

@ -128,7 +128,7 @@ void DeckEditorFilterDockWidget::actClearFilterOne()
void DeckEditorFilterDockWidget::refreshShortcuts() void DeckEditorFilterDockWidget::refreshShortcuts()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aClearFilterAll->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aClearFilterAll")); aClearFilterAll->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aClearFilterAll"));
aClearFilterOne->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aClearFilterOne")); aClearFilterOne->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aClearFilterOne"));

View file

@ -75,7 +75,7 @@ DlgConnect::DlgConnect(QWidget *parent) : QDialog(parent)
autoConnectCheckBox = new QCheckBox(tr("A&uto connect")); autoConnectCheckBox = new QCheckBox(tr("A&uto connect"));
autoConnectCheckBox->setToolTip(tr("Automatically connect to the most recent login when Cockatrice opens")); autoConnectCheckBox->setToolTip(tr("Automatically connect to the most recent login when Cockatrice opens"));
auto &servers = SettingsCache::instance()->servers(); auto &servers = SettingsCache::instance().servers();
if (servers.getSavePassword()) { if (servers.getSavePassword()) {
autoConnectCheckBox->setChecked(servers.getAutoConnect() > 0); autoConnectCheckBox->setChecked(servers.getAutoConnect() > 0);
autoConnectCheckBox->setEnabled(true); autoConnectCheckBox->setEnabled(true);
@ -213,7 +213,7 @@ void DlgConnect::rebuildComboBoxList(int failure)
UserConnection_Information uci; UserConnection_Information uci;
savedHostList = uci.getServerInfo(); savedHostList = uci.getServerInfo();
auto &servers = SettingsCache::instance()->servers(); auto &servers = SettingsCache::instance().servers();
bool autoConnectEnabled = servers.getAutoConnect() > 0; bool autoConnectEnabled = servers.getAutoConnect() > 0;
QString previousHostName = servers.getPrevioushostName(); QString previousHostName = servers.getPrevioushostName();
QString autoConnectSaveName = servers.getSaveName(); QString autoConnectSaveName = servers.getSaveName();
@ -330,7 +330,7 @@ void DlgConnect::passwordSaved(QT_STATE_CHANGED_T state)
void DlgConnect::actOk() void DlgConnect::actOk()
{ {
ServersSettings &servers = SettingsCache::instance()->servers(); ServersSettings &servers = SettingsCache::instance().servers();
if (newHostButton->isChecked()) { if (newHostButton->isChecked()) {
if (saveEdit->text().isEmpty()) { if (saveEdit->text().isEmpty()) {
@ -363,7 +363,7 @@ QString DlgConnect::getHost() const
void DlgConnect::actForgotPassword() void DlgConnect::actForgotPassword()
{ {
ServersSettings &servers = SettingsCache::instance()->servers(); ServersSettings &servers = SettingsCache::instance().servers();
servers.setFPHostName(hostEdit->text()); servers.setFPHostName(hostEdit->text());
servers.setFPPort(portEdit->text()); servers.setFPPort(portEdit->text());
servers.setFPPlayerName(playernameEdit->text().trimmed()); servers.setFPPlayerName(playernameEdit->text().trimmed());
@ -373,6 +373,6 @@ void DlgConnect::actForgotPassword()
void DlgConnect::actRemoveSavedServer() void DlgConnect::actRemoveSavedServer()
{ {
SettingsCache::instance()->servers().removeServer(hostEdit->text()); SettingsCache::instance().servers().removeServer(hostEdit->text());
previousHosts->removeItem(previousHosts->currentIndex()); previousHosts->removeItem(previousHosts->currentIndex());
} }

View file

@ -50,7 +50,7 @@ void DlgCreateGame::sharedCtor()
QRadioButton *gameTypeRadioButton = new QRadioButton(gameTypeIterator.value(), this); QRadioButton *gameTypeRadioButton = new QRadioButton(gameTypeIterator.value(), this);
gameTypeLayout->addWidget(gameTypeRadioButton); gameTypeLayout->addWidget(gameTypeRadioButton);
gameTypeCheckBoxes.insert(gameTypeIterator.key(), gameTypeRadioButton); gameTypeCheckBoxes.insert(gameTypeIterator.key(), gameTypeRadioButton);
bool isChecked = SettingsCache::instance()->getGameTypes().contains(gameTypeIterator.value() + ", "); bool isChecked = SettingsCache::instance().getGameTypes().contains(gameTypeIterator.value() + ", ");
gameTypeCheckBoxes[gameTypeIterator.key()]->setChecked(isChecked); gameTypeCheckBoxes[gameTypeIterator.key()]->setChecked(isChecked);
} }
QGroupBox *gameTypeGroupBox = new QGroupBox(tr("Game type")); QGroupBox *gameTypeGroupBox = new QGroupBox(tr("Game type"));
@ -150,23 +150,23 @@ DlgCreateGame::DlgCreateGame(TabRoom *_room, const QMap<int, QString> &_gameType
{ {
sharedCtor(); sharedCtor();
rememberGameSettings->setChecked(SettingsCache::instance()->getRememberGameSettings()); rememberGameSettings->setChecked(SettingsCache::instance().getRememberGameSettings());
descriptionEdit->setText(SettingsCache::instance()->getGameDescription()); descriptionEdit->setText(SettingsCache::instance().getGameDescription());
maxPlayersEdit->setValue(SettingsCache::instance()->getMaxPlayers()); maxPlayersEdit->setValue(SettingsCache::instance().getMaxPlayers());
if (room && room->getUserInfo()->user_level() & ServerInfo_User::IsRegistered) { if (room && room->getUserInfo()->user_level() & ServerInfo_User::IsRegistered) {
onlyBuddiesCheckBox->setChecked(SettingsCache::instance()->getOnlyBuddies()); onlyBuddiesCheckBox->setChecked(SettingsCache::instance().getOnlyBuddies());
onlyRegisteredCheckBox->setChecked(SettingsCache::instance()->getOnlyRegistered()); onlyRegisteredCheckBox->setChecked(SettingsCache::instance().getOnlyRegistered());
} else { } else {
onlyBuddiesCheckBox->setEnabled(false); onlyBuddiesCheckBox->setEnabled(false);
onlyRegisteredCheckBox->setEnabled(false); onlyRegisteredCheckBox->setEnabled(false);
} }
spectatorsAllowedCheckBox->setChecked(SettingsCache::instance()->getSpectatorsAllowed()); spectatorsAllowedCheckBox->setChecked(SettingsCache::instance().getSpectatorsAllowed());
spectatorsNeedPasswordCheckBox->setChecked(SettingsCache::instance()->getSpectatorsNeedPassword()); spectatorsNeedPasswordCheckBox->setChecked(SettingsCache::instance().getSpectatorsNeedPassword());
spectatorsCanTalkCheckBox->setChecked(SettingsCache::instance()->getSpectatorsCanTalk()); spectatorsCanTalkCheckBox->setChecked(SettingsCache::instance().getSpectatorsCanTalk());
spectatorsSeeEverythingCheckBox->setChecked(SettingsCache::instance()->getSpectatorsCanSeeEverything()); spectatorsSeeEverythingCheckBox->setChecked(SettingsCache::instance().getSpectatorsCanSeeEverything());
createGameAsSpectatorCheckBox->setChecked(SettingsCache::instance()->getCreateGameAsSpectator()); createGameAsSpectatorCheckBox->setChecked(SettingsCache::instance().getCreateGameAsSpectator());
startingLifeTotalEdit->setValue(SettingsCache::instance()->getDefaultStartingLifeTotal()); startingLifeTotalEdit->setValue(SettingsCache::instance().getDefaultStartingLifeTotal());
shareDecklistsOnLoadCheckBox->setChecked(SettingsCache::instance()->getShareDecklistsOnLoad()); shareDecklistsOnLoadCheckBox->setChecked(SettingsCache::instance().getShareDecklistsOnLoad());
if (!rememberGameSettings->isChecked()) { if (!rememberGameSettings->isChecked()) {
actReset(); actReset();
@ -285,20 +285,20 @@ void DlgCreateGame::actOK()
} }
} }
SettingsCache::instance()->setRememberGameSettings(rememberGameSettings->isChecked()); SettingsCache::instance().setRememberGameSettings(rememberGameSettings->isChecked());
if (rememberGameSettings->isChecked()) { if (rememberGameSettings->isChecked()) {
SettingsCache::instance()->setGameDescription(descriptionEdit->text()); SettingsCache::instance().setGameDescription(descriptionEdit->text());
SettingsCache::instance()->setMaxPlayers(maxPlayersEdit->value()); SettingsCache::instance().setMaxPlayers(maxPlayersEdit->value());
SettingsCache::instance()->setOnlyBuddies(onlyBuddiesCheckBox->isChecked()); SettingsCache::instance().setOnlyBuddies(onlyBuddiesCheckBox->isChecked());
SettingsCache::instance()->setOnlyRegistered(onlyRegisteredCheckBox->isChecked()); SettingsCache::instance().setOnlyRegistered(onlyRegisteredCheckBox->isChecked());
SettingsCache::instance()->setSpectatorsAllowed(spectatorsAllowedCheckBox->isChecked()); SettingsCache::instance().setSpectatorsAllowed(spectatorsAllowedCheckBox->isChecked());
SettingsCache::instance()->setSpectatorsNeedPassword(spectatorsNeedPasswordCheckBox->isChecked()); SettingsCache::instance().setSpectatorsNeedPassword(spectatorsNeedPasswordCheckBox->isChecked());
SettingsCache::instance()->setSpectatorsCanTalk(spectatorsCanTalkCheckBox->isChecked()); SettingsCache::instance().setSpectatorsCanTalk(spectatorsCanTalkCheckBox->isChecked());
SettingsCache::instance()->setSpectatorsCanSeeEverything(spectatorsSeeEverythingCheckBox->isChecked()); SettingsCache::instance().setSpectatorsCanSeeEverything(spectatorsSeeEverythingCheckBox->isChecked());
SettingsCache::instance()->setCreateGameAsSpectator(createGameAsSpectatorCheckBox->isChecked()); SettingsCache::instance().setCreateGameAsSpectator(createGameAsSpectatorCheckBox->isChecked());
SettingsCache::instance()->setDefaultStartingLifeTotal(startingLifeTotalEdit->value()); SettingsCache::instance().setDefaultStartingLifeTotal(startingLifeTotalEdit->value());
SettingsCache::instance()->setShareDecklistsOnLoad(shareDecklistsOnLoadCheckBox->isChecked()); SettingsCache::instance().setShareDecklistsOnLoad(shareDecklistsOnLoadCheckBox->isChecked());
SettingsCache::instance()->setGameTypes(_gameTypes); SettingsCache::instance().setGameTypes(_gameTypes);
} }
PendingCommand *pend = room->prepareRoomCommand(cmd); PendingCommand *pend = room->prepareRoomCommand(cmd);
connect(pend, &PendingCommand::finished, this, &DlgCreateGame::checkResponse); connect(pend, &PendingCommand::finished, this, &DlgCreateGame::checkResponse);

View file

@ -53,7 +53,7 @@ void DlgDefaultTagsEditor::retranslateUi()
void DlgDefaultTagsEditor::loadStringList() void DlgDefaultTagsEditor::loadStringList()
{ {
listWidget->clear(); listWidget->clear();
QStringList tags = SettingsCache::instance()->getVisualDeckStorageDefaultTagsList(); QStringList tags = SettingsCache::instance().getVisualDeckStorageDefaultTagsList();
for (const QString &tag : tags) { for (const QString &tag : tags) {
auto *item = new QListWidgetItem(); // Create item but don't insert yet auto *item = new QListWidgetItem(); // Create item but don't insert yet
@ -144,6 +144,6 @@ void DlgDefaultTagsEditor::confirmChanges()
updatedList.append(lineEdit->text()); updatedList.append(lineEdit->text());
} }
} }
SettingsCache::instance()->setVisualDeckStorageDefaultTagsList(updatedList); SettingsCache::instance().setVisualDeckStorageDefaultTagsList(updatedList);
accept(); // Close dialog and confirm changes accept(); // Close dialog and confirm changes
} }

View file

@ -15,7 +15,7 @@ DlgEditPassword::DlgEditPassword(QWidget *parent) : QDialog(parent)
oldPasswordEdit = new QLineEdit(); oldPasswordEdit = new QLineEdit();
oldPasswordEdit->setMaxLength(MAX_NAME_LENGTH); oldPasswordEdit->setMaxLength(MAX_NAME_LENGTH);
auto &servers = SettingsCache::instance()->servers(); auto &servers = SettingsCache::instance().servers();
if (servers.getSavePassword()) { if (servers.getSavePassword()) {
oldPasswordEdit->setText(servers.getPassword()); oldPasswordEdit->setText(servers.getPassword());
} }

View file

@ -23,7 +23,7 @@ DlgEditUser::DlgEditUser(QWidget *parent, QString email, QString country, QStrin
countryEdit->insertItem(0, tr("Undefined")); countryEdit->insertItem(0, tr("Undefined"));
countryEdit->setCurrentIndex(0); countryEdit->setCurrentIndex(0);
QStringList countries = SettingsCache::instance()->getCountries(); QStringList countries = SettingsCache::instance().getCountries();
int i = 1; int i = 1;
for (const QString &c : countries) { for (const QString &c : countries) {
countryEdit->addItem(QPixmap("theme:countries/" + c.toLower()), c); countryEdit->addItem(QPixmap("theme:countries/" + c.toLower()), c);

View file

@ -16,7 +16,7 @@ DlgForgotPasswordChallenge::DlgForgotPasswordChallenge(QWidget *parent) : QDialo
QString lastfphost; QString lastfphost;
QString lastfpport; QString lastfpport;
QString lastfpplayername; QString lastfpplayername;
ServersSettings &servers = SettingsCache::instance()->servers(); ServersSettings &servers = SettingsCache::instance().servers();
lastfphost = servers.getHostname(); lastfphost = servers.getHostname();
lastfpport = servers.getPort(); lastfpport = servers.getPort();
lastfpplayername = servers.getPlayerName(); lastfpplayername = servers.getPlayerName();
@ -98,7 +98,7 @@ void DlgForgotPasswordChallenge::actOk()
return; return;
} }
ServersSettings &servers = SettingsCache::instance()->servers(); ServersSettings &servers = SettingsCache::instance().servers();
servers.setFPHostName(hostEdit->text()); servers.setFPHostName(hostEdit->text());
servers.setFPPort(portEdit->text()); servers.setFPPort(portEdit->text());
servers.setFPPlayerName(playernameEdit->text()); servers.setFPPlayerName(playernameEdit->text());

View file

@ -16,7 +16,7 @@ DlgForgotPasswordRequest::DlgForgotPasswordRequest(QWidget *parent) : QDialog(pa
QString lastfphost; QString lastfphost;
QString lastfpport; QString lastfpport;
QString lastfpplayername; QString lastfpplayername;
ServersSettings &servers = SettingsCache::instance()->servers(); ServersSettings &servers = SettingsCache::instance().servers();
lastfphost = servers.getHostname(); lastfphost = servers.getHostname();
lastfpport = servers.getPort(); lastfpport = servers.getPort();
lastfpplayername = servers.getPlayerName(); lastfpplayername = servers.getPlayerName();
@ -75,7 +75,7 @@ void DlgForgotPasswordRequest::actOk()
return; return;
} }
ServersSettings &servers = SettingsCache::instance()->servers(); ServersSettings &servers = SettingsCache::instance().servers();
servers.setFPHostName(hostEdit->text()); servers.setFPHostName(hostEdit->text());
servers.setFPPort(portEdit->text()); servers.setFPPort(portEdit->text());
servers.setFPPlayerName(playernameEdit->text()); servers.setFPPlayerName(playernameEdit->text());

View file

@ -16,7 +16,7 @@ DlgForgotPasswordReset::DlgForgotPasswordReset(QWidget *parent) : QDialog(parent
QString lastfphost; QString lastfphost;
QString lastfpport; QString lastfpport;
QString lastfpplayername; QString lastfpplayername;
ServersSettings &servers = SettingsCache::instance()->servers(); ServersSettings &servers = SettingsCache::instance().servers();
lastfphost = servers.getHostname(); lastfphost = servers.getHostname();
lastfpport = servers.getPort(); lastfpport = servers.getPort();
lastfpplayername = servers.getPlayerName(); lastfpplayername = servers.getPlayerName();
@ -132,7 +132,7 @@ void DlgForgotPasswordReset::actOk()
return; return;
} }
ServersSettings &servers = SettingsCache::instance()->servers(); ServersSettings &servers = SettingsCache::instance().servers();
servers.setFPHostName(hostEdit->text()); servers.setFPHostName(hostEdit->text());
servers.setFPPort(portEdit->text()); servers.setFPPort(portEdit->text());
servers.setFPPlayerName(playernameEdit->text()); servers.setFPPlayerName(playernameEdit->text());

View file

@ -6,9 +6,9 @@
DlgLoadDeck::DlgLoadDeck(QWidget *parent) : QFileDialog(parent, tr("Load Deck")) DlgLoadDeck::DlgLoadDeck(QWidget *parent) : QFileDialog(parent, tr("Load Deck"))
{ {
QString startingDir = SettingsCache::instance()->recents().getLatestDeckDirPath(); QString startingDir = SettingsCache::instance().recents().getLatestDeckDirPath();
if (startingDir.isEmpty()) { if (startingDir.isEmpty()) {
startingDir = SettingsCache::instance()->getDeckPath(); startingDir = SettingsCache::instance().getDeckPath();
} }
setDirectory(startingDir); setDirectory(startingDir);
@ -19,5 +19,5 @@ DlgLoadDeck::DlgLoadDeck(QWidget *parent) : QFileDialog(parent, tr("Load Deck"))
void DlgLoadDeck::actAccepted() void DlgLoadDeck::actAccepted()
{ {
SettingsCache::instance()->recents().setLatestDeckDirPath(directory().absolutePath()); SettingsCache::instance().recents().setLatestDeckDirPath(directory().absolutePath());
} }

View file

@ -44,7 +44,7 @@ AbstractDlgDeckTextEdit::AbstractDlgDeckTextEdit(QWidget *parent) : QDialog(pare
resize(500, 500); resize(500, 500);
connect(&SettingsCache::instance().get()->shortcuts(), &ShortcutsSettings::shortCutChanged, this, connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&AbstractDlgDeckTextEdit::refreshShortcuts); &AbstractDlgDeckTextEdit::refreshShortcuts);
refreshShortcuts(); refreshShortcuts();
} }
@ -52,7 +52,7 @@ AbstractDlgDeckTextEdit::AbstractDlgDeckTextEdit(QWidget *parent) : QDialog(pare
void AbstractDlgDeckTextEdit::refreshShortcuts() void AbstractDlgDeckTextEdit::refreshShortcuts()
{ {
refreshButton->setShortcut( refreshButton->setShortcut(
SettingsCache::instance()->shortcuts().getSingleShortcut("DlgLoadDeckFromClipboard/refreshButton")); SettingsCache::instance().shortcuts().getSingleShortcut("DlgLoadDeckFromClipboard/refreshButton"));
} }
/** /**

View file

@ -158,7 +158,7 @@ WndSets::WndSets(QWidget *parent) : QMainWindow(parent)
sortWarning->setLayout(sortWarningLayout); sortWarning->setLayout(sortWarningLayout);
sortWarning->setVisible(false); sortWarning->setVisible(false);
includeRebalancedCards = SettingsCache::instance()->getIncludeRebalancedCards(); includeRebalancedCards = SettingsCache::instance().getIncludeRebalancedCards();
QCheckBox *includeRebalancedCardsCheckBox = QCheckBox *includeRebalancedCardsCheckBox =
new QCheckBox(tr("Include cards rebalanced for Alchemy [requires restart]")); new QCheckBox(tr("Include cards rebalanced for Alchemy [requires restart]"));
includeRebalancedCardsCheckBox->setChecked(includeRebalancedCards); includeRebalancedCardsCheckBox->setChecked(includeRebalancedCards);
@ -192,11 +192,11 @@ WndSets::WndSets(QWidget *parent) : QMainWindow(parent)
setWindowTitle(tr("Manage sets")); setWindowTitle(tr("Manage sets"));
setMinimumSize(800, 500); setMinimumSize(800, 500);
auto &geometry = SettingsCache::instance()->getSetsDialogGeometry(); auto &geometry = SettingsCache::instance().getSetsDialogGeometry();
if (!geometry.isEmpty()) { if (!geometry.isEmpty()) {
restoreGeometry(geometry); restoreGeometry(geometry);
} }
auto &headerState = SettingsCache::instance()->layouts().getSetsDialogHeaderState(); auto &headerState = SettingsCache::instance().layouts().getSetsDialogHeaderState();
if (!headerState.isEmpty()) { if (!headerState.isEmpty()) {
view->header()->restoreState(headerState); view->header()->restoreState(headerState);
view->header()->setSortIndicator(SORT_RESET, Qt::DescendingOrder); view->header()->setSortIndicator(SORT_RESET, Qt::DescendingOrder);
@ -212,12 +212,12 @@ WndSets::~WndSets()
void WndSets::closeEvent(QCloseEvent * /*ev*/) void WndSets::closeEvent(QCloseEvent * /*ev*/)
{ {
SettingsCache::instance()->setSetsDialogGeometry(saveGeometry()); SettingsCache::instance().setSetsDialogGeometry(saveGeometry());
} }
void WndSets::saveHeaderState() void WndSets::saveHeaderState()
{ {
SettingsCache::instance()->layouts().setSetsDialogHeaderState(view->header()->saveState()); SettingsCache::instance().layouts().setSetsDialogHeaderState(view->header()->saveState());
} }
void WndSets::rebuildMainLayout(int actionToTake) void WndSets::rebuildMainLayout(int actionToTake)
@ -250,7 +250,7 @@ void WndSets::includeRebalancedCardsChanged(bool _includeRebalancedCards)
void WndSets::actSave() void WndSets::actSave()
{ {
model->save(CardDatabaseManager::getInstance()); model->save(CardDatabaseManager::getInstance());
SettingsCache::instance()->setIncludeRebalancedCards(includeRebalancedCards); SettingsCache::instance().setIncludeRebalancedCards(includeRebalancedCards);
CardPictureLoader::clearPixmapCache(); CardPictureLoader::clearPixmapCache();
close(); close();
} }

View file

@ -14,7 +14,7 @@
DlgRegister::DlgRegister(QWidget *parent) : QDialog(parent) DlgRegister::DlgRegister(QWidget *parent) : QDialog(parent)
{ {
ServersSettings &servers = SettingsCache::instance()->servers(); ServersSettings &servers = SettingsCache::instance().servers();
infoLabel = new QLabel(tr("Enter your information and the information of the server you'd like to register to.\n" infoLabel = new QLabel(tr("Enter your information and the information of the server you'd like to register to.\n"
"Your email will be used to verify your account.")); "Your email will be used to verify your account."));
infoLabel->setWordWrap(true); infoLabel->setWordWrap(true);
@ -312,7 +312,7 @@ DlgRegister::DlgRegister(QWidget *parent) : QDialog(parent)
countryEdit->addItem(QPixmap("theme:countries/zm"), "zm"); countryEdit->addItem(QPixmap("theme:countries/zm"), "zm");
countryEdit->addItem(QPixmap("theme:countries/zw"), "zw"); countryEdit->addItem(QPixmap("theme:countries/zw"), "zw");
countryEdit->setCurrentIndex(0); countryEdit->setCurrentIndex(0);
QStringList countries = SettingsCache::instance()->getCountries(); QStringList countries = SettingsCache::instance().getCountries();
for (const QString &c : countries) for (const QString &c : countries)
countryEdit->addItem(QPixmap("theme:countries/" + c.toLower()), c); countryEdit->addItem(QPixmap("theme:countries/" + c.toLower()), c);

File diff suppressed because it is too large Load diff

View file

@ -10,7 +10,7 @@ DlgStartupCardCheck::DlgStartupCardCheck(QWidget *parent) : QDialog(parent)
layout = new QVBoxLayout(this); layout = new QVBoxLayout(this);
QDate lastCheckDate = SettingsCache::instance()->getLastCardUpdateCheck(); QDate lastCheckDate = SettingsCache::instance().getLastCardUpdateCheck();
int daysAgo = lastCheckDate.daysTo(QDate::currentDate()); int daysAgo = lastCheckDate.daysTo(QDate::currentDate());
instructionLabel = new QLabel( instructionLabel = new QLabel(

View file

@ -42,7 +42,7 @@ DlgTipOfTheDay::DlgTipOfTheDay(QWidget *parent) : QDialog(parent)
tipNumber = new QLabel(); tipNumber = new QLabel();
tipNumber->setAlignment(Qt::AlignCenter); tipNumber->setAlignment(Qt::AlignCenter);
QList<int> seenTips = SettingsCache::instance()->getSeenTips(); QList<int> seenTips = SettingsCache::instance().getSeenTips();
newTipsAvailable = false; newTipsAvailable = false;
currentTip = 0; currentTip = 0;
for (int i = 0; i < tipDatabase->rowCount(); i++) { for (int i = 0; i < tipDatabase->rowCount(); i++) {
@ -74,8 +74,8 @@ DlgTipOfTheDay::DlgTipOfTheDay(QWidget *parent) : QDialog(parent)
connect(previousButton, &QPushButton::clicked, this, &DlgTipOfTheDay::previousClicked); connect(previousButton, &QPushButton::clicked, this, &DlgTipOfTheDay::previousClicked);
showTipsOnStartupCheck = new QCheckBox("Show tips on startup"); showTipsOnStartupCheck = new QCheckBox("Show tips on startup");
showTipsOnStartupCheck->setChecked(SettingsCache::instance()->getShowTipsOnStartup()); showTipsOnStartupCheck->setChecked(SettingsCache::instance().getShowTipsOnStartup());
connect(showTipsOnStartupCheck, &QCheckBox::clicked, SettingsCache::instance().get(), connect(showTipsOnStartupCheck, &QCheckBox::clicked, &SettingsCache::instance(),
&SettingsCache::setShowTipsOnStartup); &SettingsCache::setShowTipsOnStartup);
buttonBar = new QHBoxLayout(); buttonBar = new QHBoxLayout();
buttonBar->addWidget(showTipsOnStartupCheck); buttonBar->addWidget(showTipsOnStartupCheck);
@ -131,10 +131,10 @@ void DlgTipOfTheDay::updateTip(int tipId)
} }
// Store tip id as seen // Store tip id as seen
QList<int> seenTips = SettingsCache::instance()->getSeenTips(); QList<int> seenTips = SettingsCache::instance().getSeenTips();
if (!seenTips.contains(tipId)) { if (!seenTips.contains(tipId)) {
seenTips.append(tipId); seenTips.append(tipId);
SettingsCache::instance()->setSeenTips(seenTips); SettingsCache::instance().setSeenTips(seenTips);
} }
TipOfTheDay tip = tipDatabase->getTip(tipId); TipOfTheDay tip = tipDatabase->getTip(tipId);

View file

@ -23,10 +23,10 @@ DlgUpdate::DlgUpdate(QWidget *parent) : QDialog(parent)
statusLabel = new QLabel(this); statusLabel = new QLabel(this);
statusLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); statusLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
statusLabel->setWordWrap(true); statusLabel->setWordWrap(true);
descriptionLabel = new QLabel( descriptionLabel =
tr("Current release channel") + new QLabel(tr("Current release channel") +
QString(": %1").arg(tr(SettingsCache::instance()->getUpdateReleaseChannel()->getName().toUtf8())), QString(": %1").arg(tr(SettingsCache::instance().getUpdateReleaseChannel()->getName().toUtf8())),
this); this);
progress = new QProgressBar(this); progress = new QProgressBar(this);
buttonBox = new QDialogButtonBox(this); buttonBox = new QDialogButtonBox(this);
@ -84,7 +84,7 @@ void DlgUpdate::closeDialog()
void DlgUpdate::gotoDownloadPage() void DlgUpdate::gotoDownloadPage()
{ {
QDesktopServices::openUrl(SettingsCache::instance()->getUpdateReleaseChannel()->getManualDownloadUrl()); QDesktopServices::openUrl(SettingsCache::instance().getUpdateReleaseChannel()->getManualDownloadUrl());
} }
void DlgUpdate::downloadUpdate(const QString &releaseName) void DlgUpdate::downloadUpdate(const QString &releaseName)
@ -141,7 +141,7 @@ void DlgUpdate::finishedUpdateCheck(bool needToUpdate, bool isCompatible, Releas
tr("You are already running the latest version available in the chosen release channel.") + "<br>" + tr("You are already running the latest version available in the chosen release channel.") + "<br>" +
"<b>" + tr("Current version") + QString(":</b> %1<br>").arg(VERSION_STRING) + "<b>" + "<b>" + tr("Current version") + QString(":</b> %1<br>").arg(VERSION_STRING) + "<b>" +
tr("Selected release channel") + tr("Selected release channel") +
QString(":</b> %1").arg(tr(SettingsCache::instance()->getUpdateReleaseChannel()->getName().toUtf8()))); QString(":</b> %1").arg(tr(SettingsCache::instance().getUpdateReleaseChannel()->getName().toUtf8())));
return; return;
} }

View file

@ -24,7 +24,7 @@ DlgViewLog::DlgViewLog(QWidget *parent) : QDialog(parent)
coClearLog = new QCheckBox; coClearLog = new QCheckBox;
coClearLog->setText(tr("Clear log when closing")); coClearLog->setText(tr("Clear log when closing"));
coClearLog->setChecked(SettingsCache::instance()->servers().getClearDebugLogStatus(false)); coClearLog->setChecked(SettingsCache::instance().servers().getClearDebugLogStatus(false));
connect(coClearLog, &QCheckBox::toggled, this, &DlgViewLog::actCheckBoxChanged); connect(coClearLog, &QCheckBox::toggled, this, &DlgViewLog::actCheckBoxChanged);
copyToClipboardButton = new QPushButton; copyToClipboardButton = new QPushButton;
@ -49,7 +49,7 @@ DlgViewLog::DlgViewLog(QWidget *parent) : QDialog(parent)
void DlgViewLog::actCheckBoxChanged(bool abNewValue) void DlgViewLog::actCheckBoxChanged(bool abNewValue)
{ {
SettingsCache::instance()->servers().setClearDebugLogStatus(abNewValue); SettingsCache::instance().servers().setClearDebugLogStatus(abNewValue);
} }
void DlgViewLog::actCopyToClipboard() void DlgViewLog::actCopyToClipboard()

View file

@ -21,7 +21,7 @@ HomeWidget::HomeWidget(QWidget *parent, TabSupervisor *_tabSupervisor)
backgroundSourceCard = new CardInfoPictureArtCropWidget(this); backgroundSourceCard = new CardInfoPictureArtCropWidget(this);
backgroundSourceDeck = new DeckLoader(); backgroundSourceDeck = new DeckLoader();
backgroundSourceDeck->loadFromFile(SettingsCache::instance()->getDeckPath() + "background.cod", backgroundSourceDeck->loadFromFile(SettingsCache::instance().getDeckPath() + "background.cod",
DeckLoader::CockatriceFormat, false); DeckLoader::CockatriceFormat, false);
gradientColors = extractDominantColors(background); gradientColors = extractDominantColors(background);
@ -43,9 +43,9 @@ HomeWidget::HomeWidget(QWidget *parent, TabSupervisor *_tabSupervisor)
updateConnectButton(tabSupervisor->getClient()->getStatus()); updateConnectButton(tabSupervisor->getClient()->getStatus());
connect(tabSupervisor->getClient(), &RemoteClient::statusChanged, this, &HomeWidget::updateConnectButton); connect(tabSupervisor->getClient(), &RemoteClient::statusChanged, this, &HomeWidget::updateConnectButton);
connect(SettingsCache::instance().get(), &SettingsCache::homeTabBackgroundSourceChanged, this, connect(&SettingsCache::instance(), &SettingsCache::homeTabBackgroundSourceChanged, this,
&HomeWidget::initializeBackgroundFromSource); &HomeWidget::initializeBackgroundFromSource);
connect(SettingsCache::instance().get(), &SettingsCache::homeTabBackgroundShuffleFrequencyChanged, this, connect(&SettingsCache::instance(), &SettingsCache::homeTabBackgroundShuffleFrequencyChanged, this,
&HomeWidget::onBackgroundShuffleFrequencyChanged); &HomeWidget::onBackgroundShuffleFrequencyChanged);
} }
@ -57,7 +57,7 @@ void HomeWidget::initializeBackgroundFromSource()
return; return;
} }
auto backgroundSourceType = BackgroundSources::fromId(SettingsCache::instance()->getHomeTabBackgroundSource()); auto backgroundSourceType = BackgroundSources::fromId(SettingsCache::instance().getHomeTabBackgroundSource());
cardChangeTimer->stop(); cardChangeTimer->stop();
@ -68,19 +68,19 @@ void HomeWidget::initializeBackgroundFromSource()
update(); update();
break; break;
case BackgroundSources::RandomCardArt: case BackgroundSources::RandomCardArt:
cardChangeTimer->start(SettingsCache::instance()->getHomeTabBackgroundShuffleFrequency() * 1000); cardChangeTimer->start(SettingsCache::instance().getHomeTabBackgroundShuffleFrequency() * 1000);
break; break;
case BackgroundSources::DeckFileArt: case BackgroundSources::DeckFileArt:
backgroundSourceDeck->loadFromFile(SettingsCache::instance()->getDeckPath() + "background.cod", backgroundSourceDeck->loadFromFile(SettingsCache::instance().getDeckPath() + "background.cod",
DeckLoader::CockatriceFormat, false); DeckLoader::CockatriceFormat, false);
cardChangeTimer->start(SettingsCache::instance()->getHomeTabBackgroundShuffleFrequency() * 1000); cardChangeTimer->start(SettingsCache::instance().getHomeTabBackgroundShuffleFrequency() * 1000);
break; break;
} }
} }
void HomeWidget::updateRandomCard() void HomeWidget::updateRandomCard()
{ {
auto backgroundSourceType = BackgroundSources::fromId(SettingsCache::instance()->getHomeTabBackgroundSource()); auto backgroundSourceType = BackgroundSources::fromId(SettingsCache::instance().getHomeTabBackgroundSource());
ExactCard newCard; ExactCard newCard;
@ -121,7 +121,7 @@ void HomeWidget::updateRandomCard()
backgroundSourceCard->setCard(newCard); backgroundSourceCard->setCard(newCard);
background = backgroundSourceCard->getProcessedBackground(size()); background = backgroundSourceCard->getProcessedBackground(size());
if (SettingsCache::instance()->getHomeTabBackgroundShuffleFrequency() <= 0) { if (SettingsCache::instance().getHomeTabBackgroundShuffleFrequency() <= 0) {
cardChangeTimer->stop(); cardChangeTimer->stop();
} }
} }
@ -129,10 +129,10 @@ void HomeWidget::updateRandomCard()
void HomeWidget::onBackgroundShuffleFrequencyChanged() void HomeWidget::onBackgroundShuffleFrequencyChanged()
{ {
cardChangeTimer->stop(); cardChangeTimer->stop();
if (SettingsCache::instance()->getHomeTabBackgroundShuffleFrequency() <= 0) { if (SettingsCache::instance().getHomeTabBackgroundShuffleFrequency() <= 0) {
return; return;
} }
cardChangeTimer->start(SettingsCache::instance()->getHomeTabBackgroundShuffleFrequency() * 1000); cardChangeTimer->start(SettingsCache::instance().getHomeTabBackgroundShuffleFrequency() * 1000);
} }
void HomeWidget::updateBackgroundProperties() void HomeWidget::updateBackgroundProperties()
@ -236,8 +236,8 @@ void HomeWidget::updateConnectButton(const ClientStatus status)
QPair<QColor, QColor> HomeWidget::extractDominantColors(const QPixmap &pixmap) QPair<QColor, QColor> HomeWidget::extractDominantColors(const QPixmap &pixmap)
{ {
if (SettingsCache::instance()->getThemeName() == "Default" && if (SettingsCache::instance().getThemeName() == "Default" &&
SettingsCache::instance()->getHomeTabBackgroundSource() == BackgroundSources::toId(BackgroundSources::Theme)) { SettingsCache::instance().getHomeTabBackgroundSource() == BackgroundSources::toId(BackgroundSources::Theme)) {
return QPair<QColor, QColor>(QColor::fromRgb(20, 140, 60), QColor::fromRgb(120, 200, 80)); return QPair<QColor, QColor>(QColor::fromRgb(20, 140, 60), QColor::fromRgb(120, 200, 80));
} }

View file

@ -12,7 +12,7 @@ DeckEditorMenu::DeckEditorMenu(AbstractTabDeckEditor *parent) : QMenu(parent), d
connect(aLoadDeck, &QAction::triggered, deckEditor, &AbstractTabDeckEditor::actLoadDeck); connect(aLoadDeck, &QAction::triggered, deckEditor, &AbstractTabDeckEditor::actLoadDeck);
loadRecentDeckMenu = new QMenu(this); loadRecentDeckMenu = new QMenu(this);
connect(&SettingsCache::instance().get()->recents(), &RecentsSettings::recentlyOpenedDeckPathsChanged, this, connect(&SettingsCache::instance().recents(), &RecentsSettings::recentlyOpenedDeckPathsChanged, this,
&DeckEditorMenu::updateRecentlyOpened); &DeckEditorMenu::updateRecentlyOpened);
aClearRecents = new QAction(QString(), this); aClearRecents = new QAction(QString(), this);
@ -109,7 +109,7 @@ DeckEditorMenu::DeckEditorMenu(AbstractTabDeckEditor *parent) : QMenu(parent), d
addAction(aClose); addAction(aClose);
retranslateUi(); retranslateUi();
connect(&SettingsCache::instance().get()->shortcuts(), &ShortcutsSettings::shortCutChanged, this, connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&DeckEditorMenu::refreshShortcuts); &DeckEditorMenu::refreshShortcuts);
refreshShortcuts(); refreshShortcuts();
} }
@ -130,7 +130,7 @@ void DeckEditorMenu::setSaveStatus(bool newStatus)
void DeckEditorMenu::updateRecentlyOpened() void DeckEditorMenu::updateRecentlyOpened()
{ {
loadRecentDeckMenu->clear(); loadRecentDeckMenu->clear();
for (const auto &deckPath : SettingsCache::instance()->recents().getRecentlyOpenedDeckPaths()) { for (const auto &deckPath : SettingsCache::instance().recents().getRecentlyOpenedDeckPaths()) {
QAction *aRecentlyOpenedDeck = new QAction(deckPath, this); QAction *aRecentlyOpenedDeck = new QAction(deckPath, this);
loadRecentDeckMenu->addAction(aRecentlyOpenedDeck); loadRecentDeckMenu->addAction(aRecentlyOpenedDeck);
connect(aRecentlyOpenedDeck, &QAction::triggered, deckEditor, connect(aRecentlyOpenedDeck, &QAction::triggered, deckEditor,
@ -138,12 +138,12 @@ void DeckEditorMenu::updateRecentlyOpened()
} }
loadRecentDeckMenu->addSeparator(); loadRecentDeckMenu->addSeparator();
loadRecentDeckMenu->addAction(aClearRecents); loadRecentDeckMenu->addAction(aClearRecents);
aClearRecents->setEnabled(SettingsCache::instance()->recents().getRecentlyOpenedDeckPaths().length() > 0); aClearRecents->setEnabled(SettingsCache::instance().recents().getRecentlyOpenedDeckPaths().length() > 0);
} }
void DeckEditorMenu::actClearRecents() void DeckEditorMenu::actClearRecents()
{ {
SettingsCache::instance()->recents().clearRecentlyOpenedDeckPaths(); SettingsCache::instance().recents().clearRecentlyOpenedDeckPaths();
} }
void DeckEditorMenu::retranslateUi() void DeckEditorMenu::retranslateUi()
@ -182,7 +182,7 @@ void DeckEditorMenu::retranslateUi()
void DeckEditorMenu::refreshShortcuts() void DeckEditorMenu::refreshShortcuts()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aNewDeck->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aNewDeck")); aNewDeck->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aNewDeck"));
aLoadDeck->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aLoadDeck")); aLoadDeck->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aLoadDeck"));
aSaveDeck->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aSaveDeck")); aSaveDeck->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aSaveDeck"));

View file

@ -15,16 +15,16 @@ class TearOffMenu : public QMenu
public: public:
explicit TearOffMenu(const QString &title, QWidget *parent = nullptr) : QMenu(title, parent) explicit TearOffMenu(const QString &title, QWidget *parent = nullptr) : QMenu(title, parent)
{ {
connect(SettingsCache::instance().get(), &SettingsCache::useTearOffMenusChanged, this, connect(&SettingsCache::instance(), &SettingsCache::useTearOffMenusChanged, this,
[this](const bool state) { setTearOffEnabled(state); }); [this](const bool state) { setTearOffEnabled(state); });
setTearOffEnabled(SettingsCache::instance()->getUseTearOffMenus()); setTearOffEnabled(SettingsCache::instance().getUseTearOffMenus());
} }
explicit TearOffMenu(QWidget *parent = nullptr) : QMenu(parent) explicit TearOffMenu(QWidget *parent = nullptr) : QMenu(parent)
{ {
connect(SettingsCache::instance().get(), &SettingsCache::useTearOffMenusChanged, this, connect(&SettingsCache::instance(), &SettingsCache::useTearOffMenusChanged, this,
[this](const bool state) { setTearOffEnabled(state); }); [this](const bool state) { setTearOffEnabled(state); });
setTearOffEnabled(SettingsCache::instance()->getUseTearOffMenus()); setTearOffEnabled(SettingsCache::instance().getUseTearOffMenus());
} }
TearOffMenu *addTearOffMenu(const QString &title) TearOffMenu *addTearOffMenu(const QString &title)

View file

@ -45,15 +45,15 @@ PrintingSelector::PrintingSelector(QWidget *parent, AbstractTabDeckEditor *_deck
// Create the checkbox for navigation buttons visibility // Create the checkbox for navigation buttons visibility
navigationCheckBox = new QCheckBox(this); navigationCheckBox = new QCheckBox(this);
navigationCheckBox->setChecked(SettingsCache::instance()->getPrintingSelectorNavigationButtonsVisible()); navigationCheckBox->setChecked(SettingsCache::instance().getPrintingSelectorNavigationButtonsVisible());
connect(navigationCheckBox, &QCheckBox::QT_STATE_CHANGED, this, connect(navigationCheckBox, &QCheckBox::QT_STATE_CHANGED, this,
&PrintingSelector::toggleVisibilityNavigationButtons); &PrintingSelector::toggleVisibilityNavigationButtons);
connect(navigationCheckBox, &QCheckBox::QT_STATE_CHANGED, SettingsCache::instance().get(), connect(navigationCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setPrintingSelectorNavigationButtonsVisible); &SettingsCache::setPrintingSelectorNavigationButtonsVisible);
cardSizeWidget = cardSizeWidget =
new CardSizeWidget(displayOptionsWidget, flowWidget, SettingsCache::instance()->getPrintingSelectorCardSize()); new CardSizeWidget(displayOptionsWidget, flowWidget, SettingsCache::instance().getPrintingSelectorCardSize());
connect(cardSizeWidget, &CardSizeWidget::cardSizeSettingUpdated, SettingsCache::instance().get(), connect(cardSizeWidget, &CardSizeWidget::cardSizeSettingUpdated, &SettingsCache::instance(),
&SettingsCache::setPrintingSelectorCardSize); &SettingsCache::setPrintingSelectorCardSize);
displayOptionsWidget->addSettingsWidget(sortToolBar); displayOptionsWidget->addSettingsWidget(sortToolBar);
@ -76,7 +76,7 @@ PrintingSelector::PrintingSelector(QWidget *parent, AbstractTabDeckEditor *_deck
layout->addWidget(flowWidget); layout->addWidget(flowWidget);
cardSelectionBar = new PrintingSelectorCardSelectionWidget(this); cardSelectionBar = new PrintingSelectorCardSelectionWidget(this);
cardSelectionBar->setVisible(SettingsCache::instance()->getPrintingSelectorNavigationButtonsVisible()); cardSelectionBar->setVisible(SettingsCache::instance().getPrintingSelectorNavigationButtonsVisible());
layout->addWidget(cardSelectionBar); layout->addWidget(cardSelectionBar);
// Connect deck model data change signal to update display // Connect deck model data change signal to update display
@ -206,7 +206,7 @@ void PrintingSelector::getAllSetsForCurrentCard()
sortToolBar->filterSets(sortedPrintings, searchBar->getSearchText().trimmed().toLower()); sortToolBar->filterSets(sortedPrintings, searchBar->getSearchText().trimmed().toLower());
QList<PrintingInfo> printingsToUse; QList<PrintingInfo> printingsToUse;
if (SettingsCache::instance()->getBumpSetsWithCardsInDeckToTop()) { if (SettingsCache::instance().getBumpSetsWithCardsInDeckToTop()) {
printingsToUse = sortToolBar->prependPrintingsInDeck(filteredPrintings, selectedCard, deckModel); printingsToUse = sortToolBar->prependPrintingsInDeck(filteredPrintings, selectedCard, deckModel);
} else { } else {
printingsToUse = filteredPrintings; printingsToUse = filteredPrintings;

View file

@ -168,20 +168,20 @@ void PrintingSelectorCardOverlayWidget::customMenu(QPoint point)
menu.addMenu(preferenceMenu); menu.addMenu(preferenceMenu);
const auto &preferredProviderId = const auto &preferredProviderId =
SettingsCache::instance()->cardOverrides().getCardPreferenceOverride(rootCard.getName()); SettingsCache::instance().cardOverrides().getCardPreferenceOverride(rootCard.getName());
const auto &cardProviderId = rootCard.getPrinting().getUuid(); const auto &cardProviderId = rootCard.getPrinting().getUuid();
if (preferredProviderId.isEmpty() || preferredProviderId != cardProviderId) { if (preferredProviderId.isEmpty() || preferredProviderId != cardProviderId) {
auto *pinAction = preferenceMenu->addAction(tr("Pin Printing")); auto *pinAction = preferenceMenu->addAction(tr("Pin Printing"));
connect(pinAction, &QAction::triggered, this, [this] { connect(pinAction, &QAction::triggered, this, [this] {
SettingsCache::instance()->cardOverrides().setCardPreferenceOverride( SettingsCache::instance().cardOverrides().setCardPreferenceOverride(
{rootCard.getName(), rootCard.getPrinting().getUuid()}); {rootCard.getName(), rootCard.getPrinting().getUuid()});
emit cardPreferenceChanged(); emit cardPreferenceChanged();
}); });
} else { } else {
auto *unpinAction = preferenceMenu->addAction(tr("Unpin Printing")); auto *unpinAction = preferenceMenu->addAction(tr("Unpin Printing"));
connect(unpinAction, &QAction::triggered, this, [this] { connect(unpinAction, &QAction::triggered, this, [this] {
SettingsCache::instance()->cardOverrides().deleteCardPreferenceOverride(rootCard.getName()); SettingsCache::instance().cardOverrides().deleteCardPreferenceOverride(rootCard.getName());
emit cardPreferenceChanged(); emit cardPreferenceChanged();
}); });
} }

View file

@ -25,7 +25,7 @@ PrintingSelectorCardSortingWidget::PrintingSelectorCardSortingWidget(PrintingSel
sortOptionsSelector = new QComboBox(this); sortOptionsSelector = new QComboBox(this);
sortOptionsSelector->setFocusPolicy(Qt::StrongFocus); sortOptionsSelector->setFocusPolicy(Qt::StrongFocus);
sortOptionsSelector->addItems(SORT_OPTIONS); sortOptionsSelector->addItems(SORT_OPTIONS);
sortOptionsSelector->setCurrentIndex(SettingsCache::instance()->getPrintingSelectorSortOrder()); sortOptionsSelector->setCurrentIndex(SettingsCache::instance().getPrintingSelectorSortOrder());
connect(sortOptionsSelector, &QComboBox::currentTextChanged, this, connect(sortOptionsSelector, &QComboBox::currentTextChanged, this,
&PrintingSelectorCardSortingWidget::updateSortSetting); &PrintingSelectorCardSortingWidget::updateSortSetting);
connect(sortOptionsSelector, &QComboBox::currentTextChanged, parent, &PrintingSelector::updateDisplay); connect(sortOptionsSelector, &QComboBox::currentTextChanged, parent, &PrintingSelector::updateDisplay);
@ -61,7 +61,7 @@ void PrintingSelectorCardSortingWidget::updateSortOrder()
*/ */
void PrintingSelectorCardSortingWidget::updateSortSetting() void PrintingSelectorCardSortingWidget::updateSortSetting()
{ {
SettingsCache::instance()->setPrintingSelectorSortOrder(sortOptionsSelector->currentIndex()); SettingsCache::instance().setPrintingSelectorSortOrder(sortOptionsSelector->currentIndex());
} }
/** /**
@ -89,7 +89,7 @@ QList<PrintingInfo> PrintingSelectorCardSortingWidget::sortSets(const SetToPrint
} }
if (sortedSets.empty()) { if (sortedSets.empty()) {
sortedSets << CardSet::newInstance(SettingsCache::instance()->cardDatabase(), "", "", "", QDate()); sortedSets << CardSet::newInstance(SettingsCache::instance().cardDatabase(), "", "", "", QDate());
} }
if (sortOptionsSelector->currentText() == SORT_OPTIONS_PREFERENCE) { if (sortOptionsSelector->currentText() == SORT_OPTIONS_PREFERENCE) {
@ -156,7 +156,7 @@ QList<PrintingInfo> PrintingSelectorCardSortingWidget::prependPinnedPrintings(co
const QString &cardName) const QString &cardName)
{ {
auto printingsToUse = printings; auto printingsToUse = printings;
const auto &cardProviderId = SettingsCache::instance()->cardOverrides().getCardPreferenceOverride(cardName); const auto &cardProviderId = SettingsCache::instance().cardOverrides().getCardPreferenceOverride(cardName);
if (!cardProviderId.isEmpty()) { if (!cardProviderId.isEmpty()) {
for (int i = 0; i < printingsToUse.size(); ++i) { for (int i = 0; i < printingsToUse.size(); ++i) {
const auto &card = printingsToUse[i]; const auto &card = printingsToUse[i];

View file

@ -88,7 +88,7 @@ ReplayManager::ReplayManager(TabGame *parent, GameReplay *_replay)
connect(this, &ReplayManager::requestChatAndPhaseReset, game, &TabGame::resetChatAndPhase); connect(this, &ReplayManager::requestChatAndPhaseReset, game, &TabGame::resetChatAndPhase);
connect(&SettingsCache::instance().get()->shortcuts(), &ShortcutsSettings::shortCutChanged, this, connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&ReplayManager::refreshShortcuts); &ReplayManager::refreshShortcuts);
refreshShortcuts(); refreshShortcuts();
} }
@ -128,7 +128,7 @@ void ReplayManager::replayRewind()
void ReplayManager::refreshShortcuts() void ReplayManager::refreshShortcuts()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
if (aReplaySkipForward) { if (aReplaySkipForward) {
aReplaySkipForward->setShortcuts(shortcuts.getShortcut("Replays/aSkipForward")); aReplaySkipForward->setShortcuts(shortcuts.getShortcut("Replays/aSkipForward"));
} }

View file

@ -109,7 +109,7 @@ void ReplayTimelineWidget::handleBackwardsSkip(bool doRewindBuffering)
// The rewind only happens once the timer runs out. // The rewind only happens once the timer runs out.
// If another backwards skip happens, the timer will just get reset instead of rewinding. // If another backwards skip happens, the timer will just get reset instead of rewinding.
rewindBufferingTimer->stop(); rewindBufferingTimer->stop();
rewindBufferingTimer->start(SettingsCache::instance()->getRewindBufferingMs()); rewindBufferingTimer->start(SettingsCache::instance().getRewindBufferingMs());
} else { } else {
// otherwise, process the rewind immediately // otherwise, process the rewind immediately
processRewind(); processRewind();

View file

@ -235,11 +235,11 @@ void ChatView::appendMessage(QString message,
} }
cursor.setCharFormat(defaultFormat); cursor.setCharFormat(defaultFormat);
bool mentionEnabled = SettingsCache::instance()->getChatMention(); bool mentionEnabled = SettingsCache::instance().getChatMention();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
highlightedWords = SettingsCache::instance()->getHighlightWords().split(' ', Qt::SkipEmptyParts); highlightedWords = SettingsCache::instance().getHighlightWords().split(' ', Qt::SkipEmptyParts);
#else #else
highlightedWords = SettingsCache::instance()->getHighlightWords().split(' ', QString::SkipEmptyParts); highlightedWords = SettingsCache::instance().getHighlightWords().split(' ', QString::SkipEmptyParts);
#endif #endif
// parse the message // parse the message
@ -338,8 +338,8 @@ void ChatView::checkMention(QTextCursor &cursor, QString &message, const QString
// You have received a valid mention!! // You have received a valid mention!!
soundEngine->playSound("chat_mention"); soundEngine->playSound("chat_mention");
mentionFormat.setBackground(QBrush(getCustomMentionColor())); mentionFormat.setBackground(QBrush(getCustomMentionColor()));
mentionFormat.setForeground(SettingsCache::instance()->getChatMentionForeground() ? QBrush(Qt::white) mentionFormat.setForeground(SettingsCache::instance().getChatMentionForeground() ? QBrush(Qt::white)
: QBrush(Qt::black)); : QBrush(Qt::black));
cursor.insertText(mention, mentionFormat); cursor.insertText(mention, mentionFormat);
message = message.mid(mention.size()); message = message.mid(mention.size());
showSystemPopup(userName); showSystemPopup(userName);
@ -360,8 +360,8 @@ void ChatView::checkMention(QTextCursor &cursor, QString &message, const QString
// Moderator Sending Global Message // Moderator Sending Global Message
soundEngine->playSound("all_mention"); soundEngine->playSound("all_mention");
mentionFormat.setBackground(QBrush(getCustomMentionColor())); mentionFormat.setBackground(QBrush(getCustomMentionColor()));
mentionFormat.setForeground(SettingsCache::instance()->getChatMentionForeground() ? QBrush(Qt::white) mentionFormat.setForeground(SettingsCache::instance().getChatMentionForeground() ? QBrush(Qt::white)
: QBrush(Qt::black)); : QBrush(Qt::black));
cursor.insertText("@" + fullMentionUpToSpaceOrEnd, mentionFormat); cursor.insertText("@" + fullMentionUpToSpaceOrEnd, mentionFormat);
message = message.mid(fullMentionUpToSpaceOrEnd.size() + 1); message = message.mid(fullMentionUpToSpaceOrEnd.size() + 1);
showSystemPopup(userName); showSystemPopup(userName);
@ -408,8 +408,8 @@ void ChatView::checkWord(QTextCursor &cursor, QString &message)
if (fullWordUpToSpaceOrEnd.compare(word, Qt::CaseInsensitive) == 0) { if (fullWordUpToSpaceOrEnd.compare(word, Qt::CaseInsensitive) == 0) {
// You have received a valid mention of custom word!! // You have received a valid mention of custom word!!
highlightFormat.setBackground(QBrush(getCustomHighlightColor())); highlightFormat.setBackground(QBrush(getCustomHighlightColor()));
highlightFormat.setForeground(SettingsCache::instance()->getChatHighlightForeground() ? QBrush(Qt::white) highlightFormat.setForeground(SettingsCache::instance().getChatHighlightForeground() ? QBrush(Qt::white)
: QBrush(Qt::black)); : QBrush(Qt::black));
cursor.insertText(fullWordUpToSpaceOrEnd, highlightFormat); cursor.insertText(fullWordUpToSpaceOrEnd, highlightFormat);
cursor.insertText(rest, defaultFormat); cursor.insertText(rest, defaultFormat);
QApplication::alert(this); QApplication::alert(this);
@ -465,7 +465,7 @@ void ChatView::actMessageClicked()
void ChatView::showSystemPopup(const QString &userName) void ChatView::showSystemPopup(const QString &userName)
{ {
QApplication::alert(this); QApplication::alert(this);
if (SettingsCache::instance()->getShowMentionPopup()) { if (SettingsCache::instance().getShowMentionPopup()) {
emit showMentionPopup(userName); emit showMentionPopup(userName);
} }
} }
@ -473,10 +473,10 @@ void ChatView::showSystemPopup(const QString &userName)
QColor ChatView::getCustomMentionColor() QColor ChatView::getCustomMentionColor()
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
QColor customColor = QColor::fromString("#" + SettingsCache::instance()->getChatMentionColor()); QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor());
#else #else
QColor customColor; QColor customColor;
customColor.setNamedColor("#" + SettingsCache::instance()->getChatMentionColor()); customColor.setNamedColor("#" + SettingsCache::instance().getChatMentionColor());
#endif #endif
return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR; return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR;
} }
@ -484,10 +484,10 @@ QColor ChatView::getCustomMentionColor()
QColor ChatView::getCustomHighlightColor() QColor ChatView::getCustomHighlightColor()
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
QColor customColor = QColor::fromString("#" + SettingsCache::instance()->getChatMentionColor()); QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor());
#else #else
QColor customColor; QColor customColor;
customColor.setNamedColor("#" + SettingsCache::instance()->getChatMentionColor()); customColor.setNamedColor("#" + SettingsCache::instance().getChatMentionColor());
#endif #endif
return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR; return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR;
} }

View file

@ -364,7 +364,7 @@ bool GamesProxyModel::areFilterParametersSetToDefaults() const
void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameTypes) void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameTypes)
{ {
GameFiltersSettings &gameFilters = SettingsCache::instance()->gameFilters(); GameFiltersSettings &gameFilters = SettingsCache::instance().gameFilters();
QSet<int> newGameTypeFilter; QSet<int> newGameTypeFilter;
QMapIterator<int, QString> gameTypesIterator(allGameTypes); QMapIterator<int, QString> gameTypesIterator(allGameTypes);
@ -387,7 +387,7 @@ void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameType
void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameTypes) void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameTypes)
{ {
GameFiltersSettings &gameFilters = SettingsCache::instance()->gameFilters(); GameFiltersSettings &gameFilters = SettingsCache::instance().gameFilters();
gameFilters.setHideBuddiesOnlyGames(hideBuddiesOnlyGames); gameFilters.setHideBuddiesOnlyGames(hideBuddiesOnlyGames);
gameFilters.setHideFullGames(hideFullGames); gameFilters.setHideFullGames(hideFullGames);
gameFilters.setHideGamesThatStarted(hideGamesThatStarted); gameFilters.setHideGamesThatStarted(hideGamesThatStarted);

View file

@ -87,11 +87,11 @@ void HandlePublicServers::updateServerINISettings(QMap<QString, QVariant> jsonMa
} }
if (serverFound) { if (serverFound) {
SettingsCache::instance()->servers().updateExistingServerWithoutLoss(serverName, serverAddress, serverPort, SettingsCache::instance().servers().updateExistingServerWithoutLoss(serverName, serverAddress, serverPort,
serverSite); serverSite);
} else { } else {
SettingsCache::instance()->servers().addNewServer(serverName, serverAddress, serverPort, "", "", false, SettingsCache::instance().servers().addNewServer(serverName, serverAddress, serverPort, "", "", false,
serverSite); serverSite);
} }
} }
@ -102,7 +102,7 @@ void HandlePublicServers::updateServerINISettings(QMap<QString, QVariant> jsonMa
QString serverAddr = pair.first; QString serverAddr = pair.first;
if (publicServersToRemove.indexOf(serverAddr) != -1) { if (publicServersToRemove.indexOf(serverAddr) != -1) {
SettingsCache::instance()->servers().removeServer(serverAddr); SettingsCache::instance().servers().removeServer(serverAddr);
} }
} }

View file

@ -23,7 +23,7 @@ QMap<QString, std::pair<QString, UserConnection_Information>> UserConnection_Inf
{ {
QMap<QString, std::pair<QString, UserConnection_Information>> serverList; QMap<QString, std::pair<QString, UserConnection_Information>> serverList;
ServersSettings &servers = SettingsCache::instance()->servers(); ServersSettings &servers = SettingsCache::instance().servers();
int size = servers.getValue("totalServers", "server", "server_details").toInt() + 1; int size = servers.getValue("totalServers", "server", "server_details").toInt() + 1;
@ -47,7 +47,7 @@ QStringList UserConnection_Information::getServerInfo(const QString &find)
{ {
QStringList _server; QStringList _server;
ServersSettings &servers = SettingsCache::instance()->servers(); ServersSettings &servers = SettingsCache::instance().servers();
int size = servers.getValue("totalServers", "server", "server_details").toInt() + 1; int size = servers.getValue("totalServers", "server", "server_details").toInt() + 1;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {

View file

@ -49,11 +49,9 @@ AbstractTabDeckEditor::AbstractTabDeckEditor(TabSupervisor *_tabSupervisor) : Ta
cardInfoDockWidget = new DeckEditorCardInfoDockWidget(this); cardInfoDockWidget = new DeckEditorCardInfoDockWidget(this);
filterDockWidget = new DeckEditorFilterDockWidget(this); filterDockWidget = new DeckEditorFilterDockWidget(this);
printingSelectorDockWidget = new DeckEditorPrintingSelectorDockWidget(this); printingSelectorDockWidget = new DeckEditorPrintingSelectorDockWidget(this);
connect(SettingsCache::instance().get(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this, connect(&SettingsCache::instance(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this, [this] {
[this] { printingSelectorDockWidget->setHidden(SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
printingSelectorDockWidget->setHidden( });
SettingsCache::instance()->getOverrideAllCardArtWithPersonalPreference());
});
connect(deckDockWidget, &DeckEditorDeckDockWidget::deckChanged, this, &AbstractTabDeckEditor::onDeckChanged); connect(deckDockWidget, &DeckEditorDeckDockWidget::deckChanged, this, &AbstractTabDeckEditor::onDeckChanged);
connect(deckDockWidget, &DeckEditorDeckDockWidget::deckModified, this, &AbstractTabDeckEditor::onDeckModified); connect(deckDockWidget, &DeckEditorDeckDockWidget::deckModified, this, &AbstractTabDeckEditor::onDeckModified);
@ -73,7 +71,7 @@ AbstractTabDeckEditor::AbstractTabDeckEditor(TabSupervisor *_tabSupervisor) : Ta
connect(filterDockWidget, &DeckEditorFilterDockWidget::clearAllDatabaseFilters, databaseDisplayDockWidget, connect(filterDockWidget, &DeckEditorFilterDockWidget::clearAllDatabaseFilters, databaseDisplayDockWidget,
&DeckEditorDatabaseDisplayWidget::clearAllDatabaseFilters); &DeckEditorDatabaseDisplayWidget::clearAllDatabaseFilters);
connect(&SettingsCache::instance().get()->shortcuts(), &ShortcutsSettings::shortCutChanged, this, connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&AbstractTabDeckEditor::refreshShortcuts); &AbstractTabDeckEditor::refreshShortcuts);
} }
@ -155,7 +153,7 @@ void AbstractTabDeckEditor::openDeck(DeckLoader *deck)
setDeck(deck); setDeck(deck);
if (!deck->getLastFileName().isEmpty()) { if (!deck->getLastFileName().isEmpty()) {
SettingsCache::instance()->recents().updateRecentlyOpenedDeckPaths(deck->getLastFileName()); SettingsCache::instance().recents().updateRecentlyOpenedDeckPaths(deck->getLastFileName());
} }
} }
@ -229,7 +227,7 @@ void AbstractTabDeckEditor::cleanDeckAndResetModified()
AbstractTabDeckEditor::DeckOpenLocation AbstractTabDeckEditor::confirmOpen(const bool openInSameTabIfBlank) AbstractTabDeckEditor::DeckOpenLocation AbstractTabDeckEditor::confirmOpen(const bool openInSameTabIfBlank)
{ {
// handle `openDeckInNewTab` setting // handle `openDeckInNewTab` setting
if (SettingsCache::instance()->getOpenDeckInNewTab()) { if (SettingsCache::instance().getOpenDeckInNewTab()) {
if (openInSameTabIfBlank && isBlankNewDeck()) { if (openInSameTabIfBlank && isBlankNewDeck()) {
return SAME_TAB; return SAME_TAB;
} else { } else {
@ -368,7 +366,7 @@ bool AbstractTabDeckEditor::actSaveDeck()
bool AbstractTabDeckEditor::actSaveDeckAs() bool AbstractTabDeckEditor::actSaveDeckAs()
{ {
QFileDialog dialog(this, tr("Save deck")); QFileDialog dialog(this, tr("Save deck"));
dialog.setDirectory(SettingsCache::instance()->getDeckPath()); dialog.setDirectory(SettingsCache::instance().getDeckPath());
dialog.setAcceptMode(QFileDialog::AcceptSave); dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setDefaultSuffix("cod"); dialog.setDefaultSuffix("cod");
dialog.setNameFilters(DeckLoader::FILE_NAME_FILTERS); dialog.setNameFilters(DeckLoader::FILE_NAME_FILTERS);
@ -388,7 +386,7 @@ bool AbstractTabDeckEditor::actSaveDeckAs()
} }
setModified(false); setModified(false);
SettingsCache::instance()->recents().updateRecentlyOpenedDeckPaths(fileName); SettingsCache::instance().recents().updateRecentlyOpenedDeckPaths(fileName);
return true; return true;
} }
@ -579,7 +577,7 @@ bool AbstractTabDeckEditor::eventFilter(QObject *o, QEvent *e)
} }
} }
if (o == this && e->type() == QEvent::Hide) { if (o == this && e->type() == QEvent::Hide) {
LayoutsSettings &layouts = SettingsCache::instance()->layouts(); LayoutsSettings &layouts = SettingsCache::instance().layouts();
layouts.setDeckEditorLayoutState(saveState()); layouts.setDeckEditorLayoutState(saveState());
layouts.setDeckEditorGeometry(saveGeometry()); layouts.setDeckEditorGeometry(saveGeometry());
layouts.setDeckEditorCardSize(cardInfoDockWidget->size()); layouts.setDeckEditorCardSize(cardInfoDockWidget->size());

View file

@ -93,11 +93,11 @@ void TabDeckEditor::createMenus()
aPrintingSelectorDockFloating->setCheckable(true); aPrintingSelectorDockFloating->setCheckable(true);
connect(aPrintingSelectorDockFloating, &QAction::triggered, this, &TabDeckEditor::dockFloatingTriggered); connect(aPrintingSelectorDockFloating, &QAction::triggered, this, &TabDeckEditor::dockFloatingTriggered);
if (SettingsCache::instance()->getOverrideAllCardArtWithPersonalPreference()) { if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
printingSelectorDockMenu->setEnabled(false); printingSelectorDockMenu->setEnabled(false);
} }
connect(SettingsCache::instance().get(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this, connect(&SettingsCache::instance(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this,
[this](bool enabled) { printingSelectorDockMenu->setEnabled(!enabled); }); [this](bool enabled) { printingSelectorDockMenu->setEnabled(!enabled); });
viewMenu->addSeparator(); viewMenu->addSeparator();
@ -151,7 +151,7 @@ void TabDeckEditor::retranslateUi()
void TabDeckEditor::refreshShortcuts() void TabDeckEditor::refreshShortcuts()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aResetLayout->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aResetLayout")); aResetLayout->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aResetLayout"));
} }
@ -166,7 +166,7 @@ void TabDeckEditor::showPrintingSelector()
void TabDeckEditor::loadLayout() void TabDeckEditor::loadLayout()
{ {
LayoutsSettings &layouts = SettingsCache::instance()->layouts(); LayoutsSettings &layouts = SettingsCache::instance().layouts();
setCentralWidget(databaseDisplayDockWidget); setCentralWidget(databaseDisplayDockWidget);
@ -178,7 +178,7 @@ void TabDeckEditor::loadLayout()
restoreGeometry(layouts.getDeckEditorGeometry()); restoreGeometry(layouts.getDeckEditorGeometry());
} }
if (SettingsCache::instance()->getOverrideAllCardArtWithPersonalPreference()) { if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
if (!printingSelectorDockWidget->isHidden()) { if (!printingSelectorDockWidget->isHidden()) {
printingSelectorDockWidget->setHidden(true); printingSelectorDockWidget->setHidden(true);
aPrintingSelectorDockVisible->setChecked(false); aPrintingSelectorDockVisible->setChecked(false);
@ -221,7 +221,7 @@ void TabDeckEditor::restartLayout()
aCardInfoDockVisible->setChecked(true); aCardInfoDockVisible->setChecked(true);
aDeckDockVisible->setChecked(true); aDeckDockVisible->setChecked(true);
aFilterDockVisible->setChecked(true); aFilterDockVisible->setChecked(true);
aPrintingSelectorDockVisible->setChecked(!SettingsCache::instance()->getOverrideAllCardArtWithPersonalPreference()); aPrintingSelectorDockVisible->setChecked(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
aCardInfoDockFloating->setChecked(false); aCardInfoDockFloating->setChecked(false);
aDeckDockFloating->setChecked(false); aDeckDockFloating->setChecked(false);
@ -242,7 +242,7 @@ void TabDeckEditor::restartLayout()
deckDockWidget->setVisible(true); deckDockWidget->setVisible(true);
cardInfoDockWidget->setVisible(true); cardInfoDockWidget->setVisible(true);
filterDockWidget->setVisible(true); filterDockWidget->setVisible(true);
printingSelectorDockWidget->setVisible(!SettingsCache::instance()->getOverrideAllCardArtWithPersonalPreference()); printingSelectorDockWidget->setVisible(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
splitDockWidget(cardInfoDockWidget, printingSelectorDockWidget, Qt::Horizontal); splitDockWidget(cardInfoDockWidget, printingSelectorDockWidget, Qt::Horizontal);
splitDockWidget(printingSelectorDockWidget, deckDockWidget, Qt::Horizontal); splitDockWidget(printingSelectorDockWidget, deckDockWidget, Qt::Horizontal);
@ -362,7 +362,7 @@ bool TabDeckEditor::eventFilter(QObject *o, QEvent *e)
} }
} }
if (o == this && e->type() == QEvent::Hide) { if (o == this && e->type() == QEvent::Hide) {
LayoutsSettings &layouts = SettingsCache::instance()->layouts(); LayoutsSettings &layouts = SettingsCache::instance().layouts();
layouts.setDeckEditorLayoutState(saveState()); layouts.setDeckEditorLayoutState(saveState());
layouts.setDeckEditorGeometry(saveGeometry()); layouts.setDeckEditorGeometry(saveGeometry());
layouts.setDeckEditorCardSize(cardInfoDockWidget->size()); layouts.setDeckEditorCardSize(cardInfoDockWidget->size());

View file

@ -36,7 +36,7 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor,
: Tab(_tabSupervisor), client(_client) : Tab(_tabSupervisor), client(_client)
{ {
localDirModel = new QFileSystemModel(this); localDirModel = new QFileSystemModel(this);
localDirModel->setRootPath(SettingsCache::instance()->getDeckPath()); localDirModel->setRootPath(SettingsCache::instance().getDeckPath());
localDirModel->sort(0, Qt::AscendingOrder); localDirModel->sort(0, Qt::AscendingOrder);
localDirView = new QTreeView; localDirView = new QTreeView;

View file

@ -80,7 +80,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
connectMessageLogToGameEventHandler(); connectMessageLogToGameEventHandler();
retranslateUi(); retranslateUi();
connect(&SettingsCache::instance().get()->shortcuts(), &ShortcutsSettings::shortCutChanged, this, connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&TabGame::refreshShortcuts); &TabGame::refreshShortcuts);
refreshShortcuts(); refreshShortcuts();
messageLog->logReplayStarted(game->getGameMetaInfo()->gameId()); messageLog->logReplayStarted(game->getGameMetaInfo()->gameId());
@ -125,7 +125,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor,
connectMessageLogToGameEventHandler(); connectMessageLogToGameEventHandler();
retranslateUi(); retranslateUi();
connect(&SettingsCache::instance().get()->shortcuts(), &ShortcutsSettings::shortCutChanged, this, connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&TabGame::refreshShortcuts); &TabGame::refreshShortcuts);
refreshShortcuts(); refreshShortcuts();
@ -254,7 +254,7 @@ void TabGame::resetChatAndPhase()
void TabGame::emitUserEvent() void TabGame::emitUserEvent()
{ {
bool globalEvent = bool globalEvent =
!game->getPlayerManager()->isSpectator() || SettingsCache::instance()->getSpectatorNotificationsEnabled(); !game->getPlayerManager()->isSpectator() || SettingsCache::instance().getSpectatorNotificationsEnabled();
emit userEvent(globalEvent); emit userEvent(globalEvent);
updatePlayerListDockTitle(); updatePlayerListDockTitle();
} }
@ -377,7 +377,7 @@ void TabGame::retranslateUi()
void TabGame::refreshShortcuts() void TabGame::refreshShortcuts()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
for (int i = 0; i < phaseActions.size(); ++i) { for (int i = 0; i < phaseActions.size(); ++i) {
QAction *temp = phaseActions.at(i); QAction *temp = phaseActions.at(i);
switch (i) { switch (i) {
@ -625,8 +625,8 @@ void TabGame::actRotateViewCCW()
void TabGame::actCompleterChanged() void TabGame::actCompleterChanged()
{ {
SettingsCache::instance()->getChatMentionCompleter() ? completer->setCompletionRole(2) SettingsCache::instance().getChatMentionCompleter() ? completer->setCompletionRole(2)
: completer->setCompletionRole(1); : completer->setCompletionRole(1);
} }
void TabGame::notifyPlayerJoin(QString playerName) void TabGame::notifyPlayerJoin(QString playerName)
@ -688,7 +688,7 @@ void TabGame::addLocalPlayer(Player *newPlayer, int playerId)
deckViewContainerLayout->addWidget(deckView); deckViewContainerLayout->addWidget(deckView);
// auto load deck for player if that debug setting is enabled // auto load deck for player if that debug setting is enabled
QString deckPath = SettingsCache::instance()->debug().getDeckPathForPlayer(newPlayer->getPlayerInfo()->getName()); QString deckPath = SettingsCache::instance().debug().getDeckPathForPlayer(newPlayer->getPlayerInfo()->getName());
if (!deckPath.isEmpty()) { if (!deckPath.isEmpty()) {
QTimer::singleShot(0, this, [deckView, deckPath] { QTimer::singleShot(0, this, [deckView, deckPath] {
deckView->playerDeckView->loadDeckFromFile(deckPath); deckView->playerDeckView->loadDeckFromFile(deckPath);
@ -1089,7 +1089,7 @@ void TabGame::createViewMenuItems()
void TabGame::loadLayout() void TabGame::loadLayout()
{ {
LayoutsSettings &layouts = SettingsCache::instance()->layouts(); LayoutsSettings &layouts = SettingsCache::instance().layouts();
if (replayManager->replay) { if (replayManager->replay) {
restoreGeometry(layouts.getReplayPlayAreaGeometry()); restoreGeometry(layouts.getReplayPlayAreaGeometry());
restoreState(layouts.getReplayPlayAreaLayoutState()); restoreState(layouts.getReplayPlayAreaLayoutState());
@ -1323,7 +1323,7 @@ void TabGame::createMessageDock(bool bReplay)
if (!bReplay) { if (!bReplay) {
connect(messageLog, &MessageLogWidget::openMessageDialog, this, &TabGame::openMessageDialog); connect(messageLog, &MessageLogWidget::openMessageDialog, this, &TabGame::openMessageDialog);
connect(messageLog, &MessageLogWidget::addMentionTag, this, &TabGame::addMentionTag); connect(messageLog, &MessageLogWidget::addMentionTag, this, &TabGame::addMentionTag);
connect(SettingsCache::instance().get(), &SettingsCache::chatMentionCompleterChanged, this, connect(&SettingsCache::instance(), &SettingsCache::chatMentionCompleterChanged, this,
&TabGame::actCompleterChanged); &TabGame::actCompleterChanged);
} }
@ -1384,7 +1384,7 @@ void TabGame::createMessageDock(bool bReplay)
void TabGame::hideEvent(QHideEvent *event) void TabGame::hideEvent(QHideEvent *event)
{ {
LayoutsSettings &layouts = SettingsCache::instance()->layouts(); LayoutsSettings &layouts = SettingsCache::instance().layouts();
if (replayManager->replay) { if (replayManager->replay) {
layouts.setReplayPlayAreaState(saveState()); layouts.setReplayPlayAreaState(saveState());
layouts.setReplayPlayAreaGeometry(saveGeometry()); layouts.setReplayPlayAreaGeometry(saveGeometry());

View file

@ -122,7 +122,7 @@ void TabMessage::processUserMessageEvent(const Event_UserMessage &event)
chatView->appendMessage(QString::fromStdString(event.message()), {}, *userInfo, true); chatView->appendMessage(QString::fromStdString(event.message()), {}, *userInfo, true);
if (tabSupervisor->currentIndex() != tabSupervisor->indexOf(this)) if (tabSupervisor->currentIndex() != tabSupervisor->indexOf(this))
soundEngine->playSound("private_message"); soundEngine->playSound("private_message");
if (SettingsCache::instance()->getShowMessagePopup() && shouldShowSystemPopup(event)) if (SettingsCache::instance().getShowMessagePopup() && shouldShowSystemPopup(event))
showSystemPopup(event); showSystemPopup(event);
if (QString::fromStdString(event.sender_name()).toLower().simplified() == "servatrice") if (QString::fromStdString(event.sender_name()).toLower().simplified() == "servatrice")
sayEdit->setDisabled(true); sayEdit->setDisabled(true);

View file

@ -58,7 +58,7 @@ TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client, c
QGroupBox *TabReplays::createLeftLayout() QGroupBox *TabReplays::createLeftLayout()
{ {
localDirModel = new QFileSystemModel(this); localDirModel = new QFileSystemModel(this);
localDirModel->setRootPath(SettingsCache::instance()->getReplaysPath()); localDirModel->setRootPath(SettingsCache::instance().getReplaysPath());
localDirModel->sort(0, Qt::AscendingOrder); localDirModel->sort(0, Qt::AscendingOrder);
localDirView = new QTreeView; localDirView = new QTreeView;

View file

@ -59,7 +59,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
connect(chatView, &ChatView::showCardInfoPopup, this, &TabRoom::showCardInfoPopup); connect(chatView, &ChatView::showCardInfoPopup, this, &TabRoom::showCardInfoPopup);
connect(chatView, &ChatView::deleteCardInfoPopup, this, &TabRoom::deleteCardInfoPopup); connect(chatView, &ChatView::deleteCardInfoPopup, this, &TabRoom::deleteCardInfoPopup);
connect(chatView, &ChatView::addMentionTag, this, &TabRoom::addMentionTag); connect(chatView, &ChatView::addMentionTag, this, &TabRoom::addMentionTag);
connect(SettingsCache::instance().get(), &SettingsCache::chatMentionCompleterChanged, this, connect(&SettingsCache::instance(), &SettingsCache::chatMentionCompleterChanged, this,
&TabRoom::actCompleterChanged); &TabRoom::actCompleterChanged);
sayLabel = new QLabel; sayLabel = new QLabel;
sayEdit = new LineEditCompleter; sayEdit = new LineEditCompleter;
@ -127,7 +127,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
sayEdit->setCompleter(completer); sayEdit->setCompleter(completer);
actCompleterChanged(); actCompleterChanged();
connect(&SettingsCache::instance().get()->shortcuts(), &ShortcutsSettings::shortCutChanged, this, connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&TabRoom::refreshShortcuts); &TabRoom::refreshShortcuts);
refreshShortcuts(); refreshShortcuts();
@ -229,8 +229,8 @@ void TabRoom::actOpenChatSettings()
void TabRoom::actCompleterChanged() void TabRoom::actCompleterChanged()
{ {
SettingsCache::instance()->getChatMentionCompleter() ? completer->setCompletionRole(2) SettingsCache::instance().getChatMentionCompleter() ? completer->setCompletionRole(2)
: completer->setCompletionRole(1); : completer->setCompletionRole(1);
} }
void TabRoom::processRoomEvent(const RoomEvent &event) void TabRoom::processRoomEvent(const RoomEvent &event)
@ -291,12 +291,12 @@ void TabRoom::processRoomSayEvent(const Event_RoomSay &event)
ServerInfo_User userInfo = {}; ServerInfo_User userInfo = {};
if (twi) { if (twi) {
userInfo = twi->getUserInfo(); userInfo = twi->getUserInfo();
if (SettingsCache::instance()->getIgnoreUnregisteredUsers() && if (SettingsCache::instance().getIgnoreUnregisteredUsers() &&
!UserLevelFlags(userInfo.user_level()).testFlag(ServerInfo_User::IsRegistered)) !UserLevelFlags(userInfo.user_level()).testFlag(ServerInfo_User::IsRegistered))
return; return;
} }
if (event.message_type() == Event_RoomSay::ChatHistory && !SettingsCache::instance()->getRoomHistory()) if (event.message_type() == Event_RoomSay::ChatHistory && !SettingsCache::instance().getRoomHistory())
return; return;
if (event.message_type() == Event_RoomSay::ChatHistory) if (event.message_type() == Event_RoomSay::ChatHistory)
@ -318,7 +318,7 @@ void TabRoom::processRemoveMessagesEvent(const Event_RemoveMessages &event)
void TabRoom::refreshShortcuts() void TabRoom::refreshShortcuts()
{ {
aClearChat->setShortcuts(SettingsCache::instance()->shortcuts().getShortcut("tab_room/aClearChat")); aClearChat->setShortcuts(SettingsCache::instance().shortcuts().getShortcut("tab_room/aClearChat"));
} }
void TabRoom::addMentionTag(QString mentionTag) void TabRoom::addMentionTag(QString mentionTag)

View file

@ -176,7 +176,7 @@ TabSupervisor::TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget *
aTabLog->setCheckable(true); aTabLog->setCheckable(true);
connect(aTabLog, &QAction::triggered, this, &TabSupervisor::actTabLog); connect(aTabLog, &QAction::triggered, this, &TabSupervisor::actTabLog);
connect(&SettingsCache::instance().get()->shortcuts(), &ShortcutsSettings::shortCutChanged, this, connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
&TabSupervisor::refreshShortcuts); &TabSupervisor::refreshShortcuts);
refreshShortcuts(); refreshShortcuts();
@ -252,7 +252,7 @@ void TabSupervisor::retranslateUi()
void TabSupervisor::refreshShortcuts() void TabSupervisor::refreshShortcuts()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aTabDeckEditor->setShortcuts(shortcuts.getShortcut("Tabs/aTabDeckEditor")); aTabDeckEditor->setShortcuts(shortcuts.getShortcut("Tabs/aTabDeckEditor"));
aTabVisualDeckEditor->setShortcuts(shortcuts.getShortcut("Tabs/aTabVisualDeckEditor")); aTabVisualDeckEditor->setShortcuts(shortcuts.getShortcut("Tabs/aTabVisualDeckEditor"));
@ -323,13 +323,13 @@ void TabSupervisor::initStartupTabs()
openTabHome(); openTabHome();
setCurrentWidget(tabHome); setCurrentWidget(tabHome);
if (SettingsCache::instance()->getTabVisualDeckStorageOpen()) { if (SettingsCache::instance().getTabVisualDeckStorageOpen()) {
openTabVisualDeckStorage(); openTabVisualDeckStorage();
} }
if (SettingsCache::instance()->getTabDeckStorageOpen()) { if (SettingsCache::instance().getTabDeckStorageOpen()) {
openTabDeckStorage(); openTabDeckStorage();
} }
if (SettingsCache::instance()->getTabReplaysOpen()) { if (SettingsCache::instance().getTabReplaysOpen()) {
openTabReplays(); openTabReplays();
} }
} }
@ -408,10 +408,10 @@ void TabSupervisor::start(const ServerInfo_User &_userInfo)
tabsMenu->addAction(aTabServer); tabsMenu->addAction(aTabServer);
tabsMenu->addAction(aTabAccount); tabsMenu->addAction(aTabAccount);
if (SettingsCache::instance()->getTabServerOpen()) { if (SettingsCache::instance().getTabServerOpen()) {
openTabServer(); openTabServer();
} }
if (SettingsCache::instance()->getTabAccountOpen()) { if (SettingsCache::instance().getTabAccountOpen()) {
openTabAccount(); openTabAccount();
} }
@ -422,10 +422,10 @@ void TabSupervisor::start(const ServerInfo_User &_userInfo)
tabsMenu->addAction(aTabAdmin); tabsMenu->addAction(aTabAdmin);
tabsMenu->addAction(aTabLog); tabsMenu->addAction(aTabLog);
if (SettingsCache::instance()->getTabAdminOpen()) { if (SettingsCache::instance().getTabAdminOpen()) {
openTabAdmin(); openTabAdmin();
} }
if (SettingsCache::instance()->getTabLogOpen()) { if (SettingsCache::instance().getTabLogOpen()) {
openTabLog(); openTabLog();
} }
} }
@ -528,7 +528,7 @@ void TabSupervisor::openTabHome()
void TabSupervisor::actTabVisualDeckStorage(bool checked) void TabSupervisor::actTabVisualDeckStorage(bool checked)
{ {
SettingsCache::instance()->setTabVisualDeckStorageOpen(checked); SettingsCache::instance().setTabVisualDeckStorageOpen(checked);
if (checked && !tabVisualDeckStorage) { if (checked && !tabVisualDeckStorage) {
openTabVisualDeckStorage(); openTabVisualDeckStorage();
setCurrentWidget(tabVisualDeckStorage); setCurrentWidget(tabVisualDeckStorage);
@ -552,7 +552,7 @@ void TabSupervisor::openTabVisualDeckStorage()
void TabSupervisor::actTabServer(bool checked) void TabSupervisor::actTabServer(bool checked)
{ {
SettingsCache::instance()->setTabServerOpen(checked); SettingsCache::instance().setTabServerOpen(checked);
if (checked && !tabServer) { if (checked && !tabServer) {
openTabServer(); openTabServer();
setCurrentWidget(tabServer); setCurrentWidget(tabServer);
@ -575,7 +575,7 @@ void TabSupervisor::openTabServer()
void TabSupervisor::actTabAccount(bool checked) void TabSupervisor::actTabAccount(bool checked)
{ {
SettingsCache::instance()->setTabAccountOpen(checked); SettingsCache::instance().setTabAccountOpen(checked);
if (checked && !tabAccount) { if (checked && !tabAccount) {
openTabAccount(); openTabAccount();
setCurrentWidget(tabAccount); setCurrentWidget(tabAccount);
@ -600,7 +600,7 @@ void TabSupervisor::openTabAccount()
void TabSupervisor::actTabDeckStorage(bool checked) void TabSupervisor::actTabDeckStorage(bool checked)
{ {
SettingsCache::instance()->setTabDeckStorageOpen(checked); SettingsCache::instance().setTabDeckStorageOpen(checked);
if (checked && !tabDeckStorage) { if (checked && !tabDeckStorage) {
openTabDeckStorage(); openTabDeckStorage();
setCurrentWidget(tabDeckStorage); setCurrentWidget(tabDeckStorage);
@ -623,7 +623,7 @@ void TabSupervisor::openTabDeckStorage()
void TabSupervisor::actTabReplays(bool checked) void TabSupervisor::actTabReplays(bool checked)
{ {
SettingsCache::instance()->setTabReplaysOpen(checked); SettingsCache::instance().setTabReplaysOpen(checked);
if (checked && !tabReplays) { if (checked && !tabReplays) {
openTabReplays(); openTabReplays();
setCurrentWidget(tabReplays); setCurrentWidget(tabReplays);
@ -648,7 +648,7 @@ void TabSupervisor::openTabReplays()
void TabSupervisor::actTabAdmin(bool checked) void TabSupervisor::actTabAdmin(bool checked)
{ {
SettingsCache::instance()->setTabAdminOpen(checked); SettingsCache::instance().setTabAdminOpen(checked);
if (checked && !tabAdmin) { if (checked && !tabAdmin) {
openTabAdmin(); openTabAdmin();
setCurrentWidget(tabAdmin); setCurrentWidget(tabAdmin);
@ -671,7 +671,7 @@ void TabSupervisor::openTabAdmin()
void TabSupervisor::actTabLog(bool checked) void TabSupervisor::actTabLog(bool checked)
{ {
SettingsCache::instance()->setTabLogOpen(checked); SettingsCache::instance().setTabLogOpen(checked);
if (checked && !tabLog) { if (checked && !tabLog) {
openTabLog(); openTabLog();
setCurrentWidget(tabLog); setCurrentWidget(tabLog);
@ -849,7 +849,7 @@ void TabSupervisor::talkLeft(TabMessage *tab)
*/ */
void TabSupervisor::openDeckInNewTab(const DeckLoader *deckToOpen) void TabSupervisor::openDeckInNewTab(const DeckLoader *deckToOpen)
{ {
int type = SettingsCache::instance()->getDefaultDeckEditorType(); int type = SettingsCache::instance().getDefaultDeckEditorType();
switch (type) { switch (type) {
case ClassicDeckEditor: case ClassicDeckEditor:
addDeckEditorTab(deckToOpen); addDeckEditorTab(deckToOpen);
@ -940,7 +940,7 @@ void TabSupervisor::tabUserEvent(bool globalEvent)
tab->setContentsChanged(true); tab->setContentsChanged(true);
setTabIcon(indexOf(tab), QPixmap("theme:icons/tab_changed")); setTabIcon(indexOf(tab), QPixmap("theme:icons/tab_changed"));
} }
if (globalEvent && SettingsCache::instance()->getNotificationsEnabled()) if (globalEvent && SettingsCache::instance().getNotificationsEnabled())
QApplication::alert(this); QApplication::alert(this);
} }
@ -978,7 +978,7 @@ void TabSupervisor::processUserMessageEvent(const Event_UserMessage &event)
const ServerInfo_User *onlineUserInfo = userListManager->getOnlineUser(senderName); const ServerInfo_User *onlineUserInfo = userListManager->getOnlineUser(senderName);
if (onlineUserInfo) { if (onlineUserInfo) {
auto userLevel = UserLevelFlags(onlineUserInfo->user_level()); auto userLevel = UserLevelFlags(onlineUserInfo->user_level());
if (SettingsCache::instance()->getIgnoreUnregisteredUserMessages() && if (SettingsCache::instance().getIgnoreUnregisteredUserMessages() &&
!userLevel.testFlag(ServerInfo_User::IsRegistered)) !userLevel.testFlag(ServerInfo_User::IsRegistered))
// Flags are additive, so reg/mod/admin are all IsRegistered // Flags are additive, so reg/mod/admin are all IsRegistered
return; return;
@ -1022,7 +1022,7 @@ void TabSupervisor::processUserJoined(const ServerInfo_User &userInfoJoined)
} }
} }
if (SettingsCache::instance()->getBuddyConnectNotificationsEnabled()) { if (SettingsCache::instance().getBuddyConnectNotificationsEnabled()) {
QApplication::alert(this); QApplication::alert(this);
this->actShowPopup(tr("Your buddy %1 has signed on!").arg(userName)); this->actShowPopup(tr("Your buddy %1 has signed on!").arg(userName));
} }

View file

@ -45,7 +45,7 @@ TabDeckEditorVisual::TabDeckEditorVisual(TabSupervisor *_tabSupervisor) : Abstra
installEventFilter(this); installEventFilter(this);
TabDeckEditorVisual::retranslateUi(); TabDeckEditorVisual::retranslateUi();
connect(&SettingsCache::instance().get()->shortcuts(), SIGNAL(shortCutChanged()), this, SLOT(refreshShortcuts())); connect(&SettingsCache::instance().shortcuts(), SIGNAL(shortCutChanged()), this, SLOT(refreshShortcuts()));
TabDeckEditorVisual::refreshShortcuts(); TabDeckEditorVisual::refreshShortcuts();
TabDeckEditorVisual::loadLayout(); TabDeckEditorVisual::loadLayout();
@ -126,11 +126,11 @@ void TabDeckEditorVisual::createMenus()
aPrintingSelectorDockFloating->setCheckable(true); aPrintingSelectorDockFloating->setCheckable(true);
connect(aPrintingSelectorDockFloating, SIGNAL(triggered()), this, SLOT(dockFloatingTriggered())); connect(aPrintingSelectorDockFloating, SIGNAL(triggered()), this, SLOT(dockFloatingTriggered()));
if (SettingsCache::instance()->getOverrideAllCardArtWithPersonalPreference()) { if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
printingSelectorDockMenu->setEnabled(false); printingSelectorDockMenu->setEnabled(false);
} }
connect(SettingsCache::instance().get(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this, connect(&SettingsCache::instance(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this,
[this](bool enabled) { printingSelectorDockMenu->setEnabled(!enabled); }); [this](bool enabled) { printingSelectorDockMenu->setEnabled(!enabled); });
viewMenu->addSeparator(); viewMenu->addSeparator();
@ -228,13 +228,13 @@ void TabDeckEditorVisual::freeDocksSize()
void TabDeckEditorVisual::refreshShortcuts() void TabDeckEditorVisual::refreshShortcuts()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance()->shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aResetLayout->setShortcuts(shortcuts.getShortcut("TabDeckEditorVisual/aResetLayout")); aResetLayout->setShortcuts(shortcuts.getShortcut("TabDeckEditorVisual/aResetLayout"));
} }
void TabDeckEditorVisual::loadLayout() void TabDeckEditorVisual::loadLayout()
{ {
LayoutsSettings &layouts = SettingsCache::instance()->layouts(); LayoutsSettings &layouts = SettingsCache::instance().layouts();
auto &layoutState = layouts.getDeckEditorLayoutState(); auto &layoutState = layouts.getDeckEditorLayoutState();
if (layoutState.isNull()) { if (layoutState.isNull()) {
restartLayout(); restartLayout();
@ -243,7 +243,7 @@ void TabDeckEditorVisual::loadLayout()
restoreGeometry(layouts.getDeckEditorGeometry()); restoreGeometry(layouts.getDeckEditorGeometry());
} }
if (SettingsCache::instance()->getOverrideAllCardArtWithPersonalPreference()) { if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
if (!printingSelectorDockWidget->isHidden()) { if (!printingSelectorDockWidget->isHidden()) {
printingSelectorDockWidget->setHidden(true); printingSelectorDockWidget->setHidden(true);
aPrintingSelectorDockVisible->setChecked(false); aPrintingSelectorDockVisible->setChecked(false);
@ -285,7 +285,7 @@ void TabDeckEditorVisual::restartLayout()
aCardInfoDockVisible->setChecked(true); aCardInfoDockVisible->setChecked(true);
aDeckDockVisible->setChecked(true); aDeckDockVisible->setChecked(true);
aFilterDockVisible->setChecked(false); aFilterDockVisible->setChecked(false);
aPrintingSelectorDockVisible->setChecked(!SettingsCache::instance()->getOverrideAllCardArtWithPersonalPreference()); aPrintingSelectorDockVisible->setChecked(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
aCardInfoDockFloating->setChecked(false); aCardInfoDockFloating->setChecked(false);
aDeckDockFloating->setChecked(false); aDeckDockFloating->setChecked(false);
@ -301,7 +301,7 @@ void TabDeckEditorVisual::restartLayout()
deckDockWidget->setVisible(true); deckDockWidget->setVisible(true);
cardInfoDockWidget->setVisible(true); cardInfoDockWidget->setVisible(true);
filterDockWidget->setVisible(false); filterDockWidget->setVisible(false);
printingSelectorDockWidget->setVisible(!SettingsCache::instance()->getOverrideAllCardArtWithPersonalPreference()); printingSelectorDockWidget->setVisible(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
deckDockWidget->setFloating(false); deckDockWidget->setFloating(false);
cardInfoDockWidget->setFloating(false); cardInfoDockWidget->setFloating(false);
@ -363,7 +363,7 @@ bool TabDeckEditorVisual::eventFilter(QObject *o, QEvent *e)
} }
} }
if (o == this && e->type() == QEvent::Hide) { if (o == this && e->type() == QEvent::Hide) {
LayoutsSettings &layouts = SettingsCache::instance()->layouts(); LayoutsSettings &layouts = SettingsCache::instance().layouts();
layouts.setDeckEditorLayoutState(saveState()); layouts.setDeckEditorLayoutState(saveState());
layouts.setDeckEditorGeometry(saveGeometry()); layouts.setDeckEditorGeometry(saveGeometry());
layouts.setDeckEditorCardSize(cardInfoDockWidget->size()); layouts.setDeckEditorCardSize(cardInfoDockWidget->size());

View file

@ -36,7 +36,7 @@ bool LineEditUnfocusable::isUnfocusShortcut(QKeyEvent *event)
keyNoMod = QKeySequence(event->key()).toString(); keyNoMod = QKeySequence(event->key()).toString();
QKeySequence key(modifier + keyNoMod); QKeySequence key(modifier + keyNoMod);
QList<QKeySequence> unfocusShortcut = SettingsCache::instance()->shortcuts().getShortcut("Player/unfocusTextBox"); QList<QKeySequence> unfocusShortcut = SettingsCache::instance().shortcuts().getShortcut("Player/unfocusTextBox");
for (const auto &unfocusKey : unfocusShortcut) { for (const auto &unfocusKey : unfocusShortcut) {
if (key.matches(unfocusKey) == QKeySequence::ExactMatch) if (key.matches(unfocusKey) == QKeySequence::ExactMatch)

View file

@ -46,7 +46,7 @@ void SequenceEdit::setShortcutName(const QString &_shortcutName)
clearButton->setEnabled(true); clearButton->setEnabled(true);
defaultButton->setEnabled(true); defaultButton->setEnabled(true);
lineEdit->setEnabled(true); lineEdit->setEnabled(true);
lineEdit->setText(SettingsCache::instance()->shortcuts().getShortcutString(shortcutName)); lineEdit->setText(SettingsCache::instance().shortcuts().getShortcutString(shortcutName));
// Correct as in-line translation // Correct as in-line translation
lineEdit->setPlaceholderText(tr("Hit the key/combination of keys you want to set for this action")); lineEdit->setPlaceholderText(tr("Hit the key/combination of keys you want to set for this action"));
} }
@ -74,13 +74,13 @@ void SequenceEdit::removeLastShortcut()
void SequenceEdit::restoreDefault() void SequenceEdit::restoreDefault()
{ {
lineEdit->setText(SettingsCache::instance()->shortcuts().getDefaultShortcutString(shortcutName)); lineEdit->setText(SettingsCache::instance().shortcuts().getDefaultShortcutString(shortcutName));
updateSettings(); updateSettings();
} }
void SequenceEdit::refreshShortcut() void SequenceEdit::refreshShortcut()
{ {
lineEdit->setText(SettingsCache::instance()->shortcuts().getShortcutString(shortcutName)); lineEdit->setText(SettingsCache::instance().shortcuts().getShortcutString(shortcutName));
} }
void SequenceEdit::clear() void SequenceEdit::clear()
@ -169,7 +169,7 @@ bool SequenceEdit::validateShortcut(const QKeySequence &sequence)
return true; return true;
} }
const auto &shortcutsSettings = SettingsCache::instance()->shortcuts(); const auto &shortcutsSettings = SettingsCache::instance().shortcuts();
const QString sequenceString = sequence.toString(); const QString sequenceString = sequence.toString();
if (!shortcutsSettings.isKeyAllowed(shortcutName, sequenceString)) { if (!shortcutsSettings.isKeyAllowed(shortcutName, sequenceString)) {
@ -209,7 +209,7 @@ void SequenceEdit::finishShortcut()
void SequenceEdit::updateSettings() void SequenceEdit::updateSettings()
{ {
SettingsCache::instance()->shortcuts().setShortcuts(shortcutName, lineEdit->text()); SettingsCache::instance().shortcuts().setShortcuts(shortcutName, lineEdit->text());
} }
void SequenceEdit::retranslateUi() void SequenceEdit::retranslateUi()

View file

@ -49,7 +49,7 @@ void VisualDatabaseDisplayFilterSaveLoadWidget::saveFilter()
if (filename.isEmpty()) if (filename.isEmpty())
return; return;
QString filePath = SettingsCache::instance()->getFiltersPath() + QDir::separator() + filename + ".json"; QString filePath = SettingsCache::instance().getFiltersPath() + QDir::separator() + filename + ".json";
// Serialize the filter model to JSON // Serialize the filter model to JSON
QJsonArray filtersArray; QJsonArray filtersArray;
@ -74,7 +74,7 @@ void VisualDatabaseDisplayFilterSaveLoadWidget::saveFilter()
void VisualDatabaseDisplayFilterSaveLoadWidget::loadFilter(const QString &filename) void VisualDatabaseDisplayFilterSaveLoadWidget::loadFilter(const QString &filename)
{ {
QString filePath = SettingsCache::instance()->getFiltersPath() + QDir::separator() + filename; QString filePath = SettingsCache::instance().getFiltersPath() + QDir::separator() + filename;
QFile file(filePath); QFile file(filePath);
if (!file.open(QIODevice::ReadOnly)) if (!file.open(QIODevice::ReadOnly))
@ -124,7 +124,7 @@ void VisualDatabaseDisplayFilterSaveLoadWidget::refreshFilterList()
fileButtons.clear(); // Clear the list of buttons fileButtons.clear(); // Clear the list of buttons
// Refresh the filter file list // Refresh the filter file list
QDir dir(SettingsCache::instance()->getFiltersPath()); QDir dir(SettingsCache::instance().getFiltersPath());
QStringList filterFiles = dir.entryList(QStringList() << "*.json", QDir::Files, QDir::Name); QStringList filterFiles = dir.entryList(QStringList() << "*.json", QDir::Files, QDir::Name);
// Loop through the filter files and create widgets for them // Loop through the filter files and create widgets for them

View file

@ -18,16 +18,16 @@ VisualDatabaseDisplayRecentSetFilterSettingsWidget::VisualDatabaseDisplayRecentS
filterToMostRecentSetsCheckBox = new QCheckBox(this); filterToMostRecentSetsCheckBox = new QCheckBox(this);
filterToMostRecentSetsCheckBox->setChecked( filterToMostRecentSetsCheckBox->setChecked(
SettingsCache::instance()->getVisualDatabaseDisplayFilterToMostRecentSetsEnabled()); SettingsCache::instance().getVisualDatabaseDisplayFilterToMostRecentSetsEnabled());
connect(filterToMostRecentSetsCheckBox, &QCheckBox::QT_STATE_CHANGED, SettingsCache::instance().get(), connect(filterToMostRecentSetsCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setVisualDatabaseDisplayFilterToMostRecentSetsEnabled); &SettingsCache::setVisualDatabaseDisplayFilterToMostRecentSetsEnabled);
filterToMostRecentSetsAmount = new QSpinBox(this); filterToMostRecentSetsAmount = new QSpinBox(this);
filterToMostRecentSetsAmount->setMinimum(1); filterToMostRecentSetsAmount->setMinimum(1);
filterToMostRecentSetsAmount->setMaximum(100); filterToMostRecentSetsAmount->setMaximum(100);
filterToMostRecentSetsAmount->setValue( filterToMostRecentSetsAmount->setValue(
SettingsCache::instance()->getVisualDatabaseDisplayFilterToMostRecentSetsAmount()); SettingsCache::instance().getVisualDatabaseDisplayFilterToMostRecentSetsAmount());
connect(filterToMostRecentSetsAmount, QOverload<int>::of(&QSpinBox::valueChanged), SettingsCache::instance().get(), connect(filterToMostRecentSetsAmount, QOverload<int>::of(&QSpinBox::valueChanged), &SettingsCache::instance(),
&SettingsCache::setVisualDatabaseDisplayFilterToMostRecentSetsAmount); &SettingsCache::setVisualDatabaseDisplayFilterToMostRecentSetsAmount);
layout->addWidget(filterToMostRecentSetsCheckBox); layout->addWidget(filterToMostRecentSetsCheckBox);
@ -54,10 +54,10 @@ VisualDatabaseDisplaySetFilterWidget::VisualDatabaseDisplaySetFilterWidget(QWidg
recentSetsSettingsWidget = new VisualDatabaseDisplayRecentSetFilterSettingsWidget(this); recentSetsSettingsWidget = new VisualDatabaseDisplayRecentSetFilterSettingsWidget(this);
layout->addWidget(recentSetsSettingsWidget); layout->addWidget(recentSetsSettingsWidget);
connect(SettingsCache::instance().get(), &SettingsCache::visualDatabaseDisplayFilterToMostRecentSetsEnabledChanged, connect(&SettingsCache::instance(), &SettingsCache::visualDatabaseDisplayFilterToMostRecentSetsEnabledChanged, this,
this, &VisualDatabaseDisplaySetFilterWidget::filterToRecentSets); &VisualDatabaseDisplaySetFilterWidget::filterToRecentSets);
connect(SettingsCache::instance().get(), &SettingsCache::visualDatabaseDisplayFilterToMostRecentSetsAmountChanged, connect(&SettingsCache::instance(), &SettingsCache::visualDatabaseDisplayFilterToMostRecentSetsAmountChanged, this,
this, &VisualDatabaseDisplaySetFilterWidget::filterToRecentSets); &VisualDatabaseDisplaySetFilterWidget::filterToRecentSets);
searchBox = new QLineEdit(this); searchBox = new QLineEdit(this);
searchBox->setPlaceholderText(tr("Search sets...")); searchBox->setPlaceholderText(tr("Search sets..."));
@ -115,7 +115,7 @@ void VisualDatabaseDisplaySetFilterWidget::createSetButtons()
void VisualDatabaseDisplaySetFilterWidget::filterToRecentSets() void VisualDatabaseDisplaySetFilterWidget::filterToRecentSets()
{ {
if (SettingsCache::instance()->getVisualDatabaseDisplayFilterToMostRecentSetsEnabled()) { if (SettingsCache::instance().getVisualDatabaseDisplayFilterToMostRecentSetsEnabled()) {
for (auto set : activeSets.keys()) { for (auto set : activeSets.keys()) {
activeSets[set] = false; activeSets[set] = false;
} }
@ -126,7 +126,7 @@ void VisualDatabaseDisplaySetFilterWidget::filterToRecentSets()
std::sort(allSets.begin(), allSets.end(), std::sort(allSets.begin(), allSets.end(),
[](const auto &a, const auto &b) { return a->getReleaseDate() > b->getReleaseDate(); }); [](const auto &a, const auto &b) { return a->getReleaseDate() > b->getReleaseDate(); });
int setsToPreactivate = SettingsCache::instance()->getVisualDatabaseDisplayFilterToMostRecentSetsAmount(); int setsToPreactivate = SettingsCache::instance().getVisualDatabaseDisplayFilterToMostRecentSetsAmount();
int setsActivated = 0; int setsActivated = 0;
for (const auto &set : allSets) { for (const auto &set : allSets) {

View file

@ -68,7 +68,7 @@ void FilterDisplayWidget::deleteFilter()
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) { if (reply == QMessageBox::Yes) {
// If confirmed, delete the filter // If confirmed, delete the filter
QString filePath = SettingsCache::instance()->getFiltersPath() + QDir::separator() + filterFilename; QString filePath = SettingsCache::instance().getFiltersPath() + QDir::separator() + filterFilename;
QFile file(filePath); QFile file(filePath);
if (file.remove()) { if (file.remove()) {
emit filterDeleted(filterFilename); // Emit signal for deletion emit filterDeleted(filterFilename); // Emit signal for deletion

View file

@ -22,9 +22,9 @@ VisualDeckEditorSampleHandWidget::VisualDeckEditorSampleHandWidget(QWidget *pare
resetAndHandSizeLayout->addWidget(resetButton); resetAndHandSizeLayout->addWidget(resetButton);
handSizeSpinBox = new QSpinBox(this); handSizeSpinBox = new QSpinBox(this);
handSizeSpinBox->setValue(SettingsCache::instance()->getVisualDeckEditorSampleHandSize()); handSizeSpinBox->setValue(SettingsCache::instance().getVisualDeckEditorSampleHandSize());
handSizeSpinBox->setMinimum(1); handSizeSpinBox->setMinimum(1);
connect(handSizeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), SettingsCache::instance().get(), connect(handSizeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), &SettingsCache::instance(),
&SettingsCache::setVisualDeckEditorSampleHandSize); &SettingsCache::setVisualDeckEditorSampleHandSize);
connect(handSizeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, connect(handSizeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this,
&VisualDeckEditorSampleHandWidget::updateDisplay); &VisualDeckEditorSampleHandWidget::updateDisplay);

View file

@ -105,8 +105,8 @@ void DeckPreviewDeckTagsDisplayWidget::openTagEditDlg()
if (DeckLoader::getFormatFromName(deckPreviewWidget->filePath) != DeckLoader::CockatriceFormat) { if (DeckLoader::getFormatFromName(deckPreviewWidget->filePath) != DeckLoader::CockatriceFormat) {
canAddTags = false; canAddTags = false;
// Retrieve saved preference if the prompt is disabled // Retrieve saved preference if the prompt is disabled
if (!SettingsCache::instance()->getVisualDeckStoragePromptForConversion()) { if (!SettingsCache::instance().getVisualDeckStoragePromptForConversion()) {
if (SettingsCache::instance()->getVisualDeckStorageAlwaysConvert()) { if (SettingsCache::instance().getVisualDeckStorageAlwaysConvert()) {
if (!confirmOverwriteIfExists(this, deckPreviewWidget->filePath)) if (!confirmOverwriteIfExists(this, deckPreviewWidget->filePath))
return; return;
@ -130,16 +130,16 @@ void DeckPreviewDeckTagsDisplayWidget::openTagEditDlg()
canAddTags = true; canAddTags = true;
if (conversionDialog.dontAskAgain()) { if (conversionDialog.dontAskAgain()) {
SettingsCache::instance()->setVisualDeckStoragePromptForConversion(false); SettingsCache::instance().setVisualDeckStoragePromptForConversion(false);
SettingsCache::instance()->setVisualDeckStorageAlwaysConvert(true); SettingsCache::instance().setVisualDeckStorageAlwaysConvert(true);
} }
} else { } else {
SettingsCache::instance()->setVisualDeckStorageAlwaysConvert(false); SettingsCache::instance().setVisualDeckStorageAlwaysConvert(false);
if (conversionDialog.dontAskAgain()) { if (conversionDialog.dontAskAgain()) {
SettingsCache::instance()->setVisualDeckStoragePromptForConversion(false); SettingsCache::instance().setVisualDeckStoragePromptForConversion(false);
} else { } else {
SettingsCache::instance()->setVisualDeckStoragePromptForConversion(true); SettingsCache::instance().setVisualDeckStoragePromptForConversion(true);
} }
} }
} }
@ -166,7 +166,7 @@ void DeckPreviewDeckTagsDisplayWidget::openTagEditDlg()
if (qobject_cast<AbstractTabDeckEditor *>(currentParent)) { if (qobject_cast<AbstractTabDeckEditor *>(currentParent)) {
auto *deckEditor = qobject_cast<AbstractTabDeckEditor *>(currentParent); auto *deckEditor = qobject_cast<AbstractTabDeckEditor *>(currentParent);
QStringList knownTags; QStringList knownTags;
QStringList allFiles = getAllFiles(SettingsCache::instance()->getDeckPath()); QStringList allFiles = getAllFiles(SettingsCache::instance().getDeckPath());
DeckLoader loader; DeckLoader loader;
for (const QString &file : allFiles) { for (const QString &file : allFiles) {
loader.loadFromFile(file, DeckLoader::getFormatFromName(file), false); loader.loadFromFile(file, DeckLoader::getFormatFromName(file), false);

View file

@ -20,7 +20,7 @@ DeckPreviewTagDialog::DeckPreviewTagDialog(const QStringList &knownTags,
{ {
resize(400, 500); resize(400, 500);
QStringList defaultTags = SettingsCache::instance()->getVisualDeckStorageDefaultTagsList(); QStringList defaultTags = SettingsCache::instance().getVisualDeckStorageDefaultTagsList();
// Merge knownTags with defaultTags, ensuring no duplicates // Merge knownTags with defaultTags, ensuring no duplicates
QStringList combinedTags = defaultTags + knownTags + activeTags; QStringList combinedTags = defaultTags + knownTags + activeTags;
@ -91,7 +91,7 @@ DeckPreviewTagDialog::DeckPreviewTagDialog(const QStringList &knownTags,
connect(okButton, &QPushButton::clicked, this, &DeckPreviewTagDialog::accept); connect(okButton, &QPushButton::clicked, this, &DeckPreviewTagDialog::accept);
connect(cancelButton, &QPushButton::clicked, this, &DeckPreviewTagDialog::reject); connect(cancelButton, &QPushButton::clicked, this, &DeckPreviewTagDialog::reject);
connect(SettingsCache::instance().get(), &SettingsCache::visualDeckStorageDefaultTagsListChanged, this, connect(&SettingsCache::instance(), &SettingsCache::visualDeckStorageDefaultTagsListChanged, this,
&DeckPreviewTagDialog::refreshTagList); &DeckPreviewTagDialog::refreshTagList);
retranslateUi(); retranslateUi();
@ -115,7 +115,7 @@ void DeckPreviewTagDialog::refreshTagList()
tagListView->clear(); tagListView->clear();
// Get the updated list of tags from SettingsCache // Get the updated list of tags from SettingsCache
QStringList defaultTags = SettingsCache::instance()->getVisualDeckStorageDefaultTagsList(); QStringList defaultTags = SettingsCache::instance().getVisualDeckStorageDefaultTagsList();
QStringList combinedTags = defaultTags + knownTags_ + activeTags; QStringList combinedTags = defaultTags + knownTags_ + activeTags;
combinedTags.removeDuplicates(); combinedTags.removeDuplicates();

View file

@ -42,9 +42,9 @@ DeckPreviewWidget::DeckPreviewWidget(QWidget *_parent,
connect(bannerCardDisplayWidget, &DeckPreviewCardPictureWidget::imageDoubleClicked, this, connect(bannerCardDisplayWidget, &DeckPreviewCardPictureWidget::imageDoubleClicked, this,
&DeckPreviewWidget::imageDoubleClickedEvent); &DeckPreviewWidget::imageDoubleClickedEvent);
connect(SettingsCache::instance().get(), &SettingsCache::visualDeckStorageShowTagsOnDeckPreviewsChanged, this, connect(&SettingsCache::instance(), &SettingsCache::visualDeckStorageShowTagsOnDeckPreviewsChanged, this,
&DeckPreviewWidget::updateTagsVisibility); &DeckPreviewWidget::updateTagsVisibility);
connect(SettingsCache::instance().get(), &SettingsCache::visualDeckStorageShowBannerCardComboBoxChanged, this, connect(&SettingsCache::instance(), &SettingsCache::visualDeckStorageShowBannerCardComboBoxChanged, this,
&DeckPreviewWidget::updateBannerCardComboBoxVisibility); &DeckPreviewWidget::updateBannerCardComboBoxVisibility);
connect(visualDeckStorageWidget->settings(), &VisualDeckStorageQuickSettingsWidget::deckPreviewTooltipChanged, this, connect(visualDeckStorageWidget->settings(), &VisualDeckStorageQuickSettingsWidget::deckPreviewTooltipChanged, this,
&DeckPreviewWidget::refreshBannerCardToolTip); &DeckPreviewWidget::refreshBannerCardToolTip);
@ -96,8 +96,8 @@ void DeckPreviewWidget::initializeUi(const bool deckLoadSuccess)
&DeckPreviewWidget::setBannerCard); &DeckPreviewWidget::setBannerCard);
updateBannerCardComboBox(); updateBannerCardComboBox();
updateBannerCardComboBoxVisibility(SettingsCache::instance()->getVisualDeckStorageShowBannerCardComboBox()); updateBannerCardComboBoxVisibility(SettingsCache::instance().getVisualDeckStorageShowBannerCardComboBox());
updateTagsVisibility(SettingsCache::instance()->getVisualDeckStorageShowTagsOnDeckPreviews()); updateTagsVisibility(SettingsCache::instance().getVisualDeckStorageShowTagsOnDeckPreviews());
layout->addWidget(colorIdentityWidget); layout->addWidget(colorIdentityWidget);
layout->addWidget(deckTagsDisplayWidget); layout->addWidget(deckTagsDisplayWidget);

View file

@ -42,7 +42,7 @@ VisualDeckStorageFolderDisplayWidget::VisualDeckStorageFolderDisplayWidget(
void VisualDeckStorageFolderDisplayWidget::refreshUi() void VisualDeckStorageFolderDisplayWidget::refreshUi()
{ {
QString bannerText = tr("Deck Storage"); QString bannerText = tr("Deck Storage");
QString deckPath = SettingsCache::instance()->getDeckPath(); QString deckPath = SettingsCache::instance().getDeckPath();
if (filePath != deckPath) { if (filePath != deckPath) {
QString relativePath = filePath; QString relativePath = filePath;

View file

@ -12,43 +12,43 @@ VisualDeckStorageQuickSettingsWidget::VisualDeckStorageQuickSettingsWidget(QWidg
{ {
// show folders checkbox // show folders checkbox
showFoldersCheckBox = new QCheckBox(this); showFoldersCheckBox = new QCheckBox(this);
showFoldersCheckBox->setChecked(SettingsCache::instance()->getVisualDeckStorageShowFolders()); showFoldersCheckBox->setChecked(SettingsCache::instance().getVisualDeckStorageShowFolders());
connect(showFoldersCheckBox, &QCheckBox::QT_STATE_CHANGED, this, connect(showFoldersCheckBox, &QCheckBox::QT_STATE_CHANGED, this,
&VisualDeckStorageQuickSettingsWidget::showFoldersChanged); &VisualDeckStorageQuickSettingsWidget::showFoldersChanged);
connect(showFoldersCheckBox, &QCheckBox::QT_STATE_CHANGED, SettingsCache::instance().get(), connect(showFoldersCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setVisualDeckStorageShowFolders); &SettingsCache::setVisualDeckStorageShowFolders);
// show tag filter widget checkbox // show tag filter widget checkbox
showTagFilterCheckBox = new QCheckBox(this); showTagFilterCheckBox = new QCheckBox(this);
showTagFilterCheckBox->setChecked(SettingsCache::instance()->getVisualDeckStorageShowTagFilter()); showTagFilterCheckBox->setChecked(SettingsCache::instance().getVisualDeckStorageShowTagFilter());
connect(showTagFilterCheckBox, &QCheckBox::QT_STATE_CHANGED, this, connect(showTagFilterCheckBox, &QCheckBox::QT_STATE_CHANGED, this,
&VisualDeckStorageQuickSettingsWidget::showTagFilterChanged); &VisualDeckStorageQuickSettingsWidget::showTagFilterChanged);
connect(showTagFilterCheckBox, &QCheckBox::QT_STATE_CHANGED, SettingsCache::instance().get(), connect(showTagFilterCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setVisualDeckStorageShowTagFilter); &SettingsCache::setVisualDeckStorageShowTagFilter);
// show tags on DeckPreviewWidget checkbox // show tags on DeckPreviewWidget checkbox
showTagsOnDeckPreviewsCheckBox = new QCheckBox(this); showTagsOnDeckPreviewsCheckBox = new QCheckBox(this);
showTagsOnDeckPreviewsCheckBox->setChecked(SettingsCache::instance()->getVisualDeckStorageShowTagsOnDeckPreviews()); showTagsOnDeckPreviewsCheckBox->setChecked(SettingsCache::instance().getVisualDeckStorageShowTagsOnDeckPreviews());
connect(showTagsOnDeckPreviewsCheckBox, &QCheckBox::QT_STATE_CHANGED, this, connect(showTagsOnDeckPreviewsCheckBox, &QCheckBox::QT_STATE_CHANGED, this,
&VisualDeckStorageQuickSettingsWidget::showTagsOnDeckPreviewsChanged); &VisualDeckStorageQuickSettingsWidget::showTagsOnDeckPreviewsChanged);
connect(showTagsOnDeckPreviewsCheckBox, &QCheckBox::QT_STATE_CHANGED, SettingsCache::instance().get(), connect(showTagsOnDeckPreviewsCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setVisualDeckStorageShowTagsOnDeckPreviews); &SettingsCache::setVisualDeckStorageShowTagsOnDeckPreviews);
// show banner card selector checkbox // show banner card selector checkbox
showBannerCardComboBoxCheckBox = new QCheckBox(this); showBannerCardComboBoxCheckBox = new QCheckBox(this);
showBannerCardComboBoxCheckBox->setChecked(SettingsCache::instance()->getVisualDeckStorageShowBannerCardComboBox()); showBannerCardComboBoxCheckBox->setChecked(SettingsCache::instance().getVisualDeckStorageShowBannerCardComboBox());
connect(showBannerCardComboBoxCheckBox, &QCheckBox::QT_STATE_CHANGED, this, connect(showBannerCardComboBoxCheckBox, &QCheckBox::QT_STATE_CHANGED, this,
&VisualDeckStorageQuickSettingsWidget::showBannerCardComboBoxChanged); &VisualDeckStorageQuickSettingsWidget::showBannerCardComboBoxChanged);
connect(showBannerCardComboBoxCheckBox, &QCheckBox::QT_STATE_CHANGED, SettingsCache::instance().get(), connect(showBannerCardComboBoxCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setVisualDeckStorageShowBannerCardComboBox); &SettingsCache::setVisualDeckStorageShowBannerCardComboBox);
// draw unused color identities checkbox // draw unused color identities checkbox
drawUnusedColorIdentitiesCheckBox = new QCheckBox(this); drawUnusedColorIdentitiesCheckBox = new QCheckBox(this);
drawUnusedColorIdentitiesCheckBox->setChecked( drawUnusedColorIdentitiesCheckBox->setChecked(
SettingsCache::instance()->getVisualDeckStorageDrawUnusedColorIdentities()); SettingsCache::instance().getVisualDeckStorageDrawUnusedColorIdentities());
connect(drawUnusedColorIdentitiesCheckBox, &QCheckBox::QT_STATE_CHANGED, this, connect(drawUnusedColorIdentitiesCheckBox, &QCheckBox::QT_STATE_CHANGED, this,
&VisualDeckStorageQuickSettingsWidget::drawUnusedColorIdentitiesChanged); &VisualDeckStorageQuickSettingsWidget::drawUnusedColorIdentitiesChanged);
connect(drawUnusedColorIdentitiesCheckBox, &QCheckBox::QT_STATE_CHANGED, SettingsCache::instance().get(), connect(drawUnusedColorIdentitiesCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setVisualDeckStorageDrawUnusedColorIdentities); &SettingsCache::setVisualDeckStorageDrawUnusedColorIdentities);
// color identity opacity selector // color identity opacity selector
@ -60,11 +60,11 @@ VisualDeckStorageQuickSettingsWidget::VisualDeckStorageQuickSettingsWidget(QWidg
unusedColorIdentitiesOpacitySpinBox->setMinimum(0); unusedColorIdentitiesOpacitySpinBox->setMinimum(0);
unusedColorIdentitiesOpacitySpinBox->setMaximum(100); unusedColorIdentitiesOpacitySpinBox->setMaximum(100);
unusedColorIdentitiesOpacitySpinBox->setValue( unusedColorIdentitiesOpacitySpinBox->setValue(
SettingsCache::instance()->getVisualDeckStorageUnusedColorIdentitiesOpacity()); SettingsCache::instance().getVisualDeckStorageUnusedColorIdentitiesOpacity());
connect(unusedColorIdentitiesOpacitySpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, connect(unusedColorIdentitiesOpacitySpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this,
&VisualDeckStorageQuickSettingsWidget::unusedColorIdentitiesOpacityChanged); &VisualDeckStorageQuickSettingsWidget::unusedColorIdentitiesOpacityChanged);
connect(unusedColorIdentitiesOpacitySpinBox, QOverload<int>::of(&QSpinBox::valueChanged), connect(unusedColorIdentitiesOpacitySpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
SettingsCache::instance().get(), &SettingsCache::setVisualDeckStorageUnusedColorIdentitiesOpacity); &SettingsCache::instance(), &SettingsCache::setVisualDeckStorageUnusedColorIdentitiesOpacity);
unusedColorIdentitiesOpacityLabel->setBuddy(unusedColorIdentitiesOpacitySpinBox); unusedColorIdentitiesOpacityLabel->setBuddy(unusedColorIdentitiesOpacitySpinBox);
@ -82,11 +82,11 @@ VisualDeckStorageQuickSettingsWidget::VisualDeckStorageQuickSettingsWidget(QWidg
deckPreviewTooltipComboBox->addItem("", TooltipType::None); deckPreviewTooltipComboBox->addItem("", TooltipType::None);
deckPreviewTooltipComboBox->addItem("", TooltipType::Filepath); deckPreviewTooltipComboBox->addItem("", TooltipType::Filepath);
deckPreviewTooltipComboBox->setCurrentIndex(SettingsCache::instance()->getVisualDeckStorageTooltipType()); deckPreviewTooltipComboBox->setCurrentIndex(SettingsCache::instance().getVisualDeckStorageTooltipType());
connect(deckPreviewTooltipComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(deckPreviewTooltipComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
[this] { emit deckPreviewTooltipChanged(getDeckPreviewTooltip()); }); [this] { emit deckPreviewTooltipChanged(getDeckPreviewTooltip()); });
connect(deckPreviewTooltipComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(deckPreviewTooltipComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), &SettingsCache::instance(),
SettingsCache::instance().get(), &SettingsCache::setVisualDeckStorageTooltipType); &SettingsCache::setVisualDeckStorageTooltipType);
auto deckPreviewTooltipLayout = new QHBoxLayout(deckPreviewTooltipWidget); auto deckPreviewTooltipLayout = new QHBoxLayout(deckPreviewTooltipWidget);
deckPreviewTooltipLayout->setContentsMargins(11, 0, 11, 0); deckPreviewTooltipLayout->setContentsMargins(11, 0, 11, 0);
@ -94,10 +94,10 @@ VisualDeckStorageQuickSettingsWidget::VisualDeckStorageQuickSettingsWidget(QWidg
deckPreviewTooltipLayout->addWidget(deckPreviewTooltipComboBox); deckPreviewTooltipLayout->addWidget(deckPreviewTooltipComboBox);
// card size slider // card size slider
cardSizeWidget = new CardSizeWidget(this, nullptr, SettingsCache::instance()->getVisualDeckStorageCardSize()); cardSizeWidget = new CardSizeWidget(this, nullptr, SettingsCache::instance().getVisualDeckStorageCardSize());
connect(cardSizeWidget->getSlider(), &QSlider::valueChanged, this, connect(cardSizeWidget->getSlider(), &QSlider::valueChanged, this,
&VisualDeckStorageQuickSettingsWidget::cardSizeChanged); &VisualDeckStorageQuickSettingsWidget::cardSizeChanged);
connect(cardSizeWidget, &CardSizeWidget::cardSizeSettingUpdated, SettingsCache::instance().get(), connect(cardSizeWidget, &CardSizeWidget::cardSizeSettingUpdated, &SettingsCache::instance(),
&SettingsCache::setVisualDeckStorageCardSize); &SettingsCache::setVisualDeckStorageCardSize);
// putting everything together // putting everything together
@ -110,7 +110,7 @@ VisualDeckStorageQuickSettingsWidget::VisualDeckStorageQuickSettingsWidget(QWidg
this->addSettingsWidget(deckPreviewTooltipWidget); this->addSettingsWidget(deckPreviewTooltipWidget);
this->addSettingsWidget(cardSizeWidget); this->addSettingsWidget(cardSizeWidget);
connect(SettingsCache::instance().get(), &SettingsCache::langChanged, this, connect(&SettingsCache::instance(), &SettingsCache::langChanged, this,
&VisualDeckStorageQuickSettingsWidget::retranslateUi); &VisualDeckStorageQuickSettingsWidget::retranslateUi);
retranslateUi(); retranslateUi();
} }

Some files were not shown because too many files have changed in this diff Show more