diff --git a/src/handlers/xdgurl.cpp b/src/handlers/xdgurl.cpp index 8f1530b6861146f54d5d643e934b5208aa5576ae..fd11345d5e27e47057af6b7d1c02b27d581a9d2a 100644 --- a/src/handlers/xdgurl.cpp +++ b/src/handlers/xdgurl.cpp @@ -6,21 +6,21 @@ #include <QNetworkReply> #include <QDesktopServices> -#include "../core/config.h" -#include "../core/network.h" -#include "../utility/file.h" -#include "../utility/package.h" +#include "../utils/config.h" +#include "../utils/network.h" +#include "../utils/file.h" +#include "../utils/package.h" namespace handlers { -XdgUrl::XdgUrl(const QString &xdgUrl, core::Config *config, core::Network *network, QObject *parent) : +XdgUrl::XdgUrl(const QString &xdgUrl, utils::Config *config, utils::Network *network, QObject *parent) : QObject(parent), xdgUrl_(xdgUrl), config_(config), network_(network) { parse(); loadDestinations(); - connect(network_, &core::Network::finished, this, &XdgUrl::downloaded); - connect(network_, &core::Network::downloadProgress, this, &XdgUrl::downloadProgress); + connect(network_, &utils::Network::finished, this, &XdgUrl::downloaded); + connect(network_, &utils::Network::downloadProgress, this, &XdgUrl::downloadProgress); } void XdgUrl::process() @@ -170,13 +170,13 @@ QString XdgUrl::convertPathString(const QString &path) QString newPath = path; if (newPath.contains("$HOME")) { - newPath.replace("$HOME", utility::File::homePath()); + newPath.replace("$HOME", utils::File::homePath()); } else if (newPath.contains("$XDG_DATA_HOME")) { - newPath.replace("$XDG_DATA_HOME", utility::File::xdgDataHomePath()); + newPath.replace("$XDG_DATA_HOME", utils::File::xdgDataHomePath()); } else if (newPath.contains("$KDEHOME")) { - newPath.replace("$KDEHOME", utility::File::kdehomePath()); + newPath.replace("$KDEHOME", utils::File::kdehomePath()); } return newPath; @@ -199,8 +199,8 @@ void XdgUrl::saveDownloadedFile(QNetworkReply *reply) QString destination = destinations_[type].toString(); QString path = destination + "/" + metadata_["filename"].toString(); - utility::File::makeDir(destination); - utility::File::remove(path); // Remove previous downloaded file + utils::File::makeDir(destination); + utils::File::remove(path); // Remove previous downloaded file if (!temporaryFile.copy(path)) { result["status"] = QString("error_save"); @@ -233,38 +233,38 @@ void XdgUrl::installDownloadedFile(QNetworkReply *reply) QString destination = destinations_[type].toString(); QString path = destination + "/" + metadata_["filename"].toString(); - utility::File::makeDir(destination); - utility::File::remove(path); // Remove previous downloaded file + utils::File::makeDir(destination); + utils::File::remove(path); // Remove previous downloaded file if (type == "bin" - && utility::Package::installProgram(temporaryFile.fileName(), path)) { + && utils::Package::installProgram(temporaryFile.fileName(), path)) { result["message"] = QString("The program has been installed into " + destination); } else if ((type == "plasma_plasmoids" || type == "plasma4_plasmoids" || type == "plasma5_plasmoids") - && utility::Package::installPlasmapkg(temporaryFile.fileName(), "plasmoid")) { + && utils::Package::installPlasmapkg(temporaryFile.fileName(), "plasmoid")) { result["message"] = QString("The plasmoid has been installed"); } else if ((type == "plasma_look_and_feel" || type == "plasma5_look_and_feel") - && utility::Package::installPlasmapkg(temporaryFile.fileName(), "lookandfeel")) { + && utils::Package::installPlasmapkg(temporaryFile.fileName(), "lookandfeel")) { result["message"] = QString("The plasma look and feel has been installed"); } else if ((type == "plasma_desktopthemes" || type == "plasma5_desktopthemes") - && utility::Package::installPlasmapkg(temporaryFile.fileName(), "theme")) { + && utils::Package::installPlasmapkg(temporaryFile.fileName(), "theme")) { result["message"] = QString("The plasma desktop theme has been installed"); } else if (type == "kwin_effects" - && utility::Package::installPlasmapkg(temporaryFile.fileName(), "kwineffect")) { + && utils::Package::installPlasmapkg(temporaryFile.fileName(), "kwineffect")) { result["message"] = QString("The KWin effect has been installed"); } else if (type == "kwin_scripts" - && utility::Package::installPlasmapkg(temporaryFile.fileName(), "kwinscript")) { + && utils::Package::installPlasmapkg(temporaryFile.fileName(), "kwinscript")) { result["message"] = QString("The KWin script has been installed"); } else if (type == "kwin_tabbox" - && utility::Package::installPlasmapkg(temporaryFile.fileName(), "windowswitcher")) { + && utils::Package::installPlasmapkg(temporaryFile.fileName(), "windowswitcher")) { result["message"] = QString("The KWin window switcher has been installed"); } - else if (utility::Package::uncompressArchive(temporaryFile.fileName(), destination)) { + else if (utils::Package::uncompressArchive(temporaryFile.fileName(), destination)) { result["message"] = QString("The archive file has been uncompressed into " + destination); } else if (temporaryFile.copy(path)) { diff --git a/src/handlers/xdgurl.h b/src/handlers/xdgurl.h index d4c0a52236c87a39ceea2f8c5c92fd825f22b7a1..d559961c1a29823ae7d374564beaddc22a1736b3 100644 --- a/src/handlers/xdgurl.h +++ b/src/handlers/xdgurl.h @@ -6,7 +6,7 @@ class QNetworkReply; -namespace core { +namespace utils { class Config; class Network; } @@ -18,7 +18,7 @@ class XdgUrl : public QObject Q_OBJECT public: - explicit XdgUrl(const QString &xdgUrl, core::Config *config, core::Network *network, QObject *parent = 0); + explicit XdgUrl(const QString &xdgUrl, utils::Config *config, utils::Network *network, QObject *parent = 0); signals: void started(); @@ -44,8 +44,8 @@ private: void installDownloadedFile(QNetworkReply *reply); QString xdgUrl_; - core::Config *config_; - core::Network *network_; + utils::Config *config_; + utils::Network *network_; QJsonObject metadata_; QJsonObject destinations_; diff --git a/src/main.cpp b/src/main.cpp index 6380ee48da9408a465e233411610381fb8ad3896..2d135434bb8cd706238fd4a264fc2c34f939da0b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,8 +10,8 @@ #include <QQmlApplicationEngine> #include <QQmlContext> -#include "core/config.h" -#include "core/network.h" +#include "utils/config.h" +#include "utils/network.h" #include "handlers/xdgurl.h" int main(int argc, char *argv[]) @@ -21,8 +21,8 @@ int main(int argc, char *argv[]) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif QGuiApplication app(argc, argv); - core::Config *config = new core::Config(":/configs"); - core::Network *network = new core::Network(true); + utils::Config *config = new utils::Config(":/configs"); + utils::Network *network = new utils::Network(true); QJsonObject configApplication = config->get("application"); diff --git a/src/core/config.cpp b/src/utils/config.cpp similarity index 62% rename from src/core/config.cpp rename to src/utils/config.cpp index f844df58cda51cdb2c39acf06f07da964636ae39..6da4adac24b470196ec6e97ec1452565f3638f89 100644 --- a/src/core/config.cpp +++ b/src/utils/config.cpp @@ -1,9 +1,9 @@ #include "config.h" -#include "../utility/file.h" -#include "../utility/json.h" +#include "file.h" +#include "json.h" -namespace core { +namespace utils { Config::Config(const QString &configsDir, QObject *parent) : QObject(parent), configsDir_(configsDir) @@ -14,11 +14,11 @@ QJsonObject Config::get(const QString &name) QString configFile = configsDir_ + "/" + name + ".json"; if (!cacheData_.contains(name)) { - QString json = utility::File::readText(configFile); + QString json = utils::File::readText(configFile); if (json.isEmpty()) { json = "{}"; // Blank JSON data as default } - cacheData_[name] = utility::Json::convertStrToObj(json); + cacheData_[name] = utils::Json::convertStrToObj(json); } return cacheData_[name].toObject(); } @@ -26,14 +26,14 @@ QJsonObject Config::get(const QString &name) bool Config::set(const QString &name, const QJsonObject &jsonObj) { QString configFile = configsDir_ + "/" + name + ".json"; - QString json = utility::Json::convertObjToStr(jsonObj); + QString json = utils::Json::convertObjToStr(jsonObj); - utility::File::makeDir(configsDir_); - if (utility::File::writeText(configFile, json)) { + utils::File::makeDir(configsDir_); + if (utils::File::writeText(configFile, json)) { cacheData_[name] = jsonObj; return true; } return false; } -} // namespace core +} // namespace utils diff --git a/src/core/config.h b/src/utils/config.h similarity index 75% rename from src/core/config.h rename to src/utils/config.h index eb65732a45f7365859495f279bff9bdafa3d1853..02a3f67016c68457ee1824d87d02100f45f2f937 100644 --- a/src/core/config.h +++ b/src/utils/config.h @@ -1,10 +1,10 @@ -#ifndef CORE_CONFIG_H -#define CORE_CONFIG_H +#ifndef UTILS_CONFIG_H +#define UTILS_CONFIG_H #include <QObject> #include <QJsonObject> -namespace core { +namespace utils { class Config : public QObject { @@ -21,6 +21,6 @@ private: QJsonObject cacheData_; }; -} // namespace core +} // namespace utils -#endif // CORE_CONFIG_H +#endif // UTILS_CONFIG_H diff --git a/src/utility/file.cpp b/src/utils/file.cpp similarity index 99% rename from src/utility/file.cpp rename to src/utils/file.cpp index 42a6385efe59ca08156010335372157b81aecbda..054826924eacf274a71a17c821a9602984ed66bc 100644 --- a/src/utility/file.cpp +++ b/src/utils/file.cpp @@ -6,7 +6,7 @@ #include <QFileInfo> #include <QTextStream> -namespace utility { +namespace utils { /** * XDG Base Directory Specification @@ -203,4 +203,4 @@ bool File::remove(const QString &path) return false; } -} // namespace utility +} // namespace utils diff --git a/src/utility/file.h b/src/utils/file.h similarity index 89% rename from src/utility/file.h rename to src/utils/file.h index bee2341195e4db79103139107e9d6050308198a3..6fbfa915698112b9c67095b620527fbb5d9d6312 100644 --- a/src/utility/file.h +++ b/src/utils/file.h @@ -1,12 +1,12 @@ -#ifndef UTILITY_FILE_H -#define UTILITY_FILE_H +#ifndef UTILS_FILE_H +#define UTILS_FILE_H #include <QObject> class QFileInfo; typedef QList<QFileInfo> QFileInfoList; -namespace utility { +namespace utils { class File : public QObject { @@ -33,6 +33,6 @@ public: static bool remove(const QString &path); }; -} // namespace utility +} // namespace utils -#endif // UTILITY_FILE_H +#endif // UTILS_FILE_H diff --git a/src/utility/json.cpp b/src/utils/json.cpp similarity index 95% rename from src/utility/json.cpp rename to src/utils/json.cpp index b63d6ff1ce22f99209377fb97a784f7319f917ed..027405b39a49492b8f86943491f797aa9fb0105f 100644 --- a/src/utility/json.cpp +++ b/src/utils/json.cpp @@ -4,7 +4,7 @@ #include <QJsonObject> #include <QJsonParseError> -namespace utility { +namespace utils { Json::Json(QObject *parent) : QObject(parent) {} @@ -36,4 +36,4 @@ bool Json::isValid(const QString &json) return false; } -} // namespace utility +} // namespace utils diff --git a/src/utility/json.h b/src/utils/json.h similarity index 71% rename from src/utility/json.h rename to src/utils/json.h index 0d07c969dde6b9e533f2e16e4b4e9ed496ef319e..d78c6b5cbde92a2f63805d012e1311e9a5a9a876 100644 --- a/src/utility/json.h +++ b/src/utils/json.h @@ -1,9 +1,9 @@ -#ifndef UTILITY_JSON_H -#define UTILITY_JSON_H +#ifndef UTILS_JSON_H +#define UTILS_JSON_H #include <QObject> -namespace utility { +namespace utils { class Json : public QObject { @@ -17,6 +17,6 @@ public: static bool isValid(const QString &json); }; -} // namespace utility +} // namespace utils -#endif // UTILITY_JSON_H +#endif // UTILS_JSON_H diff --git a/src/core/network.cpp b/src/utils/network.cpp similarity index 96% rename from src/core/network.cpp rename to src/utils/network.cpp index 4c65f3b3f0d8958c520d371e9e9f967edfa43b81..3c4fc9694d8da2af61552615c83b49dfe54d566c 100644 --- a/src/core/network.cpp +++ b/src/utils/network.cpp @@ -5,7 +5,7 @@ #include <QNetworkRequest> #include <QNetworkReply> -namespace core { +namespace utils { Network::Network(const bool &async, QObject *parent) : QObject(parent), async_(async) @@ -45,4 +45,4 @@ QNetworkReply *Network::get(const QUrl &uri) return reply; } -} // namespace core +} // namespace utils diff --git a/src/core/network.h b/src/utils/network.h similarity index 82% rename from src/core/network.h rename to src/utils/network.h index 4ebe28233cf3edc63ab25aa678207838d291ded9..a8cf8128af758362d83ce36dd856d415c878fe87 100644 --- a/src/core/network.h +++ b/src/utils/network.h @@ -1,5 +1,5 @@ -#ifndef CORE_NETWORK_H -#define CORE_NETWORK_H +#ifndef UTILS_NETWORK_H +#define UTILS_NETWORK_H #include <QObject> @@ -7,7 +7,7 @@ class QEventLoop; class QNetworkAccessManager; class QNetworkReply; -namespace core { +namespace utils { class Network : public QObject { @@ -30,6 +30,6 @@ private: QEventLoop *eventLoop_; }; -} // namespace core +} // namespace utils -#endif // CORE_NETWORK_H +#endif // UTILS_NETWORK_H diff --git a/src/utility/package.cpp b/src/utils/package.cpp similarity index 98% rename from src/utility/package.cpp rename to src/utils/package.cpp index cec1fd158ec7c6b0adfd1dd55c1e14ce6dbb0aeb..2edfba7a0a155dd3c23f0ab58165309a25625a8b 100644 --- a/src/utility/package.cpp +++ b/src/utils/package.cpp @@ -4,7 +4,7 @@ #include <QMimeDatabase> #include <QProcess> -namespace utility { +namespace utils { Package::Package(QObject *parent) : QObject(parent) {} @@ -106,4 +106,4 @@ bool Package::execute(const QString &program, const QStringList &arguments) return false; } -} // namespace utility +} // namespace utils diff --git a/src/utility/package.h b/src/utils/package.h similarity index 83% rename from src/utility/package.h rename to src/utils/package.h index 20bb7597a9c0e3a09873d30dee8b015305428bde..2fe8cfb67195b58b1893faea222784218ef18a1d 100644 --- a/src/utility/package.h +++ b/src/utils/package.h @@ -1,9 +1,9 @@ -#ifndef UTILITY_PACKAGE_H -#define UTILITY_PACKAGE_H +#ifndef UTILS_PACKAGE_H +#define UTILS_PACKAGE_H #include <QObject> -namespace utility { +namespace utils { class Package : public QObject { @@ -22,6 +22,6 @@ private: static bool execute(const QString &program, const QStringList &arguments); }; -} // namespace utility +} // namespace utils -#endif // UTILITY_PACKAGE_H +#endif // UTILS_PACKAGE_H diff --git a/xdgurl.pro b/xdgurl.pro index 829fb2a9453d56c25708e150aada2154673f25a1..2b39ba499273d29a48717b6c0f25f8b3afe3e759 100644 --- a/xdgurl.pro +++ b/xdgurl.pro @@ -16,20 +16,20 @@ CONFIG += \ SOURCES += \ src/main.cpp \ - src/core/config.cpp \ - src/core/network.cpp \ src/handlers/xdgurl.cpp \ - src/utility/file.cpp \ - src/utility/json.cpp \ - src/utility/package.cpp + src/utils/config.cpp \ + src/utils/network.cpp \ + src/utils/file.cpp \ + src/utils/json.cpp \ + src/utils/package.cpp HEADERS += \ - src/core/config.h \ - src/core/network.h \ src/handlers/xdgurl.h \ - src/utility/file.h \ - src/utility/json.h \ - src/utility/package.h + src/utils/config.h \ + src/utils/network.h \ + src/utils/file.h \ + src/utils/json.h \ + src/utils/package.h RESOURCES += \ src/configs/configs.qrc \