|
|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
#include "platformtheme.h"
|
|
|
|
|
#include "x11integration.h"
|
|
|
|
|
#include "qdbusmenubar_p.h"
|
|
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QFont>
|
|
|
|
|
@ -18,29 +17,8 @@
|
|
|
|
|
#include <private/qwindow_p.h>
|
|
|
|
|
#include <private/qguiapplication_p.h>
|
|
|
|
|
|
|
|
|
|
// Qt DBus
|
|
|
|
|
#include <QDBusConnection>
|
|
|
|
|
#include <QDBusConnectionInterface>
|
|
|
|
|
#include <QDBusInterface>
|
|
|
|
|
|
|
|
|
|
#include <KWindowSystem>
|
|
|
|
|
|
|
|
|
|
static const QByteArray s_x11AppMenuServiceNamePropertyName = QByteArrayLiteral("_KDE_NET_WM_APPMENU_SERVICE_NAME");
|
|
|
|
|
static const QByteArray s_x11AppMenuObjectPathPropertyName = QByteArrayLiteral("_KDE_NET_WM_APPMENU_OBJECT_PATH");
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern void updateXdgIconSystemTheme();
|
|
|
|
|
|
|
|
|
|
void onDarkModeChanged()
|
|
|
|
|
@ -135,39 +113,9 @@ const QFont* PlatformTheme::font(Font type) const
|
|
|
|
|
|
|
|
|
|
QPlatformMenuBar *PlatformTheme::createPlatformMenuBar() const
|
|
|
|
|
{
|
|
|
|
|
if (isDBusGlobalMenuAvailable()) {
|
|
|
|
|
auto *menu = new QDBusMenuBar();
|
|
|
|
|
|
|
|
|
|
QObject::connect(menu, &QDBusMenuBar::windowChanged, menu, [this, menu](QWindow *newWindow, QWindow *oldWindow) {
|
|
|
|
|
const QString &serviceName = QDBusConnection::sessionBus().baseService();
|
|
|
|
|
const QString &objectPath = menu->objectPath();
|
|
|
|
|
|
|
|
|
|
if (m_x11Integration) {
|
|
|
|
|
if (oldWindow) {
|
|
|
|
|
m_x11Integration->setWindowProperty(oldWindow, s_x11AppMenuServiceNamePropertyName, {});
|
|
|
|
|
m_x11Integration->setWindowProperty(oldWindow, s_x11AppMenuObjectPathPropertyName, {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (newWindow) {
|
|
|
|
|
m_x11Integration->setWindowProperty(newWindow, s_x11AppMenuServiceNamePropertyName, serviceName.toUtf8());
|
|
|
|
|
m_x11Integration->setWindowProperty(newWindow, s_x11AppMenuObjectPathPropertyName, objectPath.toUtf8());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if (m_kwaylandIntegration) {
|
|
|
|
|
// if (oldWindow) {
|
|
|
|
|
// m_kwaylandIntegration->setAppMenu(oldWindow, QString(), QString());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (newWindow) {
|
|
|
|
|
// m_kwaylandIntegration->setAppMenu(newWindow, serviceName, objectPath);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Qt 6 no longer exports the private QDBusPlatformMenu implementation
|
|
|
|
|
// used by the old Qt 5 global-menu code. The old implementation would
|
|
|
|
|
// make this platform theme plugin fail to load at runtime.
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|