Compares account menu with the account associated with the action to make sure apps is added to the right position.

Signed-off-by: Camila San <hello@camila.codes>
This commit is contained in:
Camila San 2018-02-22 19:15:02 +01:00
parent 4ffff7454e
commit 99d8d050c2
No known key found for this signature in database
GPG key ID: A0A1A2FD03979524
4 changed files with 24 additions and 40 deletions

View file

@ -47,6 +47,7 @@ private slots:
void slotUpdateInfo();
void slotIgnoreFilesEditor();
void loadMiscSettings();
private:
Ui::GeneralSettings *_ui;
QPointer<IgnoreListEditor> _ignoreEditor;

View file

@ -20,16 +20,6 @@
<string>General Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QCheckBox" name="monoIconsCheckBox">
<property name="toolTip">
<string>For System Tray</string>
</property>
<property name="text">
<string>Use &amp;Monochrome Icons</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="autostartCheckBox">
<property name="text">
@ -44,6 +34,16 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="monoIconsCheckBox">
<property name="toolTip">
<string>For System Tray</string>
</property>
<property name="text">
<string>Use &amp;Monochrome Icons</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -252,6 +252,9 @@
</layout>
</widget>
<tabstops>
<tabstop>autostartCheckBox</tabstop>
<tabstop>desktopNotificationsCheckBox</tabstop>
<tabstop>monoIconsCheckBox</tabstop>
<tabstop>ignoredFilesButton</tabstop>
<tabstop>newFolderLimitCheckBox</tabstop>
<tabstop>newFolderLimitSpinBox</tabstop>

View file

@ -17,6 +17,7 @@
#include "ocsnavigationappsjob.h"
#include "theme.h"
#include "folderman.h"
#include "configfile.h"
#include "progressdispatcher.h"
#include "owncloudsetupwizard.h"
#include "sharedialog.h"
@ -34,7 +35,6 @@
#include "accountmanager.h"
#include "common/syncjournalfilerecord.h"
#include "creds/abstractcredentials.h"
#include "configfile.h"
#ifdef WITH_LIBCLOUDPROVIDERS
#include "cloudproviders/cloudprovidermanager.h"
#endif
@ -54,6 +54,7 @@
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
namespace OCC {
@ -398,13 +399,11 @@ void ownCloudGui::addAccountContextMenu(AccountStatePtr accountState, QMenu *men
QAction *enable = menu->addAction(tr("Unpause all folders"));
enable->setProperty(propertyAccountC, QVariant::fromValue(accountState));
connect(enable, &QAction::triggered, this, &ownCloudGui::slotUnpauseAllFolders);
_storedActionsForNavApps.append(enable);
}
if (!allPaused) {
QAction *enable = menu->addAction(tr("Pause all folders"));
enable->setProperty(propertyAccountC, QVariant::fromValue(accountState));
connect(enable, &QAction::triggered, this, &ownCloudGui::slotPauseAllFolders);
_storedActionsForNavApps.append(enable);
}
if (accountState->isSignedOut()) {
@ -415,7 +414,6 @@ void ownCloudGui::addAccountContextMenu(AccountStatePtr accountState, QMenu *men
QAction *signout = menu->addAction(tr("Log out"));
signout->setProperty(propertyAccountC, QVariant::fromValue(accountState));
connect(signout, &QAction::triggered, this, &ownCloudGui::slotLogout);
_storedActionsForNavApps.append(signout);
}
}
}
@ -572,7 +570,6 @@ void ownCloudGui::updateContextMenu()
menu->deleteLater();
}
_accountMenus.clear();
_storedActionsForNavApps.clear();
auto accountList = AccountManager::instance()->accounts();
@ -620,7 +617,6 @@ void ownCloudGui::updateContextMenu()
_contextMenu->addAction(_actionNewAccountWizard);
}
_contextMenu->addAction(_actionSettings);
if (!Theme::instance()->helpUrl().isEmpty()) {
_contextMenu->addAction(_actionHelp);
}
@ -762,7 +758,6 @@ void ownCloudGui::slotNavigationAppsFetched(const QJsonDocument &reply)
if(!reply.isEmpty()){
auto element = reply.object().value("ocs").toObject().value("data");
auto navLinks = element.toArray();
if(navLinks.size() > 0){
if(auto account = qvariant_cast<AccountPtr>(sender()->property(propertyAccountC))){
if(QMenu *accountMenu = qvariant_cast<QMenu*>(sender()->property(propertyMenuC))){
@ -770,17 +765,13 @@ void ownCloudGui::slotNavigationAppsFetched(const QJsonDocument &reply)
// when there is only one account add the nav links above the settings
QAction *actionBefore = _actionSettings;
// when there is more than one account add the nav links bellow the account submenu
// when there is more than one account add the nav links above pause/unpause folder or logout action
if(AccountManager::instance()->accounts().size() > 1){
foreach(QAction *action, _storedActionsForNavApps){
qDebug() << "Action: "
<< action->text();
foreach(QAction *action, accountMenu->actions()){
// pause/unpause folder and logout actions have propertyAccountC
if(auto actionAccount = qvariant_cast<AccountStatePtr>(action->property(propertyAccountC))){
qDebug() << "Account found!"
<< actionAccount->account()->displayName();
if(actionAccount->account()->displayName() == account->displayName()){
qDebug() << "Menu found!"
<< actionAccount->account()->displayName();
if(actionAccount->account() == account){
actionBefore = action;
break;
}
@ -806,13 +797,11 @@ void ownCloudGui::slotNavigationAppsFetched(const QJsonDocument &reply)
}
}
void ownCloudGui::slotOcsError(int statusCode, const QString &message)
{
emit serverError(statusCode, message);
}
void ownCloudGui::slotRebuildRecentMenus()
{
_recentActionsMenu->clear();

View file

@ -18,7 +18,6 @@
#include "systray.h"
#include "connectionvalidator.h"
#include "progressdispatcher.h"
#include "configfile.h"
#include <QObject>
#include <QPointer>
@ -30,11 +29,6 @@
#include <QDBusConnection>
#endif
#include <QJsonArray>
class QJsonDocument;
class QJsonObject;
namespace OCC {
class Folder;
@ -100,6 +94,7 @@ public slots:
void slotAccountStateChanged();
void slotTrayMessageIfServerUnsupported(Account *account);
void slotNavigationAppsFetched(const QJsonDocument &reply);
/**
* Open a share dialog for a file or folder.
*
@ -121,14 +116,12 @@ private slots:
void slotPauseAllFolders();
void slotNewAccountWizard();
private:
void setPauseOnAllFoldersHelper(bool pause);
void setupActions();
void addAccountContextMenu(AccountStatePtr accountState, QMenu *menu, bool separateMenu);
void fetchNavigationApps(AccountStatePtr account, QMenu *accountMenu);
QPointer<Systray> _tray;
#if defined(Q_OS_MAC)
QPointer<SettingsDialogMac> _settingsDialog;
@ -161,11 +154,9 @@ private:
QAction *_actionHelp;
QAction *_actionQuit;
QAction *_actionCrash;
QList<QAction *> _recentItemsActions;
QList<QAction *> _storedActionsForNavApps;
Application *_app;
ConfigFile _cfg;
QList<QAction *> _recentItemsActions;
Application *_app;
};
} // namespace OCC