File indexing completed on 2024-05-05 17:42:26
0001 /* 0002 0003 SPDX-FileCopyrightText: 2016 Dmitry Shachnev <mitya57@gmail.com> 0004 Contact: https://www.qt.io/licensing/ 0005 0006 This file is part of the QtGui module of the Qt Toolkit. 0007 0008 SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KFQF-Accepted-GPL OR LicenseRef-Qt-Commercial 0009 0010 */ 0011 0012 #ifndef QDBUSMENUBAR_P_H 0013 #define QDBUSMENUBAR_P_H 0014 0015 // 0016 // W A R N I N G 0017 // ------------- 0018 // 0019 // This file is not part of the Qt API. It exists purely as an 0020 // implementation detail. This header file may change from version to 0021 // version without notice, or even be removed. 0022 // 0023 // We mean it. 0024 // 0025 0026 #include "kdeplatformtheme.h" 0027 0028 #include <QHash> 0029 #include <QString> 0030 #include <QWindow> 0031 0032 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 0033 #include <QtThemeSupport/private/qdbusmenuadaptor_p.h> 0034 #include <QtThemeSupport/private/qdbusmenuconnection_p.h> 0035 #include <QtThemeSupport/private/qdbusmenuregistrarproxy_p.h> 0036 #include <QtThemeSupport/private/qdbusplatformmenu_p.h> 0037 #else 0038 #include <private/qdbusmenuadaptor_p.h> 0039 #include <private/qdbusmenuconnection_p.h> 0040 #include <private/qdbusmenuregistrarproxy_p.h> 0041 #include <private/qdbusplatformmenu_p.h> 0042 #endif 0043 0044 QT_BEGIN_NAMESPACE 0045 0046 class QDBusMenuBar : public QPlatformMenuBar 0047 { 0048 Q_OBJECT 0049 0050 public: 0051 QDBusMenuBar(KdePlatformTheme *platformTheme); 0052 ~QDBusMenuBar() override; 0053 0054 void insertMenu(QPlatformMenu *menu, QPlatformMenu *before) override; 0055 void removeMenu(QPlatformMenu *menu) override; 0056 void syncMenu(QPlatformMenu *menu) override; 0057 void handleReparent(QWindow *newParentWindow) override; 0058 QPlatformMenu *menuForTag(quintptr tag) const override; 0059 QPlatformMenu *createMenu() const override; 0060 static QDBusMenuBar *globalMenuBar(); 0061 static QDBusMenuBar *menuBarForWindow(QWindow *window); 0062 0063 QWindow *window() const 0064 { 0065 return m_window; 0066 } 0067 QString objectPath() const 0068 { 0069 return m_objectPath; 0070 } 0071 0072 Q_SIGNALS: 0073 void windowChanged(QWindow *newWindow, QWindow *oldWindow); 0074 0075 private: 0076 QDBusPlatformMenu *m_menu = nullptr; 0077 QDBusMenuAdaptor *m_menuAdaptor = nullptr; 0078 QHash<quintptr, QDBusPlatformMenuItem *> m_menuItems; 0079 QPointer<QWindow> m_window; 0080 QString m_objectPath; 0081 bool m_initted = false; 0082 KdePlatformTheme *m_platformTheme; 0083 static QDBusMenuBar *s_globalMenuBar; 0084 static QMap<QWindow *, QDBusMenuBar *> s_menuBars; 0085 0086 QDBusPlatformMenuItem *menuItemForMenu(QPlatformMenu *menu); 0087 static void updateMenuItem(QDBusPlatformMenuItem *item, QPlatformMenu *menu); 0088 bool createDBusMenuBar(); 0089 void uncreateDBusMenuBar(); 0090 0091 static void registerMenuBarX11(QWindow *window, const QString &objectPath); 0092 static void unregisterMenuBarX11(QWindow *window); 0093 }; 0094 0095 QT_END_NAMESPACE 0096 0097 #endif // QDBUSMENUBAR_P_H