Add new qml tray icon.

This is a work in progress.

Signed-off-by: Camila San <hello@camila.codes>
This commit is contained in:
Camila San 2019-10-27 16:51:07 +01:00
parent 5c3f71c097
commit 1e43c29484
No known key found for this signature in database
GPG key ID: 7A4A6121E88E2AD4
4 changed files with 42 additions and 2 deletions

View file

@ -31,4 +31,8 @@
<file>resources/state-info.svg</file> <file>resources/state-info.svg</file>
</qresource> </qresource>
<qresource prefix="/"/> <qresource prefix="/"/>
<qresource prefix="/qml">
<file>src/gui/systemtray.qml</file>
<file>src/gui/traywindow.qml</file>
</qresource>
</RCC> </RCC>

View file

@ -55,6 +55,12 @@
#include <QJsonObject> #include <QJsonObject>
#include <QJsonArray> #include <QJsonArray>
#include <QQmlEngine>
#include <QQmlComponent>
#include <QQmlApplicationEngine>
#include <QQuickItem>
#include <QQmlContext>
namespace OCC { namespace OCC {
const char propertyAccountC[] = "oc_account"; const char propertyAccountC[] = "oc_account";
@ -88,6 +94,15 @@ ownCloudGui::ownCloudGui(Application *parent)
_tray->show(); _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(); ProgressDispatcher *pd = ProgressDispatcher::instance();
connect(pd, &ProgressDispatcher::progressInfo, this, connect(pd, &ProgressDispatcher::progressInfo, this,
&ownCloudGui::slotUpdateProgress); &ownCloudGui::slotUpdateProgress);

20
src/gui/systemtray.qml Normal file
View file

@ -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()
}
}

View file

@ -12,8 +12,9 @@ Window {
flags: Qt.FramelessWindowHint flags: Qt.FramelessWindowHint
Component.onCompleted: { Component.onCompleted: {
setX((Screen.width - width) - 18); // desktopAvailableWidth and Height doesn't include the system tray bar
setY(Screen.height - (height + 60)); setX(Screen.desktopAvailableWidth - width);
setY(Screen.desktopAvailableHeight + height);
} }
Rectangle { Rectangle {