add "open recent" menu option to deck editor tab (#5319)

* add "open recent" menu option to deck editor tab

* change texts

* also get it to work with loading from deck storage tab

* add error message when fail to open

* only update recents on successful open

* only update recents on successful open

* reword to "Clear"
This commit is contained in:
RickyRister 2024-12-24 16:55:04 -08:00 committed by GitHub
parent e7585271fb
commit 4ca1fc083d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 130 additions and 5 deletions

View file

@ -0,0 +1,32 @@
#include "recents_settings.h"
#define MAX_RECENT_DECK_COUNT 10
RecentsSettings::RecentsSettings(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();
}