From 9d9ec41736df729d6341d46e7492f4da023c2d00 Mon Sep 17 00:00:00 2001 From: Felix Kauselmann <2039670+selmf@users.noreply.github.com> Date: Mon, 21 Dec 2015 14:06:28 +0100 Subject: [PATCH] Add functions to manage a openRecent list to the configuration management code --- YACReader/configuration.cpp | 13 ++++++++++++- YACReader/configuration.h | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/YACReader/configuration.cpp b/YACReader/configuration.cpp index 1de2e1f0..be66f94a 100644 --- a/YACReader/configuration.cpp +++ b/YACReader/configuration.cpp @@ -57,4 +57,15 @@ void Configuration::load(QSettings * settings) if(!settings->contains(ADJUST_TO_FULL_SIZE)) settings->setValue(ADJUST_TO_FULL_SIZE,false); */ - } \ No newline at end of file + } +void Configuration::updateOpenRecentList (QString path) +{ + QStringList list = openRecentList(); + list.removeAll(path); + list.prepend(path); + while (list.length() > 5) + { + list.removeLast(); + } + settings->setValue("recentFiles", list); +} \ No newline at end of file diff --git a/YACReader/configuration.h b/YACReader/configuration.h index bc3a4be0..57440996 100644 --- a/YACReader/configuration.h +++ b/YACReader/configuration.h @@ -65,6 +65,10 @@ using namespace YACReader; YACReader::FitMode getFitMode() { return static_cast(settings->value(FITMODE, YACReader::FitMode::FullPage).toInt()); } void setFitMode ( YACReader::FitMode fitMode ){ settings->setValue(FITMODE, static_cast(fitMode)); } + //openRecent + QStringList openRecentList() { return settings->value("recentFiles").toStringList(); } + void updateOpenRecentList (QString path); + //Old fitmodes /* bool getAdjustToWidth() {return settings->value(FIT).toBool();}