| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qshortcut.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||
| 5 | static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window); | - | ||||||||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||||||||
| 7 | static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsWidget *w, QWidget *active_window); | - | ||||||||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||||||||
| 10 | static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidget *active_window); | - | ||||||||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||||||||
| 16 | - | |||||||||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||||||||
| 18 | bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context) | - | ||||||||||||||||||||||||||||||
| 19 | { | - | ||||||||||||||||||||||||||||||
| 20 | ((!(object)) ? qt_assert_x("QShortcutMap", "Shortcut has no owner. Illegal map state!",__FILE__,73) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||||||||
| 22 | QWidget *active_window = QApplication::activeWindow(); | - | ||||||||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||||||||
| 26 | - | |||||||||||||||||||||||||||||||
| 27 | if (QApplication::activePopupWidget()
| 0 | ||||||||||||||||||||||||||||||
| 28 | active_window = QApplication::activePopupWidget(); never executed: active_window = QApplication::activePopupWidget(); | 0 | ||||||||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||||||||
| 30 | if (!active_window
| 0 | ||||||||||||||||||||||||||||||
| 31 | QWindow *qwindow = QGuiApplication::focusWindow(); | - | ||||||||||||||||||||||||||||||
| 32 | if (qwindow
| 0 | ||||||||||||||||||||||||||||||
| 33 | while (qwindow
| 0 | ||||||||||||||||||||||||||||||
| 34 | QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(qwindow); | - | ||||||||||||||||||||||||||||||
| 35 | if (widgetWindow
| 0 | ||||||||||||||||||||||||||||||
| 36 | active_window = widgetWindow->widget(); | - | ||||||||||||||||||||||||||||||
| 37 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 38 | } | - | ||||||||||||||||||||||||||||||
| 39 | qwindow = qwindow->parent(); | - | ||||||||||||||||||||||||||||||
| 40 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 41 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 42 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||||||||
| 44 | if (!active_window
| 0 | ||||||||||||||||||||||||||||||
| 45 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||||||||
| 48 | if (QAction *a = qobject_cast<QAction *>(object)
| 0 | ||||||||||||||||||||||||||||||
| 49 | return never executed: correctActionContext(context, a, active_window);return correctActionContext(context, a, active_window);never executed: return correctActionContext(context, a, active_window); | 0 | ||||||||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||||||||
| 53 | if (QGraphicsWidget *gw = qobject_cast<QGraphicsWidget *>(object)
| 0 | ||||||||||||||||||||||||||||||
| 54 | return never executed: correctGraphicsWidgetContext(context, gw, active_window);return correctGraphicsWidgetContext(context, gw, active_window);never executed: return correctGraphicsWidgetContext(context, gw, active_window); | 0 | ||||||||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||||||||
| 57 | QWidget *w = qobject_cast<QWidget *>(object); | - | ||||||||||||||||||||||||||||||
| 58 | if (!w
| 0 | ||||||||||||||||||||||||||||||
| 59 | QShortcut *s = qobject_cast<QShortcut *>(object); | - | ||||||||||||||||||||||||||||||
| 60 | if (s
| 0 | ||||||||||||||||||||||||||||||
| 61 | w = s->parentWidget(); never executed: w = s->parentWidget(); | 0 | ||||||||||||||||||||||||||||||
| 62 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||||||||
| 64 | if (!w
| 0 | ||||||||||||||||||||||||||||||
| 65 | QWindow *qwindow = qobject_cast<QWindow *>(object); | - | ||||||||||||||||||||||||||||||
| 66 | while (qwindow
| 0 | ||||||||||||||||||||||||||||||
| 67 | QWidgetWindow *widget_window = qobject_cast<QWidgetWindow *>(qwindow); | - | ||||||||||||||||||||||||||||||
| 68 | if (widget_window
| 0 | ||||||||||||||||||||||||||||||
| 69 | w = widget_window->widget(); | - | ||||||||||||||||||||||||||||||
| 70 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 71 | } | - | ||||||||||||||||||||||||||||||
| 72 | qwindow = qwindow->parent(); | - | ||||||||||||||||||||||||||||||
| 73 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 74 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 75 | - | |||||||||||||||||||||||||||||||
| 76 | if (!w
| 0 | ||||||||||||||||||||||||||||||
| 77 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||||||||
| 79 | return never executed: correctWidgetContext(context, w, active_window);return correctWidgetContext(context, w, active_window);never executed: return correctWidgetContext(context, w, active_window); | 0 | ||||||||||||||||||||||||||||||
| 80 | } | - | ||||||||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||||||||
| 82 | static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window) | - | ||||||||||||||||||||||||||||||
| 83 | { | - | ||||||||||||||||||||||||||||||
| 84 | bool visible = w->isVisible(); | - | ||||||||||||||||||||||||||||||
| 85 | - | |||||||||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||||||||
| 90 | if (!visible
| 0 | ||||||||||||||||||||||||||||||
| 91 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 92 | - | |||||||||||||||||||||||||||||||
| 93 | if (context == Qt::ApplicationShortcut
| 0 | ||||||||||||||||||||||||||||||
| 94 | return never executed: QApplicationPrivate::tryModalHelper(w, 0);return QApplicationPrivate::tryModalHelper(w, 0);never executed: return QApplicationPrivate::tryModalHelper(w, 0); | 0 | ||||||||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||||||||
| 96 | if (context == Qt::WidgetShortcut
| 0 | ||||||||||||||||||||||||||||||
| 97 | return never executed: w == QApplication::focusWidget();return w == QApplication::focusWidget();never executed: return w == QApplication::focusWidget(); | 0 | ||||||||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||||||||
| 99 | if (context == Qt::WidgetWithChildrenShortcut
| 0 | ||||||||||||||||||||||||||||||
| 100 | const QWidget *tw = QApplication::focusWidget(); | - | ||||||||||||||||||||||||||||||
| 101 | while (tw
| 0 | ||||||||||||||||||||||||||||||
| 102 | tw = tw->parentWidget(); never executed: tw = tw->parentWidget(); | 0 | ||||||||||||||||||||||||||||||
| 103 | return never executed: tw == w;return tw == w;never executed: return tw == w; | 0 | ||||||||||||||||||||||||||||||
| 104 | } | - | ||||||||||||||||||||||||||||||
| 105 | - | |||||||||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||||||||
| 107 | QWidget *tlw = w->window(); | - | ||||||||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||||||||
| 109 | if (QWExtra *topData = static_cast<QWidgetPrivate *>(QObjectPrivate::get(tlw))->extra
| 0 | ||||||||||||||||||||||||||||||
| 110 | if (topData->proxyWidget
| 0 | ||||||||||||||||||||||||||||||
| 111 | bool res = correctGraphicsWidgetContext(context, (QGraphicsWidget *)topData->proxyWidget, active_window); | - | ||||||||||||||||||||||||||||||
| 112 | return never executed: res;return res;never executed: return res; | 0 | ||||||||||||||||||||||||||||||
| 113 | } | - | ||||||||||||||||||||||||||||||
| 114 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||||||||
| 119 | if (active_window != tlw
| 0 | ||||||||||||||||||||||||||||||
| 120 | active_window = active_window->parentWidget()->window(); | - | ||||||||||||||||||||||||||||||
| 121 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||||||||
| 123 | if (active_window != tlw
| 0 | ||||||||||||||||||||||||||||||
| 124 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||||||||
| 128 | const QWidget* sw = w; | - | ||||||||||||||||||||||||||||||
| 129 | while (sw
| 0 | ||||||||||||||||||||||||||||||
| 130 | sw = sw->parentWidget(); never executed: sw = sw->parentWidget(); | 0 | ||||||||||||||||||||||||||||||
| 131 | if (sw
| 0 | ||||||||||||||||||||||||||||||
| 132 | QWidget *focus_widget = QApplication::focusWidget(); | - | ||||||||||||||||||||||||||||||
| 133 | while (focus_widget
| 0 | ||||||||||||||||||||||||||||||
| 134 | focus_widget = focus_widget->parentWidget(); never executed: focus_widget = focus_widget->parentWidget(); | 0 | ||||||||||||||||||||||||||||||
| 135 | return never executed: sw == focus_widget;return sw == focus_widget;never executed: return sw == focus_widget; | 0 | ||||||||||||||||||||||||||||||
| 136 | } | - | ||||||||||||||||||||||||||||||
| 137 | - | |||||||||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||||||||
| 141 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 142 | } | - | ||||||||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||||||||
| 145 | static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsWidget *w, QWidget *active_window) | - | ||||||||||||||||||||||||||||||
| 146 | { | - | ||||||||||||||||||||||||||||||
| 147 | bool visible = w->isVisible(); | - | ||||||||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||||||||
| 151 | - | |||||||||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||||||||
| 153 | if (!visible
| 0 | ||||||||||||||||||||||||||||||
| 154 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||||||||
| 156 | if (context == Qt::ApplicationShortcut
| 0 | ||||||||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||||||||
| 160 | QList<QGraphicsView *> views = w->scene()->views(); | - | ||||||||||||||||||||||||||||||
| 161 | for (int i = 0; i < views.size()
| 0 | ||||||||||||||||||||||||||||||
| 162 | if (QApplicationPrivate::tryModalHelper(views.at(i), 0)
| 0 | ||||||||||||||||||||||||||||||
| 163 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 164 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 165 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 166 | } | - | ||||||||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||||||||
| 168 | if (context == Qt::WidgetShortcut
| 0 | ||||||||||||||||||||||||||||||
| 169 | return never executed: static_cast<QGraphicsItem *>(w) == w->scene()->focusItem();return static_cast<QGraphicsItem *>(w) == w->scene()->focusItem();never executed: return static_cast<QGraphicsItem *>(w) == w->scene()->focusItem(); | 0 | ||||||||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||||||||
| 171 | if (context == Qt::WidgetWithChildrenShortcut
| 0 | ||||||||||||||||||||||||||||||
| 172 | const QGraphicsItem *ti = w->scene()->focusItem(); | - | ||||||||||||||||||||||||||||||
| 173 | if (ti
| 0 | ||||||||||||||||||||||||||||||
| 174 | const QGraphicsWidget *tw = static_cast<const QGraphicsWidget *>(ti); | - | ||||||||||||||||||||||||||||||
| 175 | while (tw
| 0 | ||||||||||||||||||||||||||||||
| 176 | tw = tw->parentWidget(); never executed: tw = tw->parentWidget(); | 0 | ||||||||||||||||||||||||||||||
| 177 | return never executed: tw == w;return tw == w;never executed: return tw == w; | 0 | ||||||||||||||||||||||||||||||
| 178 | } | - | ||||||||||||||||||||||||||||||
| 179 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 180 | } | - | ||||||||||||||||||||||||||||||
| 181 | - | |||||||||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||||||||
| 183 | - | |||||||||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||||||||
| 185 | QList<QGraphicsView *> views = w->scene()->views(); | - | ||||||||||||||||||||||||||||||
| 186 | QGraphicsView *activeView = 0; | - | ||||||||||||||||||||||||||||||
| 187 | for (int i = 0; i < views.size()
| 0 | ||||||||||||||||||||||||||||||
| 188 | QGraphicsView *view = views.at(i); | - | ||||||||||||||||||||||||||||||
| 189 | if (view->window() == active_window
| 0 | ||||||||||||||||||||||||||||||
| 190 | activeView = view; | - | ||||||||||||||||||||||||||||||
| 191 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 192 | } | - | ||||||||||||||||||||||||||||||
| 193 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 194 | if (!activeView
| 0 | ||||||||||||||||||||||||||||||
| 195 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 196 | - | |||||||||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||||||||
| 198 | - | |||||||||||||||||||||||||||||||
| 199 | QGraphicsWidget *a = w->scene()->activeWindow(); | - | ||||||||||||||||||||||||||||||
| 200 | return never executed: !w->window()return !w->window() || a == w->window();
never executed: return !w->window() || a == w->window(); | 0 | ||||||||||||||||||||||||||||||
| 201 | } | - | ||||||||||||||||||||||||||||||
| 202 | - | |||||||||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||||||||
| 204 | - | |||||||||||||||||||||||||||||||
| 205 | static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidget *active_window) | - | ||||||||||||||||||||||||||||||
| 206 | { | - | ||||||||||||||||||||||||||||||
| 207 | const QList<QWidget *> &widgets = static_cast<QActionPrivate *>(QObjectPrivate::get(a))->widgets; | - | ||||||||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||||||||
| 209 | - | |||||||||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||||||||
| 212 | for (int i = 0; i < widgets.size()
| 0 | ||||||||||||||||||||||||||||||
| 213 | QWidget *w = widgets.at(i); | - | ||||||||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||||||||
| 215 | if (QMenu *menu = qobject_cast<QMenu *>(w)
| 0 | ||||||||||||||||||||||||||||||
| 216 | QAction *a = menu->menuAction(); | - | ||||||||||||||||||||||||||||||
| 217 | if (correctActionContext(context, a, active_window)
| 0 | ||||||||||||||||||||||||||||||
| 218 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 219 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||||||||
| 221 | if (correctWidgetContext(context, w, active_window)
| 0 | ||||||||||||||||||||||||||||||
| 222 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 223 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||||||||
| 225 | - | |||||||||||||||||||||||||||||||
| 226 | const QList<QGraphicsWidget *> &graphicsWidgets = static_cast<QActionPrivate *>(QObjectPrivate::get(a))->graphicsWidgets; | - | ||||||||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||||||||
| 230 | - | |||||||||||||||||||||||||||||||
| 231 | for (int i = 0; i < graphicsWidgets.size()
| 0 | ||||||||||||||||||||||||||||||
| 232 | QGraphicsWidget *w = graphicsWidgets.at(i); | - | ||||||||||||||||||||||||||||||
| 233 | if (correctGraphicsWidgetContext(context, w, active_window)
| 0 | ||||||||||||||||||||||||||||||
| 234 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 235 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||||||||
| 237 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 238 | } | - | ||||||||||||||||||||||||||||||
| 239 | class QShortcutPrivate : public QObjectPrivate | - | ||||||||||||||||||||||||||||||
| 240 | { | - | ||||||||||||||||||||||||||||||
| 241 | inline QShortcut* q_func() { return static_cast<QShortcut *>(q_ptr); } inline const QShortcut* q_func() const { return static_cast<const QShortcut *>(q_ptr); } friend class QShortcut; | - | ||||||||||||||||||||||||||||||
| 242 | public: | - | ||||||||||||||||||||||||||||||
| 243 | QShortcutPrivate() : sc_context(Qt::WindowShortcut), sc_enabled(true), sc_autorepeat(true), sc_id(0) {} never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 244 | QKeySequence sc_sequence; | - | ||||||||||||||||||||||||||||||
| 245 | Qt::ShortcutContext sc_context; | - | ||||||||||||||||||||||||||||||
| 246 | bool sc_enabled; | - | ||||||||||||||||||||||||||||||
| 247 | bool sc_autorepeat; | - | ||||||||||||||||||||||||||||||
| 248 | int sc_id; | - | ||||||||||||||||||||||||||||||
| 249 | QString sc_whatsthis; | - | ||||||||||||||||||||||||||||||
| 250 | void redoGrab(QShortcutMap &map); | - | ||||||||||||||||||||||||||||||
| 251 | }; | - | ||||||||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||||||||
| 253 | void QShortcutPrivate::redoGrab(QShortcutMap &map) | - | ||||||||||||||||||||||||||||||
| 254 | { | - | ||||||||||||||||||||||||||||||
| 255 | QShortcut * const q = q_func(); | - | ||||||||||||||||||||||||||||||
| 256 | if (!parent
| 0 | ||||||||||||||||||||||||||||||
| 257 | QMessageLogger(__FILE__, 414, __PRETTY_FUNCTION__).warning("QShortcut: No widget parent defined"); | - | ||||||||||||||||||||||||||||||
| 258 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 259 | } | - | ||||||||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||||||||
| 261 | if (sc_id
| 0 | ||||||||||||||||||||||||||||||
| 262 | map.removeShortcut(sc_id, q); never executed: map.removeShortcut(sc_id, q); | 0 | ||||||||||||||||||||||||||||||
| 263 | if (sc_sequence.isEmpty()
| 0 | ||||||||||||||||||||||||||||||
| 264 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 265 | sc_id = map.addShortcut(q, sc_sequence, sc_context, qWidgetShortcutContextMatcher); | - | ||||||||||||||||||||||||||||||
| 266 | if (!sc_enabled
| 0 | ||||||||||||||||||||||||||||||
| 267 | map.setShortcutEnabled(false, sc_id, q); never executed: map.setShortcutEnabled(false, sc_id, q); | 0 | ||||||||||||||||||||||||||||||
| 268 | if (!sc_autorepeat
| 0 | ||||||||||||||||||||||||||||||
| 269 | map.setShortcutAutoRepeat(false, sc_id, q); never executed: map.setShortcutAutoRepeat(false, sc_id, q); | 0 | ||||||||||||||||||||||||||||||
| 270 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 271 | QShortcut::QShortcut(QWidget *parent) | - | ||||||||||||||||||||||||||||||
| 272 | : QObject(*new QShortcutPrivate, parent) | - | ||||||||||||||||||||||||||||||
| 273 | { | - | ||||||||||||||||||||||||||||||
| 274 | ((!(parent != 0)) ? qt_assert("parent != 0",__FILE__,439) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 275 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 276 | QShortcut::QShortcut(const QKeySequence &key, QWidget *parent, | - | ||||||||||||||||||||||||||||||
| 277 | const char *member, const char *ambiguousMember, | - | ||||||||||||||||||||||||||||||
| 278 | Qt::ShortcutContext context) | - | ||||||||||||||||||||||||||||||
| 279 | : QObject(*new QShortcutPrivate, parent) | - | ||||||||||||||||||||||||||||||
| 280 | { | - | ||||||||||||||||||||||||||||||
| 281 | if (!(static_cast<QApplication *>(QCoreApplication::instance()))
never executed: };return; | 0 | ||||||||||||||||||||||||||||||
| 282 | - | |||||||||||||||||||||||||||||||
| 283 | QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 284 | ((!(parent != 0)) ? qt_assert("parent != 0",__FILE__,458) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 285 | d->sc_context = context; | - | ||||||||||||||||||||||||||||||
| 286 | d->sc_sequence = key; | - | ||||||||||||||||||||||||||||||
| 287 | d->redoGrab((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - | ||||||||||||||||||||||||||||||
| 288 | if (member
| 0 | ||||||||||||||||||||||||||||||
| 289 | connect(this, qFlagLocation("2""activated()" "\0" __FILE__ ":" "463"), parent, member); never executed: connect(this, qFlagLocation("2""activated()" "\0" __FILE__ ":" "463"), parent, member); | 0 | ||||||||||||||||||||||||||||||
| 290 | if (ambiguousMember
| 0 | ||||||||||||||||||||||||||||||
| 291 | connect(this, qFlagLocation("2""activatedAmbiguously()" "\0" __FILE__ ":" "465"), parent, ambiguousMember); never executed: connect(this, qFlagLocation("2""activatedAmbiguously()" "\0" __FILE__ ":" "465"), parent, ambiguousMember); | 0 | ||||||||||||||||||||||||||||||
| 292 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||||||||
| 295 | - | |||||||||||||||||||||||||||||||
| 296 | - | |||||||||||||||||||||||||||||||
| 297 | QShortcut::~QShortcut() | - | ||||||||||||||||||||||||||||||
| 298 | { | - | ||||||||||||||||||||||||||||||
| 299 | QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 300 | if ((static_cast<
| 0 | ||||||||||||||||||||||||||||||
| 301 | (static_cast< never executed: QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(d->sc_id, this);(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(d->sc_id, this);never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(d->sc_id, this); | 0 | ||||||||||||||||||||||||||||||
| 302 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 303 | void QShortcut::setKey(const QKeySequence &key) | - | ||||||||||||||||||||||||||||||
| 304 | { | - | ||||||||||||||||||||||||||||||
| 305 | QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 306 | if (d->sc_sequence == key
| 0 | ||||||||||||||||||||||||||||||
| 307 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 308 | if (!(static_cast<QApplication *>(QCoreApplication::instance()))
never executed: };return; | 0 | ||||||||||||||||||||||||||||||
| 309 | d->sc_sequence = key; | - | ||||||||||||||||||||||||||||||
| 310 | d->redoGrab((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - | ||||||||||||||||||||||||||||||
| 311 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 312 | - | |||||||||||||||||||||||||||||||
| 313 | QKeySequence QShortcut::key() const | - | ||||||||||||||||||||||||||||||
| 314 | { | - | ||||||||||||||||||||||||||||||
| 315 | const QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 316 | return never executed: d->sc_sequence;return d->sc_sequence;never executed: return d->sc_sequence; | 0 | ||||||||||||||||||||||||||||||
| 317 | } | - | ||||||||||||||||||||||||||||||
| 318 | void QShortcut::setEnabled(bool enable) | - | ||||||||||||||||||||||||||||||
| 319 | { | - | ||||||||||||||||||||||||||||||
| 320 | QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 321 | if (d->sc_enabled == enable
| 0 | ||||||||||||||||||||||||||||||
| 322 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 323 | if (!(static_cast<QApplication *>(QCoreApplication::instance()))
never executed: };return; | 0 | ||||||||||||||||||||||||||||||
| 324 | d->sc_enabled = enable; | - | ||||||||||||||||||||||||||||||
| 325 | (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.setShortcutEnabled(enable, d->sc_id, this); | - | ||||||||||||||||||||||||||||||
| 326 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||||||||
| 328 | bool QShortcut::isEnabled() const | - | ||||||||||||||||||||||||||||||
| 329 | { | - | ||||||||||||||||||||||||||||||
| 330 | const QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 331 | return never executed: d->sc_enabled;return d->sc_enabled;never executed: return d->sc_enabled; | 0 | ||||||||||||||||||||||||||||||
| 332 | } | - | ||||||||||||||||||||||||||||||
| 333 | void QShortcut::setContext(Qt::ShortcutContext context) | - | ||||||||||||||||||||||||||||||
| 334 | { | - | ||||||||||||||||||||||||||||||
| 335 | QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 336 | if(d->sc_context == context
| 0 | ||||||||||||||||||||||||||||||
| 337 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 338 | if (!(static_cast<QApplication *>(QCoreApplication::instance()))
never executed: };return; | 0 | ||||||||||||||||||||||||||||||
| 339 | d->sc_context = context; | - | ||||||||||||||||||||||||||||||
| 340 | d->redoGrab((static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap); | - | ||||||||||||||||||||||||||||||
| 341 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 342 | - | |||||||||||||||||||||||||||||||
| 343 | Qt::ShortcutContext QShortcut::context() const | - | ||||||||||||||||||||||||||||||
| 344 | { | - | ||||||||||||||||||||||||||||||
| 345 | const QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 346 | return never executed: d->sc_context;return d->sc_context;never executed: return d->sc_context; | 0 | ||||||||||||||||||||||||||||||
| 347 | } | - | ||||||||||||||||||||||||||||||
| 348 | void QShortcut::setWhatsThis(const QString &text) | - | ||||||||||||||||||||||||||||||
| 349 | { | - | ||||||||||||||||||||||||||||||
| 350 | QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 351 | d->sc_whatsthis = text; | - | ||||||||||||||||||||||||||||||
| 352 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 353 | - | |||||||||||||||||||||||||||||||
| 354 | QString QShortcut::whatsThis() const | - | ||||||||||||||||||||||||||||||
| 355 | { | - | ||||||||||||||||||||||||||||||
| 356 | const QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 357 | return never executed: d->sc_whatsthis;return d->sc_whatsthis;never executed: return d->sc_whatsthis; | 0 | ||||||||||||||||||||||||||||||
| 358 | } | - | ||||||||||||||||||||||||||||||
| 359 | void QShortcut::setAutoRepeat(bool on) | - | ||||||||||||||||||||||||||||||
| 360 | { | - | ||||||||||||||||||||||||||||||
| 361 | QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 362 | if (d->sc_autorepeat == on
| 0 | ||||||||||||||||||||||||||||||
| 363 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 364 | if (!(static_cast<QApplication *>(QCoreApplication::instance()))
never executed: };return; | 0 | ||||||||||||||||||||||||||||||
| 365 | d->sc_autorepeat = on; | - | ||||||||||||||||||||||||||||||
| 366 | (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.setShortcutAutoRepeat(on, d->sc_id, this); | - | ||||||||||||||||||||||||||||||
| 367 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||||||||
| 369 | bool QShortcut::autoRepeat() const | - | ||||||||||||||||||||||||||||||
| 370 | { | - | ||||||||||||||||||||||||||||||
| 371 | const QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 372 | return never executed: d->sc_autorepeat;return d->sc_autorepeat;never executed: return d->sc_autorepeat; | 0 | ||||||||||||||||||||||||||||||
| 373 | } | - | ||||||||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||||||||
| 375 | - | |||||||||||||||||||||||||||||||
| 376 | - | |||||||||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||||||||
| 379 | - | |||||||||||||||||||||||||||||||
| 380 | int QShortcut::id() const | - | ||||||||||||||||||||||||||||||
| 381 | { | - | ||||||||||||||||||||||||||||||
| 382 | const QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 383 | return never executed: d->sc_id;return d->sc_id;never executed: return d->sc_id; | 0 | ||||||||||||||||||||||||||||||
| 384 | } | - | ||||||||||||||||||||||||||||||
| 385 | - | |||||||||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||||||||
| 387 | - | |||||||||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||||||||
| 389 | bool QShortcut::event(QEvent *e) | - | ||||||||||||||||||||||||||||||
| 390 | { | - | ||||||||||||||||||||||||||||||
| 391 | QShortcutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 392 | bool handled = false; | - | ||||||||||||||||||||||||||||||
| 393 | if (d->sc_enabled
| 0 | ||||||||||||||||||||||||||||||
| 394 | QShortcutEvent *se = static_cast<QShortcutEvent *>(e); | - | ||||||||||||||||||||||||||||||
| 395 | if (se->shortcutId() == d->sc_id
| 0 | ||||||||||||||||||||||||||||||
| 396 | - | |||||||||||||||||||||||||||||||
| 397 | if (QWhatsThis::inWhatsThisMode()
| 0 | ||||||||||||||||||||||||||||||
| 398 | QWhatsThis::showText(QCursor::pos(), d->sc_whatsthis); | - | ||||||||||||||||||||||||||||||
| 399 | handled = true; | - | ||||||||||||||||||||||||||||||
| 400 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||||||||
| 402 | if (se->isAmbiguous()
| 0 | ||||||||||||||||||||||||||||||
| 403 | activatedAmbiguously(); never executed: activatedAmbiguously(); | 0 | ||||||||||||||||||||||||||||||
| 404 | else | - | ||||||||||||||||||||||||||||||
| 405 | activated(); never executed: activated(); | 0 | ||||||||||||||||||||||||||||||
| 406 | handled = true; | - | ||||||||||||||||||||||||||||||
| 407 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 408 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 409 | return never executed: handled;return handled;never executed: return handled; | 0 | ||||||||||||||||||||||||||||||
| 410 | } | - | ||||||||||||||||||||||||||||||
| 411 | - | |||||||||||||||||||||||||||||||
| 412 | - | |||||||||||||||||||||||||||||||
| 413 | - | |||||||||||||||||||||||||||||||
| 414 | - | |||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |