| Line | Source | Count | 
| 1 |  | - | 
| 2 |  | - | 
| 3 |  | - | 
| 4 |  | - | 
| 5 |  | - | 
| 6 |  | - | 
| 7 |  | - | 
| 8 |  | - | 
| 9 |  | - | 
| 10 |  | - | 
| 11 |  | - | 
| 12 |  | - | 
| 13 |  | - | 
| 14 |  | - | 
| 15 |  | - | 
| 16 |  | - | 
| 17 |  | - | 
| 18 |  | - | 
| 19 |  | - | 
| 20 |  | - | 
| 21 |  | - | 
| 22 |  | - | 
| 23 |  | - | 
| 24 |  | - | 
| 25 |  | - | 
| 26 |  | - | 
| 27 |  | - | 
| 28 |  | - | 
| 29 |  | - | 
| 30 |  | - | 
| 31 |  | - | 
| 32 |  | - | 
| 33 |  | - | 
| 34 |  | - | 
| 35 |  | - | 
| 36 |  | - | 
| 37 |  | - | 
| 38 |  | - | 
| 39 |  | - | 
| 40 | #include "qshortcut.h" | - | 
| 41 | #include "private/qwidget_p.h" | - | 
| 42 |  | - | 
| 43 | #ifndef QT_NO_SHORTCUT | - | 
| 44 | #include <qevent.h> | - | 
| 45 | #include <qwhatsthis.h> | - | 
| 46 | #include <qmenu.h> | - | 
| 47 | #include <qmenubar.h> | - | 
| 48 | #include <qapplication.h> | - | 
| 49 | #include <private/qapplication_p.h> | - | 
| 50 | #include <private/qshortcutmap_p.h> | - | 
| 51 | #include <private/qaction_p.h> | - | 
| 52 | #include <private/qwidgetwindow_p.h> | - | 
| 53 | #include <qpa/qplatformmenu.h> | - | 
| 54 |  | - | 
| 55 | QT_BEGIN_NAMESPACE | - | 
| 56 |  | - | 
| 57 | #define QAPP_CHECK(functionName) \ | - | 
| 58 |     if (Q_UNLIKELY(!qApp))) {                                            \ | - | 
| 59 |         qWarning("QShortcut: Initialize QApplication before calling '" functionName "'."); \ | - | 
| 60 |         return; \ | - | 
| 61 |     } | - | 
| 62 |  | - | 
| 63 |  | - | 
| 64 | static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window); | - | 
| 65 | #ifndef QT_NO_GRAPHICSVIEW | - | 
| 66 | static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsWidget *w, QWidget *active_window); | - | 
| 67 | #endif | - | 
| 68 | #ifndef QT_NO_ACTION | - | 
| 69 | static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidget *active_window); | - | 
| 70 | #endif | - | 
| 71 |  | - | 
| 72 |  | - | 
| 73 |  | - | 
| 74 |  | - | 
| 75 |  | - | 
| 76 |  | - | 
| 77 | bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context) | - | 
| 78 | { | - | 
| 79 |     Q_ASSERT_X(object, "QShortcutMap", "Shortcut has no owner. Illegal map state!"); | - | 
| 80 |  | - | 
| 81 |     QWidget *active_window = QApplication::activeWindow(); | - | 
| 82 |  | - | 
| 83 |      | - | 
| 84 |      | - | 
| 85 |      | - | 
| 86 |     if (QApplication::activePopupWidget()) | - | 
| 87 |         active_window = QApplication::activePopupWidget(); | - | 
| 88 |  | - | 
| 89 |     if (!active_window) { | - | 
| 90 |         QWindow *qwindow = QGuiApplication::focusWindow(); | - | 
| 91 |         if (qwindow && qwindow->isActive()) { | - | 
| 92 |             while (qwindow) { | - | 
| 93 |                 QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(qwindow); | - | 
| 94 |                 if (widgetWindow) { | - | 
| 95 |                     active_window = widgetWindow->widget(); | - | 
| 96 |                     break; | - | 
| 97 |                 } | - | 
| 98 |                 qwindow = qwindow->parent(); | - | 
| 99 |             } | - | 
| 100 |         } | - | 
| 101 |     } | - | 
| 102 |  | - | 
| 103 |     if (!active_window) | - | 
| 104 |         return false; | - | 
| 105 |  | - | 
| 106 | #ifndef QT_NO_ACTION | - | 
| 107 |     if (QAction *a = qobject_cast<QAction *>(object)) | - | 
| 108 |         return correctActionContext(context, a, active_window); | - | 
| 109 | #endif | - | 
| 110 |  | - | 
| 111 | #ifndef QT_NO_GRAPHICSVIEW | - | 
| 112 |     if (QGraphicsWidget *gw = qobject_cast<QGraphicsWidget *>(object)) | - | 
| 113 |         return correctGraphicsWidgetContext(context, gw, active_window); | - | 
| 114 | #endif | - | 
| 115 |  | - | 
| 116 |     QWidget *w = qobject_cast<QWidget *>(object); | - | 
| 117 |     if (!w) { | - | 
| 118 |         QShortcut *s = qobject_cast<QShortcut *>(object); | - | 
| 119 |         if (s) | - | 
| 120 |             w = s->parentWidget(); | - | 
| 121 |     } | - | 
| 122 |  | - | 
| 123 |     if (!w) { | - | 
| 124 |         QWindow *qwindow = qobject_cast<QWindow *>(object); | - | 
| 125 |         while (qwindow) { | - | 
| 126 |             QWidgetWindow *widget_window = qobject_cast<QWidgetWindow *>(qwindow); | - | 
| 127 |             if (widget_window) { | - | 
| 128 |                 w = widget_window->widget(); | - | 
| 129 |                 break; | - | 
| 130 |             } | - | 
| 131 |             qwindow = qwindow->parent(); | - | 
| 132 |         } | - | 
| 133 |     } | - | 
| 134 |  | - | 
| 135 |     if (!w) | - | 
| 136 |         return false; | - | 
| 137 |  | - | 
| 138 |     return correctWidgetContext(context, w, active_window); | - | 
| 139 | } | - | 
| 140 |  | - | 
| 141 | static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window) | - | 
| 142 | { | - | 
| 143 |     bool visible = w->isVisible(); | - | 
| 144 | #ifdef Q_OS_MAC | - | 
| 145 |     if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w)) | - | 
| 146 |         visible = true; | - | 
| 147 | #endif | - | 
| 148 |  | - | 
| 149 |     if (!visible || !w->isEnabled()) | - | 
| 150 |         return false; | - | 
| 151 |  | - | 
| 152 |     if (context == Qt::ApplicationShortcut) | - | 
| 153 |         return QApplicationPrivate::tryModalHelper(w, 0);  | - | 
| 154 |  | - | 
| 155 |     if (context == Qt::WidgetShortcut) | - | 
| 156 |         return w == QApplication::focusWidget(); | - | 
| 157 |  | - | 
| 158 |     if (context == Qt::WidgetWithChildrenShortcut) { | - | 
| 159 |         const QWidget *tw = QApplication::focusWidget(); | - | 
| 160 |         while (tw && tw != w && (tw->windowType() == Qt::Widget || tw->windowType() == Qt::Popup || tw->windowType() == Qt::SubWindow)) | - | 
| 161 |             tw = tw->parentWidget(); | - | 
| 162 |         return tw == w; | - | 
| 163 |     } | - | 
| 164 |  | - | 
| 165 |      | - | 
| 166 |     QWidget *tlw = w->window(); | - | 
| 167 | #ifndef QT_NO_GRAPHICSVIEW | - | 
| 168 |     if (QWExtra *topData = static_cast<QWidgetPrivate *>(QObjectPrivate::get(tlw))->extra) { | - | 
| 169 |         if (topData->proxyWidget) { | - | 
| 170 |             bool res = correctGraphicsWidgetContext(context, (QGraphicsWidget *)topData->proxyWidget, active_window); | - | 
| 171 |             return res; | - | 
| 172 |         } | - | 
| 173 |     } | - | 
| 174 | #endif | - | 
| 175 |  | - | 
| 176 |      | - | 
| 177 |  | - | 
| 178 |     if (active_window != tlw && active_window && active_window->windowType() == Qt::Tool && active_window->parentWidget()) { | - | 
| 179 |         active_window = active_window->parentWidget()->window(); | - | 
| 180 |     } | - | 
| 181 |  | - | 
| 182 |     if (active_window  != tlw) | - | 
| 183 |         return false; | - | 
| 184 |  | - | 
| 185 |      | - | 
| 186 |  | - | 
| 187 |     const QWidget* sw = w; | - | 
| 188 |     while (sw && !(sw->windowType() == Qt::SubWindow) && !sw->isWindow()) | - | 
| 189 |         sw = sw->parentWidget(); | - | 
| 190 |     if (sw && (sw->windowType() == Qt::SubWindow)) { | - | 
| 191 |         QWidget *focus_widget = QApplication::focusWidget(); | - | 
| 192 |         while (focus_widget && focus_widget != sw) | - | 
| 193 |             focus_widget = focus_widget->parentWidget(); | - | 
| 194 |         return sw == focus_widget; | - | 
| 195 |     } | - | 
| 196 |  | - | 
| 197 | #if defined(DEBUG_QSHORTCUTMAP) | - | 
| 198 |     qDebug().nospace() << "..true [Pass-through]"; | - | 
| 199 | #endif | - | 
| 200 |     return true; | - | 
| 201 | } | - | 
| 202 |  | - | 
| 203 | #ifndef QT_NO_GRAPHICSVIEW | - | 
| 204 | static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsWidget *w, QWidget *active_window) | - | 
| 205 | { | - | 
| 206 |     bool visible = w->isVisible(); | - | 
| 207 | #ifdef Q_OS_MAC | - | 
| 208 |     if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w)) | - | 
| 209 |         visible = true; | - | 
| 210 | #endif | - | 
| 211 |  | - | 
| 212 |     if (!visible || !w->isEnabled() || !w->scene()) | - | 
| 213 |         return false; | - | 
| 214 |  | - | 
| 215 |     if (context == Qt::ApplicationShortcut) { | - | 
| 216 |          | - | 
| 217 |          | - | 
| 218 |          | - | 
| 219 |         QList<QGraphicsView *> views = w->scene()->views(); | - | 
| 220 |         for (int i = 0; i < views.size(); ++i) { | - | 
| 221 |             if (QApplicationPrivate::tryModalHelper(views.at(i), 0)) | - | 
| 222 |                 return true; | - | 
| 223 |         } | - | 
| 224 |         return false; | - | 
| 225 |     } | - | 
| 226 |  | - | 
| 227 |     if (context == Qt::WidgetShortcut) | - | 
| 228 |         return static_cast<QGraphicsItem *>(w) == w->scene()->focusItem(); | - | 
| 229 |  | - | 
| 230 |     if (context == Qt::WidgetWithChildrenShortcut) { | - | 
| 231 |         const QGraphicsItem *ti = w->scene()->focusItem(); | - | 
| 232 |         if (ti && ti->isWidget()) { | - | 
| 233 |             const QGraphicsWidget *tw = static_cast<const QGraphicsWidget *>(ti); | - | 
| 234 |             while (tw && tw != w && (tw->windowType() == Qt::Widget || tw->windowType() == Qt::Popup)) | - | 
| 235 |                 tw = tw->parentWidget(); | - | 
| 236 |             return tw == w; | - | 
| 237 |         } | - | 
| 238 |         return false; | - | 
| 239 |     } | - | 
| 240 |  | - | 
| 241 |      | - | 
| 242 |  | - | 
| 243 |      | - | 
| 244 |     QList<QGraphicsView *> views = w->scene()->views(); | - | 
| 245 |     QGraphicsView *activeView = 0; | - | 
| 246 |     for (int i = 0; i < views.size(); ++i) { | - | 
| 247 |         QGraphicsView *view = views.at(i); | - | 
| 248 |         if (view->window() == active_window) { | - | 
| 249 |             activeView = view; | - | 
| 250 |             break; | - | 
| 251 |         } | - | 
| 252 |     } | - | 
| 253 |     if (!activeView) | - | 
| 254 |         return false; | - | 
| 255 |  | - | 
| 256 |      | - | 
| 257 |      | - | 
| 258 |     QGraphicsWidget *a = w->scene()->activeWindow(); | - | 
| 259 |     return !w->window() || a == w->window(); | - | 
| 260 | } | - | 
| 261 | #endif | - | 
| 262 |  | - | 
| 263 | #ifndef QT_NO_ACTION | - | 
| 264 | static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidget *active_window) | - | 
| 265 | { | - | 
| 266 |     const QList<QWidget *> &widgets = static_cast<QActionPrivate *>(QObjectPrivate::get(a))->widgets; | - | 
| 267 | #if defined(DEBUG_QSHORTCUTMAP) | - | 
| 268 |     if (widgets.isEmpty()) | - | 
| 269 |         qDebug() << a << "not connected to any widgets; won't trigger"; | - | 
| 270 | #endif | - | 
| 271 |     for (int i = 0; i < widgets.size(); ++i) { | - | 
| 272 |         QWidget *w = widgets.at(i); | - | 
| 273 | #ifndef QT_NO_MENU | - | 
| 274 |         if (QMenu *menu = qobject_cast<QMenu *>(w)) { | - | 
| 275 | #ifdef Q_OS_MAC | - | 
| 276 |              | - | 
| 277 |              | - | 
| 278 |              | - | 
| 279 |              | - | 
| 280 |              | - | 
| 281 |              | - | 
| 282 |              | - | 
| 283 |              | - | 
| 284 |             QPlatformMenu *pm = menu->platformMenu(); | - | 
| 285 |             if (!pm || !pm->isEnabled()) | - | 
| 286 |                 continue; | - | 
| 287 | #endif | - | 
| 288 |             QAction *a = menu->menuAction(); | - | 
| 289 |             if (correctActionContext(context, a, active_window)) | - | 
| 290 |                 return true; | - | 
| 291 |         } else | - | 
| 292 | #endif | - | 
| 293 |             if (correctWidgetContext(context, w, active_window)) | - | 
| 294 |                 return true; | - | 
| 295 |     } | - | 
| 296 |  | - | 
| 297 | #ifndef QT_NO_GRAPHICSVIEW | - | 
| 298 |     const QList<QGraphicsWidget *> &graphicsWidgets = static_cast<QActionPrivate *>(QObjectPrivate::get(a))->graphicsWidgets; | - | 
| 299 | #if defined(DEBUG_QSHORTCUTMAP) | - | 
| 300 |     if (graphicsWidgets.isEmpty()) | - | 
| 301 |         qDebug() << a << "not connected to any widgets; won't trigger"; | - | 
| 302 | #endif | - | 
| 303 |     for (int i = 0; i < graphicsWidgets.size(); ++i) { | - | 
| 304 |         QGraphicsWidget *w = graphicsWidgets.at(i); | - | 
| 305 |         if (correctGraphicsWidgetContext(context, w, active_window)) | - | 
| 306 |             return true; | - | 
| 307 |     } | - | 
| 308 | #endif | - | 
| 309 |     return false; | - | 
| 310 | } | - | 
| 311 | #endif // QT_NO_ACTION | - | 
| 312 |  | - | 
| 313 |  | - | 
| 314 |  | - | 
| 315 |  | - | 
| 316 |  | - | 
| 317 |  | - | 
| 318 |  | - | 
| 319 |  | - | 
| 320 |  | - | 
| 321 |  | - | 
| 322 |  | - | 
| 323 |  | - | 
| 324 |  | - | 
| 325 |  | - | 
| 326 |  | - | 
| 327 |  | - | 
| 328 |  | - | 
| 329 |  | - | 
| 330 |  | - | 
| 331 |  | - | 
| 332 |  | - | 
| 333 |  | - | 
| 334 |  | - | 
| 335 |  | - | 
| 336 |  | - | 
| 337 |  | - | 
| 338 |  | - | 
| 339 |  | - | 
| 340 |  | - | 
| 341 |  | - | 
| 342 |  | - | 
| 343 |  | - | 
| 344 |  | - | 
| 345 |  | - | 
| 346 |  | - | 
| 347 |  | - | 
| 348 |  | - | 
| 349 |  | - | 
| 350 |  | - | 
| 351 |  | - | 
| 352 |  | - | 
| 353 |  | - | 
| 354 |  | - | 
| 355 |  | - | 
| 356 |  | - | 
| 357 |  | - | 
| 358 |  | - | 
| 359 |  | - | 
| 360 |  | - | 
| 361 |  | - | 
| 362 |  | - | 
| 363 |  | - | 
| 364 |  | - | 
| 365 |  | - | 
| 366 |  | - | 
| 367 |  | - | 
| 368 |  | - | 
| 369 |  | - | 
| 370 |  | - | 
| 371 |  | - | 
| 372 |  | - | 
| 373 |  | - | 
| 374 |  | - | 
| 375 |  | - | 
| 376 |  | - | 
| 377 |  | - | 
| 378 |  | - | 
| 379 |  | - | 
| 380 |  | - | 
| 381 |  | - | 
| 382 |  | - | 
| 383 |  | - | 
| 384 |  | - | 
| 385 |  | - | 
| 386 |  | - | 
| 387 |  | - | 
| 388 |  | - | 
| 389 |  | - | 
| 390 |  | - | 
| 391 |  | - | 
| 392 |  | - | 
| 393 |  | - | 
| 394 |  | - | 
| 395 |  | - | 
| 396 |  | - | 
| 397 |  | - | 
| 398 |  | - | 
| 399 |  | - | 
| 400 |  | - | 
| 401 |  | - | 
| 402 | class QShortcutPrivate : public QObjectPrivate | - | 
| 403 | { | - | 
| 404 |     Q_DECLARE_PUBLIC(QShortcut) | - | 
| 405 | public: | - | 
| 406 |     QShortcutPrivate() : sc_context(Qt::WindowShortcut), sc_enabled(true), sc_autorepeat(true), sc_id(0) {} | - | 
| 407 |     QKeySequence sc_sequence; | - | 
| 408 |     Qt::ShortcutContext sc_context; | - | 
| 409 |     bool sc_enabled; | - | 
| 410 |     bool sc_autorepeat; | - | 
| 411 |     int sc_id; | - | 
| 412 |     QString sc_whatsthis; | - | 
| 413 |     void redoGrab(QShortcutMap &map); | - | 
| 414 | }; | - | 
| 415 |  | - | 
| 416 | void QShortcutPrivate::redoGrab(QShortcutMap &map) | - | 
| 417 | { | - | 
| 418 |     Q_Q(QShortcut); | - | 
| 419 |     if (Q_UNLIKELY(!parent))) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 420 |         qWarning("QShortcut: No widget parent defined"); | - | 
| 421 |         return; never executed: return;  | 0 | 
| 422 |     } | - | 
| 423 |  | - | 
| 424 |     if (sc_id)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 425 |         map.removeShortcut(sc_id, q); never executed: map.removeShortcut(sc_id, q);  | 0 | 
| 426 |     if (sc_sequence.isEmpty())| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 427 |         return; never executed: return;  | 0 | 
| 428 |     sc_id = map.addShortcut(q, sc_sequence, sc_context, qWidgetShortcutContextMatcher); | - | 
| 429 |     if (!sc_enabled)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 430 |         map.setShortcutEnabled(false, sc_id, q); never executed: map.setShortcutEnabled(false, sc_id, q);  | 0 | 
| 431 |     if (!sc_autorepeat)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 432 |         map.setShortcutAutoRepeat(false, sc_id, q); never executed: map.setShortcutAutoRepeat(false, sc_id, q);  | 0 | 
| 433 | } never executed: end of block  | 0 | 
| 434 |  | - | 
| 435 |  | - | 
| 436 |  | - | 
| 437 |  | - | 
| 438 |  | - | 
| 439 |  | - | 
| 440 |  | - | 
| 441 |  | - | 
| 442 | QShortcut::QShortcut(QWidget *parent) | - | 
| 443 |     : QObject(*new QShortcutPrivate, parent) | - | 
| 444 | { | - | 
| 445 |     Q_ASSERT(parent != 0); | - | 
| 446 | } | - | 
| 447 |  | - | 
| 448 |  | - | 
| 449 |  | - | 
| 450 |  | - | 
| 451 |  | - | 
| 452 |  | - | 
| 453 |  | - | 
| 454 |  | - | 
| 455 |  | - | 
| 456 | QShortcut::QShortcut(const QKeySequence &key, QWidget *parent, | - | 
| 457 |                      const char *member, const char *ambiguousMember, | - | 
| 458 |                      Qt::ShortcutContext context) | - | 
| 459 |     : QObject(*new QShortcutPrivate, parent) | - | 
| 460 | { | - | 
| 461 |     QAPP_CHECK("QShortcut"); | - | 
| 462 |  | - | 
| 463 |     Q_D(QShortcut); | - | 
| 464 |     Q_ASSERT(parent != 0); | - | 
| 465 |     d->sc_context = context; | - | 
| 466 |     d->sc_sequence = key; | - | 
| 467 |     d->redoGrab(qApp->d_func()->shortcutMap); | - | 
| 468 |     if (member) | - | 
| 469 |         connect(this, SIGNAL(activated()), parent, member); | - | 
| 470 |     if (ambiguousMember) | - | 
| 471 |         connect(this, SIGNAL(activatedAmbiguously()), parent, ambiguousMember); | - | 
| 472 | } | - | 
| 473 |  | - | 
| 474 |  | - | 
| 475 |  | - | 
| 476 |  | - | 
| 477 | QShortcut::~QShortcut() | - | 
| 478 | { | - | 
| 479 |     Q_D(QShortcut); | - | 
| 480 |     if (qApp) | - | 
| 481 |         qApp->d_func()->shortcutMap.removeShortcut(d->sc_id, this); | - | 
| 482 | } | - | 
| 483 |  | - | 
| 484 |  | - | 
| 485 |  | - | 
| 486 |  | - | 
| 487 |  | - | 
| 488 |  | - | 
| 489 |  | - | 
| 490 |  | - | 
| 491 |  | - | 
| 492 |  | - | 
| 493 |  | - | 
| 494 |  | - | 
| 495 | void QShortcut::setKey(const QKeySequence &key) | - | 
| 496 | { | - | 
| 497 |     Q_D(QShortcut); | - | 
| 498 |     if (d->sc_sequence == key) | - | 
| 499 |         return; | - | 
| 500 |     QAPP_CHECK("setKey"); | - | 
| 501 |     d->sc_sequence = key; | - | 
| 502 |     d->redoGrab(qApp->d_func()->shortcutMap); | - | 
| 503 | } | - | 
| 504 |  | - | 
| 505 | QKeySequence QShortcut::key() const | - | 
| 506 | { | - | 
| 507 |     Q_D(const QShortcut); | - | 
| 508 |     return d->sc_sequence; | - | 
| 509 | } | - | 
| 510 |  | - | 
| 511 |  | - | 
| 512 |  | - | 
| 513 |  | - | 
| 514 |  | - | 
| 515 |  | - | 
| 516 |  | - | 
| 517 |  | - | 
| 518 |  | - | 
| 519 |  | - | 
| 520 |  | - | 
| 521 |  | - | 
| 522 |  | - | 
| 523 |  | - | 
| 524 |  | - | 
| 525 |  | - | 
| 526 | void QShortcut::setEnabled(bool enable) | - | 
| 527 | { | - | 
| 528 |     Q_D(QShortcut); | - | 
| 529 |     if (d->sc_enabled == enable) | - | 
| 530 |         return; | - | 
| 531 |     QAPP_CHECK("setEnabled"); | - | 
| 532 |     d->sc_enabled = enable; | - | 
| 533 |     qApp->d_func()->shortcutMap.setShortcutEnabled(enable, d->sc_id, this); | - | 
| 534 | } | - | 
| 535 |  | - | 
| 536 | bool QShortcut::isEnabled() const | - | 
| 537 | { | - | 
| 538 |     Q_D(const QShortcut); | - | 
| 539 |     return d->sc_enabled; | - | 
| 540 | } | - | 
| 541 |  | - | 
| 542 |  | - | 
| 543 |  | - | 
| 544 |  | - | 
| 545 |  | - | 
| 546 |  | - | 
| 547 |  | - | 
| 548 |  | - | 
| 549 |  | - | 
| 550 |  | - | 
| 551 |  | - | 
| 552 |  | - | 
| 553 |  | - | 
| 554 | void QShortcut::setContext(Qt::ShortcutContext context) | - | 
| 555 | { | - | 
| 556 |     Q_D(QShortcut); | - | 
| 557 |     if(d->sc_context == context) | - | 
| 558 |         return; | - | 
| 559 |     QAPP_CHECK("setContext"); | - | 
| 560 |     d->sc_context = context; | - | 
| 561 |     d->redoGrab(qApp->d_func()->shortcutMap); | - | 
| 562 | } | - | 
| 563 |  | - | 
| 564 | Qt::ShortcutContext QShortcut::context() const | - | 
| 565 | { | - | 
| 566 |     Q_D(const QShortcut); | - | 
| 567 |     return d->sc_context; | - | 
| 568 | } | - | 
| 569 |  | - | 
| 570 |  | - | 
| 571 |  | - | 
| 572 |  | - | 
| 573 |  | - | 
| 574 |  | - | 
| 575 |  | - | 
| 576 |  | - | 
| 577 |  | - | 
| 578 |  | - | 
| 579 |  | - | 
| 580 |  | - | 
| 581 |  | - | 
| 582 |  | - | 
| 583 |  | - | 
| 584 | void QShortcut::setWhatsThis(const QString &text) | - | 
| 585 | { | - | 
| 586 |     Q_D(QShortcut); | - | 
| 587 |     d->sc_whatsthis = text; | - | 
| 588 | } | - | 
| 589 |  | - | 
| 590 | QString QShortcut::whatsThis() const | - | 
| 591 | { | - | 
| 592 |     Q_D(const QShortcut); | - | 
| 593 |     return d->sc_whatsthis; | - | 
| 594 | } | - | 
| 595 |  | - | 
| 596 |  | - | 
| 597 |  | - | 
| 598 |  | - | 
| 599 |  | - | 
| 600 |  | - | 
| 601 |  | - | 
| 602 |  | - | 
| 603 |  | - | 
| 604 |  | - | 
| 605 |  | - | 
| 606 | void QShortcut::setAutoRepeat(bool on) | - | 
| 607 | { | - | 
| 608 |     Q_D(QShortcut); | - | 
| 609 |     if (d->sc_autorepeat == on) | - | 
| 610 |         return; | - | 
| 611 |     QAPP_CHECK("setAutoRepeat"); | - | 
| 612 |     d->sc_autorepeat = on; | - | 
| 613 |     qApp->d_func()->shortcutMap.setShortcutAutoRepeat(on, d->sc_id, this); | - | 
| 614 | } | - | 
| 615 |  | - | 
| 616 | bool QShortcut::autoRepeat() const | - | 
| 617 | { | - | 
| 618 |     Q_D(const QShortcut); | - | 
| 619 |     return d->sc_autorepeat; | - | 
| 620 | } | - | 
| 621 |  | - | 
| 622 |  | - | 
| 623 |  | - | 
| 624 |  | - | 
| 625 |  | - | 
| 626 |  | - | 
| 627 | int QShortcut::id() const | - | 
| 628 | { | - | 
| 629 |     Q_D(const QShortcut); | - | 
| 630 |     return d->sc_id; | - | 
| 631 | } | - | 
| 632 |  | - | 
| 633 |  | - | 
| 634 |  | - | 
| 635 |  | - | 
| 636 | bool QShortcut::event(QEvent *e) | - | 
| 637 | { | - | 
| 638 |     Q_D(QShortcut); | - | 
| 639 |     bool handled = false; | - | 
| 640 |     if (d->sc_enabled && e->type() == QEvent::Shortcut) { | - | 
| 641 |         QShortcutEvent *se = static_cast<QShortcutEvent *>(e); | - | 
| 642 |         if (se->shortcutId() == d->sc_id && se->key() == d->sc_sequence){ | - | 
| 643 | #ifndef QT_NO_WHATSTHIS | - | 
| 644 |             if (QWhatsThis::inWhatsThisMode()) { | - | 
| 645 |                 QWhatsThis::showText(QCursor::pos(), d->sc_whatsthis); | - | 
| 646 |                 handled = true; | - | 
| 647 |             } else | - | 
| 648 | #endif | - | 
| 649 |             if (se->isAmbiguous()) | - | 
| 650 |                 emit activatedAmbiguously(); | - | 
| 651 |             else | - | 
| 652 |                 emit activated(); | - | 
| 653 |             handled = true; | - | 
| 654 |         } | - | 
| 655 |     } | - | 
| 656 |     return handled; | - | 
| 657 | } | - | 
| 658 | #endif // QT_NO_SHORTCUT | - | 
| 659 |  | - | 
| 660 | QT_END_NAMESPACE | - | 
| 661 |  | - | 
| 662 | #include "moc_qshortcut.cpp" | - | 
 |  |  |