[Pkg-owncloud-commits] [owncloud-client] 95/498: Systray menu: show one entry per account to open in a browser

Sandro Knauß hefee-guest at moszumanska.debian.org
Tue Aug 11 14:48:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit af94e8943d0cd6fa1a57b60c0735d7a950f845fe
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Wed May 13 12:54:31 2015 +0200

    Systray menu: show one entry per account to open in a browser
---
 src/gui/owncloudgui.cpp | 34 +++++++++++++++++++++++-----------
 src/gui/owncloudgui.h   |  1 -
 2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp
index 10bdfaf..806e29d 100644
--- a/src/gui/owncloudgui.cpp
+++ b/src/gui/owncloudgui.cpp
@@ -44,6 +44,8 @@
 
 namespace OCC {
 
+const char propertyAccountC[] = "oc_account";
+
 ownCloudGui::ownCloudGui(Application *parent) :
     QObject(parent),
     _tray(0),
@@ -274,16 +276,17 @@ void ownCloudGui::setupContextMenu()
 {
     FolderMan *folderMan = FolderMan::instance();
 
-#warning FIXME
-    AccountState *a = AccountManager::instance()->accounts().value(0).data();
+    auto accountList = AccountManager::instance()->accounts();
 
-    bool isConfigured = (a != 0);
-    _actionOpenoC->setEnabled(isConfigured);
+    bool isConfigured = (!accountList.isEmpty());
     bool isConnected = false;
-    if (isConfigured) {
-        isConnected = a->isConnected();
+    foreach (auto a, accountList) {
+        if (a->isConnected()) {
+            isConnected = true;
+        }
     }
 
+
     if ( _contextMenu ) {
         _contextMenu->clear();
         _recentActionsMenu->clear();
@@ -297,7 +300,18 @@ void ownCloudGui::setupContextMenu()
         _tray->setContextMenu(_contextMenu.data());
     }
     _contextMenu->setTitle(Theme::instance()->appNameGUI() );
-    _contextMenu->addAction(_actionOpenoC);
+
+
+    if (accountList.count() == 1) {
+        auto actionOpenoC = _contextMenu->addAction(tr("Open %1 in browser").arg(Theme::instance()->appNameGUI()));
+        actionOpenoC->setProperty(propertyAccountC, QVariant::fromValue(accountList.first()->account()));
+        QObject::connect(actionOpenoC, SIGNAL(triggered(bool)), SLOT(slotOpenOwnCloud()));
+        actionOpenoC->setEnabled(isConfigured);
+    } else foreach(auto account, accountList) {
+        auto actionOpenoC = _contextMenu->addAction(tr("Open %1 in browser").arg(account->account()->displayName()));
+        actionOpenoC->setProperty(propertyAccountC, QVariant::fromValue(account->account()));
+        QObject::connect(actionOpenoC, SIGNAL(triggered(bool)), SLOT(slotOpenOwnCloud()));
+    }
 
     int folderCnt = folderMan->map().size();
     // add open actions for all sync folders to the tray menu
@@ -404,8 +418,6 @@ void ownCloudGui::slotFolderOpenAction( const QString& alias )
 
 void ownCloudGui::setupActions()
 {
-    _actionOpenoC = new QAction(tr("Open %1 in browser").arg(Theme::instance()->appNameGUI()), this);
-    QObject::connect(_actionOpenoC, SIGNAL(triggered(bool)), SLOT(slotOpenOwnCloud()));
     _actionQuota = new QAction(tr("Calculating quota..."), this);
     _actionQuota->setEnabled( false );
     _actionStatus = new QAction(tr("Unknown status"), this);
@@ -591,8 +603,8 @@ void ownCloudGui::slotToggleLogBrowser()
 
 void ownCloudGui::slotOpenOwnCloud()
 {
-    if (auto account = AccountManager::instance()->accounts().value(0)) {
-        QDesktopServices::openUrl(account->account()->url());
+    if (auto account = qvariant_cast<AccountPtr>(sender()->property(propertyAccountC))) {
+        QDesktopServices::openUrl(account->url());
     }
 }
 
diff --git a/src/gui/owncloudgui.h b/src/gui/owncloudgui.h
index c4ec16b..33f7084 100644
--- a/src/gui/owncloudgui.h
+++ b/src/gui/owncloudgui.h
@@ -94,7 +94,6 @@ private:
     QAction *_actionLogin;
     QAction *_actionLogout;
 
-    QAction *_actionOpenoC;
     QAction *_actionSettings;
     QAction *_actionQuota;
     QAction *_actionStatus;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list