From 560e15d48d8c0228bad45a3a5484cf411cded62f Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 6 Sep 2020 21:37:15 +0200 Subject: [PATCH] implement inheritance keyword for .qsrun entries --- entryprovider.cpp | 25 ++++++++++++++++++++++++- entryprovider.h | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/entryprovider.cpp b/entryprovider.cpp index 99172a4..eb77b2f 100644 --- a/entryprovider.cpp +++ b/entryprovider.cpp @@ -162,7 +162,7 @@ EntryConfig EntryProvider::readFromFile(const QString &path) inheritedConfig = readFromDesktopFile(resolveEntryPath(splitted[1])); } } - return result; + return result.update(inheritedConfig); } QString EntryProvider::resolveEntryPath(QString path) @@ -224,3 +224,26 @@ QVector EntryProvider::getSystemEntries() { return readConfig(this->systemEntriesDirsPaths); } + +template void assignIfDestDefault(T &dest, const T &source) +{ + if(dest == T()) + { + dest = source; + } +} + +EntryConfig &EntryConfig::update(const EntryConfig &o) +{ + assignIfDestDefault(this->arguments, o.arguments); + assignIfDestDefault(this->col, o.col); + assignIfDestDefault(this->command, o.command); + if(this->icon.isNull()) + { + this->icon = o.icon; + } + assignIfDestDefault(this->key, o.key); + assignIfDestDefault(this->name, o.name); + assignIfDestDefault(this->row, o.row); + return *this; +} diff --git a/entryprovider.h b/entryprovider.h index ccbb99e..a7ee8ab 100644 --- a/entryprovider.h +++ b/entryprovider.h @@ -24,6 +24,8 @@ class EntryConfig QIcon icon; int row = 0; int col = 0; + + EntryConfig &update(const EntryConfig &o); }; class EntryProvider