implement inheritance keyword for .qsrun entries

This commit is contained in:
Albert S. 2020-09-06 21:37:15 +02:00
parent 45d7b930f8
commit 560e15d48d
2 changed files with 26 additions and 1 deletions

View File

@ -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<EntryConfig> EntryProvider::getSystemEntries()
{
return readConfig(this->systemEntriesDirsPaths);
}
template <class T> 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;
}

View File

@ -24,6 +24,8 @@ class EntryConfig
QIcon icon;
int row = 0;
int col = 0;
EntryConfig &update(const EntryConfig &o);
};
class EntryProvider