Cockatrice/libcockatrice_settings/libcockatrice/settings/recents_settings.cpp
BruebachL f62e29f5d5
Give settings managers default groups instead of manually specifying them everywhere. (#6273)
* Give settings managers default groups instead of manually specifying them everywhere.

Took 1 hour 2 minutes


Took 41 seconds

Took 32 seconds

Took 5 minutes

* Fix dbconverter mock.

Took 2 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2025-11-15 15:58:25 +01:00

42 lines
1.1 KiB
C++

#include "recents_settings.h"
#define MAX_RECENT_DECK_COUNT 10
RecentsSettings::RecentsSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "recents.ini", "deckbuilder", QString(), parent)
{
}
QStringList RecentsSettings::getRecentlyOpenedDeckPaths()
{
return getValue("deckpaths").toStringList();
}
void RecentsSettings::clearRecentlyOpenedDeckPaths()
{
deleteValue("deckpaths");
emit recentlyOpenedDeckPathsChanged();
}
void RecentsSettings::updateRecentlyOpenedDeckPaths(const QString &deckPath)
{
auto deckPaths = getValue("deckpaths").toStringList();
deckPaths.removeAll(deckPath);
deckPaths.prepend(deckPath);
while (deckPaths.size() > MAX_RECENT_DECK_COUNT) {
deckPaths.removeLast();
}
setValue(deckPaths, "deckpaths");
emit recentlyOpenedDeckPathsChanged();
}
QString RecentsSettings::getLatestDeckDirPath()
{
return getValue("latestDeckDir", "dirs").toString();
}
void RecentsSettings::setLatestDeckDirPath(const QString &dirPath)
{
setValue(dirPath, "latestDeckDir", "dirs");
}