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 QWIDGETPLATFORMMENU_P_H
5#define QWIDGETPLATFORMMENU_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 <QtGui/qpa/qplatformmenu.h>
19#include <QtCore/private/qglobal_p.h>
20
21QT_BEGIN_NAMESPACE
22
23class QMenu;
24class QWidgetPlatformMenuItem;
25
26class QWidgetPlatformMenu : public QPlatformMenu
27{
28 Q_OBJECT
29
30public:
31 explicit QWidgetPlatformMenu(QObject *parent = nullptr);
32 ~QWidgetPlatformMenu();
33
34 QMenu *menu() const;
35
36 void insertMenuItem(QPlatformMenuItem *item, QPlatformMenuItem *before) override;
37 void removeMenuItem(QPlatformMenuItem *item) override;
38 void syncMenuItem(QPlatformMenuItem *item) override;
39 void syncSeparatorsCollapsible(bool enable) override;
40
41 void setText(const QString &text) override;
42 void setIcon(const QIcon &icon) override;
43 void setEnabled(bool enabled) override;
44 bool isEnabled() const override;
45 void setVisible(bool visible) override;
46 void setMinimumWidth(int width) override;
47 void setFont(const QFont &font) override;
48 void setMenuType(MenuType type) override;
49
50 void showPopup(const QWindow *window, const QRect &targetRect, const QPlatformMenuItem *item) override;
51 void dismiss() override;
52
53 QPlatformMenuItem *menuItemAt(int position) const override;
54 QPlatformMenuItem *menuItemForTag(quintptr tag) const override;
55
56 QPlatformMenuItem *createMenuItem() const override;
57 QPlatformMenu *createSubMenu() const override;
58
59private:
60 QScopedPointer<QMenu> m_menu;
61 QList<QWidgetPlatformMenuItem *> m_items;
62};
63
64QT_END_NAMESPACE
65
66Q_DECLARE_METATYPE(QPlatformMenu::MenuType)
67
68#endif // QWIDGETPLATFORMMENU_P_H
69

source code of qtdeclarative/src/labs/platform/widgets/qwidgetplatformmenu_p.h