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())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
87 | active_window = QApplication::activePopupWidget(); never executed: active_window = QApplication::activePopupWidget(); | 0 |
88 | | - |
89 | if (!active_window) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
90 | QWindow *qwindow = QGuiApplication::focusWindow(); | - |
91 | if (qwindow && qwindow->isActive()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
92 | while (qwindow) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
93 | QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(qwindow); | - |
94 | if (widgetWindow) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
95 | active_window = widgetWindow->widget(); | - |
96 | break; never executed: break; | 0 |
97 | } | - |
98 | qwindow = qwindow->parent(); | - |
99 | } never executed: end of block | 0 |
100 | } never executed: end of block | 0 |
101 | } never executed: end of block | 0 |
102 | | - |
103 | if (!active_window)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
104 | return false; never executed: return false; | 0 |
105 | | - |
106 | #ifndef QT_NO_ACTION | - |
107 | if (QAction *a = qobject_cast<QAction *>(object))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
108 | return correctActionContext(context, a, active_window); never executed: return correctActionContext(context, a, active_window); | 0 |
109 | #endif | - |
110 | | - |
111 | #ifndef QT_NO_GRAPHICSVIEW | - |
112 | if (QGraphicsWidget *gw = qobject_cast<QGraphicsWidget *>(object))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
113 | return correctGraphicsWidgetContext(context, gw, active_window); never executed: return correctGraphicsWidgetContext(context, gw, active_window); | 0 |
114 | #endif | - |
115 | | - |
116 | QWidget *w = qobject_cast<QWidget *>(object); | - |
117 | if (!w) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
118 | QShortcut *s = qobject_cast<QShortcut *>(object); | - |
119 | if (s)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
120 | w = s->parentWidget(); never executed: w = s->parentWidget(); | 0 |
121 | } never executed: end of block | 0 |
122 | | - |
123 | if (!w) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
124 | QWindow *qwindow = qobject_cast<QWindow *>(object); | - |
125 | while (qwindow) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
126 | QWidgetWindow *widget_window = qobject_cast<QWidgetWindow *>(qwindow); | - |
127 | if (widget_window) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
128 | w = widget_window->widget(); | - |
129 | break; never executed: break; | 0 |
130 | } | - |
131 | qwindow = qwindow->parent(); | - |
132 | } never executed: end of block | 0 |
133 | } never executed: end of block | 0 |
134 | | - |
135 | if (!w)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
136 | return false; never executed: return false; | 0 |
137 | | - |
138 | return correctWidgetContext(context, w, active_window); never executed: return correctWidgetContext(context, w, active_window); | 0 |
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())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
150 | return false; never executed: return false; | 0 |
151 | | - |
152 | if (context == Qt::ApplicationShortcut)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
153 | return QApplicationPrivate::tryModalHelper(w, 0); never executed: return QApplicationPrivate::tryModalHelper(w, 0); | 0 |
154 | | - |
155 | if (context == Qt::WidgetShortcut)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
156 | return w == QApplication::focusWidget(); never executed: return w == QApplication::focusWidget(); | 0 |
157 | | - |
158 | if (context == Qt::WidgetWithChildrenShortcut) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
159 | const QWidget *tw = QApplication::focusWidget(); | - |
160 | 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 |
161 | tw = tw->parentWidget(); never executed: tw = tw->parentWidget(); | 0 |
162 | return tw == w; never executed: return tw == w; | 0 |
163 | } | - |
164 | | - |
165 | | - |
166 | QWidget *tlw = w->window(); | - |
167 | #ifndef QT_NO_GRAPHICSVIEW | - |
168 | if (QWExtra *topData = static_cast<QWidgetPrivate *>(QObjectPrivate::get(tlw))->extra) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
169 | if (topData->proxyWidget) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
170 | bool res = correctGraphicsWidgetContext(context, (QGraphicsWidget *)topData->proxyWidget, active_window); | - |
171 | return res; never executed: return res; | 0 |
172 | } | - |
173 | } never executed: end of block | 0 |
174 | #endif | - |
175 | | - |
176 | | - |
177 | | - |
178 | 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 |
179 | active_window = active_window->parentWidget()->window(); | - |
180 | } never executed: end of block | 0 |
181 | | - |
182 | if (active_window != tlw)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
183 | return false; never executed: return false; | 0 |
184 | | - |
185 | | - |
186 | | - |
187 | const QWidget* sw = w; | - |
188 | 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 |
189 | sw = sw->parentWidget(); never executed: sw = sw->parentWidget(); | 0 |
190 | if (sw && (sw->windowType() == Qt::SubWindow)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
191 | QWidget *focus_widget = QApplication::focusWidget(); | - |
192 | while (focus_widget && focus_widget != sw)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
193 | focus_widget = focus_widget->parentWidget(); never executed: focus_widget = focus_widget->parentWidget(); | 0 |
194 | return sw == focus_widget; never executed: return sw == focus_widget; | 0 |
195 | } | - |
196 | | - |
197 | #if defined(DEBUG_QSHORTCUTMAP) | - |
198 | qDebug().nospace() << "..true [Pass-through]"; | - |
199 | #endif | - |
200 | return true; never executed: return true; | 0 |
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())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
213 | return false; never executed: return false; | 0 |
214 | | - |
215 | if (context == Qt::ApplicationShortcut) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
216 | | - |
217 | | - |
218 | | - |
219 | QList<QGraphicsView *> views = w->scene()->views(); | - |
220 | for (int i = 0; i < views.size(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
221 | if (QApplicationPrivate::tryModalHelper(views.at(i), 0))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
222 | return true; never executed: return true; | 0 |
223 | } never executed: end of block | 0 |
224 | return false; never executed: return false; | 0 |
225 | } | - |
226 | | - |
227 | if (context == Qt::WidgetShortcut)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
228 | return static_cast<QGraphicsItem *>(w) == w->scene()->focusItem(); never executed: return static_cast<QGraphicsItem *>(w) == w->scene()->focusItem(); | 0 |
229 | | - |
230 | if (context == Qt::WidgetWithChildrenShortcut) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
231 | const QGraphicsItem *ti = w->scene()->focusItem(); | - |
232 | if (ti && ti->isWidget()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
233 | const QGraphicsWidget *tw = static_cast<const QGraphicsWidget *>(ti); | - |
234 | 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 |
235 | tw = tw->parentWidget(); never executed: tw = tw->parentWidget(); | 0 |
236 | return tw == w; never executed: return tw == w; | 0 |
237 | } | - |
238 | return false; never executed: return false; | 0 |
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) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
247 | QGraphicsView *view = views.at(i); | - |
248 | if (view->window() == active_window) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
249 | activeView = view; | - |
250 | break; never executed: break; | 0 |
251 | } | - |
252 | } never executed: end of block | 0 |
253 | if (!activeView)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
254 | return false; never executed: return false; | 0 |
255 | | - |
256 | | - |
257 | | - |
258 | QGraphicsWidget *a = w->scene()->activeWindow(); | - |
259 | return !w->window() || a == w->window(); never executed: return !w->window() || a == w->window(); | 0 |
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) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
272 | QWidget *w = widgets.at(i); | - |
273 | #ifndef QT_NO_MENU | - |
274 | if (QMenu *menu = qobject_cast<QMenu *>(w)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
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))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
290 | return true; never executed: return true; | 0 |
291 | } else never executed: end of block | 0 |
292 | #endif | - |
293 | if (correctWidgetContext(context, w, active_window))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
294 | return true; never executed: return true; | 0 |
295 | } never executed: end of block | 0 |
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) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
304 | QGraphicsWidget *w = graphicsWidgets.at(i); | - |
305 | if (correctGraphicsWidgetContext(context, w, active_window))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
306 | return true; never executed: return true; | 0 |
307 | } never executed: end of block | 0 |
308 | #endif | - |
309 | return false; never executed: return false; | 0 |
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) {} never executed: end of block | 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 | } never executed: end of block | 0 |
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"); never executed: return; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
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)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
469 | connect(this, SIGNAL(activated()), parent, member); never executed: connect(this, qFlagLocation("2""activated()" "\0" __FILE__ ":" "469"), parent, member); | 0 |
470 | if (ambiguousMember)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
471 | connect(this, SIGNAL(activatedAmbiguously()), parent, ambiguousMember); never executed: connect(this, qFlagLocation("2""activatedAmbiguously()" "\0" __FILE__ ":" "471"), parent, ambiguousMember); | 0 |
472 | } never executed: end of block | 0 |
473 | | - |
474 | | - |
475 | | - |
476 | | - |
477 | QShortcut::~QShortcut() | - |
478 | { | - |
479 | Q_D(QShortcut); | - |
480 | if (qApp)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
481 | 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 |
482 | } never executed: end of block | 0 |
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)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
499 | return; never executed: return; | 0 |
500 | QAPP_CHECK("setKey"); never executed: return; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
501 | d->sc_sequence = key; | - |
502 | d->redoGrab(qApp->d_func()->shortcutMap); | - |
503 | } never executed: end of block | 0 |
504 | | - |
505 | QKeySequence QShortcut::key() const | - |
506 | { | - |
507 | Q_D(const QShortcut); | - |
508 | return d->sc_sequence; never executed: return d->sc_sequence; | 0 |
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)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
530 | return; never executed: return; | 0 |
531 | QAPP_CHECK("setEnabled"); never executed: return; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
532 | d->sc_enabled = enable; | - |
533 | qApp->d_func()->shortcutMap.setShortcutEnabled(enable, d->sc_id, this); | - |
534 | } never executed: end of block | 0 |
535 | | - |
536 | bool QShortcut::isEnabled() const | - |
537 | { | - |
538 | Q_D(const QShortcut); | - |
539 | return d->sc_enabled; never executed: return d->sc_enabled; | 0 |
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)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
558 | return; never executed: return; | 0 |
559 | QAPP_CHECK("setContext"); never executed: return; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
560 | d->sc_context = context; | - |
561 | d->redoGrab(qApp->d_func()->shortcutMap); | - |
562 | } never executed: end of block | 0 |
563 | | - |
564 | Qt::ShortcutContext QShortcut::context() const | - |
565 | { | - |
566 | Q_D(const QShortcut); | - |
567 | return d->sc_context; never executed: return d->sc_context; | 0 |
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 | } never executed: end of block | 0 |
589 | | - |
590 | QString QShortcut::whatsThis() const | - |
591 | { | - |
592 | Q_D(const QShortcut); | - |
593 | return d->sc_whatsthis; never executed: return d->sc_whatsthis; | 0 |
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)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
610 | return; never executed: return; | 0 |
611 | QAPP_CHECK("setAutoRepeat"); never executed: return; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
612 | d->sc_autorepeat = on; | - |
613 | qApp->d_func()->shortcutMap.setShortcutAutoRepeat(on, d->sc_id, this); | - |
614 | } never executed: end of block | 0 |
615 | | - |
616 | bool QShortcut::autoRepeat() const | - |
617 | { | - |
618 | Q_D(const QShortcut); | - |
619 | return d->sc_autorepeat; never executed: return d->sc_autorepeat; | 0 |
620 | } | - |
621 | | - |
622 | | - |
623 | | - |
624 | | - |
625 | | - |
626 | | - |
627 | int QShortcut::id() const | - |
628 | { | - |
629 | Q_D(const QShortcut); | - |
630 | return d->sc_id; never executed: return d->sc_id; | 0 |
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) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
641 | QShortcutEvent *se = static_cast<QShortcutEvent *>(e); | - |
642 | if (se->shortcutId() == d->sc_id && se->key() == d->sc_sequence){TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
643 | #ifndef QT_NO_WHATSTHIS | - |
644 | if (QWhatsThis::inWhatsThisMode()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
645 | QWhatsThis::showText(QCursor::pos(), d->sc_whatsthis); | - |
646 | handled = true; | - |
647 | } else never executed: end of block | 0 |
648 | #endif | - |
649 | if (se->isAmbiguous())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
650 | emit activatedAmbiguously(); never executed: activatedAmbiguously(); | 0 |
651 | else | - |
652 | emit activated(); never executed: activated(); | 0 |
653 | handled = true; | - |
654 | } never executed: end of block | 0 |
655 | } never executed: end of block | 0 |
656 | return handled; never executed: return handled; | 0 |
657 | } | - |
658 | #endif // QT_NO_SHORTCUT | - |
659 | | - |
660 | QT_END_NAMESPACE | - |
661 | | - |
662 | #include "moc_qshortcut.cpp" | - |
| | |