summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/platformsupport/themes/genericunix/qgenericunixthemes.cpp')
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp68
1 files changed, 67 insertions, 1 deletions
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index 026ba11c3d..aee12eed76 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -59,9 +59,12 @@
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformservices.h>
#include <qpa/qplatformdialoghelper.h>
+#ifndef QT_NO_DBUS
+#include "QtPlatformSupport/private/qdbusplatformmenu_p.h"
+#include "QtPlatformSupport/private/qdbusmenubar_p.h"
+#endif
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
#include "QtPlatformSupport/private/qdbustrayicon_p.h"
-#include "QtPlatformSupport/private/qdbusplatformmenu_p.h"
#endif
#include <algorithm>
@@ -114,6 +117,21 @@ static bool isDBusTrayAvailable() {
}
#endif
+#ifndef QT_NO_DBUS
+static bool checkDBusGlobalMenuAvailable()
+{
+ QDBusConnection connection = QDBusConnection::sessionBus();
+ QString registrarService = QStringLiteral("com.canonical.AppMenu.Registrar");
+ return connection.interface()->isServiceRegistered(registrarService);
+}
+
+static bool isDBusGlobalMenuAvailable()
+{
+ static bool dbusGlobalMenuAvailable = checkDBusGlobalMenuAvailable();
+ return dbusGlobalMenuAvailable;
+}
+#endif
+
class QGenericUnixThemePrivate : public QPlatformThemePrivate
{
public:
@@ -172,6 +190,22 @@ QStringList QGenericUnixTheme::xdgIconThemePaths()
return paths;
}
+#ifndef QT_NO_DBUS
+QPlatformMenu *QGenericUnixTheme::createPlatformMenu() const
+{
+ if (isDBusGlobalMenuAvailable())
+ return new QDBusPlatformMenu();
+ return nullptr;
+}
+
+QPlatformMenuBar *QGenericUnixTheme::createPlatformMenuBar() const
+{
+ if (isDBusGlobalMenuAvailable())
+ return new QDBusMenuBar();
+ return nullptr;
+}
+#endif
+
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
QPlatformSystemTrayIcon *QGenericUnixTheme::createPlatformSystemTrayIcon() const
{
@@ -559,6 +593,22 @@ QPlatformTheme *QKdeTheme::createKdeTheme()
return new QKdeTheme(kdeDirs, kdeVersion);
}
+#ifndef QT_NO_DBUS
+QPlatformMenu *QKdeTheme::createPlatformMenu() const
+{
+ if (isDBusGlobalMenuAvailable())
+ return new QDBusPlatformMenu();
+ return nullptr;
+}
+
+QPlatformMenuBar *QKdeTheme::createPlatformMenuBar() const
+{
+ if (isDBusGlobalMenuAvailable())
+ return new QDBusMenuBar();
+ return nullptr;
+}
+#endif
+
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
QPlatformSystemTrayIcon *QKdeTheme::createPlatformSystemTrayIcon() const
{
@@ -655,6 +705,22 @@ QString QGnomeTheme::gtkFontName() const
return QStringLiteral("%1 %2").arg(QLatin1String(defaultSystemFontNameC)).arg(defaultSystemFontSize);
}
+#ifndef QT_NO_DBUS
+QPlatformMenu *QGnomeTheme::createPlatformMenu() const
+{
+ if (isDBusGlobalMenuAvailable())
+ return new QDBusPlatformMenu();
+ return nullptr;
+}
+
+QPlatformMenuBar *QGnomeTheme::createPlatformMenuBar() const
+{
+ if (isDBusGlobalMenuAvailable())
+ return new QDBusMenuBar();
+ return nullptr;
+}
+#endif
+
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
QPlatformSystemTrayIcon *QGnomeTheme::createPlatformSystemTrayIcon() const
{