From: Christian Kamm Date: Fri, 4 Sep 2015 09:58:50 +0000 (+0200) Subject: Tray: Don't use the tray workaround with the KDE theme #3706 X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~1408^2~121 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=699acc99e4875c9f5b09f12b084330f3f2020681;p=nextcloud-desktop.git Tray: Don't use the tray workaround with the KDE theme #3706 That just triggers another bug... --- diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 628163082..359baeb01 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -42,16 +42,6 @@ #include #endif -// Enables workarounds for bugs introduced in Qt 5.5.0 -// In particular QTBUG-47863 #3672 (tray menu fails to update and -// becomes unresponsive) and QTBUG-48068 #3722 (click signal is -// emitted several times) -#ifdef Q_OS_LINUX -#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) -#define WORKAROUND_QT_TRAY_DBUS -#endif -#endif - namespace OCC { const char propertyAccountC[] = "oc_account"; @@ -66,6 +56,7 @@ ownCloudGui::ownCloudGui(Application *parent) : #endif _logBrowser(0), _recentActionsMenu(0), + _qdbusmenuWorkaround(false), _folderOpenActionMapper(new QSignalMapper(this)), _recentItemsMapper(new QSignalMapper(this)), _app(parent) @@ -172,13 +163,13 @@ void ownCloudGui::slotOpenSettingsDialog() void ownCloudGui::slotTrayClicked( QSystemTrayIcon::ActivationReason reason ) { -#ifdef WORKAROUND_QT_TRAY_DBUS - static QElapsedTimer last_click; - if (last_click.isValid() && last_click.elapsed() < 200) { - return; + if (_qdbusmenuWorkaround) { + static QElapsedTimer last_click; + if (last_click.isValid() && last_click.elapsed() < 200) { + return; + } + last_click.start(); } - last_click.start(); -#endif // A click on the tray icon should only open the status window on Win and // Linux, not on Mac. They want a menu entry. @@ -385,11 +376,10 @@ void ownCloudGui::setupContextMenu() } } -#ifdef WORKAROUND_QT_TRAY_DBUS - _tray->hide(); -#endif - if ( _contextMenu ) { + if (_qdbusmenuWorkaround) { + _tray->hide(); + } _contextMenu->clear(); _recentActionsMenu->clear(); _recentActionsMenu->addAction(tr("None.")); @@ -400,6 +390,17 @@ void ownCloudGui::setupContextMenu() // this must be called only once after creating the context menu, or // it will trigger a bug in Ubuntu's SNI bridge patch (11.10, 12.04). _tray->setContextMenu(_contextMenu.data()); + + // Enables workarounds for bugs introduced in Qt 5.5.0 + // In particular QTBUG-47863 #3672 (tray menu fails to update and + // becomes unresponsive) and QTBUG-48068 #3722 (click signal is + // emitted several times) + QObject* platformMenu = reinterpret_cast(_tray->contextMenu()->platformMenu()); + if (platformMenu + && platformMenu->metaObject()->className() == QLatin1String("QDBusPlatformMenu")) { + _qdbusmenuWorkaround = true; + qDebug() << "Enabled QDBusPlatformMenu workaround"; + } } _contextMenu->setTitle(Theme::instance()->appNameGUI() ); // We must call deleteLater because we might be called from the press in one of the action. @@ -452,9 +453,9 @@ void ownCloudGui::setupContextMenu() } _contextMenu->addAction(_actionQuit); -#ifdef WORKAROUND_QT_TRAY_DBUS - _tray->show(); -#endif + if (_qdbusmenuWorkaround) { + _tray->show(); + } } diff --git a/src/gui/owncloudgui.h b/src/gui/owncloudgui.h index 3f4e09f98..891bd74d7 100644 --- a/src/gui/owncloudgui.h +++ b/src/gui/owncloudgui.h @@ -98,6 +98,7 @@ private: QScopedPointer _contextMenu; QMenu *_recentActionsMenu; QVector _accountMenus; + bool _qdbusmenuWorkaround; QAction *_actionLogin; QAction *_actionLogout;