Skip to content

Commit

Permalink
Fix #2085 new tray menu.
Browse files Browse the repository at this point in the history
Update systray behavior and context menu:
- left click brings up the new QtQuick based dialogs on all latforms
- right click brings up the new QtQuick based dialog on Mac OS only
- right click brings up a context menu on all other platforms than Mac OS
- "Quit Nextcloud" => "Quit"
- Add "Open Main Dialog" option.

Signed-off-by: Camila <[email protected]>
  • Loading branch information
Camila committed Jul 1, 2020
1 parent be4ba03 commit 140f50f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ ownCloudGui::ownCloudGui(Application *parent)
connect(_tray.data(), &Systray::openHelp,
this, &ownCloudGui::slotHelp);

connect(_tray.data(), &Systray::openMainDialog,
this, &ownCloudGui::slotOpenSettingsDialog);

connect(_tray.data(), &Systray::openSettings,
this, &ownCloudGui::slotShowSettings);

Expand Down Expand Up @@ -145,7 +148,7 @@ void ownCloudGui::slotOpenSettingsDialog()
// if account is set up, start the configuration wizard.
if (!AccountManager::instance()->accounts().isEmpty()) {
if (_settingsDialog.isNull() || QApplication::activeWindow() != _settingsDialog) {
slotShowSettings();
slotOpenMainDialog();
} else {
_settingsDialog->close();
}
Expand All @@ -164,7 +167,7 @@ void ownCloudGui::slotOpenMainDialog()

void ownCloudGui::slotTrayClicked(QSystemTrayIcon::ActivationReason reason)
{
if (reason == QSystemTrayIcon::Trigger || reason == QSystemTrayIcon::Context) {
if (reason == QSystemTrayIcon::Trigger) {
if (OwncloudSetupWizard::bringWizardToFrontIfVisible()) {
// brought wizard to front
} else if (_shareDialogs.size() > 0) {
Expand Down Expand Up @@ -544,12 +547,16 @@ void ownCloudGui::slotShowGuiMessage(const QString &title, const QString &messag

void ownCloudGui::slotShowSettings()
{
if (_settingsDialog.isNull()) {
_settingsDialog = new SettingsDialog(this);
_settingsDialog->setAttribute(Qt::WA_DeleteOnClose, true);
_settingsDialog->show();
if (!AccountManager::instance()->accounts().isEmpty()) {
if (_settingsDialog.isNull()) {
_settingsDialog = new SettingsDialog(this);
_settingsDialog->setAttribute(Qt::WA_DeleteOnClose, true);
_settingsDialog->show();
}
raiseDialog(_settingsDialog.data());
} else {
slotNewAccountWizard();
}
raiseDialog(_settingsDialog.data());
}

void ownCloudGui::slotSettingsDialogActivated()
Expand Down
9 changes: 9 additions & 0 deletions src/gui/systray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QQmlContext>
#include <QQuickWindow>
#include <QScreen>
#include <QMenu>

#ifdef USE_FDO_NOTIFICATIONS
#include <QDBusConnection>
Expand Down Expand Up @@ -79,6 +80,14 @@ Systray::Systray()
}
);

#ifndef Q_OS_MAC
auto contextMenu = new QMenu();
contextMenu->addAction(tr("Open Main Dialog"), this, &Systray::openMainDialog);
contextMenu->addAction(tr("Settings"), this, &Systray::openSettings);
contextMenu->addAction(tr("Quit"), this, &Systray::shutdown);
setContextMenu(contextMenu);
#endif

connect(UserModel::instance(), &UserModel::newUserSelected,
this, &Systray::slotNewUserSelected);

Expand Down
1 change: 1 addition & 0 deletions src/gui/systray.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Systray

signals:
void currentUserChanged();
void openMainDialog();
void openSettings();
void openHelp();
void shutdown();
Expand Down

0 comments on commit 140f50f

Please sign in to comment.