| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/accessible/qaccessiblemenu.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||
| 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 "qaccessiblemenu_p.h" | - | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | #include <qmenu.h> | - | ||||||||||||||||||
| 43 | #include <qmenubar.h> | - | ||||||||||||||||||
| 44 | #include <QtWidgets/QAction> | - | ||||||||||||||||||
| 45 | #include <qstyle.h> | - | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | #ifndef QT_NO_MENU | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | QString qt_accStripAmp(const QString &text); | - | ||||||||||||||||||
| 54 | QString qt_accHotKey(const QString &text); | - | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | QAccessibleInterface *getOrCreateMenu(QWidget *menu, QAction *action) | - | ||||||||||||||||||
| 57 | { | - | ||||||||||||||||||
| 58 | QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(action); | - | ||||||||||||||||||
| 59 | if (!iface) {
| 0 | ||||||||||||||||||
| 60 | iface = new QAccessibleMenuItem(menu, action); | - | ||||||||||||||||||
| 61 | QAccessible::registerAccessibleInterface(iface); | - | ||||||||||||||||||
| 62 | } never executed: end of block | 0 | ||||||||||||||||||
| 63 | return iface; never executed: return iface; | 0 | ||||||||||||||||||
| 64 | } | - | ||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | QAccessibleMenu::QAccessibleMenu(QWidget *w) | - | ||||||||||||||||||
| 67 | : QAccessibleWidget(w) | - | ||||||||||||||||||
| 68 | { | - | ||||||||||||||||||
| 69 | Q_ASSERT(menu()); | - | ||||||||||||||||||
| 70 | } never executed: end of block | 0 | ||||||||||||||||||
| 71 | - | |||||||||||||||||||
| 72 | QMenu *QAccessibleMenu::menu() const | - | ||||||||||||||||||
| 73 | { | - | ||||||||||||||||||
| 74 | return qobject_cast<QMenu*>(object()); never executed: return qobject_cast<QMenu*>(object()); | 0 | ||||||||||||||||||
| 75 | } | - | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | int QAccessibleMenu::childCount() const | - | ||||||||||||||||||
| 78 | { | - | ||||||||||||||||||
| 79 | return menu()->actions().count(); never executed: return menu()->actions().count(); | 0 | ||||||||||||||||||
| 80 | } | - | ||||||||||||||||||
| 81 | - | |||||||||||||||||||
| 82 | QAccessibleInterface *QAccessibleMenu::childAt(int x, int y) const | - | ||||||||||||||||||
| 83 | { | - | ||||||||||||||||||
| 84 | QAction *act = menu()->actionAt(menu()->mapFromGlobal(QPoint(x,y))); | - | ||||||||||||||||||
| 85 | if(act && act->isSeparator())
| 0 | ||||||||||||||||||
| 86 | act = 0; never executed: act = 0; | 0 | ||||||||||||||||||
| 87 | return act ? getOrCreateMenu(menu(), act) : 0; never executed: return act ? getOrCreateMenu(menu(), act) : 0; | 0 | ||||||||||||||||||
| 88 | } | - | ||||||||||||||||||
| 89 | - | |||||||||||||||||||
| 90 | QString QAccessibleMenu::text(QAccessible::Text t) const | - | ||||||||||||||||||
| 91 | { | - | ||||||||||||||||||
| 92 | QString tx = QAccessibleWidget::text(t); | - | ||||||||||||||||||
| 93 | if (!tx.isEmpty())
| 0 | ||||||||||||||||||
| 94 | return tx; never executed: return tx; | 0 | ||||||||||||||||||
| 95 | - | |||||||||||||||||||
| 96 | if (t == QAccessible::Name)
| 0 | ||||||||||||||||||
| 97 | return menu()->windowTitle(); never executed: return menu()->windowTitle(); | 0 | ||||||||||||||||||
| 98 | return tx; never executed: return tx; | 0 | ||||||||||||||||||
| 99 | } | - | ||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | QAccessible::Role QAccessibleMenu::role() const | - | ||||||||||||||||||
| 102 | { | - | ||||||||||||||||||
| 103 | return QAccessible::PopupMenu; never executed: return QAccessible::PopupMenu; | 0 | ||||||||||||||||||
| 104 | } | - | ||||||||||||||||||
| 105 | - | |||||||||||||||||||
| 106 | QAccessibleInterface *QAccessibleMenu::child(int index) const | - | ||||||||||||||||||
| 107 | { | - | ||||||||||||||||||
| 108 | if (index < childCount())
| 0 | ||||||||||||||||||
| 109 | return getOrCreateMenu(menu(), menu()->actions().at(index)); never executed: return getOrCreateMenu(menu(), menu()->actions().at(index)); | 0 | ||||||||||||||||||
| 110 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 111 | } | - | ||||||||||||||||||
| 112 | - | |||||||||||||||||||
| 113 | QAccessibleInterface *QAccessibleMenu::parent() const | - | ||||||||||||||||||
| 114 | { | - | ||||||||||||||||||
| 115 | if (QAction *menuAction = menu()->menuAction()) {
| 0 | ||||||||||||||||||
| 116 | QList<QWidget *> parentCandidates; | - | ||||||||||||||||||
| 117 | parentCandidates << menu()->parentWidget(); | - | ||||||||||||||||||
| 118 | parentCandidates << menuAction->associatedWidgets(); | - | ||||||||||||||||||
| 119 | foreach (QWidget *w, parentCandidates) { | - | ||||||||||||||||||
| 120 | if (qobject_cast<QMenu*>(w) || qobject_cast<QMenuBar*>(w)) {
| 0 | ||||||||||||||||||
| 121 | if (w->actions().indexOf(menuAction) != -1)
| 0 | ||||||||||||||||||
| 122 | return getOrCreateMenu(w, menuAction); never executed: return getOrCreateMenu(w, menuAction); | 0 | ||||||||||||||||||
| 123 | } never executed: end of block | 0 | ||||||||||||||||||
| 124 | } never executed: end of block | 0 | ||||||||||||||||||
| 125 | } never executed: end of block | 0 | ||||||||||||||||||
| 126 | return QAccessibleWidget::parent(); never executed: return QAccessibleWidget::parent(); | 0 | ||||||||||||||||||
| 127 | } | - | ||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | int QAccessibleMenu::indexOfChild( const QAccessibleInterface *child) const | - | ||||||||||||||||||
| 130 | { | - | ||||||||||||||||||
| 131 | QAccessible::Role r = child->role(); | - | ||||||||||||||||||
| 132 | if ((r == QAccessible::MenuItem || r == QAccessible::Separator) && menu()) {
| 0 | ||||||||||||||||||
| 133 | return menu()->actions().indexOf(qobject_cast<QAction*>(child->object())); never executed: return menu()->actions().indexOf(qobject_cast<QAction*>(child->object())); | 0 | ||||||||||||||||||
| 134 | } | - | ||||||||||||||||||
| 135 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 136 | } | - | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||
| 139 | QAccessibleMenuBar::QAccessibleMenuBar(QWidget *w) | - | ||||||||||||||||||
| 140 | : QAccessibleWidget(w, QAccessible::MenuBar) | - | ||||||||||||||||||
| 141 | { | - | ||||||||||||||||||
| 142 | Q_ASSERT(menuBar()); | - | ||||||||||||||||||
| 143 | } never executed: end of block | 0 | ||||||||||||||||||
| 144 | - | |||||||||||||||||||
| 145 | QMenuBar *QAccessibleMenuBar::menuBar() const | - | ||||||||||||||||||
| 146 | { | - | ||||||||||||||||||
| 147 | return qobject_cast<QMenuBar*>(object()); never executed: return qobject_cast<QMenuBar*>(object()); | 0 | ||||||||||||||||||
| 148 | } | - | ||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | int QAccessibleMenuBar::childCount() const | - | ||||||||||||||||||
| 151 | { | - | ||||||||||||||||||
| 152 | return menuBar()->actions().count(); never executed: return menuBar()->actions().count(); | 0 | ||||||||||||||||||
| 153 | } | - | ||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | QAccessibleInterface *QAccessibleMenuBar::child(int index) const | - | ||||||||||||||||||
| 156 | { | - | ||||||||||||||||||
| 157 | if (index < childCount()) {
| 0 | ||||||||||||||||||
| 158 | return getOrCreateMenu(menuBar(), menuBar()->actions().at(index)); never executed: return getOrCreateMenu(menuBar(), menuBar()->actions().at(index)); | 0 | ||||||||||||||||||
| 159 | } | - | ||||||||||||||||||
| 160 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 161 | } | - | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | int QAccessibleMenuBar::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
| 164 | { | - | ||||||||||||||||||
| 165 | QAccessible::Role r = child->role(); | - | ||||||||||||||||||
| 166 | if ((r == QAccessible::MenuItem || r == QAccessible::Separator) && menuBar()) {
| 0 | ||||||||||||||||||
| 167 | return menuBar()->actions().indexOf(qobject_cast<QAction*>(child->object())); never executed: return menuBar()->actions().indexOf(qobject_cast<QAction*>(child->object())); | 0 | ||||||||||||||||||
| 168 | } | - | ||||||||||||||||||
| 169 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 170 | } | - | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | #endif // QT_NO_MENUBAR | - | ||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | QAccessibleMenuItem::QAccessibleMenuItem(QWidget *owner, QAction *action) | - | ||||||||||||||||||
| 175 | : m_action(action), m_owner(owner) | - | ||||||||||||||||||
| 176 | { | - | ||||||||||||||||||
| 177 | } never executed: end of block | 0 | ||||||||||||||||||
| 178 | - | |||||||||||||||||||
| 179 | QAccessibleMenuItem::~QAccessibleMenuItem() | - | ||||||||||||||||||
| 180 | {} | - | ||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | QAccessibleInterface *QAccessibleMenuItem::childAt(int x, int y ) const | - | ||||||||||||||||||
| 183 | { | - | ||||||||||||||||||
| 184 | for (int i = childCount() - 1; i >= 0; --i) {
| 0 | ||||||||||||||||||
| 185 | QAccessibleInterface *childInterface = child(i); | - | ||||||||||||||||||
| 186 | if (childInterface->rect().contains(x,y)) {
| 0 | ||||||||||||||||||
| 187 | return childInterface; never executed: return childInterface; | 0 | ||||||||||||||||||
| 188 | } | - | ||||||||||||||||||
| 189 | } never executed: end of block | 0 | ||||||||||||||||||
| 190 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 191 | } | - | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | int QAccessibleMenuItem::childCount() const | - | ||||||||||||||||||
| 194 | { | - | ||||||||||||||||||
| 195 | return m_action->menu() ? 1 : 0; never executed: return m_action->menu() ? 1 : 0; | 0 | ||||||||||||||||||
| 196 | } | - | ||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | int QAccessibleMenuItem::indexOfChild(const QAccessibleInterface * child) const | - | ||||||||||||||||||
| 199 | { | - | ||||||||||||||||||
| 200 | if (child && child->role() == QAccessible::PopupMenu && child->object() == m_action->menu())
| 0 | ||||||||||||||||||
| 201 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 202 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 203 | } | - | ||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | bool QAccessibleMenuItem::isValid() const | - | ||||||||||||||||||
| 206 | { | - | ||||||||||||||||||
| 207 | return m_action && m_owner; never executed: return m_action && m_owner; | 0 | ||||||||||||||||||
| 208 | } | - | ||||||||||||||||||
| 209 | - | |||||||||||||||||||
| 210 | QAccessibleInterface *QAccessibleMenuItem::parent() const | - | ||||||||||||||||||
| 211 | { | - | ||||||||||||||||||
| 212 | return QAccessible::queryAccessibleInterface(owner()); never executed: return QAccessible::queryAccessibleInterface(owner()); | 0 | ||||||||||||||||||
| 213 | } | - | ||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | QAccessibleInterface *QAccessibleMenuItem::child(int index) const | - | ||||||||||||||||||
| 216 | { | - | ||||||||||||||||||
| 217 | if (index == 0 && action()->menu())
| 0 | ||||||||||||||||||
| 218 | return QAccessible::queryAccessibleInterface(action()->menu()); never executed: return QAccessible::queryAccessibleInterface(action()->menu()); | 0 | ||||||||||||||||||
| 219 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 220 | } | - | ||||||||||||||||||
| 221 | - | |||||||||||||||||||
| 222 | void *QAccessibleMenuItem::interface_cast(QAccessible::InterfaceType t) | - | ||||||||||||||||||
| 223 | { | - | ||||||||||||||||||
| 224 | if (t == QAccessible::ActionInterface)
| 0 | ||||||||||||||||||
| 225 | return static_cast<QAccessibleActionInterface*>(this); never executed: return static_cast<QAccessibleActionInterface*>(this); | 0 | ||||||||||||||||||
| 226 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 227 | } | - | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | QObject *QAccessibleMenuItem::object() const | - | ||||||||||||||||||
| 230 | { | - | ||||||||||||||||||
| 231 | return m_action; never executed: return m_action; | 0 | ||||||||||||||||||
| 232 | } | - | ||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | /*! \reimp */ | - | ||||||||||||||||||
| 235 | QWindow *QAccessibleMenuItem::window() const | - | ||||||||||||||||||
| 236 | { | - | ||||||||||||||||||
| 237 | QWindow *result = Q_NULLPTR; | - | ||||||||||||||||||
| 238 | if (!m_owner.isNull()) {
| 0 | ||||||||||||||||||
| 239 | result = m_owner->windowHandle(); | - | ||||||||||||||||||
| 240 | if (!result) {
| 0 | ||||||||||||||||||
| 241 | if (const QWidget *nativeParent = m_owner->nativeParentWidget())
| 0 | ||||||||||||||||||
| 242 | result = nativeParent->windowHandle(); never executed: result = nativeParent->windowHandle(); | 0 | ||||||||||||||||||
| 243 | } never executed: end of block | 0 | ||||||||||||||||||
| 244 | } never executed: end of block | 0 | ||||||||||||||||||
| 245 | return result; never executed: return result; | 0 | ||||||||||||||||||
| 246 | } | - | ||||||||||||||||||
| 247 | - | |||||||||||||||||||
| 248 | QRect QAccessibleMenuItem::rect() const | - | ||||||||||||||||||
| 249 | { | - | ||||||||||||||||||
| 250 | QRect rect; | - | ||||||||||||||||||
| 251 | QWidget *own = owner(); | - | ||||||||||||||||||
| 252 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||
| 253 | if (QMenuBar *menuBar = qobject_cast<QMenuBar*>(own)) {
| 0 | ||||||||||||||||||
| 254 | rect = menuBar->actionGeometry(m_action); | - | ||||||||||||||||||
| 255 | QPoint globalPos = menuBar->mapToGlobal(QPoint(0,0)); | - | ||||||||||||||||||
| 256 | rect = rect.translated(globalPos); | - | ||||||||||||||||||
| 257 | } else never executed: end of block | 0 | ||||||||||||||||||
| 258 | #endif // QT_NO_MENUBAR | - | ||||||||||||||||||
| 259 | if (QMenu *menu = qobject_cast<QMenu*>(own)) {
| 0 | ||||||||||||||||||
| 260 | rect = menu->actionGeometry(m_action); | - | ||||||||||||||||||
| 261 | QPoint globalPos = menu->mapToGlobal(QPoint(0,0)); | - | ||||||||||||||||||
| 262 | rect = rect.translated(globalPos); | - | ||||||||||||||||||
| 263 | } never executed: end of block | 0 | ||||||||||||||||||
| 264 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
| 265 | } | - | ||||||||||||||||||
| 266 | - | |||||||||||||||||||
| 267 | QAccessible::Role QAccessibleMenuItem::role() const | - | ||||||||||||||||||
| 268 | { | - | ||||||||||||||||||
| 269 | return m_action->isSeparator() ? QAccessible::Separator : QAccessible::MenuItem; never executed: return m_action->isSeparator() ? QAccessible::Separator : QAccessible::MenuItem; | 0 | ||||||||||||||||||
| 270 | } | - | ||||||||||||||||||
| 271 | - | |||||||||||||||||||
| 272 | void QAccessibleMenuItem::setText(QAccessible::Text /*t*/, const QString & /*text */) | - | ||||||||||||||||||
| 273 | { | - | ||||||||||||||||||
| 274 | } | - | ||||||||||||||||||
| 275 | - | |||||||||||||||||||
| 276 | QAccessible::State QAccessibleMenuItem::state() const | - | ||||||||||||||||||
| 277 | { | - | ||||||||||||||||||
| 278 | QAccessible::State s; | - | ||||||||||||||||||
| 279 | QWidget *own = owner(); | - | ||||||||||||||||||
| 280 | - | |||||||||||||||||||
| 281 | if (own && (own->testAttribute(Qt::WA_WState_Visible) == false || m_action->isVisible() == false)) {
| 0 | ||||||||||||||||||
| 282 | s.invisible = true; | - | ||||||||||||||||||
| 283 | } never executed: end of block | 0 | ||||||||||||||||||
| 284 | - | |||||||||||||||||||
| 285 | if (QMenu *menu = qobject_cast<QMenu*>(own)) {
| 0 | ||||||||||||||||||
| 286 | if (menu->activeAction() == m_action)
| 0 | ||||||||||||||||||
| 287 | s.focused = true; never executed: s.focused = true; | 0 | ||||||||||||||||||
| 288 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||
| 289 | } else if (QMenuBar *menuBar = qobject_cast<QMenuBar*>(own)) { never executed: end of block
| 0 | ||||||||||||||||||
| 290 | if (menuBar->activeAction() == m_action)
| 0 | ||||||||||||||||||
| 291 | s.focused = true; never executed: s.focused = true; | 0 | ||||||||||||||||||
| 292 | #endif | - | ||||||||||||||||||
| 293 | } never executed: end of block | 0 | ||||||||||||||||||
| 294 | if (own && own->style()->styleHint(QStyle::SH_Menu_MouseTracking))
| 0 | ||||||||||||||||||
| 295 | s.hotTracked = true; never executed: s.hotTracked = true; | 0 | ||||||||||||||||||
| 296 | if (m_action->isSeparator() || !m_action->isEnabled())
| 0 | ||||||||||||||||||
| 297 | s.disabled = true; never executed: s.disabled = true; | 0 | ||||||||||||||||||
| 298 | if (m_action->isChecked())
| 0 | ||||||||||||||||||
| 299 | s.checked = true; never executed: s.checked = true; | 0 | ||||||||||||||||||
| 300 | - | |||||||||||||||||||
| 301 | return s; never executed: return s; | 0 | ||||||||||||||||||
| 302 | } | - | ||||||||||||||||||
| 303 | - | |||||||||||||||||||
| 304 | QString QAccessibleMenuItem::text(QAccessible::Text t) const | - | ||||||||||||||||||
| 305 | { | - | ||||||||||||||||||
| 306 | QString str; | - | ||||||||||||||||||
| 307 | switch (t) { | - | ||||||||||||||||||
| 308 | case QAccessible::Name: never executed: case QAccessible::Name: | 0 | ||||||||||||||||||
| 309 | str = qt_accStripAmp(m_action->text()); | - | ||||||||||||||||||
| 310 | break; never executed: break; | 0 | ||||||||||||||||||
| 311 | case QAccessible::Accelerator: { never executed: case QAccessible::Accelerator: | 0 | ||||||||||||||||||
| 312 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||
| 313 | QKeySequence key = m_action->shortcut(); | - | ||||||||||||||||||
| 314 | if (!key.isEmpty()) {
| 0 | ||||||||||||||||||
| 315 | str = key.toString(); | - | ||||||||||||||||||
| 316 | } else never executed: end of block | 0 | ||||||||||||||||||
| 317 | #endif | - | ||||||||||||||||||
| 318 | { | - | ||||||||||||||||||
| 319 | str = qt_accHotKey(m_action->text()); | - | ||||||||||||||||||
| 320 | } never executed: end of block | 0 | ||||||||||||||||||
| 321 | break; never executed: break; | 0 | ||||||||||||||||||
| 322 | } | - | ||||||||||||||||||
| 323 | default: never executed: default: | 0 | ||||||||||||||||||
| 324 | break; never executed: break; | 0 | ||||||||||||||||||
| 325 | } | - | ||||||||||||||||||
| 326 | return str; never executed: return str; | 0 | ||||||||||||||||||
| 327 | } | - | ||||||||||||||||||
| 328 | - | |||||||||||||||||||
| 329 | QStringList QAccessibleMenuItem::actionNames() const | - | ||||||||||||||||||
| 330 | { | - | ||||||||||||||||||
| 331 | QStringList actions; | - | ||||||||||||||||||
| 332 | if (!m_action || m_action->isSeparator())
| 0 | ||||||||||||||||||
| 333 | return actions; never executed: return actions; | 0 | ||||||||||||||||||
| 334 | - | |||||||||||||||||||
| 335 | if (m_action->menu()) {
| 0 | ||||||||||||||||||
| 336 | actions << showMenuAction(); | - | ||||||||||||||||||
| 337 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 338 | actions << pressAction(); | - | ||||||||||||||||||
| 339 | } never executed: end of block | 0 | ||||||||||||||||||
| 340 | return actions; never executed: return actions; | 0 | ||||||||||||||||||
| 341 | } | - | ||||||||||||||||||
| 342 | - | |||||||||||||||||||
| 343 | void QAccessibleMenuItem::doAction(const QString &actionName) | - | ||||||||||||||||||
| 344 | { | - | ||||||||||||||||||
| 345 | if (!m_action->isEnabled())
| 0 | ||||||||||||||||||
| 346 | return; never executed: return; | 0 | ||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | if (actionName == pressAction()) {
| 0 | ||||||||||||||||||
| 349 | m_action->trigger(); | - | ||||||||||||||||||
| 350 | } else if (actionName == showMenuAction()) { never executed: end of block
| 0 | ||||||||||||||||||
| 351 | if (QMenuBar *bar = qobject_cast<QMenuBar*>(owner())) {
| 0 | ||||||||||||||||||
| 352 | if (m_action->menu() && m_action->menu()->isVisible()) {
| 0 | ||||||||||||||||||
| 353 | m_action->menu()->hide(); | - | ||||||||||||||||||
| 354 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 355 | bar->setActiveAction(m_action); | - | ||||||||||||||||||
| 356 | } never executed: end of block | 0 | ||||||||||||||||||
| 357 | } else if (QMenu *menu = qobject_cast<QMenu*>(owner())){
| 0 | ||||||||||||||||||
| 358 | if (m_action->menu() && m_action->menu()->isVisible()) {
| 0 | ||||||||||||||||||
| 359 | m_action->menu()->hide(); | - | ||||||||||||||||||
| 360 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 361 | menu->setActiveAction(m_action); | - | ||||||||||||||||||
| 362 | } never executed: end of block | 0 | ||||||||||||||||||
| 363 | } | - | ||||||||||||||||||
| 364 | } never executed: end of block | 0 | ||||||||||||||||||
| 365 | } never executed: end of block | 0 | ||||||||||||||||||
| 366 | - | |||||||||||||||||||
| 367 | QStringList QAccessibleMenuItem::keyBindingsForAction(const QString &) const | - | ||||||||||||||||||
| 368 | { | - | ||||||||||||||||||
| 369 | return QStringList(); never executed: return QStringList(); | 0 | ||||||||||||||||||
| 370 | } | - | ||||||||||||||||||
| 371 | - | |||||||||||||||||||
| 372 | - | |||||||||||||||||||
| 373 | QAction *QAccessibleMenuItem::action() const | - | ||||||||||||||||||
| 374 | { | - | ||||||||||||||||||
| 375 | return m_action; never executed: return m_action; | 0 | ||||||||||||||||||
| 376 | } | - | ||||||||||||||||||
| 377 | - | |||||||||||||||||||
| 378 | QWidget *QAccessibleMenuItem::owner() const | - | ||||||||||||||||||
| 379 | { | - | ||||||||||||||||||
| 380 | return m_owner; never executed: return m_owner; | 0 | ||||||||||||||||||
| 381 | } | - | ||||||||||||||||||
| 382 | - | |||||||||||||||||||
| 383 | #endif // QT_NO_MENU | - | ||||||||||||||||||
| 384 | - | |||||||||||||||||||
| 385 | QT_END_NAMESPACE | - | ||||||||||||||||||
| 386 | - | |||||||||||||||||||
| 387 | #endif // QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
| 388 | - | |||||||||||||||||||
| Source code | Switch to Preprocessed file |