From 27ac3155d3900269d987569a7b39e02c8f045ca3 Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 13 Sep 2020 15:13:28 +0200 Subject: [PATCH] EntryConfig: Introduce (dirty) way to distinguish between user/system entries --- entryprovider.cpp | 9 +++++++-- entryprovider.h | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/entryprovider.cpp b/entryprovider.cpp index f70d8f0..8edf460 100644 --- a/entryprovider.cpp +++ b/entryprovider.cpp @@ -214,7 +214,7 @@ QString EntryProvider::resolveEntryPath(QString path) return {}; } -QVector EntryProvider::readConfig(QStringList paths) +QVector EntryProvider::readConfig(QStringList paths, bool userentrymode) { QVector result; for(QString &configPath : paths) @@ -228,6 +228,11 @@ QVector EntryProvider::readConfig(QStringList paths) { if(!entry->hidden) { + if(userentrymode) + { + entry->userEntry = true; + entry->entryPath = path; + } result.append(*entry); } } @@ -238,7 +243,7 @@ QVector EntryProvider::readConfig(QStringList paths) QVector EntryProvider::getUserEntries() { - return readConfig(this->userEntriesDirsPaths); + return readConfig(this->userEntriesDirsPaths, true); } QVector EntryProvider::getSystemEntries() diff --git a/entryprovider.h b/entryprovider.h index 4184ba4..dcd7066 100644 --- a/entryprovider.h +++ b/entryprovider.h @@ -18,7 +18,9 @@ class ConfigFormatException : public std::runtime_error class EntryConfig { public: + bool userEntry = false; bool hidden = false; + QString entryPath; QString key; QString name; QString command; @@ -39,13 +41,14 @@ class EntryProvider EntryConfig readqsrunFile(const QString &path); EntryConfig readFromDesktopFile(const QString &path); std::optional readEntryFromPath(const QString &path); - QVector readConfig(QStringList paths); + QVector readConfig(QStringList paths, bool userentrymode=false); QString resolveEntryPath(QString path); public: EntryProvider(QStringList userEntriesDirsPaths, QStringList systemEntriesDirsPaths); QVector getUserEntries(); QVector getSystemEntries(); + void saveUserEntry(const EntryConfig &config); }; #endif // ENTRYPROVIDER_H