]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Prevent jumping of tray menu
authorSergey Zolotarev <sryze@protonmail.com>
Sat, 5 Oct 2019 15:54:09 +0000 (21:54 +0600)
committerSergey Zolotarev <sryze@protonmail.com>
Sat, 5 Oct 2019 16:10:35 +0000 (22:10 +0600)
Instead of adding the "Apps" menu after the apps are fetched, add it
from the start (together with other actions) but in a disabled state,
and enable it after the apps data is ready.

Signed-off-by: Sergey Zolotarev <sryze@protonmail.com>
src/gui/owncloudgui.cpp
src/gui/owncloudgui.h

index 53b5684136733af5b53fcbdf192292b5ff6891f6..28b57d295591a5f7fe7d543ed81bab3becd2bda0 100644 (file)
@@ -675,6 +675,12 @@ void ownCloudGui::updateContextMenu()
 
     _contextMenu->addSeparator();
 
+    if (_navLinksMenu) {
+        _contextMenu->addMenu(_navLinksMenu);
+    }
+
+    _contextMenu->addSeparator();
+
     if (accountList.isEmpty()) {
         _contextMenu->addAction(_actionNewAccountWizard);
     }
@@ -688,6 +694,7 @@ void ownCloudGui::updateContextMenu()
     }
 
     _contextMenu->addSeparator();
+
     if (atLeastOnePaused) {
         QString text;
         if (accountList.count() > 1) {
@@ -777,6 +784,8 @@ void ownCloudGui::setupActions()
 {
     _actionStatus = new QAction(tr("Unknown status"), this);
     _actionStatus->setEnabled(false);
+    _navLinksMenu = new QMenu(tr("Apps"));
+    _navLinksMenu->setEnabled(false);
     _actionSettings = new QAction(tr("Settings..."), this);
     _actionNewAccountWizard = new QAction(tr("New account..."), this);
     _actionRecent = new QAction(tr("View more activity..."), this);
@@ -819,7 +828,6 @@ void ownCloudGui::fetchNavigationApps(AccountStatePtr account){
 void ownCloudGui::buildNavigationAppsMenu(AccountStatePtr account, QMenu *accountMenu){
     auto navLinks = _navApps.value(account);
     if(navLinks.size() > 0){
-
         // when there is only one account add the nav links above the settings
         QAction *actionBefore = _actionSettings;
 
@@ -838,17 +846,14 @@ void ownCloudGui::buildNavigationAppsMenu(AccountStatePtr account, QMenu *accoun
         }
 
         // Create submenu with links
-        QMenu *navLinksMenu = new QMenu(tr("Apps"));
-        accountMenu->insertSeparator(actionBefore);
-        accountMenu->insertMenu(actionBefore, navLinksMenu);
         foreach (const QJsonValue &value, navLinks) {
             auto navLink = value.toObject();
             QAction *action = new QAction(navLink.value("name").toString(), this);
             QUrl href(navLink.value("href").toString());
             connect(action, &QAction::triggered, this, [href] { QDesktopServices::openUrl(href); });
-            navLinksMenu->addAction(action);
+            _navLinksMenu->addAction(action);
         }
-        accountMenu->insertSeparator(actionBefore);
+        _navLinksMenu->setEnabled(true);
     }
 }
 
index 105235233a95d7c0e14ef359a3f12cc08ac8fa3a..95d078bc6919283031bfd9b40cfccf7ec11e94f1 100644 (file)
@@ -168,6 +168,7 @@ private:
     QAction *_actionQuit;
     QAction *_actionCrash;
 
+    QMenu *_navLinksMenu;
     QMap<AccountStatePtr, QJsonArray> _navApps;
 
     QList<QAction *> _recentItemsActions;