Cockatrice/cockatrice/src/settings/recents_settings.cpp
RickyRister bb4214e28a
Make SettingsManager params const ref (#5405)
* pass settingsPath by const ref

* pass params by const ref

* cleanup
2025-01-02 00:33:37 -05:00

32 lines
No EOL
892 B
C++

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