Tray creation timing, account menu reinstantiating on visible change
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sat, 11 Jan 2020 14:05:37 +0000 (15:05 +0100)
committerDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sat, 11 Jan 2020 14:05:37 +0000 (15:05 +0100)
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
src/gui/owncloudgui.cpp
src/gui/systray.cpp
src/gui/systray.h
src/gui/tray/Window.qml

index 96718c22946c338c0c2cda5b91c6e69b72604a38..b071e2d3e0b839c7374f6e23e26aeedffe66b338 100644 (file)
@@ -110,6 +110,8 @@ ownCloudGui::ownCloudGui(Application *parent)
         this, &ownCloudGui::slotShowOptionalTrayMessage);
     connect(Logger::instance(), &Logger::guiMessage,
         this, &ownCloudGui::slotShowGuiMessage);
+
+    _tray->create();
 }
 
 #ifdef WITH_LIBCLOUDPROVIDERS
index 93240c133d9f7f2f869046330b710fde3b22c14f..c7bbe2fe30452c1e2a58f4ed764f53793c291576 100644 (file)
@@ -50,7 +50,6 @@ Systray::Systray() // TODO: make singleton, provide ::instance()
     _trayEngine->rootContext()->setContextProperty("systrayBackend", this);
 
     _trayComponent = new QQmlComponent(_trayEngine, QUrl(QStringLiteral("qrc:/qml/src/gui/tray/Window.qml")));
-    _trayContext = _trayEngine->contextForObject(_trayComponent->create());
 
     if (!AccountManager::instance()->accounts().isEmpty()) {
         slotChangeActivityModel();
@@ -58,14 +57,20 @@ Systray::Systray() // TODO: make singleton, provide ::instance()
 
     connect(UserModel::instance(), &UserModel::newUserSelected,
         this, &Systray::slotChangeActivityModel);
-
-    hideWindow();
 }
 
 Systray::~Systray()
 {
 }
 
+void Systray::create()
+{
+    if (_trayContext == nullptr) {
+        _trayContext = _trayEngine->contextForObject(_trayComponent->create());
+        hideWindow();
+    }
+}
+
 void Systray::slotChangeActivityModel()
 {
     _trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
index 3460940a38629e352d65e1a48c0a238614d50f13..a09fc1c6cfed0ebaa293fe354dbf5e9654a325a8 100644 (file)
@@ -45,6 +45,7 @@ class Systray
 public:
     explicit Systray();
     ~Systray();
+    void create();
     void showMessage(const QString &title, const QString &message, MessageIcon icon = Information, int millisecondsTimeoutHint = 10000);
     void setToolTip(const QString &tip);
     bool isOpen();
index 9c54a46511b74cfa4f98e23a5c516a5762395691..4cea7dd6dd17497bd44af7e42b7f1928dec9a68d 100644 (file)
@@ -27,6 +27,9 @@ Window {
         currentAccountUser.text = userModelBackend.currentUserName();\r
         currentAccountServer.text = userModelBackend.currentUserServer();\r
         trayWindowTalkButton.visible = userModelBackend.currentServerHasTalk() ? true : false;\r
+\r
+        userLineInstantiator.active = false;\r
+        userLineInstantiator.active = true;\r
     }\r
 \r
     Connections {\r
@@ -116,11 +119,6 @@ Window {
                                 radius: 2\r
                             }\r
 \r
-                            onClosed: {\r
-                                userLineInstantiator.active = false;\r
-                                userLineInstantiator.active = true;\r
-                            }\r
-\r
                             Instantiator {\r
                                 id: userLineInstantiator\r
                                 model: userModelBackend\r