diff --git a/app/src/handlers/systemhandler.cpp b/app/src/handlers/systemhandler.cpp
index a719dac8e7d019ec79b3f0eeaf7c925acc23f07e..7d39f682f7d0a12cc3f731c24aededd0704db15c 100644
--- a/app/src/handlers/systemhandler.cpp
+++ b/app/src/handlers/systemhandler.cpp
@@ -64,8 +64,8 @@ bool SystemHandler::openUrl(const QString &url) const
QString SystemHandler::desktopEnvironment() const
{
- QString desktop = "";
- QString currentDesktop = "";
+ QString desktop;
+ QString currentDesktop;
if (!qgetenv("XDG_CURRENT_DESKTOP").isEmpty()) {
currentDesktop = QString::fromLocal8Bit(qgetenv("XDG_CURRENT_DESKTOP").constData()).toLower();
@@ -168,10 +168,21 @@ bool SystemHandler::applyFile(const QString &path, const QString &installType) c
#endif
#ifdef QTLIB_UNIX
-bool SystemHandler::applyKdeWallpaper(const QString &path) const
+bool SystemHandler::evaluateScriptWithPlasmaShell(const QString &script) const
{
auto message = QDBusMessage::createMethodCall("org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell", "evaluateScript");
+ message.setArguments(QVariantList() << QVariant(script));
+ auto reply = QDBusConnection::sessionBus().call(message);
+
+ if (reply.type() == QDBusMessage::ErrorMessage) {
+ qWarning() << reply.errorMessage();
+ return false;
+ }
+ return true;
+}
+bool SystemHandler::applyKdeWallpaper(const QString &path) const
+{
QString script;
QTextStream out(&script);
out << "for (var key in desktops()) {"
@@ -181,24 +192,12 @@ bool SystemHandler::applyKdeWallpaper(const QString &path) const
<< "d.writeConfig('Image', 'file://" + path + "');"
<< "}";
- QVariantList arguments;
- arguments << QVariant(script);
- message.setArguments(arguments);
-
- auto reply = QDBusConnection::sessionBus().call(message);
-
- if (reply.type() == QDBusMessage::ErrorMessage) {
- qWarning() << reply.errorMessage();
- return false;
- }
-
- return true;
+ return evaluateScriptWithPlasmaShell(script);
}
bool SystemHandler::applyKdeIcon(const QString &path) const
{
auto themeName = QFileInfo(path).fileName();
- auto message = QDBusMessage::createMethodCall("org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell", "evaluateScript");
QString script;
QTextStream out(&script);
@@ -206,27 +205,17 @@ bool SystemHandler::applyKdeIcon(const QString &path) const
<< "c.group = 'Icons';"
<< "c.writeEntry('Theme', '" + themeName + "');";
- QVariantList arguments;
- arguments << QVariant(script);
- message.setArguments(arguments);
-
- auto reply = QDBusConnection::sessionBus().call(message);
-
- if (reply.type() == QDBusMessage::ErrorMessage) {
- qWarning() << reply.errorMessage();
- return false;
+ if (evaluateScriptWithPlasmaShell(script)) {
+ QProcess::startDetached("kquitapp5 plasmashell");
+ QProcess::startDetached("kstart5 plasmashell");
+ return true;
}
-
- QProcess::startDetached("kquitapp5 plasmashell");
- QProcess::startDetached("kstart5 plasmashell");
-
- return true;
+ return false;
}
bool SystemHandler::applyKdeCursor(const QString &path) const
{
auto themeName = QFileInfo(path).fileName();
- auto message = QDBusMessage::createMethodCall("org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell", "evaluateScript");
QString script;
QTextStream out(&script);
@@ -234,24 +223,12 @@ bool SystemHandler::applyKdeCursor(const QString &path) const
<< "c.group = 'Mouse';"
<< "c.writeEntry('cursorTheme', '" + themeName + "');";
- QVariantList arguments;
- arguments << QVariant(script);
- message.setArguments(arguments);
-
- auto reply = QDBusConnection::sessionBus().call(message);
-
- if (reply.type() == QDBusMessage::ErrorMessage) {
- qWarning() << reply.errorMessage();
- return false;
- }
-
- return true;
+ return evaluateScriptWithPlasmaShell(script);
}
bool SystemHandler::applyKdePlasmaDesktoptheme(const QString &path) const
{
auto themeName = QFileInfo(path).fileName();
- auto message = QDBusMessage::createMethodCall("org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell", "evaluateScript");
QString script;
QTextStream out(&script);
@@ -259,27 +236,17 @@ bool SystemHandler::applyKdePlasmaDesktoptheme(const QString &path) const
<< "c.group = 'Theme';"
<< "c.writeEntry('name', '" + themeName + "');";
- QVariantList arguments;
- arguments << QVariant(script);
- message.setArguments(arguments);
-
- auto reply = QDBusConnection::sessionBus().call(message);
-
- if (reply.type() == QDBusMessage::ErrorMessage) {
- qWarning() << reply.errorMessage();
- return false;
+ if (evaluateScriptWithPlasmaShell(script)) {
+ QProcess::startDetached("kquitapp5 plasmashell");
+ QProcess::startDetached("kstart5 plasmashell");
+ return true;
}
-
- QProcess::startDetached("kquitapp5 plasmashell");
- QProcess::startDetached("kstart5 plasmashell");
-
- return true;
+ return false;
}
bool SystemHandler::applyKdeAuroraeTheme(const QString &path) const
{
auto themeName = QFileInfo(path).fileName();
- auto message = QDBusMessage::createMethodCall("org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell", "evaluateScript");
QString script;
QTextStream out(&script);
@@ -288,21 +255,12 @@ bool SystemHandler::applyKdeAuroraeTheme(const QString &path) const
<< "c.writeEntry('library', 'org.kde.kwin.aurorae');"
<< "c.writeEntry('theme', '__aurorae__svg__" + themeName + "');";
- QVariantList arguments;
- arguments << QVariant(script);
- message.setArguments(arguments);
-
- auto reply = QDBusConnection::sessionBus().call(message);
-
- if (reply.type() == QDBusMessage::ErrorMessage) {
- qWarning() << reply.errorMessage();
- return false;
+ if (evaluateScriptWithPlasmaShell(script)) {
+ auto refreshMessage = QDBusMessage::createMethodCall("org.kde.KWin", "/KWin", "org.kde.KWin", "reconfigure");
+ QDBusConnection::sessionBus().call(refreshMessage);
+ return true;
}
-
- auto refreshMessage = QDBusMessage::createMethodCall("org.kde.KWin", "/KWin", "org.kde.KWin", "reconfigure");
- QDBusConnection::sessionBus().call(refreshMessage);
-
- return true;
+ return false;
}
bool SystemHandler::applyGnomeWallpaper(const QString &path) const
diff --git a/app/src/handlers/systemhandler.h b/app/src/handlers/systemhandler.h
index f9bd1ee4082652a9bb0c6b5c6941f026ae2b006d..06cd247a85ddef772a5752a2afe21779ff7d4828 100644
--- a/app/src/handlers/systemhandler.h
+++ b/app/src/handlers/systemhandler.h
@@ -23,6 +23,7 @@ public slots:
private:
#ifdef QTLIB_UNIX
+ bool evaluateScriptWithPlasmaShell(const QString &script) const;
bool applyKdeWallpaper(const QString &path) const;
bool applyKdeIcon(const QString &path) const;
bool applyKdeCursor(const QString &path) const;
diff --git a/app/src/websockets/websocketserver.cpp b/app/src/websockets/websocketserver.cpp
index 8eb69e9cc8b80a2ae88e2ce8b0fad6676afb012d..59f8f78005f3951dc477efeb2c1ab091ed7fd18f 100644
--- a/app/src/websockets/websocketserver.cpp
+++ b/app/src/websockets/websocketserver.cpp
@@ -15,6 +15,7 @@ WebSocketServer::WebSocketServer(ConfigHandler *configHandler, const QString &se
: QObject(parent), configHandler_(configHandler), serverName_(serverName), serverPort_(serverPort)
{
wsServer_ = new QWebSocketServer(serverName_, QWebSocketServer::NonSecureMode, this);
+
connect(wsServer_, &QWebSocketServer::newConnection, this, &WebSocketServer::wsNewConnection);
connect(wsServer_, &QWebSocketServer::closed, this, &WebSocketServer::stopped);
@@ -22,6 +23,7 @@ WebSocketServer::WebSocketServer(ConfigHandler *configHandler, const QString &se
systemHandler_ = new SystemHandler(this);
ocsApiHandler_ = new OcsApiHandler(configHandler_, this);
itemHandler_ = new ItemHandler(configHandler_, this);
+
connect(itemHandler_, &ItemHandler::metadataSetChanged, this, &WebSocketServer::itemMetadataSetChanged);
connect(itemHandler_, &ItemHandler::downloadStarted, this, &WebSocketServer::itemDownloadStarted);
connect(itemHandler_, &ItemHandler::downloadFinished, this, &WebSocketServer::itemDownloadFinished);
@@ -75,9 +77,11 @@ QUrl WebSocketServer::serverUrl() const
void WebSocketServer::wsNewConnection()
{
auto *wsClient = wsServer_->nextPendingConnection();
+
connect(wsClient, &QWebSocket::disconnected, this, &WebSocketServer::wsDisconnected);
connect(wsClient, &QWebSocket::textMessageReceived, this, &WebSocketServer::wsTextMessageReceived);
connect(wsClient, &QWebSocket::binaryMessageReceived, this, &WebSocketServer::wsBinaryMessageReceived);
+
wsClients_ << wsClient;
}