File indexing completed on 2024-11-17 05:01:39
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 #include <QtThemeSupport/private/qdbusmenuadaptor_p.h> 0033 #include <QtThemeSupport/private/qdbusmenuconnection_p.h> 0034 #include <QtThemeSupport/private/qdbusmenuregistrarproxy_p.h> 0035 #include <QtThemeSupport/private/qdbusplatformmenu_p.h> 0036 0037 QT_BEGIN_NAMESPACE 0038 0039 class QDBusMenuBar : public QPlatformMenuBar 0040 { 0041 Q_OBJECT 0042 0043 public: 0044 QDBusMenuBar(KdePlatformTheme *platformTheme); 0045 ~QDBusMenuBar() override; 0046 0047 void insertMenu(QPlatformMenu *menu, QPlatformMenu *before) override; 0048 void removeMenu(QPlatformMenu *menu) override; 0049 void syncMenu(QPlatformMenu *menu) override; 0050 void handleReparent(QWindow *newParentWindow) override; 0051 QPlatformMenu *menuForTag(quintptr tag) const override; 0052 QPlatformMenu *createMenu() const override; 0053 static QDBusMenuBar *globalMenuBar(); 0054 static QDBusMenuBar *menuBarForWindow(QWindow *window); 0055 0056 QWindow *window() const 0057 { 0058 return m_window; 0059 } 0060 QString objectPath() const 0061 { 0062 return m_objectPath; 0063 } 0064 0065 Q_SIGNALS: 0066 void windowChanged(QWindow *newWindow, QWindow *oldWindow); 0067 0068 private: 0069 QDBusPlatformMenu *m_menu = nullptr; 0070 QDBusMenuAdaptor *m_menuAdaptor = nullptr; 0071 QHash<quintptr, QDBusPlatformMenuItem *> m_menuItems; 0072 QPointer<QWindow> m_window; 0073 QString m_objectPath; 0074 bool m_initted = false; 0075 KdePlatformTheme *m_platformTheme; 0076 static QDBusMenuBar *s_globalMenuBar; 0077 static QMap<QWindow *, QDBusMenuBar *> s_menuBars; 0078 0079 QDBusPlatformMenuItem *menuItemForMenu(QPlatformMenu *menu); 0080 static void updateMenuItem(QDBusPlatformMenuItem *item, QPlatformMenu *menu); 0081 bool createDBusMenuBar(); 0082 void uncreateDBusMenuBar(); 0083 0084 static void registerMenuBarX11(QWindow *window, const QString &objectPath); 0085 static void unregisterMenuBarX11(QWindow *window); 0086 }; 0087 0088 QT_END_NAMESPACE 0089 0090 #endif // QDBUSMENUBAR_P_H