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