From fa4328a59673809890de3345cef99f5c1579aea3 Mon Sep 17 00:00:00 2001 From: Camila San Date: Tue, 21 Aug 2018 12:26:20 +0200 Subject: [PATCH 1/2] Changes repo for 3rdparty/qtmacgoodies. - The fork has the functions needed to add separators in the toolbar. Signed-off-by: Camila San --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index d25acc3cc1..ea2e773908 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "src/3rdparty/qtmacgoodies"] path = src/3rdparty/qtmacgoodies - url = https://github.com/guruz/qtmacgoodies.git + url = https://github.com/camilasan/qtmacgoodies.git [submodule "binary"] path = binary url = git://github.com/owncloud/owncloud-client-binary.git From c8d5d9a6222a2aa730e33f9446850dfce3167cdb Mon Sep 17 00:00:00 2001 From: Camila San Date: Tue, 21 Aug 2018 14:54:10 +0200 Subject: [PATCH 2/2] Removes dynamic cast when building navigation apps. - It checks for the menu title to know where to add the apps menu instead of trying to cast the menu pointer saved in the sender() property. - The previous solution was not working reliably - see #523 - Adds TODO. Signed-off-by: Camila San --- src/gui/owncloudgui.cpp | 23 +++++++++++++++-------- src/gui/owncloudgui.h | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index d0212b6168..6c8e3b6a72 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -58,7 +58,6 @@ namespace OCC { const char propertyAccountC[] = "oc_account"; -const char propertyMenuC[] = "oc_account_menu"; ownCloudGui::ownCloudGui(Application *parent) : QObject(parent) @@ -617,11 +616,11 @@ void ownCloudGui::updateContextMenu() _contextMenu->addMenu(accountMenu); addAccountContextMenu(account, accountMenu, true); - fetchNavigationApps(account, accountMenu); + fetchNavigationApps(account); } } else if (accountList.count() == 1) { addAccountContextMenu(accountList.first(), _contextMenu.data(), false); - fetchNavigationApps(accountList.first(), _contextMenu.data()); + fetchNavigationApps(accountList.first()); } _contextMenu->addSeparator(); @@ -769,10 +768,9 @@ void ownCloudGui::slotEtagResponseHeaderReceived(const QByteArray &value, int st } } -void ownCloudGui::fetchNavigationApps(AccountStatePtr account, QMenu *accountMenu){ +void ownCloudGui::fetchNavigationApps(AccountStatePtr account){ OcsNavigationAppsJob *job = new OcsNavigationAppsJob(account->account()); job->setProperty(propertyAccountC, QVariant::fromValue(account)); - job->setProperty(propertyMenuC, QVariant::fromValue(accountMenu)); job->addRawHeader("If-None-Match", account->navigationAppsEtagResponseHeader()); connect(job, &OcsNavigationAppsJob::appsJobFinished, this, &ownCloudGui::slotNavigationAppsFetched); connect(job, &OcsNavigationAppsJob::etagResponseHeaderReceived, this, &ownCloudGui::slotEtagResponseHeaderReceived); @@ -829,9 +827,18 @@ void ownCloudGui::slotNavigationAppsFetched(const QJsonDocument &reply, int stat } } - if(QObject *accountMenuObj = qvariant_cast(sender()->property(propertyMenuC))){ - if(QMenu *accountMenu = dynamic_cast(accountMenuObj)) - buildNavigationAppsMenu(account, accountMenu); + // TODO see pull #523 + auto accountList = AccountManager::instance()->accounts(); + if(accountList.size() > 1){ + // the list of apps will be displayed under the account that it belongs to + foreach (QMenu *accountMenu, _accountMenus) { + if(accountMenu->title() == account->account()->displayName()){ + buildNavigationAppsMenu(account, accountMenu); + break; + } + } + } else if(accountList.size() == 1){ + buildNavigationAppsMenu(account, _contextMenu.data()); } } } diff --git a/src/gui/owncloudgui.h b/src/gui/owncloudgui.h index ca1170e905..c7e4c1272c 100644 --- a/src/gui/owncloudgui.h +++ b/src/gui/owncloudgui.h @@ -127,7 +127,7 @@ private: void setPauseOnAllFoldersHelper(bool pause); void setupActions(); void addAccountContextMenu(AccountStatePtr accountState, QMenu *menu, bool separateMenu); - void fetchNavigationApps(AccountStatePtr account, QMenu *accountMenu); + void fetchNavigationApps(AccountStatePtr account); void buildNavigationAppsMenu(AccountStatePtr account, QMenu *accountMenu); QPointer _tray;