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#include "qwidgetplatformmenuitem_p.h"
5#include "qwidgetplatformmenu_p.h"
6
7#include <QtGui/qaction.h>
8#include <QtWidgets/qmenu.h>
9
10QT_BEGIN_NAMESPACE
11
12QWidgetPlatformMenuItem::QWidgetPlatformMenuItem(QObject *parent)
13 : m_action(new QAction)
14{
15 setParent(parent);
16 connect(sender: m_action.data(), signal: &QAction::hovered, context: this, slot: &QPlatformMenuItem::hovered);
17 connect(sender: m_action.data(), signal: &QAction::triggered, context: this, slot: &QPlatformMenuItem::activated);
18}
19
20QWidgetPlatformMenuItem::~QWidgetPlatformMenuItem()
21{
22}
23
24QAction *QWidgetPlatformMenuItem::action() const
25{
26 return m_action.data();
27}
28
29void QWidgetPlatformMenuItem::setText(const QString &text)
30{
31 m_action->setText(text);
32}
33
34void QWidgetPlatformMenuItem::setIcon(const QIcon &icon)
35{
36 m_action->setIcon(icon);
37}
38
39void QWidgetPlatformMenuItem::setMenu(QPlatformMenu *menu)
40{
41 QWidgetPlatformMenu *widgetMenu = qobject_cast<QWidgetPlatformMenu *>(object: menu);
42 m_action->setMenu(widgetMenu ? widgetMenu->menu() : nullptr);
43}
44
45void QWidgetPlatformMenuItem::setVisible(bool visible)
46{
47 m_action->setVisible(visible);
48}
49
50void QWidgetPlatformMenuItem::setIsSeparator(bool separator)
51{
52 m_action->setSeparator(separator);
53}
54
55void QWidgetPlatformMenuItem::setFont(const QFont &font)
56{
57 m_action->setFont(font);
58}
59
60void QWidgetPlatformMenuItem::setRole(MenuRole role)
61{
62 m_action->setMenuRole(static_cast<QAction::MenuRole>(role));
63}
64
65void QWidgetPlatformMenuItem::setCheckable(bool checkable)
66{
67 m_action->setCheckable(checkable);
68}
69
70void QWidgetPlatformMenuItem::setChecked(bool checked)
71{
72 m_action->setChecked(checked);
73}
74
75#if QT_CONFIG(shortcut)
76void QWidgetPlatformMenuItem::setShortcut(const QKeySequence &shortcut)
77{
78 m_action->setShortcut(shortcut);
79}
80#endif
81
82void QWidgetPlatformMenuItem::setEnabled(bool enabled)
83{
84 m_action->setEnabled(enabled);
85}
86
87void QWidgetPlatformMenuItem::setIconSize(int size)
88{
89 Q_UNUSED(size);
90}
91
92QT_END_NAMESPACE
93
94#include "moc_qwidgetplatformmenuitem_p.cpp"
95

source code of qtdeclarative/src/labs/platform/widgets/qwidgetplatformmenuitem.cpp