| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICKLABSPLATFORMMENUBAR_P_H |
| 5 | #define QQUICKLABSPLATFORMMENUBAR_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtCore/qobject.h> |
| 19 | #include <QtQml/qqmlparserstatus.h> |
| 20 | #include <QtQml/qqmllist.h> |
| 21 | #include <QtQml/qqml.h> |
| 22 | #include <QtCore/private/qglobal_p.h> |
| 23 | |
| 24 | QT_BEGIN_NAMESPACE |
| 25 | |
| 26 | class QWindow; |
| 27 | class QPlatformMenuBar; |
| 28 | class QQuickLabsPlatformMenu; |
| 29 | |
| 30 | class QQuickLabsPlatformMenuBar : public QObject, public QQmlParserStatus |
| 31 | { |
| 32 | Q_OBJECT |
| 33 | QML_NAMED_ELEMENT(MenuBar) |
| 34 | Q_INTERFACES(QQmlParserStatus) |
| 35 | Q_PROPERTY(QQmlListProperty<QObject> data READ data FINAL) |
| 36 | Q_PROPERTY(QQmlListProperty<QQuickLabsPlatformMenu> menus READ menus NOTIFY menusChanged FINAL) |
| 37 | Q_PROPERTY(QWindow *window READ window WRITE setWindow NOTIFY windowChanged FINAL) |
| 38 | Q_CLASSINFO("DefaultProperty", "data") |
| 39 | |
| 40 | public: |
| 41 | explicit QQuickLabsPlatformMenuBar(QObject *parent = nullptr); |
| 42 | ~QQuickLabsPlatformMenuBar(); |
| 43 | |
| 44 | QPlatformMenuBar *handle() const; |
| 45 | |
| 46 | QQmlListProperty<QObject> data(); |
| 47 | QQmlListProperty<QQuickLabsPlatformMenu> menus(); |
| 48 | |
| 49 | QWindow *window() const; |
| 50 | void setWindow(QWindow *window); |
| 51 | |
| 52 | Q_INVOKABLE void addMenu(QQuickLabsPlatformMenu *menu); |
| 53 | Q_INVOKABLE void insertMenu(int index, QQuickLabsPlatformMenu *menu); |
| 54 | Q_INVOKABLE void removeMenu(QQuickLabsPlatformMenu *menu); |
| 55 | Q_INVOKABLE void clear(); |
| 56 | |
| 57 | Q_SIGNALS: |
| 58 | void menusChanged(); |
| 59 | void windowChanged(); |
| 60 | |
| 61 | protected: |
| 62 | void classBegin() override; |
| 63 | void componentComplete() override; |
| 64 | |
| 65 | QWindow *findWindow() const; |
| 66 | |
| 67 | static void data_append(QQmlListProperty<QObject> *property, QObject *object); |
| 68 | static qsizetype data_count(QQmlListProperty<QObject> *property); |
| 69 | static QObject *data_at(QQmlListProperty<QObject> *property, qsizetype index); |
| 70 | static void data_clear(QQmlListProperty<QObject> *property); |
| 71 | |
| 72 | static void menus_append(QQmlListProperty<QQuickLabsPlatformMenu> *property, QQuickLabsPlatformMenu *menu); |
| 73 | static qsizetype menus_count(QQmlListProperty<QQuickLabsPlatformMenu> *property); |
| 74 | static QQuickLabsPlatformMenu *menus_at(QQmlListProperty<QQuickLabsPlatformMenu> *property, qsizetype index); |
| 75 | static void menus_clear(QQmlListProperty<QQuickLabsPlatformMenu> *property); |
| 76 | |
| 77 | private: |
| 78 | bool m_complete; |
| 79 | QWindow *m_window; |
| 80 | QList<QObject *> m_data; |
| 81 | QList<QQuickLabsPlatformMenu *> m_menus; |
| 82 | QPlatformMenuBar *m_handle; |
| 83 | }; |
| 84 | |
| 85 | QT_END_NAMESPACE |
| 86 | |
| 87 | #endif // QQUICKLABSPLATFORMMENUBAR_P_H |
| 88 |
