Skip to content

Commit

Permalink
Fix #2085 new tray menu.
Browse files Browse the repository at this point in the history
- left click on the systray icon brings up the new QtQuick based dialogs on all platforms
- right click on the systray icon brings up the new QtQuick based dialog on Mac OS only
- right click on the systray icon brings up a context menu on all other platforms than Mac OS

Signed-off-by: Camila <[email protected]>
  • Loading branch information
Camila committed Jun 29, 2020
1 parent 372f678 commit 67355ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,13 @@ void ownCloudGui::slotOpenMainDialog()

void ownCloudGui::slotTrayClicked(QSystemTrayIcon::ActivationReason reason)
{
if (reason == QSystemTrayIcon::Trigger || reason == QSystemTrayIcon::Context) {
bool macos = false;
#ifdef Q_OS_MAC
macos = true;
#endif

if(reason == QSystemTrayIcon::Trigger ||
(macos && reason == QSystemTrayIcon::Context)){
if (OwncloudSetupWizard::bringWizardToFrontIfVisible()) {
// brought wizard to front
} else if (_shareDialogs.size() > 0) {
Expand Down
11 changes: 10 additions & 1 deletion 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 Settings"), this, &Systray::openSettings);
contextMenu->addAction(tr("Help"), this, &Systray::openHelp);
contextMenu->addAction(tr("Quit Nextcloud"), this, &Systray::shutdown);
setContextMenu(contextMenu);
#endif

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

Expand Down Expand Up @@ -259,7 +268,7 @@ QRect Systray::taskbarGeometry() const
#else
if (taskbarOrientation() == TaskBarPosition::Bottom || taskbarOrientation() == TaskBarPosition::Top) {
auto screenWidth = currentScreenRect().width();
return QRect(0, 0, screenWidth, 32);
return {0, 0, screenWidth, 32};
} else {
auto screenHeight = currentScreenRect().height();
return QRect(0, 0, 32, screenHeight);
Expand Down

0 comments on commit 67355ce

Please sign in to comment.