From 1e43c29484ed51a61931d6d9f1c6ce5d8bd9e52f Mon Sep 17 00:00:00 2001 From: Camila San Date: Sun, 27 Oct 2019 16:51:07 +0100 Subject: [PATCH] Add new qml tray icon. This is a work in progress. Signed-off-by: Camila San --- client.qrc | 4 ++++ src/gui/owncloudgui.cpp | 15 +++++++++++++++ src/gui/systemtray.qml | 20 ++++++++++++++++++++ src/gui/traywindow.qml | 5 +++-- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 src/gui/systemtray.qml diff --git a/client.qrc b/client.qrc index f9952965a..a5494f542 100644 --- a/client.qrc +++ b/client.qrc @@ -31,4 +31,8 @@ resources/state-info.svg + + src/gui/systemtray.qml + src/gui/traywindow.qml + diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index d3828aed6..c18705fb8 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -55,6 +55,12 @@ #include #include +#include +#include +#include +#include +#include + namespace OCC { const char propertyAccountC[] = "oc_account"; @@ -88,6 +94,15 @@ ownCloudGui::ownCloudGui(Application *parent) _tray->show(); + // QML System tray + QQmlEngine *engine = new QQmlEngine; + //engine.load(QUrl(QStringLiteral(":/qml/src/gui/systemtray.qml"))); + QQmlComponent systrayrtest(engine, QUrl(QStringLiteral("qrc:/qml/src/gui/systemtray.qml"))); + QQmlContext *ctxt = engine->contextForObject(systrayrtest.create()); + // TODO hack to pass the icon to QML + //ctxt->setContextProperty("theme", QLatin1String("colored")); + //ctxt->setContextProperty("filename", "state-offline"); + ProgressDispatcher *pd = ProgressDispatcher::instance(); connect(pd, &ProgressDispatcher::progressInfo, this, &ownCloudGui::slotUpdateProgress); diff --git a/src/gui/systemtray.qml b/src/gui/systemtray.qml new file mode 100644 index 000000000..c1398bebf --- /dev/null +++ b/src/gui/systemtray.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 +import Qt.labs.platform 1.1 + +SystemTrayIcon { + visible: true + //icon.source: "qrc:/client/theme/colored/state-offiline-32.png" + icon.source: "qrc:/client/theme/colored/state-sync-32.png"; + + Component.onCompleted: { + showMessage("Desktop Client 2.7", "New QML menu!", 1000) + } + + onActivated: { + var component = Qt.createComponent("qrc:/qml/src/gui/traywindow.qml") + win = component.createObject() + win.show() + win.raise() + win.requestActivate() + } +} diff --git a/src/gui/traywindow.qml b/src/gui/traywindow.qml index d6bb09015..c40aa5273 100644 --- a/src/gui/traywindow.qml +++ b/src/gui/traywindow.qml @@ -12,8 +12,9 @@ Window { flags: Qt.FramelessWindowHint Component.onCompleted: { - setX((Screen.width - width) - 18); - setY(Screen.height - (height + 60)); + // desktopAvailableWidth and Height doesn't include the system tray bar + setX(Screen.desktopAvailableWidth - width); + setY(Screen.desktopAvailableHeight + height); } Rectangle {