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

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