1// Copyright (C) 2020 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 QQUICKMENUBAR_P_P_H
5#define QQUICKMENUBAR_P_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 <QtQuickTemplates2/private/qquickmenubar_p.h>
19#include <QtQuickTemplates2/private/qquickcontainer_p_p.h>
20
21#include <QtCore/qpointer.h>
22#include <QtGui/qpa/qplatformmenu.h>
23
24QT_BEGIN_NAMESPACE
25
26class QQmlComponent;
27class QQuickMenuBarItem;
28
29class Q_QUICKTEMPLATES2_EXPORT QQuickMenuBarPrivate : public QQuickContainerPrivate
30{
31public:
32 Q_DECLARE_PUBLIC(QQuickMenuBar)
33
34 static QQuickMenuBarPrivate *get(QQuickMenuBar *menuBar)
35 {
36 return menuBar->d_func();
37 }
38
39 QQmlListProperty<QQuickMenu> menus();
40 QQmlListProperty<QObject> contentData();
41
42 QQuickItem *createItemFromDelegate();
43 QQuickMenuBarItem *createMenuBarItem(QQuickMenu *menu);
44
45 void openCurrentMenu();
46 void closeCurrentMenu();
47 void activateMenuItem(int index);
48
49 void activateItem(QQuickMenuBarItem *item);
50 void activateNextItem();
51 void activatePreviousItem();
52
53 void onItemHovered();
54 void onItemTriggered();
55 void onMenuAboutToHide(QQuickMenu *menu);
56
57 void insertMenu(int index, QQuickMenu *menu, QQuickMenuBarItem *delegateItem);
58 QQuickMenu *takeMenu(int index);
59 void insertNativeMenu(QQuickMenu *menu);
60 void removeNativeMenu(QQuickMenu *menu);
61 void syncMenuBarItemVisibilty(QQuickMenuBarItem *menuBarItem);
62
63 QWindow *window() const;
64 int menuIndex(QQuickMenu *menu) const;
65
66 QPlatformMenuBar *nativeHandle() const;
67 bool useNativeMenuBar() const;
68 bool useNativeMenu(const QQuickMenu *menu) const;
69 void syncNativeMenuBarVisible();
70 void createNativeMenuBar();
71 void removeNativeMenuBar();
72
73 qreal getContentWidth() const override;
74 qreal getContentHeight() const override;
75
76 void itemImplicitWidthChanged(QQuickItem *item) override;
77 void itemImplicitHeightChanged(QQuickItem *item) override;
78
79 static void contentData_append(QQmlListProperty<QObject> *prop, QObject *obj);
80
81 static void menus_append(QQmlListProperty<QQuickMenu> *prop, QQuickMenu *obj);
82 static qsizetype menus_count(QQmlListProperty<QQuickMenu> *prop);
83 static QQuickMenu *menus_at(QQmlListProperty<QQuickMenu> *prop, qsizetype index);
84 static void menus_clear(QQmlListProperty<QQuickMenu> *prop);
85
86 QPalette defaultPalette() const override;
87
88 bool closingCurrentMenu = false;
89 bool altPressed = false;
90 bool currentMenuOpen = false;
91 QQmlComponent *delegate = nullptr;
92 QPointer<QQuickMenuBarItem> currentItem;
93 QPointer<QQuickItem> windowContentItem;
94
95private:
96 std::unique_ptr<QPlatformMenuBar> handle;
97};
98
99QT_END_NAMESPACE
100
101#endif // QQUICKMENUBAR_P_P_H
102

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtdeclarative/src/quicktemplates/qquickmenubar_p_p.h