diff --git a/src/handlers/xdgurl.cpp b/src/handlers/xdgurl.cpp index d4e352ffc379c78b538b2116fc21ba0e6a93ccda..7b5abcc1bfc2d6fb066056142aa4dfbcc2c8b5f9 100644 --- a/src/handlers/xdgurl.cpp +++ b/src/handlers/xdgurl.cpp @@ -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; diff --git a/src/handlers/xdgurl.h b/src/handlers/xdgurl.h index bdf637b8bf4a39c7c4ab60b0316a6e9f4f65b71a..2503b6ae878263d41644fe548816feccb177d06b 100644 --- a/src/handlers/xdgurl.h +++ b/src/handlers/xdgurl.h @@ -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();