Skip to content
Snippets Groups Projects
Commit 50723c9a authored by akiraohgaki's avatar akiraohgaki
Browse files

System handler

parent 5d78c9d3
No related branches found
No related tags found
No related merge requests found
QT += \
core \
gui \
network \
websockets
QT -= gui
HEADERS += \
$${PWD}/src/websockets/websocketserver.h \
$${PWD}/src/handlers/confighandler.h \
......
#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";
......
......@@ -11,6 +11,8 @@ public:
public slots:
bool isUnix();
bool isMobileDevice();
bool openUrl(const QString &url);
QString desktopEnvironment();
bool isApplicableType(const QString &installType);
......
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
......
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