Show activitylist on initial tray opening when logged in
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sun, 12 Jan 2020 20:19:18 +0000 (21:19 +0100)
committerDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sun, 12 Jan 2020 20:19:18 +0000 (21:19 +0100)
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
src/gui/accountsettings.cpp
src/gui/application.cpp
src/gui/owncloudgui.cpp
src/gui/owncloudgui.h
src/gui/systray.cpp
src/gui/tray/UserModel.cpp
src/gui/tray/UserModel.h
src/gui/tray/Window.qml

index 20822b0683a1468f22d51b81b45d558db434372f..1c9e3b47d6cafb2243524d6efdc4058c9e7126a6 100644 (file)
@@ -189,10 +189,6 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
     connect(_accountState, &AccountState::stateChanged, this, &AccountSettings::slotAccountStateChanged);
     slotAccountStateChanged();
 
-    if (!AccountManager::instance()->accounts().isEmpty()) {
-        Systray::instance()->slotChangeActivityModel();
-    }
-
     connect(&_quotaInfo, &QuotaInfo::quotaUpdated,
         this, &AccountSettings::slotUpdateQuota);
 
index 45b06ae403f5c4f20f83ee9984df8c3d37f28096..4cfcab31d265664ad349ac653594600488d404ac 100644 (file)
@@ -266,6 +266,8 @@ Application::Application(int &argc, char **argv)
 
     // Allow other classes to hook into isShowingSettingsDialog() signals (re-auth widgets, for example)
     connect(_gui.data(), &ownCloudGui::isShowingSettingsDialog, this, &Application::slotGuiIsShowingSettings);
+
+    _gui->createTray();
 }
 
 Application::~Application()
index 5375786fd05127bd94584f72a625934e7ef7e61b..b62122395b8968789da3931d31e45cb91b4cfb12 100644 (file)
@@ -111,6 +111,10 @@ ownCloudGui::ownCloudGui(Application *parent)
     connect(Logger::instance(), &Logger::guiMessage,
         this, &ownCloudGui::slotShowGuiMessage);
 
+}
+
+void ownCloudGui::createTray()
+{
     _tray->create();
 }
 
index 518be8b16597dbd0f0f1b13546a8acbe56e1ba04..9efd34e8b9bee5d61065660ee41bd0f50128acf0 100644 (file)
@@ -63,6 +63,7 @@ public:
     void setupCloudProviders();
     bool cloudProviderApiAvailable();
 #endif
+    void createTray();
 
 signals:
     void setupProxy();
index 52222586dd83cba9fe09a48b97f577c855741ec0..62efff23a953609bc070971350fda00d7e8dd348 100644 (file)
@@ -71,6 +71,7 @@ Systray::Systray()
 void Systray::create()
 {
     if (_trayContext == nullptr) {
+        _trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
         _trayContext = _trayEngine->contextForObject(_trayComponent->create());
         hideWindow();
     }
index 510bbcbbcfa84269a540892ed50e2adef573bb2b..aea75264ac529ac757e3b3c9810f974b125beb04 100644 (file)
@@ -275,8 +275,8 @@ Q_INVOKABLE void UserModel::switchCurrentUser(const int &id)
     _users[_currentUserId]->setCurrentUser(false);
     _users[id]->setCurrentUser(true);
     _currentUserId = id;
-    emit newUserSelected();
     emit refreshCurrentUserGui();
+    emit newUserSelected();
 }
 
 Q_INVOKABLE void UserModel::login(const int &id) {
@@ -371,6 +371,13 @@ bool UserModel::currentUserHasActivities()
     return _users[currentUserIndex()]->hasActivities();
 }
 
+void UserModel::fetchCurrentActivityModel()
+{
+    if (_users[currentUserId()]->isConnected()) {
+        _users[currentUserId()]->getActivityModel()->fetchMore(QModelIndex());
+    }
+}
+
 /*-------------------------------------------------------------------------------------*/
 
 ImageProvider::ImageProvider()
index 9f9ad55d7e3036c9d41577e204449db95b78c7d2..3775e66b2cc3794604f0f2c844204f24f0c4df1e 100644 (file)
@@ -58,6 +58,7 @@ public:
 
     QImage avatarById(const int &id);
 
+    Q_INVOKABLE void fetchCurrentActivityModel();
     Q_INVOKABLE void openCurrentAccountLocalFolder();
     Q_INVOKABLE void openCurrentAccountTalk();
     Q_INVOKABLE void openCurrentAccountServer();
index 1cc2dd542d8decfbf0a2032c800e643c0eb4fbea..169c02ac8bf027a34e245434ccaef58d2ac91d1f 100644 (file)
@@ -31,10 +31,6 @@ Window {
         currentAccountStateIndicator.source = ""\r
         currentAccountStateIndicator.source = userModelBackend.isUserConnected(userModelBackend.currentUserId()) ? "qrc:///client/theme/colored/state-ok.svg" : "qrc:///client/theme/colored/state-offline.svg"\r
 \r
-        if (userModelBackend.isUserConnected(userModelBackend.currentUserId())) {\r
-            systrayBackend.slotChangeActivityModel()\r
-        }\r
-\r
         userLineInstantiator.active = false;\r
         userLineInstantiator.active = true;\r
     }\r
@@ -65,6 +61,7 @@ Window {
             trayWindow.setX( systrayBackend.calcTrayWindowX());\r
             trayWindow.setY( systrayBackend.calcTrayWindowY());\r
             systrayBackend.setOpened();\r
+            userModelBackend.fetchCurrentActivityModel();\r
         }\r
         onHideWindow: {\r
             trayWindow.hide();\r