1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 BogDan Vatra <bogdan@kde.org>
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #include "qandroidplatformmenuitem.h"
41 #include "qandroidplatformmenu.h"
42 
43 QT_BEGIN_NAMESPACE
44 
QAndroidPlatformMenuItem()45 QAndroidPlatformMenuItem::QAndroidPlatformMenuItem()
46 {
47     m_menu = 0;
48     m_isVisible = true;
49     m_isSeparator = false;
50     m_role = NoRole;
51     m_isCheckable = false;
52     m_isChecked = false;
53     m_isEnabled = true;
54 }
55 
setText(const QString & text)56 void QAndroidPlatformMenuItem::setText(const QString &text)
57 {
58     m_text = text;
59     if (m_menu)
60         m_menu->setText(m_text);
61 }
62 
text() const63 QString QAndroidPlatformMenuItem::text() const
64 {
65     return m_text;
66 }
67 
setIcon(const QIcon & icon)68 void QAndroidPlatformMenuItem::setIcon(const QIcon &icon)
69 {
70     m_icon = icon;
71     if (m_menu)
72         m_menu->setIcon(m_icon);
73 }
74 
icon() const75 QIcon QAndroidPlatformMenuItem::icon() const
76 {
77     return m_icon;
78 }
79 
setMenu(QPlatformMenu * menu)80 void QAndroidPlatformMenuItem::setMenu(QPlatformMenu *menu)
81 {
82     m_menu = static_cast<QAndroidPlatformMenu *>(menu);
83     if (!m_menu)
84         return;
85 
86     m_menu->setText(m_text);
87     m_menu->setIcon(m_icon);
88     m_menu->setVisible(m_isVisible);
89     m_menu->setEnabled(m_isEnabled);
90 }
91 
menu() const92 QAndroidPlatformMenu *QAndroidPlatformMenuItem::menu() const
93 {
94     return m_menu;
95 }
96 
setVisible(bool isVisible)97 void QAndroidPlatformMenuItem::setVisible(bool isVisible)
98 {
99     m_isVisible = isVisible;
100     if (m_menu)
101         m_menu->setVisible(m_isVisible);
102 }
103 
isVisible() const104 bool QAndroidPlatformMenuItem::isVisible() const
105 {
106     return m_isVisible;
107 }
108 
setIsSeparator(bool isSeparator)109 void QAndroidPlatformMenuItem::setIsSeparator(bool isSeparator)
110 {
111     m_isSeparator = isSeparator;
112 }
113 
isSeparator() const114 bool QAndroidPlatformMenuItem::isSeparator() const
115 {
116     return m_isSeparator;
117 }
118 
setFont(const QFont & font)119 void QAndroidPlatformMenuItem::setFont(const QFont &font)
120 {
121     Q_UNUSED(font)
122 }
123 
setRole(QPlatformMenuItem::MenuRole role)124 void QAndroidPlatformMenuItem::setRole(QPlatformMenuItem::MenuRole role)
125 {
126     m_role = role;
127 }
128 
role() const129 QPlatformMenuItem::MenuRole QAndroidPlatformMenuItem::role() const
130 {
131     return m_role;
132 }
133 
setCheckable(bool checkable)134 void QAndroidPlatformMenuItem::setCheckable(bool checkable)
135 {
136     m_isCheckable = checkable;
137 }
138 
isCheckable() const139 bool QAndroidPlatformMenuItem::isCheckable() const
140 {
141     return m_isCheckable;
142 }
143 
setChecked(bool isChecked)144 void QAndroidPlatformMenuItem::setChecked(bool isChecked)
145 {
146     m_isChecked = isChecked;
147 }
148 
isChecked() const149 bool QAndroidPlatformMenuItem::isChecked() const
150 {
151     return m_isChecked;
152 }
153 
setShortcut(const QKeySequence & shortcut)154 void QAndroidPlatformMenuItem::setShortcut(const QKeySequence &shortcut)
155 {
156     Q_UNUSED(shortcut)
157 }
158 
setEnabled(bool enabled)159 void QAndroidPlatformMenuItem::setEnabled(bool enabled)
160 {
161     m_isEnabled = enabled;
162     if (m_menu)
163         m_menu->setEnabled(m_isEnabled);
164 }
165 
isEnabled() const166 bool QAndroidPlatformMenuItem::isEnabled() const
167 {
168     return m_isEnabled;
169 }
170 
setIconSize(int size)171 void QAndroidPlatformMenuItem::setIconSize(int size)
172 {
173     Q_UNUSED(size)
174 }
175 
176 QT_END_NAMESPACE
177