diff --git a/README.md b/README.md index 333c2b31d53916b03812c2fac36a66fe1020371d..cd6db47e89b0743635f5fb1051c6459dba0894d9 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,20 @@ # ocs-manager -a tool to handle filemanagement and "apply" -[](https://www.gnu.org/licenses/lgpl-3.0) +[](https://www.gnu.org/licenses/gpl-3.0) [](https://travis-ci.org/opendesktop/ocs-manager) -A management tool for ocs. +A tool to handle filemanagement and "apply". Copyright: 2017, Opendesktop.org -License: LGPL-3+ +License: GPL-3+ -## Note - ### Package depends +* libqt5gui5 * libqt5websockets5 +* libqt5dbus5 ### Package depends (build) diff --git a/app/app.pri b/app/app.pri index 737e3eba34ea71dcc522e3e8a1f466a72023b313..5495172d96673f2b36daadf58ce583280ca3cd8d 100644 --- a/app/app.pri +++ b/app/app.pri @@ -1,10 +1,9 @@ QT += \ core \ + gui \ network \ websockets -QT -= gui - HEADERS += \ $${PWD}/src/websockets/websocketserver.h \ $${PWD}/src/handlers/confighandler.h \ diff --git a/app/configs/application.json b/app/configs/application.json index b61c09fd7cd3497720ebd33e1ad0a62f45cbe240..d690c57350a886ab79c82e2112b405bad84687a8 100644 --- a/app/configs/application.json +++ b/app/configs/application.json @@ -1,12 +1,12 @@ { "id": "ocs-manager", "name": "ocs-manager", - "version": "0.0.0", + "version": "0.1.0", "organization": "Opendesktop.org", "domain": "org.opendesktop.ocs-manager", "icon": "", - "description": "A management tool for ocs.", - "license": "LGPL-3+", + "description": "A tool to handle filemanagement and apply.", + "license": "GPL-3+", "author": "Opendesktop.org", "contact": "contact@opendesktop.org", "homepage": "https://github.com/opendesktop/ocs-manager" diff --git a/app/src/handlers/systemhandler.cpp b/app/src/handlers/systemhandler.cpp index b7b95ae612ad117f55182713ee9ec9f7b9211a91..2230d8d3c6352e192f27711674b0d04bab382531 100644 --- a/app/src/handlers/systemhandler.cpp +++ b/app/src/handlers/systemhandler.cpp @@ -1,5 +1,8 @@ #include "systemhandler.h" +#include <QUrl> +#include <QDesktopServices> + #ifdef QTLIB_UNIX #include <QFileInfo> #include <QProcess> @@ -9,6 +12,10 @@ #include <QDebug> #endif +#ifdef Q_OS_ANDROID +#include "qtlib_package.h" +#endif + SystemHandler::SystemHandler(QObject *parent) : QObject(parent) {} @@ -21,6 +28,40 @@ bool SystemHandler::isUnix() return false; } +bool SystemHandler::isMobileDevice() +{ +#if defined(APP_MOBILE) + return true; +#elif defined(Q_OS_IOS) || defined(Q_OS_ANDROID) || defined(Q_OS_WINPHONE) + return true; +#elif defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM) // Ubuntu Phone, Plasma Phone + return true; +#endif + return false; +} + +bool SystemHandler::openUrl(const QString &url) +{ + QString path = url; + path.replace("file://localhost", "", Qt::CaseInsensitive); + path.replace("file://", "", Qt::CaseInsensitive); + +#ifdef QTLIB_UNIX + if ((path.endsWith(".appimage", Qt::CaseInsensitive) || path.endsWith(".exe", Qt::CaseInsensitive)) + && QFileInfo(path).isExecutable()) { + return QProcess::startDetached(path); + } +#endif + +#ifdef Q_OS_ANDROID + if (path.endsWith(".apk", Qt::CaseInsensitive)) { + return qtlib::Package(path).installAsApk(); + } +#endif + + return QDesktopServices::openUrl(QUrl(url)); +} + QString SystemHandler::desktopEnvironment() { QString desktop = "unknown"; diff --git a/app/src/handlers/systemhandler.h b/app/src/handlers/systemhandler.h index a49f9a6a6b7a1aff0ee9e9036eea2a40a8e625cd..f291c8a89551809a8c0c0ab1d573906ff62405e0 100644 --- a/app/src/handlers/systemhandler.h +++ b/app/src/handlers/systemhandler.h @@ -11,6 +11,8 @@ public: public slots: bool isUnix(); + bool isMobileDevice(); + bool openUrl(const QString &url); QString desktopEnvironment(); bool isApplicableType(const QString &installType); diff --git a/app/src/main.cpp b/app/src/main.cpp index e6c228c2964fb470b73bea8df5603877082b6eb1..15bdaf5714e60d3df7f6697d3fcc068abcebafe4 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -1,10 +1,10 @@ #include <QStringList> #include <QJsonObject> -//#include <QTranslator> -//#include <QLocale> +#include <QTranslator> +#include <QLocale> #include <QCommandLineParser> #include <QCommandLineOption> -#include <QCoreApplication> +#include <QGuiApplication> #include <QDebug> #include "handlers/confighandler.h" @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) { // Init - QCoreApplication app(argc, argv); + QGuiApplication app(argc, argv); // This is backend program, but need GUI module ConfigHandler *configHandler = new ConfigHandler(); QJsonObject appConfigApplication = configHandler->getAppConfigApplication(); @@ -24,10 +24,10 @@ int main(int argc, char *argv[]) app.setOrganizationDomain(appConfigApplication["domain"].toString()); // Setup translator - //QTranslator translator; - //if (translator.load(QLocale(), "messages", ".", ":/i18n")) { - // app.installTranslator(&translator); - //} + QTranslator translator; + if (translator.load(QLocale(), "messages", ".", ":/i18n")) { + app.installTranslator(&translator); + } // Setup CLI QCommandLineParser clParser; diff --git a/app/src/websockets/websocketserver.cpp b/app/src/websockets/websocketserver.cpp index 857c9e9e7496aee7551c855bd63aabad11c3ba5f..2ccc371c53b3ecf57162cf909239847f83a490f6 100644 --- a/app/src/websockets/websocketserver.cpp +++ b/app/src/websockets/websocketserver.cpp @@ -266,6 +266,12 @@ void WebSocketServer::receiveMessage(const QString &id, const QString &func, con else if (func == "SystemHandler::isUnix") { resultData.append(systemHandler_->isUnix()); } + else if (func == "SystemHandler::isMobileDevice") { + resultData.append(systemHandler_->isMobileDevice()); + } + else if (func == "SystemHandler::openUrl") { + resultData.append(systemHandler_->openUrl(data.at(0).toString())); + } else if (func == "SystemHandler::desktopEnvironment") { resultData.append(systemHandler_->desktopEnvironment()); } diff --git a/i18n/i18n.pri b/i18n/i18n.pri new file mode 100644 index 0000000000000000000000000000000000000000..31b3fcf015d808de7fd1fb6b0118bb263b3859bf --- /dev/null +++ b/i18n/i18n.pri @@ -0,0 +1 @@ +RESOURCES += $${PWD}/i18n.qrc diff --git a/i18n/i18n.pro b/i18n/i18n.pro new file mode 100644 index 0000000000000000000000000000000000000000..757f38e1cb06485ae4181b6dff9328f461e775a3 --- /dev/null +++ b/i18n/i18n.pro @@ -0,0 +1,7 @@ +SOURCES += $$system(find $${PWD}/../app -type f -name "*.cpp" -or -name "*.qml" -or -name "*.js") + +TRANSLATIONS += \ + $${PWD}/messages.ts \ + $${PWD}/messages.en_US.ts + +include($${PWD}/i18n.pri) diff --git a/i18n/i18n.qrc b/i18n/i18n.qrc new file mode 100644 index 0000000000000000000000000000000000000000..196056e88cd16b582c2230e134a580b74746714b --- /dev/null +++ b/i18n/i18n.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/i18n"> + <file>messages.qm</file> + <file>messages.en_US.qm</file> + </qresource> +</RCC> diff --git a/i18n/messages.en_US.qm b/i18n/messages.en_US.qm new file mode 100644 index 0000000000000000000000000000000000000000..9dad8dffceb9623e88f8b96d9cd0caf25574c6fa Binary files /dev/null and b/i18n/messages.en_US.qm differ diff --git a/i18n/messages.en_US.ts b/i18n/messages.en_US.ts new file mode 100644 index 0000000000000000000000000000000000000000..125a0d58480ca52fd6d8a215830f0ab1074f7181 --- /dev/null +++ b/i18n/messages.en_US.ts @@ -0,0 +1,112 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="en_US"> +<context> + <name>ItemHandler</name> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="55"/> + <source>The file already downloading</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="69"/> + <source>Downloading</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="119"/> + <source>Invalid OCS-URL</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="128"/> + <source>Uninstalling</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="197"/> + <source>Uninstalled</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="222"/> + <source>Downloaded</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="252"/> + <location filename="../app/src/handlers/itemhandler.cpp" line="291"/> + <source>Saving</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="264"/> + <location filename="../app/src/handlers/itemhandler.cpp" line="306"/> + <source>Failed to save data</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="271"/> + <location filename="../app/src/handlers/itemhandler.cpp" line="314"/> + <source>Saved</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="319"/> + <source>Installing</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="330"/> + <source>The file has been installed as program</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="335"/> + <source>The plasmoid has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="340"/> + <source>The plasma look and feel has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="345"/> + <source>The plasma desktop theme has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="350"/> + <source>The KWin effect has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="355"/> + <source>The KWin script has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="360"/> + <source>The KWin window switcher has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="363"/> + <source>The archive file has been extracted</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="366"/> + <location filename="../app/src/handlers/itemhandler.cpp" line="380"/> + <source>The file has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="370"/> + <location filename="../app/src/handlers/itemhandler.cpp" line="384"/> + <source>Failed to installation</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/i18n/messages.qm b/i18n/messages.qm new file mode 100644 index 0000000000000000000000000000000000000000..be651eede2edc9cb0da5c140b31664afee169fa8 --- /dev/null +++ b/i18n/messages.qm @@ -0,0 +1 @@ +<クdハ�箆!ソ`。スン \ No newline at end of file diff --git a/i18n/messages.ts b/i18n/messages.ts new file mode 100644 index 0000000000000000000000000000000000000000..017e5e88fee33017c50782e464e47ecf87025f60 --- /dev/null +++ b/i18n/messages.ts @@ -0,0 +1,112 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1"> +<context> + <name>ItemHandler</name> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="55"/> + <source>The file already downloading</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="69"/> + <source>Downloading</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="119"/> + <source>Invalid OCS-URL</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="128"/> + <source>Uninstalling</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="197"/> + <source>Uninstalled</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="222"/> + <source>Downloaded</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="252"/> + <location filename="../app/src/handlers/itemhandler.cpp" line="291"/> + <source>Saving</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="264"/> + <location filename="../app/src/handlers/itemhandler.cpp" line="306"/> + <source>Failed to save data</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="271"/> + <location filename="../app/src/handlers/itemhandler.cpp" line="314"/> + <source>Saved</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="319"/> + <source>Installing</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="330"/> + <source>The file has been installed as program</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="335"/> + <source>The plasmoid has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="340"/> + <source>The plasma look and feel has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="345"/> + <source>The plasma desktop theme has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="350"/> + <source>The KWin effect has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="355"/> + <source>The KWin script has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="360"/> + <source>The KWin window switcher has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="363"/> + <source>The archive file has been extracted</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="366"/> + <location filename="../app/src/handlers/itemhandler.cpp" line="380"/> + <source>The file has been installed</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../app/src/handlers/itemhandler.cpp" line="370"/> + <location filename="../app/src/handlers/itemhandler.cpp" line="384"/> + <source>Failed to installation</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/ocs-manager.pro b/ocs-manager.pro index f1df8facfdf0c4aa4a68db2cf30d7e1ae4d708f7..18d40c3b42b72d7ffa5a6383a0972d15984d101f 100644 --- a/ocs-manager.pro +++ b/ocs-manager.pro @@ -1,5 +1,11 @@ message("Please execute scripts/import.sh for build dependencies") +ios|android|!isEmpty(APP_MOBILE) { + DEFINES += APP_MOBILE +} else { + DEFINES += APP_DESKTOP +} + TARGET = ocs-manager TEMPLATE = app @@ -16,4 +22,5 @@ DISTFILES += $${PWD}/README.md include($${PWD}/lib/lib.pri) include($${PWD}/app/app.pri) +include($${PWD}/i18n/i18n.pri) include($${PWD}/scripts/scripts.pri)