1// Copyright (C) 2017 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_H
5#define QQUICKMENUBAR_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/qquickcontainer_p.h>
19
20QT_REQUIRE_CONFIG(quicktemplates2_container);
21
22QT_BEGIN_NAMESPACE
23
24class QQuickMenu;
25class QQuickMenuBarPrivate;
26class QQmlComponent;
27
28class Q_QUICKTEMPLATES2_EXPORT QQuickMenuBar : public QQuickContainer
29{
30 Q_OBJECT
31 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
32 Q_PRIVATE_PROPERTY(QQuickMenuBar::d_func(), QQmlListProperty<QQuickMenu> menus READ menus NOTIFY menusChanged FINAL)
33 Q_PRIVATE_PROPERTY(QQuickMenuBar::d_func(), QQmlListProperty<QObject> contentData READ contentData FINAL)
34 QML_NAMED_ELEMENT(MenuBar)
35 QML_ADDED_IN_VERSION(2, 3)
36
37public:
38 explicit QQuickMenuBar(QQuickItem *parent = nullptr);
39 ~QQuickMenuBar() override;
40
41 QQmlComponent *delegate() const;
42 void setDelegate(QQmlComponent *delegate);
43
44 Q_INVOKABLE QQuickMenu *menuAt(int index) const;
45 Q_INVOKABLE void addMenu(QQuickMenu *menu);
46 Q_INVOKABLE void insertMenu(int index, QQuickMenu *menu);
47 Q_INVOKABLE void removeMenu(QQuickMenu *menu);
48 Q_INVOKABLE QQuickMenu *takeMenu(int index);
49
50Q_SIGNALS:
51 void delegateChanged();
52 void menusChanged();
53
54protected:
55 bool eventFilter(QObject *object, QEvent *event) override;
56 void keyPressEvent(QKeyEvent *event) override;
57 void keyReleaseEvent(QKeyEvent *event) override;
58 void hoverLeaveEvent(QHoverEvent *event) override;
59
60 bool isContent(QQuickItem *item) const override;
61 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override;
62 void itemAdded(int index, QQuickItem *item) override;
63 void itemMoved(int index, QQuickItem *item) override;
64 void itemRemoved(int index, QQuickItem *item) override;
65
66 void componentComplete() override;
67
68 QFont defaultFont() const override;
69
70#if QT_CONFIG(accessibility)
71 QAccessible::Role accessibleRole() const override;
72#endif
73
74private:
75 Q_DISABLE_COPY(QQuickMenuBar)
76 Q_DECLARE_PRIVATE(QQuickMenuBar)
77};
78
79QT_END_NAMESPACE
80
81#endif // QQUICKMENUBAR_P_H
82

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