Some Dialogs: Bring to top on tray click #5515 #5566 (#5664)

On my OS X, it might get hidden under other apps while I opened it and then want to quickly
verify something in another app.
This commit is contained in:
Markus Goetz 2017-04-20 08:55:44 +02:00 committed by GitHub
parent 3a8d6a6f16
commit de9ee295be
3 changed files with 35 additions and 14 deletions

View File

@ -174,22 +174,31 @@ void ownCloudGui::slotTrayClicked( QSystemTrayIcon::ActivationReason reason )
last_click.start();
}
// A click on the tray icon should only open the status window on Win and
// Linux, not on Mac. They want a menu entry.
#if !defined Q_OS_MAC
// Left click
if( reason == QSystemTrayIcon::Trigger ) {
// Start settings if config is existing.
slotOpenSettingsDialog();
}
if (OwncloudSetupWizard::bringWizardToFrontIfVisible()) {
// brought wizard to front
} else if (_shareDialogs.size() > 0) {
// Share dialog(s) be hidden by other apps, bring them back
Q_FOREACH(const QPointer<ShareDialog> &shareDialog, _shareDialogs) {
Q_ASSERT(shareDialog.data());
raiseDialog(shareDialog);
}
} else {
#ifdef Q_OS_MAC
// on macOS, a left click always opens menu.
// However if the settings dialog is already visible but hidden
// by other applications, this will bring it to the front.
if (!_settingsDialog.isNull() && _settingsDialog->isVisible()) {
raiseDialog(_settingsDialog.data());
}
#else
// On Mac, if the settings dialog is already visible but hidden
// by other applications, this will bring it to the front.
if( reason == QSystemTrayIcon::Trigger ) {
if (!_settingsDialog.isNull() && _settingsDialog->isVisible()) {
slotShowSettings();
slotOpenSettingsDialog();
#endif
}
}
#endif
// FIXME: Also make sure that any auto updater dialogue https://github.com/owncloud/client/issues/5613
// or SSL error dialog also comes to front.
}
void ownCloudGui::slotSyncStateChange( Folder* folder )

View File

@ -32,6 +32,7 @@
#include "accountmanager.h"
#include "clientproxy.h"
#include "filesystem.h"
#include "owncloudgui.h"
#include "creds/credentialsfactory.h"
#include "creds/abstractcredentials.h"
@ -64,10 +65,10 @@ OwncloudSetupWizard::~OwncloudSetupWizard()
_ocWizard->deleteLater();
}
static QPointer<OwncloudSetupWizard> wiz = 0;
void OwncloudSetupWizard::runWizard(QObject* obj, const char* amember, QWidget *parent)
{
static QPointer<OwncloudSetupWizard> wiz;
if (!wiz.isNull()) {
return;
}
@ -78,6 +79,16 @@ void OwncloudSetupWizard::runWizard(QObject* obj, const char* amember, QWidget *
wiz->startWizard();
}
bool OwncloudSetupWizard::bringWizardToFrontIfVisible()
{
if (wiz.isNull()) {
return false;
}
ownCloudGui::raiseDialog(wiz->_ocWizard);
return true;
}
void OwncloudSetupWizard::startWizard()
{
AccountPtr account = AccountManager::createAccount();

View File

@ -60,6 +60,7 @@ class OwncloudSetupWizard : public QObject
public:
/** Run the wizard */
static void runWizard(QObject *obj, const char* amember, QWidget *parent = 0 );
static bool bringWizardToFrontIfVisible();
signals:
// overall dialog close signal.
void ownCloudWizardDone( int );