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