Skip to content
Snippets Groups Projects
Commit 04f5a379 authored by akiraohgaki's avatar akiraohgaki
Browse files

Import and parse destinations config

parent d55cdd5e
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@ XdgUrl::XdgUrl(const QString &xdgUrl, Core::Config *appConfig, Core::Config *use
QObject(parent), _xdgUrl(xdgUrl), _appConfig(appConfig), _userConfig(userConfig), _asyncNetwork(asyncNetwork)
{
_meta = _parse();
_destinations = _importDestinations();
}
QJsonObject XdgUrl::_parse()
......@@ -56,6 +57,35 @@ QJsonObject XdgUrl::_parse()
return meta;
}
QJsonObject XdgUrl::_importDestinations()
{
QJsonObject destinations;
QJsonObject appConfigDestinations = _appConfig->get("destinations");
QJsonObject appConfigDestinationsAlias = _appConfig->get("destinations_alias");
foreach (const QString key, appConfigDestinations.keys()) {
QString value = appConfigDestinations[key].toString();
if (value.startsWith("$HOME")) {
destinations[key] = value.replace("$HOME", Utility::File::homePath());
}
else if (value.startsWith("$XDG_DATA")) {
destinations[key] = value.replace("$XDG_DATA", Utility::File::xdgDataHomePath());
}
else if (value.startsWith("$KDE_DATA")) {
destinations[key] = value.replace("$KDE_DATA", Utility::File::kdeDataHomePath());
}
}
foreach (const QString key, appConfigDestinationsAlias.keys()) {
QString value = appConfigDestinationsAlias[key].toString();
if (destinations.contains(value)) {
destinations[key] = destinations.value(value);
}
}
return destinations;
}
bool XdgUrl::_installPlasmapkg(const QString &path, const QString &type)
{
return true;
......
......@@ -32,6 +32,7 @@ public:
private:
QJsonObject _parse();
QJsonObject _importDestinations();
bool _installPlasmapkg(const QString &path, const QString &type = "plasmoid");
bool _uncompressArchive(const QString &path, const QString &targetDir);
bool _download();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment