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 | | - |
41 | #include "qapplication.h" | - |
42 | #include "qapplication_p.h" | - |
43 | #include "qbrush.h" | - |
44 | #include "qcursor.h" | - |
45 | #include "qdesktopwidget_p.h" | - |
46 | #include "qevent.h" | - |
47 | #include "qlayout.h" | - |
48 | #include "qmenu.h" | - |
49 | #include "qmetaobject.h" | - |
50 | #include "qpixmap.h" | - |
51 | #include "qpointer.h" | - |
52 | #include "qstack.h" | - |
53 | #include "qstyle.h" | - |
54 | #include "qstylefactory.h" | - |
55 | #include "qvariant.h" | - |
56 | #include "qwidget.h" | - |
57 | #include "qstyleoption.h" | - |
58 | #include "qstylehints.h" | - |
59 | #ifndef QT_NO_ACCESSIBILITY | - |
60 | # include "qaccessible.h" | - |
61 | #endif | - |
62 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
63 | # include "qt_mac_p.h" | - |
64 | # include "qt_cocoa_helpers_mac_p.h" | - |
65 | # include "qmainwindow.h" | - |
66 | # include "qtoolbar.h" | - |
67 | # include <private/qmainwindowlayout_p.h> | - |
68 | #endif | - |
69 | #include <qpa/qplatformwindow.h> | - |
70 | #include <qpa/qplatformbackingstore.h> | - |
71 | #include "private/qwidgetwindow_p.h" | - |
72 | #include "qpainter.h" | - |
73 | #include "qtooltip.h" | - |
74 | #include "qwhatsthis.h" | - |
75 | #include "qdebug.h" | - |
76 | #include "private/qstylesheetstyle_p.h" | - |
77 | #include "private/qstyle_p.h" | - |
78 | #include "qfileinfo.h" | - |
79 | #include <QtGui/private/qhighdpiscaling_p.h> | - |
80 | #include <QtGui/qinputmethod.h> | - |
81 | #include <QtGui/qopenglcontext.h> | - |
82 | #include <QtGui/private/qopenglcontext_p.h> | - |
83 | #include <QtGui/qoffscreensurface.h> | - |
84 | | - |
85 | #include <private/qgraphicseffect_p.h> | - |
86 | #include <qbackingstore.h> | - |
87 | #include <private/qwidgetbackingstore_p.h> | - |
88 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
89 | # include <private/qpaintengine_mac_p.h> | - |
90 | #endif | - |
91 | #include <private/qpaintengine_raster_p.h> | - |
92 | | - |
93 | #include "qwidget_p.h" | - |
94 | #include <QtGui/private/qwindow_p.h> | - |
95 | #include "qaction_p.h" | - |
96 | #include "qlayout_p.h" | - |
97 | #include "QtWidgets/qgraphicsproxywidget.h" | - |
98 | #include "QtWidgets/qgraphicsscene.h" | - |
99 | #include "private/qgraphicsproxywidget_p.h" | - |
100 | #include "QtWidgets/qabstractscrollarea.h" | - |
101 | #include "private/qabstractscrollarea_p.h" | - |
102 | #include "private/qevent_p.h" | - |
103 | | - |
104 | #include "private/qgesturemanager_p.h" | - |
105 | | - |
106 | #ifdef QT_KEYPAD_NAVIGATION | - |
107 | #include "qtabwidget.h" // Needed in inTabWidget() | - |
108 | #endif // QT_KEYPAD_NAVIGATION | - |
109 | | - |
110 | #include "qwindowcontainer_p.h" | - |
111 | | - |
112 | #include <QtPlatformHeaders/qxcbwindowfunctions.h> | - |
113 | | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | QT_BEGIN_NAMESPACE | - |
119 | | - |
120 | static bool qt_enable_backingstore = true; | - |
121 | #ifdef Q_DEAD_CODE_FROM_QT4_X11 | - |
122 | | - |
123 | Q_WIDGETS_EXPORT void qt_x11_set_global_double_buffer(bool enable) | - |
124 | { | - |
125 | qt_enable_backingstore = enable; | - |
126 | } | - |
127 | #endif | - |
128 | | - |
129 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
130 | bool qt_mac_clearDirtyOnWidgetInsideDrawWidget = false; | - |
131 | #endif | - |
132 | | - |
133 | static inline bool qRectIntersects(const QRect &r1, const QRect &r2) | - |
134 | { | - |
135 | return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right()) && | - |
136 | qMax(r1.top(), r2.top()) <= qMin(r1.bottom(), r2.bottom())); | - |
137 | } | - |
138 | | - |
139 | static inline bool hasBackingStoreSupport() | - |
140 | { | - |
141 | return true; | - |
142 | } | - |
143 | | - |
144 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
145 | # define QT_NO_PAINT_DEBUG | - |
146 | #endif | - |
147 | | - |
148 | extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); | - |
149 | extern QDesktopWidget *qt_desktopWidget; | - |
150 | | - |
151 | | - |
152 | | - |
153 | | - |
154 | | - |
155 | | - |
156 | | - |
157 | | - |
158 | | - |
159 | | - |
160 | | - |
161 | QWidgetBackingStoreTracker::QWidgetBackingStoreTracker() | - |
162 | : m_ptr(0) | - |
163 | { | - |
164 | | - |
165 | } | - |
166 | | - |
167 | QWidgetBackingStoreTracker::~QWidgetBackingStoreTracker() | - |
168 | { | - |
169 | delete m_ptr; | - |
170 | } | - |
171 | | - |
172 | | - |
173 | | - |
174 | | - |
175 | | - |
176 | | - |
177 | | - |
178 | void QWidgetBackingStoreTracker::create(QWidget *widget) | - |
179 | { | - |
180 | destroy(); | - |
181 | m_ptr = new QWidgetBackingStore(widget); | - |
182 | } | - |
183 | | - |
184 | | - |
185 | | - |
186 | | - |
187 | | - |
188 | | - |
189 | void QWidgetBackingStoreTracker::destroy() | - |
190 | { | - |
191 | delete m_ptr; | - |
192 | m_ptr = 0; | - |
193 | m_widgets.clear(); | - |
194 | } | - |
195 | | - |
196 | | - |
197 | | - |
198 | | - |
199 | | - |
200 | | - |
201 | void QWidgetBackingStoreTracker::registerWidget(QWidget *w) | - |
202 | { | - |
203 | Q_ASSERT(m_ptr); | - |
204 | Q_ASSERT(w->internalWinId()); | - |
205 | Q_ASSERT(qt_widget_private(w)->maybeBackingStore() == m_ptr); | - |
206 | m_widgets.insert(w); | - |
207 | } | - |
208 | | - |
209 | | - |
210 | | - |
211 | | - |
212 | | - |
213 | | - |
214 | | - |
215 | | - |
216 | void QWidgetBackingStoreTracker::unregisterWidget(QWidget *w) | - |
217 | { | - |
218 | if (m_widgets.remove(w) && m_widgets.isEmpty()) { | - |
219 | delete m_ptr; | - |
220 | m_ptr = 0; | - |
221 | } | - |
222 | } | - |
223 | | - |
224 | | - |
225 | | - |
226 | | - |
227 | | - |
228 | void QWidgetBackingStoreTracker::unregisterWidgetSubtree(QWidget *widget) | - |
229 | { | - |
230 | unregisterWidget(widget); | - |
231 | foreach (QObject *child, widget->children()) | - |
232 | if (QWidget *childWidget = qobject_cast<QWidget *>(child)) | - |
233 | unregisterWidgetSubtree(childWidget); | - |
234 | } | - |
235 | | - |
236 | QWidgetPrivate::QWidgetPrivate(int version) | - |
237 | : QObjectPrivate(version) | - |
238 | , extra(0) | - |
239 | , focus_next(0) | - |
240 | , focus_prev(0) | - |
241 | , focus_child(0) | - |
242 | , layout(0) | - |
243 | , needsFlush(0) | - |
244 | , redirectDev(0) | - |
245 | , widgetItem(0) | - |
246 | , extraPaintEngine(0) | - |
247 | , polished(0) | - |
248 | , graphicsEffect(0) | - |
249 | #if !defined(QT_NO_IM) | - |
250 | , imHints(Qt::ImhNone) | - |
251 | #endif | - |
252 | #ifndef QT_NO_TOOLTIP | - |
253 | , toolTipDuration(-1) | - |
254 | #endif | - |
255 | , inheritedFontResolveMask(0) | - |
256 | , inheritedPaletteResolveMask(0) | - |
257 | , leftmargin(0) | - |
258 | , topmargin(0) | - |
259 | , rightmargin(0) | - |
260 | , bottommargin(0) | - |
261 | , leftLayoutItemMargin(0) | - |
262 | , topLayoutItemMargin(0) | - |
263 | , rightLayoutItemMargin(0) | - |
264 | , bottomLayoutItemMargin(0) | - |
265 | , hd(0) | - |
266 | , size_policy(QSizePolicy::Preferred, QSizePolicy::Preferred) | - |
267 | , fg_role(QPalette::NoRole) | - |
268 | , bg_role(QPalette::NoRole) | - |
269 | , dirtyOpaqueChildren(1) | - |
270 | , isOpaque(0) | - |
271 | , retainSizeWhenHiddenChanged(0) | - |
272 | , inDirtyList(0) | - |
273 | , isScrolled(0) | - |
274 | , isMoved(0) | - |
275 | , usesDoubleBufferedGLContext(0) | - |
276 | , mustHaveWindowHandle(0) | - |
277 | , renderToTexture(0) | - |
278 | , textureChildSeen(0) | - |
279 | #ifndef QT_NO_IM | - |
280 | , inheritsInputMethodHints(0) | - |
281 | #endif | - |
282 | #ifndef QT_NO_OPENGL | - |
283 | , renderToTextureReallyDirty(1) | - |
284 | , renderToTextureComposeActive(0) | - |
285 | #endif | - |
286 | , childrenHiddenByWState(0) | - |
287 | , childrenShownByExpose(0) | - |
288 | #if defined(Q_OS_WIN) | - |
289 | , noPaintOnScreen(0) | - |
290 | #endif | - |
291 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - |
292 | , picture(0) | - |
293 | #elif defined(Q_DEAD_CODE_FROM_QT4_WIN) | - |
294 | #ifndef QT_NO_GESTURES | - |
295 | , nativeGesturePanEnabled(0) | - |
296 | #endif | - |
297 | #elif defined(Q_DEAD_CODE_FROM_QT4_MAC) | - |
298 | , needWindowChange(0) | - |
299 | , window_event(0) | - |
300 | , qd_hd(0) | - |
301 | #endif | - |
302 | { | - |
303 | if (Q_UNLIKELY(!qApp))) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
304 | qFatal("QWidget: Must construct a QApplication before a QWidget"); | - |
305 | return; never executed: return; | 0 |
306 | } | - |
307 | | - |
308 | #ifdef QT_BUILD_INTERNAL | - |
309 | | - |
310 | | - |
311 | Q_UNUSED(version); | - |
312 | #else | - |
313 | if (Q_UNLIKELY(version != QObjectPrivateVersion))) | - |
314 | qFatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)", | - |
315 | version, QObjectPrivateVersion); | - |
316 | #endif | - |
317 | | - |
318 | isWidget = true; | - |
319 | memset(high_attributes, 0, sizeof(high_attributes)); | - |
320 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
321 | drawRectOriginalAdded = false; | - |
322 | originalDrawMethod = true; | - |
323 | changeMethods = false; | - |
324 | isInUnifiedToolbar = false; | - |
325 | unifiedSurface = 0; | - |
326 | toolbar_ancestor = 0; | - |
327 | flushRequested = false; | - |
328 | touchEventsEnabled = false; | - |
329 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - |
330 | #ifdef QWIDGET_EXTRA_DEBUG | - |
331 | static int count = 0; | - |
332 | qDebug() << "widgets" << ++count; | - |
333 | #endif | - |
334 | } never executed: end of block | 0 |
335 | | - |
336 | | - |
337 | QWidgetPrivate::~QWidgetPrivate() | - |
338 | { | - |
339 | if (widgetItem) | - |
340 | widgetItem->wid = 0; | - |
341 | | - |
342 | if (extra) | - |
343 | deleteExtra(); | - |
344 | | - |
345 | #ifndef QT_NO_GRAPHICSEFFECT | - |
346 | delete graphicsEffect; | - |
347 | #endif //QT_NO_GRAPHICSEFFECT | - |
348 | } | - |
349 | | - |
350 | | - |
351 | | - |
352 | | - |
353 | void QWidgetPrivate::scrollChildren(int dx, int dy) | - |
354 | { | - |
355 | Q_Q(QWidget); | - |
356 | if (q->children().size() > 0) { | - |
357 | QPoint pd(dx, dy); | - |
358 | QObjectList childObjects = q->children(); | - |
359 | for (int i = 0; i < childObjects.size(); ++i) { | - |
360 | QWidget *w = qobject_cast<QWidget*>(childObjects.at(i)); | - |
361 | if (w && !w->isWindow()) { | - |
362 | QPoint oldp = w->pos(); | - |
363 | QRect r(w->pos() + pd, w->size()); | - |
364 | w->data->crect = r; | - |
365 | if (w->testAttribute(Qt::WA_WState_Created)) | - |
366 | w->d_func()->setWSGeometry(); | - |
367 | w->d_func()->setDirtyOpaqueRegion(); | - |
368 | QMoveEvent e(r.topLeft(), oldp); | - |
369 | QApplication::sendEvent(w, &e); | - |
370 | } | - |
371 | } | - |
372 | } | - |
373 | } | - |
374 | | - |
375 | void QWidgetPrivate::setWSGeometry() | - |
376 | { | - |
377 | Q_Q(QWidget); | - |
378 | if (QWindow *window = q->windowHandle()) | - |
379 | window->setGeometry(data.crect); | - |
380 | } | - |
381 | | - |
382 | void QWidgetPrivate::updateWidgetTransform(QEvent *event) | - |
383 | { | - |
384 | Q_Q(QWidget); | - |
385 | if (q == QGuiApplication::focusObject() || event->type() == QEvent::FocusIn) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
386 | QTransform t; | - |
387 | QPoint p = q->mapTo(q->topLevelWidget(), QPoint(0,0)); | - |
388 | t.translate(p.x(), p.y()); | - |
389 | QGuiApplication::inputMethod()->setInputItemTransform(t); | - |
390 | QGuiApplication::inputMethod()->setInputItemRectangle(q->rect()); | - |
391 | QGuiApplication::inputMethod()->update(Qt::ImInputItemClipRectangle); | - |
392 | } never executed: end of block | 0 |
393 | } never executed: end of block | 0 |
394 | | - |
395 | #ifdef QT_KEYPAD_NAVIGATION | - |
396 | QPointer<QWidget> QWidgetPrivate::editingWidget; | - |
397 | | - |
398 | | - |
399 | | - |
400 | | - |
401 | | - |
402 | | - |
403 | | - |
404 | | - |
405 | bool QWidget::hasEditFocus() const | - |
406 | { | - |
407 | const QWidget* w = this; | - |
408 | while (w->d_func()->extra && w->d_func()->extra->focus_proxy) | - |
409 | w = w->d_func()->extra->focus_proxy; | - |
410 | return QWidgetPrivate::editingWidget == w; | - |
411 | } | - |
412 | | - |
413 | | - |
414 | | - |
415 | | - |
416 | | - |
417 | | - |
418 | | - |
419 | | - |
420 | | - |
421 | | - |
422 | | - |
423 | | - |
424 | | - |
425 | void QWidget::setEditFocus(bool on) | - |
426 | { | - |
427 | QWidget *f = this; | - |
428 | while (f->d_func()->extra && f->d_func()->extra->focus_proxy) | - |
429 | f = f->d_func()->extra->focus_proxy; | - |
430 | | - |
431 | if (QWidgetPrivate::editingWidget && QWidgetPrivate::editingWidget != f) | - |
432 | QWidgetPrivate::editingWidget->setEditFocus(false); | - |
433 | | - |
434 | if (on && !f->hasFocus()) | - |
435 | f->setFocus(); | - |
436 | | - |
437 | if ((!on && !QWidgetPrivate::editingWidget) | - |
438 | || (on && QWidgetPrivate::editingWidget == f)) { | - |
439 | return; | - |
440 | } | - |
441 | | - |
442 | if (!on && QWidgetPrivate::editingWidget == f) { | - |
443 | QWidgetPrivate::editingWidget = 0; | - |
444 | QEvent event(QEvent::LeaveEditFocus); | - |
445 | QApplication::sendEvent(f, &event); | - |
446 | QApplication::sendEvent(f->style(), &event); | - |
447 | } else if (on) { | - |
448 | QWidgetPrivate::editingWidget = f; | - |
449 | QEvent event(QEvent::EnterEditFocus); | - |
450 | QApplication::sendEvent(f, &event); | - |
451 | QApplication::sendEvent(f->style(), &event); | - |
452 | } | - |
453 | } | - |
454 | #endif | - |
455 | | - |
456 | | - |
457 | | - |
458 | | - |
459 | | - |
460 | | - |
461 | | - |
462 | | - |
463 | | - |
464 | | - |
465 | | - |
466 | | - |
467 | | - |
468 | | - |
469 | | - |
470 | | - |
471 | | - |
472 | | - |
473 | | - |
474 | | - |
475 | | - |
476 | | - |
477 | | - |
478 | | - |
479 | | - |
480 | bool QWidget::autoFillBackground() const | - |
481 | { | - |
482 | Q_D(const QWidget); | - |
483 | return d->extra && d->extra->autoFillBackground; | - |
484 | } | - |
485 | | - |
486 | void QWidget::setAutoFillBackground(bool enabled) | - |
487 | { | - |
488 | Q_D(QWidget); | - |
489 | if (!d->extra) | - |
490 | d->createExtra(); | - |
491 | if (d->extra->autoFillBackground == enabled) | - |
492 | return; | - |
493 | | - |
494 | d->extra->autoFillBackground = enabled; | - |
495 | d->updateIsOpaque(); | - |
496 | update(); | - |
497 | d->updateIsOpaque(); | - |
498 | } | - |
499 | | - |
500 | | - |
501 | | - |
502 | | - |
503 | | - |
504 | | - |
505 | | - |
506 | | - |
507 | | - |
508 | | - |
509 | | - |
510 | | - |
511 | | - |
512 | | - |
513 | | - |
514 | | - |
515 | | - |
516 | | - |
517 | | - |
518 | | - |
519 | | - |
520 | | - |
521 | | - |
522 | | - |
523 | | - |
524 | | - |
525 | | - |
526 | | - |
527 | | - |
528 | | - |
529 | | - |
530 | | - |
531 | | - |
532 | | - |
533 | | - |
534 | | - |
535 | | - |
536 | | - |
537 | | - |
538 | | - |
539 | | - |
540 | | - |
541 | | - |
542 | | - |
543 | | - |
544 | | - |
545 | | - |
546 | | - |
547 | | - |
548 | | - |
549 | | - |
550 | | - |
551 | | - |
552 | | - |
553 | | - |
554 | | - |
555 | | - |
556 | | - |
557 | | - |
558 | | - |
559 | | - |
560 | | - |
561 | | - |
562 | | - |
563 | | - |
564 | | - |
565 | | - |
566 | | - |
567 | | - |
568 | | - |
569 | | - |
570 | | - |
571 | | - |
572 | | - |
573 | | - |
574 | | - |
575 | | - |
576 | | - |
577 | | - |
578 | | - |
579 | | - |
580 | | - |
581 | | - |
582 | | - |
583 | | - |
584 | | - |
585 | | - |
586 | | - |
587 | | - |
588 | | - |
589 | | - |
590 | | - |
591 | | - |
592 | | - |
593 | | - |
594 | | - |
595 | | - |
596 | | - |
597 | | - |
598 | | - |
599 | | - |
600 | | - |
601 | | - |
602 | | - |
603 | | - |
604 | | - |
605 | | - |
606 | | - |
607 | | - |
608 | | - |
609 | | - |
610 | | - |
611 | | - |
612 | | - |
613 | | - |
614 | | - |
615 | | - |
616 | | - |
617 | | - |
618 | | - |
619 | | - |
620 | | - |
621 | | - |
622 | | - |
623 | | - |
624 | | - |
625 | | - |
626 | | - |
627 | | - |
628 | | - |
629 | | - |
630 | | - |
631 | | - |
632 | | - |
633 | | - |
634 | | - |
635 | | - |
636 | | - |
637 | | - |
638 | | - |
639 | | - |
640 | | - |
641 | | - |
642 | | - |
643 | | - |
644 | | - |
645 | | - |
646 | | - |
647 | | - |
648 | | - |
649 | | - |
650 | | - |
651 | | - |
652 | | - |
653 | | - |
654 | | - |
655 | | - |
656 | | - |
657 | | - |
658 | | - |
659 | | - |
660 | | - |
661 | | - |
662 | | - |
663 | | - |
664 | | - |
665 | | - |
666 | | - |
667 | | - |
668 | | - |
669 | | - |
670 | | - |
671 | | - |
672 | | - |
673 | | - |
674 | | - |
675 | | - |
676 | | - |
677 | | - |
678 | | - |
679 | | - |
680 | | - |
681 | | - |
682 | | - |
683 | | - |
684 | | - |
685 | | - |
686 | | - |
687 | | - |
688 | | - |
689 | | - |
690 | | - |
691 | | - |
692 | | - |
693 | | - |
694 | | - |
695 | | - |
696 | | - |
697 | | - |
698 | | - |
699 | | - |
700 | | - |
701 | | - |
702 | | - |
703 | | - |
704 | | - |
705 | | - |
706 | | - |
707 | | - |
708 | | - |
709 | | - |
710 | | - |
711 | | - |
712 | | - |
713 | | - |
714 | | - |
715 | | - |
716 | | - |
717 | | - |
718 | | - |
719 | | - |
720 | | - |
721 | | - |
722 | | - |
723 | | - |
724 | | - |
725 | | - |
726 | | - |
727 | | - |
728 | | - |
729 | | - |
730 | | - |
731 | | - |
732 | | - |
733 | | - |
734 | | - |
735 | | - |
736 | | - |
737 | | - |
738 | | - |
739 | | - |
740 | | - |
741 | | - |
742 | | - |
743 | | - |
744 | | - |
745 | | - |
746 | | - |
747 | | - |
748 | | - |
749 | | - |
750 | | - |
751 | | - |
752 | | - |
753 | | - |
754 | | - |
755 | | - |
756 | | - |
757 | | - |
758 | | - |
759 | | - |
760 | | - |
761 | | - |
762 | | - |
763 | | - |
764 | | - |
765 | | - |
766 | | - |
767 | | - |
768 | | - |
769 | | - |
770 | | - |
771 | | - |
772 | | - |
773 | | - |
774 | | - |
775 | | - |
776 | | - |
777 | | - |
778 | | - |
779 | | - |
780 | | - |
781 | | - |
782 | | - |
783 | | - |
784 | | - |
785 | | - |
786 | | - |
787 | | - |
788 | | - |
789 | | - |
790 | | - |
791 | | - |
792 | | - |
793 | | - |
794 | | - |
795 | | - |
796 | | - |
797 | | - |
798 | | - |
799 | | - |
800 | | - |
801 | | - |
802 | | - |
803 | | - |
804 | | - |
805 | | - |
806 | | - |
807 | | - |
808 | | - |
809 | | - |
810 | | - |
811 | | - |
812 | | - |
813 | | - |
814 | | - |
815 | | - |
816 | | - |
817 | | - |
818 | | - |
819 | | - |
820 | | - |
821 | | - |
822 | | - |
823 | | - |
824 | | - |
825 | | - |
826 | | - |
827 | | - |
828 | | - |
829 | | - |
830 | | - |
831 | | - |
832 | | - |
833 | | - |
834 | | - |
835 | | - |
836 | | - |
837 | | - |
838 | | - |
839 | | - |
840 | | - |
841 | | - |
842 | | - |
843 | | - |
844 | | - |
845 | | - |
846 | | - |
847 | | - |
848 | | - |
849 | | - |
850 | | - |
851 | | - |
852 | | - |
853 | | - |
854 | | - |
855 | | - |
856 | | - |
857 | | - |
858 | | - |
859 | | - |
860 | | - |
861 | | - |
862 | | - |
863 | | - |
864 | | - |
865 | | - |
866 | | - |
867 | | - |
868 | | - |
869 | | - |
870 | | - |
871 | | - |
872 | | - |
873 | | - |
874 | | - |
875 | | - |
876 | | - |
877 | | - |
878 | | - |
879 | | - |
880 | | - |
881 | | - |
882 | | - |
883 | | - |
884 | | - |
885 | | - |
886 | | - |
887 | | - |
888 | | - |
889 | | - |
890 | | - |
891 | | - |
892 | | - |
893 | | - |
894 | | - |
895 | | - |
896 | | - |
897 | | - |
898 | | - |
899 | | - |
900 | | - |
901 | | - |
902 | | - |
903 | | - |
904 | | - |
905 | | - |
906 | | - |
907 | | - |
908 | | - |
909 | | - |
910 | | - |
911 | | - |
912 | | - |
913 | | - |
914 | | - |
915 | | - |
916 | | - |
917 | | - |
918 | | - |
919 | | - |
920 | | - |
921 | | - |
922 | | - |
923 | | - |
924 | | - |
925 | | - |
926 | | - |
927 | | - |
928 | | - |
929 | | - |
930 | | - |
931 | | - |
932 | | - |
933 | | - |
934 | | - |
935 | | - |
936 | | - |
937 | | - |
938 | | - |
939 | | - |
940 | | - |
941 | | - |
942 | | - |
943 | | - |
944 | | - |
945 | | - |
946 | | - |
947 | | - |
948 | | - |
949 | QWidgetMapper *QWidgetPrivate::mapper = 0; | - |
950 | QWidgetSet *QWidgetPrivate::allWidgets = 0; | - |
951 | | - |
952 | | - |
953 | | - |
954 | | - |
955 | | - |
956 | | - |
957 | QRegion qt_dirtyRegion(QWidget *widget) | - |
958 | { | - |
959 | if (!widget) | - |
960 | return QRegion(); | - |
961 | | - |
962 | QWidgetBackingStore *bs = qt_widget_private(widget)->maybeBackingStore(); | - |
963 | if (!bs) | - |
964 | return QRegion(); | - |
965 | | - |
966 | return bs->dirtyRegion(widget); | - |
967 | } | - |
968 | | - |
969 | | - |
970 | | - |
971 | | - |
972 | | - |
973 | | - |
974 | | - |
975 | | - |
976 | | - |
977 | | - |
978 | | - |
979 | | - |
980 | | - |
981 | | - |
982 | | - |
983 | | - |
984 | | - |
985 | | - |
986 | | - |
987 | | - |
988 | | - |
989 | | - |
990 | struct QWidgetExceptionCleaner | - |
991 | { | - |
992 | | - |
993 | static inline void cleanup(QWidget *that, QWidgetPrivate *d) | - |
994 | { | - |
995 | #ifdef QT_NO_EXCEPTIONS | - |
996 | Q_UNUSED(that); | - |
997 | Q_UNUSED(d); | - |
998 | #else | - |
999 | QWidgetPrivate::allWidgets->remove(that); | - |
1000 | if (d->focus_next != that) { | - |
1001 | if (d->focus_next) | - |
1002 | d->focus_next->d_func()->focus_prev = d->focus_prev; | - |
1003 | if (d->focus_prev) | - |
1004 | d->focus_prev->d_func()->focus_next = d->focus_next; | - |
1005 | } | - |
1006 | #endif | - |
1007 | } | - |
1008 | }; | - |
1009 | | - |
1010 | | - |
1011 | | - |
1012 | | - |
1013 | | - |
1014 | | - |
1015 | | - |
1016 | | - |
1017 | | - |
1018 | | - |
1019 | | - |
1020 | | - |
1021 | | - |
1022 | | - |
1023 | | - |
1024 | | - |
1025 | | - |
1026 | | - |
1027 | | - |
1028 | | - |
1029 | | - |
1030 | | - |
1031 | | - |
1032 | | - |
1033 | | - |
1034 | | - |
1035 | QWidget::QWidget(QWidget *parent, Qt::WindowFlags f) | - |
1036 | : QObject(*new QWidgetPrivate, 0), QPaintDevice() | - |
1037 | { | - |
1038 | QT_TRY { | - |
1039 | d_func()->init(parent, f); | - |
1040 | } QT_CATCH(...) { dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - |
1041 | QWidgetExceptionCleaner::cleanup(this, d_func()); dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - |
1042 | QT_RETHROW; dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - |
1043 | } dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - |
1044 | } | - |
1045 | | - |
1046 | | - |
1047 | | - |
1048 | | - |
1049 | QWidget::QWidget(QWidgetPrivate &dd, QWidget* parent, Qt::WindowFlags f) | - |
1050 | : QObject(dd, 0), QPaintDevice() | - |
1051 | { | - |
1052 | Q_D(QWidget); | - |
1053 | QT_TRY { | - |
1054 | d->init(parent, f); | - |
1055 | } QT_CATCH(...) { dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - |
1056 | QWidgetExceptionCleaner::cleanup(this, d_func()); dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - |
1057 | QT_RETHROW; dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - |
1058 | } dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - |
1059 | } | - |
1060 | | - |
1061 | | - |
1062 | | - |
1063 | | - |
1064 | int QWidget::devType() const | - |
1065 | { | - |
1066 | return QInternal::Widget; | - |
1067 | } | - |
1068 | | - |
1069 | | - |
1070 | | - |
1071 | void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w) | - |
1072 | { | - |
1073 | bool customize = (flags & (Qt::CustomizeWindowHint | - |
1074 | | Qt::FramelessWindowHint | - |
1075 | | Qt::WindowTitleHint | - |
1076 | | Qt::WindowSystemMenuHint | - |
1077 | | Qt::WindowMinimizeButtonHint | - |
1078 | | Qt::WindowMaximizeButtonHint | - |
1079 | | Qt::WindowCloseButtonHint | - |
1080 | | Qt::WindowContextHelpButtonHint)); | - |
1081 | | - |
1082 | uint type = (flags & Qt::WindowType_Mask); | - |
1083 | | - |
1084 | if ((type == Qt::Widget || type == Qt::SubWindow) && w && !w->parent()) { | - |
1085 | type = Qt::Window; | - |
1086 | flags |= Qt::Window; | - |
1087 | } | - |
1088 | | - |
1089 | if (flags & Qt::CustomizeWindowHint) { | - |
1090 | | - |
1091 | | - |
1092 | | - |
1093 | | - |
1094 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - |
1095 | if ((flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowContextHelpButtonHint)) | - |
1096 | # ifdef Q_OS_WIN | - |
1097 | && type != Qt::Dialog | - |
1098 | # endif | - |
1099 | ) { | - |
1100 | flags |= Qt::WindowSystemMenuHint; | - |
1101 | #else | - |
1102 | if (flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | - |
1103 | | Qt::WindowSystemMenuHint)) { | - |
1104 | #endif | - |
1105 | flags |= Qt::WindowTitleHint; | - |
1106 | flags &= ~Qt::FramelessWindowHint; | - |
1107 | } | - |
1108 | } else if (customize && !(flags & Qt::FramelessWindowHint)) { | - |
1109 | | - |
1110 | | - |
1111 | | - |
1112 | flags |= Qt::WindowSystemMenuHint; | - |
1113 | flags |= Qt::WindowTitleHint; | - |
1114 | } | - |
1115 | if (customize) | - |
1116 | ; | - |
1117 | else if (type == Qt::Dialog || type == Qt::Sheet) | - |
1118 | #ifndef Q_OS_WINCE | - |
1119 | flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint; | - |
1120 | #else | - |
1121 | flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; | - |
1122 | #endif | - |
1123 | else if (type == Qt::Tool) | - |
1124 | flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; | - |
1125 | else | - |
1126 | flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | | - |
1127 | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint; | - |
1128 | if (w->testAttribute(Qt::WA_TransparentForMouseEvents)) | - |
1129 | flags |= Qt::WindowTransparentForInput; | - |
1130 | } | - |
1131 | | - |
1132 | void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) | - |
1133 | { | - |
1134 | Q_Q(QWidget); | - |
1135 | if (Q_UNLIKELY(!qobject_cast<QApplication *>(QCoreApplication::instance()))())))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1136 | qFatal("QWidget: Cannot create a QWidget without QApplication"); never executed: QMessageLogger(__FILE__, 1136, __PRETTY_FUNCTION__).fatal("QWidget: Cannot create a QWidget without QApplication"); | 0 |
1137 | | - |
1138 | Q_ASSERT(allWidgets); | - |
1139 | if (allWidgets)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1140 | allWidgets->insert(q); never executed: allWidgets->insert(q); | 0 |
1141 | | - |
1142 | int targetScreen = -1; | - |
1143 | if (parentWidget && parentWidget->windowType() == Qt::Desktop) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1144 | const QDesktopScreenWidget *sw = qobject_cast<const QDesktopScreenWidget *>(parentWidget); | - |
1145 | targetScreen = sw ? sw->screenNumber() : 0;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1146 | parentWidget = 0; | - |
1147 | } never executed: end of block | 0 |
1148 | | - |
1149 | q->data = &data; | - |
1150 | | - |
1151 | #ifndef QT_NO_THREAD | - |
1152 | if (!parent) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1153 | Q_ASSERT_X(q->thread() == qApp->thread(), "QWidget", | - |
1154 | "Widgets must be created in the GUI thread."); | - |
1155 | } never executed: end of block | 0 |
1156 | #endif | - |
1157 | | - |
1158 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - |
1159 | if (desktopWidget) { | - |
1160 | | - |
1161 | | - |
1162 | xinfo = desktopWidget->d_func()->xinfo; | - |
1163 | } | - |
1164 | #endif | - |
1165 | if (targetScreen >= 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1166 | topData()->initialScreenIndex = targetScreen; | - |
1167 | if (QWindow *window = q->windowHandle())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1168 | window->setScreen(QGuiApplication::screens().value(targetScreen, Q_NULLPTR)); never executed: window->setScreen(QGuiApplication::screens().value(targetScreen, nullptr)); | 0 |
1169 | } never executed: end of block | 0 |
1170 | | - |
1171 | data.fstrut_dirty = true; | - |
1172 | | - |
1173 | data.winid = 0; | - |
1174 | data.widget_attributes = 0; | - |
1175 | data.window_flags = f; | - |
1176 | data.window_state = 0; | - |
1177 | data.focus_policy = 0; | - |
1178 | data.context_menu_policy = Qt::DefaultContextMenu; | - |
1179 | data.window_modality = Qt::NonModal; | - |
1180 | | - |
1181 | data.sizehint_forced = 0; | - |
1182 | data.is_closing = 0; | - |
1183 | data.in_show = 0; | - |
1184 | data.in_set_window_state = 0; | - |
1185 | data.in_destructor = false; | - |
1186 | | - |
1187 | | - |
1188 | if (f & Qt::MSWindowsOwnDC) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1189 | mustHaveWindowHandle = 1; | - |
1190 | q->setAttribute(Qt::WA_NativeWindow); | - |
1191 | } never executed: end of block | 0 |
1192 | | - |
1193 | | - |
1194 | | - |
1195 | | - |
1196 | q->setAttribute(Qt::WA_QuitOnClose); | - |
1197 | adjustQuitOnCloseAttribute(); | - |
1198 | | - |
1199 | q->setAttribute(Qt::WA_WState_Hidden); | - |
1200 | | - |
1201 | | - |
1202 | data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1203 | focus_next = focus_prev = q; | - |
1204 | | - |
1205 | if ((f & Qt::WindowType_Mask) == Qt::Desktop)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1206 | q->create(); never executed: q->create(); | 0 |
1207 | else if (parentWidget)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1208 | q->setParent(parentWidget, data.window_flags); never executed: q->setParent(parentWidget, data.window_flags); | 0 |
1209 | else { | - |
1210 | adjustFlags(data.window_flags, q); | - |
1211 | resolveLayoutDirection(); | - |
1212 | | - |
1213 | const QBrush &background = q->palette().brush(QPalette::Window); | - |
1214 | setOpaque(q->isWindow() && background.style() != Qt::NoBrush && background.isOpaque()); | - |
1215 | } never executed: end of block | 0 |
1216 | data.fnt = QFont(data.fnt, q); | - |
1217 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - |
1218 | data.fnt.x11SetScreen(xinfo.screen()); | - |
1219 | #endif // Q_DEAD_CODE_FROM_QT4_X11 | - |
1220 | | - |
1221 | q->setAttribute(Qt::WA_PendingMoveEvent); | - |
1222 | q->setAttribute(Qt::WA_PendingResizeEvent); | - |
1223 | | - |
1224 | if (++QWidgetPrivate::instanceCounter > QWidgetPrivate::maxInstances)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1225 | QWidgetPrivate::maxInstances = QWidgetPrivate::instanceCounter; never executed: QWidgetPrivate::maxInstances = QWidgetPrivate::instanceCounter; | 0 |
1226 | | - |
1227 | if (QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation)) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1228 | q->create(); never executed: q->create(); | 0 |
1229 | | - |
1230 | QEvent e(QEvent::Create); | - |
1231 | QApplication::sendEvent(q, &e); | - |
1232 | QApplication::postEvent(q, new QEvent(QEvent::PolishRequest)); | - |
1233 | | - |
1234 | extraPaintEngine = 0; | - |
1235 | | - |
1236 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
1237 | | - |
1238 | if (parentWidget && parentWidget->d_func() && parentWidget->d_func()->isInUnifiedToolbar) { | - |
1239 | if (parentWidget->d_func()->unifiedSurface) { | - |
1240 | QWidget *toolbar = parentWidget->d_func()->toolbar_ancestor; | - |
1241 | parentWidget->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset); | - |
1242 | } | - |
1243 | } | - |
1244 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - |
1245 | } never executed: end of block | 0 |
1246 | | - |
1247 | | - |
1248 | | - |
1249 | void QWidgetPrivate::createRecursively() | - |
1250 | { | - |
1251 | Q_Q(QWidget); | - |
1252 | q->create(0, true, true); | - |
1253 | for (int i = 0; i < children.size(); ++i) { | - |
1254 | QWidget *child = qobject_cast<QWidget *>(children.at(i)); | - |
1255 | if (child && !child->isHidden() && !child->isWindow() && !child->testAttribute(Qt::WA_WState_Created)) | - |
1256 | child->d_func()->createRecursively(); | - |
1257 | } | - |
1258 | } | - |
1259 | | - |
1260 | | - |
1261 | | - |
1262 | | - |
1263 | | - |
1264 | | - |
1265 | | - |
1266 | | - |
1267 | | - |
1268 | | - |
1269 | | - |
1270 | | - |
1271 | | - |
1272 | | - |
1273 | | - |
1274 | | - |
1275 | | - |
1276 | | - |
1277 | | - |
1278 | | - |
1279 | | - |
1280 | | - |
1281 | | - |
1282 | | - |
1283 | | - |
1284 | | - |
1285 | void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) | - |
1286 | { | - |
1287 | Q_D(QWidget); | - |
1288 | if (Q_UNLIKELY(window)) | - |
1289 | qWarning("QWidget::create(): Parameter 'window' does not have any effect."); | - |
1290 | if (testAttribute(Qt::WA_WState_Created) && window == 0 && internalWinId()) | - |
1291 | return; | - |
1292 | | - |
1293 | if (d->data.in_destructor) | - |
1294 | return; | - |
1295 | | - |
1296 | Qt::WindowType type = windowType(); | - |
1297 | Qt::WindowFlags &flags = data->window_flags; | - |
1298 | | - |
1299 | if ((type == Qt::Widget || type == Qt::SubWindow) && !parentWidget()) { | - |
1300 | type = Qt::Window; | - |
1301 | flags |= Qt::Window; | - |
1302 | } | - |
1303 | | - |
1304 | if (QWidget *parent = parentWidget()) { | - |
1305 | if (type & Qt::Window) { | - |
1306 | if (!parent->testAttribute(Qt::WA_WState_Created)) | - |
1307 | parent->createWinId(); | - |
1308 | } else if (testAttribute(Qt::WA_NativeWindow) && !parent->internalWinId() | - |
1309 | && !testAttribute(Qt::WA_DontCreateNativeAncestors)) { | - |
1310 | | - |
1311 | | - |
1312 | | - |
1313 | d->createWinId(); | - |
1314 | | - |
1315 | Q_ASSERT(testAttribute(Qt::WA_WState_Created)); | - |
1316 | Q_ASSERT(internalWinId()); | - |
1317 | return; | - |
1318 | } | - |
1319 | } | - |
1320 | | - |
1321 | | - |
1322 | static const bool paintOnScreenEnv = qEnvironmentVariableIntValue("QT_ONSCREEN_PAINT") > 0; | - |
1323 | if (paintOnScreenEnv) | - |
1324 | setAttribute(Qt::WA_PaintOnScreen); | - |
1325 | | - |
1326 | if (QApplicationPrivate::testAttribute(Qt::AA_NativeWindows)) | - |
1327 | setAttribute(Qt::WA_NativeWindow); | - |
1328 | | - |
1329 | #ifdef ALIEN_DEBUG | - |
1330 | qDebug() << "QWidget::create:" << this << "parent:" << parentWidget() | - |
1331 | << "Alien?" << !testAttribute(Qt::WA_NativeWindow); | - |
1332 | #endif | - |
1333 | | - |
1334 | #if defined (Q_DEAD_CODE_FROM_QT4_WIN) && !defined(QT_NO_DRAGANDDROP) | - |
1335 | | - |
1336 | | - |
1337 | if (testAttribute(Qt::WA_WState_Created) && !internalWinId() && testAttribute(Qt::WA_NativeWindow) | - |
1338 | && d->extra && d->extra->dropTarget) { | - |
1339 | d->registerDropSite(false); | - |
1340 | } | - |
1341 | #endif // defined (Q_DEAD_CODE_FROM_QT4_WIN) && !defined(QT_NO_DRAGANDDROP) | - |
1342 | | - |
1343 | d->updateIsOpaque(); | - |
1344 | | - |
1345 | setAttribute(Qt::WA_WState_Created); | - |
1346 | d->create_sys(window, initializeWindow, destroyOldWindow); | - |
1347 | | - |
1348 | | - |
1349 | if (isWindow() && windowType() != Qt::Desktop) { | - |
1350 | d->topData()->backingStoreTracker.destroy(); | - |
1351 | if (hasBackingStoreSupport()) | - |
1352 | d->topData()->backingStoreTracker.create(this); | - |
1353 | } | - |
1354 | | - |
1355 | d->setModal_sys(); | - |
1356 | | - |
1357 | if (!isWindow() && parentWidget() && parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)) | - |
1358 | setAttribute(Qt::WA_DropSiteRegistered, true); | - |
1359 | | - |
1360 | #ifdef QT_EVAL | - |
1361 | extern void qt_eval_init_widget(QWidget *w); | - |
1362 | qt_eval_init_widget(this); | - |
1363 | #endif | - |
1364 | | - |
1365 | | - |
1366 | if (testAttribute(Qt::WA_SetWindowIcon)) | - |
1367 | d->setWindowIcon_sys(); | - |
1368 | | - |
1369 | if (isWindow() && !d->topData()->iconText.isEmpty()) | - |
1370 | d->setWindowIconText_helper(d->topData()->iconText); | - |
1371 | if (isWindow() && !d->topData()->caption.isEmpty()) | - |
1372 | d->setWindowTitle_helper(d->topData()->caption); | - |
1373 | if (windowType() != Qt::Desktop) { | - |
1374 | d->updateSystemBackground(); | - |
1375 | | - |
1376 | if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon)) | - |
1377 | d->setWindowIcon_sys(); | - |
1378 | } | - |
1379 | | - |
1380 | | - |
1381 | | - |
1382 | | - |
1383 | | - |
1384 | | - |
1385 | d->updateFrameStrut(); | - |
1386 | } | - |
1387 | | - |
1388 | void q_createNativeChildrenAndSetParent(const QWidget *parentWidget) | - |
1389 | { | - |
1390 | QObjectList children = parentWidget->children(); | - |
1391 | for (int i = 0; i < children.size(); i++) { | - |
1392 | if (children.at(i)->isWidgetType()) { | - |
1393 | const QWidget *childWidget = qobject_cast<const QWidget *>(children.at(i)); | - |
1394 | if (childWidget) { | - |
1395 | if (childWidget->testAttribute(Qt::WA_NativeWindow)) { | - |
1396 | if (!childWidget->internalWinId()) | - |
1397 | childWidget->winId(); | - |
1398 | if (childWidget->windowHandle()) { | - |
1399 | if (childWidget->isWindow()) { | - |
1400 | childWidget->windowHandle()->setTransientParent(parentWidget->window()->windowHandle()); | - |
1401 | } else { | - |
1402 | childWidget->windowHandle()->setParent(childWidget->nativeParentWidget()->windowHandle()); | - |
1403 | } | - |
1404 | } | - |
1405 | } else { | - |
1406 | q_createNativeChildrenAndSetParent(childWidget); | - |
1407 | } | - |
1408 | } | - |
1409 | } | - |
1410 | } | - |
1411 | | - |
1412 | } | - |
1413 | | - |
1414 | void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow) | - |
1415 | { | - |
1416 | Q_Q(QWidget); | - |
1417 | | - |
1418 | Q_UNUSED(window); | - |
1419 | Q_UNUSED(initializeWindow); | - |
1420 | Q_UNUSED(destroyOldWindow); | - |
1421 | | - |
1422 | Qt::WindowFlags flags = data.window_flags; | - |
1423 | | - |
1424 | if (!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1425 | return; never executed: return; | 0 |
1426 | | - |
1427 | QWindow *win = topData()->window; | - |
1428 | | - |
1429 | | - |
1430 | if (!win) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1431 | createTLSysExtra(); | - |
1432 | win = topData()->window; | - |
1433 | } never executed: end of block | 0 |
1434 | | - |
1435 | foreachconst auto dynamicPropertyNames = q->dynamicPropertyNames(); | - |
1436 | for (const QByteArray &propertyName , q->: dynamicPropertyNames())) { | - |
1437 | if (!qstrncmp(propertyName, "_q_platform_", 12))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1438 | win->setProperty(propertyName, q->property(propertyName)); never executed: win->setProperty(propertyName, q->property(propertyName)); | 0 |
1439 | } never executed: end of block | 0 |
1440 | | - |
1441 | if (q->testAttribute(Qt::WA_ShowWithoutActivating))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1442 | win->setProperty("_q_showWithoutActivating", QVariant(true)); never executed: win->setProperty("_q_showWithoutActivating", QVariant(true)); | 0 |
1443 | if (q->testAttribute(Qt::WA_MacAlwaysShowToolWindow))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1444 | win->setProperty("_q_macAlwaysShowToolWindow", QVariant::fromValue(QVariant(true))); never executed: win->setProperty("_q_macAlwaysShowToolWindow", QVariant::fromValue(QVariant(true))); | 0 |
1445 | setNetWmWindowTypes(true); | - |
1446 | win->setFlags(data.window_flags); | - |
1447 | fixPosIncludesFrame(); | - |
1448 | if (q->testAttribute(Qt::WA_Moved)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1449 | || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowManagement))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1450 | win->setGeometry(q->geometry()); never executed: win->setGeometry(q->geometry()); | 0 |
1451 | else | - |
1452 | win->resize(q->size()); never executed: win->resize(q->size()); | 0 |
1453 | if (win->isTopLevel()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1454 | int screenNumber = topData()->initialScreenIndex; | - |
1455 | topData()->initialScreenIndex = -1; | - |
1456 | if (screenNumber < 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1457 | screenNumber = q->windowType() != Qt::DesktopTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1458 | ? QApplication::desktop()->screenNumber(q) : 0; | - |
1459 | } never executed: end of block | 0 |
1460 | win->setScreen(QGuiApplication::screens().value(screenNumber, Q_NULLPTR)); | - |
1461 | } never executed: end of block | 0 |
1462 | | - |
1463 | QSurfaceFormat format = win->requestedFormat(); | - |
1464 | if ((flags & Qt::Window) && win->surfaceType() != QSurface::OpenGLSurfaceTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1465 | && q->testAttribute(Qt::WA_TranslucentBackground)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1466 | format.setAlphaBufferSize(8); | - |
1467 | } never executed: end of block | 0 |
1468 | win->setFormat(format); | - |
1469 | | - |
1470 | if (QWidget *nativeParent = q->nativeParentWidget()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1471 | if (nativeParent->windowHandle()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1472 | if (flags & Qt::Window) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1473 | win->setTransientParent(nativeParent->window()->windowHandle()); | - |
1474 | win->setParent(0); | - |
1475 | } else { never executed: end of block | 0 |
1476 | win->setTransientParent(0); | - |
1477 | win->setParent(nativeParent->windowHandle()); | - |
1478 | } never executed: end of block | 0 |
1479 | } | - |
1480 | } never executed: end of block | 0 |
1481 | | - |
1482 | qt_window_private(win)->positionPolicy = topData()->posIncludesFrame ?TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1483 | QWindowPrivate::WindowFrameInclusive : QWindowPrivate::WindowFrameExclusive; | - |
1484 | win->create(); | - |
1485 | | - |
1486 | if ((flags & Qt::Desktop) == Qt::Window)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1487 | { never executed: win->handle()->setFrameStrutEventsEnabled(true); | 0 |
| if (QPlatformWindow *platformWindow = never executed: win->handle()->setFrameStrutEventsEnabled(true); win->handle())never executed: win->handle()->setFrameStrutEventsEnabled(true); | |
| platformWindow-> never executed: win->handle()->setFrameStrutEventsEnabled(true); ()->setFrameStrutEventsEnabled(true);never executed: win->handle()->setFrameStrutEventsEnabled(true); | |
1488 | | - |
1489 | }data.window_flags = win->flags(); | - |
1490 | | - |
1491 | if (!topData()->role.isNull())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1492 | QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1()); never executed: QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1()); | 0 |
1493 | | - |
1494 | QBackingStore *store = q->backingStore(); | - |
1495 | | - |
1496 | if (!store) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1497 | if (win && q->windowType() != Qt::Desktop) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1498 | if (q->isTopLevel())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1499 | q->setBackingStore(new QBackingStore(win)); never executed: q->setBackingStore(new QBackingStore(win)); | 0 |
1500 | } else { never executed: end of block | 0 |
1501 | q->setAttribute(Qt::WA_PaintOnScreen, true); | - |
1502 | } never executed: end of block | 0 |
1503 | } | - |
1504 | | - |
1505 | setWindowModified_helper(); | - |
1506 | WId id = win->winId(); | - |
1507 | | - |
1508 | Q_ASSERT(id != WId(0)); | - |
1509 | setWinId(id); | - |
1510 | | - |
1511 | | - |
1512 | q_createNativeChildrenAndSetParent(q); | - |
1513 | | - |
1514 | if (extra && !extra->mask.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1515 | setMask_sys(extra->mask); never executed: setMask_sys(extra->mask); | 0 |
1516 | | - |
1517 | if (data.crect.width() == 0 || data.crect.height() == 0) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1518 | q->setAttribute(Qt::WA_OutsideWSRange, true); | - |
1519 | } else if (q->isVisible()) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1520 | | - |
1521 | win->setVisible(true); | - |
1522 | } never executed: end of block | 0 |
1523 | } never executed: end of block | 0 |
1524 | | - |
1525 | #ifdef Q_OS_WIN | - |
1526 | static const char activeXNativeParentHandleProperty[] = "_q_embedded_native_parent_handle"; | - |
1527 | #endif | - |
1528 | | - |
1529 | void QWidgetPrivate::createTLSysExtra() | - |
1530 | { | - |
1531 | Q_Q(QWidget); | - |
1532 | if (!extra->topextra->window && (q->testAttribute(Qt::WA_NativeWindow) || q->isWindow())) { | - |
1533 | extra->topextra->window = new QWidgetWindow(q); | - |
1534 | if (extra->minw || extra->minh) | - |
1535 | extra->topextra->window->setMinimumSize(QSize(extra->minw, extra->minh)); | - |
1536 | if (extra->maxw != QWIDGETSIZE_MAX || extra->maxh != QWIDGETSIZE_MAX) | - |
1537 | extra->topextra->window->setMaximumSize(QSize(extra->maxw, extra->maxh)); | - |
1538 | if (extra->topextra->opacity != 255 && q->isWindow()) | - |
1539 | extra->topextra->window->setOpacity(qreal(extra->topextra->opacity) / qreal(255)); | - |
1540 | #ifdef Q_OS_WIN | - |
1541 | | - |
1542 | const QVariant activeXNativeParentHandle = q->property(activeXNativeParentHandleProperty); | - |
1543 | if (activeXNativeParentHandle.isValid()) | - |
1544 | extra->topextra->window->setProperty(activeXNativeParentHandleProperty, activeXNativeParentHandle); | - |
1545 | if (q->inherits("QTipLabel") || q->inherits("QAlphaWidget")) | - |
1546 | extra->topextra->window->setProperty("_q_windowsDropShadow", QVariant(true)); | - |
1547 | #endif | - |
1548 | } | - |
1549 | | - |
1550 | } | - |
1551 | | - |
1552 | | - |
1553 | | - |
1554 | | - |
1555 | | - |
1556 | | - |
1557 | | - |
1558 | | - |
1559 | QWidget::~QWidget() | - |
1560 | { | - |
1561 | Q_D(QWidget); | - |
1562 | d->data.in_destructor = true; | - |
1563 | | - |
1564 | #if defined (QT_CHECK_STATE) | - |
1565 | if (Q_UNLIKELY(paintingActive())())) | - |
1566 | qWarning("QWidget: %s (%s) deleted while being painted", className(), name()); | - |
1567 | #endif | - |
1568 | | - |
1569 | #ifndef QT_NO_GESTURES | - |
1570 | foreachif (QtQGestureManager *manager = QGestureManager::GestureType type,instance()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1571 | | - |
1572 | for (auto it = d->gestureContext.keys())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
| ungrabGestureTRUE | never evaluated | FALSE | never evaluated |
keyBegin(), end = d->gestureContext.keyEnd(); it != end; ++it)TRUE | never evaluated | FALSE | never evaluated |
| |
1573 | manager->cleanupCachedGestures never executed: manager->cleanupCachedGestures(this, *it); (typethis, *it);never executed: manager->cleanupCachedGestures(this, *it); | 0 |
1574 | } never executed: end of block | 0 |
1575 | d->gestureContext.clear(); | - |
1576 | #endif | - |
1577 | | - |
1578 | | - |
1579 | d->registerDropSite(false); | - |
1580 | | - |
1581 | #ifndef QT_NO_ACTION | - |
1582 | | - |
1583 | for (int i = 0; i < d->actions.size(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1584 | QActionPrivate *apriv = d->actions.at(i)->d_func(); | - |
1585 | apriv->widgets.removeAll(this); | - |
1586 | } never executed: end of block | 0 |
1587 | d->actions.clear(); | - |
1588 | #endif | - |
1589 | | - |
1590 | #ifndef QT_NO_SHORTCUT | - |
1591 | | - |
1592 | | - |
1593 | if (!QApplicationPrivate::is_app_closing && testAttribute(Qt::WA_GrabbedShortcut))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1594 | qApp->d_func()->shortcutMap.removeShortcut(0, this, QKeySequence()); never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(0, this, QKeySequence()); | 0 |
1595 | #endif | - |
1596 | | - |
1597 | | - |
1598 | delete d->layout; | - |
1599 | d->layout = 0; | - |
1600 | | - |
1601 | | - |
1602 | Q_ASSERT(d->focus_next->d_func()->focus_prev == this); | - |
1603 | Q_ASSERT(d->focus_prev->d_func()->focus_next == this); | - |
1604 | | - |
1605 | if (d->focus_next != this) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1606 | d->focus_next->d_func()->focus_prev = d->focus_prev; | - |
1607 | d->focus_prev->d_func()->focus_next = d->focus_next; | - |
1608 | d->focus_next = d->focus_prev = 0; | - |
1609 | } never executed: end of block | 0 |
1610 | | - |
1611 | | - |
1612 | QT_TRY { | - |
1613 | #ifndef QT_NO_GRAPHICSVIEW | - |
1614 | const QWidget* w = this; | - |
1615 | while (w->d_func()->extra && w->d_func()->extra->focus_proxy)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1616 | w = w->d_func()->extra->focus_proxy; never executed: w = w->d_func()->extra->focus_proxy; | 0 |
1617 | QWidget *window = w->window(); | - |
1618 | QWExtra *e = window ? window->d_func()->extra : 0;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1619 | if (!e || !e->proxyWidget || (w->parentWidget() && w->parentWidget()->d_func()->focus_child == this))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 |
1620 | #endif | - |
1621 | clearFocus(); never executed: clearFocus(); | 0 |
1622 | } QT_CATCH(...) { never executed: end of block dead code: { } | - |
1623 | dead code: { } | - |
1624 | } dead code: { } | - |
1625 | | - |
1626 | d->setDirtyOpaqueRegion(); | - |
1627 | | - |
1628 | if (isWindow() && isVisible() && internalWinId()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1629 | QT_TRY { | - |
1630 | d->close_helper(QWidgetPrivate::CloseNoEvent); | - |
1631 | } QT_CATCH(...) { never executed: end of block dead code: { if (true) { hide(); } else { } } | - |
1632 | dead code: { if (true) { hide(); } else { } } | - |
1633 | QT_TRY { dead code: { if (true) { hide(); } else { } } | - |
1634 | hide(); dead code: { if (true) { hide(); } else { } } | - |
1635 | } QT_CATCH(...) { dead code: { if (true) { hide(); } else { } } dead code: { } | - |
1636 | dead code: { if (true) { hide(); } else { } } dead code: { } | - |
1637 | } dead code: { if (true) { hide(); } else { } } dead code: { } | - |
1638 | } dead code: { if (true) { hide(); } else { } } | - |
1639 | } | - |
1640 | | - |
1641 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_X11)|| defined(Q_DEAD_CODE_FROM_QT4_MAC) | - |
1642 | else if (!internalWinId() && isVisible()) { | - |
1643 | qApp->d_func()->sendSyntheticEnterLeave(this); | - |
1644 | } | - |
1645 | #endif | - |
1646 | else if (isVisible()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1647 | qApp->d_func()->sendSyntheticEnterLeave(this); | - |
1648 | } never executed: end of block | 0 |
1649 | | - |
1650 | if (QWidgetBackingStore *bs = d->maybeBackingStore()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1651 | bs->removeDirtyWidget(this); | - |
1652 | if (testAttribute(Qt::WA_StaticContents))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1653 | bs->removeStaticWidget(this); never executed: bs->removeStaticWidget(this); | 0 |
1654 | } never executed: end of block | 0 |
1655 | | - |
1656 | delete d->needsFlush; | - |
1657 | d->needsFlush = 0; | - |
1658 | | - |
1659 | | - |
1660 | | - |
1661 | bool blocked = d->blockSig; | - |
1662 | d->blockSig = 0; | - |
1663 | | - |
1664 | if (d->isSignalConnected(0)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1665 | QT_TRY { | - |
1666 | emit destroyed(this); | - |
1667 | } QT_CATCH(...) { never executed: end of block dead code: { QMessageLogger(__FILE__, 1670, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - |
1668 | dead code: { QMessageLogger(__FILE__, 1670, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - |
1669 | dead code: { QMessageLogger(__FILE__, 1670, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - |
1670 | qWarning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); dead code: { QMessageLogger(__FILE__, 1670, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - |
1671 | QT_RETHROW; dead code: { QMessageLogger(__FILE__, 1670, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - |
1672 | } dead code: { QMessageLogger(__FILE__, 1670, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - |
1673 | } | - |
1674 | | - |
1675 | if (d->declarativeData) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1676 | if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1677 | if (QAbstractDeclarativeData::destroyed_qml1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1678 | QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this); never executed: QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this); | 0 |
1679 | } else { never executed: end of block | 0 |
1680 | if (QAbstractDeclarativeData::destroyed)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1681 | QAbstractDeclarativeData::destroyed(d->declarativeData, this); never executed: QAbstractDeclarativeData::destroyed(d->declarativeData, this); | 0 |
1682 | } never executed: end of block | 0 |
1683 | d->declarativeData = 0; | - |
1684 | } never executed: end of block | 0 |
1685 | | - |
1686 | d->blockSig = blocked; | - |
1687 | | - |
1688 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
1689 | | - |
1690 | | - |
1691 | | - |
1692 | | - |
1693 | extern void qt_mac_clearCocoaViewQWidgetPointers(QWidget *); | - |
1694 | qt_mac_clearCocoaViewQWidgetPointers(this); | - |
1695 | #endif | - |
1696 | | - |
1697 | if (!d->children.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1698 | d->deleteChildren(); never executed: d->deleteChildren(); | 0 |
1699 | | - |
1700 | QApplication::removePostedEvents(this); | - |
1701 | | - |
1702 | QT_TRY { | - |
1703 | destroy(); | - |
1704 | } QT_CATCH(...) { never executed: end of block dead code: { } | - |
1705 | dead code: { } | - |
1706 | } dead code: { } | - |
1707 | --QWidgetPrivate::instanceCounter; | - |
1708 | | - |
1709 | if (QWidgetPrivate::allWidgets) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1710 | QWidgetPrivate::allWidgets->remove(this); never executed: QWidgetPrivate::allWidgets->remove(this); | 0 |
1711 | | - |
1712 | QT_TRY { | - |
1713 | QEvent e(QEvent::Destroy); | - |
1714 | QCoreApplication::sendEvent(this, &e); | - |
1715 | } QT_CATCH(const std::exception&) { never executed: end of block dead code: { } | - |
1716 | dead code: { } | - |
1717 | } dead code: { } | - |
1718 | } | - |
1719 | | - |
1720 | int QWidgetPrivate::instanceCounter = 0; | - |
1721 | int QWidgetPrivate::maxInstances = 0; | - |
1722 | | - |
1723 | void QWidgetPrivate::setWinId(WId id) | - |
1724 | { | - |
1725 | Q_Q(QWidget); | - |
1726 | | - |
1727 | | - |
1728 | | - |
1729 | | - |
1730 | | - |
1731 | bool userDesktopWidget = qt_desktopWidget != 0 && qt_desktopWidget != q && q->windowType() == Qt::Desktop; | - |
1732 | if (mapper && data.winid && !userDesktopWidget) { | - |
1733 | mapper->remove(data.winid); | - |
1734 | } | - |
1735 | | - |
1736 | const WId oldWinId = data.winid; | - |
1737 | | - |
1738 | data.winid = id; | - |
1739 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - |
1740 | hd = id; | - |
1741 | #endif | - |
1742 | if (mapper && id && !userDesktopWidget) { | - |
1743 | mapper->insert(data.winid, q); | - |
1744 | } | - |
1745 | | - |
1746 | if(oldWinId != id) { | - |
1747 | QEvent e(QEvent::WinIdChange); | - |
1748 | QCoreApplication::sendEvent(q, &e); | - |
1749 | } | - |
1750 | } | - |
1751 | | - |
1752 | void QWidgetPrivate::createTLExtra() | - |
1753 | { | - |
1754 | if (!extra) | - |
1755 | createExtra(); | - |
1756 | if (!extra->topextra) { | - |
1757 | QTLWExtra* x = extra->topextra = new QTLWExtra; | - |
1758 | x->icon = 0; | - |
1759 | x->backingStore = 0; | - |
1760 | x->sharedPainter = 0; | - |
1761 | x->incw = x->inch = 0; | - |
1762 | x->basew = x->baseh = 0; | - |
1763 | x->frameStrut.setCoords(0, 0, 0, 0); | - |
1764 | x->normalGeometry = QRect(0,0,-1,-1); | - |
1765 | x->savedFlags = 0; | - |
1766 | x->opacity = 255; | - |
1767 | x->posIncludesFrame = 0; | - |
1768 | x->sizeAdjusted = false; | - |
1769 | x->inTopLevelResize = false; | - |
1770 | x->inRepaint = false; | - |
1771 | x->embedded = 0; | - |
1772 | x->window = 0; | - |
1773 | x->shareContext = 0; | - |
1774 | x->initialScreenIndex = -1; | - |
1775 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
1776 | x->wasMaximized = false; | - |
1777 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - |
1778 | #ifdef QWIDGET_EXTRA_DEBUG | - |
1779 | static int count = 0; | - |
1780 | qDebug() << "tlextra" << ++count; | - |
1781 | #endif | - |
1782 | } | - |
1783 | } | - |
1784 | | - |
1785 | | - |
1786 | | - |
1787 | | - |
1788 | | - |
1789 | | - |
1790 | void QWidgetPrivate::createExtra() | - |
1791 | { | - |
1792 | if (!extra) { | - |
1793 | extra = new QWExtra; | - |
1794 | extra->glContext = 0; | - |
1795 | extra->topextra = 0; | - |
1796 | #ifndef QT_NO_GRAPHICSVIEW | - |
1797 | extra->proxyWidget = 0; | - |
1798 | #endif | - |
1799 | #ifndef QT_NO_CURSOR | - |
1800 | extra->curs = 0; | - |
1801 | #endif | - |
1802 | extra->minw = 0; | - |
1803 | extra->minh = 0; | - |
1804 | extra->maxw = QWIDGETSIZE_MAX; | - |
1805 | extra->maxh = QWIDGETSIZE_MAX; | - |
1806 | extra->customDpiX = 0; | - |
1807 | extra->customDpiY = 0; | - |
1808 | extra->explicitMinSize = 0; | - |
1809 | extra->explicitMaxSize = 0; | - |
1810 | extra->autoFillBackground = 0; | - |
1811 | extra->nativeChildrenForced = 0; | - |
1812 | extra->inRenderWithPainter = 0; | - |
1813 | extra->hasWindowContainer = false; | - |
1814 | extra->hasMask = 0; | - |
1815 | createSysExtra(); | - |
1816 | #ifdef QWIDGET_EXTRA_DEBUG | - |
1817 | static int count = 0; | - |
1818 | qDebug() << "extra" << ++count; | - |
1819 | #endif | - |
1820 | } | - |
1821 | } | - |
1822 | | - |
1823 | void QWidgetPrivate::createSysExtra() | - |
1824 | { | - |
1825 | } | - |
1826 | | - |
1827 | | - |
1828 | | - |
1829 | | - |
1830 | | - |
1831 | | - |
1832 | void QWidgetPrivate::deleteExtra() | - |
1833 | { | - |
1834 | if (extra) { | - |
1835 | #ifndef QT_NO_CURSOR | - |
1836 | delete extra->curs; | - |
1837 | #endif | - |
1838 | deleteSysExtra(); | - |
1839 | #ifndef QT_NO_STYLE_STYLESHEET | - |
1840 | | - |
1841 | if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(extra->style)) | - |
1842 | proxy->deref(); | - |
1843 | #endif | - |
1844 | if (extra->topextra) { | - |
1845 | deleteTLSysExtra(); | - |
1846 | | - |
1847 | delete extra->topextra->icon; | - |
1848 | delete extra->topextra; | - |
1849 | } | - |
1850 | delete extra; | - |
1851 | | - |
1852 | extra = 0; | - |
1853 | } | - |
1854 | } | - |
1855 | | - |
1856 | void QWidgetPrivate::deleteSysExtra() | - |
1857 | { | - |
1858 | } | - |
1859 | | - |
1860 | static void deleteBackingStore(QWidgetPrivate *d) | - |
1861 | { | - |
1862 | QTLWExtra *topData = d->topData(); | - |
1863 | | - |
1864 | | - |
1865 | | - |
1866 | | - |
1867 | | - |
1868 | QScopedPointer<QOffscreenSurface> tempSurface; | - |
1869 | #ifndef QT_NO_OPENGL | - |
1870 | if (d->textureChildSeen && topData->shareContext) { | - |
1871 | if (topData->window->handle()) { | - |
1872 | topData->shareContext->makeCurrent(topData->window); | - |
1873 | } else { | - |
1874 | tempSurface.reset(new QOffscreenSurface); | - |
1875 | tempSurface->setFormat(topData->shareContext->format()); | - |
1876 | tempSurface->create(); | - |
1877 | topData->shareContext->makeCurrent(tempSurface.data()); | - |
1878 | } | - |
1879 | } | - |
1880 | #endif | - |
1881 | | - |
1882 | delete topData->backingStore; | - |
1883 | topData->backingStore = 0; | - |
1884 | | - |
1885 | #ifndef QT_NO_OPENGL | - |
1886 | if (d->textureChildSeen && topData->shareContext) | - |
1887 | topData->shareContext->doneCurrent(); | - |
1888 | #endif | - |
1889 | } | - |
1890 | | - |
1891 | void QWidgetPrivate::deleteTLSysExtra() | - |
1892 | { | - |
1893 | if (extra && extra->topextra) { | - |
1894 | | - |
1895 | | - |
1896 | | - |
1897 | | - |
1898 | extra->topextra->backingStoreTracker.destroy(); | - |
1899 | deleteBackingStore(this); | - |
1900 | #ifndef QT_NO_OPENGL | - |
1901 | qDeleteAll(extra->topextra->widgetTextures); | - |
1902 | extra->topextra->widgetTextures.clear(); | - |
1903 | delete extra->topextra->shareContext; | - |
1904 | extra->topextra->shareContext = 0; | - |
1905 | #endif | - |
1906 | | - |
1907 | | - |
1908 | | - |
1909 | | - |
1910 | | - |
1911 | if (extra->topextra->window) { | - |
1912 | extra->topextra->window->destroy(); | - |
1913 | } | - |
1914 | delete extra->topextra->window; | - |
1915 | extra->topextra->window = 0; | - |
1916 | | - |
1917 | } | - |
1918 | } | - |
1919 | | - |
1920 | | - |
1921 | | - |
1922 | | - |
1923 | | - |
1924 | | - |
1925 | bool QWidgetPrivate::isOverlapped(const QRect &rect) const | - |
1926 | { | - |
1927 | Q_Q(const QWidget); | - |
1928 | | - |
1929 | const QWidget *w = q; | - |
1930 | QRect r = rect; | - |
1931 | while (w) { | - |
1932 | if (w->isWindow()) | - |
1933 | return false; | - |
1934 | QWidgetPrivate *pd = w->parentWidget()->d_func(); | - |
1935 | bool above = false; | - |
1936 | for (int i = 0; i < pd->children.size(); ++i) { | - |
1937 | QWidget *sibling = qobject_cast<QWidget *>(pd->children.at(i)); | - |
1938 | if (!sibling || !sibling->isVisible() || sibling->isWindow()) | - |
1939 | continue; | - |
1940 | if (!above) { | - |
1941 | above = (sibling == w); | - |
1942 | continue; | - |
1943 | } | - |
1944 | | - |
1945 | if (qRectIntersects(sibling->d_func()->effectiveRectFor(sibling->data->crect), r)) { | - |
1946 | const QWExtra *siblingExtra = sibling->d_func()->extra; | - |
1947 | if (siblingExtra && siblingExtra->hasMask && !sibling->d_func()->graphicsEffect | - |
1948 | && !siblingExtra->mask.translated(sibling->data->crect.topLeft()).intersects(r)) { | - |
1949 | continue; | - |
1950 | } | - |
1951 | return true; | - |
1952 | } | - |
1953 | } | - |
1954 | w = w->parentWidget(); | - |
1955 | r.translate(pd->data.crect.topLeft()); | - |
1956 | } | - |
1957 | return false; | - |
1958 | } | - |
1959 | | - |
1960 | void QWidgetPrivate::syncBackingStore() | - |
1961 | { | - |
1962 | if (paintOnScreen()) { | - |
1963 | repaint_sys(dirty); | - |
1964 | dirty = QRegion(); | - |
1965 | } else if (QWidgetBackingStore *bs = maybeBackingStore()) { | - |
1966 | bs->sync(); | - |
1967 | } | - |
1968 | } | - |
1969 | | - |
1970 | void QWidgetPrivate::syncBackingStore(const QRegion ®ion) | - |
1971 | { | - |
1972 | if (paintOnScreen()) | - |
1973 | repaint_sys(region); | - |
1974 | else if (QWidgetBackingStore *bs = maybeBackingStore()) { | - |
1975 | bs->sync(q_func(), region); | - |
1976 | } | - |
1977 | } | - |
1978 | | - |
1979 | void QWidgetPrivate::setUpdatesEnabled_helper(bool enable) | - |
1980 | { | - |
1981 | Q_Q(QWidget); | - |
1982 | | - |
1983 | if (enable && !q->isWindow() && q->parentWidget() && !q->parentWidget()->updatesEnabled()) | - |
1984 | return; | - |
1985 | | - |
1986 | if (enable != q->testAttribute(Qt::WA_UpdatesDisabled)) | - |
1987 | return; | - |
1988 | | - |
1989 | q->setAttribute(Qt::WA_UpdatesDisabled, !enable); | - |
1990 | if (enable) | - |
1991 | q->update(); | - |
1992 | | - |
1993 | Qt::WidgetAttribute attribute = enable ? Qt::WA_ForceUpdatesDisabled : Qt::WA_UpdatesDisabled; | - |
1994 | for (int i = 0; i < children.size(); ++i) { | - |
1995 | QWidget *w = qobject_cast<QWidget *>(children.at(i)); | - |
1996 | if (w && !w->isWindow() && !w->testAttribute(attribute)) | - |
1997 | w->d_func()->setUpdatesEnabled_helper(enable); | - |
1998 | } | - |
1999 | } | - |
2000 | | - |
2001 | | - |
2002 | | - |
2003 | | - |
2004 | | - |
2005 | | - |
2006 | | - |
2007 | | - |
2008 | void QWidgetPrivate::propagatePaletteChange() | - |
2009 | { | - |
2010 | Q_Q(QWidget); | - |
2011 | | - |
2012 | #ifndef QT_NO_GRAPHICSVIEW | - |
2013 | if (!q->parentWidget() && extra && extra->proxyWidget) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2014 | QGraphicsProxyWidget *p = extra->proxyWidget; | - |
2015 | inheritedPaletteResolveMask = p->d_func()->inheritedPaletteResolveMask | p->palette().resolve(); | - |
2016 | } else never executed: end of block | 0 |
2017 | #endif //QT_NO_GRAPHICSVIEW | - |
2018 | if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2019 | inheritedPaletteResolveMask = 0; | - |
2020 | } never executed: end of block | 0 |
2021 | int mask = data.pal.resolve() | inheritedPaletteResolveMask; | - |
2022 | | - |
2023 | const bool useStyleSheetPropagationInWidgetStyles = | - |
2024 | QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); | - |
2025 | | - |
2026 | QEvent pc(QEvent::PaletteChange); | - |
2027 | QApplication::sendEvent(q, &pc); | - |
2028 | for (int i = 0; i < children.size(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2029 | QWidget *w = qobject_cast<QWidget*>(children.at(i)); | - |
2030 | if (w && !(!w->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2031 | && (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2032 | QWidgetPrivate *wd = w->d_func(); | - |
2033 | wd->inheritedPaletteResolveMask = mask; | - |
2034 | wd->resolvePalette(); | - |
2035 | } never executed: end of block | 0 |
2036 | } never executed: end of block | 0 |
2037 | } never executed: end of block | 0 |
2038 | | - |
2039 | | - |
2040 | | - |
2041 | | - |
2042 | QRect QWidgetPrivate::clipRect() const | - |
2043 | { | - |
2044 | Q_Q(const QWidget); | - |
2045 | const QWidget * w = q; | - |
2046 | if (!w->isVisible()) | - |
2047 | return QRect(); | - |
2048 | QRect r = effectiveRectFor(q->rect()); | - |
2049 | int ox = 0; | - |
2050 | int oy = 0; | - |
2051 | while (w | - |
2052 | && w->isVisible() | - |
2053 | && !w->isWindow() | - |
2054 | && w->parentWidget()) { | - |
2055 | ox -= w->x(); | - |
2056 | oy -= w->y(); | - |
2057 | w = w->parentWidget(); | - |
2058 | r &= QRect(ox, oy, w->width(), w->height()); | - |
2059 | } | - |
2060 | return r; | - |
2061 | } | - |
2062 | | - |
2063 | | - |
2064 | | - |
2065 | | - |
2066 | QRegion QWidgetPrivate::clipRegion() const | - |
2067 | { | - |
2068 | Q_Q(const QWidget); | - |
2069 | if (!q->isVisible()) | - |
2070 | return QRegion(); | - |
2071 | QRegion r(q->rect()); | - |
2072 | const QWidget * w = q; | - |
2073 | const QWidget *ignoreUpTo; | - |
2074 | int ox = 0; | - |
2075 | int oy = 0; | - |
2076 | while (w | - |
2077 | && w->isVisible() | - |
2078 | && !w->isWindow() | - |
2079 | && w->parentWidget()) { | - |
2080 | ox -= w->x(); | - |
2081 | oy -= w->y(); | - |
2082 | ignoreUpTo = w; | - |
2083 | w = w->parentWidget(); | - |
2084 | r &= QRegion(ox, oy, w->width(), w->height()); | - |
2085 | | - |
2086 | int i = 0; | - |
2087 | while(w->d_func()->children.at(i++) != static_cast<const QObject *>(ignoreUpTo)) | - |
2088 | ; | - |
2089 | for ( ; i < w->d_func()->children.size(); ++i) { | - |
2090 | if(QWidget *sibling = qobject_cast<QWidget *>(w->d_func()->children.at(i))) { | - |
2091 | if(sibling->isVisible() && !sibling->isWindow()) { | - |
2092 | QRect siblingRect(ox+sibling->x(), oy+sibling->y(), | - |
2093 | sibling->width(), sibling->height()); | - |
2094 | if (qRectIntersects(siblingRect, q->rect())) | - |
2095 | r -= QRegion(siblingRect); | - |
2096 | } | - |
2097 | } | - |
2098 | } | - |
2099 | } | - |
2100 | return r; | - |
2101 | } | - |
2102 | | - |
2103 | void QWidgetPrivate::setSystemClip(QPaintDevice *paintDevice, const QRegion ®ion) | - |
2104 | { | - |
2105 | | - |
2106 | QPaintEngine *paintEngine = paintDevice->paintEngine(); | - |
2107 | QTransform scaleTransform; | - |
2108 | const qreal devicePixelRatio = paintDevice->devicePixelRatioF(); | - |
2109 | scaleTransform.scale(devicePixelRatio, devicePixelRatio); | - |
2110 | paintEngine->d_func()->systemClip = scaleTransform.map(region); | - |
2111 | } | - |
2112 | | - |
2113 | #ifndef QT_NO_GRAPHICSEFFECT | - |
2114 | void QWidgetPrivate::invalidateGraphicsEffectsRecursively() | - |
2115 | { | - |
2116 | Q_Q(QWidget); | - |
2117 | QWidget *w = q; | - |
2118 | do { | - |
2119 | if (w->graphicsEffect()) { | - |
2120 | QWidgetEffectSourcePrivate *sourced = | - |
2121 | static_cast<QWidgetEffectSourcePrivate *>(w->graphicsEffect()->source()->d_func()); | - |
2122 | if (!sourced->updateDueToGraphicsEffect) | - |
2123 | w->graphicsEffect()->source()->d_func()->invalidateCache(); | - |
2124 | } | - |
2125 | w = w->parentWidget(); | - |
2126 | } while (w); | - |
2127 | } | - |
2128 | #endif //QT_NO_GRAPHICSEFFECT | - |
2129 | | - |
2130 | void QWidgetPrivate::setDirtyOpaqueRegion() | - |
2131 | { | - |
2132 | Q_Q(QWidget); | - |
2133 | | - |
2134 | dirtyOpaqueChildren = true; | - |
2135 | | - |
2136 | #ifndef QT_NO_GRAPHICSEFFECT | - |
2137 | invalidateGraphicsEffectsRecursively(); | - |
2138 | #endif //QT_NO_GRAPHICSEFFECT | - |
2139 | | - |
2140 | if (q->isWindow()) | - |
2141 | return; | - |
2142 | | - |
2143 | QWidget *parent = q->parentWidget(); | - |
2144 | if (!parent) | - |
2145 | return; | - |
2146 | | - |
2147 | | - |
2148 | QWidgetPrivate *pd = parent->d_func(); | - |
2149 | if (!pd->dirtyOpaqueChildren) | - |
2150 | pd->setDirtyOpaqueRegion(); | - |
2151 | } | - |
2152 | | - |
2153 | const QRegion &QWidgetPrivate::getOpaqueChildren() const | - |
2154 | { | - |
2155 | if (!dirtyOpaqueChildren) | - |
2156 | return opaqueChildren; | - |
2157 | | - |
2158 | QWidgetPrivate *that = const_cast<QWidgetPrivate*>(this); | - |
2159 | that->opaqueChildren = QRegion(); | - |
2160 | | - |
2161 | for (int i = 0; i < children.size(); ++i) { | - |
2162 | QWidget *child = qobject_cast<QWidget *>(children.at(i)); | - |
2163 | if (!child || !child->isVisible() || child->isWindow()) | - |
2164 | continue; | - |
2165 | | - |
2166 | const QPoint offset = child->geometry().topLeft(); | - |
2167 | QWidgetPrivate *childd = child->d_func(); | - |
2168 | QRegion r = childd->isOpaque ? child->rect() : childd->getOpaqueChildren(); | - |
2169 | if (childd->extra && childd->extra->hasMask) | - |
2170 | r &= childd->extra->mask; | - |
2171 | if (r.isEmpty()) | - |
2172 | continue; | - |
2173 | r.translate(offset); | - |
2174 | that->opaqueChildren += r; | - |
2175 | } | - |
2176 | | - |
2177 | that->opaqueChildren &= q_func()->rect(); | - |
2178 | that->dirtyOpaqueChildren = false; | - |
2179 | | - |
2180 | return that->opaqueChildren; | - |
2181 | } | - |
2182 | | - |
2183 | void QWidgetPrivate::subtractOpaqueChildren(QRegion &source, const QRect &clipRect) const | - |
2184 | { | - |
2185 | if (children.isEmpty() || clipRect.isEmpty()) | - |
2186 | return; | - |
2187 | | - |
2188 | const QRegion &r = getOpaqueChildren(); | - |
2189 | if (!r.isEmpty()) | - |
2190 | source -= (r & clipRect); | - |
2191 | } | - |
2192 | | - |
2193 | | - |
2194 | void QWidgetPrivate::subtractOpaqueSiblings(QRegion &sourceRegion, bool *hasDirtySiblingsAbove, | - |
2195 | bool alsoNonOpaque) const | - |
2196 | { | - |
2197 | Q_Q(const QWidget); | - |
2198 | static int disableSubtractOpaqueSiblings = qEnvironmentVariableIntValue("QT_NO_SUBTRACTOPAQUESIBLINGS"); | - |
2199 | if (disableSubtractOpaqueSiblings || q->isWindow()) | - |
2200 | return; | - |
2201 | | - |
2202 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
2203 | if (q->d_func()->isInUnifiedToolbar) | - |
2204 | return; | - |
2205 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - |
2206 | | - |
2207 | QRect clipBoundingRect; | - |
2208 | bool dirtyClipBoundingRect = true; | - |
2209 | | - |
2210 | QRegion parentClip; | - |
2211 | bool dirtyParentClip = true; | - |
2212 | | - |
2213 | QPoint parentOffset = data.crect.topLeft(); | - |
2214 | | - |
2215 | const QWidget *w = q; | - |
2216 | | - |
2217 | while (w) { | - |
2218 | if (w->isWindow()) | - |
2219 | break; | - |
2220 | QWidgetPrivate *pd = w->parentWidget()->d_func(); | - |
2221 | const int myIndex = pd->children.indexOf(const_cast<QWidget *>(w)); | - |
2222 | const QRect widgetGeometry = w->d_func()->effectiveRectFor(w->data->crect); | - |
2223 | for (int i = myIndex + 1; i < pd->children.size(); ++i) { | - |
2224 | QWidget *sibling = qobject_cast<QWidget *>(pd->children.at(i)); | - |
2225 | if (!sibling || !sibling->isVisible() || sibling->isWindow()) | - |
2226 | continue; | - |
2227 | | - |
2228 | const QRect siblingGeometry = sibling->d_func()->effectiveRectFor(sibling->data->crect); | - |
2229 | if (!qRectIntersects(siblingGeometry, widgetGeometry)) | - |
2230 | continue; | - |
2231 | | - |
2232 | if (dirtyClipBoundingRect) { | - |
2233 | clipBoundingRect = sourceRegion.boundingRect(); | - |
2234 | dirtyClipBoundingRect = false; | - |
2235 | } | - |
2236 | | - |
2237 | if (!qRectIntersects(siblingGeometry, clipBoundingRect.translated(parentOffset))) | - |
2238 | continue; | - |
2239 | | - |
2240 | if (dirtyParentClip) { | - |
2241 | parentClip = sourceRegion.translated(parentOffset); | - |
2242 | dirtyParentClip = false; | - |
2243 | } | - |
2244 | | - |
2245 | const QPoint siblingPos(sibling->data->crect.topLeft()); | - |
2246 | const QRect siblingClipRect(sibling->d_func()->clipRect()); | - |
2247 | QRegion siblingDirty(parentClip); | - |
2248 | siblingDirty &= (siblingClipRect.translated(siblingPos)); | - |
2249 | const bool hasMask = sibling->d_func()->extra && sibling->d_func()->extra->hasMask | - |
2250 | && !sibling->d_func()->graphicsEffect; | - |
2251 | if (hasMask) | - |
2252 | siblingDirty &= sibling->d_func()->extra->mask.translated(siblingPos); | - |
2253 | if (siblingDirty.isEmpty()) | - |
2254 | continue; | - |
2255 | | - |
2256 | if (sibling->d_func()->isOpaque || alsoNonOpaque) { | - |
2257 | if (hasMask) { | - |
2258 | siblingDirty.translate(-parentOffset); | - |
2259 | sourceRegion -= siblingDirty; | - |
2260 | } else { | - |
2261 | sourceRegion -= siblingGeometry.translated(-parentOffset); | - |
2262 | } | - |
2263 | } else { | - |
2264 | if (hasDirtySiblingsAbove) | - |
2265 | *hasDirtySiblingsAbove = true; | - |
2266 | if (sibling->d_func()->children.isEmpty()) | - |
2267 | continue; | - |
2268 | QRegion opaqueSiblingChildren(sibling->d_func()->getOpaqueChildren()); | - |
2269 | opaqueSiblingChildren.translate(-parentOffset + siblingPos); | - |
2270 | sourceRegion -= opaqueSiblingChildren; | - |
2271 | } | - |
2272 | if (sourceRegion.isEmpty()) | - |
2273 | return; | - |
2274 | | - |
2275 | dirtyClipBoundingRect = true; | - |
2276 | dirtyParentClip = true; | - |
2277 | } | - |
2278 | | - |
2279 | w = w->parentWidget(); | - |
2280 | parentOffset += pd->data.crect.topLeft(); | - |
2281 | dirtyParentClip = true; | - |
2282 | } | - |
2283 | } | - |
2284 | | - |
2285 | void QWidgetPrivate::clipToEffectiveMask(QRegion ®ion) const | - |
2286 | { | - |
2287 | Q_Q(const QWidget); | - |
2288 | | - |
2289 | const QWidget *w = q; | - |
2290 | QPoint offset; | - |
2291 | | - |
2292 | #ifndef QT_NO_GRAPHICSEFFECT | - |
2293 | if (graphicsEffect) { | - |
2294 | w = q->parentWidget(); | - |
2295 | offset -= data.crect.topLeft(); | - |
2296 | } | - |
2297 | #endif //QT_NO_GRAPHICSEFFECT | - |
2298 | | - |
2299 | while (w) { | - |
2300 | const QWidgetPrivate *wd = w->d_func(); | - |
2301 | if (wd->extra && wd->extra->hasMask) | - |
2302 | region &= (w != q) ? wd->extra->mask.translated(offset) : wd->extra->mask; | - |
2303 | if (w->isWindow()) | - |
2304 | return; | - |
2305 | offset -= wd->data.crect.topLeft(); | - |
2306 | w = w->parentWidget(); | - |
2307 | } | - |
2308 | } | - |
2309 | | - |
2310 | bool QWidgetPrivate::paintOnScreen() const | - |
2311 | { | - |
2312 | #if defined(QT_NO_BACKINGSTORE) | - |
2313 | return true; | - |
2314 | #else | - |
2315 | Q_Q(const QWidget); | - |
2316 | if (q->testAttribute(Qt::WA_PaintOnScreen) | - |
2317 | || (!q->isWindow() && q->window()->testAttribute(Qt::WA_PaintOnScreen))) { | - |
2318 | return true; | - |
2319 | } | - |
2320 | | - |
2321 | return !qt_enable_backingstore; | - |
2322 | #endif | - |
2323 | } | - |
2324 | | - |
2325 | void QWidgetPrivate::updateIsOpaque() | - |
2326 | { | - |
2327 | | - |
2328 | setDirtyOpaqueRegion(); | - |
2329 | | - |
2330 | #ifndef QT_NO_GRAPHICSEFFECT | - |
2331 | if (graphicsEffect) { | - |
2332 | | - |
2333 | setOpaque(false); | - |
2334 | return; | - |
2335 | } | - |
2336 | #endif //QT_NO_GRAPHICSEFFECT | - |
2337 | | - |
2338 | Q_Q(QWidget); | - |
2339 | #ifdef Q_DEAD_CODE_FROM_QT4_X11 | - |
2340 | if (q->testAttribute(Qt::WA_X11OpenGLOverlay)) { | - |
2341 | setOpaque(false); | - |
2342 | return; | - |
2343 | } | - |
2344 | #endif | - |
2345 | | - |
2346 | if (q->testAttribute(Qt::WA_OpaquePaintEvent) || q->testAttribute(Qt::WA_PaintOnScreen)) { | - |
2347 | setOpaque(true); | - |
2348 | return; | - |
2349 | } | - |
2350 | | - |
2351 | const QPalette &pal = q->palette(); | - |
2352 | | - |
2353 | if (q->autoFillBackground()) { | - |
2354 | const QBrush &autoFillBrush = pal.brush(q->backgroundRole()); | - |
2355 | if (autoFillBrush.style() != Qt::NoBrush && autoFillBrush.isOpaque()) { | - |
2356 | setOpaque(true); | - |
2357 | return; | - |
2358 | } | - |
2359 | } | - |
2360 | | - |
2361 | if (q->isWindow() && !q->testAttribute(Qt::WA_NoSystemBackground)) { | - |
2362 | const QBrush &windowBrush = q->palette().brush(QPalette::Window); | - |
2363 | if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) { | - |
2364 | setOpaque(true); | - |
2365 | return; | - |
2366 | } | - |
2367 | } | - |
2368 | setOpaque(false); | - |
2369 | } | - |
2370 | | - |
2371 | void QWidgetPrivate::setOpaque(bool opaque) | - |
2372 | { | - |
2373 | if (isOpaque != opaque) { | - |
2374 | isOpaque = opaque; | - |
2375 | updateIsTranslucent(); | - |
2376 | } | - |
2377 | } | - |
2378 | | - |
2379 | void QWidgetPrivate::updateIsTranslucent() | - |
2380 | { | - |
2381 | Q_Q(QWidget); | - |
2382 | if (QWindow *window = q->windowHandle()) { | - |
2383 | QSurfaceFormat format = window->format(); | - |
2384 | const int oldAlpha = format.alphaBufferSize(); | - |
2385 | const int newAlpha = q->testAttribute(Qt::WA_TranslucentBackground)? 8 : 0; | - |
2386 | if (oldAlpha != newAlpha) { | - |
2387 | format.setAlphaBufferSize(newAlpha); | - |
2388 | window->setFormat(format); | - |
2389 | } | - |
2390 | } | - |
2391 | } | - |
2392 | | - |
2393 | static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrush &brush) | - |
2394 | { | - |
2395 | Q_ASSERT(painter); | - |
2396 | | - |
2397 | if (brush.style() == Qt::TexturePattern) { | - |
2398 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
2399 | | - |
2400 | | - |
2401 | | - |
2402 | extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush); | - |
2403 | qt_mac_fill_background(painter, rgn, brush); | - |
2404 | #else | - |
2405 | { | - |
2406 | const QRect rect(rgn.boundingRect()); | - |
2407 | painter->setClipRegion(rgn); | - |
2408 | painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); | - |
2409 | } | - |
2410 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - |
2411 | | - |
2412 | } else if (brush.gradient() | - |
2413 | && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode) { | - |
2414 | painter->save(); | - |
2415 | painter->setClipRegion(rgn); | - |
2416 | painter->fillRect(0, 0, painter->device()->width(), painter->device()->height(), brush); | - |
2417 | painter->restore(); | - |
2418 | } else { | - |
2419 | const QVector<QRect> &rects = rgn.rects(); | - |
2420 | for (int i = 0; i < rects.size(); ++i) | - |
2421 | painter->fillRect(rects.at(i), brush); | - |
2422 | } | - |
2423 | } | - |
2424 | | - |
2425 | void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int flags) const | - |
2426 | { | - |
2427 | Q_Q(const QWidget); | - |
2428 | | - |
2429 | #ifndef QT_NO_SCROLLAREA | - |
2430 | bool resetBrushOrigin = false; | - |
2431 | QPointF oldBrushOrigin; | - |
2432 | | - |
2433 | QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent); | - |
2434 | if (scrollArea && scrollArea->viewport() == q) { | - |
2435 | QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr.data(); | - |
2436 | QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate); | - |
2437 | oldBrushOrigin = painter->brushOrigin(); | - |
2438 | resetBrushOrigin = true; | - |
2439 | painter->setBrushOrigin(-priv->contentsOffset()); | - |
2440 | | - |
2441 | } | - |
2442 | #endif // QT_NO_SCROLLAREA | - |
2443 | | - |
2444 | const QBrush autoFillBrush = q->palette().brush(q->backgroundRole()); | - |
2445 | | - |
2446 | if ((flags & DrawAsRoot) && !(q->autoFillBackground() && autoFillBrush.isOpaque())) { | - |
2447 | const QBrush bg = q->palette().brush(QPalette::Window); | - |
2448 | if (!(flags & DontSetCompositionMode)) { | - |
2449 | | - |
2450 | QPainter::CompositionMode oldMode = painter->compositionMode(); | - |
2451 | painter->setCompositionMode(QPainter::CompositionMode_Source); | - |
2452 | fillRegion(painter, rgn, bg); | - |
2453 | painter->setCompositionMode(oldMode); | - |
2454 | } else { | - |
2455 | fillRegion(painter, rgn, bg); | - |
2456 | } | - |
2457 | } | - |
2458 | | - |
2459 | if (q->autoFillBackground()) | - |
2460 | fillRegion(painter, rgn, autoFillBrush); | - |
2461 | | - |
2462 | if (q->testAttribute(Qt::WA_StyledBackground)) { | - |
2463 | painter->setClipRegion(rgn); | - |
2464 | QStyleOption opt; | - |
2465 | opt.initFrom(q); | - |
2466 | q->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, q); | - |
2467 | } | - |
2468 | | - |
2469 | #ifndef QT_NO_SCROLLAREA | - |
2470 | if (resetBrushOrigin) | - |
2471 | painter->setBrushOrigin(oldBrushOrigin); | - |
2472 | #endif // QT_NO_SCROLLAREA | - |
2473 | } | - |
2474 | | - |
2475 | | - |
2476 | | - |
2477 | | - |
2478 | | - |
2479 | | - |
2480 | | - |
2481 | | - |
2482 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
2483 | extern QPointer<QWidget> qt_button_down; | - |
2484 | #else | - |
2485 | extern QWidget *qt_button_down; | - |
2486 | #endif | - |
2487 | | - |
2488 | void QWidgetPrivate::deactivateWidgetCleanup() | - |
2489 | { | - |
2490 | Q_Q(QWidget); | - |
2491 | | - |
2492 | if (QApplication::activeWindow() == q) | - |
2493 | QApplication::setActiveWindow(0); | - |
2494 | | - |
2495 | if (q == qt_button_down) | - |
2496 | qt_button_down = 0; | - |
2497 | } | - |
2498 | | - |
2499 | | - |
2500 | | - |
2501 | | - |
2502 | | - |
2503 | | - |
2504 | | - |
2505 | | - |
2506 | | - |
2507 | | - |
2508 | | - |
2509 | QWidget *QWidget::find(WId id) | - |
2510 | { | - |
2511 | return QWidgetPrivate::mapper ? QWidgetPrivate::mapper->value(id, 0) : 0; | - |
2512 | } | - |
2513 | | - |
2514 | | - |
2515 | | - |
2516 | | - |
2517 | | - |
2518 | | - |
2519 | | - |
2520 | | - |
2521 | | - |
2522 | | - |
2523 | | - |
2524 | | - |
2525 | | - |
2526 | | - |
2527 | | - |
2528 | | - |
2529 | | - |
2530 | | - |
2531 | | - |
2532 | | - |
2533 | | - |
2534 | | - |
2535 | | - |
2536 | | - |
2537 | | - |
2538 | | - |
2539 | | - |
2540 | | - |
2541 | | - |
2542 | | - |
2543 | WId QWidget::winId() const | - |
2544 | { | - |
2545 | if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { | - |
2546 | #ifdef ALIEN_DEBUG | - |
2547 | qDebug() << "QWidget::winId: creating native window for" << this; | - |
2548 | #endif | - |
2549 | QWidget *that = const_cast<QWidget*>(this); | - |
2550 | that->setAttribute(Qt::WA_NativeWindow); | - |
2551 | that->d_func()->createWinId(); | - |
2552 | return that->data->winid; | - |
2553 | } | - |
2554 | return data->winid; | - |
2555 | } | - |
2556 | | - |
2557 | void QWidgetPrivate::createWinId() | - |
2558 | { | - |
2559 | Q_Q(QWidget); | - |
2560 | | - |
2561 | #ifdef ALIEN_DEBUG | - |
2562 | qDebug() << "QWidgetPrivate::createWinId for" << q; | - |
2563 | #endif | - |
2564 | const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow); | - |
2565 | if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) { | - |
2566 | if (!q->isWindow()) { | - |
2567 | QWidget *parent = q->parentWidget(); | - |
2568 | QWidgetPrivate *pd = parent->d_func(); | - |
2569 | if (forceNativeWindow && !q->testAttribute(Qt::WA_DontCreateNativeAncestors)) | - |
2570 | parent->setAttribute(Qt::WA_NativeWindow); | - |
2571 | if (!parent->internalWinId()) { | - |
2572 | pd->createWinId(); | - |
2573 | } | - |
2574 | | - |
2575 | for (int i = 0; i < pd->children.size(); ++i) { | - |
2576 | QWidget *w = qobject_cast<QWidget *>(pd->children.at(i)); | - |
2577 | if (w && !w->isWindow() && (!w->testAttribute(Qt::WA_WState_Created) | - |
2578 | || (!w->internalWinId() && w->testAttribute(Qt::WA_NativeWindow)))) { | - |
2579 | w->create(); | - |
2580 | } | - |
2581 | } | - |
2582 | } else { | - |
2583 | q->create(); | - |
2584 | } | - |
2585 | } | - |
2586 | } | - |
2587 | | - |
2588 | | - |
2589 | | - |
2590 | | - |
2591 | | - |
2592 | | - |
2593 | | - |
2594 | | - |
2595 | void QWidget::createWinId() | - |
2596 | { | - |
2597 | Q_D(QWidget); | - |
2598 | #ifdef ALIEN_DEBUG | - |
2599 | qDebug() << "QWidget::createWinId" << this; | - |
2600 | #endif | - |
2601 | | - |
2602 | d->createWinId(); | - |
2603 | } | - |
2604 | | - |
2605 | | - |
2606 | | - |
2607 | | - |
2608 | | - |
2609 | | - |
2610 | | - |
2611 | | - |
2612 | | - |
2613 | | - |
2614 | | - |
2615 | | - |
2616 | | - |
2617 | | - |
2618 | | - |
2619 | | - |
2620 | WId QWidget::effectiveWinId() const | - |
2621 | { | - |
2622 | const WId id = internalWinId(); | - |
2623 | if (id || !testAttribute(Qt::WA_WState_Created)) | - |
2624 | return id; | - |
2625 | if (const QWidget *realParent = nativeParentWidget()) | - |
2626 | return realParent->internalWinId(); | - |
2627 | return 0; | - |
2628 | } | - |
2629 | | - |
2630 | | - |
2631 | | - |
2632 | | - |
2633 | | - |
2634 | | - |
2635 | | - |
2636 | | - |
2637 | | - |
2638 | | - |
2639 | | - |
2640 | | - |
2641 | QWindow *QWidget::windowHandle() const | - |
2642 | { | - |
2643 | Q_D(const QWidget); | - |
2644 | QTLWExtra *extra = d->maybeTopData(); | - |
2645 | if (extra) | - |
2646 | return extra->window; | - |
2647 | | - |
2648 | return 0; | - |
2649 | } | - |
2650 | | - |
2651 | #ifndef QT_NO_STYLE_STYLESHEET | - |
2652 | | - |
2653 | | - |
2654 | | - |
2655 | | - |
2656 | | - |
2657 | | - |
2658 | | - |
2659 | | - |
2660 | | - |
2661 | | - |
2662 | | - |
2663 | | - |
2664 | | - |
2665 | | - |
2666 | | - |
2667 | | - |
2668 | QString QWidget::styleSheet() const | - |
2669 | { | - |
2670 | Q_D(const QWidget); | - |
2671 | if (!d->extra) | - |
2672 | return QString(); | - |
2673 | return d->extra->styleSheet; | - |
2674 | } | - |
2675 | | - |
2676 | void QWidget::setStyleSheet(const QString& styleSheet) | - |
2677 | { | - |
2678 | Q_D(QWidget); | - |
2679 | if (data->in_destructor) | - |
2680 | return; | - |
2681 | d->createExtra(); | - |
2682 | | - |
2683 | QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(d->extra->style); | - |
2684 | d->extra->styleSheet = styleSheet; | - |
2685 | if (styleSheet.isEmpty()) { | - |
2686 | if (!proxy) | - |
2687 | return; | - |
2688 | | - |
2689 | d->inheritStyle(); | - |
2690 | return; | - |
2691 | } | - |
2692 | | - |
2693 | if (proxy) { | - |
2694 | if (d->polished) | - |
2695 | proxy->repolish(this); | - |
2696 | return; | - |
2697 | } | - |
2698 | | - |
2699 | if (testAttribute(Qt::WA_SetStyle)) { | - |
2700 | d->setStyle_helper(new QStyleSheetStyle(d->extra->style), true); | - |
2701 | } else { | - |
2702 | d->setStyle_helper(new QStyleSheetStyle(0), true); | - |
2703 | } | - |
2704 | } | - |
2705 | | - |
2706 | #endif // QT_NO_STYLE_STYLESHEET | - |
2707 | | - |
2708 | | - |
2709 | | - |
2710 | | - |
2711 | | - |
2712 | QStyle *QWidget::style() const | - |
2713 | { | - |
2714 | Q_D(const QWidget); | - |
2715 | | - |
2716 | if (d->extra && d->extra->style) | - |
2717 | return d->extra->style; | - |
2718 | return QApplication::style(); | - |
2719 | } | - |
2720 | | - |
2721 | | - |
2722 | | - |
2723 | | - |
2724 | | - |
2725 | | - |
2726 | | - |
2727 | | - |
2728 | | - |
2729 | | - |
2730 | | - |
2731 | | - |
2732 | | - |
2733 | | - |
2734 | | - |
2735 | | - |
2736 | | - |
2737 | | - |
2738 | | - |
2739 | | - |
2740 | | - |
2741 | | - |
2742 | void QWidget::setStyle(QStyle *style) | - |
2743 | { | - |
2744 | Q_D(QWidget); | - |
2745 | setAttribute(Qt::WA_SetStyle, style != 0); | - |
2746 | d->createExtra(); | - |
2747 | #ifndef QT_NO_STYLE_STYLESHEET | - |
2748 | if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(style)) { | - |
2749 | | - |
2750 | | - |
2751 | proxy->ref(); | - |
2752 | d->setStyle_helper(style, false); | - |
2753 | } else if (qobject_cast<QStyleSheetStyle *>(d->extra->style) || !qApp->styleSheet().isEmpty()) { | - |
2754 | | - |
2755 | d->setStyle_helper(new QStyleSheetStyle(style), true); | - |
2756 | } else | - |
2757 | #endif | - |
2758 | d->setStyle_helper(style, false); | - |
2759 | } | - |
2760 | | - |
2761 | void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool | - |
2762 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
2763 | metalHack | - |
2764 | #endif | - |
2765 | ) | - |
2766 | { | - |
2767 | Q_Q(QWidget); | - |
2768 | QStyle *oldStyle = q->style(); | - |
2769 | #ifndef QT_NO_STYLE_STYLESHEET | - |
2770 | QPointer<QStyle> origStyle; | - |
2771 | #endif | - |
2772 | | - |
2773 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
2774 | | - |
2775 | | - |
2776 | | - |
2777 | | - |
2778 | if (!metalHack) | - |
2779 | #endif | - |
2780 | { | - |
2781 | createExtra(); | - |
2782 | | - |
2783 | #ifndef QT_NO_STYLE_STYLESHEET | - |
2784 | origStyle = extra->style.data(); | - |
2785 | #endif | - |
2786 | extra->style = newStyle; | - |
2787 | } | - |
2788 | | - |
2789 | | - |
2790 | if (q->windowType() != Qt::Desktop) { | - |
2791 | if (polished) { | - |
2792 | oldStyle->unpolish(q); | - |
2793 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
2794 | if (metalHack) | - |
2795 | macUpdateMetalAttribute(); | - |
2796 | #endif | - |
2797 | q->style()->polish(q); | - |
2798 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
2799 | } else if (metalHack) { | - |
2800 | macUpdateMetalAttribute(); | - |
2801 | #endif | - |
2802 | } | - |
2803 | } | - |
2804 | | - |
2805 | if (propagate) { | - |
2806 | | - |
2807 | const QObjectList childrenList = children; | - |
2808 | for (int i = 0; i < childrenList.size(); ++i) { | - |
2809 | QWidget *c = qobject_cast<QWidget*>(childrenList.at(i)); | - |
2810 | if (c) | - |
2811 | c->d_func()->inheritStyle(); | - |
2812 | } | - |
2813 | } | - |
2814 | | - |
2815 | #ifndef QT_NO_STYLE_STYLESHEET | - |
2816 | if (!qobject_cast<QStyleSheetStyle*>(newStyle)) { | - |
2817 | if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle.data())) { | - |
2818 | cssStyle->clearWidgetFont(q); | - |
2819 | } | - |
2820 | } | - |
2821 | #endif | - |
2822 | | - |
2823 | QEvent e(QEvent::StyleChange); | - |
2824 | QApplication::sendEvent(q, &e); | - |
2825 | | - |
2826 | #ifndef QT_NO_STYLE_STYLESHEET | - |
2827 | | - |
2828 | if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle.data())) | - |
2829 | proxy->deref(); | - |
2830 | #endif | - |
2831 | } | - |
2832 | | - |
2833 | | - |
2834 | void QWidgetPrivate::inheritStyle() | - |
2835 | { | - |
2836 | #ifndef QT_NO_STYLE_STYLESHEET | - |
2837 | Q_Q(QWidget); | - |
2838 | | - |
2839 | QStyleSheetStyle *proxy = extra ? qobject_cast<QStyleSheetStyle *>(extra->style) : 0; | - |
2840 | | - |
2841 | if (!q->styleSheet().isEmpty()) { | - |
2842 | Q_ASSERT(proxy); | - |
2843 | proxy->repolish(q); | - |
2844 | return; | - |
2845 | } | - |
2846 | | - |
2847 | QStyle *origStyle = proxy ? proxy->base : (extra ? (QStyle*)extra->style : 0); | - |
2848 | QWidget *parent = q->parentWidget(); | - |
2849 | QStyle *parentStyle = (parent && parent->d_func()->extra) ? (QStyle*)parent->d_func()->extra->style : 0; | - |
2850 | | - |
2851 | | - |
2852 | if (!qApp->styleSheet().isEmpty() || qobject_cast<QStyleSheetStyle *>(parentStyle)) { | - |
2853 | QStyle *newStyle = parentStyle; | - |
2854 | if (q->testAttribute(Qt::WA_SetStyle)) | - |
2855 | newStyle = new QStyleSheetStyle(origStyle); | - |
2856 | else if (QStyleSheetStyle *newProxy = qobject_cast<QStyleSheetStyle *>(parentStyle)) | - |
2857 | newProxy->ref(); | - |
2858 | | - |
2859 | setStyle_helper(newStyle, true); | - |
2860 | return; | - |
2861 | } | - |
2862 | | - |
2863 | | - |
2864 | | - |
2865 | if (origStyle == (extra ? (QStyle*)extra->style : 0)) | - |
2866 | return; | - |
2867 | | - |
2868 | | - |
2869 | | - |
2870 | | - |
2871 | if (!q->testAttribute(Qt::WA_SetStyle)) | - |
2872 | origStyle = 0; | - |
2873 | | - |
2874 | setStyle_helper(origStyle, true); | - |
2875 | #endif // QT_NO_STYLE_STYLESHEET | - |
2876 | } | - |
2877 | | - |
2878 | | - |
2879 | | - |
2880 | | - |
2881 | | - |
2882 | | - |
2883 | | - |
2884 | | - |
2885 | | - |
2886 | | - |
2887 | | - |
2888 | | - |
2889 | | - |
2890 | | - |
2891 | | - |
2892 | | - |
2893 | | - |
2894 | | - |
2895 | | - |
2896 | | - |
2897 | | - |
2898 | | - |
2899 | | - |
2900 | | - |
2901 | | - |
2902 | | - |
2903 | | - |
2904 | | - |
2905 | | - |
2906 | | - |
2907 | | - |
2908 | | - |
2909 | | - |
2910 | | - |
2911 | | - |
2912 | | - |
2913 | | - |
2914 | | - |
2915 | | - |
2916 | | - |
2917 | | - |
2918 | | - |
2919 | | - |
2920 | | - |
2921 | | - |
2922 | | - |
2923 | | - |
2924 | | - |
2925 | | - |
2926 | | - |
2927 | | - |
2928 | | - |
2929 | | - |
2930 | Qt::WindowModality QWidget::windowModality() const | - |
2931 | { | - |
2932 | return static_cast<Qt::WindowModality>(data->window_modality); | - |
2933 | } | - |
2934 | | - |
2935 | void QWidget::setWindowModality(Qt::WindowModality windowModality) | - |
2936 | { | - |
2937 | data->window_modality = windowModality; | - |
2938 | | - |
2939 | setAttribute(Qt::WA_ShowModal, (data->window_modality != Qt::NonModal)); | - |
2940 | setAttribute(Qt::WA_SetWindowModality, true); | - |
2941 | } | - |
2942 | | - |
2943 | void QWidgetPrivate::setModal_sys() | - |
2944 | { | - |
2945 | Q_Q(QWidget); | - |
2946 | if (q->windowHandle()) | - |
2947 | q->windowHandle()->setModality(q->windowModality()); | - |
2948 | } | - |
2949 | | - |
2950 | | - |
2951 | | - |
2952 | | - |
2953 | | - |
2954 | | - |
2955 | | - |
2956 | | - |
2957 | | - |
2958 | | - |
2959 | | - |
2960 | | - |
2961 | | - |
2962 | | - |
2963 | | - |
2964 | | - |
2965 | | - |
2966 | | - |
2967 | | - |
2968 | | - |
2969 | | - |
2970 | | - |
2971 | | - |
2972 | bool QWidget::isMinimized() const | - |
2973 | { return data->window_state & Qt::WindowMinimized; } | - |
2974 | | - |
2975 | | - |
2976 | | - |
2977 | | - |
2978 | | - |
2979 | | - |
2980 | | - |
2981 | | - |
2982 | | - |
2983 | void QWidget::showMinimized() | - |
2984 | { | - |
2985 | bool isMin = isMinimized(); | - |
2986 | if (isMin && isVisible()) | - |
2987 | return; | - |
2988 | | - |
2989 | ensurePolished(); | - |
2990 | | - |
2991 | if (!isMin) | - |
2992 | setWindowState((windowState() & ~Qt::WindowActive) | Qt::WindowMinimized); | - |
2993 | setVisible(true); | - |
2994 | } | - |
2995 | | - |
2996 | | - |
2997 | | - |
2998 | | - |
2999 | | - |
3000 | | - |
3001 | | - |
3002 | | - |
3003 | | - |
3004 | | - |
3005 | | - |
3006 | | - |
3007 | | - |
3008 | | - |
3009 | | - |
3010 | | - |
3011 | | - |
3012 | bool QWidget::isMaximized() const | - |
3013 | { return data->window_state & Qt::WindowMaximized; } | - |
3014 | | - |
3015 | | - |
3016 | | - |
3017 | | - |
3018 | | - |
3019 | | - |
3020 | | - |
3021 | | - |
3022 | | - |
3023 | | - |
3024 | Qt::WindowStates QWidget::windowState() const | - |
3025 | { | - |
3026 | return Qt::WindowStates(data->window_state); | - |
3027 | } | - |
3028 | | - |
3029 | | - |
3030 | | - |
3031 | | - |
3032 | | - |
3033 | | - |
3034 | | - |
3035 | | - |
3036 | void QWidget::overrideWindowState(Qt::WindowStates newstate) | - |
3037 | { | - |
3038 | QWindowStateChangeEvent e(Qt::WindowStates(data->window_state), true); | - |
3039 | data->window_state = newstate; | - |
3040 | QApplication::sendEvent(this, &e); | - |
3041 | } | - |
3042 | | - |
3043 | Qt::WindowState effectiveState(Qt::WindowStates state) | - |
3044 | { | - |
3045 | if (state & Qt::WindowMinimized) | - |
3046 | return Qt::WindowMinimized; | - |
3047 | else if (state & Qt::WindowFullScreen) | - |
3048 | return Qt::WindowFullScreen; | - |
3049 | else if (state & Qt::WindowMaximized) | - |
3050 | return Qt::WindowMaximized; | - |
3051 | return Qt::WindowNoState; | - |
3052 | } | - |
3053 | | - |
3054 | | - |
3055 | | - |
3056 | | - |
3057 | | - |
3058 | | - |
3059 | | - |
3060 | | - |
3061 | | - |
3062 | | - |
3063 | | - |
3064 | | - |
3065 | | - |
3066 | | - |
3067 | | - |
3068 | | - |
3069 | | - |
3070 | | - |
3071 | | - |
3072 | | - |
3073 | | - |
3074 | | - |
3075 | | - |
3076 | | - |
3077 | | - |
3078 | | - |
3079 | | - |
3080 | | - |
3081 | | - |
3082 | | - |
3083 | | - |
3084 | void QWidget::setWindowState(Qt::WindowStates newstate) | - |
3085 | { | - |
3086 | Q_D(QWidget); | - |
3087 | Qt::WindowStates oldstate = windowState(); | - |
3088 | if (oldstate == newstate) | - |
3089 | return; | - |
3090 | if (isWindow() && !testAttribute(Qt::WA_WState_Created)) | - |
3091 | create(); | - |
3092 | | - |
3093 | data->window_state = newstate; | - |
3094 | data->in_set_window_state = 1; | - |
3095 | Qt::WindowState newEffectiveState = effectiveState(newstate); | - |
3096 | Qt::WindowState oldEffectiveState = effectiveState(oldstate); | - |
3097 | if (isWindow() && newEffectiveState != oldEffectiveState) { | - |
3098 | | - |
3099 | if (!testAttribute(Qt::WA_Resized) && !isVisible()) | - |
3100 | adjustSize(); | - |
3101 | | - |
3102 | d->createTLExtra(); | - |
3103 | if (oldEffectiveState == Qt::WindowNoState) | - |
3104 | d->topData()->normalGeometry = geometry(); | - |
3105 | | - |
3106 | Q_ASSERT(windowHandle()); | - |
3107 | windowHandle()->setWindowState(newEffectiveState); | - |
3108 | } | - |
3109 | data->in_set_window_state = 0; | - |
3110 | | - |
3111 | if (newstate & Qt::WindowActive) | - |
3112 | activateWindow(); | - |
3113 | | - |
3114 | QWindowStateChangeEvent e(oldstate); | - |
3115 | QApplication::sendEvent(this, &e); | - |
3116 | } | - |
3117 | | - |
3118 | | - |
3119 | | - |
3120 | | - |
3121 | | - |
3122 | | - |
3123 | | - |
3124 | | - |
3125 | | - |
3126 | | - |
3127 | | - |
3128 | | - |
3129 | bool QWidget::isFullScreen() const | - |
3130 | { return data->window_state & Qt::WindowFullScreen; } | - |
3131 | | - |
3132 | | - |
3133 | | - |
3134 | | - |
3135 | | - |
3136 | | - |
3137 | | - |
3138 | | - |
3139 | | - |
3140 | | - |
3141 | | - |
3142 | | - |
3143 | | - |
3144 | | - |
3145 | | - |
3146 | | - |
3147 | | - |
3148 | | - |
3149 | | - |
3150 | | - |
3151 | | - |
3152 | | - |
3153 | | - |
3154 | | - |
3155 | | - |
3156 | | - |
3157 | | - |
3158 | | - |
3159 | | - |
3160 | | - |
3161 | void QWidget::showFullScreen() | - |
3162 | { | - |
3163 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
3164 | | - |
3165 | QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); | - |
3166 | if (mainWindow && mainWindow->unifiedTitleAndToolBarOnMac()) { | - |
3167 | mainWindow->setUnifiedTitleAndToolBarOnMac(false); | - |
3168 | QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); | - |
3169 | mainLayout->activateUnifiedToolbarAfterFullScreen = true; | - |
3170 | } | - |
3171 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - |
3172 | ensurePolished(); | - |
3173 | | - |
3174 | setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowMaximized)) | - |
3175 | | Qt::WindowFullScreen); | - |
3176 | setVisible(true); | - |
3177 | #if !defined Q_OS_QNX // On QNX this window will be activated anyway from libscreen | - |
3178 | | - |
3179 | activateWindow(); | - |
3180 | #endif | - |
3181 | } | - |
3182 | | - |
3183 | | - |
3184 | | - |
3185 | | - |
3186 | | - |
3187 | | - |
3188 | | - |
3189 | | - |
3190 | | - |
3191 | | - |
3192 | | - |
3193 | void QWidget::showMaximized() | - |
3194 | { | - |
3195 | ensurePolished(); | - |
3196 | | - |
3197 | setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen)) | - |
3198 | | Qt::WindowMaximized); | - |
3199 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
3200 | | - |
3201 | QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); | - |
3202 | if (mainWindow) | - |
3203 | { | - |
3204 | QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); | - |
3205 | if (mainLayout->activateUnifiedToolbarAfterFullScreen) { | - |
3206 | mainWindow->setUnifiedTitleAndToolBarOnMac(true); | - |
3207 | mainLayout->activateUnifiedToolbarAfterFullScreen = false; | - |
3208 | } | - |
3209 | } | - |
3210 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - |
3211 | setVisible(true); | - |
3212 | } | - |
3213 | | - |
3214 | | - |
3215 | | - |
3216 | | - |
3217 | | - |
3218 | | - |
3219 | | - |
3220 | | - |
3221 | void QWidget::showNormal() | - |
3222 | { | - |
3223 | ensurePolished(); | - |
3224 | | - |
3225 | setWindowState(windowState() & ~(Qt::WindowMinimized | - |
3226 | | Qt::WindowMaximized | - |
3227 | | Qt::WindowFullScreen)); | - |
3228 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
3229 | | - |
3230 | QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); | - |
3231 | if (mainWindow) | - |
3232 | { | - |
3233 | QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); | - |
3234 | if (mainLayout->activateUnifiedToolbarAfterFullScreen) { | - |
3235 | mainWindow->setUnifiedTitleAndToolBarOnMac(true); | - |
3236 | mainLayout->activateUnifiedToolbarAfterFullScreen = false; | - |
3237 | } | - |
3238 | } | - |
3239 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - |
3240 | setVisible(true); | - |
3241 | } | - |
3242 | | - |
3243 | | - |
3244 | | - |
3245 | | - |
3246 | | - |
3247 | | - |
3248 | | - |
3249 | | - |
3250 | | - |
3251 | | - |
3252 | | - |
3253 | | - |
3254 | | - |
3255 | | - |
3256 | | - |
3257 | | - |
3258 | | - |
3259 | | - |
3260 | | - |
3261 | | - |
3262 | | - |
3263 | bool QWidget::isEnabledTo(const QWidget *ancestor) const | - |
3264 | { | - |
3265 | const QWidget * w = this; | - |
3266 | while (!w->testAttribute(Qt::WA_ForceDisabled) | - |
3267 | && !w->isWindow() | - |
3268 | && w->parentWidget() | - |
3269 | && w->parentWidget() != ancestor) | - |
3270 | w = w->parentWidget(); | - |
3271 | return !w->testAttribute(Qt::WA_ForceDisabled); | - |
3272 | } | - |
3273 | | - |
3274 | #ifndef QT_NO_ACTION | - |
3275 | | - |
3276 | | - |
3277 | | - |
3278 | | - |
3279 | | - |
3280 | | - |
3281 | | - |
3282 | | - |
3283 | | - |
3284 | | - |
3285 | | - |
3286 | | - |
3287 | | - |
3288 | | - |
3289 | | - |
3290 | void QWidget::addAction(QAction *action) | - |
3291 | { | - |
3292 | insertAction(0, action); | - |
3293 | } | - |
3294 | | - |
3295 | | - |
3296 | | - |
3297 | | - |
3298 | | - |
3299 | | - |
3300 | #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) | - |
3301 | void QWidget::addActions(const QList<QAction *> &actions) | - |
3302 | #else | - |
3303 | void QWidget::addActions(QList<QAction*> actions) | - |
3304 | #endif | - |
3305 | { | - |
3306 | for(int i = 0; i < actions.count(); i++) | - |
3307 | insertAction(0, actions.at(i)); | - |
3308 | } | - |
3309 | | - |
3310 | | - |
3311 | | - |
3312 | | - |
3313 | | - |
3314 | | - |
3315 | | - |
3316 | | - |
3317 | | - |
3318 | | - |
3319 | void QWidget::insertAction(QAction *before, QAction *action) | - |
3320 | { | - |
3321 | if (Q_UNLIKELY(!action))) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3322 | qWarning("QWidget::insertAction: Attempt to insert null action"); | - |
3323 | return; never executed: return; | 0 |
3324 | } | - |
3325 | | - |
3326 | Q_D(QWidget); | - |
3327 | if(d->actions.contains(action))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3328 | removeAction(action); never executed: removeAction(action); | 0 |
3329 | | - |
3330 | int pos = d->actions.indexOf(before); | - |
3331 | if (pos < 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3332 | before = 0; | - |
3333 | pos = d->actions.size(); | - |
3334 | } never executed: end of block | 0 |
3335 | d->actions.insert(pos, action); | - |
3336 | | - |
3337 | QActionPrivate *apriv = action->d_func(); | - |
3338 | apriv->widgets.append(this); | - |
3339 | | - |
3340 | QActionEvent e(QEvent::ActionAdded, action, before); | - |
3341 | QApplication::sendEvent(this, &e); | - |
3342 | } never executed: end of block | 0 |
3343 | | - |
3344 | | - |
3345 | | - |
3346 | | - |
3347 | | - |
3348 | | - |
3349 | | - |
3350 | | - |
3351 | | - |
3352 | | - |
3353 | #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) | - |
3354 | void QWidget::insertActions(QAction *before, const QList<QAction*> &actions) | - |
3355 | #else | - |
3356 | void QWidget::insertActions(QAction *before, QList<QAction*> actions) | - |
3357 | #endif | - |
3358 | { | - |
3359 | for(int i = 0; i < actions.count(); ++i)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3360 | insertAction(before, actions.at(i)); never executed: insertAction(before, actions.at(i)); | 0 |
3361 | } never executed: end of block | 0 |
3362 | | - |
3363 | | - |
3364 | | - |
3365 | | - |
3366 | | - |
3367 | void QWidget::removeAction(QAction *action) | - |
3368 | { | - |
3369 | if (!action) | - |
3370 | return; | - |
3371 | | - |
3372 | Q_D(QWidget); | - |
3373 | | - |
3374 | QActionPrivate *apriv = action->d_func(); | - |
3375 | apriv->widgets.removeAll(this); | - |
3376 | | - |
3377 | if (d->actions.removeAll(action)) { | - |
3378 | QActionEvent e(QEvent::ActionRemoved, action); | - |
3379 | QApplication::sendEvent(this, &e); | - |
3380 | } | - |
3381 | } | - |
3382 | | - |
3383 | | - |
3384 | | - |
3385 | | - |
3386 | | - |
3387 | | - |
3388 | QList<QAction*> QWidget::actions() const | - |
3389 | { | - |
3390 | Q_D(const QWidget); | - |
3391 | return d->actions; | - |
3392 | } | - |
3393 | #endif // QT_NO_ACTION | - |
3394 | | - |
3395 | | - |
3396 | | - |
3397 | | - |
3398 | | - |
3399 | | - |
3400 | | - |
3401 | | - |
3402 | | - |
3403 | | - |
3404 | | - |
3405 | | - |
3406 | | - |
3407 | | - |
3408 | | - |
3409 | | - |
3410 | | - |
3411 | | - |
3412 | | - |
3413 | | - |
3414 | | - |
3415 | | - |
3416 | | - |
3417 | | - |
3418 | | - |
3419 | | - |
3420 | | - |
3421 | | - |
3422 | | - |
3423 | void QWidget::setEnabled(bool enable) | - |
3424 | { | - |
3425 | Q_D(QWidget); | - |
3426 | setAttribute(Qt::WA_ForceDisabled, !enable); | - |
3427 | d->setEnabled_helper(enable); | - |
3428 | } | - |
3429 | | - |
3430 | void QWidgetPrivate::setEnabled_helper(bool enable) | - |
3431 | { | - |
3432 | Q_Q(QWidget); | - |
3433 | | - |
3434 | if (enable && !q->isWindow() && q->parentWidget() && !q->parentWidget()->isEnabled()) | - |
3435 | return; | - |
3436 | | - |
3437 | if (enable != q->testAttribute(Qt::WA_Disabled)) | - |
3438 | return; | - |
3439 | | - |
3440 | q->setAttribute(Qt::WA_Disabled, !enable); | - |
3441 | updateSystemBackground(); | - |
3442 | | - |
3443 | if (!enable && q->window()->focusWidget() == q) { | - |
3444 | bool parentIsEnabled = (!q->parentWidget() || q->parentWidget()->isEnabled()); | - |
3445 | if (!parentIsEnabled || !q->focusNextChild()) | - |
3446 | q->clearFocus(); | - |
3447 | } | - |
3448 | | - |
3449 | Qt::WidgetAttribute attribute = enable ? Qt::WA_ForceDisabled : Qt::WA_Disabled; | - |
3450 | for (int i = 0; i < children.size(); ++i) { | - |
3451 | QWidget *w = qobject_cast<QWidget *>(children.at(i)); | - |
3452 | if (w && !w->testAttribute(attribute)) | - |
3453 | w->d_func()->setEnabled_helper(enable); | - |
3454 | } | - |
3455 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - |
3456 | if (q->testAttribute(Qt::WA_SetCursor) || q->isWindow()) { | - |
3457 | | - |
3458 | | - |
3459 | qt_x11_enforce_cursor(q); | - |
3460 | } | - |
3461 | #endif | - |
3462 | #ifndef QT_NO_CURSOR | - |
3463 | if (q->testAttribute(Qt::WA_SetCursor) || q->isWindow()) { | - |
3464 | | - |
3465 | | - |
3466 | qt_qpa_set_cursor(q, false); | - |
3467 | } | - |
3468 | #endif | - |
3469 | #if defined(Q_DEAD_CODE_FROM_QT4_MAC) | - |
3470 | setEnabled_helper_sys(enable); | - |
3471 | #endif | - |
3472 | #ifndef QT_NO_IM | - |
3473 | if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) { | - |
3474 | QWidget *focusWidget = effectiveFocusWidget(); | - |
3475 | | - |
3476 | if (enable) { | - |
3477 | if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) | - |
3478 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); | - |
3479 | } else { | - |
3480 | QGuiApplication::inputMethod()->commit(); | - |
3481 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); | - |
3482 | } | - |
3483 | } | - |
3484 | #endif //QT_NO_IM | - |
3485 | QEvent e(QEvent::EnabledChange); | - |
3486 | QApplication::sendEvent(q, &e); | - |
3487 | } | - |
3488 | | - |
3489 | | - |
3490 | | - |
3491 | | - |
3492 | | - |
3493 | | - |
3494 | | - |
3495 | | - |
3496 | | - |
3497 | | - |
3498 | | - |
3499 | | - |
3500 | | - |
3501 | | - |
3502 | | - |
3503 | | - |
3504 | | - |
3505 | | - |
3506 | bool QWidget::acceptDrops() const | - |
3507 | { | - |
3508 | return testAttribute(Qt::WA_AcceptDrops); | - |
3509 | } | - |
3510 | | - |
3511 | void QWidget::setAcceptDrops(bool on) | - |
3512 | { | - |
3513 | setAttribute(Qt::WA_AcceptDrops, on); | - |
3514 | | - |
3515 | } | - |
3516 | | - |
3517 | void QWidgetPrivate::registerDropSite(bool on) | - |
3518 | { | - |
3519 | Q_UNUSED(on); | - |
3520 | } | - |
3521 | | - |
3522 | | - |
3523 | | - |
3524 | | - |
3525 | | - |
3526 | | - |
3527 | | - |
3528 | | - |
3529 | | - |
3530 | void QWidget::setDisabled(bool disable) | - |
3531 | { | - |
3532 | setEnabled(!disable); | - |
3533 | } | - |
3534 | | - |
3535 | | - |
3536 | | - |
3537 | | - |
3538 | | - |
3539 | | - |
3540 | | - |
3541 | | - |
3542 | | - |
3543 | | - |
3544 | | - |
3545 | | - |
3546 | | - |
3547 | | - |
3548 | QRect QWidget::frameGeometry() const | - |
3549 | { | - |
3550 | Q_D(const QWidget); | - |
3551 | if (isWindow() && ! (windowType() == Qt::Popup)) { | - |
3552 | QRect fs = d->frameStrut(); | - |
3553 | return QRect(data->crect.x() - fs.left(), | - |
3554 | data->crect.y() - fs.top(), | - |
3555 | data->crect.width() + fs.left() + fs.right(), | - |
3556 | data->crect.height() + fs.top() + fs.bottom()); | - |
3557 | } | - |
3558 | return data->crect; | - |
3559 | } | - |
3560 | | - |
3561 | | - |
3562 | | - |
3563 | | - |
3564 | | - |
3565 | | - |
3566 | | - |
3567 | | - |
3568 | | - |
3569 | | - |
3570 | | - |
3571 | | - |
3572 | | - |
3573 | | - |
3574 | int QWidget::x() const | - |
3575 | { | - |
3576 | Q_D(const QWidget); | - |
3577 | if (isWindow() && ! (windowType() == Qt::Popup)) | - |
3578 | return data->crect.x() - d->frameStrut().left(); | - |
3579 | return data->crect.x(); | - |
3580 | } | - |
3581 | | - |
3582 | | - |
3583 | | - |
3584 | | - |
3585 | | - |
3586 | | - |
3587 | | - |
3588 | | - |
3589 | | - |
3590 | | - |
3591 | | - |
3592 | | - |
3593 | | - |
3594 | int QWidget::y() const | - |
3595 | { | - |
3596 | Q_D(const QWidget); | - |
3597 | if (isWindow() && ! (windowType() == Qt::Popup)) | - |
3598 | return data->crect.y() - d->frameStrut().top(); | - |
3599 | return data->crect.y(); | - |
3600 | } | - |
3601 | | - |
3602 | | - |
3603 | | - |
3604 | | - |
3605 | | - |
3606 | | - |
3607 | | - |
3608 | | - |
3609 | | - |
3610 | | - |
3611 | | - |
3612 | | - |
3613 | | - |
3614 | | - |
3615 | | - |
3616 | | - |
3617 | | - |
3618 | | - |
3619 | | - |
3620 | | - |
3621 | | - |
3622 | | - |
3623 | | - |
3624 | | - |
3625 | QPoint QWidget::pos() const | - |
3626 | { | - |
3627 | Q_D(const QWidget); | - |
3628 | QPoint result = data->crect.topLeft(); | - |
3629 | if (isWindow() && ! (windowType() == Qt::Popup)) | - |
3630 | if (!d->maybeTopData() || !d->maybeTopData()->posIncludesFrame) | - |
3631 | result -= d->frameStrut().topLeft(); | - |
3632 | return result; | - |
3633 | } | - |
3634 | | - |
3635 | | - |
3636 | | - |
3637 | | - |
3638 | | - |
3639 | | - |
3640 | | - |
3641 | | - |
3642 | | - |
3643 | | - |
3644 | | - |
3645 | | - |
3646 | | - |
3647 | | - |
3648 | | - |
3649 | | - |
3650 | | - |
3651 | | - |
3652 | | - |
3653 | | - |
3654 | | - |
3655 | | - |
3656 | | - |
3657 | | - |
3658 | | - |
3659 | | - |
3660 | | - |
3661 | | - |
3662 | | - |
3663 | | - |
3664 | | - |
3665 | | - |
3666 | | - |
3667 | | - |
3668 | | - |
3669 | | - |
3670 | | - |
3671 | | - |
3672 | | - |
3673 | | - |
3674 | | - |
3675 | | - |
3676 | | - |
3677 | | - |
3678 | | - |
3679 | | - |
3680 | | - |
3681 | | - |
3682 | | - |
3683 | | - |
3684 | | - |
3685 | | - |
3686 | | - |
3687 | | - |
3688 | | - |
3689 | | - |
3690 | | - |
3691 | | - |
3692 | | - |
3693 | | - |
3694 | | - |
3695 | | - |
3696 | | - |
3697 | | - |
3698 | | - |
3699 | | - |
3700 | | - |
3701 | | - |
3702 | | - |
3703 | | - |
3704 | | - |
3705 | | - |
3706 | | - |
3707 | | - |
3708 | | - |
3709 | | - |
3710 | | - |
3711 | | - |
3712 | | - |
3713 | | - |
3714 | | - |
3715 | | - |
3716 | | - |
3717 | | - |
3718 | | - |
3719 | | - |
3720 | | - |
3721 | | - |
3722 | | - |
3723 | | - |
3724 | | - |
3725 | | - |
3726 | | - |
3727 | | - |
3728 | | - |
3729 | | - |
3730 | | - |
3731 | | - |
3732 | | - |
3733 | | - |
3734 | | - |
3735 | | - |
3736 | | - |
3737 | | - |
3738 | | - |
3739 | | - |
3740 | | - |
3741 | | - |
3742 | | - |
3743 | | - |
3744 | | - |
3745 | | - |
3746 | | - |
3747 | | - |
3748 | QRect QWidget::normalGeometry() const | - |
3749 | { | - |
3750 | Q_D(const QWidget); | - |
3751 | if (!d->extra || !d->extra->topextra) | - |
3752 | return QRect(); | - |
3753 | | - |
3754 | if (!isMaximized() && !isFullScreen()) | - |
3755 | return geometry(); | - |
3756 | | - |
3757 | return d->topData()->normalGeometry; | - |
3758 | } | - |
3759 | | - |
3760 | | - |
3761 | | - |
3762 | | - |
3763 | | - |
3764 | | - |
3765 | | - |
3766 | | - |
3767 | | - |
3768 | | - |
3769 | | - |
3770 | | - |
3771 | | - |
3772 | | - |
3773 | QRect QWidget::childrenRect() const | - |
3774 | { | - |
3775 | Q_D(const QWidget); | - |
3776 | QRect r(0, 0, 0, 0); | - |
3777 | for (int i = 0; i < d->children.size(); ++i) { | - |
3778 | QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); | - |
3779 | if (w && !w->isWindow() && !w->isHidden()) | - |
3780 | r |= w->geometry(); | - |
3781 | } | - |
3782 | return r; | - |
3783 | } | - |
3784 | | - |
3785 | | - |
3786 | | - |
3787 | | - |
3788 | | - |
3789 | | - |
3790 | | - |
3791 | | - |
3792 | | - |
3793 | | - |
3794 | | - |
3795 | | - |
3796 | | - |
3797 | QRegion QWidget::childrenRegion() const | - |
3798 | { | - |
3799 | Q_D(const QWidget); | - |
3800 | QRegion r; | - |
3801 | for (int i = 0; i < d->children.size(); ++i) { | - |
3802 | QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); | - |
3803 | if (w && !w->isWindow() && !w->isHidden()) { | - |
3804 | QRegion mask = w->mask(); | - |
3805 | if (mask.isEmpty()) | - |
3806 | r |= w->geometry(); | - |
3807 | else | - |
3808 | r |= mask.translated(w->pos()); | - |
3809 | } | - |
3810 | } | - |
3811 | return r; | - |
3812 | } | - |
3813 | | - |
3814 | | - |
3815 | | - |
3816 | | - |
3817 | | - |
3818 | | - |
3819 | | - |
3820 | | - |
3821 | | - |
3822 | | - |
3823 | | - |
3824 | | - |
3825 | | - |
3826 | | - |
3827 | | - |
3828 | | - |
3829 | | - |
3830 | | - |
3831 | | - |
3832 | QSize QWidget::minimumSize() const | - |
3833 | { | - |
3834 | Q_D(const QWidget); | - |
3835 | return d->extra ? QSize(d->extra->minw, d->extra->minh) : QSize(0, 0); | - |
3836 | } | - |
3837 | | - |
3838 | | - |
3839 | | - |
3840 | | - |
3841 | | - |
3842 | | - |
3843 | | - |
3844 | | - |
3845 | | - |
3846 | | - |
3847 | | - |
3848 | | - |
3849 | | - |
3850 | | - |
3851 | | - |
3852 | | - |
3853 | | - |
3854 | QSize QWidget::maximumSize() const | - |
3855 | { | - |
3856 | Q_D(const QWidget); | - |
3857 | return d->extra ? QSize(d->extra->maxw, d->extra->maxh) | - |
3858 | : QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); | - |
3859 | } | - |
3860 | | - |
3861 | | - |
3862 | | - |
3863 | | - |
3864 | | - |
3865 | | - |
3866 | | - |
3867 | | - |
3868 | | - |
3869 | | - |
3870 | | - |
3871 | | - |
3872 | | - |
3873 | | - |
3874 | | - |
3875 | | - |
3876 | | - |
3877 | | - |
3878 | | - |
3879 | | - |
3880 | | - |
3881 | | - |
3882 | | - |
3883 | | - |
3884 | | - |
3885 | | - |
3886 | | - |
3887 | | - |
3888 | | - |
3889 | | - |
3890 | | - |
3891 | | - |
3892 | | - |
3893 | | - |
3894 | | - |
3895 | | - |
3896 | | - |
3897 | | - |
3898 | | - |
3899 | | - |
3900 | | - |
3901 | | - |
3902 | | - |
3903 | | - |
3904 | | - |
3905 | | - |
3906 | | - |
3907 | | - |
3908 | | - |
3909 | | - |
3910 | | - |
3911 | | - |
3912 | | - |
3913 | | - |
3914 | | - |
3915 | | - |
3916 | | - |
3917 | | - |
3918 | | - |
3919 | | - |
3920 | | - |
3921 | | - |
3922 | | - |
3923 | | - |
3924 | | - |
3925 | | - |
3926 | | - |
3927 | | - |
3928 | | - |
3929 | | - |
3930 | | - |
3931 | | - |
3932 | | - |
3933 | QSize QWidget::sizeIncrement() const | - |
3934 | { | - |
3935 | Q_D(const QWidget); | - |
3936 | return (d->extra && d->extra->topextra) | - |
3937 | ? QSize(d->extra->topextra->incw, d->extra->topextra->inch) | - |
3938 | : QSize(0, 0); | - |
3939 | } | - |
3940 | | - |
3941 | | - |
3942 | | - |
3943 | | - |
3944 | | - |
3945 | | - |
3946 | | - |
3947 | | - |
3948 | | - |
3949 | | - |
3950 | | - |
3951 | | - |
3952 | | - |
3953 | | - |
3954 | QSize QWidget::baseSize() const | - |
3955 | { | - |
3956 | Q_D(const QWidget); | - |
3957 | return (d->extra != 0 && d->extra->topextra != 0) | - |
3958 | ? QSize(d->extra->topextra->basew, d->extra->topextra->baseh) | - |
3959 | : QSize(0, 0); | - |
3960 | } | - |
3961 | | - |
3962 | bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh) | - |
3963 | { | - |
3964 | Q_Q(QWidget); | - |
3965 | | - |
3966 | int mw = minw, mh = minh; | - |
3967 | if (mw == QWIDGETSIZE_MAX)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3968 | mw = 0; never executed: mw = 0; | 0 |
3969 | if (mh == QWIDGETSIZE_MAX)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3970 | mh = 0; never executed: mh = 0; | 0 |
3971 | if (Q_UNLIKELY(minw > QWIDGETSIZE_MAX || minh > QWIDGETSIZE_MAX))) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3972 | qWarning("QWidget::setMinimumSize: (%s/%s) " | - |
3973 | "The largest allowed size is (%d,%d)", | - |
3974 | q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX, | - |
3975 | QWIDGETSIZE_MAX); | - |
3976 | minw = mw = qMin<int>(minw, QWIDGETSIZE_MAX); | - |
3977 | minh = mh = qMin<int>(minh, QWIDGETSIZE_MAX); | - |
3978 | } never executed: end of block | 0 |
3979 | if (Q_UNLIKELY(minw < 0 || minh < 0))) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3980 | qWarning("QWidget::setMinimumSize: (%s/%s) Negative sizes (%d,%d) " | - |
3981 | "are not possible", | - |
3982 | q->objectName().toLocal8Bit().data(), q->metaObject()->className(), minw, minh); | - |
3983 | minw = mw = qMax(minw, 0); | - |
3984 | minh = mh = qMax(minh, 0); | - |
3985 | } never executed: end of block | 0 |
3986 | createExtra(); | - |
3987 | if (extra->minw == mw && extra->minh == mh)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3988 | return false; never executed: return false; | 0 |
3989 | extra->minw = mw; | - |
3990 | extra->minh = mh; | - |
3991 | extra->explicitMinSize = (mw ? Qt::Horizontal : 0) | (mh ? Qt::Vertical : 0);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3992 | return true; never executed: return true; | 0 |
3993 | } | - |
3994 | | - |
3995 | void QWidgetPrivate::setConstraints_sys() | - |
3996 | { | - |
3997 | Q_Q(QWidget); | - |
3998 | if (extra && q->windowHandle()) { | - |
3999 | QWindow *win = q->windowHandle(); | - |
4000 | QWindowPrivate *winp = qt_window_private(win); | - |
4001 | | - |
4002 | winp->minimumSize = QSize(extra->minw, extra->minh); | - |
4003 | winp->maximumSize = QSize(extra->maxw, extra->maxh); | - |
4004 | | - |
4005 | if (extra->topextra) { | - |
4006 | winp->baseSize = QSize(extra->topextra->basew, extra->topextra->baseh); | - |
4007 | winp->sizeIncrement = QSize(extra->topextra->incw, extra->topextra->inch); | - |
4008 | } | - |
4009 | | - |
4010 | if (winp->platformWindow) { | - |
4011 | fixPosIncludesFrame(); | - |
4012 | winp->platformWindow->propagateSizeHints(); | - |
4013 | } | - |
4014 | } | - |
4015 | } | - |
4016 | | - |
4017 | | - |
4018 | | - |
4019 | | - |
4020 | | - |
4021 | | - |
4022 | | - |
4023 | | - |
4024 | | - |
4025 | void QWidget::setMinimumSize(int minw, int minh) | - |
4026 | { | - |
4027 | Q_D(QWidget); | - |
4028 | if (!d->setMinimumSize_helper(minw, minh)) | - |
4029 | return; | - |
4030 | | - |
4031 | if (isWindow()) | - |
4032 | d->setConstraints_sys(); | - |
4033 | if (minw > width() || minh > height()) { | - |
4034 | bool resized = testAttribute(Qt::WA_Resized); | - |
4035 | bool maximized = isMaximized(); | - |
4036 | resize(qMax(minw,width()), qMax(minh,height())); | - |
4037 | setAttribute(Qt::WA_Resized, resized); | - |
4038 | if (maximized) | - |
4039 | data->window_state = data->window_state | Qt::WindowMaximized; | - |
4040 | } | - |
4041 | #ifndef QT_NO_GRAPHICSVIEW | - |
4042 | if (d->extra) { | - |
4043 | if (d->extra->proxyWidget) | - |
4044 | d->extra->proxyWidget->setMinimumSize(minw, minh); | - |
4045 | } | - |
4046 | #endif | - |
4047 | d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh); | - |
4048 | } | - |
4049 | | - |
4050 | bool QWidgetPrivate::setMaximumSize_helper(int &maxw, int &maxh) | - |
4051 | { | - |
4052 | Q_Q(QWidget); | - |
4053 | if (Q_UNLIKELY(maxw > QWIDGETSIZE_MAX || maxh > QWIDGETSIZE_MAX))) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4054 | qWarning("QWidget::setMaximumSize: (%s/%s) " | - |
4055 | "The largest allowed size is (%d,%d)", | - |
4056 | q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX, | - |
4057 | QWIDGETSIZE_MAX); | - |
4058 | maxw = qMin<int>(maxw, QWIDGETSIZE_MAX); | - |
4059 | maxh = qMin<int>(maxh, QWIDGETSIZE_MAX); | - |
4060 | } never executed: end of block | 0 |
4061 | if (Q_UNLIKELY(maxw < 0 || maxh < 0))) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4062 | qWarning("QWidget::setMaximumSize: (%s/%s) Negative sizes (%d,%d) " | - |
4063 | "are not possible", | - |
4064 | q->objectName().toLocal8Bit().data(), q->metaObject()->className(), maxw, maxh); | - |
4065 | maxw = qMax(maxw, 0); | - |
4066 | maxh = qMax(maxh, 0); | - |
4067 | } never executed: end of block | 0 |
4068 | createExtra(); | - |
4069 | if (extra->maxw == maxw && extra->maxh == maxh)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4070 | return false; never executed: return false; | 0 |
4071 | extra->maxw = maxw; | - |
4072 | extra->maxh = maxh; | - |
4073 | extra->explicitMaxSize = (maxw != QWIDGETSIZE_MAX ? Qt::Horizontal : 0) |TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4074 | (maxh != QWIDGETSIZE_MAX ? Qt::Vertical : 0); | - |
4075 | return true; never executed: return true; | 0 |
4076 | } | - |
4077 | | - |
4078 | | - |
4079 | | - |
4080 | | - |
4081 | | - |
4082 | | - |
4083 | | - |
4084 | | - |
4085 | void QWidget::setMaximumSize(int maxw, int maxh) | - |
4086 | { | - |
4087 | Q_D(QWidget); | - |
4088 | if (!d->setMaximumSize_helper(maxw, maxh)) | - |
4089 | return; | - |
4090 | | - |
4091 | if (isWindow()) | - |
4092 | d->setConstraints_sys(); | - |
4093 | if (maxw < width() || maxh < height()) { | - |
4094 | bool resized = testAttribute(Qt::WA_Resized); | - |
4095 | resize(qMin(maxw,width()), qMin(maxh,height())); | - |
4096 | setAttribute(Qt::WA_Resized, resized); | - |
4097 | } | - |
4098 | | - |
4099 | #ifndef QT_NO_GRAPHICSVIEW | - |
4100 | if (d->extra) { | - |
4101 | if (d->extra->proxyWidget) | - |
4102 | d->extra->proxyWidget->setMaximumSize(maxw, maxh); | - |
4103 | } | - |
4104 | #endif | - |
4105 | | - |
4106 | d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh); | - |
4107 | } | - |
4108 | | - |
4109 | | - |
4110 | | - |
4111 | | - |
4112 | | - |
4113 | | - |
4114 | | - |
4115 | void QWidget::setSizeIncrement(int w, int h) | - |
4116 | { | - |
4117 | Q_D(QWidget); | - |
4118 | d->createTLExtra(); | - |
4119 | QTLWExtra* x = d->topData(); | - |
4120 | if (x->incw == w && x->inch == h) | - |
4121 | return; | - |
4122 | x->incw = w; | - |
4123 | x->inch = h; | - |
4124 | if (isWindow()) | - |
4125 | d->setConstraints_sys(); | - |
4126 | } | - |
4127 | | - |
4128 | | - |
4129 | | - |
4130 | | - |
4131 | | - |
4132 | | - |
4133 | | - |
4134 | void QWidget::setBaseSize(int basew, int baseh) | - |
4135 | { | - |
4136 | Q_D(QWidget); | - |
4137 | d->createTLExtra(); | - |
4138 | QTLWExtra* x = d->topData(); | - |
4139 | if (x->basew == basew && x->baseh == baseh) | - |
4140 | return; | - |
4141 | x->basew = basew; | - |
4142 | x->baseh = baseh; | - |
4143 | if (isWindow()) | - |
4144 | d->setConstraints_sys(); | - |
4145 | } | - |
4146 | | - |
4147 | | - |
4148 | | - |
4149 | | - |
4150 | | - |
4151 | | - |
4152 | | - |
4153 | | - |
4154 | | - |
4155 | | - |
4156 | | - |
4157 | | - |
4158 | | - |
4159 | | - |
4160 | | - |
4161 | | - |
4162 | void QWidget::setFixedSize(const QSize & s) | - |
4163 | { | - |
4164 | setFixedSize(s.width(), s.height()); | - |
4165 | } | - |
4166 | | - |
4167 | | - |
4168 | | - |
4169 | | - |
4170 | | - |
4171 | | - |
4172 | | - |
4173 | | - |
4174 | | - |
4175 | void QWidget::setFixedSize(int w, int h) | - |
4176 | { | - |
4177 | Q_D(QWidget); | - |
4178 | bool minSizeSet = d->setMinimumSize_helper(w, h); | - |
4179 | bool maxSizeSet = d->setMaximumSize_helper(w, h); | - |
4180 | if (!minSizeSet && !maxSizeSet) | - |
4181 | return; | - |
4182 | | - |
4183 | if (isWindow()) | - |
4184 | d->setConstraints_sys(); | - |
4185 | else | - |
4186 | d->updateGeometry_helper(true); | - |
4187 | | - |
4188 | if (w != QWIDGETSIZE_MAX || h != QWIDGETSIZE_MAX) | - |
4189 | resize(w, h); | - |
4190 | } | - |
4191 | | - |
4192 | void QWidget::setMinimumWidth(int w) | - |
4193 | { | - |
4194 | Q_D(QWidget); | - |
4195 | d->createExtra(); | - |
4196 | uint expl = d->extra->explicitMinSize | (w ? Qt::Horizontal : 0); | - |
4197 | setMinimumSize(w, minimumSize().height()); | - |
4198 | d->extra->explicitMinSize = expl; | - |
4199 | } | - |
4200 | | - |
4201 | void QWidget::setMinimumHeight(int h) | - |
4202 | { | - |
4203 | Q_D(QWidget); | - |
4204 | d->createExtra(); | - |
4205 | uint expl = d->extra->explicitMinSize | (h ? Qt::Vertical : 0); | - |
4206 | setMinimumSize(minimumSize().width(), h); | - |
4207 | d->extra->explicitMinSize = expl; | - |
4208 | } | - |
4209 | | - |
4210 | void QWidget::setMaximumWidth(int w) | - |
4211 | { | - |
4212 | Q_D(QWidget); | - |
4213 | d->createExtra(); | - |
4214 | uint expl = d->extra->explicitMaxSize | (w == QWIDGETSIZE_MAX ? 0 : Qt::Horizontal); | - |
4215 | setMaximumSize(w, maximumSize().height()); | - |
4216 | d->extra->explicitMaxSize = expl; | - |
4217 | } | - |
4218 | | - |
4219 | void QWidget::setMaximumHeight(int h) | - |
4220 | { | - |
4221 | Q_D(QWidget); | - |
4222 | d->createExtra(); | - |
4223 | uint expl = d->extra->explicitMaxSize | (h == QWIDGETSIZE_MAX ? 0 : Qt::Vertical); | - |
4224 | setMaximumSize(maximumSize().width(), h); | - |
4225 | d->extra->explicitMaxSize = expl; | - |
4226 | } | - |
4227 | | - |
4228 | | - |
4229 | | - |
4230 | | - |
4231 | | - |
4232 | | - |
4233 | | - |
4234 | | - |
4235 | void QWidget::setFixedWidth(int w) | - |
4236 | { | - |
4237 | Q_D(QWidget); | - |
4238 | d->createExtra(); | - |
4239 | uint explMin = d->extra->explicitMinSize | Qt::Horizontal; | - |
4240 | uint explMax = d->extra->explicitMaxSize | Qt::Horizontal; | - |
4241 | setMinimumSize(w, minimumSize().height()); | - |
4242 | setMaximumSize(w, maximumSize().height()); | - |
4243 | d->extra->explicitMinSize = explMin; | - |
4244 | d->extra->explicitMaxSize = explMax; | - |
4245 | } | - |
4246 | | - |
4247 | | - |
4248 | | - |
4249 | | - |
4250 | | - |
4251 | | - |
4252 | | - |
4253 | | - |
4254 | | - |
4255 | void QWidget::setFixedHeight(int h) | - |
4256 | { | - |
4257 | Q_D(QWidget); | - |
4258 | d->createExtra(); | - |
4259 | uint explMin = d->extra->explicitMinSize | Qt::Vertical; | - |
4260 | uint explMax = d->extra->explicitMaxSize | Qt::Vertical; | - |
4261 | setMinimumSize(minimumSize().width(), h); | - |
4262 | setMaximumSize(maximumSize().width(), h); | - |
4263 | d->extra->explicitMinSize = explMin; | - |
4264 | d->extra->explicitMaxSize = explMax; | - |
4265 | } | - |
4266 | | - |
4267 | | - |
4268 | | - |
4269 | | - |
4270 | | - |
4271 | | - |
4272 | | - |
4273 | | - |
4274 | | - |
4275 | | - |
4276 | QPoint QWidget::mapTo(const QWidget * parent, const QPoint & pos) const | - |
4277 | { | - |
4278 | QPoint p = pos; | - |
4279 | if (parent) { | - |
4280 | const QWidget * w = this; | - |
4281 | while (w != parent) { | - |
4282 | Q_ASSERT_X(w, "QWidget::mapTo(const QWidget *parent, const QPoint &pos)", | - |
4283 | "parent must be in parent hierarchy"); | - |
4284 | p = w->mapToParent(p); | - |
4285 | w = w->parentWidget(); | - |
4286 | } | - |
4287 | } | - |
4288 | return p; | - |
4289 | } | - |
4290 | | - |
4291 | | - |
4292 | | - |
4293 | | - |
4294 | | - |
4295 | | - |
4296 | | - |
4297 | | - |
4298 | | - |
4299 | | - |
4300 | QPoint QWidget::mapFrom(const QWidget * parent, const QPoint & pos) const | - |
4301 | { | - |
4302 | QPoint p(pos); | - |
4303 | if (parent) { | - |
4304 | const QWidget * w = this; | - |
4305 | while (w != parent) { | - |
4306 | Q_ASSERT_X(w, "QWidget::mapFrom(const QWidget *parent, const QPoint &pos)", | - |
4307 | "parent must be in parent hierarchy"); | - |
4308 | | - |
4309 | p = w->mapFromParent(p); | - |
4310 | w = w->parentWidget(); | - |
4311 | } | - |
4312 | } | - |
4313 | return p; | - |
4314 | } | - |
4315 | | - |
4316 | | - |
4317 | | - |
4318 | | - |
4319 | | - |
4320 | | - |
4321 | | - |
4322 | | - |
4323 | | - |
4324 | | - |
4325 | | - |
4326 | QPoint QWidget::mapToParent(const QPoint &pos) const | - |
4327 | { | - |
4328 | return pos + data->crect.topLeft(); | - |
4329 | } | - |
4330 | | - |
4331 | | - |
4332 | | - |
4333 | | - |
4334 | | - |
4335 | | - |
4336 | | - |
4337 | | - |
4338 | | - |
4339 | | - |
4340 | QPoint QWidget::mapFromParent(const QPoint &pos) const | - |
4341 | { | - |
4342 | return pos - data->crect.topLeft(); | - |
4343 | } | - |
4344 | | - |
4345 | | - |
4346 | | - |
4347 | | - |
4348 | | - |
4349 | | - |
4350 | | - |
4351 | | - |
4352 | | - |
4353 | | - |
4354 | | - |
4355 | | - |
4356 | | - |
4357 | | - |
4358 | | - |
4359 | QWidget *QWidget::window() const | - |
4360 | { | - |
4361 | QWidget *w = const_cast<QWidget *>(this); | - |
4362 | QWidget *p = w->parentWidget(); | - |
4363 | while (!w->isWindow() && p) { | - |
4364 | w = p; | - |
4365 | p = p->parentWidget(); | - |
4366 | } | - |
4367 | return w; | - |
4368 | } | - |
4369 | | - |
4370 | | - |
4371 | | - |
4372 | | - |
4373 | | - |
4374 | | - |
4375 | | - |
4376 | | - |
4377 | | - |
4378 | QWidget *QWidget::nativeParentWidget() const | - |
4379 | { | - |
4380 | QWidget *parent = parentWidget(); | - |
4381 | while (parent && !parent->internalWinId()) | - |
4382 | parent = parent->parentWidget(); | - |
4383 | return parent; | - |
4384 | } | - |
4385 | | - |
4386 | | - |
4387 | | - |
4388 | | - |
4389 | | - |
4390 | | - |
4391 | | - |
4392 | | - |
4393 | | - |
4394 | | - |
4395 | | - |
4396 | | - |
4397 | | - |
4398 | | - |
4399 | | - |
4400 | | - |
4401 | | - |
4402 | | - |
4403 | | - |
4404 | | - |
4405 | QPalette::ColorRole QWidget::backgroundRole() const | - |
4406 | { | - |
4407 | | - |
4408 | const QWidget *w = this; | - |
4409 | do { | - |
4410 | QPalette::ColorRole role = w->d_func()->bg_role; | - |
4411 | if (role != QPalette::NoRole) | - |
4412 | return role; | - |
4413 | if (w->isWindow() || w->windowType() == Qt::SubWindow) | - |
4414 | break; | - |
4415 | w = w->parentWidget(); | - |
4416 | } while (w); | - |
4417 | return QPalette::Window; | - |
4418 | } | - |
4419 | | - |
4420 | | - |
4421 | | - |
4422 | | - |
4423 | | - |
4424 | | - |
4425 | | - |
4426 | | - |
4427 | | - |
4428 | | - |
4429 | | - |
4430 | | - |
4431 | | - |
4432 | | - |
4433 | | - |
4434 | | - |
4435 | | - |
4436 | void QWidget::setBackgroundRole(QPalette::ColorRole role) | - |
4437 | { | - |
4438 | Q_D(QWidget); | - |
4439 | d->bg_role = role; | - |
4440 | d->updateSystemBackground(); | - |
4441 | d->propagatePaletteChange(); | - |
4442 | d->updateIsOpaque(); | - |
4443 | } | - |
4444 | | - |
4445 | | - |
4446 | | - |
4447 | | - |
4448 | | - |
4449 | | - |
4450 | | - |
4451 | | - |
4452 | | - |
4453 | | - |
4454 | | - |
4455 | | - |
4456 | QPalette::ColorRole QWidget::foregroundRole() const | - |
4457 | { | - |
4458 | Q_D(const QWidget); | - |
4459 | QPalette::ColorRole rl = QPalette::ColorRole(d->fg_role); | - |
4460 | if (rl != QPalette::NoRole) | - |
4461 | return rl; | - |
4462 | QPalette::ColorRole role = QPalette::WindowText; | - |
4463 | switch (backgroundRole()) { | - |
4464 | case QPalette::Button: | - |
4465 | role = QPalette::ButtonText; | - |
4466 | break; | - |
4467 | case QPalette::Base: | - |
4468 | role = QPalette::Text; | - |
4469 | break; | - |
4470 | case QPalette::Dark: | - |
4471 | case QPalette::Shadow: | - |
4472 | role = QPalette::Light; | - |
4473 | break; | - |
4474 | case QPalette::Highlight: | - |
4475 | role = QPalette::HighlightedText; | - |
4476 | break; | - |
4477 | case QPalette::ToolTipBase: | - |
4478 | role = QPalette::ToolTipText; | - |
4479 | break; | - |
4480 | default: | - |
4481 | ; | - |
4482 | } | - |
4483 | return role; | - |
4484 | } | - |
4485 | | - |
4486 | | - |
4487 | | - |
4488 | | - |
4489 | | - |
4490 | | - |
4491 | | - |
4492 | | - |
4493 | | - |
4494 | | - |
4495 | | - |
4496 | | - |
4497 | | - |
4498 | | - |
4499 | | - |
4500 | | - |
4501 | void QWidget::setForegroundRole(QPalette::ColorRole role) | - |
4502 | { | - |
4503 | Q_D(QWidget); | - |
4504 | d->fg_role = role; | - |
4505 | d->updateSystemBackground(); | - |
4506 | d->propagatePaletteChange(); | - |
4507 | } | - |
4508 | | - |
4509 | | - |
4510 | | - |
4511 | | - |
4512 | | - |
4513 | | - |
4514 | | - |
4515 | | - |
4516 | | - |
4517 | | - |
4518 | | - |
4519 | | - |
4520 | | - |
4521 | | - |
4522 | | - |
4523 | | - |
4524 | | - |
4525 | | - |
4526 | | - |
4527 | | - |
4528 | | - |
4529 | | - |
4530 | | - |
4531 | | - |
4532 | | - |
4533 | | - |
4534 | | - |
4535 | | - |
4536 | | - |
4537 | | - |
4538 | | - |
4539 | | - |
4540 | | - |
4541 | | - |
4542 | | - |
4543 | | - |
4544 | | - |
4545 | | - |
4546 | | - |
4547 | | - |
4548 | | - |
4549 | | - |
4550 | | - |
4551 | | - |
4552 | | - |
4553 | | - |
4554 | | - |
4555 | | - |
4556 | | - |
4557 | | - |
4558 | | - |
4559 | | - |
4560 | | - |
4561 | | - |
4562 | const QPalette &QWidget::palette() const | - |
4563 | { | - |
4564 | if (!isEnabled()) { | - |
4565 | data->pal.setCurrentColorGroup(QPalette::Disabled); | - |
4566 | } else if ((!isVisible() || isActiveWindow()) | - |
4567 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) | - |
4568 | && !QApplicationPrivate::isBlockedByModal(const_cast<QWidget *>(this)) | - |
4569 | #endif | - |
4570 | ) { | - |
4571 | data->pal.setCurrentColorGroup(QPalette::Active); | - |
4572 | } else { | - |
4573 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
4574 | extern bool qt_mac_can_clickThrough(const QWidget *); | - |
4575 | if (qt_mac_can_clickThrough(this)) | - |
4576 | data->pal.setCurrentColorGroup(QPalette::Active); | - |
4577 | else | - |
4578 | #endif | - |
4579 | data->pal.setCurrentColorGroup(QPalette::Inactive); | - |
4580 | } | - |
4581 | return data->pal; | - |
4582 | } | - |
4583 | | - |
4584 | void QWidget::setPalette(const QPalette &palette) | - |
4585 | { | - |
4586 | Q_D(QWidget); | - |
4587 | setAttribute(Qt::WA_SetPalette, palette.resolve() != 0); | - |
4588 | | - |
4589 | | - |
4590 | | - |
4591 | | - |
4592 | | - |
4593 | QPalette naturalPalette = d->naturalWidgetPalette(d->inheritedPaletteResolveMask); | - |
4594 | QPalette resolvedPalette = palette.resolve(naturalPalette); | - |
4595 | d->setPalette_helper(resolvedPalette); | - |
4596 | } | - |
4597 | | - |
4598 | | - |
4599 | | - |
4600 | | - |
4601 | | - |
4602 | | - |
4603 | | - |
4604 | | - |
4605 | | - |
4606 | | - |
4607 | QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const | - |
4608 | { | - |
4609 | Q_Q(const QWidget); | - |
4610 | | - |
4611 | const bool useStyleSheetPropagationInWidgetStyles = | - |
4612 | QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); | - |
4613 | | - |
4614 | QPalette naturalPalette = QApplication::palette(q); | - |
4615 | if (!((!q->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4616 | && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4617 | #ifndef QT_NO_GRAPHICSVIEW | - |
4618 | || (extra && extra->proxyWidget)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4619 | #endif //QT_NO_GRAPHICSVIEW | - |
4620 | )) { | - |
4621 | if (QWidget *p = q->parentWidget()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4622 | if (!p->testAttribute(Qt::WA_StyleSheet))) || useStyleSheetPropagationInWidgetStyles) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4623 | if (!naturalPalette.isCopyOf(QApplication::palette())) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4624 | QPalette inheritedPalette = p->palette(); | - |
4625 | inheritedPalette.resolve(inheritedMask); | - |
4626 | naturalPalette = inheritedPalette.resolve(naturalPalette); | - |
4627 | } else { never executed: end of block | 0 |
4628 | naturalPalette = p->palette(); | - |
4629 | } never executed: end of block | 0 |
4630 | } | - |
4631 | } never executed: end of block | 0 |
4632 | #ifndef QT_NO_GRAPHICSVIEW | - |
4633 | else if (extra && extra->proxyWidget) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4634 | QPalette inheritedPalette = extra->proxyWidget->palette(); | - |
4635 | inheritedPalette.resolve(inheritedMask); | - |
4636 | naturalPalette = inheritedPalette.resolve(naturalPalette); | - |
4637 | } never executed: end of block | 0 |
4638 | #endif //QT_NO_GRAPHICSVIEW | - |
4639 | } never executed: end of block | 0 |
4640 | naturalPalette.resolve(0); | - |
4641 | return naturalPalette; never executed: return naturalPalette; | 0 |
4642 | } | - |
4643 | | - |
4644 | | - |
4645 | | - |
4646 | | - |
4647 | | - |
4648 | | - |
4649 | | - |
4650 | | - |
4651 | void QWidgetPrivate::resolvePalette() | - |
4652 | { | - |
4653 | QPalette naturalPalette = naturalWidgetPalette(inheritedPaletteResolveMask); | - |
4654 | QPalette resolvedPalette = data.pal.resolve(naturalPalette); | - |
4655 | setPalette_helper(resolvedPalette); | - |
4656 | } | - |
4657 | | - |
4658 | void QWidgetPrivate::setPalette_helper(const QPalette &palette) | - |
4659 | { | - |
4660 | Q_Q(QWidget); | - |
4661 | if (data.pal == palette && data.pal.resolve() == palette.resolve()) | - |
4662 | return; | - |
4663 | data.pal = palette; | - |
4664 | updateSystemBackground(); | - |
4665 | propagatePaletteChange(); | - |
4666 | updateIsOpaque(); | - |
4667 | q->update(); | - |
4668 | updateIsOpaque(); | - |
4669 | } | - |
4670 | | - |
4671 | void QWidgetPrivate::updateSystemBackground() | - |
4672 | { | - |
4673 | } | - |
4674 | | - |
4675 | | - |
4676 | | - |
4677 | | - |
4678 | | - |
4679 | | - |
4680 | | - |
4681 | | - |
4682 | | - |
4683 | | - |
4684 | | - |
4685 | | - |
4686 | | - |
4687 | | - |
4688 | | - |
4689 | | - |
4690 | | - |
4691 | | - |
4692 | | - |
4693 | | - |
4694 | | - |
4695 | | - |
4696 | | - |
4697 | | - |
4698 | | - |
4699 | | - |
4700 | | - |
4701 | | - |
4702 | | - |
4703 | | - |
4704 | | - |
4705 | | - |
4706 | | - |
4707 | | - |
4708 | | - |
4709 | | - |
4710 | | - |
4711 | | - |
4712 | | - |
4713 | | - |
4714 | | - |
4715 | | - |
4716 | | - |
4717 | | - |
4718 | | - |
4719 | | - |
4720 | | - |
4721 | void QWidget::setFont(const QFont &font) | - |
4722 | { | - |
4723 | Q_D(QWidget); | - |
4724 | | - |
4725 | #ifndef QT_NO_STYLE_STYLESHEET | - |
4726 | const QStyleSheetStyle* style; | - |
4727 | if (d->extra && (style = qobject_cast<const QStyleSheetStyle*>(d->extra->style))) { | - |
4728 | style->saveWidgetFont(this, font); | - |
4729 | } | - |
4730 | #endif | - |
4731 | | - |
4732 | setAttribute(Qt::WA_SetFont, font.resolve() != 0); | - |
4733 | | - |
4734 | | - |
4735 | | - |
4736 | | - |
4737 | | - |
4738 | QFont naturalFont = d->naturalWidgetFont(d->inheritedFontResolveMask); | - |
4739 | QFont resolvedFont = font.resolve(naturalFont); | - |
4740 | d->setFont_helper(resolvedFont); | - |
4741 | } | - |
4742 | | - |
4743 | | - |
4744 | | - |
4745 | | - |
4746 | | - |
4747 | | - |
4748 | | - |
4749 | | - |
4750 | | - |
4751 | | - |
4752 | | - |
4753 | | - |
4754 | | - |
4755 | QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const | - |
4756 | { | - |
4757 | Q_Q(const QWidget); | - |
4758 | | - |
4759 | const bool useStyleSheetPropagationInWidgetStyles = | - |
4760 | QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); | - |
4761 | | - |
4762 | QFont naturalFont = QApplication::font(q); | - |
4763 | if (!((!q->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4764 | && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4765 | #ifndef QT_NO_GRAPHICSVIEW | - |
4766 | || (extra && extra->proxyWidget)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4767 | #endif //QT_NO_GRAPHICSVIEW | - |
4768 | )) { | - |
4769 | if (QWidget *p = q->parentWidget()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4770 | if (!p->testAttribute(Qt::WA_StyleSheet))) || useStyleSheetPropagationInWidgetStyles) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4771 | if (!naturalFont.isCopyOf(QApplication::font())) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4772 | if (inheritedMask != 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4773 | QFont inheritedFont = p->font(); | - |
4774 | inheritedFont.resolve(inheritedMask); | - |
4775 | naturalFont = inheritedFont.resolve(naturalFont); | - |
4776 | } never executed: end of block | 0 |
4777 | } else { never executed: end of block | 0 |
4778 | naturalFont = p->font(); | - |
4779 | } never executed: end of block | 0 |
4780 | } | - |
4781 | } never executed: end of block | 0 |
4782 | #ifndef QT_NO_GRAPHICSVIEW | - |
4783 | else if (extra && extra->proxyWidget) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4784 | if (inheritedMask != 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4785 | QFont inheritedFont = extra->proxyWidget->font(); | - |
4786 | inheritedFont.resolve(inheritedMask); | - |
4787 | naturalFont = inheritedFont.resolve(naturalFont); | - |
4788 | } never executed: end of block | 0 |
4789 | } never executed: end of block | 0 |
4790 | #endif //QT_NO_GRAPHICSVIEW | - |
4791 | } never executed: end of block | 0 |
4792 | naturalFont.resolve(0); | - |
4793 | return naturalFont; never executed: return naturalFont; | 0 |
4794 | } | - |
4795 | | - |
4796 | | - |
4797 | | - |
4798 | | - |
4799 | | - |
4800 | | - |
4801 | | - |
4802 | | - |
4803 | | - |
4804 | void QWidgetPrivate::resolveFont() | - |
4805 | { | - |
4806 | QFont naturalFont = naturalWidgetFont(inheritedFontResolveMask); | - |
4807 | QFont resolvedFont = data.fnt.resolve(naturalFont); | - |
4808 | setFont_helper(resolvedFont); | - |
4809 | } | - |
4810 | | - |
4811 | | - |
4812 | | - |
4813 | | - |
4814 | | - |
4815 | | - |
4816 | | - |
4817 | | - |
4818 | | - |
4819 | | - |
4820 | void QWidgetPrivate::updateFont(const QFont &font) | - |
4821 | { | - |
4822 | Q_Q(QWidget); | - |
4823 | #ifndef QT_NO_STYLE_STYLESHEET | - |
4824 | const QStyleSheetStyle* cssStyle; | - |
4825 | cssStyle = extra ? qobject_cast<const QStyleSheetStyle*>(extra->style) : 0;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4826 | const bool useStyleSheetPropagationInWidgetStyles = | - |
4827 | QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); | - |
4828 | #endif | - |
4829 | | - |
4830 | data.fnt = QFont(font, q); | - |
4831 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - |
4832 | | - |
4833 | data.fnt.x11SetScreen(xinfo.screen()); | - |
4834 | #endif | - |
4835 | | - |
4836 | #ifndef QT_NO_GRAPHICSVIEW | - |
4837 | if (!q->parentWidget() && extra && extra->proxyWidget) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4838 | QGraphicsProxyWidget *p = extra->proxyWidget; | - |
4839 | inheritedFontResolveMask = p->d_func()->inheritedFontResolveMask | p->font().resolve(); | - |
4840 | } else never executed: end of block | 0 |
4841 | #endif //QT_NO_GRAPHICSVIEW | - |
4842 | if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4843 | inheritedFontResolveMask = 0; | - |
4844 | } never executed: end of block | 0 |
4845 | uint newMask = data.fnt.resolve() | inheritedFontResolveMask; | - |
4846 | | - |
4847 | for (int i = 0; i < children.size(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4848 | QWidget *w = qobject_cast<QWidget*>(children.at(i)); | - |
4849 | if (w) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4850 | if (0) { dead code: { } | - |
4851 | #ifndef QT_NO_STYLE_STYLESHEET dead code: { } | - |
4852 | } else if ((!useStyleSheetPropagationInWidgetStyles && w->testAttribute(Qt::WA_StyleSheet)) { dead code: { } TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| - |
4853 | | - |
4854 | if (cssStyle)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4855 | cssStyle->updateStyleSheetFont(w); never executed: cssStyle->updateStyleSheetFont(w); | 0 |
4856 | #endif | - |
4857 | } else if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4858 | | - |
4859 | QWidgetPrivate *wd = w->d_func(); | - |
4860 | wd->inheritedFontResolveMask = newMask; | - |
4861 | wd->resolveFont(); | - |
4862 | } never executed: end of block | 0 |
4863 | } never executed: end of block | 0 |
4864 | } never executed: end of block | 0 |
4865 | | - |
4866 | #ifndef QT_NO_STYLE_STYLESHEET | - |
4867 | if ((!useStyleSheetPropagationInWidgetStyles && cssStyle) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
4868 | cssStyle->updateStyleSheetFont(q); | - |
4869 | } never executed: end of block | 0 |
4870 | #endif | - |
4871 | | - |
4872 | QEvent e(QEvent::FontChange); | - |
4873 | QApplication::sendEvent(q, &e); | - |
4874 | } never executed: end of block | 0 |
4875 | | - |
4876 | void QWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction) | - |
4877 | { | - |
4878 | Q_Q(QWidget); | - |
4879 | | - |
4880 | if ( (direction == Qt::RightToLeft) == q->testAttribute(Qt::WA_RightToLeft)) | - |
4881 | return; | - |
4882 | q->setAttribute(Qt::WA_RightToLeft, (direction == Qt::RightToLeft)); | - |
4883 | if (!children.isEmpty()) { | - |
4884 | for (int i = 0; i < children.size(); ++i) { | - |
4885 | QWidget *w = qobject_cast<QWidget*>(children.at(i)); | - |
4886 | if (w && !w->isWindow() && !w->testAttribute(Qt::WA_SetLayoutDirection)) | - |
4887 | w->d_func()->setLayoutDirection_helper(direction); | - |
4888 | } | - |
4889 | } | - |
4890 | QEvent e(QEvent::LayoutDirectionChange); | - |
4891 | QApplication::sendEvent(q, &e); | - |
4892 | } | - |
4893 | | - |
4894 | void QWidgetPrivate::resolveLayoutDirection() | - |
4895 | { | - |
4896 | Q_Q(const QWidget); | - |
4897 | if (!q->testAttribute(Qt::WA_SetLayoutDirection)) | - |
4898 | setLayoutDirection_helper(q->isWindow() ? QApplication::layoutDirection() : q->parentWidget()->layoutDirection()); | - |
4899 | } | - |
4900 | | - |
4901 | | - |
4902 | | - |
4903 | | - |
4904 | | - |
4905 | | - |
4906 | | - |
4907 | | - |
4908 | | - |
4909 | | - |
4910 | | - |
4911 | | - |
4912 | | - |
4913 | | - |
4914 | | - |
4915 | | - |
4916 | | - |
4917 | | - |
4918 | | - |
4919 | void QWidget::setLayoutDirection(Qt::LayoutDirection direction) | - |
4920 | { | - |
4921 | Q_D(QWidget); | - |
4922 | | - |
4923 | if (direction == Qt::LayoutDirectionAuto) { | - |
4924 | unsetLayoutDirection(); | - |
4925 | return; | - |
4926 | } | - |
4927 | | - |
4928 | setAttribute(Qt::WA_SetLayoutDirection); | - |
4929 | d->setLayoutDirection_helper(direction); | - |
4930 | } | - |
4931 | | - |
4932 | Qt::LayoutDirection QWidget::layoutDirection() const | - |
4933 | { | - |
4934 | return testAttribute(Qt::WA_RightToLeft) ? Qt::RightToLeft : Qt::LeftToRight; | - |
4935 | } | - |
4936 | | - |
4937 | void QWidget::unsetLayoutDirection() | - |
4938 | { | - |
4939 | Q_D(QWidget); | - |
4940 | setAttribute(Qt::WA_SetLayoutDirection, false); | - |
4941 | d->resolveLayoutDirection(); | - |
4942 | } | - |
4943 | | - |
4944 | | - |
4945 | | - |
4946 | | - |
4947 | | - |
4948 | | - |
4949 | | - |
4950 | | - |
4951 | | - |
4952 | | - |
4953 | | - |
4954 | | - |
4955 | | - |
4956 | | - |
4957 | | - |
4958 | | - |
4959 | | - |
4960 | | - |
4961 | | - |
4962 | | - |
4963 | | - |
4964 | | - |
4965 | | - |
4966 | | - |
4967 | | - |
4968 | | - |
4969 | | - |
4970 | | - |
4971 | | - |
4972 | | - |
4973 | | - |
4974 | | - |
4975 | | - |
4976 | | - |
4977 | | - |
4978 | | - |
4979 | | - |
4980 | | - |
4981 | | - |
4982 | | - |
4983 | | - |
4984 | | - |
4985 | | - |
4986 | | - |
4987 | #ifndef QT_NO_CURSOR | - |
4988 | QCursor QWidget::cursor() const | - |
4989 | { | - |
4990 | Q_D(const QWidget); | - |
4991 | if (testAttribute(Qt::WA_SetCursor)) | - |
4992 | return (d->extra && d->extra->curs) | - |
4993 | ? *d->extra->curs | - |
4994 | : QCursor(Qt::ArrowCursor); | - |
4995 | if (isWindow() || !parentWidget()) | - |
4996 | return QCursor(Qt::ArrowCursor); | - |
4997 | return parentWidget()->cursor(); | - |
4998 | } | - |
4999 | | - |
5000 | void QWidget::setCursor(const QCursor &cursor) | - |
5001 | { | - |
5002 | Q_D(QWidget); | - |
5003 | | - |
5004 | #if !defined(Q_DEAD_CODE_FROM_QT4_MAC) | - |
5005 | if (cursor.shape() != Qt::ArrowCursor | - |
5006 | || (d->extra && d->extra->curs)) | - |
5007 | #endif | - |
5008 | { | - |
5009 | d->createExtra(); | - |
5010 | QCursor *newCursor = new QCursor(cursor); | - |
5011 | delete d->extra->curs; | - |
5012 | d->extra->curs = newCursor; | - |
5013 | } | - |
5014 | setAttribute(Qt::WA_SetCursor); | - |
5015 | d->setCursor_sys(cursor); | - |
5016 | | - |
5017 | QEvent event(QEvent::CursorChange); | - |
5018 | QApplication::sendEvent(this, &event); | - |
5019 | } | - |
5020 | | - |
5021 | void QWidgetPrivate::setCursor_sys(const QCursor &cursor) | - |
5022 | { | - |
5023 | Q_UNUSED(cursor); | - |
5024 | Q_Q(QWidget); | - |
5025 | qt_qpa_set_cursor(q, false); | - |
5026 | } | - |
5027 | | - |
5028 | void QWidget::unsetCursor() | - |
5029 | { | - |
5030 | Q_D(QWidget); | - |
5031 | if (d->extra) { | - |
5032 | delete d->extra->curs; | - |
5033 | d->extra->curs = 0; | - |
5034 | } | - |
5035 | if (!isWindow()) | - |
5036 | setAttribute(Qt::WA_SetCursor, false); | - |
5037 | d->unsetCursor_sys(); | - |
5038 | | - |
5039 | QEvent event(QEvent::CursorChange); | - |
5040 | QApplication::sendEvent(this, &event); | - |
5041 | } | - |
5042 | | - |
5043 | void QWidgetPrivate::unsetCursor_sys() | - |
5044 | { | - |
5045 | Q_Q(QWidget); | - |
5046 | qt_qpa_set_cursor(q, false); | - |
5047 | } | - |
5048 | | - |
5049 | static inline void applyCursor(QWidget *w, const QCursor c&c) | - |
5050 | { | - |
5051 | if (QWindow *window = w->windowHandle())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5052 | window->setCursor(c); never executed: window->setCursor(c); | 0 |
5053 | } never executed: end of block | 0 |
5054 | | - |
5055 | static inline void unsetCursor(QWidget *w) | - |
5056 | { | - |
5057 | if (QWindow *window = w->windowHandle()) | - |
5058 | window->unsetCursor(); | - |
5059 | } | - |
5060 | | - |
5061 | void qt_qpa_set_cursor(QWidget *w, bool force) | - |
5062 | { | - |
5063 | if (!w->testAttribute(Qt::WA_WState_Created)) | - |
5064 | return; | - |
5065 | | - |
5066 | static QPointer<QWidget> lastUnderMouse = 0; | - |
5067 | if (force) { | - |
5068 | lastUnderMouse = w; | - |
5069 | } else if (lastUnderMouse) { | - |
5070 | const WId lastWinId = lastUnderMouse->effectiveWinId(); | - |
5071 | const WId winId = w->effectiveWinId(); | - |
5072 | if (lastWinId && lastWinId == winId) | - |
5073 | w = lastUnderMouse; | - |
5074 | } else if (!w->internalWinId()) { | - |
5075 | return; | - |
5076 | } | - |
5077 | | - |
5078 | while (!w->internalWinId() && w->parentWidget() && !w->isWindow() | - |
5079 | && !w->testAttribute(Qt::WA_SetCursor)) | - |
5080 | w = w->parentWidget(); | - |
5081 | | - |
5082 | QWidget *nativeParent = w; | - |
5083 | if (!w->internalWinId()) | - |
5084 | nativeParent = w->nativeParentWidget(); | - |
5085 | if (!nativeParent || !nativeParent->internalWinId()) | - |
5086 | return; | - |
5087 | | - |
5088 | if (w->isWindow() || w->testAttribute(Qt::WA_SetCursor)) { | - |
5089 | if (w->isEnabled()) | - |
5090 | applyCursor(nativeParent, w->cursor()); | - |
5091 | else | - |
5092 | | - |
5093 | | - |
5094 | unsetCursor(nativeParent); | - |
5095 | } else { | - |
5096 | unsetCursor(nativeParent); | - |
5097 | } | - |
5098 | } | - |
5099 | #endif | - |
5100 | | - |
5101 | | - |
5102 | | - |
5103 | | - |
5104 | | - |
5105 | | - |
5106 | | - |
5107 | | - |
5108 | | - |
5109 | | - |
5110 | | - |
5111 | | - |
5112 | | - |
5113 | | - |
5114 | | - |
5115 | | - |
5116 | | - |
5117 | | - |
5118 | | - |
5119 | | - |
5120 | | - |
5121 | | - |
5122 | | - |
5123 | | - |
5124 | | - |
5125 | | - |
5126 | | - |
5127 | | - |
5128 | | - |
5129 | | - |
5130 | | - |
5131 | | - |
5132 | | - |
5133 | | - |
5134 | | - |
5135 | | - |
5136 | | - |
5137 | | - |
5138 | | - |
5139 | void QWidget::render(QPaintDevice *target, const QPoint &targetOffset, | - |
5140 | const QRegion &sourceRegion, RenderFlags renderFlags) | - |
5141 | { | - |
5142 | QPainter p(target); | - |
5143 | render(&p, targetOffset, sourceRegion, renderFlags); | - |
5144 | } | - |
5145 | | - |
5146 | | - |
5147 | | - |
5148 | | - |
5149 | | - |
5150 | | - |
5151 | | - |
5152 | | - |
5153 | | - |
5154 | | - |
5155 | | - |
5156 | | - |
5157 | | - |
5158 | | - |
5159 | void QWidget::render(QPainter *painter, const QPoint &targetOffset, | - |
5160 | const QRegion &sourceRegion, RenderFlags renderFlags) | - |
5161 | { | - |
5162 | if (Q_UNLIKELY(!painter))) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5163 | qWarning("QWidget::render: Null pointer to painter"); | - |
5164 | return; never executed: return; | 0 |
5165 | } | - |
5166 | | - |
5167 | if (Q_UNLIKELY(!painter->isActive())())) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5168 | qWarning("QWidget::render: Cannot render with an inactive painter"); | - |
5169 | return; never executed: return; | 0 |
5170 | } | - |
5171 | | - |
5172 | const qreal opacity = painter->opacity(); | - |
5173 | if (qFuzzyIsNull(opacity))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5174 | return; never executed: return; | 0 |
5175 | | - |
5176 | Q_D(QWidget); | - |
5177 | const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter;TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5178 | const QRegion toBePainted = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5179 | : sourceRegion; | - |
5180 | if (toBePainted.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5181 | return; never executed: return; | 0 |
5182 | | - |
5183 | if (!d->extra)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5184 | d->createExtra(); never executed: d->createExtra(); | 0 |
5185 | d->extra->inRenderWithPainter = true; | - |
5186 | | - |
5187 | QPaintEngine *engine = painter->paintEngine(); | - |
5188 | Q_ASSERT(engine); | - |
5189 | QPaintEnginePrivate *enginePriv = engine->d_func(); | - |
5190 | Q_ASSERT(enginePriv); | - |
5191 | QPaintDevice *target = engine->paintDevice(); | - |
5192 | Q_ASSERT(target); | - |
5193 | | - |
5194 | | - |
5195 | if (!inRenderWithPainter && (opacity < 1.0 || (target->devType() == QInternal::Printer))) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5196 | d->render_helper(painter, targetOffset, toBePainted, renderFlags); | - |
5197 | d->extra->inRenderWithPainter = inRenderWithPainter; | - |
5198 | return; never executed: return; | 0 |
5199 | } | - |
5200 | | - |
5201 | | - |
5202 | QPainter *oldPainter = d->sharedPainter(); | - |
5203 | d->setSharedPainter(painter); | - |
5204 | | - |
5205 | | - |
5206 | const QTransform oldTransform = enginePriv->systemTransform; | - |
5207 | const QRegion oldSystemClip = enginePriv->systemClip; | - |
5208 | const QRegion oldSystemViewport = enginePriv->systemViewport; | - |
5209 | | - |
5210 | | - |
5211 | if (painter->hasClipping()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5212 | const QRegion painterClip = painter->deviceTransform().map(painter->clipRegion()); | - |
5213 | enginePriv->setSystemViewport(oldSystemClip.isEmpty() ? painterClip : oldSystemClip & painterClip); | - |
5214 | } else { never executed: end of block | 0 |
5215 | enginePriv->setSystemViewport(oldSystemClip); | - |
5216 | } never executed: end of block | 0 |
5217 | | - |
5218 | d->render(target, targetOffset, toBePainted, renderFlags); | - |
5219 | | - |
5220 | | - |
5221 | enginePriv->systemClip = oldSystemClip;enginePriv->setSystemViewport(oldSystemViewport); | - |
5222 | enginePriv->setSystemTransform(oldTransform); | - |
5223 | enginePriv->systemClip = oldSystemClip; | - |
5224 | | - |
5225 | | - |
5226 | d->setSharedPainter(oldPainter); | - |
5227 | | - |
5228 | d->extra->inRenderWithPainter = inRenderWithPainter; | - |
5229 | } never executed: end of block | 0 |
5230 | | - |
5231 | static void sendResizeEvents(QWidget *target) | - |
5232 | { | - |
5233 | QResizeEvent e(target->size(), QSize()); | - |
5234 | QApplication::sendEvent(target, &e); | - |
5235 | | - |
5236 | const QObjectList children = target->children(); | - |
5237 | for (int i = 0; i < children.size(); ++i) { | - |
5238 | if (!children.at(i)->isWidgetType()) | - |
5239 | continue; | - |
5240 | QWidget *child = static_cast<QWidget*>(children.at(i)); | - |
5241 | if (!child->isWindow() && child->testAttribute(Qt::WA_PendingResizeEvent)) | - |
5242 | sendResizeEvents(child); | - |
5243 | } | - |
5244 | } | - |
5245 | | - |
5246 | | - |
5247 | | - |
5248 | | - |
5249 | | - |
5250 | | - |
5251 | | - |
5252 | | - |
5253 | | - |
5254 | | - |
5255 | | - |
5256 | | - |
5257 | | - |
5258 | | - |
5259 | | - |
5260 | QPixmap QWidget::grab(const QRect &rectangle) | - |
5261 | { | - |
5262 | Q_D(QWidget); | - |
5263 | if (testAttribute(Qt::WA_PendingResizeEvent) || !testAttribute(Qt::WA_WState_Created)) | - |
5264 | sendResizeEvents(this); | - |
5265 | | - |
5266 | const QWidget::RenderFlags renderFlags = QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask; | - |
5267 | | - |
5268 | const bool oldDirtyOpaqueChildren = d->dirtyOpaqueChildren; | - |
5269 | QRect r(rectangle); | - |
5270 | if (r.width() < 0 || r.height() < 0) { | - |
5271 | | - |
5272 | | - |
5273 | r = d->prepareToRender(QRegion(), renderFlags).boundingRect(); | - |
5274 | r.setTopLeft(rectangle.topLeft()); | - |
5275 | } | - |
5276 | | - |
5277 | if (!r.intersects(rect())) | - |
5278 | return QPixmap(); | - |
5279 | | - |
5280 | const qreal dpr = devicePixelRatioF(); | - |
5281 | QPixmap res((QSizeF(r.size()) * dpr).toSize()); | - |
5282 | res.setDevicePixelRatio(dpr); | - |
5283 | if (!d->isOpaque) | - |
5284 | res.fill(Qt::transparent); | - |
5285 | d->render(&res, QPoint(), QRegion(r), renderFlags); | - |
5286 | | - |
5287 | d->dirtyOpaqueChildren = oldDirtyOpaqueChildren; | - |
5288 | return res; | - |
5289 | } | - |
5290 | | - |
5291 | | - |
5292 | | - |
5293 | | - |
5294 | | - |
5295 | | - |
5296 | | - |
5297 | | - |
5298 | | - |
5299 | | - |
5300 | | - |
5301 | #ifndef QT_NO_GRAPHICSEFFECT | - |
5302 | QGraphicsEffect *QWidget::graphicsEffect() const | - |
5303 | { | - |
5304 | Q_D(const QWidget); | - |
5305 | return d->graphicsEffect; | - |
5306 | } | - |
5307 | #endif //QT_NO_GRAPHICSEFFECT | - |
5308 | | - |
5309 | | - |
5310 | | - |
5311 | | - |
5312 | | - |
5313 | | - |
5314 | | - |
5315 | | - |
5316 | | - |
5317 | | - |
5318 | | - |
5319 | | - |
5320 | | - |
5321 | | - |
5322 | | - |
5323 | | - |
5324 | | - |
5325 | | - |
5326 | | - |
5327 | | - |
5328 | | - |
5329 | | - |
5330 | | - |
5331 | #ifndef QT_NO_GRAPHICSEFFECT | - |
5332 | void QWidget::setGraphicsEffect(QGraphicsEffect *effect) | - |
5333 | { | - |
5334 | Q_D(QWidget); | - |
5335 | if (d->graphicsEffect == effect) | - |
5336 | return; | - |
5337 | | - |
5338 | if (d->graphicsEffect) { | - |
5339 | d->invalidateBuffer(rect()); | - |
5340 | delete d->graphicsEffect; | - |
5341 | d->graphicsEffect = 0; | - |
5342 | } | - |
5343 | | - |
5344 | if (effect) { | - |
5345 | | - |
5346 | QGraphicsEffectSourcePrivate *sourced = new QWidgetEffectSourcePrivate(this); | - |
5347 | QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced); | - |
5348 | d->graphicsEffect = effect; | - |
5349 | effect->d_func()->setGraphicsEffectSource(source); | - |
5350 | update(); | - |
5351 | } | - |
5352 | | - |
5353 | d->updateIsOpaque(); | - |
5354 | } | - |
5355 | #endif //QT_NO_GRAPHICSEFFECT | - |
5356 | | - |
5357 | bool QWidgetPrivate::isAboutToShow() const | - |
5358 | { | - |
5359 | if (data.in_show) | - |
5360 | return true; | - |
5361 | | - |
5362 | Q_Q(const QWidget); | - |
5363 | if (q->isHidden()) | - |
5364 | return false; | - |
5365 | | - |
5366 | | - |
5367 | QWidget *parent = q->parentWidget(); | - |
5368 | return parent ? parent->d_func()->isAboutToShow() : false; | - |
5369 | } | - |
5370 | | - |
5371 | QRegion QWidgetPrivate::prepareToRender(const QRegion ®ion, QWidget::RenderFlags renderFlags) | - |
5372 | { | - |
5373 | Q_Q(QWidget); | - |
5374 | const bool isVisible = q->isVisible(); | - |
5375 | | - |
5376 | | - |
5377 | if (!isVisible && !isAboutToShow()) { | - |
5378 | QWidget *topLevel = q->window(); | - |
5379 | (void)topLevel->d_func()->topData(); | - |
5380 | topLevel->ensurePolished(); | - |
5381 | | - |
5382 | | - |
5383 | | - |
5384 | QWidget *widget = q; | - |
5385 | QWidgetList hiddenWidgets; | - |
5386 | while (widget) { | - |
5387 | if (widget->isHidden()) { | - |
5388 | widget->setAttribute(Qt::WA_WState_Hidden, false); | - |
5389 | hiddenWidgets.append(widget); | - |
5390 | if (!widget->isWindow() && widget->parentWidget()->d_func()->layout) | - |
5391 | widget->d_func()->updateGeometry_helper(true); | - |
5392 | } | - |
5393 | widget = widget->parentWidget(); | - |
5394 | } | - |
5395 | | - |
5396 | | - |
5397 | if (topLevel->d_func()->layout) | - |
5398 | topLevel->d_func()->layout->activate(); | - |
5399 | | - |
5400 | | - |
5401 | QTLWExtra *topLevelExtra = topLevel->d_func()->maybeTopData(); | - |
5402 | if (topLevelExtra && !topLevelExtra->sizeAdjusted | - |
5403 | && !topLevel->testAttribute(Qt::WA_Resized)) { | - |
5404 | topLevel->adjustSize(); | - |
5405 | topLevel->setAttribute(Qt::WA_Resized, false); | - |
5406 | } | - |
5407 | | - |
5408 | | - |
5409 | topLevel->d_func()->activateChildLayoutsRecursively(); | - |
5410 | | - |
5411 | | - |
5412 | for (int i = 0; i < hiddenWidgets.size(); ++i) { | - |
5413 | QWidget *widget = hiddenWidgets.at(i); | - |
5414 | widget->setAttribute(Qt::WA_WState_Hidden); | - |
5415 | if (!widget->isWindow() && widget->parentWidget()->d_func()->layout) | - |
5416 | widget->parentWidget()->d_func()->layout->invalidate(); | - |
5417 | } | - |
5418 | } else if (isVisible) { | - |
5419 | q->window()->d_func()->sendPendingMoveAndResizeEvents(true, true); | - |
5420 | } | - |
5421 | | - |
5422 | | - |
5423 | QRegion toBePainted = !region.isEmpty() ? region : QRegion(q->rect()); | - |
5424 | if (!(renderFlags & QWidget::IgnoreMask) && extra && extra->hasMask) | - |
5425 | toBePainted &= extra->mask; | - |
5426 | return toBePainted; | - |
5427 | } | - |
5428 | | - |
5429 | void QWidgetPrivate::render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &toBePainted, | - |
5430 | QWidget::RenderFlags renderFlags) | - |
5431 | { | - |
5432 | Q_ASSERT(painter); | - |
5433 | Q_ASSERT(!toBePainted.isEmpty()); | - |
5434 | | - |
5435 | Q_Q(QWidget); | - |
5436 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - |
5437 | const QTransform originalTransform = painter->worldTransform(); | - |
5438 | const bool useDeviceCoordinates = originalTransform.isScaling(); | - |
5439 | if (!useDeviceCoordinates) { | - |
5440 | #endif | - |
5441 | | - |
5442 | const QRect rect = toBePainted.boundingRect(); | - |
5443 | const QSize size = rect.size(); | - |
5444 | if (size.isNull()) | - |
5445 | return; | - |
5446 | | - |
5447 | const qreal pixmapDevicePixelRatio = painter->device()->devicePixelRatioF(); | - |
5448 | QPixmap pixmap(size * pixmapDevicePixelRatio); | - |
5449 | pixmap.setDevicePixelRatio(pixmapDevicePixelRatio); | - |
5450 | | - |
5451 | if (!(renderFlags & QWidget::DrawWindowBackground) || !isOpaque) | - |
5452 | pixmap.fill(Qt::transparent); | - |
5453 | q->render(&pixmap, QPoint(), toBePainted, renderFlags); | - |
5454 | | - |
5455 | const bool restore = !(painter->renderHints() & QPainter::SmoothPixmapTransform); | - |
5456 | painter->setRenderHints(QPainter::SmoothPixmapTransform, true); | - |
5457 | | - |
5458 | painter->drawPixmap(targetOffset, pixmap); | - |
5459 | | - |
5460 | if (restore) | - |
5461 | painter->setRenderHints(QPainter::SmoothPixmapTransform, false); | - |
5462 | | - |
5463 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - |
5464 | } else { | - |
5465 | | - |
5466 | QTransform transform = originalTransform; | - |
5467 | transform.translate(targetOffset.x(), targetOffset.y()); | - |
5468 | | - |
5469 | QPaintDevice *device = painter->device(); | - |
5470 | Q_ASSERT(device); | - |
5471 | | - |
5472 | | - |
5473 | const QRectF rect(toBePainted.boundingRect()); | - |
5474 | QRect deviceRect = transform.mapRect(QRectF(0, 0, rect.width(), rect.height())).toAlignedRect(); | - |
5475 | deviceRect &= QRect(0, 0, device->width(), device->height()); | - |
5476 | | - |
5477 | QPixmap pixmap(deviceRect.size()); | - |
5478 | pixmap.fill(Qt::transparent); | - |
5479 | | - |
5480 | | - |
5481 | QPainter pixmapPainter(&pixmap); | - |
5482 | pixmapPainter.setRenderHints(painter->renderHints()); | - |
5483 | transform *= QTransform::fromTranslate(-deviceRect.x(), -deviceRect.y()); | - |
5484 | pixmapPainter.setTransform(transform); | - |
5485 | | - |
5486 | q->render(&pixmapPainter, QPoint(), toBePainted, renderFlags); | - |
5487 | pixmapPainter.end(); | - |
5488 | | - |
5489 | | - |
5490 | painter->setTransform(QTransform()); | - |
5491 | painter->drawPixmap(deviceRect.topLeft(), pixmap); | - |
5492 | painter->setTransform(originalTransform); | - |
5493 | } | - |
5494 | #endif | - |
5495 | } | - |
5496 | | - |
5497 | void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, | - |
5498 | QPainter *sharedPainter, QWidgetBackingStore *backingStore) | - |
5499 | { | - |
5500 | if (rgn.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5501 | return; never executed: return; | 0 |
5502 | | - |
5503 | const bool asRoot = flags & DrawAsRoot; | - |
5504 | bool onScreen = paintOnScreen(); | - |
5505 | | - |
5506 | Q_Q(QWidget); | - |
5507 | #ifndef QT_NO_GRAPHICSEFFECT | - |
5508 | if (graphicsEffect && graphicsEffect->isEnabled()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5509 | QGraphicsEffectSource *source = graphicsEffect->d_func()->source; | - |
5510 | QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *> | - |
5511 | (source->d_func()); | - |
5512 | if (!sourced->context) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5513 | QWidgetPaintContext context(pdev, rgn, offset, flags, sharedPainter, backingStore); | - |
5514 | sourced->context = &context; | - |
5515 | if (!sharedPainter) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5516 | setSystemClip(pdev, rgn.translated(offset)); | - |
5517 | QPainter p(pdev); | - |
5518 | p.translate(offset); | - |
5519 | context.painter = &p; | - |
5520 | graphicsEffect->draw(&p); | - |
5521 | setSystemClip(pdev, QRegion()); | - |
5522 | } else { never executed: end of block | 0 |
5523 | context.painter = sharedPainter; | - |
5524 | if (sharedPainter->worldTransform() != sourced->lastEffectTransform) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5525 | sourced->invalidateCache(); | - |
5526 | sourced->lastEffectTransform = sharedPainter->worldTransform(); | - |
5527 | } never executed: end of block | 0 |
5528 | sharedPainter->save(); | - |
5529 | sharedPainter->translate(offset); | - |
5530 | graphicsEffect->draw(sharedPainter); | - |
5531 | sharedPainter->restore(); | - |
5532 | } never executed: end of block | 0 |
5533 | sourced->context = 0; | - |
5534 | | - |
5535 | | - |
5536 | | - |
5537 | if (backingStore && !onScreen && !asRoot && (q->internalWinId() || !q->nativeParentWidget()->isWindow()))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 |
5538 | backingStore->markDirtyOnScreen(rgn, q, offset); never executed: backingStore->markDirtyOnScreen(rgn, q, offset); | 0 |
5539 | | - |
5540 | return; never executed: return; | 0 |
5541 | } | - |
5542 | } never executed: end of block | 0 |
5543 | #endif //QT_NO_GRAFFICSEFFECT | - |
5544 | | - |
5545 | const bool alsoOnScreen = flags & DrawPaintOnScreen; | - |
5546 | const bool recursive = flags & DrawRecursive; | - |
5547 | const bool alsoInvisible = flags & DrawInvisible; | - |
5548 | | - |
5549 | Q_ASSERT(sharedPainter ? sharedPainter->isActive() : true); | - |
5550 | | - |
5551 | QRegion toBePainted(rgn); | - |
5552 | if (asRoot && !alsoInvisible)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5553 | toBePainted &= clipRect(); never executed: toBePainted &= clipRect(); | 0 |
5554 | if (!(flags & DontSubtractOpaqueChildren))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5555 | subtractOpaqueChildren(toBePainted, q->rect()); never executed: subtractOpaqueChildren(toBePainted, q->rect()); | 0 |
5556 | | - |
5557 | if (!toBePainted.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5558 | if (!onScreen || alsoOnScreen) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5559 | | - |
5560 | if (Q_UNLIKELY(q->testAttribute(Qt::WA_WState_InPaintEvent)))))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5561 | qWarning("QWidget::repaint: Recursive repaint detected"); never executed: QMessageLogger(__FILE__, 5561, __PRETTY_FUNCTION__).warning("QWidget::repaint: Recursive repaint detected"); | 0 |
5562 | q->setAttribute(Qt::WA_WState_InPaintEvent); | - |
5563 | | - |
5564 | | - |
5565 | #ifndef QT_NO_PAINT_DEBUG | - |
5566 | bool flushed = QWidgetBackingStore::flushPaint(q, toBePainted); | - |
5567 | #endif | - |
5568 | QPaintEngine *paintEngine = pdev->paintEngine(); | - |
5569 | if (paintEngine) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5570 | setRedirected(pdev, -offset); | - |
5571 | | - |
5572 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
5573 | | - |
5574 | | - |
5575 | | - |
5576 | | - |
5577 | if (pdev->devType() == QInternal::Widget) | - |
5578 | static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent); | - |
5579 | | - |
5580 | #endif | - |
5581 | if (sharedPainter)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5582 | setSystemClip(pdev, toBePainted); never executed: setSystemClip(pdev, toBePainted); | 0 |
5583 | else | - |
5584 | paintEngine->d_func()->systemRect = q->data->crect; never executed: paintEngine->d_func()->systemRect = q->data->crect; | 0 |
5585 | | - |
5586 | | - |
5587 | if ((asRoot || q->autoFillBackground() || onScreen || q->testAttribute(Qt::WA_StyledBackground))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 |
5588 | && !q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5589 | #ifndef QT_NO_OPENGL | - |
5590 | beginBackingStorePainting(); | - |
5591 | #endif | - |
5592 | QPainter p(q); | - |
5593 | paintBackground(&p, toBePainted, (asRoot || onScreen) ? flags | DrawAsRoot : 0); | - |
5594 | #ifndef QT_NO_OPENGL | - |
5595 | endBackingStorePainting(); | - |
5596 | #endif | - |
5597 | } never executed: end of block | 0 |
5598 | | - |
5599 | if (!sharedPainter)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5600 | setSystemClip(pdev, toBePainted.translated(offset)); never executed: setSystemClip(pdev, toBePainted.translated(offset)); | 0 |
5601 | | - |
5602 | if (!onScreen && !asRoot && !isOpaque && q->testAttribute(Qt::WA_TintedBackground)) {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 |
5603 | #ifndef QT_NO_OPENGL | - |
5604 | beginBackingStorePainting(); | - |
5605 | #endif | - |
5606 | QPainter p(q); | - |
5607 | QColor tint = q->palette().window().color(); | - |
5608 | tint.setAlphaF(qreal(.6)); | - |
5609 | p.fillRect(toBePainted.boundingRect(), tint); | - |
5610 | #ifndef QT_NO_OPENGL | - |
5611 | endBackingStorePainting(); | - |
5612 | #endif | - |
5613 | } never executed: end of block | 0 |
5614 | } never executed: end of block | 0 |
5615 | | - |
5616 | #if 0 | - |
5617 | qDebug() << "painting" << q << "opaque ==" << isOpaque(); | - |
5618 | qDebug() << "clipping to" << toBePainted << "location == " << offset | - |
5619 | << "geometry ==" << QRect(q->mapTo(q->window(), QPoint(0, 0)), q->size()); | - |
5620 | #endif | - |
5621 | | - |
5622 | bool skipPaintEvent = false; | - |
5623 | #ifndef QT_NO_OPENGL | - |
5624 | if (renderToTexture) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5625 | | - |
5626 | | - |
5627 | if (!q->testAttribute(Qt::WA_AlwaysStackOnTop)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5628 | beginBackingStorePainting(); | - |
5629 | if (backingStore) {QPainter p(q); | - |
5630 | if (backingStore) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5631 | p.setCompositionMode(QPainter::CompositionMode_Source); | - |
5632 | p.fillRect(q->rect(), Qt::transparent); | - |
5633 | } else { never executed: end of block | 0 |
5634 | QImage img = grabFramebuffer(); | - |
| QPainter p(q); | |
5635 | p.drawImage(q->rect(), img);grabFramebuffer()); | - |
5636 | skipPaintEvent = true; | - |
5637 | } never executed: end of block | 0 |
5638 | endBackingStorePainting(); | - |
5639 | } never executed: end of block | 0 |
5640 | if (renderToTextureReallyDirty)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5641 | renderToTextureReallyDirty = 0; never executed: renderToTextureReallyDirty = 0; | 0 |
5642 | else | - |
5643 | skipPaintEvent = true; never executed: skipPaintEvent = true; | 0 |
5644 | } | - |
5645 | #endif // QT_NO_OPENGL | - |
5646 | | - |
5647 | if (!skipPaintEvent) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5648 | | - |
5649 | sendPaintEvent(toBePainted); | - |
5650 | } never executed: end of block | 0 |
5651 | | - |
5652 | | - |
5653 | if (backingStore && !onScreen && !asRoot && (q->internalWinId() || (q->nativeParentWidget() && !q->nativeParentWidget()->isWindow())))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 |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5654 | backingStore->markDirtyOnScreen(toBePainted, q, offset); never executed: backingStore->markDirtyOnScreen(toBePainted, q, offset); | 0 |
5655 | | - |
5656 | | - |
5657 | if (paintEngine) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5658 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
5659 | if (pdev->devType() == QInternal::Widget) | - |
5660 | static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent, false); | - |
5661 | #endif | - |
5662 | restoreRedirected(); | - |
5663 | if (!sharedPainter)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5664 | paintEngine->d_func()->systemRect = QRect(); never executed: paintEngine->d_func()->systemRect = QRect(); | 0 |
5665 | else | - |
5666 | paintEngine->d_func()->currentClipDevice = 0; never executed: paintEngine->d_func()->currentClipDevice = 0; | 0 |
5667 | | - |
5668 | setSystemClip(pdev, QRegion()); | - |
5669 | } never executed: end of block | 0 |
5670 | q->setAttribute(Qt::WA_WState_InPaintEvent, false); | - |
5671 | if (Q_UNLIKELY(q->paintingActive())()))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5672 | qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent"); never executed: QMessageLogger(__FILE__, 5672, __PRETTY_FUNCTION__).warning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent"); | 0 |
5673 | | - |
5674 | if (paintEngine && paintEngine->autoDestruct()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5675 | delete paintEngine; | - |
5676 | } never executed: end of block | 0 |
5677 | | - |
5678 | #ifndef QT_NO_PAINT_DEBUG | - |
5679 | if (flushed)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5680 | QWidgetBackingStore::unflushPaint(q, toBePainted); never executed: QWidgetBackingStore::unflushPaint(q, toBePainted); | 0 |
5681 | #endif | - |
5682 | } else if (q->isWindow()) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5683 | QPaintEngine *engine = pdev->paintEngine(); | - |
5684 | if (engine) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5685 | QPainter p(pdev); | - |
5686 | p.setClipRegion(toBePainted); | - |
5687 | const QBrush bg = q->palette().brush(QPalette::Window); | - |
5688 | if (bg.style() == Qt::TexturePattern)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5689 | p.drawTiledPixmap(q->rect(), bg.texture()); never executed: p.drawTiledPixmap(q->rect(), bg.texture()); | 0 |
5690 | else | - |
5691 | p.fillRect(q->rect(), bg); never executed: p.fillRect(q->rect(), bg); | 0 |
5692 | | - |
5693 | if (engine->autoDestruct())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5694 | delete engine; never executed: delete engine; | 0 |
5695 | } never executed: end of block | 0 |
5696 | } never executed: end of block | 0 |
5697 | } never executed: end of block | 0 |
5698 | | - |
5699 | if (recursive && !children.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5700 | paintSiblingsRecursive(pdev, children, children.size() - 1, rgn, offset, flags & ~DrawAsRoot | - |
5701 | , sharedPainter, backingStore); | - |
5702 | } never executed: end of block | 0 |
5703 | } never executed: end of block | 0 |
5704 | | - |
5705 | void QWidgetPrivate::sendPaintEvent(const QRegion &toBePainted) | - |
5706 | { | - |
5707 | Q_Q(QWidget); | - |
5708 | QPaintEvent e(toBePainted); | - |
5709 | QCoreApplication::sendSpontaneousEvent(q, &e); | - |
5710 | | - |
5711 | #ifndef QT_NO_OPENGL | - |
5712 | if (renderToTexture) | - |
5713 | resolveSamples(); | - |
5714 | #endif // QT_NO_OPENGL | - |
5715 | } | - |
5716 | | - |
5717 | void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, | - |
5718 | const QRegion &sourceRegion, QWidget::RenderFlags renderFlags) | - |
5719 | { | - |
5720 | if (Q_UNLIKELY(!target))) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5721 | qWarning("QWidget::render: null pointer to paint device"); | - |
5722 | return; never executed: return; | 0 |
5723 | } | - |
5724 | | - |
5725 | const bool inRenderWithPainter = extra && extra->inRenderWithPainter;TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5726 | QRegion paintRegion = !inRenderWithPainterTRUE | never evaluated | FALSE | never evaluated |
| 0 |
5727 | ? prepareToRender(sourceRegion, renderFlags) | - |
5728 | : sourceRegion; | - |
5729 | if (paintRegion.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5730 | return; never executed: return; | 0 |
5731 | | - |
5732 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - |
5733 | QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : 0;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5734 | | - |
5735 | | - |
5736 | | - |
5737 | if (target->devType() == QInternal::Widget) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5738 | QWidgetPrivate *targetPrivate = static_cast<QWidget *>(target)->d_func(); | - |
5739 | if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5740 | QPainter *targetPainter = targetPrivate->sharedPainter(); | - |
5741 | if (targetPainter && targetPainter->isActive())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5742 | setSharedPainter(targetPainter); never executed: setSharedPainter(targetPainter); | 0 |
5743 | } never executed: end of block | 0 |
5744 | } never executed: end of block | 0 |
5745 | #endif | - |
5746 | | - |
5747 | | - |
5748 | | - |
5749 | | - |
5750 | QPoint offset = targetOffset; | - |
5751 | offset -= paintRegion.boundingRect().topLeft(); | - |
5752 | QPoint redirectionOffset; | - |
5753 | QPaintDevice *redirected = 0; | - |
5754 | | - |
5755 | if (target->devType() == QInternal::Widget)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5756 | redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset); never executed: redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset); | 0 |
5757 | if (!redirected)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5758 | redirected = QPainter::redirected(target, &redirectionOffset); never executed: redirected = QPainter::redirected(target, &redirectionOffset); | 0 |
5759 | | - |
5760 | if (redirected) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5761 | target = redirected; | - |
5762 | offset -= redirectionOffset; | - |
5763 | } never executed: end of block | 0 |
5764 | | - |
5765 | if (!inRenderWithPainter) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5766 | if (QPaintEngine *targetEngine = target->paintEngine()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5767 | const QRegion targetSystemClip = targetEngine->systemClip(); | - |
5768 | if (!targetSystemClip.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5769 | paintRegion &= targetSystemClip.translated(-offset); never executed: paintRegion &= targetSystemClip.translated(-offset); | 0 |
5770 | } never executed: end of block | 0 |
5771 | } never executed: end of block | 0 |
5772 | | - |
5773 | | - |
5774 | int flags = DrawPaintOnScreen | DrawInvisible; | - |
5775 | if (renderFlags & QWidget::DrawWindowBackground)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5776 | flags |= DrawAsRoot; never executed: flags |= DrawAsRoot; | 0 |
5777 | | - |
5778 | if (renderFlags & QWidget::DrawChildren)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5779 | flags |= DrawRecursive; never executed: flags |= DrawRecursive; | 0 |
5780 | else | - |
5781 | flags |= DontSubtractOpaqueChildren; never executed: flags |= DontSubtractOpaqueChildren; | 0 |
5782 | | - |
5783 | flags |= DontSetCompositionMode; | - |
5784 | | - |
5785 | | - |
5786 | drawWidget(target, paintRegion, offset, flags, sharedPainter()); | - |
5787 | | - |
5788 | | - |
5789 | if (oldSharedPainter)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5790 | setSharedPainter(oldSharedPainter); never executed: setSharedPainter(oldSharedPainter); | 0 |
5791 | } never executed: end of block | 0 |
5792 | | - |
5793 | void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& siblings, int index, const QRegion &rgn, | - |
5794 | const QPoint &offset, int flags | - |
5795 | , QPainter *sharedPainter, QWidgetBackingStore *backingStore) | - |
5796 | { | - |
5797 | QWidget *w = 0; | - |
5798 | QRect boundingRect; | - |
5799 | bool dirtyBoundingRect = true; | - |
5800 | const bool exludeOpaqueChildren = (flags & DontDrawOpaqueChildren); | - |
5801 | const bool excludeNativeChildren = (flags & DontDrawNativeChildren); | - |
5802 | | - |
5803 | do { | - |
5804 | QWidget *x = qobject_cast<QWidget*>(siblings.at(index)); | - |
5805 | if (x && !(exludeOpaqueChildren && x->d_func()->isOpaque) && !x->isHidden() && !x->isWindow() | - |
5806 | && !(excludeNativeChildren && x->internalWinId())) { | - |
5807 | if (dirtyBoundingRect) { | - |
5808 | boundingRect = rgn.boundingRect(); | - |
5809 | dirtyBoundingRect = false; | - |
5810 | } | - |
5811 | | - |
5812 | if (qRectIntersects(boundingRect, x->d_func()->effectiveRectFor(x->data->crect))) { | - |
5813 | w = x; | - |
5814 | break; | - |
5815 | } | - |
5816 | } | - |
5817 | --index; | - |
5818 | } while (index >= 0); | - |
5819 | | - |
5820 | if (!w) | - |
5821 | return; | - |
5822 | | - |
5823 | QWidgetPrivate *wd = w->d_func(); | - |
5824 | const QPoint widgetPos(w->data->crect.topLeft()); | - |
5825 | const bool hasMask = wd->extra && wd->extra->hasMask && !wd->graphicsEffect; | - |
5826 | if (index > 0) { | - |
5827 | QRegion wr(rgn); | - |
5828 | if (wd->isOpaque) | - |
5829 | wr -= hasMask ? wd->extra->mask.translated(widgetPos) : w->data->crect; | - |
5830 | paintSiblingsRecursive(pdev, siblings, --index, wr, offset, flags | - |
5831 | , sharedPainter, backingStore); | - |
5832 | } | - |
5833 | | - |
5834 | if (w->updatesEnabled() | - |
5835 | #ifndef QT_NO_GRAPHICSVIEW | - |
5836 | && (!w->d_func()->extra || !w->d_func()->extra->proxyWidget) | - |
5837 | #endif //QT_NO_GRAPHICSVIEW | - |
5838 | ) { | - |
5839 | QRegion wRegion(rgn); | - |
5840 | wRegion &= wd->effectiveRectFor(w->data->crect); | - |
5841 | wRegion.translate(-widgetPos); | - |
5842 | if (hasMask) | - |
5843 | wRegion &= wd->extra->mask; | - |
5844 | wd->drawWidget(pdev, wRegion, offset + widgetPos, flags, sharedPainter, backingStore); | - |
5845 | } | - |
5846 | } | - |
5847 | | - |
5848 | #ifndef QT_NO_GRAPHICSEFFECT | - |
5849 | QRectF QWidgetEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const | - |
5850 | { | - |
5851 | if (system != Qt::DeviceCoordinates)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5852 | return m_widget->rect(); never executed: return m_widget->rect(); | 0 |
5853 | | - |
5854 | if (Q_UNLIKELY(!context))) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5855 | | - |
5856 | qWarning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context"); | - |
5857 | return QRectF(); never executed: return QRectF(); | 0 |
5858 | } | - |
5859 | | - |
5860 | return context->painter->worldTransform().mapRect(m_widget->rect()); never executed: return context->painter->worldTransform().mapRect(m_widget->rect()); | 0 |
5861 | } | - |
5862 | | - |
5863 | void QWidgetEffectSourcePrivate::draw(QPainter *painter) | - |
5864 | { | - |
5865 | if (!context || context->painter != painter) { | - |
5866 | m_widget->render(painter); | - |
5867 | return; | - |
5868 | } | - |
5869 | | - |
5870 | | - |
5871 | | - |
5872 | QRegion toBePainted = context->rgn; | - |
5873 | toBePainted &= m_widget->rect(); | - |
5874 | QWidgetPrivate *wd = qt_widget_private(m_widget); | - |
5875 | if (wd->extra && wd->extra->hasMask) | - |
5876 | toBePainted &= wd->extra->mask; | - |
5877 | | - |
5878 | wd->drawWidget(context->pdev, toBePainted, context->offset, context->flags, | - |
5879 | context->sharedPainter, context->backingStore); | - |
5880 | } | - |
5881 | | - |
5882 | QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset, | - |
5883 | QGraphicsEffect::PixmapPadMode mode) const | - |
5884 | { | - |
5885 | const bool deviceCoordinates = (system == Qt::DeviceCoordinates); | - |
5886 | if (Q_UNLIKELY(!context && deviceCoordinates))) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5887 | | - |
5888 | qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); | - |
5889 | return QPixmap(); never executed: return QPixmap(); | 0 |
5890 | } | - |
5891 | | - |
5892 | QPoint pixmapOffset; | - |
5893 | QRectF sourceRect = m_widget->rect(); | - |
5894 | | - |
5895 | if (deviceCoordinates) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5896 | const QTransform &painterTransform = context->painter->worldTransform(); | - |
5897 | sourceRect = painterTransform.mapRect(sourceRect); | - |
5898 | pixmapOffset = painterTransform.map(pixmapOffset); | - |
5899 | } never executed: end of block | 0 |
5900 | | - |
5901 | QRect effectRect; | - |
5902 | | - |
5903 | if (mode == QGraphicsEffect::PadToEffectiveBoundingRect)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5904 | effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); never executed: effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); | 0 |
5905 | else if (mode == QGraphicsEffect::PadToTransparentBorder)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5906 | effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); never executed: effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); | 0 |
5907 | else | - |
5908 | effectRect = sourceRect.toAlignedRect(); never executed: effectRect = sourceRect.toAlignedRect(); | 0 |
5909 | | - |
5910 | if (offset)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
5911 | *offset = effectRect.topLeft(); never executed: *offset = effectRect.topLeft(); | 0 |
5912 | | - |
5913 | pixmapOffset -= effectRect.topLeft(); | - |
5914 | | - |
5915 | const qreal dpr = context->painter->device()->devicePixelRatio(); | - |
5916 | QPixmap pixmap(effectRect.size() * dpr); | - |
5917 | pixmap.setDevicePixelRatio(dpr); | - |
5918 | | - |
5919 | pixmap.fill(Qt::transparent); | - |
5920 | m_widget->render(&pixmap, pixmapOffset, QRegion(), QWidget::DrawChildren); | - |
5921 | return pixmap; never executed: return pixmap; | 0 |
5922 | } | - |
5923 | #endif //QT_NO_GRAPHICSEFFECT | - |
5924 | | - |
5925 | #ifndef QT_NO_GRAPHICSVIEW | - |
5926 | | - |
5927 | | - |
5928 | | - |
5929 | | - |
5930 | | - |
5931 | | - |
5932 | | - |
5933 | | - |
5934 | QGraphicsProxyWidget * QWidgetPrivate::nearestGraphicsProxyWidget(const QWidget *origin) | - |
5935 | { | - |
5936 | if (origin) { | - |
5937 | QWExtra *extra = origin->d_func()->extra; | - |
5938 | if (extra && extra->proxyWidget) | - |
5939 | return extra->proxyWidget; | - |
5940 | return nearestGraphicsProxyWidget(origin->parentWidget()); | - |
5941 | } | - |
5942 | return 0; | - |
5943 | } | - |
5944 | #endif | - |
5945 | | - |
5946 | | - |
5947 | | - |
5948 | | - |
5949 | | - |
5950 | | - |
5951 | | - |
5952 | | - |
5953 | | - |
5954 | | - |
5955 | | - |
5956 | | - |
5957 | | - |
5958 | | - |
5959 | | - |
5960 | | - |
5961 | void QWidgetPrivate::setLocale_helper(const QLocale &loc, bool forceUpdate) | - |
5962 | { | - |
5963 | Q_Q(QWidget); | - |
5964 | if (locale == loc && !forceUpdate) | - |
5965 | return; | - |
5966 | | - |
5967 | locale = loc; | - |
5968 | | - |
5969 | if (!children.isEmpty()) { | - |
5970 | for (int i = 0; i < children.size(); ++i) { | - |
5971 | QWidget *w = qobject_cast<QWidget*>(children.at(i)); | - |
5972 | if (!w) | - |
5973 | continue; | - |
5974 | if (w->testAttribute(Qt::WA_SetLocale)) | - |
5975 | continue; | - |
5976 | if (w->isWindow() && !w->testAttribute(Qt::WA_WindowPropagation)) | - |
5977 | continue; | - |
5978 | w->d_func()->setLocale_helper(loc, forceUpdate); | - |
5979 | } | - |
5980 | } | - |
5981 | QEvent e(QEvent::LocaleChange); | - |
5982 | QApplication::sendEvent(q, &e); | - |
5983 | } | - |
5984 | | - |
5985 | void QWidget::setLocale(const QLocale &locale) | - |
5986 | { | - |
5987 | Q_D(QWidget); | - |
5988 | | - |
5989 | setAttribute(Qt::WA_SetLocale); | - |
5990 | d->setLocale_helper(locale); | - |
5991 | } | - |
5992 | | - |
5993 | QLocale QWidget::locale() const | - |
5994 | { | - |
5995 | Q_D(const QWidget); | - |
5996 | | - |
5997 | return d->locale; | - |
5998 | } | - |
5999 | | - |
6000 | void QWidgetPrivate::resolveLocale() | - |
6001 | { | - |
6002 | Q_Q(const QWidget); | - |
6003 | | - |
6004 | if (!q->testAttribute(Qt::WA_SetLocale)) { | - |
6005 | setLocale_helper(q->isWindow() | - |
6006 | ? QLocale() | - |
6007 | : q->parentWidget()->locale()); | - |
6008 | } | - |
6009 | } | - |
6010 | | - |
6011 | void QWidget::unsetLocale() | - |
6012 | { | - |
6013 | Q_D(QWidget); | - |
6014 | setAttribute(Qt::WA_SetLocale, false); | - |
6015 | d->resolveLocale(); | - |
6016 | } | - |
6017 | | - |
6018 | | - |
6019 | | - |
6020 | | - |
6021 | | - |
6022 | | - |
6023 | | - |
6024 | | - |
6025 | | - |
6026 | | - |
6027 | | - |
6028 | | - |
6029 | | - |
6030 | | - |
6031 | | - |
6032 | | - |
6033 | | - |
6034 | | - |
6035 | | - |
6036 | | - |
6037 | | - |
6038 | | - |
6039 | | - |
6040 | | - |
6041 | QString QWidget::windowTitle() const | - |
6042 | { | - |
6043 | Q_D(const QWidget); | - |
6044 | if (d->extra && d->extra->topextra) { | - |
6045 | if (!d->extra->topextra->caption.isEmpty()) | - |
6046 | return d->extra->topextra->caption; | - |
6047 | if (!d->extra->topextra->filePath.isEmpty()) | - |
6048 | return QFileInfo(d->extra->topextra->filePath).fileName() + QLatin1String("[*]"); | - |
6049 | } | - |
6050 | return QString(); | - |
6051 | } | - |
6052 | | - |
6053 | | - |
6054 | | - |
6055 | | - |
6056 | | - |
6057 | | - |
6058 | | - |
6059 | | - |
6060 | | - |
6061 | | - |
6062 | | - |
6063 | | - |
6064 | QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widget) | - |
6065 | { | - |
6066 | Q_ASSERT(widget); | - |
6067 | | - |
6068 | #ifdef QT_EVAL | - |
6069 | extern QString qt_eval_adapt_window_title(const QString &title); | - |
6070 | QString cap = qt_eval_adapt_window_title(title); | - |
6071 | #else | - |
6072 | QString cap = title; | - |
6073 | #endif | - |
6074 | | - |
6075 | if (cap.isEmpty()) | - |
6076 | return cap; | - |
6077 | | - |
6078 | QLatin1String placeHolder("[*]"); | - |
6079 | int index = cap.indexOf(placeHolder); | - |
6080 | | - |
6081 | | - |
6082 | while (index != -1) { | - |
6083 | index += placeHolder.size(); | - |
6084 | int count = 1; | - |
6085 | while (cap.indexOf(placeHolder, index) == index) { | - |
6086 | ++count; | - |
6087 | index += placeHolder.size(); | - |
6088 | } | - |
6089 | | - |
6090 | if (count%2) { | - |
6091 | int lastIndex = cap.lastIndexOf(placeHolder, index - 1); | - |
6092 | if (widget->isWindowModified() | - |
6093 | && widget->style()->styleHint(QStyle::SH_TitleBar_ModifyNotification, 0, widget)) | - |
6094 | cap.replace(lastIndex, 3, QWidget::tr("*")); | - |
6095 | else | - |
6096 | cap.remove(lastIndex, 3); | - |
6097 | } | - |
6098 | | - |
6099 | index = cap.indexOf(placeHolder, index); | - |
6100 | } | - |
6101 | | - |
6102 | cap.replace(QLatin1String("[*][*]"), placeHolder); | - |
6103 | | - |
6104 | return cap; | - |
6105 | } | - |
6106 | | - |
6107 | void QWidgetPrivate::setWindowTitle_helper(const QString &title) | - |
6108 | { | - |
6109 | Q_Q(QWidget); | - |
6110 | if (q->testAttribute(Qt::WA_WState_Created)) | - |
6111 | setWindowTitle_sys(qt_setWindowTitle_helperHelper(title, q)); | - |
6112 | } | - |
6113 | | - |
6114 | void QWidgetPrivate::setWindowTitle_sys(const QString &caption) | - |
6115 | { | - |
6116 | Q_Q(QWidget); | - |
6117 | if (!q->isWindow()) | - |
6118 | return; | - |
6119 | | - |
6120 | if (QWindow *window = q->windowHandle()) | - |
6121 | window->setTitle(caption); | - |
6122 | | - |
6123 | } | - |
6124 | | - |
6125 | void QWidgetPrivate::setWindowIconText_helper(const QString &title) | - |
6126 | { | - |
6127 | Q_Q(QWidget); | - |
6128 | if (q->testAttribute(Qt::WA_WState_Created)) | - |
6129 | setWindowIconText_sys(qt_setWindowTitle_helperHelper(title, q)); | - |
6130 | } | - |
6131 | | - |
6132 | void QWidgetPrivate::setWindowIconText_sys(const QString &iconText) | - |
6133 | { | - |
6134 | Q_Q(QWidget); | - |
6135 | | - |
6136 | | - |
6137 | if (QWindow *window = q->windowHandle()) | - |
6138 | QXcbWindowFunctions::setWmWindowIconText(window, iconText); | - |
6139 | } | - |
6140 | | - |
6141 | | - |
6142 | | - |
6143 | | - |
6144 | | - |
6145 | | - |
6146 | | - |
6147 | | - |
6148 | | - |
6149 | | - |
6150 | | - |
6151 | | - |
6152 | | - |
6153 | void QWidget::setWindowIconText(const QString &iconText) | - |
6154 | { | - |
6155 | if (QWidget::windowIconText() == iconText) | - |
6156 | return; | - |
6157 | | - |
6158 | Q_D(QWidget); | - |
6159 | d->topData()->iconText = iconText; | - |
6160 | d->setWindowIconText_helper(iconText); | - |
6161 | | - |
6162 | QEvent e(QEvent::IconTextChange); | - |
6163 | QApplication::sendEvent(this, &e); | - |
6164 | | - |
6165 | emit windowIconTextChanged(iconText); | - |
6166 | } | - |
6167 | | - |
6168 | | - |
6169 | | - |
6170 | | - |
6171 | | - |
6172 | | - |
6173 | | - |
6174 | | - |
6175 | | - |
6176 | | - |
6177 | void QWidget::setWindowTitle(const QString &title) | - |
6178 | { | - |
6179 | if (QWidget::windowTitle() == title && !title.isEmpty() && !title.isNull()) | - |
6180 | return; | - |
6181 | | - |
6182 | Q_D(QWidget); | - |
6183 | d->topData()->caption = title; | - |
6184 | d->setWindowTitle_helper(title); | - |
6185 | | - |
6186 | QEvent e(QEvent::WindowTitleChange); | - |
6187 | QApplication::sendEvent(this, &e); | - |
6188 | | - |
6189 | emit windowTitleChanged(title); | - |
6190 | } | - |
6191 | | - |
6192 | | - |
6193 | | - |
6194 | | - |
6195 | | - |
6196 | | - |
6197 | | - |
6198 | | - |
6199 | | - |
6200 | | - |
6201 | | - |
6202 | | - |
6203 | QIcon QWidget::windowIcon() const | - |
6204 | { | - |
6205 | const QWidget *w = this; | - |
6206 | while (w) { | - |
6207 | const QWidgetPrivate *d = w->d_func(); | - |
6208 | if (d->extra && d->extra->topextra && d->extra->topextra->icon) | - |
6209 | return *d->extra->topextra->icon; | - |
6210 | w = w->parentWidget(); | - |
6211 | } | - |
6212 | return QApplication::windowIcon(); | - |
6213 | } | - |
6214 | | - |
6215 | void QWidgetPrivate::setWindowIcon_helper() | - |
6216 | { | - |
6217 | Q_Q(QWidget); | - |
6218 | QEvent e(QEvent::WindowIconChange); | - |
6219 | | - |
6220 | | - |
6221 | | - |
6222 | | - |
6223 | | - |
6224 | if (!q->windowHandle()) | - |
6225 | QApplication::sendEvent(q, &e); | - |
6226 | for (int i = 0; i < children.size(); ++i) { | - |
6227 | QWidget *w = qobject_cast<QWidget *>(children.at(i)); | - |
6228 | if (w && !w->isWindow()) | - |
6229 | QApplication::sendEvent(w, &e); | - |
6230 | } | - |
6231 | } | - |
6232 | | - |
6233 | | - |
6234 | | - |
6235 | | - |
6236 | | - |
6237 | | - |
6238 | | - |
6239 | | - |
6240 | | - |
6241 | | - |
6242 | void QWidget::setWindowIcon(const QIcon &icon) | - |
6243 | { | - |
6244 | Q_D(QWidget); | - |
6245 | | - |
6246 | setAttribute(Qt::WA_SetWindowIcon, !icon.isNull()); | - |
6247 | d->createTLExtra(); | - |
6248 | | - |
6249 | if (!d->extra->topextra->icon) | - |
6250 | d->extra->topextra->icon = new QIcon(); | - |
6251 | *d->extra->topextra->icon = icon; | - |
6252 | | - |
6253 | d->setWindowIcon_sys(); | - |
6254 | d->setWindowIcon_helper(); | - |
6255 | | - |
6256 | emit windowIconChanged(icon); | - |
6257 | } | - |
6258 | | - |
6259 | void QWidgetPrivate::setWindowIcon_sys() | - |
6260 | { | - |
6261 | Q_Q(QWidget); | - |
6262 | if (QWindow *window = q->windowHandle()) | - |
6263 | window->setIcon(q->windowIcon()); | - |
6264 | } | - |
6265 | | - |
6266 | | - |
6267 | | - |
6268 | | - |
6269 | | - |
6270 | | - |
6271 | | - |
6272 | | - |
6273 | | - |
6274 | | - |
6275 | | - |
6276 | | - |
6277 | | - |
6278 | | - |
6279 | | - |
6280 | | - |
6281 | QString QWidget::windowIconText() const | - |
6282 | { | - |
6283 | Q_D(const QWidget); | - |
6284 | return (d->extra && d->extra->topextra) ? d->extra->topextra->iconText : QString(); | - |
6285 | } | - |
6286 | | - |
6287 | | - |
6288 | | - |
6289 | | - |
6290 | | - |
6291 | | - |
6292 | | - |
6293 | | - |
6294 | | - |
6295 | | - |
6296 | | - |
6297 | | - |
6298 | | - |
6299 | | - |
6300 | | - |
6301 | | - |
6302 | | - |
6303 | | - |
6304 | | - |
6305 | | - |
6306 | | - |
6307 | | - |
6308 | | - |
6309 | | - |
6310 | | - |
6311 | QString QWidget::windowFilePath() const | - |
6312 | { | - |
6313 | Q_D(const QWidget); | - |
6314 | return (d->extra && d->extra->topextra) ? d->extra->topextra->filePath : QString(); | - |
6315 | } | - |
6316 | | - |
6317 | void QWidget::setWindowFilePath(const QString &filePath) | - |
6318 | { | - |
6319 | if (filePath == windowFilePath()) | - |
6320 | return; | - |
6321 | | - |
6322 | Q_D(QWidget); | - |
6323 | | - |
6324 | d->createTLExtra(); | - |
6325 | d->extra->topextra->filePath = filePath; | - |
6326 | d->setWindowFilePath_helper(filePath); | - |
6327 | } | - |
6328 | | - |
6329 | void QWidgetPrivate::setWindowFilePath_helper(const QString &filePath) | - |
6330 | { | - |
6331 | if (extra->topextra && extra->topextra->caption.isEmpty()) { | - |
6332 | #ifdef Q_OS_MAC | - |
6333 | setWindowTitle_helper(QFileInfo(filePath).fileName()); | - |
6334 | #else | - |
6335 | Q_Q(QWidget); | - |
6336 | Q_UNUSED(filePath); | - |
6337 | setWindowTitle_helper(q->windowTitle()); | - |
6338 | #endif | - |
6339 | } | - |
6340 | #ifdef Q_OS_MAC | - |
6341 | setWindowFilePath_sys(filePath); | - |
6342 | #endif | - |
6343 | } | - |
6344 | | - |
6345 | void QWidgetPrivate::setWindowFilePath_sys(const QString &filePath) | - |
6346 | { | - |
6347 | Q_Q(QWidget); | - |
6348 | if (!q->isWindow()) | - |
6349 | return; | - |
6350 | | - |
6351 | if (QWindow *window = q->windowHandle()) | - |
6352 | window->setFilePath(filePath); | - |
6353 | } | - |
6354 | | - |
6355 | | - |
6356 | | - |
6357 | | - |
6358 | | - |
6359 | | - |
6360 | | - |
6361 | QString QWidget::windowRole() const | - |
6362 | { | - |
6363 | Q_D(const QWidget); | - |
6364 | return (d->extra && d->extra->topextra) ? d->extra->topextra->role : QString(); | - |
6365 | } | - |
6366 | | - |
6367 | | - |
6368 | | - |
6369 | | - |
6370 | | - |
6371 | void QWidget::setWindowRole(const QString &role) | - |
6372 | { | - |
6373 | Q_D(QWidget); | - |
6374 | d->createTLExtra(); | - |
6375 | d->topData()->role = role; | - |
6376 | if (windowHandle()) | - |
6377 | QXcbWindowFunctions::setWmWindowRole(windowHandle(), role.toLatin1()); | - |
6378 | } | - |
6379 | | - |
6380 | | - |
6381 | | - |
6382 | | - |
6383 | | - |
6384 | | - |
6385 | | - |
6386 | | - |
6387 | | - |
6388 | | - |
6389 | | - |
6390 | | - |
6391 | | - |
6392 | | - |
6393 | | - |
6394 | | - |
6395 | | - |
6396 | | - |
6397 | | - |
6398 | | - |
6399 | | - |
6400 | | - |
6401 | | - |
6402 | | - |
6403 | | - |
6404 | | - |
6405 | | - |
6406 | | - |
6407 | | - |
6408 | | - |
6409 | | - |
6410 | void QWidget::setFocusProxy(QWidget * w) | - |
6411 | { | - |
6412 | Q_D(QWidget); | - |
6413 | if (!w && !d->extra)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6414 | return; never executed: return; | 0 |
6415 | | - |
6416 | for (QWidget* fp = w; fp; fp = fp->focusProxy()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6417 | if (Q_UNLIKELY(fp == this))) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6418 | qWarning("QWidget: %s (%s) already in focus proxy chain", metaObject()->className(), objectName().toLocal8Bit().constData()); | - |
6419 | return; never executed: return; | 0 |
6420 | } | - |
6421 | } never executed: end of block | 0 |
6422 | | - |
6423 | d->createExtra(); | - |
6424 | d->extra->focus_proxy = w; | - |
6425 | } never executed: end of block | 0 |
6426 | | - |
6427 | | - |
6428 | | - |
6429 | | - |
6430 | | - |
6431 | | - |
6432 | | - |
6433 | | - |
6434 | QWidget * QWidget::focusProxy() const | - |
6435 | { | - |
6436 | Q_D(const QWidget); | - |
6437 | return d->extra ? (QWidget *)d->extra->focus_proxy : 0; | - |
6438 | } | - |
6439 | | - |
6440 | | - |
6441 | | - |
6442 | | - |
6443 | | - |
6444 | | - |
6445 | | - |
6446 | | - |
6447 | | - |
6448 | | - |
6449 | | - |
6450 | | - |
6451 | | - |
6452 | | - |
6453 | bool QWidget::hasFocus() const | - |
6454 | { | - |
6455 | const QWidget* w = this; | - |
6456 | while (w->d_func()->extra && w->d_func()->extra->focus_proxy) | - |
6457 | w = w->d_func()->extra->focus_proxy; | - |
6458 | #ifndef QT_NO_GRAPHICSVIEW | - |
6459 | if (QWidget *window = w->window()) { | - |
6460 | QWExtra *e = window->d_func()->extra; | - |
6461 | if (e && e->proxyWidget && e->proxyWidget->hasFocus() && window->focusWidget() == w) | - |
6462 | return true; | - |
6463 | } | - |
6464 | #endif // !QT_NO_GRAPHICSVIEW | - |
6465 | return (QApplication::focusWidget() == w); | - |
6466 | } | - |
6467 | | - |
6468 | | - |
6469 | | - |
6470 | | - |
6471 | | - |
6472 | | - |
6473 | | - |
6474 | | - |
6475 | | - |
6476 | | - |
6477 | | - |
6478 | | - |
6479 | | - |
6480 | | - |
6481 | | - |
6482 | | - |
6483 | | - |
6484 | | - |
6485 | | - |
6486 | | - |
6487 | | - |
6488 | | - |
6489 | | - |
6490 | | - |
6491 | | - |
6492 | | - |
6493 | | - |
6494 | | - |
6495 | | - |
6496 | | - |
6497 | | - |
6498 | | - |
6499 | | - |
6500 | | - |
6501 | | - |
6502 | | - |
6503 | void QWidget::setFocus(Qt::FocusReason reason) | - |
6504 | { | - |
6505 | if (!isEnabled()) | - |
6506 | return; | - |
6507 | | - |
6508 | QWidget *f = this; | - |
6509 | while (f->d_func()->extra && f->d_func()->extra->focus_proxy) | - |
6510 | f = f->d_func()->extra->focus_proxy; | - |
6511 | | - |
6512 | if (QApplication::focusWidget() == f | - |
6513 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - |
6514 | && GetFocus() == f->internalWinId() | - |
6515 | #endif | - |
6516 | ) | - |
6517 | return; | - |
6518 | | - |
6519 | #ifndef QT_NO_GRAPHICSVIEW | - |
6520 | QWidget *previousProxyFocus = 0; | - |
6521 | if (QWExtra *topData = window()->d_func()->extra) { | - |
6522 | if (topData->proxyWidget && topData->proxyWidget->hasFocus()) { | - |
6523 | previousProxyFocus = topData->proxyWidget->widget()->focusWidget(); | - |
6524 | if (previousProxyFocus && previousProxyFocus->focusProxy()) | - |
6525 | previousProxyFocus = previousProxyFocus->focusProxy(); | - |
6526 | if (previousProxyFocus == this && !topData->proxyWidget->d_func()->proxyIsGivingFocus) | - |
6527 | return; | - |
6528 | } | - |
6529 | } | - |
6530 | #endif | - |
6531 | | - |
6532 | #ifndef QT_NO_GRAPHICSVIEW | - |
6533 | | - |
6534 | if (QWExtra *topData = window()->d_func()->extra) { | - |
6535 | if (topData->proxyWidget && !topData->proxyWidget->hasFocus()) { | - |
6536 | f->d_func()->updateFocusChild(); | - |
6537 | topData->proxyWidget->d_func()->focusFromWidgetToProxy = 1; | - |
6538 | topData->proxyWidget->setFocus(reason); | - |
6539 | topData->proxyWidget->d_func()->focusFromWidgetToProxy = 0; | - |
6540 | } | - |
6541 | } | - |
6542 | #endif | - |
6543 | | - |
6544 | if (f->isActiveWindow()) { | - |
6545 | QWidget *prev = QApplicationPrivate::focus_widget; | - |
6546 | if (prev) { | - |
6547 | if (reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason | - |
6548 | && prev->testAttribute(Qt::WA_InputMethodEnabled)) { | - |
6549 | QGuiApplication::inputMethod()->commit(); | - |
6550 | } | - |
6551 | | - |
6552 | if (reason != Qt::NoFocusReason) { | - |
6553 | QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, reason); | - |
6554 | QApplication::sendEvent(prev, &focusAboutToChange); | - |
6555 | } | - |
6556 | } | - |
6557 | | - |
6558 | f->d_func()->updateFocusChild(); | - |
6559 | | - |
6560 | QApplicationPrivate::setFocusWidget(f, reason); | - |
6561 | #ifndef QT_NO_ACCESSIBILITY | - |
6562 | # ifdef Q_OS_WIN | - |
6563 | | - |
6564 | if (!(testAttribute(Qt::WA_WState_Created) && window()->windowType() != Qt::Popup && internalWinId())) | - |
6565 | | - |
6566 | # endif | - |
6567 | | - |
6568 | if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem"))) | - |
6569 | { | - |
6570 | QAccessibleEvent event(f, QAccessible::Focus); | - |
6571 | QAccessible::updateAccessibility(&event); | - |
6572 | } | - |
6573 | #endif | - |
6574 | #ifndef QT_NO_GRAPHICSVIEW | - |
6575 | if (QWExtra *topData = window()->d_func()->extra) { | - |
6576 | if (topData->proxyWidget) { | - |
6577 | if (previousProxyFocus && previousProxyFocus != f) { | - |
6578 | | - |
6579 | QFocusEvent event(QEvent::FocusOut, reason); | - |
6580 | QPointer<QWidget> that = previousProxyFocus; | - |
6581 | QApplication::sendEvent(previousProxyFocus, &event); | - |
6582 | if (that) | - |
6583 | QApplication::sendEvent(that->style(), &event); | - |
6584 | } | - |
6585 | if (!isHidden()) { | - |
6586 | #ifndef QT_NO_GRAPHICSVIEW | - |
6587 | | - |
6588 | if (QWExtra *topData = window()->d_func()->extra) | - |
6589 | if (topData->proxyWidget && topData->proxyWidget->hasFocus()) | - |
6590 | topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget(); | - |
6591 | #endif | - |
6592 | | - |
6593 | QFocusEvent event(QEvent::FocusIn, reason); | - |
6594 | QPointer<QWidget> that = f; | - |
6595 | QApplication::sendEvent(f, &event); | - |
6596 | if (that) | - |
6597 | QApplication::sendEvent(that->style(), &event); | - |
6598 | } | - |
6599 | } | - |
6600 | } | - |
6601 | #endif | - |
6602 | } else { | - |
6603 | f->d_func()->updateFocusChild(); | - |
6604 | } | - |
6605 | | - |
6606 | if (QTLWExtra *extra = f->window()->d_func()->maybeTopData()) { | - |
6607 | if (extra->window) | - |
6608 | emit extra->window->focusObjectChanged(f); | - |
6609 | } | - |
6610 | } | - |
6611 | | - |
6612 | void QWidgetPrivate::setFocus_sys() | - |
6613 | { | - |
6614 | Q_Q(QWidget); | - |
6615 | | - |
6616 | const QWidget *topLevel = q->window(); | - |
6617 | if (topLevel->windowType() != Qt::Popup) { | - |
6618 | if (QWindow *nativeWindow = q->window()->windowHandle()) { | - |
6619 | if (nativeWindow != QGuiApplication::focusWindow() | - |
6620 | && q->testAttribute(Qt::WA_WState_Created)) { | - |
6621 | nativeWindow->requestActivate(); | - |
6622 | } | - |
6623 | } | - |
6624 | } | - |
6625 | } | - |
6626 | | - |
6627 | | - |
6628 | void QWidgetPrivate::updateFocusChild() | - |
6629 | { | - |
6630 | Q_Q(QWidget); | - |
6631 | | - |
6632 | QWidget *w = q; | - |
6633 | if (q->isHidden()) { | - |
6634 | while (w && w->isHidden()) { | - |
6635 | w->d_func()->focus_child = q; | - |
6636 | w = w->isWindow() ? 0 : w->parentWidget(); | - |
6637 | } | - |
6638 | } else { | - |
6639 | while (w) { | - |
6640 | w->d_func()->focus_child = q; | - |
6641 | w = w->isWindow() ? 0 : w->parentWidget(); | - |
6642 | } | - |
6643 | } | - |
6644 | } | - |
6645 | | - |
6646 | | - |
6647 | | - |
6648 | | - |
6649 | | - |
6650 | | - |
6651 | | - |
6652 | | - |
6653 | | - |
6654 | | - |
6655 | | - |
6656 | | - |
6657 | | - |
6658 | | - |
6659 | | - |
6660 | | - |
6661 | | - |
6662 | | - |
6663 | | - |
6664 | | - |
6665 | | - |
6666 | | - |
6667 | | - |
6668 | void QWidget::clearFocus() | - |
6669 | { | - |
6670 | if (hasFocus()) { | - |
6671 | if (testAttribute(Qt::WA_InputMethodEnabled)) | - |
6672 | QGuiApplication::inputMethod()->commit(); | - |
6673 | | - |
6674 | QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); | - |
6675 | QApplication::sendEvent(this, &focusAboutToChange); | - |
6676 | } | - |
6677 | | - |
6678 | QWidget *w = this; | - |
6679 | while (w) { | - |
6680 | | - |
6681 | if (w->d_func()->focus_child == this) | - |
6682 | w->d_func()->focus_child = 0; | - |
6683 | w = w->parentWidget(); | - |
6684 | } | - |
6685 | | - |
6686 | | - |
6687 | | - |
6688 | | - |
6689 | #ifndef QT_NO_GRAPHICSVIEW | - |
6690 | QWExtra *topData = d_func()->extra; | - |
6691 | if (topData && topData->proxyWidget) | - |
6692 | topData->proxyWidget->clearFocus(); | - |
6693 | #endif | - |
6694 | | - |
6695 | if (hasFocus()) { | - |
6696 | | - |
6697 | QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason); | - |
6698 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - |
6699 | if (!(windowType() == Qt::Popup) && GetFocus() == internalWinId()) | - |
6700 | SetFocus(0); | - |
6701 | else | - |
6702 | #endif | - |
6703 | { | - |
6704 | #ifndef QT_NO_ACCESSIBILITY | - |
6705 | QAccessibleEvent event(this, QAccessible::Focus); | - |
6706 | QAccessible::updateAccessibility(&event); | - |
6707 | #endif | - |
6708 | } | - |
6709 | } | - |
6710 | | - |
6711 | | - |
6712 | | - |
6713 | | - |
6714 | | - |
6715 | if (QTLWExtra *extra = window()->d_func()->maybeTopData()) { | - |
6716 | if (extra->window) | - |
6717 | emit extra->window->focusObjectChanged(extra->window->focusObject()); | - |
6718 | } | - |
6719 | } | - |
6720 | | - |
6721 | | - |
6722 | | - |
6723 | | - |
6724 | | - |
6725 | | - |
6726 | | - |
6727 | | - |
6728 | | - |
6729 | | - |
6730 | | - |
6731 | | - |
6732 | | - |
6733 | | - |
6734 | | - |
6735 | | - |
6736 | | - |
6737 | | - |
6738 | | - |
6739 | | - |
6740 | | - |
6741 | | - |
6742 | | - |
6743 | | - |
6744 | | - |
6745 | | - |
6746 | | - |
6747 | | - |
6748 | | - |
6749 | | - |
6750 | | - |
6751 | | - |
6752 | | - |
6753 | | - |
6754 | | - |
6755 | | - |
6756 | | - |
6757 | | - |
6758 | | - |
6759 | | - |
6760 | | - |
6761 | | - |
6762 | | - |
6763 | | - |
6764 | bool QWidget::focusNextPrevChild(bool next) | - |
6765 | { | - |
6766 | Q_D(QWidget); | - |
6767 | QWidget* p = parentWidget(); | - |
6768 | bool isSubWindow = (windowType() == Qt::SubWindow); | - |
6769 | if (!isWindow() && !isSubWindow && p) | - |
6770 | return p->focusNextPrevChild(next); | - |
6771 | #ifndef QT_NO_GRAPHICSVIEW | - |
6772 | if (d->extra && d->extra->proxyWidget) | - |
6773 | return d->extra->proxyWidget->focusNextPrevChild(next); | - |
6774 | #endif | - |
6775 | | - |
6776 | bool wrappingOccurred = false; | - |
6777 | QWidget *w = QApplicationPrivate::focusNextPrevChild_helper(this, next, | - |
6778 | &wrappingOccurred); | - |
6779 | if (!w) return false; | - |
6780 | | - |
6781 | Qt::FocusReason reason = next ? Qt::TabFocusReason : Qt::BacktabFocusReason; | - |
6782 | | - |
6783 | | - |
6784 | | - |
6785 | | - |
6786 | | - |
6787 | | - |
6788 | if (wrappingOccurred) { | - |
6789 | QWindow *window = windowHandle(); | - |
6790 | if (window != 0) { | - |
6791 | QWindowPrivate *winp = qt_window_private(window); | - |
6792 | | - |
6793 | if (winp->platformWindow != 0) { | - |
6794 | QFocusEvent event(QEvent::FocusIn, reason); | - |
6795 | event.ignore(); | - |
6796 | winp->platformWindow->windowEvent(&event); | - |
6797 | if (event.isAccepted()) return true; | - |
6798 | } | - |
6799 | } | - |
6800 | } | - |
6801 | | - |
6802 | w->setFocus(reason); | - |
6803 | return true; | - |
6804 | } | - |
6805 | | - |
6806 | | - |
6807 | | - |
6808 | | - |
6809 | | - |
6810 | | - |
6811 | | - |
6812 | | - |
6813 | | - |
6814 | | - |
6815 | QWidget *QWidget::focusWidget() const | - |
6816 | { | - |
6817 | return const_cast<QWidget *>(d_func()->focus_child); | - |
6818 | } | - |
6819 | | - |
6820 | | - |
6821 | | - |
6822 | | - |
6823 | | - |
6824 | | - |
6825 | QWidget *QWidget::nextInFocusChain() const | - |
6826 | { | - |
6827 | return const_cast<QWidget *>(d_func()->focus_next); | - |
6828 | } | - |
6829 | | - |
6830 | | - |
6831 | | - |
6832 | | - |
6833 | | - |
6834 | | - |
6835 | | - |
6836 | | - |
6837 | | - |
6838 | QWidget *QWidget::previousInFocusChain() const | - |
6839 | { | - |
6840 | return const_cast<QWidget *>(d_func()->focus_prev); | - |
6841 | } | - |
6842 | | - |
6843 | | - |
6844 | | - |
6845 | | - |
6846 | | - |
6847 | | - |
6848 | | - |
6849 | | - |
6850 | | - |
6851 | | - |
6852 | | - |
6853 | | - |
6854 | | - |
6855 | | - |
6856 | | - |
6857 | | - |
6858 | bool QWidget::isActiveWindow() const | - |
6859 | { | - |
6860 | QWidget *tlw = window(); | - |
6861 | if(tlw == QApplication::activeWindow() || (isVisible() && (tlw->windowType() == Qt::Popup))) | - |
6862 | return true; | - |
6863 | | - |
6864 | #ifndef QT_NO_GRAPHICSVIEW | - |
6865 | if (QWExtra *tlwExtra = tlw->d_func()->extra) { | - |
6866 | if (isVisible() && tlwExtra->proxyWidget) | - |
6867 | return tlwExtra->proxyWidget->isActiveWindow(); | - |
6868 | } | - |
6869 | #endif | - |
6870 | | - |
6871 | if(style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, this)) { | - |
6872 | if(tlw->windowType() == Qt::Tool && | - |
6873 | !tlw->isModal() && | - |
6874 | (!tlw->parentWidget() || tlw->parentWidget()->isActiveWindow())) | - |
6875 | return true; | - |
6876 | QWidget *w = QApplication::activeWindow(); | - |
6877 | while(w && tlw->windowType() == Qt::Tool && | - |
6878 | !w->isModal() && w->parentWidget()) { | - |
6879 | w = w->parentWidget()->window(); | - |
6880 | if(w == tlw) | - |
6881 | return true; | - |
6882 | } | - |
6883 | } | - |
6884 | | - |
6885 | | - |
6886 | if (QWindow *ww = QGuiApplication::focusWindow()) { | - |
6887 | while (ww) { | - |
6888 | QWidgetWindow *qww = qobject_cast<QWidgetWindow *>(ww); | - |
6889 | QWindowContainer *qwc = qww ? qobject_cast<QWindowContainer *>(qww->widget()) : 0; | - |
6890 | if (qwc && qwc->topLevelWidget() == tlw) | - |
6891 | return true; | - |
6892 | ww = ww->parent(); | - |
6893 | } | - |
6894 | } | - |
6895 | | - |
6896 | | - |
6897 | | - |
6898 | | - |
6899 | | - |
6900 | | - |
6901 | if (const QWindow *w = tlw->windowHandle()) { | - |
6902 | if (w->handle()) | - |
6903 | return w->handle()->isActive(); | - |
6904 | } | - |
6905 | | - |
6906 | return false; | - |
6907 | } | - |
6908 | | - |
6909 | | - |
6910 | | - |
6911 | | - |
6912 | | - |
6913 | | - |
6914 | | - |
6915 | | - |
6916 | | - |
6917 | | - |
6918 | | - |
6919 | | - |
6920 | | - |
6921 | | - |
6922 | | - |
6923 | | - |
6924 | | - |
6925 | | - |
6926 | void QWidget::setTabOrder(QWidget* first, QWidget *second) | - |
6927 | { | - |
6928 | if (!first || !second || first->focusPolicy() == Qt::NoFocus || second->focusPolicy() == Qt::NoFocus)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 |
6929 | return; never executed: return; | 0 |
6930 | | - |
6931 | if (Q_UNLIKELY(first->window() != second->window())())) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6932 | qWarning("QWidget::setTabOrder: 'first' and 'second' must be in the same window"); | - |
6933 | return; never executed: return; | 0 |
6934 | } | - |
6935 | | - |
6936 | QWidget *fp = first->focusProxy(); | - |
6937 | if (fp) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6938 | | - |
6939 | | - |
6940 | | - |
6941 | | - |
6942 | QList<QWidget *> l = first->findChildren<QWidget *>(); | - |
6943 | for (int i = l.size()-1; i >= 0; --i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6944 | QWidget * next = l.at(i); | - |
6945 | if (next->window() == fp->window()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6946 | fp = next; | - |
6947 | if (fp->focusPolicy() != Qt::NoFocus)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6948 | break; never executed: break; | 0 |
6949 | } never executed: end of block | 0 |
6950 | } never executed: end of block | 0 |
6951 | first = fp; | - |
6952 | } never executed: end of block | 0 |
6953 | | - |
6954 | if (fp == second)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6955 | return; never executed: return; | 0 |
6956 | | - |
6957 | if (QWidget *sp = second->focusProxy())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6958 | second = sp; never executed: second = sp; | 0 |
6959 | | - |
6960 | | - |
6961 | QWidget *fn = first->d_func()->focus_next; | - |
6962 | | - |
6963 | if (fn == second || first == second)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
6964 | return; never executed: return; | 0 |
6965 | | - |
6966 | QWidget *sp = second->d_func()->focus_prev; | - |
6967 | QWidget *sn = second->d_func()->focus_next; | - |
6968 | | - |
6969 | fn->d_func()->focus_prev = second; | - |
6970 | first->d_func()->focus_next = second; | - |
6971 | | - |
6972 | second->d_func()->focus_next = fn; | - |
6973 | second->d_func()->focus_prev = first; | - |
6974 | | - |
6975 | sp->d_func()->focus_next = sn; | - |
6976 | sn->d_func()->focus_prev = sp; | - |
6977 | | - |
6978 | | - |
6979 | Q_ASSERT(first->d_func()->focus_next->d_func()->focus_prev == first); | - |
6980 | Q_ASSERT(first->d_func()->focus_prev->d_func()->focus_next == first); | - |
6981 | | - |
6982 | Q_ASSERT(second->d_func()->focus_next->d_func()->focus_prev == second); | - |
6983 | Q_ASSERT(second->d_func()->focus_prev->d_func()->focus_next == second); | - |
6984 | } never executed: end of block | 0 |
6985 | | - |
6986 | | - |
6987 | | - |
6988 | | - |
6989 | | - |
6990 | | - |
6991 | | - |
6992 | | - |
6993 | | - |
6994 | | - |
6995 | | - |
6996 | | - |
6997 | | - |
6998 | void QWidgetPrivate::reparentFocusWidgets(QWidget * oldtlw) | - |
6999 | { | - |
7000 | Q_Q(QWidget); | - |
7001 | if (oldtlw == q->window()) | - |
7002 | return; | - |
7003 | | - |
7004 | if(focus_child) | - |
7005 | focus_child->clearFocus(); | - |
7006 | | - |
7007 | | - |
7008 | QWidget *firstOld = 0; | - |
7009 | | - |
7010 | QWidget *o = 0; | - |
7011 | QWidget *n = q; | - |
7012 | | - |
7013 | bool prevWasNew = true; | - |
7014 | QWidget *w = focus_next; | - |
7015 | | - |
7016 | | - |
7017 | | - |
7018 | | - |
7019 | while (w != q) { | - |
7020 | bool currentIsNew = q->isAncestorOf(w); | - |
7021 | if (currentIsNew) { | - |
7022 | if (!prevWasNew) { | - |
7023 | | - |
7024 | n->d_func()->focus_next = w; | - |
7025 | w->d_func()->focus_prev = n; | - |
7026 | } | - |
7027 | n = w; | - |
7028 | } else { | - |
7029 | if (prevWasNew) { | - |
7030 | | - |
7031 | if (o) { | - |
7032 | o->d_func()->focus_next = w; | - |
7033 | w->d_func()->focus_prev = o; | - |
7034 | } else { | - |
7035 | | - |
7036 | firstOld = w; | - |
7037 | } | - |
7038 | } | - |
7039 | o = w; | - |
7040 | } | - |
7041 | w = w->d_func()->focus_next; | - |
7042 | prevWasNew = currentIsNew; | - |
7043 | } | - |
7044 | | - |
7045 | | - |
7046 | if (firstOld) { | - |
7047 | o->d_func()->focus_next = firstOld; | - |
7048 | firstOld->d_func()->focus_prev = o; | - |
7049 | } | - |
7050 | | - |
7051 | if (!q->isWindow()) { | - |
7052 | QWidget *topLevel = q->window(); | - |
7053 | | - |
7054 | | - |
7055 | QWidget *prev = topLevel->d_func()->focus_prev; | - |
7056 | | - |
7057 | topLevel->d_func()->focus_prev = n; | - |
7058 | prev->d_func()->focus_next = q; | - |
7059 | | - |
7060 | focus_prev = prev; | - |
7061 | n->d_func()->focus_next = topLevel; | - |
7062 | } else { | - |
7063 | | - |
7064 | n->d_func()->focus_next = q; | - |
7065 | focus_prev = n; | - |
7066 | } | - |
7067 | | - |
7068 | } | - |
7069 | | - |
7070 | | - |
7071 | | - |
7072 | | - |
7073 | | - |
7074 | | - |
7075 | | - |
7076 | | - |
7077 | | - |
7078 | | - |
7079 | int QWidgetPrivate::pointToRect(const QPoint &p, const QRect &r) | - |
7080 | { | - |
7081 | int dx = 0; | - |
7082 | int dy = 0; | - |
7083 | if (p.x() < r.left()) | - |
7084 | dx = r.left() - p.x(); | - |
7085 | else if (p.x() > r.right()) | - |
7086 | dx = p.x() - r.right(); | - |
7087 | if (p.y() < r.top()) | - |
7088 | dy = r.top() - p.y(); | - |
7089 | else if (p.y() > r.bottom()) | - |
7090 | dy = p.y() - r.bottom(); | - |
7091 | return dx + dy; | - |
7092 | } | - |
7093 | | - |
7094 | | - |
7095 | | - |
7096 | | - |
7097 | | - |
7098 | | - |
7099 | | - |
7100 | | - |
7101 | QSize QWidget::frameSize() const | - |
7102 | { | - |
7103 | Q_D(const QWidget); | - |
7104 | if (isWindow() && !(windowType() == Qt::Popup)) { | - |
7105 | QRect fs = d->frameStrut(); | - |
7106 | return QSize(data->crect.width() + fs.left() + fs.right(), | - |
7107 | data->crect.height() + fs.top() + fs.bottom()); | - |
7108 | } | - |
7109 | return data->crect.size(); | - |
7110 | } | - |
7111 | | - |
7112 | | - |
7113 | | - |
7114 | | - |
7115 | | - |
7116 | | - |
7117 | | - |
7118 | | - |
7119 | void QWidget::move(const QPoint &p) | - |
7120 | { | - |
7121 | Q_D(QWidget); | - |
7122 | setAttribute(Qt::WA_Moved); | - |
7123 | if (testAttribute(Qt::WA_WState_Created)) { | - |
7124 | if (isWindow()) | - |
7125 | d->topData()->posIncludesFrame = false; | - |
7126 | d->setGeometry_sys(p.x() + geometry().x() - QWidget::x(), | - |
7127 | p.y() + geometry().y() - QWidget::y(), | - |
7128 | width(), height(), true); | - |
7129 | d->setDirtyOpaqueRegion(); | - |
7130 | } else { | - |
7131 | | - |
7132 | if (isWindow()) | - |
7133 | d->topData()->posIncludesFrame = true; | - |
7134 | data->crect.moveTopLeft(p); | - |
7135 | setAttribute(Qt::WA_PendingMoveEvent); | - |
7136 | } | - |
7137 | | - |
7138 | if (d->extra && d->extra->hasWindowContainer) | - |
7139 | QWindowContainer::parentWasMoved(this); | - |
7140 | } | - |
7141 | | - |
7142 | | - |
7143 | | - |
7144 | | - |
7145 | void QWidgetPrivate::fixPosIncludesFrame() | - |
7146 | { | - |
7147 | Q_Q(QWidget); | - |
7148 | if (QTLWExtra *te = maybeTopData()) { | - |
7149 | if (te->posIncludesFrame) { | - |
7150 | | - |
7151 | | - |
7152 | if (q->testAttribute(Qt::WA_DontShowOnScreen)) { | - |
7153 | te->posIncludesFrame = 0; | - |
7154 | } else { | - |
7155 | if (q->windowHandle()) { | - |
7156 | updateFrameStrut(); | - |
7157 | if (!q->data->fstrut_dirty) { | - |
7158 | data.crect.translate(te->frameStrut.x(), te->frameStrut.y()); | - |
7159 | te->posIncludesFrame = 0; | - |
7160 | } | - |
7161 | } | - |
7162 | } | - |
7163 | } | - |
7164 | } | - |
7165 | } | - |
7166 | | - |
7167 | | - |
7168 | | - |
7169 | | - |
7170 | | - |
7171 | | - |
7172 | | - |
7173 | void QWidget::resize(const QSize &s) | - |
7174 | { | - |
7175 | Q_D(QWidget); | - |
7176 | setAttribute(Qt::WA_Resized); | - |
7177 | if (testAttribute(Qt::WA_WState_Created)) { | - |
7178 | d->fixPosIncludesFrame(); | - |
7179 | d->setGeometry_sys(geometry().x(), geometry().y(), s.width(), s.height(), false); | - |
7180 | d->setDirtyOpaqueRegion(); | - |
7181 | } else { | - |
7182 | data->crect.setSize(s.boundedTo(maximumSize()).expandedTo(minimumSize())); | - |
7183 | setAttribute(Qt::WA_PendingResizeEvent); | - |
7184 | } | - |
7185 | } | - |
7186 | | - |
7187 | void QWidget::setGeometry(const QRect &r) | - |
7188 | { | - |
7189 | Q_D(QWidget); | - |
7190 | setAttribute(Qt::WA_Resized); | - |
7191 | setAttribute(Qt::WA_Moved); | - |
7192 | if (isWindow()) | - |
7193 | d->topData()->posIncludesFrame = 0; | - |
7194 | if (testAttribute(Qt::WA_WState_Created)) { | - |
7195 | d->setGeometry_sys(r.x(), r.y(), r.width(), r.height(), true); | - |
7196 | d->setDirtyOpaqueRegion(); | - |
7197 | } else { | - |
7198 | data->crect.setTopLeft(r.topLeft()); | - |
7199 | data->crect.setSize(r.size().boundedTo(maximumSize()).expandedTo(minimumSize())); | - |
7200 | setAttribute(Qt::WA_PendingMoveEvent); | - |
7201 | setAttribute(Qt::WA_PendingResizeEvent); | - |
7202 | } | - |
7203 | | - |
7204 | if (d->extra && d->extra->hasWindowContainer) | - |
7205 | QWindowContainer::parentWasMoved(this); | - |
7206 | } | - |
7207 | | - |
7208 | void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) | - |
7209 | { | - |
7210 | Q_Q(QWidget); | - |
7211 | if (extra) { | - |
7212 | w = qMin(w,extra->maxw); | - |
7213 | h = qMin(h,extra->maxh); | - |
7214 | w = qMax(w,extra->minw); | - |
7215 | h = qMax(h,extra->minh); | - |
7216 | } | - |
7217 | | - |
7218 | if (q->isWindow() && q->windowHandle()) { | - |
7219 | QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration(); | - |
7220 | if (!integration->hasCapability(QPlatformIntegration::NonFullScreenWindows)) { | - |
7221 | x = 0; | - |
7222 | y = 0; | - |
7223 | w = q->windowHandle()->width(); | - |
7224 | h = q->windowHandle()->height(); | - |
7225 | } | - |
7226 | } | - |
7227 | | - |
7228 | QPoint oldp = q->geometry().topLeft(); | - |
7229 | QSize olds = q->size(); | - |
7230 | QRect r(x, y, w, h); | - |
7231 | | - |
7232 | bool isResize = olds != r.size(); | - |
7233 | isMove = oldp != r.topLeft(); | - |
7234 | | - |
7235 | | - |
7236 | | - |
7237 | | - |
7238 | if (r.size() == olds && oldp == r.topLeft()) | - |
7239 | return; | - |
7240 | | - |
7241 | if (!data.in_set_window_state) { | - |
7242 | q->data->window_state &= ~Qt::WindowMaximized; | - |
7243 | q->data->window_state &= ~Qt::WindowFullScreen; | - |
7244 | if (q->isWindow()) | - |
7245 | topData()->normalGeometry = QRect(0, 0, -1, -1); | - |
7246 | } | - |
7247 | | - |
7248 | QPoint oldPos = q->pos(); | - |
7249 | data.crect = r; | - |
7250 | | - |
7251 | bool needsShow = false; | - |
7252 | | - |
7253 | if (q->isWindow() || q->windowHandle()) { | - |
7254 | if (!(data.window_state & Qt::WindowFullScreen) && (w == 0 || h == 0)) { | - |
7255 | q->setAttribute(Qt::WA_OutsideWSRange, true); | - |
7256 | if (q->isVisible()) | - |
7257 | hide_sys(); | - |
7258 | data.crect = QRect(x, y, w, h); | - |
7259 | } else if (q->testAttribute(Qt::WA_OutsideWSRange)) { | - |
7260 | q->setAttribute(Qt::WA_OutsideWSRange, false); | - |
7261 | needsShow = true; | - |
7262 | } | - |
7263 | } | - |
7264 | | - |
7265 | if (q->isVisible()) { | - |
7266 | if (!q->testAttribute(Qt::WA_DontShowOnScreen) && !q->testAttribute(Qt::WA_OutsideWSRange)) { | - |
7267 | if (q->windowHandle()) { | - |
7268 | if (q->isWindow()) { | - |
7269 | q->windowHandle()->setGeometry(q->geometry()); | - |
7270 | } else { | - |
7271 | QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint()); | - |
7272 | q->windowHandle()->setGeometry(QRect(posInNativeParent,r.size())); | - |
7273 | } | - |
7274 | | - |
7275 | if (needsShow) | - |
7276 | show_sys(); | - |
7277 | } | - |
7278 | | - |
7279 | if (!q->isWindow()) { | - |
7280 | if (renderToTexture) { | - |
7281 | QRegion updateRegion(q->geometry()); | - |
7282 | updateRegion += QRect(oldPos, olds); | - |
7283 | q->parentWidget()->d_func()->invalidateBuffer(updateRegion); | - |
7284 | } else if (isMove && !isResize) { | - |
7285 | moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y()); | - |
7286 | } else { | - |
7287 | invalidateBuffer_resizeHelper(oldPos, olds); | - |
7288 | } | - |
7289 | } | - |
7290 | } | - |
7291 | | - |
7292 | if (isMove) { | - |
7293 | QMoveEvent e(q->pos(), oldPos); | - |
7294 | QApplication::sendEvent(q, &e); | - |
7295 | } | - |
7296 | if (isResize) { | - |
7297 | QResizeEvent e(r.size(), olds); | - |
7298 | QApplication::sendEvent(q, &e); | - |
7299 | if (q->windowHandle()) | - |
7300 | q->update(); | - |
7301 | } | - |
7302 | } else { | - |
7303 | if (isMove && q->pos() != oldPos) | - |
7304 | q->setAttribute(Qt::WA_PendingMoveEvent, true); | - |
7305 | if (isResize) | - |
7306 | q->setAttribute(Qt::WA_PendingResizeEvent, true); | - |
7307 | } | - |
7308 | | - |
7309 | } | - |
7310 | | - |
7311 | | - |
7312 | | - |
7313 | | - |
7314 | | - |
7315 | | - |
7316 | | - |
7317 | | - |
7318 | | - |
7319 | | - |
7320 | | - |
7321 | | - |
7322 | | - |
7323 | | - |
7324 | | - |
7325 | | - |
7326 | | - |
7327 | | - |
7328 | QByteArray QWidget::saveGeometry() const | - |
7329 | { | - |
7330 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
7331 | | - |
7332 | | - |
7333 | Q_D(const QWidget); | - |
7334 | QRect newFramePosition = frameGeometry(); | - |
7335 | QRect newNormalPosition = normalGeometry(); | - |
7336 | if(d->topData()->wasMaximized && !(windowState() & Qt::WindowMaximized)) { | - |
7337 | | - |
7338 | newFramePosition.moveTo(0, 0); | - |
7339 | newNormalPosition.moveTo(0, 0); | - |
7340 | } | - |
7341 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - |
7342 | QByteArray array; | - |
7343 | QDataStream stream(&array, QIODevice::WriteOnly); | - |
7344 | stream.setVersion(QDataStream::Qt_4_0); | - |
7345 | const quint32 magicNumber = 0x1D9D0CB; | - |
7346 | | - |
7347 | | - |
7348 | | - |
7349 | quint16 majorVersion = 2; | - |
7350 | quint16 minorVersion = 0; | - |
7351 | const int screenNumber = QApplication::desktop()->screenNumber(this); | - |
7352 | stream << magicNumber | - |
7353 | << majorVersion | - |
7354 | << minorVersion | - |
7355 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
7356 | << newFramePosition | - |
7357 | << newNormalPosition | - |
7358 | #else | - |
7359 | << frameGeometry() | - |
7360 | << normalGeometry() | - |
7361 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - |
7362 | << qint32(screenNumber) | - |
7363 | << quint8(windowState() & Qt::WindowMaximized) | - |
7364 | << quint8(windowState() & Qt::WindowFullScreen) | - |
7365 | << qint32(QApplication::desktop()->screenGeometry(screenNumber).width()); | - |
7366 | return array; | - |
7367 | } | - |
7368 | | - |
7369 | | - |
7370 | | - |
7371 | | - |
7372 | | - |
7373 | | - |
7374 | | - |
7375 | | - |
7376 | | - |
7377 | | - |
7378 | | - |
7379 | | - |
7380 | | - |
7381 | | - |
7382 | | - |
7383 | | - |
7384 | | - |
7385 | | - |
7386 | | - |
7387 | | - |
7388 | | - |
7389 | | - |
7390 | | - |
7391 | | - |
7392 | bool QWidget::restoreGeometry(const QByteArray &geometry) | - |
7393 | { | - |
7394 | if (geometry.size() < 4) | - |
7395 | return false; | - |
7396 | QDataStream stream(geometry); | - |
7397 | stream.setVersion(QDataStream::Qt_4_0); | - |
7398 | | - |
7399 | const quint32 magicNumber = 0x1D9D0CB; | - |
7400 | quint32 storedMagicNumber; | - |
7401 | stream >> storedMagicNumber; | - |
7402 | if (storedMagicNumber != magicNumber) | - |
7403 | return false; | - |
7404 | | - |
7405 | const quint16 currentMajorVersion = 2; | - |
7406 | quint16 majorVersion = 0; | - |
7407 | quint16 minorVersion = 0; | - |
7408 | | - |
7409 | stream >> majorVersion >> minorVersion; | - |
7410 | | - |
7411 | if (majorVersion > currentMajorVersion) | - |
7412 | return false; | - |
7413 | | - |
7414 | | - |
7415 | QRect restoredFrameGeometry; | - |
7416 | QRect restoredNormalGeometry; | - |
7417 | qint32 restoredScreenNumber; | - |
7418 | quint8 maximized; | - |
7419 | quint8 fullScreen; | - |
7420 | qint32 restoredScreenWidth = 0; | - |
7421 | | - |
7422 | stream >> restoredFrameGeometry | - |
7423 | >> restoredNormalGeometry | - |
7424 | >> restoredScreenNumber | - |
7425 | >> maximized | - |
7426 | >> fullScreen; | - |
7427 | | - |
7428 | if (majorVersion > 1) | - |
7429 | stream >> restoredScreenWidth; | - |
7430 | | - |
7431 | const QDesktopWidget * const desktop = QApplication::desktop(); | - |
7432 | if (restoredScreenNumber >= desktop->numScreens()) | - |
7433 | restoredScreenNumber = desktop->primaryScreen(); | - |
7434 | const qreal screenWidthF = qreal(desktop->screenGeometry(restoredScreenNumber).width()); | - |
7435 | | - |
7436 | | - |
7437 | if (restoredScreenWidth) { | - |
7438 | const qreal factor = qreal(restoredScreenWidth) / screenWidthF; | - |
7439 | if (factor < 0.8 || factor > 1.25) | - |
7440 | return false; | - |
7441 | } else { | - |
7442 | | - |
7443 | | - |
7444 | if (!maximized && !fullScreen && qreal(restoredFrameGeometry.width()) / screenWidthF > 1.5) | - |
7445 | return false; | - |
7446 | } | - |
7447 | | - |
7448 | const int frameHeight = 20; | - |
7449 | if (!restoredFrameGeometry.isValid()) | - |
7450 | restoredFrameGeometry = QRect(QPoint(0,0), sizeHint()); | - |
7451 | | - |
7452 | if (!restoredNormalGeometry.isValid()) | - |
7453 | restoredNormalGeometry = QRect(QPoint(0, frameHeight), sizeHint()); | - |
7454 | if (!restoredNormalGeometry.isValid()) { | - |
7455 | | - |
7456 | restoredNormalGeometry.setSize(restoredNormalGeometry | - |
7457 | .size() | - |
7458 | .expandedTo(d_func()->adjustedSize())); | - |
7459 | } | - |
7460 | | - |
7461 | const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber); | - |
7462 | | - |
7463 | | - |
7464 | | - |
7465 | | - |
7466 | | - |
7467 | | - |
7468 | | - |
7469 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
7470 | restoredFrameGeometry.setHeight(qMin(restoredFrameGeometry.height(), availableGeometry.height())); | - |
7471 | restoredNormalGeometry.setHeight(qMin(restoredNormalGeometry.height(), availableGeometry.height() - frameHeight)); | - |
7472 | #endif | - |
7473 | | - |
7474 | if (!restoredFrameGeometry.intersects(availableGeometry)) { | - |
7475 | restoredFrameGeometry.moveBottom(qMin(restoredFrameGeometry.bottom(), availableGeometry.bottom())); | - |
7476 | restoredFrameGeometry.moveLeft(qMax(restoredFrameGeometry.left(), availableGeometry.left())); | - |
7477 | restoredFrameGeometry.moveRight(qMin(restoredFrameGeometry.right(), availableGeometry.right())); | - |
7478 | } | - |
7479 | restoredFrameGeometry.moveTop(qMax(restoredFrameGeometry.top(), availableGeometry.top())); | - |
7480 | | - |
7481 | if (!restoredNormalGeometry.intersects(availableGeometry)) { | - |
7482 | restoredNormalGeometry.moveBottom(qMin(restoredNormalGeometry.bottom(), availableGeometry.bottom())); | - |
7483 | restoredNormalGeometry.moveLeft(qMax(restoredNormalGeometry.left(), availableGeometry.left())); | - |
7484 | restoredNormalGeometry.moveRight(qMin(restoredNormalGeometry.right(), availableGeometry.right())); | - |
7485 | } | - |
7486 | restoredNormalGeometry.moveTop(qMax(restoredNormalGeometry.top(), availableGeometry.top() + frameHeight)); | - |
7487 | | - |
7488 | if (maximized || fullScreen) { | - |
7489 | | - |
7490 | | - |
7491 | Qt::WindowStates ws = windowState(); | - |
7492 | #ifndef Q_OS_WIN | - |
7493 | setGeometry(restoredNormalGeometry); | - |
7494 | #else | - |
7495 | if (ws & Qt::WindowFullScreen) { | - |
7496 | | - |
7497 | move(availableGeometry.topLeft()); | - |
7498 | } else if (ws & Qt::WindowMaximized) { | - |
7499 | | - |
7500 | | - |
7501 | | - |
7502 | if (restoredScreenNumber != desktop->screenNumber(this)) { | - |
7503 | setWindowState(Qt::WindowNoState); | - |
7504 | setGeometry(restoredNormalGeometry); | - |
7505 | } | - |
7506 | } else { | - |
7507 | setGeometry(restoredNormalGeometry); | - |
7508 | } | - |
7509 | #endif // Q_OS_WIN | - |
7510 | if (maximized) | - |
7511 | ws |= Qt::WindowMaximized; | - |
7512 | if (fullScreen) | - |
7513 | ws |= Qt::WindowFullScreen; | - |
7514 | setWindowState(ws); | - |
7515 | d_func()->topData()->normalGeometry = restoredNormalGeometry; | - |
7516 | } else { | - |
7517 | QPoint offset; | - |
7518 | #ifdef Q_DEAD_CODE_FROM_QT4_X11 | - |
7519 | if (isFullScreen()) | - |
7520 | offset = d_func()->topData()->fullScreenOffset; | - |
7521 | #endif | - |
7522 | setWindowState(windowState() & ~(Qt::WindowMaximized | Qt::WindowFullScreen)); | - |
7523 | move(restoredFrameGeometry.topLeft() + offset); | - |
7524 | resize(restoredNormalGeometry.size()); | - |
7525 | } | - |
7526 | return true; | - |
7527 | } | - |
7528 | | - |
7529 | | - |
7530 | | - |
7531 | | - |
7532 | | - |
7533 | | - |
7534 | | - |
7535 | | - |
7536 | | - |
7537 | | - |
7538 | | - |
7539 | | - |
7540 | | - |
7541 | | - |
7542 | | - |
7543 | | - |
7544 | | - |
7545 | void QWidget::setContentsMargins(int left, int top, int right, int bottom) | - |
7546 | { | - |
7547 | Q_D(QWidget); | - |
7548 | if (left == d->leftmargin && top == d->topmargin | - |
7549 | && right == d->rightmargin && bottom == d->bottommargin) | - |
7550 | return; | - |
7551 | d->leftmargin = left; | - |
7552 | d->topmargin = top; | - |
7553 | d->rightmargin = right; | - |
7554 | d->bottommargin = bottom; | - |
7555 | | - |
7556 | if (QLayout *l=d->layout) | - |
7557 | l->update(); | - |
7558 | else | - |
7559 | updateGeometry(); | - |
7560 | | - |
7561 | if (isVisible()) { | - |
7562 | update(); | - |
7563 | QResizeEvent e(data->crect.size(), data->crect.size()); | - |
7564 | QApplication::sendEvent(this, &e); | - |
7565 | } else { | - |
7566 | setAttribute(Qt::WA_PendingResizeEvent, true); | - |
7567 | } | - |
7568 | | - |
7569 | QEvent e(QEvent::ContentsRectChange); | - |
7570 | QApplication::sendEvent(this, &e); | - |
7571 | } | - |
7572 | | - |
7573 | | - |
7574 | | - |
7575 | | - |
7576 | | - |
7577 | | - |
7578 | | - |
7579 | | - |
7580 | | - |
7581 | | - |
7582 | | - |
7583 | | - |
7584 | | - |
7585 | | - |
7586 | | - |
7587 | | - |
7588 | | - |
7589 | void QWidget::setContentsMargins(const QMargins &margins) | - |
7590 | { | - |
7591 | setContentsMargins(margins.left(), margins.top(), | - |
7592 | margins.right(), margins.bottom()); | - |
7593 | } | - |
7594 | | - |
7595 | | - |
7596 | | - |
7597 | | - |
7598 | | - |
7599 | | - |
7600 | | - |
7601 | void QWidget::getContentsMargins(int *left, int *top, int *right, int *bottom) const | - |
7602 | { | - |
7603 | Q_D(const QWidget); | - |
7604 | if (left) | - |
7605 | *left = d->leftmargin; | - |
7606 | if (top) | - |
7607 | *top = d->topmargin; | - |
7608 | if (right) | - |
7609 | *right = d->rightmargin; | - |
7610 | if (bottom) | - |
7611 | *bottom = d->bottommargin; | - |
7612 | } | - |
7613 | | - |
7614 | | - |
7615 | | - |
7616 | | - |
7617 | | - |
7618 | | - |
7619 | | - |
7620 | | - |
7621 | QMargins QWidget::contentsMargins() const | - |
7622 | { | - |
7623 | Q_D(const QWidget); | - |
7624 | return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin); | - |
7625 | } | - |
7626 | | - |
7627 | | - |
7628 | | - |
7629 | | - |
7630 | | - |
7631 | | - |
7632 | | - |
7633 | QRect QWidget::contentsRect() const | - |
7634 | { | - |
7635 | Q_D(const QWidget); | - |
7636 | return QRect(QPoint(d->leftmargin, d->topmargin), | - |
7637 | QPoint(data->crect.width() - 1 - d->rightmargin, | - |
7638 | data->crect.height() - 1 - d->bottommargin)); | - |
7639 | | - |
7640 | } | - |
7641 | | - |
7642 | | - |
7643 | | - |
7644 | | - |
7645 | | - |
7646 | | - |
7647 | | - |
7648 | | - |
7649 | | - |
7650 | | - |
7651 | | - |
7652 | | - |
7653 | | - |
7654 | | - |
7655 | | - |
7656 | | - |
7657 | | - |
7658 | | - |
7659 | | - |
7660 | | - |
7661 | | - |
7662 | | - |
7663 | | - |
7664 | | - |
7665 | | - |
7666 | | - |
7667 | | - |
7668 | | - |
7669 | | - |
7670 | | - |
7671 | | - |
7672 | | - |
7673 | | - |
7674 | Qt::ContextMenuPolicy QWidget::contextMenuPolicy() const | - |
7675 | { | - |
7676 | return (Qt::ContextMenuPolicy)data->context_menu_policy; | - |
7677 | } | - |
7678 | | - |
7679 | void QWidget::setContextMenuPolicy(Qt::ContextMenuPolicy policy) | - |
7680 | { | - |
7681 | data->context_menu_policy = (uint) policy; | - |
7682 | } | - |
7683 | | - |
7684 | | - |
7685 | | - |
7686 | | - |
7687 | | - |
7688 | | - |
7689 | | - |
7690 | | - |
7691 | | - |
7692 | | - |
7693 | | - |
7694 | | - |
7695 | | - |
7696 | | - |
7697 | | - |
7698 | | - |
7699 | | - |
7700 | | - |
7701 | | - |
7702 | | - |
7703 | | - |
7704 | | - |
7705 | | - |
7706 | Qt::FocusPolicy QWidget::focusPolicy() const | - |
7707 | { | - |
7708 | return (Qt::FocusPolicy)data->focus_policy; | - |
7709 | } | - |
7710 | | - |
7711 | void QWidget::setFocusPolicy(Qt::FocusPolicy policy) | - |
7712 | { | - |
7713 | data->focus_policy = (uint) policy; | - |
7714 | Q_D(QWidget); | - |
7715 | if (d->extra && d->extra->focus_proxy) | - |
7716 | d->extra->focus_proxy->setFocusPolicy(policy); | - |
7717 | } | - |
7718 | | - |
7719 | | - |
7720 | | - |
7721 | | - |
7722 | | - |
7723 | | - |
7724 | | - |
7725 | | - |
7726 | | - |
7727 | | - |
7728 | | - |
7729 | | - |
7730 | | - |
7731 | | - |
7732 | | - |
7733 | | - |
7734 | | - |
7735 | | - |
7736 | | - |
7737 | | - |
7738 | | - |
7739 | | - |
7740 | | - |
7741 | | - |
7742 | | - |
7743 | | - |
7744 | | - |
7745 | | - |
7746 | | - |
7747 | void QWidget::setUpdatesEnabled(bool enable) | - |
7748 | { | - |
7749 | Q_D(QWidget); | - |
7750 | setAttribute(Qt::WA_ForceUpdatesDisabled, !enable); | - |
7751 | d->setUpdatesEnabled_helper(enable); | - |
7752 | } | - |
7753 | | - |
7754 | | - |
7755 | | - |
7756 | | - |
7757 | | - |
7758 | | - |
7759 | | - |
7760 | | - |
7761 | | - |
7762 | | - |
7763 | void QWidget::show() | - |
7764 | { | - |
7765 | Qt::WindowState defaultState = QGuiApplicationPrivate::platformIntegration()->defaultWindowState(data->window_flags); | - |
7766 | if (defaultState == Qt::WindowFullScreen) | - |
7767 | showFullScreen(); | - |
7768 | else if (defaultState == Qt::WindowMaximized) | - |
7769 | showMaximized(); | - |
7770 | else | - |
7771 | setVisible(true); | - |
7772 | } | - |
7773 | | - |
7774 | | - |
7775 | | - |
7776 | | - |
7777 | | - |
7778 | | - |
7779 | void QWidgetPrivate::show_recursive() | - |
7780 | { | - |
7781 | Q_Q(QWidget); | - |
7782 | | - |
7783 | | - |
7784 | if (!q->testAttribute(Qt::WA_WState_Created)) | - |
7785 | createRecursively(); | - |
7786 | q->ensurePolished(); | - |
7787 | | - |
7788 | if (!q->isWindow() && q->parentWidget()->d_func()->layout && !q->parentWidget()->data->in_show) | - |
7789 | q->parentWidget()->d_func()->layout->activate(); | - |
7790 | | - |
7791 | if (layout) | - |
7792 | layout->activate(); | - |
7793 | | - |
7794 | show_helper(); | - |
7795 | } | - |
7796 | | - |
7797 | void QWidgetPrivate::sendPendingMoveAndResizeEvents(bool recursive, bool disableUpdates) | - |
7798 | { | - |
7799 | Q_Q(QWidget); | - |
7800 | | - |
7801 | disableUpdates = disableUpdates && q->updatesEnabled(); | - |
7802 | if (disableUpdates) | - |
7803 | q->setAttribute(Qt::WA_UpdatesDisabled); | - |
7804 | | - |
7805 | if (q->testAttribute(Qt::WA_PendingMoveEvent)) { | - |
7806 | QMoveEvent e(data.crect.topLeft(), data.crect.topLeft()); | - |
7807 | QApplication::sendEvent(q, &e); | - |
7808 | q->setAttribute(Qt::WA_PendingMoveEvent, false); | - |
7809 | } | - |
7810 | | - |
7811 | if (q->testAttribute(Qt::WA_PendingResizeEvent)) { | - |
7812 | QResizeEvent e(data.crect.size(), QSize()); | - |
7813 | QApplication::sendEvent(q, &e); | - |
7814 | q->setAttribute(Qt::WA_PendingResizeEvent, false); | - |
7815 | } | - |
7816 | | - |
7817 | if (disableUpdates) | - |
7818 | q->setAttribute(Qt::WA_UpdatesDisabled, false); | - |
7819 | | - |
7820 | if (!recursive) | - |
7821 | return; | - |
7822 | | - |
7823 | for (int i = 0; i < children.size(); ++i) { | - |
7824 | if (QWidget *child = qobject_cast<QWidget *>(children.at(i))) | - |
7825 | child->d_func()->sendPendingMoveAndResizeEvents(recursive, disableUpdates); | - |
7826 | } | - |
7827 | } | - |
7828 | | - |
7829 | void QWidgetPrivate::activateChildLayoutsRecursively() | - |
7830 | { | - |
7831 | sendPendingMoveAndResizeEvents(false, true); | - |
7832 | | - |
7833 | for (int i = 0; i < children.size(); ++i) { | - |
7834 | QWidget *child = qobject_cast<QWidget *>(children.at(i)); | - |
7835 | if (!child || child->isHidden() || child->isWindow()) | - |
7836 | continue; | - |
7837 | | - |
7838 | child->ensurePolished(); | - |
7839 | | - |
7840 | | - |
7841 | QWidgetPrivate *childPrivate = child->d_func(); | - |
7842 | if (childPrivate->layout) | - |
7843 | childPrivate->layout->activate(); | - |
7844 | | - |
7845 | | - |
7846 | const bool wasVisible = child->isVisible(); | - |
7847 | if (!wasVisible) | - |
7848 | child->setAttribute(Qt::WA_WState_Visible); | - |
7849 | | - |
7850 | | - |
7851 | childPrivate->activateChildLayoutsRecursively(); | - |
7852 | | - |
7853 | | - |
7854 | if (!wasVisible) | - |
7855 | child->setAttribute(Qt::WA_WState_Visible, false); | - |
7856 | } | - |
7857 | } | - |
7858 | | - |
7859 | void QWidgetPrivate::show_helper() | - |
7860 | { | - |
7861 | Q_Q(QWidget); | - |
7862 | data.in_show = true; | - |
7863 | | - |
7864 | sendPendingMoveAndResizeEvents(); | - |
7865 | | - |
7866 | | - |
7867 | q->setAttribute(Qt::WA_WState_Visible); | - |
7868 | | - |
7869 | | - |
7870 | showChildren(false); | - |
7871 | | - |
7872 | | - |
7873 | | - |
7874 | const bool isWindow = q->isWindow(); | - |
7875 | #ifndef QT_NO_GRAPHICSVIEW | - |
7876 | bool isEmbedded = isWindow && q->graphicsProxyWidget() != Q_NULLPTR; | - |
7877 | #else | - |
7878 | bool isEmbedded = false; | - |
7879 | #endif | - |
7880 | | - |
7881 | | - |
7882 | | - |
7883 | | - |
7884 | if (isWindow && !isEmbedded) { | - |
7885 | if ((q->windowType() == Qt::Tool) || (q->windowType() == Qt::Popup) || q->windowType() == Qt::ToolTip) { | - |
7886 | q->raise(); | - |
7887 | if (q->parentWidget() && q->parentWidget()->window()->testAttribute(Qt::WA_KeyboardFocusChange)) | - |
7888 | q->setAttribute(Qt::WA_KeyboardFocusChange); | - |
7889 | } else { | - |
7890 | while (QApplication::activePopupWidget()) { | - |
7891 | if (!QApplication::activePopupWidget()->close()) | - |
7892 | break; | - |
7893 | } | - |
7894 | } | - |
7895 | } | - |
7896 | | - |
7897 | | - |
7898 | | - |
7899 | #ifndef QT_NO_GRAPHICSVIEW | - |
7900 | if (isWindow) { | - |
7901 | if (!isEmbedded && !bypassGraphicsProxyWidget(q)) { | - |
7902 | QGraphicsProxyWidget *ancestorProxy = nearestGraphicsProxyWidget(q->parentWidget()); | - |
7903 | if (ancestorProxy) { | - |
7904 | isEmbedded = true; | - |
7905 | ancestorProxy->d_func()->embedSubWindow(q); | - |
7906 | } | - |
7907 | } | - |
7908 | } | - |
7909 | #else | - |
7910 | Q_UNUSED(isEmbedded); | - |
7911 | #endif | - |
7912 | | - |
7913 | | - |
7914 | | - |
7915 | | - |
7916 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_MAC) | - |
7917 | if (!isEmbedded && q->windowType() == Qt::Popup) | - |
7918 | qApp->d_func()->openPopup(q); | - |
7919 | #endif | - |
7920 | | - |
7921 | | - |
7922 | QShowEvent showEvent; | - |
7923 | QApplication::sendEvent(q, &showEvent); | - |
7924 | | - |
7925 | show_sys(); | - |
7926 | | - |
7927 | if (!isEmbedded && q->windowType() == Qt::Popup) | - |
7928 | qApp->d_func()->openPopup(q); | - |
7929 | | - |
7930 | #ifndef QT_NO_ACCESSIBILITY | - |
7931 | if (q->windowType() != Qt::ToolTip) { | - |
7932 | QAccessibleEvent event(q, QAccessible::ObjectShow); | - |
7933 | QAccessible::updateAccessibility(&event); | - |
7934 | } | - |
7935 | #endif | - |
7936 | | - |
7937 | if (QApplicationPrivate::hidden_focus_widget == q) { | - |
7938 | QApplicationPrivate::hidden_focus_widget = 0; | - |
7939 | q->setFocus(Qt::OtherFocusReason); | - |
7940 | } | - |
7941 | | - |
7942 | | - |
7943 | | - |
7944 | | - |
7945 | if (!qApp->d_func()->in_exec && q->windowType() == Qt::SplashScreen) | - |
7946 | QApplication::processEvents(); | - |
7947 | | - |
7948 | data.in_show = false; | - |
7949 | } | - |
7950 | | - |
7951 | void QWidgetPrivate::show_sys() | - |
7952 | { | - |
7953 | Q_Q(QWidget); | - |
7954 | | - |
7955 | QWindow *window = q->windowHandle(); | - |
7956 | | - |
7957 | if (q->testAttribute(Qt::WA_DontShowOnScreen)) { | - |
7958 | invalidateBuffer(q->rect()); | - |
7959 | q->setAttribute(Qt::WA_Mapped); | - |
7960 | | - |
7961 | if (window && q->isWindow() | - |
7962 | #ifndef QT_NO_GRAPHICSVIEW | - |
7963 | && (!extra || !extra->proxyWidget) | - |
7964 | #endif | - |
7965 | && q->windowModality() != Qt::NonModal) { | - |
7966 | QGuiApplicationPrivate::showModalWindow(window); | - |
7967 | } | - |
7968 | return; | - |
7969 | } | - |
7970 | | - |
7971 | if (renderToTexture && !q->isWindow()) | - |
7972 | QApplication::postEvent(q->parentWidget(), new QUpdateLaterEvent(q->geometry())); | - |
7973 | else | - |
7974 | QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); | - |
7975 | | - |
7976 | if ((!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow)) | - |
7977 | || q->testAttribute(Qt::WA_OutsideWSRange)) { | - |
7978 | return; | - |
7979 | } | - |
7980 | | - |
7981 | if (window) { | - |
7982 | if (q->isWindow()) | - |
7983 | fixPosIncludesFrame(); | - |
7984 | QRect geomRect = q->geometry(); | - |
7985 | if (!q->isWindow()) { | - |
7986 | QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),QPoint()); | - |
7987 | geomRect.moveTopLeft(topLeftOfWindow); | - |
7988 | } | - |
7989 | const QRect windowRect = window->geometry(); | - |
7990 | if (windowRect != geomRect) { | - |
7991 | if (q->testAttribute(Qt::WA_Moved) | - |
7992 | || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowManagement)) | - |
7993 | window->setGeometry(geomRect); | - |
7994 | else | - |
7995 | window->resize(geomRect.size()); | - |
7996 | } | - |
7997 | | - |
7998 | #ifndef QT_NO_CURSOR | - |
7999 | qt_qpa_set_cursor(q, false); | - |
8000 | #endif | - |
8001 | invalidateBuffer(q->rect()); | - |
8002 | window->setVisible(true); | - |
8003 | | - |
8004 | if (window->isTopLevel()) { | - |
8005 | const QPoint crectTopLeft = q->data->crect.topLeft(); | - |
8006 | const QPoint windowTopLeft = window->geometry().topLeft(); | - |
8007 | if (crectTopLeft == QPoint(0, 0) && windowTopLeft != crectTopLeft) | - |
8008 | q->data->crect.moveTopLeft(windowTopLeft); | - |
8009 | } | - |
8010 | } | - |
8011 | } | - |
8012 | | - |
8013 | | - |
8014 | | - |
8015 | | - |
8016 | | - |
8017 | | - |
8018 | | - |
8019 | | - |
8020 | | - |
8021 | | - |
8022 | | - |
8023 | | - |
8024 | void QWidget::hide() | - |
8025 | { | - |
8026 | setVisible(false); | - |
8027 | } | - |
8028 | | - |
8029 | | - |
8030 | | - |
8031 | void QWidgetPrivate::hide_helper() | - |
8032 | { | - |
8033 | Q_Q(QWidget); | - |
8034 | | - |
8035 | bool isEmbedded = false; | - |
8036 | #if !defined QT_NO_GRAPHICSVIEW | - |
8037 | isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != 0; | - |
8038 | #else | - |
8039 | Q_UNUSED(isEmbedded); | - |
8040 | #endif | - |
8041 | | - |
8042 | if (!isEmbedded && (q->windowType() == Qt::Popup)) | - |
8043 | qApp->d_func()->closePopup(q); | - |
8044 | | - |
8045 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - |
8046 | if (q->isWindow() && !(q->windowType() == Qt::Popup) && q->parentWidget() | - |
8047 | && !q->parentWidget()->isHidden() && q->isActiveWindow()) | - |
8048 | q->parentWidget()->activateWindow(); | - |
8049 | #endif | - |
8050 | | - |
8051 | q->setAttribute(Qt::WA_Mapped, false); | - |
8052 | hide_sys(); | - |
8053 | | - |
8054 | bool wasVisible = q->testAttribute(Qt::WA_WState_Visible); | - |
8055 | | - |
8056 | if (wasVisible) { | - |
8057 | q->setAttribute(Qt::WA_WState_Visible, false); | - |
8058 | | - |
8059 | } | - |
8060 | | - |
8061 | QHideEvent hideEvent; | - |
8062 | QApplication::sendEvent(q, &hideEvent); | - |
8063 | hideChildren(false); | - |
8064 | | - |
8065 | | - |
8066 | | - |
8067 | if (wasVisible) { | - |
8068 | qApp->d_func()->sendSyntheticEnterLeave(q); | - |
8069 | QWidget *fw = QApplication::focusWidget(); | - |
8070 | while (fw && !fw->isWindow()) { | - |
8071 | if (fw == q) { | - |
8072 | q->focusNextPrevChild(true); | - |
8073 | break; | - |
8074 | } | - |
8075 | fw = fw->parentWidget(); | - |
8076 | } | - |
8077 | } | - |
8078 | | - |
8079 | if (QWidgetBackingStore *bs = maybeBackingStore()) | - |
8080 | bs->removeDirtyWidget(q); | - |
8081 | | - |
8082 | #ifndef QT_NO_ACCESSIBILITY | - |
8083 | if (wasVisible) { | - |
8084 | QAccessibleEvent event(q, QAccessible::ObjectHide); | - |
8085 | QAccessible::updateAccessibility(&event); | - |
8086 | } | - |
8087 | #endif | - |
8088 | } | - |
8089 | | - |
8090 | void QWidgetPrivate::hide_sys() | - |
8091 | { | - |
8092 | Q_Q(QWidget); | - |
8093 | | - |
8094 | QWindow *window = q->windowHandle(); | - |
8095 | | - |
8096 | if (q->testAttribute(Qt::WA_DontShowOnScreen)) { | - |
8097 | q->setAttribute(Qt::WA_Mapped, false); | - |
8098 | | - |
8099 | if (window && q->isWindow() | - |
8100 | #ifndef QT_NO_GRAPHICSVIEW | - |
8101 | && (!extra || !extra->proxyWidget) | - |
8102 | #endif | - |
8103 | && q->windowModality() != Qt::NonModal) { | - |
8104 | QGuiApplicationPrivate::hideModalWindow(window); | - |
8105 | } | - |
8106 | | - |
8107 | } | - |
8108 | | - |
8109 | deactivateWidgetCleanup(); | - |
8110 | | - |
8111 | if (!q->isWindow()) { | - |
8112 | QWidget *p = q->parentWidget(); | - |
8113 | if (p &&p->isVisible()) { | - |
8114 | if (renderToTexture) | - |
8115 | p->d_func()->invalidateBuffer(q->geometry()); | - |
8116 | else | - |
8117 | invalidateBuffer(q->rect()); | - |
8118 | } | - |
8119 | } else { | - |
8120 | invalidateBuffer(q->rect()); | - |
8121 | } | - |
8122 | | - |
8123 | if (window) | - |
8124 | window->setVisible(false); | - |
8125 | } | - |
8126 | | - |
8127 | | - |
8128 | | - |
8129 | | - |
8130 | | - |
8131 | | - |
8132 | | - |
8133 | | - |
8134 | | - |
8135 | | - |
8136 | | - |
8137 | | - |
8138 | | - |
8139 | | - |
8140 | | - |
8141 | | - |
8142 | | - |
8143 | | - |
8144 | | - |
8145 | | - |
8146 | | - |
8147 | | - |
8148 | | - |
8149 | | - |
8150 | | - |
8151 | void QWidget::setVisible(bool visible) | - |
8152 | { | - |
8153 | if (visible) { | - |
8154 | if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden)) | - |
8155 | return; | - |
8156 | | - |
8157 | Q_D(QWidget); | - |
8158 | | - |
8159 | | - |
8160 | if (!isWindow() && parentWidget() && parentWidget()->isVisible() | - |
8161 | && !parentWidget()->testAttribute(Qt::WA_WState_Created)) | - |
8162 | parentWidget()->window()->d_func()->createRecursively(); | - |
8163 | | - |
8164 | | - |
8165 | QWidget *pw = parentWidget(); | - |
8166 | if (!testAttribute(Qt::WA_WState_Created) | - |
8167 | && (isWindow() || pw->testAttribute(Qt::WA_WState_Created))) { | - |
8168 | create(); | - |
8169 | } | - |
8170 | | - |
8171 | bool wasResized = testAttribute(Qt::WA_Resized); | - |
8172 | Qt::WindowStates initialWindowState = windowState(); | - |
8173 | | - |
8174 | | - |
8175 | ensurePolished(); | - |
8176 | | - |
8177 | | - |
8178 | setAttribute(Qt::WA_WState_ExplicitShowHide); | - |
8179 | | - |
8180 | bool needUpdateGeometry = !isWindow() && testAttribute(Qt::WA_WState_Hidden); | - |
8181 | | - |
8182 | setAttribute(Qt::WA_WState_Hidden, false); | - |
8183 | | - |
8184 | if (needUpdateGeometry) | - |
8185 | d->updateGeometry_helper(true); | - |
8186 | | - |
8187 | | - |
8188 | if (d->layout) | - |
8189 | d->layout->activate(); | - |
8190 | | - |
8191 | if (!isWindow()) { | - |
8192 | QWidget *parent = parentWidget(); | - |
8193 | while (parent && parent->isVisible() && parent->d_func()->layout && !parent->data->in_show) { | - |
8194 | parent->d_func()->layout->activate(); | - |
8195 | if (parent->isWindow()) | - |
8196 | break; | - |
8197 | parent = parent->parentWidget(); | - |
8198 | } | - |
8199 | if (parent) | - |
8200 | parent->d_func()->setDirtyOpaqueRegion(); | - |
8201 | } | - |
8202 | | - |
8203 | | - |
8204 | if (!wasResized | - |
8205 | && (isWindow() || !parentWidget()->d_func()->layout)) { | - |
8206 | if (isWindow()) { | - |
8207 | adjustSize(); | - |
8208 | if (windowState() != initialWindowState) | - |
8209 | setWindowState(initialWindowState); | - |
8210 | } else { | - |
8211 | adjustSize(); | - |
8212 | } | - |
8213 | setAttribute(Qt::WA_Resized, false); | - |
8214 | } | - |
8215 | | - |
8216 | setAttribute(Qt::WA_KeyboardFocusChange, false); | - |
8217 | | - |
8218 | if (isWindow() || parentWidget()->isVisible()) { | - |
8219 | d->show_helper(); | - |
8220 | | - |
8221 | qApp->d_func()->sendSyntheticEnterLeave(this); | - |
8222 | } | - |
8223 | | - |
8224 | QEvent showToParentEvent(QEvent::ShowToParent); | - |
8225 | QApplication::sendEvent(this, &showToParentEvent); | - |
8226 | } else { | - |
8227 | if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden)) | - |
8228 | return; | - |
8229 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - |
8230 | | - |
8231 | if(isWindow() && testAttribute(Qt::WA_WState_Created) | - |
8232 | && QApplicationPrivate::isBlockedByModal(this)) | - |
8233 | { | - |
8234 | LONG dwStyle = GetWindowLong(winId(), GWL_STYLE); | - |
8235 | dwStyle &= ~WS_DISABLED; | - |
8236 | SetWindowLong(winId(), GWL_STYLE, dwStyle); | - |
8237 | } | - |
8238 | #endif | - |
8239 | if (QApplicationPrivate::hidden_focus_widget == this) | - |
8240 | QApplicationPrivate::hidden_focus_widget = 0; | - |
8241 | | - |
8242 | Q_D(QWidget); | - |
8243 | | - |
8244 | | - |
8245 | | - |
8246 | | - |
8247 | | - |
8248 | if (!isWindow() && parentWidget()) | - |
8249 | parentWidget()->d_func()->setDirtyOpaqueRegion(); | - |
8250 | | - |
8251 | setAttribute(Qt::WA_WState_Hidden); | - |
8252 | setAttribute(Qt::WA_WState_ExplicitShowHide); | - |
8253 | if (testAttribute(Qt::WA_WState_Created)) | - |
8254 | d->hide_helper(); | - |
8255 | | - |
8256 | | - |
8257 | if (!isWindow() && parentWidget()) { | - |
8258 | if (parentWidget()->d_func()->layout) | - |
8259 | parentWidget()->d_func()->layout->invalidate(); | - |
8260 | else if (parentWidget()->isVisible()) | - |
8261 | QApplication::postEvent(parentWidget(), new QEvent(QEvent::LayoutRequest)); | - |
8262 | } | - |
8263 | | - |
8264 | QEvent hideToParentEvent(QEvent::HideToParent); | - |
8265 | QApplication::sendEvent(this, &hideToParentEvent); | - |
8266 | } | - |
8267 | } | - |
8268 | | - |
8269 | | - |
8270 | | - |
8271 | | - |
8272 | void QWidget::setHidden(bool hidden) | - |
8273 | { | - |
8274 | setVisible(!hidden); | - |
8275 | } | - |
8276 | | - |
8277 | void QWidgetPrivate::_q_showIfNotHidden() | - |
8278 | { | - |
8279 | Q_Q(QWidget); | - |
8280 | if ( !(q->isHidden() && q->testAttribute(Qt::WA_WState_ExplicitShowHide)) ) | - |
8281 | q->setVisible(true); | - |
8282 | } | - |
8283 | | - |
8284 | void QWidgetPrivate::showChildren(bool spontaneous) | - |
8285 | { | - |
8286 | QList<QObject*> childList = children; | - |
8287 | for (int i = 0; i < childList.size(); ++i) { | - |
8288 | QWidget *widget = qobject_cast<QWidget*>(childList.at(i)); | - |
8289 | if (!widget | - |
8290 | || widget->isWindow() | - |
8291 | || widget->testAttribute(Qt::WA_WState_Hidden)) | - |
8292 | continue; | - |
8293 | if (spontaneous) { | - |
8294 | widget->setAttribute(Qt::WA_Mapped); | - |
8295 | widget->d_func()->showChildren(true); | - |
8296 | QShowEvent e; | - |
8297 | QApplication::sendSpontaneousEvent(widget, &e); | - |
8298 | } else { | - |
8299 | if (widget->testAttribute(Qt::WA_WState_ExplicitShowHide)) | - |
8300 | widget->d_func()->show_recursive(); | - |
8301 | else | - |
8302 | widget->show(); | - |
8303 | } | - |
8304 | } | - |
8305 | } | - |
8306 | | - |
8307 | void QWidgetPrivate::hideChildren(bool spontaneous) | - |
8308 | { | - |
8309 | QList<QObject*> childList = children; | - |
8310 | for (int i = 0; i < childList.size(); ++i) { | - |
8311 | QWidget *widget = qobject_cast<QWidget*>(childList.at(i)); | - |
8312 | if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden)) | - |
8313 | continue; | - |
8314 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
8315 | | - |
8316 | | - |
8317 | | - |
8318 | | - |
8319 | | - |
8320 | | - |
8321 | | - |
8322 | | - |
8323 | | - |
8324 | | - |
8325 | | - |
8326 | | - |
8327 | | - |
8328 | if(widget == qt_button_down) | - |
8329 | qt_button_down = 0; | - |
8330 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - |
8331 | if (spontaneous) | - |
8332 | widget->setAttribute(Qt::WA_Mapped, false); | - |
8333 | else | - |
8334 | widget->setAttribute(Qt::WA_WState_Visible, false); | - |
8335 | widget->d_func()->hideChildren(spontaneous); | - |
8336 | QHideEvent e; | - |
8337 | if (spontaneous) { | - |
8338 | QApplication::sendSpontaneousEvent(widget, &e); | - |
8339 | } else { | - |
8340 | QApplication::sendEvent(widget, &e); | - |
8341 | if (widget->internalWinId() | - |
8342 | && widget->testAttribute(Qt::WA_DontCreateNativeAncestors)) { | - |
8343 | | - |
8344 | | - |
8345 | widget->d_func()->hide_sys(); | - |
8346 | } | - |
8347 | } | - |
8348 | qApp->d_func()->sendSyntheticEnterLeave(widget); | - |
8349 | #ifndef QT_NO_ACCESSIBILITY | - |
8350 | if (!spontaneous) { | - |
8351 | QAccessibleEvent event(widget, QAccessible::ObjectHide); | - |
8352 | QAccessible::updateAccessibility(&event); | - |
8353 | } | - |
8354 | #endif | - |
8355 | } | - |
8356 | } | - |
8357 | | - |
8358 | bool QWidgetPrivate::close_helper(CloseMode mode) | - |
8359 | { | - |
8360 | if (data.is_closing) | - |
8361 | return true; | - |
8362 | | - |
8363 | Q_Q(QWidget); | - |
8364 | data.is_closing = 1; | - |
8365 | | - |
8366 | QPointer<QWidget> that = q; | - |
8367 | QPointer<QWidget> parentWidget = q->parentWidget(); | - |
8368 | | - |
8369 | bool quitOnClose = q->testAttribute(Qt::WA_QuitOnClose); | - |
8370 | if (mode != CloseNoEvent) { | - |
8371 | QCloseEvent e; | - |
8372 | if (mode == CloseWithSpontaneousEvent) | - |
8373 | QApplication::sendSpontaneousEvent(q, &e); | - |
8374 | else | - |
8375 | QApplication::sendEvent(q, &e); | - |
8376 | if (!that.isNull() && !e.isAccepted()) { | - |
8377 | data.is_closing = 0; | - |
8378 | return false; | - |
8379 | } | - |
8380 | } | - |
8381 | | - |
8382 | if (!that.isNull() && !q->isHidden()) | - |
8383 | q->hide(); | - |
8384 | | - |
8385 | | - |
8386 | quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible()); | - |
8387 | | - |
8388 | if (quitOnClose) { | - |
8389 | | - |
8390 | | - |
8391 | | - |
8392 | QWidgetList list = QApplication::topLevelWidgets(); | - |
8393 | bool lastWindowClosed = true; | - |
8394 | for (int i = 0; i < list.size(); ++i) { | - |
8395 | QWidget *w = list.at(i); | - |
8396 | if (!w->isVisible() || w->parentWidget() || !w->testAttribute(Qt::WA_QuitOnClose)) | - |
8397 | continue; | - |
8398 | lastWindowClosed = false; | - |
8399 | break; | - |
8400 | } | - |
8401 | if (lastWindowClosed) { | - |
8402 | QGuiApplicationPrivate::emitLastWindowClosed(); | - |
8403 | QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance())); | - |
8404 | applicationPrivate->maybeQuit(); | - |
8405 | } | - |
8406 | } | - |
8407 | | - |
8408 | | - |
8409 | if (!that.isNull()) { | - |
8410 | data.is_closing = 0; | - |
8411 | if (q->testAttribute(Qt::WA_DeleteOnClose)) { | - |
8412 | q->setAttribute(Qt::WA_DeleteOnClose, false); | - |
8413 | q->deleteLater(); | - |
8414 | } | - |
8415 | } | - |
8416 | return true; | - |
8417 | } | - |
8418 | | - |
8419 | | - |
8420 | | - |
8421 | | - |
8422 | | - |
8423 | | - |
8424 | | - |
8425 | | - |
8426 | | - |
8427 | | - |
8428 | | - |
8429 | | - |
8430 | | - |
8431 | | - |
8432 | | - |
8433 | | - |
8434 | | - |
8435 | | - |
8436 | | - |
8437 | | - |
8438 | | - |
8439 | | - |
8440 | | - |
8441 | | - |
8442 | bool QWidget::close() | - |
8443 | { | - |
8444 | return d_func()->close_helper(QWidgetPrivate::CloseWithEvent); | - |
8445 | } | - |
8446 | | - |
8447 | | - |
8448 | | - |
8449 | | - |
8450 | | - |
8451 | | - |
8452 | | - |
8453 | | - |
8454 | | - |
8455 | | - |
8456 | | - |
8457 | | - |
8458 | | - |
8459 | | - |
8460 | | - |
8461 | | - |
8462 | | - |
8463 | | - |
8464 | | - |
8465 | | - |
8466 | | - |
8467 | | - |
8468 | | - |
8469 | | - |
8470 | | - |
8471 | | - |
8472 | | - |
8473 | | - |
8474 | | - |
8475 | | - |
8476 | | - |
8477 | | - |
8478 | | - |
8479 | | - |
8480 | | - |
8481 | | - |
8482 | | - |
8483 | | - |
8484 | | - |
8485 | | - |
8486 | | - |
8487 | | - |
8488 | | - |
8489 | | - |
8490 | | - |
8491 | | - |
8492 | | - |
8493 | | - |
8494 | | - |
8495 | | - |
8496 | | - |
8497 | | - |
8498 | | - |
8499 | | - |
8500 | | - |
8501 | | - |
8502 | | - |
8503 | | - |
8504 | | - |
8505 | bool QWidget::isVisibleTo(const QWidget *ancestor) const | - |
8506 | { | - |
8507 | if (!ancestor) | - |
8508 | return isVisible(); | - |
8509 | const QWidget * w = this; | - |
8510 | while (!w->isHidden() | - |
8511 | && !w->isWindow() | - |
8512 | && w->parentWidget() | - |
8513 | && w->parentWidget() != ancestor) | - |
8514 | w = w->parentWidget(); | - |
8515 | return !w->isHidden(); | - |
8516 | } | - |
8517 | | - |
8518 | | - |
8519 | | - |
8520 | | - |
8521 | | - |
8522 | | - |
8523 | | - |
8524 | | - |
8525 | | - |
8526 | | - |
8527 | | - |
8528 | | - |
8529 | QRegion QWidget::visibleRegion() const | - |
8530 | { | - |
8531 | Q_D(const QWidget); | - |
8532 | | - |
8533 | QRect clipRect = d->clipRect(); | - |
8534 | if (clipRect.isEmpty()) | - |
8535 | return QRegion(); | - |
8536 | QRegion r(clipRect); | - |
8537 | d->subtractOpaqueChildren(r, clipRect); | - |
8538 | d->subtractOpaqueSiblings(r); | - |
8539 | return r; | - |
8540 | } | - |
8541 | | - |
8542 | | - |
8543 | QSize QWidgetPrivate::adjustedSize() const | - |
8544 | { | - |
8545 | Q_Q(const QWidget); | - |
8546 | | - |
8547 | QSize s = q->sizeHint(); | - |
8548 | | - |
8549 | if (q->isWindow()) { | - |
8550 | Qt::Orientations exp; | - |
8551 | if (layout) { | - |
8552 | if (layout->hasHeightForWidth()) | - |
8553 | s.setHeight(layout->totalHeightForWidth(s.width())); | - |
8554 | exp = layout->expandingDirections(); | - |
8555 | } else | - |
8556 | { | - |
8557 | if (q->sizePolicy().hasHeightForWidth()) | - |
8558 | s.setHeight(q->heightForWidth(s.width())); | - |
8559 | exp = q->sizePolicy().expandingDirections(); | - |
8560 | } | - |
8561 | if (exp & Qt::Horizontal) | - |
8562 | s.setWidth(qMax(s.width(), 200)); | - |
8563 | if (exp & Qt::Vertical) | - |
8564 | s.setHeight(qMax(s.height(), 100)); | - |
8565 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - |
8566 | QRect screen = QApplication::desktop()->screenGeometry(q->x11Info().screen()); | - |
8567 | #else // all others | - |
8568 | QRect screen = QApplication::desktop()->screenGeometry(q->pos()); | - |
8569 | #endif | - |
8570 | #if defined (Q_OS_WINCE) | - |
8571 | s.setWidth(qMin(s.width(), screen.width())); | - |
8572 | s.setHeight(qMin(s.height(), screen.height())); | - |
8573 | #else | - |
8574 | s.setWidth(qMin(s.width(), screen.width()*2/3)); | - |
8575 | s.setHeight(qMin(s.height(), screen.height()*2/3)); | - |
8576 | #endif | - |
8577 | if (QTLWExtra *extra = maybeTopData()) | - |
8578 | extra->sizeAdjusted = true; | - |
8579 | } | - |
8580 | | - |
8581 | if (!s.isValid()) { | - |
8582 | QRect r = q->childrenRect(); | - |
8583 | if (r.isNull()) | - |
8584 | return s; | - |
8585 | s = r.size() + QSize(2 * r.x(), 2 * r.y()); | - |
8586 | } | - |
8587 | | - |
8588 | return s; | - |
8589 | } | - |
8590 | | - |
8591 | | - |
8592 | | - |
8593 | | - |
8594 | | - |
8595 | | - |
8596 | | - |
8597 | | - |
8598 | | - |
8599 | | - |
8600 | | - |
8601 | | - |
8602 | | - |
8603 | | - |
8604 | | - |
8605 | | - |
8606 | | - |
8607 | void QWidget::adjustSize() | - |
8608 | { | - |
8609 | Q_D(QWidget); | - |
8610 | ensurePolished(); | - |
8611 | QSize s = d->adjustedSize(); | - |
8612 | | - |
8613 | if (d->layout) | - |
8614 | d->layout->activate(); | - |
8615 | | - |
8616 | if (s.isValid()) | - |
8617 | resize(s); | - |
8618 | } | - |
8619 | | - |
8620 | | - |
8621 | | - |
8622 | | - |
8623 | | - |
8624 | | - |
8625 | | - |
8626 | | - |
8627 | | - |
8628 | | - |
8629 | | - |
8630 | | - |
8631 | | - |
8632 | | - |
8633 | | - |
8634 | | - |
8635 | | - |
8636 | QSize QWidget::sizeHint() const | - |
8637 | { | - |
8638 | Q_D(const QWidget); | - |
8639 | if (d->layout) | - |
8640 | return d->layout->totalSizeHint(); | - |
8641 | return QSize(-1, -1); | - |
8642 | } | - |
8643 | | - |
8644 | | - |
8645 | | - |
8646 | | - |
8647 | | - |
8648 | | - |
8649 | | - |
8650 | | - |
8651 | | - |
8652 | | - |
8653 | | - |
8654 | | - |
8655 | | - |
8656 | | - |
8657 | | - |
8658 | | - |
8659 | | - |
8660 | | - |
8661 | | - |
8662 | | - |
8663 | QSize QWidget::minimumSizeHint() const | - |
8664 | { | - |
8665 | Q_D(const QWidget); | - |
8666 | if (d->layout) | - |
8667 | return d->layout->totalMinimumSize(); | - |
8668 | return QSize(-1, -1); | - |
8669 | } | - |
8670 | | - |
8671 | | - |
8672 | | - |
8673 | | - |
8674 | | - |
8675 | | - |
8676 | | - |
8677 | | - |
8678 | | - |
8679 | | - |
8680 | | - |
8681 | | - |
8682 | | - |
8683 | | - |
8684 | | - |
8685 | | - |
8686 | bool QWidget::isAncestorOf(const QWidget *child) const | - |
8687 | { | - |
8688 | while (child) { | - |
8689 | if (child == this) | - |
8690 | return true; | - |
8691 | if (child->isWindow()) | - |
8692 | return false; | - |
8693 | child = child->parentWidget(); | - |
8694 | } | - |
8695 | return false; | - |
8696 | } | - |
8697 | | - |
8698 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - |
8699 | inline void setDisabledStyle(QWidget *w, bool setStyle) | - |
8700 | { | - |
8701 | | - |
8702 | if(w && w->isWindow() && w->isVisible() && w->isEnabled()) { | - |
8703 | LONG dwStyle = GetWindowLong(w->winId(), GWL_STYLE); | - |
8704 | LONG newStyle = dwStyle; | - |
8705 | if (setStyle) | - |
8706 | newStyle |= WS_DISABLED; | - |
8707 | else | - |
8708 | newStyle &= ~WS_DISABLED; | - |
8709 | if (newStyle != dwStyle) { | - |
8710 | SetWindowLong(w->winId(), GWL_STYLE, newStyle); | - |
8711 | | - |
8712 | w->repaint(); | - |
8713 | } | - |
8714 | } | - |
8715 | } | - |
8716 | #endif | - |
8717 | | - |
8718 | | - |
8719 | | - |
8720 | | - |
8721 | | - |
8722 | | - |
8723 | | - |
8724 | | - |
8725 | | - |
8726 | | - |
8727 | | - |
8728 | | - |
8729 | | - |
8730 | | - |
8731 | | - |
8732 | | - |
8733 | | - |
8734 | | - |
8735 | | - |
8736 | | - |
8737 | | - |
8738 | | - |
8739 | | - |
8740 | | - |
8741 | | - |
8742 | | - |
8743 | | - |
8744 | | - |
8745 | | - |
8746 | | - |
8747 | | - |
8748 | | - |
8749 | | - |
8750 | bool QWidget::event(QEvent *event) | - |
8751 | { | - |
8752 | Q_D(QWidget); | - |
8753 | | - |
8754 | | - |
8755 | if (!isEnabled()) { | - |
8756 | switch(event->type()) { | - |
8757 | case QEvent::TabletPress: | - |
8758 | case QEvent::TabletRelease: | - |
8759 | case QEvent::TabletMove: | - |
8760 | case QEvent::MouseButtonPress: | - |
8761 | case QEvent::MouseButtonRelease: | - |
8762 | case QEvent::MouseButtonDblClick: | - |
8763 | case QEvent::MouseMove: | - |
8764 | case QEvent::TouchBegin: | - |
8765 | case QEvent::TouchUpdate: | - |
8766 | case QEvent::TouchEnd: | - |
8767 | case QEvent::TouchCancel: | - |
8768 | case QEvent::ContextMenu: | - |
8769 | case QEvent::KeyPress: | - |
8770 | case QEvent::KeyRelease: | - |
8771 | #ifndef QT_NO_WHEELEVENT | - |
8772 | case QEvent::Wheel: | - |
8773 | #endif | - |
8774 | return false; | - |
8775 | default: | - |
8776 | break; | - |
8777 | } | - |
8778 | } | - |
8779 | switch (event->type()) { | - |
8780 | case QEvent::MouseMove: | - |
8781 | mouseMoveEvent((QMouseEvent*)event); | - |
8782 | break; | - |
8783 | | - |
8784 | case QEvent::MouseButtonPress: | - |
8785 | mousePressEvent((QMouseEvent*)event); | - |
8786 | break; | - |
8787 | | - |
8788 | case QEvent::MouseButtonRelease: | - |
8789 | mouseReleaseEvent((QMouseEvent*)event); | - |
8790 | break; | - |
8791 | | - |
8792 | case QEvent::MouseButtonDblClick: | - |
8793 | mouseDoubleClickEvent((QMouseEvent*)event); | - |
8794 | break; | - |
8795 | #ifndef QT_NO_WHEELEVENT | - |
8796 | case QEvent::Wheel: | - |
8797 | wheelEvent((QWheelEvent*)event); | - |
8798 | break; | - |
8799 | #endif | - |
8800 | #ifndef QT_NO_TABLETEVENT | - |
8801 | case QEvent::TabletMove: | - |
8802 | case QEvent::TabletPress: | - |
8803 | case QEvent::TabletRelease: | - |
8804 | tabletEvent((QTabletEvent*)event); | - |
8805 | break; | - |
8806 | #endif | - |
8807 | case QEvent::KeyPress: { | - |
8808 | QKeyEvent *k = (QKeyEvent *)event; | - |
8809 | bool res = false; | - |
8810 | if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { | - |
8811 | if (k->key() == Qt::Key_Backtab | - |
8812 | || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier))) | - |
8813 | res = focusNextPrevChild(false); | - |
8814 | else if (k->key() == Qt::Key_Tab) | - |
8815 | res = focusNextPrevChild(true); | - |
8816 | if (res) | - |
8817 | break; | - |
8818 | } | - |
8819 | keyPressEvent(k); | - |
8820 | #ifdef QT_KEYPAD_NAVIGATION | - |
8821 | if (!k->isAccepted() && QApplication::keypadNavigationEnabled() | - |
8822 | && !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::ShiftModifier))) { | - |
8823 | if (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder) { | - |
8824 | if (k->key() == Qt::Key_Up) | - |
8825 | res = focusNextPrevChild(false); | - |
8826 | else if (k->key() == Qt::Key_Down) | - |
8827 | res = focusNextPrevChild(true); | - |
8828 | } else if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) { | - |
8829 | if (k->key() == Qt::Key_Up) | - |
8830 | res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionNorth); | - |
8831 | else if (k->key() == Qt::Key_Right) | - |
8832 | res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionEast); | - |
8833 | else if (k->key() == Qt::Key_Down) | - |
8834 | res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionSouth); | - |
8835 | else if (k->key() == Qt::Key_Left) | - |
8836 | res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionWest); | - |
8837 | } | - |
8838 | if (res) { | - |
8839 | k->accept(); | - |
8840 | break; | - |
8841 | } | - |
8842 | } | - |
8843 | #endif | - |
8844 | #ifndef QT_NO_WHATSTHIS | - |
8845 | if (!k->isAccepted() | - |
8846 | && k->modifiers() & Qt::ShiftModifier && k->key() == Qt::Key_F1 | - |
8847 | && d->whatsThis.size()) { | - |
8848 | QWhatsThis::showText(mapToGlobal(inputMethodQuery(Qt::ImCursorRectangle).toRect().center()), d->whatsThis, this); | - |
8849 | k->accept(); | - |
8850 | } | - |
8851 | #endif | - |
8852 | } | - |
8853 | break; | - |
8854 | | - |
8855 | case QEvent::KeyRelease: | - |
8856 | keyReleaseEvent((QKeyEvent*)event); | - |
8857 | | - |
8858 | case QEvent::ShortcutOverride: | - |
8859 | break; | - |
8860 | | - |
8861 | case QEvent::InputMethod: | - |
8862 | inputMethodEvent((QInputMethodEvent *) event); | - |
8863 | break; | - |
8864 | | - |
8865 | case QEvent::InputMethodQuery: | - |
8866 | if (testAttribute(Qt::WA_InputMethodEnabled)) { | - |
8867 | QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(event); | - |
8868 | Qt::InputMethodQueries queries = query->queries(); | - |
8869 | for (uint i = 0; i < 32; ++i) { | - |
8870 | Qt::InputMethodQuery q = (Qt::InputMethodQuery)(int)(queries & (1<<i)); | - |
8871 | if (q) { | - |
8872 | QVariant v = inputMethodQuery(q); | - |
8873 | if (q == Qt::ImEnabled && !v.isValid() && isEnabled()) | - |
8874 | v = QVariant(true); | - |
8875 | query->setValue(q, v); | - |
8876 | } | - |
8877 | } | - |
8878 | query->accept(); | - |
8879 | } | - |
8880 | break; | - |
8881 | | - |
8882 | case QEvent::PolishRequest: | - |
8883 | ensurePolished(); | - |
8884 | break; | - |
8885 | | - |
8886 | case QEvent::Polish: { | - |
8887 | style()->polish(this); | - |
8888 | setAttribute(Qt::WA_WState_Polished); | - |
8889 | if (!QApplication::font(this).isCopyOf(QApplication::font())) | - |
8890 | d->resolveFont(); | - |
8891 | if (!QApplication::palette(this).isCopyOf(QApplication::palette())) | - |
8892 | d->resolvePalette(); | - |
8893 | } | - |
8894 | break; | - |
8895 | | - |
8896 | case QEvent::ApplicationWindowIconChange: | - |
8897 | if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon)) { | - |
8898 | d->setWindowIcon_sys(); | - |
8899 | d->setWindowIcon_helper(); | - |
8900 | } | - |
8901 | break; | - |
8902 | case QEvent::FocusIn: | - |
8903 | focusInEvent((QFocusEvent*)event); | - |
8904 | d->updateWidgetTransform(event); | - |
8905 | break; | - |
8906 | | - |
8907 | case QEvent::FocusOut: | - |
8908 | focusOutEvent((QFocusEvent*)event); | - |
8909 | break; | - |
8910 | | - |
8911 | case QEvent::Enter: | - |
8912 | #ifndef QT_NO_STATUSTIP | - |
8913 | if (d->statusTip.size()) { | - |
8914 | QStatusTipEvent tip(d->statusTip); | - |
8915 | QApplication::sendEvent(const_cast<QWidget *>(this), &tip); | - |
8916 | } | - |
8917 | #endif | - |
8918 | enterEvent(event); | - |
8919 | break; | - |
8920 | | - |
8921 | case QEvent::Leave: | - |
8922 | #ifndef QT_NO_STATUSTIP | - |
8923 | if (d->statusTip.size()) { | - |
8924 | QString empty; | - |
8925 | QStatusTipEvent tip(empty); | - |
8926 | QApplication::sendEvent(const_cast<QWidget *>(this), &tip); | - |
8927 | } | - |
8928 | #endif | - |
8929 | leaveEvent(event); | - |
8930 | break; | - |
8931 | | - |
8932 | case QEvent::HoverEnter: | - |
8933 | case QEvent::HoverLeave: | - |
8934 | update(); | - |
8935 | break; | - |
8936 | | - |
8937 | case QEvent::Paint: | - |
8938 | | - |
8939 | | - |
8940 | | - |
8941 | paintEvent((QPaintEvent*)event); | - |
8942 | break; | - |
8943 | | - |
8944 | case QEvent::Move: | - |
8945 | moveEvent((QMoveEvent*)event); | - |
8946 | d->updateWidgetTransform(event); | - |
8947 | break; | - |
8948 | | - |
8949 | case QEvent::Resize: | - |
8950 | resizeEvent((QResizeEvent*)event); | - |
8951 | d->updateWidgetTransform(event); | - |
8952 | break; | - |
8953 | | - |
8954 | case QEvent::Close: | - |
8955 | closeEvent((QCloseEvent *)event); | - |
8956 | break; | - |
8957 | | - |
8958 | #ifndef QT_NO_CONTEXTMENU | - |
8959 | case QEvent::ContextMenu: | - |
8960 | switch (data->context_menu_policy) { | - |
8961 | case Qt::PreventContextMenu: | - |
8962 | break; | - |
8963 | case Qt::DefaultContextMenu: | - |
8964 | contextMenuEvent(static_cast<QContextMenuEvent *>(event)); | - |
8965 | break; | - |
8966 | case Qt::CustomContextMenu: | - |
8967 | emit customContextMenuRequested(static_cast<QContextMenuEvent *>(event)->pos()); | - |
8968 | break; | - |
8969 | #ifndef QT_NO_MENU | - |
8970 | case Qt::ActionsContextMenu: | - |
8971 | if (d->actions.count()) { | - |
8972 | QMenu::exec(d->actions, static_cast<QContextMenuEvent *>(event)->globalPos(), | - |
8973 | 0, this); | - |
8974 | break; | - |
8975 | } | - |
8976 | | - |
8977 | #endif | - |
8978 | default: | - |
8979 | event->ignore(); | - |
8980 | break; | - |
8981 | } | - |
8982 | break; | - |
8983 | #endif // QT_NO_CONTEXTMENU | - |
8984 | | - |
8985 | #ifndef QT_NO_DRAGANDDROP | - |
8986 | case QEvent::Drop: | - |
8987 | dropEvent((QDropEvent*) event); | - |
8988 | break; | - |
8989 | | - |
8990 | case QEvent::DragEnter: | - |
8991 | dragEnterEvent((QDragEnterEvent*) event); | - |
8992 | break; | - |
8993 | | - |
8994 | case QEvent::DragMove: | - |
8995 | dragMoveEvent((QDragMoveEvent*) event); | - |
8996 | break; | - |
8997 | | - |
8998 | case QEvent::DragLeave: | - |
8999 | dragLeaveEvent((QDragLeaveEvent*) event); | - |
9000 | break; | - |
9001 | #endif | - |
9002 | | - |
9003 | case QEvent::Show: | - |
9004 | showEvent((QShowEvent*) event); | - |
9005 | break; | - |
9006 | | - |
9007 | case QEvent::Hide: | - |
9008 | hideEvent((QHideEvent*) event); | - |
9009 | break; | - |
9010 | | - |
9011 | case QEvent::ShowWindowRequest: | - |
9012 | if (!isHidden()) | - |
9013 | d->show_sys(); | - |
9014 | break; | - |
9015 | | - |
9016 | case QEvent::ApplicationFontChange: | - |
9017 | d->resolveFont(); | - |
9018 | break; | - |
9019 | case QEvent::ApplicationPaletteChange: | - |
9020 | if (!(windowType() == Qt::Desktop)) | - |
9021 | d->resolvePalette(); | - |
9022 | break; | - |
9023 | | - |
9024 | case QEvent::ToolBarChange: | - |
9025 | case QEvent::ActivationChange: | - |
9026 | case QEvent::EnabledChange: | - |
9027 | case QEvent::FontChange: | - |
9028 | case QEvent::StyleChange: | - |
9029 | case QEvent::PaletteChange: | - |
9030 | case QEvent::WindowTitleChange: | - |
9031 | case QEvent::IconTextChange: | - |
9032 | case QEvent::ModifiedChange: | - |
9033 | case QEvent::MouseTrackingChange: | - |
9034 | case QEvent::ParentChange: | - |
9035 | case QEvent::LocaleChange: | - |
9036 | case QEvent::MacSizeChange: | - |
9037 | case QEvent::ContentsRectChange: | - |
9038 | case QEvent::ThemeChange: | - |
9039 | case QEvent::ReadOnlyChange: | - |
9040 | changeEvent(event); | - |
9041 | break; | - |
9042 | | - |
9043 | case QEvent::WindowStateChange: { | - |
9044 | const bool wasMinimized = static_cast<const QWindowStateChangeEvent *>(event)->oldState() & Qt::WindowMinimized; | - |
9045 | if (wasMinimized != isMinimized()) { | - |
9046 | QWidget *widget = const_cast<QWidget *>(this); | - |
9047 | if (wasMinimized) { | - |
9048 | | - |
9049 | if (!d->childrenShownByExpose) { | - |
9050 | | - |
9051 | d->showChildren(true); | - |
9052 | QShowEvent showEvent; | - |
9053 | QCoreApplication::sendSpontaneousEvent(widget, &showEvent); | - |
9054 | } | - |
9055 | d->childrenHiddenByWState = false; | - |
9056 | } else { | - |
9057 | QHideEvent hideEvent; | - |
9058 | QCoreApplication::sendSpontaneousEvent(widget, &hideEvent); | - |
9059 | d->hideChildren(true); | - |
9060 | d->childrenHiddenByWState = true; | - |
9061 | } | - |
9062 | d->childrenShownByExpose = false; | - |
9063 | } | - |
9064 | changeEvent(event); | - |
9065 | } | - |
9066 | break; | - |
9067 | | - |
9068 | case QEvent::WindowActivate: | - |
9069 | case QEvent::WindowDeactivate: { | - |
9070 | if (isVisible() && !palette().isEqual(QPalette::Active, QPalette::Inactive)) | - |
9071 | update(); | - |
9072 | QList<QObject*> childList = d->children; | - |
9073 | for (int i = 0; i < childList.size(); ++i) { | - |
9074 | QWidget *w = qobject_cast<QWidget *>(childList.at(i)); | - |
9075 | if (w && w->isVisible() && !w->isWindow()) | - |
9076 | QApplication::sendEvent(w, event); | - |
9077 | } | - |
9078 | break; } | - |
9079 | | - |
9080 | case QEvent::LanguageChange: | - |
9081 | changeEvent(event); | - |
9082 | { | - |
9083 | QList<QObject*> childList = d->children; | - |
9084 | for (int i = 0; i < childList.size(); ++i) { | - |
9085 | QObject *o = childList.at(i); | - |
9086 | if (o) | - |
9087 | QApplication::sendEvent(o, event); | - |
9088 | } | - |
9089 | } | - |
9090 | update(); | - |
9091 | break; | - |
9092 | | - |
9093 | case QEvent::ApplicationLayoutDirectionChange: | - |
9094 | d->resolveLayoutDirection(); | - |
9095 | break; | - |
9096 | | - |
9097 | case QEvent::LayoutDirectionChange: | - |
9098 | if (d->layout) | - |
9099 | d->layout->invalidate(); | - |
9100 | update(); | - |
9101 | changeEvent(event); | - |
9102 | break; | - |
9103 | case QEvent::UpdateRequest: | - |
9104 | d->syncBackingStore(); | - |
9105 | break; | - |
9106 | case QEvent::UpdateLater: | - |
9107 | update(static_cast<QUpdateLaterEvent*>(event)->region()); | - |
9108 | break; | - |
9109 | case QEvent::StyleAnimationUpdate: | - |
9110 | if (isVisible() && !window()->isMinimized()) { | - |
9111 | event->accept(); | - |
9112 | update(); | - |
9113 | } | - |
9114 | break; | - |
9115 | | - |
9116 | case QEvent::WindowBlocked: | - |
9117 | case QEvent::WindowUnblocked: | - |
9118 | if (!d->children.isEmpty()) { | - |
9119 | QWidget *modalWidget = QApplication::activeModalWidget(); | - |
9120 | for (int i = 0; i < d->children.size(); ++i) { | - |
9121 | QObject *o = d->children.at(i); | - |
9122 | if (o && o != modalWidget && o->isWidgetType()) { | - |
9123 | QWidget *w = static_cast<QWidget *>(o); | - |
9124 | | - |
9125 | if (!w->isWindow()) | - |
9126 | QApplication::sendEvent(w, event); | - |
9127 | } | - |
9128 | } | - |
9129 | } | - |
9130 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - |
9131 | setDisabledStyle(this, (event->type() == QEvent::WindowBlocked)); | - |
9132 | #endif | - |
9133 | break; | - |
9134 | #ifndef QT_NO_TOOLTIP | - |
9135 | case QEvent::ToolTip: | - |
9136 | if (!d->toolTip.isEmpty()) | - |
9137 | QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip, this, QRect(), d->toolTipDuration); | - |
9138 | else | - |
9139 | event->ignore(); | - |
9140 | break; | - |
9141 | #endif | - |
9142 | #ifndef QT_NO_WHATSTHIS | - |
9143 | case QEvent::WhatsThis: | - |
9144 | if (d->whatsThis.size()) | - |
9145 | QWhatsThis::showText(static_cast<QHelpEvent *>(event)->globalPos(), d->whatsThis, this); | - |
9146 | else | - |
9147 | event->ignore(); | - |
9148 | break; | - |
9149 | case QEvent::QueryWhatsThis: | - |
9150 | if (d->whatsThis.isEmpty()) | - |
9151 | event->ignore(); | - |
9152 | break; | - |
9153 | #endif | - |
9154 | case QEvent::EmbeddingControl: | - |
9155 | d->topData()->frameStrut.setCoords(0 ,0, 0, 0); | - |
9156 | data->fstrut_dirty = false; | - |
9157 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_X11) | - |
9158 | d->topData()->embedded = 1; | - |
9159 | #endif | - |
9160 | break; | - |
9161 | #ifndef QT_NO_ACTION | - |
9162 | case QEvent::ActionAdded: | - |
9163 | case QEvent::ActionRemoved: | - |
9164 | case QEvent::ActionChanged: | - |
9165 | actionEvent((QActionEvent*)event); | - |
9166 | break; | - |
9167 | #endif | - |
9168 | | - |
9169 | case QEvent::KeyboardLayoutChange: | - |
9170 | { | - |
9171 | changeEvent(event); | - |
9172 | | - |
9173 | | - |
9174 | QList<QObject*> childList = d->children; | - |
9175 | for (int i = 0; i < childList.size(); ++i) { | - |
9176 | QWidget *w = qobject_cast<QWidget *>(childList.at(i)); | - |
9177 | if (w && w->isVisible() && !w->isWindow()) | - |
9178 | QApplication::sendEvent(w, event); | - |
9179 | } | - |
9180 | break; | - |
9181 | } | - |
9182 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
9183 | case QEvent::MacGLWindowChange: | - |
9184 | d->needWindowChange = false; | - |
9185 | break; | - |
9186 | #endif | - |
9187 | case QEvent::TouchBegin: | - |
9188 | case QEvent::TouchUpdate: | - |
9189 | case QEvent::TouchEnd: | - |
9190 | case QEvent::TouchCancel: | - |
9191 | { | - |
9192 | event->ignore(); | - |
9193 | break; | - |
9194 | } | - |
9195 | #ifndef QT_NO_GESTURES | - |
9196 | case QEvent::Gesture: | - |
9197 | event->ignore(); | - |
9198 | break; | - |
9199 | #endif | - |
9200 | case QEvent::ScreenChangeInternal: | - |
9201 | if (const QTLWExtra *te = d->maybeTopData()) { | - |
9202 | const QWindow *win = te->window; | - |
9203 | d->setWinId((win && win->handle()) ? win->handle()->winId() : 0); | - |
9204 | } | - |
9205 | #ifndef QT_NO_OPENGL | - |
9206 | d->renderToTextureReallyDirty = 1; | - |
9207 | #endif | - |
9208 | break; | - |
9209 | #ifndef QT_NO_PROPERTIES | - |
9210 | case QEvent::DynamicPropertyChange: { | - |
9211 | const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName(); | - |
9212 | if (propName.length() == 13 && !qstrncmp(propName, "_q_customDpi", 12)) { | - |
9213 | uint value = property(propName.constData()).toUInt(); | - |
9214 | if (!d->extra) | - |
9215 | d->createExtra(); | - |
9216 | const char axis = propName.at(12); | - |
9217 | if (axis == 'X') | - |
9218 | d->extra->customDpiX = value; | - |
9219 | else if (axis == 'Y') | - |
9220 | d->extra->customDpiY = value; | - |
9221 | d->updateFont(d->data.fnt); | - |
9222 | } | - |
9223 | if (windowHandle() && !qstrncmp(propName, "_q_platform_", 12)) | - |
9224 | windowHandle()->setProperty(propName, property(propName)); | - |
9225 | | - |
9226 | } | - |
9227 | #endif | - |
9228 | default: | - |
9229 | return QObject::event(event); | - |
9230 | } | - |
9231 | return true; | - |
9232 | } | - |
9233 | | - |
9234 | | - |
9235 | | - |
9236 | | - |
9237 | | - |
9238 | | - |
9239 | | - |
9240 | | - |
9241 | | - |
9242 | | - |
9243 | | - |
9244 | | - |
9245 | | - |
9246 | | - |
9247 | | - |
9248 | | - |
9249 | | - |
9250 | void QWidget::changeEvent(QEvent * event) | - |
9251 | { | - |
9252 | switch(event->type()) { | - |
9253 | case QEvent::EnabledChange: { | - |
9254 | update(); | - |
9255 | #ifndef QT_NO_ACCESSIBILITY | - |
9256 | QAccessible::State s; | - |
9257 | s.disabled = true; | - |
9258 | QAccessibleStateChangeEvent event(this, s); | - |
9259 | QAccessible::updateAccessibility(&event); | - |
9260 | #endif | - |
9261 | break; | - |
9262 | } | - |
9263 | | - |
9264 | case QEvent::FontChange: | - |
9265 | case QEvent::StyleChange: { | - |
9266 | Q_D(QWidget); | - |
9267 | update(); | - |
9268 | updateGeometry(); | - |
9269 | if (d->layout) | - |
9270 | d->layout->invalidate(); | - |
9271 | break; | - |
9272 | } | - |
9273 | | - |
9274 | case QEvent::PaletteChange: | - |
9275 | update(); | - |
9276 | break; | - |
9277 | | - |
9278 | case QEvent::ThemeChange: | - |
9279 | if (QApplication::desktopSettingsAware() && windowType() != Qt::Desktop | - |
9280 | && qApp && !QApplication::closingDown()) { | - |
9281 | if (testAttribute(Qt::WA_WState_Polished)) | - |
9282 | QApplication::style()->unpolish(this); | - |
9283 | if (testAttribute(Qt::WA_WState_Polished)) | - |
9284 | QApplication::style()->polish(this); | - |
9285 | QEvent styleChangedEvent(QEvent::StyleChange); | - |
9286 | QCoreApplication::sendEvent(this, &styleChangedEvent); | - |
9287 | if (isVisible()) | - |
9288 | update(); | - |
9289 | } | - |
9290 | break; | - |
9291 | | - |
9292 | #ifdef Q_OS_MAC | - |
9293 | case QEvent::MacSizeChange: | - |
9294 | updateGeometry(); | - |
9295 | break; | - |
9296 | #elif defined Q_DEAD_CODE_FROM_QT4_MAC | - |
9297 | case QEvent::ToolTipChange: | - |
9298 | case QEvent::MouseTrackingChange: | - |
9299 | qt_mac_update_mouseTracking(this); | - |
9300 | break; | - |
9301 | #endif | - |
9302 | | - |
9303 | default: | - |
9304 | break; | - |
9305 | } | - |
9306 | } | - |
9307 | | - |
9308 | | - |
9309 | | - |
9310 | | - |
9311 | | - |
9312 | | - |
9313 | | - |
9314 | | - |
9315 | | - |
9316 | | - |
9317 | | - |
9318 | | - |
9319 | | - |
9320 | | - |
9321 | | - |
9322 | | - |
9323 | | - |
9324 | | - |
9325 | | - |
9326 | | - |
9327 | | - |
9328 | | - |
9329 | | - |
9330 | | - |
9331 | | - |
9332 | | - |
9333 | | - |
9334 | void QWidget::mouseMoveEvent(QMouseEvent *event) | - |
9335 | { | - |
9336 | event->ignore(); | - |
9337 | } | - |
9338 | | - |
9339 | | - |
9340 | | - |
9341 | | - |
9342 | | - |
9343 | | - |
9344 | | - |
9345 | | - |
9346 | | - |
9347 | | - |
9348 | | - |
9349 | | - |
9350 | | - |
9351 | | - |
9352 | | - |
9353 | | - |
9354 | | - |
9355 | | - |
9356 | void QWidget::mousePressEvent(QMouseEvent *event) | - |
9357 | { | - |
9358 | event->ignore(); | - |
9359 | if ((windowType() == Qt::Popup)) { | - |
9360 | event->accept(); | - |
9361 | QWidget* w; | - |
9362 | while ((w = QApplication::activePopupWidget()) && w != this){ | - |
9363 | w->close(); | - |
9364 | if (QApplication::activePopupWidget() == w) | - |
9365 | w->hide(); | - |
9366 | } | - |
9367 | if (!rect().contains(event->pos())){ | - |
9368 | close(); | - |
9369 | } | - |
9370 | } | - |
9371 | } | - |
9372 | | - |
9373 | | - |
9374 | | - |
9375 | | - |
9376 | | - |
9377 | | - |
9378 | | - |
9379 | | - |
9380 | | - |
9381 | void QWidget::mouseReleaseEvent(QMouseEvent *event) | - |
9382 | { | - |
9383 | event->ignore(); | - |
9384 | } | - |
9385 | | - |
9386 | | - |
9387 | | - |
9388 | | - |
9389 | | - |
9390 | | - |
9391 | | - |
9392 | | - |
9393 | | - |
9394 | | - |
9395 | | - |
9396 | | - |
9397 | | - |
9398 | | - |
9399 | | - |
9400 | | - |
9401 | void QWidget::mouseDoubleClickEvent(QMouseEvent *event) | - |
9402 | { | - |
9403 | mousePressEvent(event); | - |
9404 | } | - |
9405 | | - |
9406 | #ifndef QT_NO_WHEELEVENT | - |
9407 | | - |
9408 | | - |
9409 | | - |
9410 | | - |
9411 | | - |
9412 | | - |
9413 | | - |
9414 | | - |
9415 | | - |
9416 | | - |
9417 | | - |
9418 | | - |
9419 | | - |
9420 | | - |
9421 | void QWidget::wheelEvent(QWheelEvent *event) | - |
9422 | { | - |
9423 | event->ignore(); | - |
9424 | } | - |
9425 | #endif // QT_NO_WHEELEVENT | - |
9426 | | - |
9427 | #ifndef QT_NO_TABLETEVENT | - |
9428 | | - |
9429 | | - |
9430 | | - |
9431 | | - |
9432 | | - |
9433 | | - |
9434 | | - |
9435 | | - |
9436 | | - |
9437 | | - |
9438 | | - |
9439 | | - |
9440 | | - |
9441 | | - |
9442 | void QWidget::tabletEvent(QTabletEvent *event) | - |
9443 | { | - |
9444 | event->ignore(); | - |
9445 | } | - |
9446 | #endif // QT_NO_TABLETEVENT | - |
9447 | | - |
9448 | | - |
9449 | | - |
9450 | | - |
9451 | | - |
9452 | | - |
9453 | | - |
9454 | | - |
9455 | | - |
9456 | | - |
9457 | | - |
9458 | | - |
9459 | | - |
9460 | | - |
9461 | | - |
9462 | | - |
9463 | | - |
9464 | | - |
9465 | | - |
9466 | | - |
9467 | | - |
9468 | | - |
9469 | | - |
9470 | | - |
9471 | void QWidget::keyPressEvent(QKeyEvent *event) | - |
9472 | { | - |
9473 | if ((windowType() == Qt::Popup) && event->matches(QKeySequence::Cancel)) { | - |
9474 | event->accept(); | - |
9475 | close(); | - |
9476 | } else { | - |
9477 | event->ignore(); | - |
9478 | } | - |
9479 | } | - |
9480 | | - |
9481 | | - |
9482 | | - |
9483 | | - |
9484 | | - |
9485 | | - |
9486 | | - |
9487 | | - |
9488 | | - |
9489 | | - |
9490 | | - |
9491 | | - |
9492 | | - |
9493 | | - |
9494 | | - |
9495 | | - |
9496 | | - |
9497 | | - |
9498 | | - |
9499 | | - |
9500 | | - |
9501 | | - |
9502 | | - |
9503 | void QWidget::keyReleaseEvent(QKeyEvent *event) | - |
9504 | { | - |
9505 | event->ignore(); | - |
9506 | } | - |
9507 | | - |
9508 | | - |
9509 | | - |
9510 | | - |
9511 | | - |
9512 | | - |
9513 | | - |
9514 | | - |
9515 | | - |
9516 | | - |
9517 | | - |
9518 | | - |
9519 | | - |
9520 | | - |
9521 | | - |
9522 | | - |
9523 | | - |
9524 | | - |
9525 | | - |
9526 | | - |
9527 | void QWidget::focusInEvent(QFocusEvent *) | - |
9528 | { | - |
9529 | if (focusPolicy() != Qt::NoFocus || !isWindow()) { | - |
9530 | update(); | - |
9531 | } | - |
9532 | } | - |
9533 | | - |
9534 | | - |
9535 | | - |
9536 | | - |
9537 | | - |
9538 | | - |
9539 | | - |
9540 | | - |
9541 | | - |
9542 | | - |
9543 | | - |
9544 | | - |
9545 | | - |
9546 | | - |
9547 | | - |
9548 | | - |
9549 | | - |
9550 | | - |
9551 | | - |
9552 | | - |
9553 | void QWidget::focusOutEvent(QFocusEvent *) | - |
9554 | { | - |
9555 | if (focusPolicy() != Qt::NoFocus || !isWindow()) | - |
9556 | update(); | - |
9557 | | - |
9558 | #ifndef Q_OS_IOS | - |
9559 | | - |
9560 | if (qApp->autoSipEnabled() && testAttribute(Qt::WA_InputMethodEnabled)) | - |
9561 | QGuiApplication::inputMethod()->hide(); | - |
9562 | #endif | - |
9563 | } | - |
9564 | | - |
9565 | | - |
9566 | | - |
9567 | | - |
9568 | | - |
9569 | | - |
9570 | | - |
9571 | | - |
9572 | | - |
9573 | | - |
9574 | | - |
9575 | | - |
9576 | | - |
9577 | void QWidget::enterEvent(QEvent *) | - |
9578 | { | - |
9579 | } | - |
9580 | | - |
9581 | | - |
9582 | | - |
9583 | | - |
9584 | | - |
9585 | | - |
9586 | | - |
9587 | | - |
9588 | | - |
9589 | | - |
9590 | | - |
9591 | | - |
9592 | | - |
9593 | | - |
9594 | | - |
9595 | void QWidget::leaveEvent(QEvent *) | - |
9596 | { | - |
9597 | } | - |
9598 | | - |
9599 | | - |
9600 | | - |
9601 | | - |
9602 | | - |
9603 | | - |
9604 | | - |
9605 | | - |
9606 | | - |
9607 | | - |
9608 | | - |
9609 | | - |
9610 | | - |
9611 | | - |
9612 | | - |
9613 | | - |
9614 | | - |
9615 | | - |
9616 | | - |
9617 | | - |
9618 | | - |
9619 | | - |
9620 | | - |
9621 | | - |
9622 | | - |
9623 | | - |
9624 | | - |
9625 | | - |
9626 | | - |
9627 | | - |
9628 | | - |
9629 | | - |
9630 | | - |
9631 | | - |
9632 | | - |
9633 | | - |
9634 | | - |
9635 | | - |
9636 | | - |
9637 | | - |
9638 | | - |
9639 | | - |
9640 | | - |
9641 | | - |
9642 | | - |
9643 | | - |
9644 | | - |
9645 | | - |
9646 | | - |
9647 | void QWidget::paintEvent(QPaintEvent *) | - |
9648 | { | - |
9649 | } | - |
9650 | | - |
9651 | | - |
9652 | | - |
9653 | | - |
9654 | | - |
9655 | | - |
9656 | | - |
9657 | | - |
9658 | | - |
9659 | | - |
9660 | | - |
9661 | | - |
9662 | | - |
9663 | | - |
9664 | | - |
9665 | void QWidget::moveEvent(QMoveEvent *) | - |
9666 | { | - |
9667 | } | - |
9668 | | - |
9669 | | - |
9670 | | - |
9671 | | - |
9672 | | - |
9673 | | - |
9674 | | - |
9675 | | - |
9676 | | - |
9677 | | - |
9678 | | - |
9679 | | - |
9680 | | - |
9681 | | - |
9682 | | - |
9683 | | - |
9684 | | - |
9685 | | - |
9686 | void QWidget::resizeEvent(QResizeEvent * ) | - |
9687 | { | - |
9688 | } | - |
9689 | | - |
9690 | #ifndef QT_NO_ACTION | - |
9691 | | - |
9692 | | - |
9693 | | - |
9694 | | - |
9695 | | - |
9696 | | - |
9697 | | - |
9698 | | - |
9699 | void QWidget::actionEvent(QActionEvent *) | - |
9700 | { | - |
9701 | | - |
9702 | } | - |
9703 | #endif | - |
9704 | | - |
9705 | | - |
9706 | | - |
9707 | | - |
9708 | | - |
9709 | | - |
9710 | | - |
9711 | | - |
9712 | | - |
9713 | | - |
9714 | | - |
9715 | | - |
9716 | | - |
9717 | | - |
9718 | | - |
9719 | | - |
9720 | | - |
9721 | | - |
9722 | | - |
9723 | | - |
9724 | | - |
9725 | void QWidget::closeEvent(QCloseEvent *event) | - |
9726 | { | - |
9727 | event->accept(); | - |
9728 | } | - |
9729 | | - |
9730 | #ifndef QT_NO_CONTEXTMENU | - |
9731 | | - |
9732 | | - |
9733 | | - |
9734 | | - |
9735 | | - |
9736 | | - |
9737 | | - |
9738 | | - |
9739 | | - |
9740 | | - |
9741 | | - |
9742 | | - |
9743 | | - |
9744 | void QWidget::contextMenuEvent(QContextMenuEvent *event) | - |
9745 | { | - |
9746 | event->ignore(); | - |
9747 | } | - |
9748 | #endif // QT_NO_CONTEXTMENU | - |
9749 | | - |
9750 | | - |
9751 | | - |
9752 | | - |
9753 | | - |
9754 | | - |
9755 | | - |
9756 | | - |
9757 | | - |
9758 | | - |
9759 | | - |
9760 | | - |
9761 | | - |
9762 | | - |
9763 | | - |
9764 | | - |
9765 | | - |
9766 | | - |
9767 | void QWidget::inputMethodEvent(QInputMethodEvent *event) | - |
9768 | { | - |
9769 | event->ignore(); | - |
9770 | } | - |
9771 | | - |
9772 | | - |
9773 | | - |
9774 | | - |
9775 | | - |
9776 | | - |
9777 | | - |
9778 | | - |
9779 | | - |
9780 | | - |
9781 | | - |
9782 | QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const | - |
9783 | { | - |
9784 | switch(query) { | - |
9785 | case Qt::ImCursorRectangle: never executed: case Qt::ImCursorRectangle: | 0 |
9786 | return QRect(width()/2, 0, 1, height()); never executed: return QRect(width()/2, 0, 1, height()); | 0 |
9787 | case Qt::ImFont: never executed: case Qt::ImFont: | 0 |
9788 | return font(); never executed: return font(); | 0 |
9789 | case Qt::ImAnchorPosition: never executed: case Qt::ImAnchorPosition: | 0 |
9790 | | - |
9791 | return inputMethodQuery(Qt::ImCursorPosition); never executed: return inputMethodQuery(Qt::ImCursorPosition); | 0 |
9792 | case Qt::ImHints: never executed: case Qt::ImHints: | 0 |
9793 | return (int)inputMethodHints(); never executed: return (int)inputMethodHints(); | 0 |
9794 | case Qt::ImInputItemClipRectangle: never executed: case Qt::ImInputItemClipRectangle: | 0 |
9795 | return d_func()->clipRect never executed: return d_func()->clipRect(); ();never executed: return d_func()->clipRect(); | 0 |
9796 | default: never executed: default: | 0 |
9797 | return QVariant(); never executed: return QVariant(); | 0 |
9798 | } | - |
9799 | } | - |
9800 | | - |
9801 | | - |
9802 | | - |
9803 | | - |
9804 | | - |
9805 | | - |
9806 | | - |
9807 | | - |
9808 | | - |
9809 | | - |
9810 | | - |
9811 | | - |
9812 | | - |
9813 | | - |
9814 | | - |
9815 | | - |
9816 | | - |
9817 | | - |
9818 | | - |
9819 | | - |
9820 | | - |
9821 | | - |
9822 | | - |
9823 | | - |
9824 | | - |
9825 | | - |
9826 | Qt::InputMethodHints QWidget::inputMethodHints() const | - |
9827 | { | - |
9828 | #ifndef QT_NO_IM | - |
9829 | const QWidgetPrivate *priv = d_func(); | - |
9830 | while (priv->inheritsInputMethodHints) { | - |
9831 | priv = priv->q_func()->parentWidget()->d_func(); | - |
9832 | Q_ASSERT(priv); | - |
9833 | } | - |
9834 | return priv->imHints; | - |
9835 | #else //QT_NO_IM | - |
9836 | return 0; | - |
9837 | #endif //QT_NO_IM | - |
9838 | } | - |
9839 | | - |
9840 | void QWidget::setInputMethodHints(Qt::InputMethodHints hints) | - |
9841 | { | - |
9842 | #ifndef QT_NO_IM | - |
9843 | Q_D(QWidget); | - |
9844 | if (d->imHints == hints) | - |
9845 | return; | - |
9846 | d->imHints = hints; | - |
9847 | if (this == QGuiApplication::focusObject()) | - |
9848 | QGuiApplication::inputMethod()->update(Qt::ImHints); | - |
9849 | #else | - |
9850 | Q_UNUSED(hints); | - |
9851 | #endif //QT_NO_IM | - |
9852 | } | - |
9853 | | - |
9854 | | - |
9855 | #ifndef QT_NO_DRAGANDDROP | - |
9856 | | - |
9857 | | - |
9858 | | - |
9859 | | - |
9860 | | - |
9861 | | - |
9862 | | - |
9863 | | - |
9864 | | - |
9865 | | - |
9866 | | - |
9867 | | - |
9868 | | - |
9869 | | - |
9870 | | - |
9871 | void QWidget::dragEnterEvent(QDragEnterEvent *) | - |
9872 | { | - |
9873 | } | - |
9874 | | - |
9875 | | - |
9876 | | - |
9877 | | - |
9878 | | - |
9879 | | - |
9880 | | - |
9881 | | - |
9882 | | - |
9883 | | - |
9884 | | - |
9885 | | - |
9886 | | - |
9887 | | - |
9888 | | - |
9889 | void QWidget::dragMoveEvent(QDragMoveEvent *) | - |
9890 | { | - |
9891 | } | - |
9892 | | - |
9893 | | - |
9894 | | - |
9895 | | - |
9896 | | - |
9897 | | - |
9898 | | - |
9899 | | - |
9900 | | - |
9901 | | - |
9902 | | - |
9903 | | - |
9904 | | - |
9905 | void QWidget::dragLeaveEvent(QDragLeaveEvent *) | - |
9906 | { | - |
9907 | } | - |
9908 | | - |
9909 | | - |
9910 | | - |
9911 | | - |
9912 | | - |
9913 | | - |
9914 | | - |
9915 | | - |
9916 | | - |
9917 | | - |
9918 | | - |
9919 | | - |
9920 | void QWidget::dropEvent(QDropEvent *) | - |
9921 | { | - |
9922 | } | - |
9923 | | - |
9924 | #endif // QT_NO_DRAGANDDROP | - |
9925 | | - |
9926 | | - |
9927 | | - |
9928 | | - |
9929 | | - |
9930 | | - |
9931 | | - |
9932 | | - |
9933 | | - |
9934 | | - |
9935 | | - |
9936 | | - |
9937 | | - |
9938 | | - |
9939 | | - |
9940 | | - |
9941 | | - |
9942 | | - |
9943 | | - |
9944 | | - |
9945 | void QWidget::showEvent(QShowEvent *) | - |
9946 | { | - |
9947 | } | - |
9948 | | - |
9949 | | - |
9950 | | - |
9951 | | - |
9952 | | - |
9953 | | - |
9954 | | - |
9955 | | - |
9956 | | - |
9957 | | - |
9958 | | - |
9959 | | - |
9960 | | - |
9961 | | - |
9962 | | - |
9963 | | - |
9964 | | - |
9965 | | - |
9966 | | - |
9967 | void QWidget::hideEvent(QHideEvent *) | - |
9968 | { | - |
9969 | } | - |
9970 | | - |
9971 | | - |
9972 | | - |
9973 | | - |
9974 | | - |
9975 | | - |
9976 | | - |
9977 | | - |
9978 | | - |
9979 | | - |
9980 | | - |
9981 | | - |
9982 | | - |
9983 | | - |
9984 | | - |
9985 | | - |
9986 | | - |
9987 | | - |
9988 | | - |
9989 | | - |
9990 | | - |
9991 | | - |
9992 | | - |
9993 | bool QWidget::nativeEvent(const QByteArray &eventType, void *message, long *result) | - |
9994 | { | - |
9995 | Q_UNUSED(eventType); | - |
9996 | Q_UNUSED(message); | - |
9997 | Q_UNUSED(result); | - |
9998 | return false; | - |
9999 | } | - |
10000 | | - |
10001 | | - |
10002 | | - |
10003 | | - |
10004 | | - |
10005 | | - |
10006 | | - |
10007 | | - |
10008 | | - |
10009 | | - |
10010 | | - |
10011 | | - |
10012 | | - |
10013 | | - |
10014 | | - |
10015 | | - |
10016 | | - |
10017 | | - |
10018 | | - |
10019 | | - |
10020 | | - |
10021 | | - |
10022 | | - |
10023 | | - |
10024 | void QWidget::ensurePolished() const | - |
10025 | { | - |
10026 | Q_D(const QWidget); | - |
10027 | | - |
10028 | const QMetaObject *m = metaObject(); | - |
10029 | if (m == d->polished) | - |
10030 | return; | - |
10031 | d->polished = m; | - |
10032 | | - |
10033 | QEvent e(QEvent::Polish); | - |
10034 | QCoreApplication::sendEvent(const_cast<QWidget *>(this), &e); | - |
10035 | | - |
10036 | | - |
10037 | QList<QObject*> children = d->children; | - |
10038 | for (int i = 0; i < children.size(); ++i) { | - |
10039 | QObject *o = children.at(i); | - |
10040 | if(!o->isWidgetType()) | - |
10041 | continue; | - |
10042 | if (QWidget *w = qobject_cast<QWidget *>(o)) | - |
10043 | w->ensurePolished(); | - |
10044 | } | - |
10045 | | - |
10046 | if (d->parent && d->sendChildEvents) { | - |
10047 | QChildEvent e(QEvent::ChildPolished, const_cast<QWidget *>(this)); | - |
10048 | QCoreApplication::sendEvent(d->parent, &e); | - |
10049 | } | - |
10050 | } | - |
10051 | | - |
10052 | | - |
10053 | | - |
10054 | | - |
10055 | | - |
10056 | | - |
10057 | | - |
10058 | QRegion QWidget::mask() const | - |
10059 | { | - |
10060 | Q_D(const QWidget); | - |
10061 | return d->extra ? d->extra->mask : QRegion(); | - |
10062 | } | - |
10063 | | - |
10064 | | - |
10065 | | - |
10066 | | - |
10067 | | - |
10068 | | - |
10069 | | - |
10070 | | - |
10071 | | - |
10072 | | - |
10073 | QLayout *QWidget::layout() const | - |
10074 | { | - |
10075 | return d_func()->layout; | - |
10076 | } | - |
10077 | | - |
10078 | | - |
10079 | | - |
10080 | | - |
10081 | | - |
10082 | | - |
10083 | | - |
10084 | | - |
10085 | | - |
10086 | | - |
10087 | | - |
10088 | | - |
10089 | | - |
10090 | | - |
10091 | | - |
10092 | | - |
10093 | | - |
10094 | | - |
10095 | | - |
10096 | | - |
10097 | | - |
10098 | | - |
10099 | | - |
10100 | | - |
10101 | | - |
10102 | | - |
10103 | | - |
10104 | void QWidget::setLayout(QLayout *l) | - |
10105 | { | - |
10106 | if (Q_UNLIKELY(!l))) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10107 | qWarning("QWidget::setLayout: Cannot set layout to 0"); | - |
10108 | return; never executed: return; | 0 |
10109 | } | - |
10110 | if (layout()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10111 | if (Q_UNLIKELY(layout() != l)))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10112 | qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a" never executed: QMessageLogger(__FILE__, 10112, __PRETTY_FUNCTION__).warning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a" " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(), objectName().toLocal8Bit().data()); | 0 |
10113 | " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(), never executed: QMessageLogger(__FILE__, 10112, __PRETTY_FUNCTION__).warning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a" " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(), objectName().toLocal8Bit().data()); | 0 |
10114 | objectName().toLocal8Bit().data()); never executed: QMessageLogger(__FILE__, 10112, __PRETTY_FUNCTION__).warning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a" " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(), objectName().toLocal8Bit().data()); | 0 |
10115 | return; never executed: return; | 0 |
10116 | } | - |
10117 | | - |
10118 | QObject *oldParent = l->parent(); | - |
10119 | if (oldParent && oldParent != this) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10120 | if (oldParent->isWidgetType()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10121 | | - |
10122 | | - |
10123 | QWidget *oldParentWidget = static_cast<QWidget *>(oldParent); | - |
10124 | oldParentWidget->takeLayout(); | - |
10125 | } else { never executed: end of block | 0 |
10126 | qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent", | - |
10127 | l->objectName().toLocal8Bit().data(), metaObject()->className(), | - |
10128 | objectName().toLocal8Bit().data()); | - |
10129 | return; never executed: return; | 0 |
10130 | } | - |
10131 | } | - |
10132 | | - |
10133 | Q_D(QWidget); | - |
10134 | l->d_func()->topLevel = true; | - |
10135 | d->layout = l; | - |
10136 | if (oldParent != this) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10137 | l->setParent(this); | - |
10138 | l->d_func()->reparentChildWidgets(this); | - |
10139 | l->invalidate(); | - |
10140 | } never executed: end of block | 0 |
10141 | | - |
10142 | if (isWindow() && d->maybeTopData())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10143 | d->topData()->sizeAdjusted = false; never executed: d->topData()->sizeAdjusted = false; | 0 |
10144 | } never executed: end of block | 0 |
10145 | | - |
10146 | | - |
10147 | | - |
10148 | | - |
10149 | | - |
10150 | | - |
10151 | | - |
10152 | | - |
10153 | QLayout *QWidget::takeLayout() | - |
10154 | { | - |
10155 | Q_D(QWidget); | - |
10156 | QLayout *l = layout(); | - |
10157 | if (!l) | - |
10158 | return 0; | - |
10159 | d->layout = 0; | - |
10160 | l->setParent(0); | - |
10161 | return l; | - |
10162 | } | - |
10163 | | - |
10164 | | - |
10165 | | - |
10166 | | - |
10167 | | - |
10168 | | - |
10169 | | - |
10170 | | - |
10171 | | - |
10172 | | - |
10173 | | - |
10174 | | - |
10175 | | - |
10176 | | - |
10177 | | - |
10178 | | - |
10179 | | - |
10180 | | - |
10181 | | - |
10182 | | - |
10183 | | - |
10184 | | - |
10185 | | - |
10186 | | - |
10187 | | - |
10188 | | - |
10189 | QSizePolicy QWidget::sizePolicy() const | - |
10190 | { | - |
10191 | Q_D(const QWidget); | - |
10192 | return d->size_policy; | - |
10193 | } | - |
10194 | | - |
10195 | void QWidget::setSizePolicy(QSizePolicy policy) | - |
10196 | { | - |
10197 | Q_D(QWidget); | - |
10198 | setAttribute(Qt::WA_WState_OwnSizePolicy); | - |
10199 | if (policy == d->size_policy) | - |
10200 | return; | - |
10201 | | - |
10202 | if (d->size_policy.retainSizeWhenHidden() != policy.retainSizeWhenHidden()) | - |
10203 | d->retainSizeWhenHiddenChanged = 1; | - |
10204 | | - |
10205 | d->size_policy = policy; | - |
10206 | | - |
10207 | #ifndef QT_NO_GRAPHICSVIEW | - |
10208 | if (QWExtra *extra = d->extra) { | - |
10209 | if (extra->proxyWidget) | - |
10210 | extra->proxyWidget->setSizePolicy(policy); | - |
10211 | } | - |
10212 | #endif | - |
10213 | | - |
10214 | updateGeometry(); | - |
10215 | d->retainSizeWhenHiddenChanged = 0; | - |
10216 | | - |
10217 | if (isWindow() && d->maybeTopData()) | - |
10218 | d->topData()->sizeAdjusted = false; | - |
10219 | } | - |
10220 | | - |
10221 | | - |
10222 | | - |
10223 | | - |
10224 | | - |
10225 | | - |
10226 | | - |
10227 | | - |
10228 | | - |
10229 | | - |
10230 | | - |
10231 | | - |
10232 | | - |
10233 | | - |
10234 | | - |
10235 | | - |
10236 | | - |
10237 | | - |
10238 | | - |
10239 | | - |
10240 | int QWidget::heightForWidth(int w) const | - |
10241 | { | - |
10242 | if (layout() && layout()->hasHeightForWidth()) | - |
10243 | return layout()->totalHeightForWidth(w); | - |
10244 | return -1; | - |
10245 | } | - |
10246 | | - |
10247 | | - |
10248 | | - |
10249 | | - |
10250 | | - |
10251 | | - |
10252 | | - |
10253 | bool QWidget::hasHeightForWidth() const | - |
10254 | { | - |
10255 | Q_D(const QWidget); | - |
10256 | return d->layout ? d->layout->hasHeightForWidth() : d->size_policy.hasHeightForWidth(); | - |
10257 | } | - |
10258 | | - |
10259 | | - |
10260 | | - |
10261 | | - |
10262 | | - |
10263 | | - |
10264 | | - |
10265 | | - |
10266 | | - |
10267 | | - |
10268 | | - |
10269 | | - |
10270 | | - |
10271 | | - |
10272 | | - |
10273 | | - |
10274 | QWidget *QWidget::childAt(const QPoint &p) const | - |
10275 | { | - |
10276 | return d_func()->childAt_helper(p, false); | - |
10277 | } | - |
10278 | | - |
10279 | QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const | - |
10280 | { | - |
10281 | if (children.isEmpty()) | - |
10282 | return 0; | - |
10283 | | - |
10284 | if (!pointInsideRectAndMask(p)) | - |
10285 | return 0; | - |
10286 | return childAtRecursiveHelper(p, ignoreChildrenInDestructor); | - |
10287 | } | - |
10288 | | - |
10289 | QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor) const | - |
10290 | { | - |
10291 | for (int i = children.size() - 1; i >= 0; --i) { | - |
10292 | QWidget *child = qobject_cast<QWidget *>(children.at(i)); | - |
10293 | if (!child || child->isWindow() || child->isHidden() || child->testAttribute(Qt::WA_TransparentForMouseEvents) | - |
10294 | || (ignoreChildrenInDestructor && child->data->in_destructor)) { | - |
10295 | continue; | - |
10296 | } | - |
10297 | | - |
10298 | | - |
10299 | QPoint childPoint = p; | - |
10300 | childPoint -= child->data->crect.topLeft(); | - |
10301 | | - |
10302 | | - |
10303 | if (!child->d_func()->pointInsideRectAndMask(childPoint)) | - |
10304 | continue; | - |
10305 | | - |
10306 | | - |
10307 | if (QWidget *w = child->d_func()->childAtRecursiveHelper(childPoint, ignoreChildrenInDestructor)) | - |
10308 | return w; | - |
10309 | | - |
10310 | | - |
10311 | return child; | - |
10312 | } | - |
10313 | return 0; | - |
10314 | } | - |
10315 | | - |
10316 | void QWidgetPrivate::updateGeometry_helper(bool forceUpdate) | - |
10317 | { | - |
10318 | Q_Q(QWidget); | - |
10319 | if (widgetItem) | - |
10320 | widgetItem->invalidateSizeCache(); | - |
10321 | QWidget *parent; | - |
10322 | if (forceUpdate || !extra || extra->minw != extra->maxw || extra->minh != extra->maxh) { | - |
10323 | const int isHidden = q->isHidden() && !size_policy.retainSizeWhenHidden() && !retainSizeWhenHiddenChanged; | - |
10324 | | - |
10325 | if (!q->isWindow() && !isHidden && (parent = q->parentWidget())) { | - |
10326 | if (parent->d_func()->layout) | - |
10327 | parent->d_func()->layout->invalidate(); | - |
10328 | else if (parent->isVisible()) | - |
10329 | QApplication::postEvent(parent, new QEvent(QEvent::LayoutRequest)); | - |
10330 | } | - |
10331 | } | - |
10332 | } | - |
10333 | | - |
10334 | | - |
10335 | | - |
10336 | | - |
10337 | | - |
10338 | | - |
10339 | | - |
10340 | | - |
10341 | | - |
10342 | | - |
10343 | | - |
10344 | void QWidget::updateGeometry() | - |
10345 | { | - |
10346 | Q_D(QWidget); | - |
10347 | d->updateGeometry_helper(false); | - |
10348 | } | - |
10349 | | - |
10350 | | - |
10351 | | - |
10352 | | - |
10353 | | - |
10354 | | - |
10355 | | - |
10356 | | - |
10357 | | - |
10358 | | - |
10359 | | - |
10360 | | - |
10361 | | - |
10362 | | - |
10363 | | - |
10364 | | - |
10365 | | - |
10366 | | - |
10367 | | - |
10368 | void QWidget::setWindowFlags(Qt::WindowFlags flags) | - |
10369 | { | - |
10370 | Q_D(QWidget); | - |
10371 | d->setWindowFlags(flags); | - |
10372 | } | - |
10373 | | - |
10374 | | - |
10375 | | - |
10376 | | - |
10377 | | - |
10378 | void QWidgetPrivate::setWindowFlags(Qt::WindowFlags flags) | - |
10379 | { | - |
10380 | Q_Q(QWidget); | - |
10381 | if (q->data->window_flags == flags) | - |
10382 | return; | - |
10383 | | - |
10384 | if ((q->data->window_flags | flags) & Qt::Window) { | - |
10385 | | - |
10386 | QPoint oldPos = q->pos(); | - |
10387 | bool visible = q->isVisible(); | - |
10388 | const bool windowFlagChanged = (q->data->window_flags ^ flags) & Qt::Window; | - |
10389 | q->setParent(q->parentWidget(), flags); | - |
10390 | | - |
10391 | | - |
10392 | | - |
10393 | if (!windowFlagChanged && (visible || q->testAttribute(Qt::WA_Moved))) | - |
10394 | q->move(oldPos); | - |
10395 | | - |
10396 | adjustQuitOnCloseAttribute(); | - |
10397 | } else { | - |
10398 | q->data->window_flags = flags; | - |
10399 | } | - |
10400 | } | - |
10401 | | - |
10402 | | - |
10403 | | - |
10404 | | - |
10405 | | - |
10406 | | - |
10407 | | - |
10408 | | - |
10409 | | - |
10410 | | - |
10411 | void QWidget::overrideWindowFlags(Qt::WindowFlags flags) | - |
10412 | { | - |
10413 | data->window_flags = flags; | - |
10414 | } | - |
10415 | | - |
10416 | | - |
10417 | | - |
10418 | | - |
10419 | | - |
10420 | | - |
10421 | | - |
10422 | | - |
10423 | | - |
10424 | | - |
10425 | | - |
10426 | | - |
10427 | | - |
10428 | | - |
10429 | | - |
10430 | | - |
10431 | | - |
10432 | | - |
10433 | | - |
10434 | | - |
10435 | | - |
10436 | | - |
10437 | | - |
10438 | | - |
10439 | | - |
10440 | | - |
10441 | | - |
10442 | | - |
10443 | | - |
10444 | | - |
10445 | | - |
10446 | | - |
10447 | | - |
10448 | | - |
10449 | | - |
10450 | | - |
10451 | | - |
10452 | | - |
10453 | void QWidget::setParent(QWidget *parent) | - |
10454 | { | - |
10455 | if (parent == parentWidget()) | - |
10456 | return; | - |
10457 | setParent((QWidget*)parent, windowFlags() & ~Qt::WindowType_Mask); | - |
10458 | } | - |
10459 | | - |
10460 | #ifndef QT_NO_OPENGL | - |
10461 | static void sendWindowChangeToTextureChildrenRecursively(QWidget *widget) | - |
10462 | { | - |
10463 | QWidgetPrivate *d = QWidgetPrivate::get(widget); | - |
10464 | if (d->renderToTexture) { | - |
10465 | QEvent e(QEvent::WindowChangeInternal); | - |
10466 | QApplication::sendEvent(widget, &e); | - |
10467 | } | - |
10468 | | - |
10469 | for (int i = 0; i < d->children.size(); ++i) { | - |
10470 | QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); | - |
10471 | if (w && !w->isWindow() && !w->isHidden() && QWidgetPrivate::get(w)->textureChildSeen) | - |
10472 | sendWindowChangeToTextureChildrenRecursively(w); | - |
10473 | } | - |
10474 | } | - |
10475 | #endif | - |
10476 | | - |
10477 | | - |
10478 | | - |
10479 | | - |
10480 | | - |
10481 | | - |
10482 | | - |
10483 | void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) | - |
10484 | { | - |
10485 | Q_D(QWidget); | - |
10486 | bool resized = testAttribute(Qt::WA_Resized); | - |
10487 | bool wasCreated = testAttribute(Qt::WA_WState_Created); | - |
10488 | QWidget *oldtlw = window(); | - |
10489 | | - |
10490 | if (f & Qt::Window) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10491 | d->data.fstrut_dirty = true; never executed: d->data.fstrut_dirty = true; | 0 |
10492 | | - |
10493 | QWidget *desktopWidget = 0; | - |
10494 | if (parent && parent->windowType() == Qt::Desktop)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10495 | desktopWidget = parent; never executed: desktopWidget = parent; | 0 |
10496 | bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget;TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10497 | | - |
10498 | if (newParent && parent && !desktopWidget) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10499 | if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10500 | parent->d_func()->enforceNativeChildren(); never executed: parent->d_func()->enforceNativeChildren(); | 0 |
10501 | else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10502 | setAttribute(Qt::WA_NativeWindow); never executed: setAttribute(Qt::WA_NativeWindow); | 0 |
10503 | } never executed: end of block | 0 |
10504 | | - |
10505 | if (wasCreated) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10506 | if (!testAttribute(Qt::WA_WState_Hidden)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10507 | hide(); | - |
10508 | setAttribute(Qt::WA_WState_ExplicitShowHide, false); | - |
10509 | } never executed: end of block | 0 |
10510 | if (newParent) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10511 | QEvent e(QEvent::ParentAboutToChange); | - |
10512 | QApplication::sendEvent(this, &e); | - |
10513 | } never executed: end of block | 0 |
10514 | } never executed: end of block | 0 |
10515 | if (newParent && isAncestorOf(focusWidget()))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10516 | focusWidget()->clearFocus(); never executed: focusWidget()->clearFocus(); | 0 |
10517 | | - |
10518 | QTLWExtra *oldTopExtra = window()->d_func()->maybeTopData(); | - |
10519 | QWidgetBackingStoreTracker *oldBsTracker = oldTopExtra ? &oldTopExtra->backingStoreTracker : 0;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10520 | | - |
10521 | d->setParent_sys(parent, f); | - |
10522 | | - |
10523 | QTLWExtra *topExtra = window()->d_func()->maybeTopData(); | - |
10524 | QWidgetBackingStoreTracker *bsTracker = topExtra ? &topExtra->backingStoreTracker : 0;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10525 | if (oldBsTracker && oldBsTracker != bsTracker)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10526 | oldBsTracker->unregisterWidgetSubtree(this); never executed: oldBsTracker->unregisterWidgetSubtree(this); | 0 |
10527 | | - |
10528 | if (desktopWidget)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10529 | parent = 0; never executed: parent = 0; | 0 |
10530 | | - |
10531 | #ifndef QT_NO_OPENGL | - |
10532 | if (d->textureChildSeen && parent) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10533 | | - |
10534 | QWidgetPrivate::get(parent)->setTextureChildSeen(); | - |
10535 | } never executed: end of block | 0 |
10536 | #endif | - |
10537 | | - |
10538 | if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10539 | if (newParent)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10540 | oldBs->removeDirtyWidget(this); never executed: oldBs->removeDirtyWidget(this); | 0 |
10541 | | - |
10542 | | - |
10543 | oldBs->moveStaticWidgets(this); | - |
10544 | } never executed: end of block | 0 |
10545 | | - |
10546 | | - |
10547 | if (QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation) && !testAttribute(Qt::WA_WState_Created))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10548 | create(); never executed: create(); | 0 |
10549 | | - |
10550 | d->reparentFocusWidgets(oldtlw); | - |
10551 | setAttribute(Qt::WA_Resized, resized); | - |
10552 | | - |
10553 | const bool useStyleSheetPropagationInWidgetStyles = | - |
10554 | QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); | - |
10555 | | - |
10556 | if (!useStyleSheetPropagationInWidgetStyles && !testAttribute(Qt::WA_StyleSheet)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10557 | && (!parent || !parent->testAttribute(Qt::WA_StyleSheet))) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10558 | d->resolveFont(); | - |
10559 | d->resolvePalette(); | - |
10560 | } never executed: end of block | 0 |
10561 | d->resolveLayoutDirection(); | - |
10562 | d->resolveLocale(); | - |
10563 | | - |
10564 | | - |
10565 | | - |
10566 | | - |
10567 | | - |
10568 | if (newParentTRUE | never evaluated | FALSE | never evaluated |
| 0 |
10569 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(QT_OPENGL_ES) | - |
10570 | || (f & Qt::MSWindowsOwnDC) | - |
10571 | #endif | - |
10572 | ) { | - |
10573 | | - |
10574 | if (!isWindow()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10575 | if (!testAttribute(Qt::WA_ForceDisabled))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10576 | d->setEnabled_helper(parent ? parent->isEnabled() : true); never executed: d->setEnabled_helper(parent ? parent->isEnabled() : true); | 0 |
10577 | if (!testAttribute(Qt::WA_ForceUpdatesDisabled))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10578 | d->setUpdatesEnabled_helper(parent ? parent->updatesEnabled() : true); never executed: d->setUpdatesEnabled_helper(parent ? parent->updatesEnabled() : true); | 0 |
10579 | } never executed: end of block | 0 |
10580 | d->inheritStyle(); | - |
10581 | | - |
10582 | | - |
10583 | if (parent && d->sendChildEvents) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10584 | QChildEvent e(QEvent::ChildAdded, this); | - |
10585 | QApplication::sendEvent(parent, &e); | - |
10586 | } never executed: end of block | 0 |
10587 | | - |
10588 | | - |
10589 | | - |
10590 | | - |
10591 | | - |
10592 | | - |
10593 | | - |
10594 | | - |
10595 | | - |
10596 | | - |
10597 | if (parent && d->sendChildEvents && d->polished) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10598 | QChildEvent e(QEvent::ChildPolished, this); | - |
10599 | QCoreApplication::sendEvent(parent, &e); | - |
10600 | } never executed: end of block | 0 |
10601 | | - |
10602 | QEvent e(QEvent::ParentChange); | - |
10603 | QApplication::sendEvent(this, &e); | - |
10604 | } never executed: end of block | 0 |
10605 | #ifndef QT_NO_OPENGL | - |
10606 | | - |
10607 | if (d->textureChildSeen && oldtlw != window()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10608 | sendWindowChangeToTextureChildrenRecursively(this); | - |
10609 | } never executed: end of block | 0 |
10610 | #endif | - |
10611 | | - |
10612 | if (!wasCreated) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10613 | if (isWindow() || parentWidget()->isVisible())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10614 | setAttribute(Qt::WA_WState_Hidden, true); never executed: setAttribute(Qt::WA_WState_Hidden, true); | 0 |
10615 | else if (!testAttribute(Qt::WA_WState_ExplicitShowHide))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10616 | setAttribute(Qt::WA_WState_Hidden, false); never executed: setAttribute(Qt::WA_WState_Hidden, false); | 0 |
10617 | } never executed: end of block | 0 |
10618 | | - |
10619 | d->updateIsOpaque(); | - |
10620 | | - |
10621 | #ifndef QT_NO_GRAPHICSVIEW | - |
10622 | | - |
10623 | | - |
10624 | if (oldtlw->graphicsProxyWidget()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10625 | if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(oldtlw))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10626 | ancestorProxy->d_func()->unembedSubWindow(this); never executed: ancestorProxy->d_func()->unembedSubWindow(this); | 0 |
10627 | } never executed: end of block | 0 |
10628 | if (isWindow() && parent && !graphicsProxyWidget() && !bypassGraphicsProxyWidget(this)) {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 |
10629 | if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(parent))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10630 | ancestorProxy->d_func()->embedSubWindow(this); never executed: ancestorProxy->d_func()->embedSubWindow(this); | 0 |
10631 | } never executed: end of block | 0 |
10632 | #endif | - |
10633 | | - |
10634 | if (d->extra && d->extra->hasWindowContainer)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
10635 | QWindowContainer::parentWasChanged(this); never executed: QWindowContainer::parentWasChanged(this); | 0 |
10636 | } never executed: end of block | 0 |
10637 | | - |
10638 | void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) | - |
10639 | { | - |
10640 | Q_Q(QWidget); | - |
10641 | | - |
10642 | Qt::WindowFlags oldFlags = data.window_flags; | - |
10643 | bool wasCreated = q->testAttribute(Qt::WA_WState_Created); | - |
10644 | | - |
10645 | int targetScreen = -1; | - |
10646 | | - |
10647 | if (newparent && newparent->windowType() == Qt::Desktop) { | - |
10648 | | - |
10649 | | - |
10650 | const QDesktopScreenWidget *sw = qobject_cast<const QDesktopScreenWidget *>(newparent); | - |
10651 | targetScreen = sw ? sw->screenNumber() : 0; | - |
10652 | newparent = 0; | - |
10653 | } | - |
10654 | | - |
10655 | setWinId(0); | - |
10656 | | - |
10657 | if (parent != newparent) { | - |
10658 | QObjectPrivate::setParent_helper(newparent); | - |
10659 | if (q->windowHandle()) { | - |
10660 | q->windowHandle()->setFlags(f); | - |
10661 | QWidget *parentWithWindow = | - |
10662 | newparent ? (newparent->windowHandle() ? newparent : newparent->nativeParentWidget()) : 0; | - |
10663 | if (parentWithWindow) { | - |
10664 | QWidget *topLevel = parentWithWindow->window(); | - |
10665 | if ((f & Qt::Window) && topLevel && topLevel->windowHandle()) { | - |
10666 | q->windowHandle()->setTransientParent(topLevel->windowHandle()); | - |
10667 | q->windowHandle()->setParent(0); | - |
10668 | } else { | - |
10669 | q->windowHandle()->setTransientParent(0); | - |
10670 | q->windowHandle()->setParent(parentWithWindow->windowHandle()); | - |
10671 | } | - |
10672 | } else { | - |
10673 | q->windowHandle()->setTransientParent(0); | - |
10674 | q->windowHandle()->setParent(0); | - |
10675 | } | - |
10676 | } | - |
10677 | } | - |
10678 | | - |
10679 | if (!newparent) { | - |
10680 | f |= Qt::Window; | - |
10681 | if (targetScreen == -1) { | - |
10682 | if (parent) | - |
10683 | targetScreen = QApplication::desktop()->screenNumber(q->parentWidget()->window()); | - |
10684 | } | - |
10685 | } | - |
10686 | | - |
10687 | bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); | - |
10688 | | - |
10689 | | - |
10690 | if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) { | - |
10691 | if (extra && extra->hasWindowContainer) | - |
10692 | QWindowContainer::toplevelAboutToBeDestroyed(q); | - |
10693 | | - |
10694 | QWindow *newParentWindow = newparent->windowHandle(); | - |
10695 | if (!newParentWindow) | - |
10696 | if (QWidget *npw = newparent->nativeParentWidget()) | - |
10697 | newParentWindow = npw->windowHandle(); | - |
10698 | | - |
10699 | Q_FOREACH (QObject *child, q->windowHandle()->children()) { | - |
10700 | QWindow *childWindow = qobject_cast<QWindow *>(child); | - |
10701 | if (!childWindow) | - |
10702 | continue; | - |
10703 | | - |
10704 | QWidgetWindow *childWW = qobject_cast<QWidgetWindow *>(childWindow); | - |
10705 | QWidget *childWidget = childWW ? childWW->widget() : 0; | - |
10706 | if (!childWW || (childWidget && childWidget->testAttribute(Qt::WA_NativeWindow))) | - |
10707 | childWindow->setParent(newParentWindow); | - |
10708 | } | - |
10709 | q->destroy(); | - |
10710 | } | - |
10711 | | - |
10712 | adjustFlags(f, q); | - |
10713 | data.window_flags = f; | - |
10714 | q->setAttribute(Qt::WA_WState_Created, false); | - |
10715 | q->setAttribute(Qt::WA_WState_Visible, false); | - |
10716 | q->setAttribute(Qt::WA_WState_Hidden, false); | - |
10717 | | - |
10718 | if (newparent && wasCreated && (q->testAttribute(Qt::WA_NativeWindow) || (f & Qt::Window))) | - |
10719 | q->createWinId(); | - |
10720 | | - |
10721 | if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden) | - |
10722 | q->setAttribute(Qt::WA_WState_Hidden); | - |
10723 | q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); | - |
10724 | | - |
10725 | | - |
10726 | if (!newparent && targetScreen != -1) { | - |
10727 | | - |
10728 | if (q->testAttribute(Qt::WA_WState_Created)) | - |
10729 | q->windowHandle()->setScreen(QGuiApplication::screens().value(targetScreen, 0)); | - |
10730 | else | - |
10731 | topData()->initialScreenIndex = targetScreen; | - |
10732 | } | - |
10733 | } | - |
10734 | | - |
10735 | | - |
10736 | | - |
10737 | | - |
10738 | | - |
10739 | | - |
10740 | | - |
10741 | | - |
10742 | | - |
10743 | | - |
10744 | | - |
10745 | | - |
10746 | | - |
10747 | | - |
10748 | | - |
10749 | | - |
10750 | | - |
10751 | | - |
10752 | | - |
10753 | | - |
10754 | | - |
10755 | | - |
10756 | void QWidget::scroll(int dx, int dy) | - |
10757 | { | - |
10758 | if ((!updatesEnabled() && children().size() == 0) || !isVisible()) | - |
10759 | return; | - |
10760 | if (dx == 0 && dy == 0) | - |
10761 | return; | - |
10762 | Q_D(QWidget); | - |
10763 | #ifndef QT_NO_GRAPHICSVIEW | - |
10764 | if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) { | - |
10765 | | - |
10766 | | - |
10767 | | - |
10768 | if (!d->dirty.isEmpty()) { | - |
10769 | foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects()) | - |
10770 | proxy->update(rect); | - |
10771 | } | - |
10772 | proxy->scroll(dx, dy, proxy->subWidgetRect(this)); | - |
10773 | return; | - |
10774 | } | - |
10775 | #endif | - |
10776 | d->setDirtyOpaqueRegion(); | - |
10777 | d->scroll_sys(dx, dy); | - |
10778 | } | - |
10779 | | - |
10780 | void QWidgetPrivate::scroll_sys(int dx, int dy) | - |
10781 | { | - |
10782 | Q_Q(QWidget); | - |
10783 | scrollChildren(dx, dy); | - |
10784 | scrollRect(q->rect(), dx, dy); | - |
10785 | } | - |
10786 | | - |
10787 | | - |
10788 | | - |
10789 | | - |
10790 | | - |
10791 | | - |
10792 | | - |
10793 | | - |
10794 | | - |
10795 | | - |
10796 | | - |
10797 | void QWidget::scroll(int dx, int dy, const QRect &r) | - |
10798 | { | - |
10799 | | - |
10800 | if ((!updatesEnabled() && children().size() == 0) || !isVisible()) | - |
10801 | return; | - |
10802 | if (dx == 0 && dy == 0) | - |
10803 | return; | - |
10804 | Q_D(QWidget); | - |
10805 | #ifndef QT_NO_GRAPHICSVIEW | - |
10806 | if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) { | - |
10807 | | - |
10808 | | - |
10809 | | - |
10810 | if (!d->dirty.isEmpty()) { | - |
10811 | foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects()) | - |
10812 | proxy->update(rect); | - |
10813 | } | - |
10814 | proxy->scroll(dx, dy, r.translated(proxy->subWidgetRect(this).topLeft().toPoint())); | - |
10815 | return; | - |
10816 | } | - |
10817 | #endif | - |
10818 | d->scroll_sys(dx, dy, r); | - |
10819 | } | - |
10820 | | - |
10821 | void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) | - |
10822 | { | - |
10823 | scrollRect(r, dx, dy); | - |
10824 | } | - |
10825 | | - |
10826 | | - |
10827 | | - |
10828 | | - |
10829 | | - |
10830 | | - |
10831 | | - |
10832 | | - |
10833 | | - |
10834 | | - |
10835 | | - |
10836 | | - |
10837 | | - |
10838 | | - |
10839 | | - |
10840 | | - |
10841 | | - |
10842 | void QWidget::repaint() | - |
10843 | { | - |
10844 | repaint(rect()); | - |
10845 | } | - |
10846 | | - |
10847 | | - |
10848 | | - |
10849 | | - |
10850 | | - |
10851 | | - |
10852 | | - |
10853 | | - |
10854 | | - |
10855 | void QWidget::repaint(int x, int y, int w, int h) | - |
10856 | { | - |
10857 | if (x > data->crect.width() || y > data->crect.height()) | - |
10858 | return; | - |
10859 | | - |
10860 | if (w < 0) | - |
10861 | w = data->crect.width() - x; | - |
10862 | if (h < 0) | - |
10863 | h = data->crect.height() - y; | - |
10864 | | - |
10865 | repaint(QRect(x, y, w, h)); | - |
10866 | } | - |
10867 | | - |
10868 | | - |
10869 | | - |
10870 | | - |
10871 | | - |
10872 | void QWidget::repaint(const QRect &rect) | - |
10873 | { | - |
10874 | Q_D(QWidget); | - |
10875 | | - |
10876 | if (testAttribute(Qt::WA_WState_ConfigPending)) { | - |
10877 | update(rect); | - |
10878 | return; | - |
10879 | } | - |
10880 | | - |
10881 | if (!isVisible() || !updatesEnabled() || rect.isEmpty()) | - |
10882 | return; | - |
10883 | | - |
10884 | if (hasBackingStoreSupport()) { | - |
10885 | QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); | - |
10886 | if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { | - |
10887 | tlwExtra->inRepaint = true; | - |
10888 | tlwExtra->backingStoreTracker->markDirty(rect, this, QWidgetBackingStore::UpdateNow); | - |
10889 | tlwExtra->inRepaint = false; | - |
10890 | } | - |
10891 | } else { | - |
10892 | d->repaint_sys(rect); | - |
10893 | } | - |
10894 | } | - |
10895 | | - |
10896 | | - |
10897 | | - |
10898 | | - |
10899 | | - |
10900 | | - |
10901 | void QWidget::repaint(const QRegion &rgn) | - |
10902 | { | - |
10903 | Q_D(QWidget); | - |
10904 | | - |
10905 | if (testAttribute(Qt::WA_WState_ConfigPending)) { | - |
10906 | update(rgn); | - |
10907 | return; | - |
10908 | } | - |
10909 | | - |
10910 | if (!isVisible() || !updatesEnabled() || rgn.isEmpty()) | - |
10911 | return; | - |
10912 | | - |
10913 | if (hasBackingStoreSupport()) { | - |
10914 | QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); | - |
10915 | if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { | - |
10916 | tlwExtra->inRepaint = true; | - |
10917 | tlwExtra->backingStoreTracker->markDirty(rgn, this, QWidgetBackingStore::UpdateNow); | - |
10918 | tlwExtra->inRepaint = false; | - |
10919 | } | - |
10920 | } else { | - |
10921 | d->repaint_sys(rgn); | - |
10922 | } | - |
10923 | } | - |
10924 | | - |
10925 | | - |
10926 | | - |
10927 | | - |
10928 | | - |
10929 | | - |
10930 | | - |
10931 | | - |
10932 | | - |
10933 | | - |
10934 | | - |
10935 | | - |
10936 | | - |
10937 | | - |
10938 | | - |
10939 | | - |
10940 | | - |
10941 | | - |
10942 | | - |
10943 | void QWidget::update() | - |
10944 | { | - |
10945 | update(rect()); | - |
10946 | } | - |
10947 | | - |
10948 | | - |
10949 | | - |
10950 | | - |
10951 | | - |
10952 | | - |
10953 | | - |
10954 | | - |
10955 | | - |
10956 | | - |
10957 | | - |
10958 | | - |
10959 | | - |
10960 | void QWidget::update(const QRect &rect) | - |
10961 | { | - |
10962 | if (!isVisible() || !updatesEnabled()) | - |
10963 | return; | - |
10964 | | - |
10965 | QRect r = rect & QWidget::rect(); | - |
10966 | | - |
10967 | if (r.isEmpty()) | - |
10968 | return; | - |
10969 | | - |
10970 | if (testAttribute(Qt::WA_WState_InPaintEvent)) { | - |
10971 | QApplication::postEvent(this, new QUpdateLaterEvent(r)); | - |
10972 | return; | - |
10973 | } | - |
10974 | | - |
10975 | if (hasBackingStoreSupport()) { | - |
10976 | QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); | - |
10977 | if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) | - |
10978 | tlwExtra->backingStoreTracker->markDirty(r, this); | - |
10979 | } else { | - |
10980 | d_func()->repaint_sys(r); | - |
10981 | } | - |
10982 | } | - |
10983 | | - |
10984 | | - |
10985 | | - |
10986 | | - |
10987 | | - |
10988 | | - |
10989 | void QWidget::update(const QRegion &rgn) | - |
10990 | { | - |
10991 | if (!isVisible() || !updatesEnabled()) | - |
10992 | return; | - |
10993 | | - |
10994 | QRegion r = rgn & QWidget::rect(); | - |
10995 | | - |
10996 | if (r.isEmpty()) | - |
10997 | return; | - |
10998 | | - |
10999 | if (testAttribute(Qt::WA_WState_InPaintEvent)) { | - |
11000 | QApplication::postEvent(this, new QUpdateLaterEvent(r)); | - |
11001 | return; | - |
11002 | } | - |
11003 | | - |
11004 | if (hasBackingStoreSupport()) { | - |
11005 | QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); | - |
11006 | if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) | - |
11007 | tlwExtra->backingStoreTracker->markDirty(r, this); | - |
11008 | } else { | - |
11009 | d_func()->repaint_sys(r); | - |
11010 | } | - |
11011 | } | - |
11012 | | - |
11013 | | - |
11014 | | - |
11015 | | - |
11016 | | - |
11017 | | - |
11018 | | - |
11019 | static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidgetData *data, | - |
11020 | QWidgetPrivate *d) | - |
11021 | { | - |
11022 | if (attribute < int(8*sizeof(uint))) { | - |
11023 | if (on) | - |
11024 | data->widget_attributes |= (1<<attribute); | - |
11025 | else | - |
11026 | data->widget_attributes &= ~(1<<attribute); | - |
11027 | } else { | - |
11028 | const int x = attribute - 8*sizeof(uint); | - |
11029 | const int int_off = x / (8*sizeof(uint)); | - |
11030 | if (on) | - |
11031 | d->high_attributes[int_off] |= (1<<(x-(int_off*8*sizeof(uint)))); | - |
11032 | else | - |
11033 | d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint)))); | - |
11034 | } | - |
11035 | } | - |
11036 | | - |
11037 | #ifdef Q_OS_MAC | - |
11038 | void QWidgetPrivate::macUpdateSizeAttribute() | - |
11039 | { | - |
11040 | Q_Q(QWidget); | - |
11041 | QEvent event(QEvent::MacSizeChange); | - |
11042 | QApplication::sendEvent(q, &event); | - |
11043 | for (int i = 0; i < children.size(); ++i) { | - |
11044 | QWidget *w = qobject_cast<QWidget *>(children.at(i)); | - |
11045 | if (w && (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation)) | - |
11046 | && !q->testAttribute(Qt::WA_MacMiniSize) | - |
11047 | && !w->testAttribute(Qt::WA_MacSmallSize) | - |
11048 | && !w->testAttribute(Qt::WA_MacNormalSize)) | - |
11049 | w->d_func()->macUpdateSizeAttribute(); | - |
11050 | } | - |
11051 | resolveFont(); | - |
11052 | } | - |
11053 | #endif | - |
11054 | | - |
11055 | | - |
11056 | | - |
11057 | | - |
11058 | | - |
11059 | | - |
11060 | | - |
11061 | void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) | - |
11062 | { | - |
11063 | if (testAttribute(attribute) == on) | - |
11064 | return; | - |
11065 | | - |
11066 | Q_D(QWidget); | - |
11067 | Q_STATIC_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8), | - |
11068 | "QWidget::setAttribute(WidgetAttribute, bool): " | - |
11069 | "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute"); | - |
11070 | #ifdef Q_OS_WIN | - |
11071 | | - |
11072 | if (attribute == Qt::WA_PaintOnScreen && on && windowType() != Qt::Desktop && !inherits("QGLWidget")) { | - |
11073 | | - |
11074 | paintEngine(); | - |
11075 | if (d->noPaintOnScreen) | - |
11076 | return; | - |
11077 | } | - |
11078 | #endif | - |
11079 | | - |
11080 | | - |
11081 | if (attribute == Qt::WA_NativeWindow && !d->mustHaveWindowHandle) { | - |
11082 | QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); | - |
11083 | if (!platformIntegration->hasCapability(QPlatformIntegration::NativeWidgets)) | - |
11084 | return; | - |
11085 | } | - |
11086 | | - |
11087 | setAttribute_internal(attribute, on, data, d); | - |
11088 | | - |
11089 | switch (attribute) { | - |
11090 | | - |
11091 | #ifndef QT_NO_DRAGANDDROP | - |
11092 | case Qt::WA_AcceptDrops: { | - |
11093 | if (on && !testAttribute(Qt::WA_DropSiteRegistered)) | - |
11094 | setAttribute(Qt::WA_DropSiteRegistered, true); | - |
11095 | else if (!on && (isWindow() || !parentWidget() || !parentWidget()->testAttribute(Qt::WA_DropSiteRegistered))) | - |
11096 | setAttribute(Qt::WA_DropSiteRegistered, false); | - |
11097 | QEvent e(QEvent::AcceptDropsChange); | - |
11098 | QApplication::sendEvent(this, &e); | - |
11099 | break; | - |
11100 | } | - |
11101 | case Qt::WA_DropSiteRegistered: { | - |
11102 | d->registerDropSite(on); | - |
11103 | for (int i = 0; i < d->children.size(); ++i) { | - |
11104 | QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); | - |
11105 | if (w && !w->isWindow() && !w->testAttribute(Qt::WA_AcceptDrops) && w->testAttribute(Qt::WA_DropSiteRegistered) != on) | - |
11106 | w->setAttribute(Qt::WA_DropSiteRegistered, on); | - |
11107 | } | - |
11108 | break; | - |
11109 | } | - |
11110 | #endif | - |
11111 | | - |
11112 | case Qt::WA_NoChildEventsForParent: | - |
11113 | d->sendChildEvents = !on; | - |
11114 | break; | - |
11115 | case Qt::WA_NoChildEventsFromChildren: | - |
11116 | d->receiveChildEvents = !on; | - |
11117 | break; | - |
11118 | case Qt::WA_MacBrushedMetal: | - |
11119 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
11120 | d->setStyle_helper(style(), false, true); | - |
11121 | | - |
11122 | case Qt::WA_MacOpaqueSizeGrip: | - |
11123 | d->macUpdateOpaqueSizeGrip(); | - |
11124 | break; | - |
11125 | case Qt::WA_MacShowFocusRect: | - |
11126 | if (hasFocus()) { | - |
11127 | clearFocus(); | - |
11128 | setFocus(); | - |
11129 | } | - |
11130 | break; | - |
11131 | case Qt::WA_Hover: | - |
11132 | qt_mac_update_mouseTracking(this); | - |
11133 | break; | - |
11134 | #endif | - |
11135 | case Qt::WA_MacAlwaysShowToolWindow: | - |
11136 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
11137 | d->macUpdateHideOnSuspend(); | - |
11138 | #endif | - |
11139 | break; | - |
11140 | case Qt::WA_MacNormalSize: | - |
11141 | case Qt::WA_MacSmallSize: | - |
11142 | case Qt::WA_MacMiniSize: | - |
11143 | #ifdef Q_OS_MAC | - |
11144 | { | - |
11145 | | - |
11146 | const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize, | - |
11147 | Qt::WA_MacMiniSize }; | - |
11148 | for (int i = 0; i < 3; ++i) { | - |
11149 | if (MacSizes[i] != attribute) | - |
11150 | setAttribute_internal(MacSizes[i], false, data, d); | - |
11151 | } | - |
11152 | d->macUpdateSizeAttribute(); | - |
11153 | } | - |
11154 | #endif | - |
11155 | break; | - |
11156 | case Qt::WA_ShowModal: | - |
11157 | if (!on) { | - |
11158 | | - |
11159 | data->window_modality = Qt::NonModal; | - |
11160 | } else if (data->window_modality == Qt::NonModal) { | - |
11161 | | - |
11162 | | - |
11163 | | - |
11164 | | - |
11165 | QWidget *w = parentWidget(); | - |
11166 | if (w) | - |
11167 | w = w->window(); | - |
11168 | while (w && !w->testAttribute(Qt::WA_GroupLeader)) { | - |
11169 | w = w->parentWidget(); | - |
11170 | if (w) | - |
11171 | w = w->window(); | - |
11172 | } | - |
11173 | data->window_modality = (w && w->testAttribute(Qt::WA_GroupLeader)) | - |
11174 | ? Qt::WindowModal | - |
11175 | : Qt::ApplicationModal; | - |
11176 | | - |
11177 | | - |
11178 | | - |
11179 | } | - |
11180 | if (testAttribute(Qt::WA_WState_Created)) { | - |
11181 | | - |
11182 | d->setModal_sys(); | - |
11183 | } | - |
11184 | break; | - |
11185 | case Qt::WA_MouseTracking: { | - |
11186 | QEvent e(QEvent::MouseTrackingChange); | - |
11187 | QApplication::sendEvent(this, &e); | - |
11188 | break; } | - |
11189 | case Qt::WA_NativeWindow: { | - |
11190 | d->createTLExtra(); | - |
11191 | if (on) | - |
11192 | d->createTLSysExtra(); | - |
11193 | #ifndef QT_NO_IM | - |
11194 | QWidget *focusWidget = d->effectiveFocusWidget(); | - |
11195 | if (on && !internalWinId() && this == QGuiApplication::focusObject() | - |
11196 | && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) { | - |
11197 | QGuiApplication::inputMethod()->commit(); | - |
11198 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); | - |
11199 | } | - |
11200 | if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()) | - |
11201 | parentWidget()->d_func()->enforceNativeChildren(); | - |
11202 | if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created)) | - |
11203 | d->createWinId(); | - |
11204 | if (isEnabled() && focusWidget->isEnabled() && this == QGuiApplication::focusObject() | - |
11205 | && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) { | - |
11206 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); | - |
11207 | } | - |
11208 | #endif //QT_NO_IM | - |
11209 | break; | - |
11210 | } | - |
11211 | case Qt::WA_PaintOnScreen: | - |
11212 | d->updateIsOpaque(); | - |
11213 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_X11) || defined(Q_DEAD_CODE_FROM_QT4_MAC) | - |
11214 | | - |
11215 | | - |
11216 | | - |
11217 | if (on) { | - |
11218 | setAttribute(Qt::WA_NativeWindow); | - |
11219 | d->enforceNativeChildren(); | - |
11220 | } | - |
11221 | #endif | - |
11222 | | - |
11223 | case Qt::WA_OpaquePaintEvent: | - |
11224 | d->updateIsOpaque(); | - |
11225 | break; | - |
11226 | case Qt::WA_NoSystemBackground: | - |
11227 | d->updateIsOpaque(); | - |
11228 | | - |
11229 | case Qt::WA_UpdatesDisabled: | - |
11230 | d->updateSystemBackground(); | - |
11231 | break; | - |
11232 | case Qt::WA_TransparentForMouseEvents: | - |
11233 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
11234 | d->macUpdateIgnoreMouseEvents(); | - |
11235 | #endif | - |
11236 | break; | - |
11237 | case Qt::WA_InputMethodEnabled: { | - |
11238 | #ifndef QT_NO_IM | - |
11239 | if (QGuiApplication::focusObject() == this) { | - |
11240 | if (!on) | - |
11241 | QGuiApplication::inputMethod()->commit(); | - |
11242 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); | - |
11243 | } | - |
11244 | #endif //QT_NO_IM | - |
11245 | break; | - |
11246 | } | - |
11247 | case Qt::WA_WindowPropagation: | - |
11248 | d->resolvePalette(); | - |
11249 | d->resolveFont(); | - |
11250 | d->resolveLocale(); | - |
11251 | break; | - |
11252 | #ifdef Q_DEAD_CODE_FROM_QT4_X11 | - |
11253 | case Qt::WA_NoX11EventCompression: | - |
11254 | if (!d->extra) | - |
11255 | d->createExtra(); | - |
11256 | d->extra->compress_events = on; | - |
11257 | break; | - |
11258 | case Qt::WA_X11OpenGLOverlay: | - |
11259 | d->updateIsOpaque(); | - |
11260 | break; | - |
11261 | case Qt::WA_X11DoNotAcceptFocus: | - |
11262 | if (testAttribute(Qt::WA_WState_Created)) | - |
11263 | d->updateX11AcceptFocus(); | - |
11264 | break; | - |
11265 | #endif | - |
11266 | case Qt::WA_DontShowOnScreen: { | - |
11267 | if (on && isVisible()) { | - |
11268 | | - |
11269 | | - |
11270 | | - |
11271 | d->hide_sys(); | - |
11272 | d->show_sys(); | - |
11273 | } | - |
11274 | break; | - |
11275 | } | - |
11276 | | - |
11277 | case Qt::WA_X11NetWmWindowTypeDesktop: | - |
11278 | case Qt::WA_X11NetWmWindowTypeDock: | - |
11279 | case Qt::WA_X11NetWmWindowTypeToolBar: | - |
11280 | case Qt::WA_X11NetWmWindowTypeMenu: | - |
11281 | case Qt::WA_X11NetWmWindowTypeUtility: | - |
11282 | case Qt::WA_X11NetWmWindowTypeSplash: | - |
11283 | case Qt::WA_X11NetWmWindowTypeDialog: | - |
11284 | case Qt::WA_X11NetWmWindowTypeDropDownMenu: | - |
11285 | case Qt::WA_X11NetWmWindowTypePopupMenu: | - |
11286 | case Qt::WA_X11NetWmWindowTypeToolTip: | - |
11287 | case Qt::WA_X11NetWmWindowTypeNotification: | - |
11288 | case Qt::WA_X11NetWmWindowTypeCombo: | - |
11289 | case Qt::WA_X11NetWmWindowTypeDND: | - |
11290 | d->setNetWmWindowTypes(); | - |
11291 | break; | - |
11292 | | - |
11293 | case Qt::WA_StaticContents: | - |
11294 | if (QWidgetBackingStore *bs = d->maybeBackingStore()) { | - |
11295 | if (on) | - |
11296 | bs->addStaticWidget(this); | - |
11297 | else | - |
11298 | bs->removeStaticWidget(this); | - |
11299 | } | - |
11300 | break; | - |
11301 | case Qt::WA_TranslucentBackground: | - |
11302 | if (on) { | - |
11303 | setAttribute(Qt::WA_NoSystemBackground); | - |
11304 | d->updateIsTranslucent(); | - |
11305 | } | - |
11306 | | - |
11307 | break; | - |
11308 | case Qt::WA_AcceptTouchEvents: | - |
11309 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_MAC) | - |
11310 | if (on) | - |
11311 | d->registerTouchWindow(); | - |
11312 | #endif | - |
11313 | break; | - |
11314 | default: | - |
11315 | break; | - |
11316 | } | - |
11317 | } | - |
11318 | | - |
11319 | | - |
11320 | | - |
11321 | | - |
11322 | | - |
11323 | | - |
11324 | | - |
11325 | | - |
11326 | bool QWidget::testAttribute_helper(Qt::WidgetAttribute attribute) const | - |
11327 | { | - |
11328 | Q_D(const QWidget); | - |
11329 | const int x = attribute - 8*sizeof(uint); | - |
11330 | const int int_off = x / (8*sizeof(uint)); | - |
11331 | return (d->high_attributes[int_off] & (1<<(x-(int_off*8*sizeof(uint))))); | - |
11332 | } | - |
11333 | | - |
11334 | | - |
11335 | | - |
11336 | | - |
11337 | | - |
11338 | | - |
11339 | | - |
11340 | | - |
11341 | | - |
11342 | | - |
11343 | | - |
11344 | | - |
11345 | | - |
11346 | | - |
11347 | | - |
11348 | | - |
11349 | | - |
11350 | | - |
11351 | | - |
11352 | | - |
11353 | | - |
11354 | | - |
11355 | | - |
11356 | | - |
11357 | | - |
11358 | | - |
11359 | qreal QWidget::windowOpacity() const | - |
11360 | { | - |
11361 | Q_D(const QWidget); | - |
11362 | return (isWindow() && d->maybeTopData()) ? d->maybeTopData()->opacity / 255. : 1.0; | - |
11363 | } | - |
11364 | | - |
11365 | void QWidget::setWindowOpacity(qreal opacity) | - |
11366 | { | - |
11367 | Q_D(QWidget); | - |
11368 | if (!isWindow()) | - |
11369 | return; | - |
11370 | | - |
11371 | opacity = qBound(qreal(0.0), opacity, qreal(1.0)); | - |
11372 | QTLWExtra *extra = d->topData(); | - |
11373 | extra->opacity = uint(opacity * 255); | - |
11374 | setAttribute(Qt::WA_WState_WindowOpacitySet); | - |
11375 | d->setWindowOpacity_sys(opacity); | - |
11376 | | - |
11377 | if (!testAttribute(Qt::WA_WState_Created)) | - |
11378 | return; | - |
11379 | | - |
11380 | #ifndef QT_NO_GRAPHICSVIEW | - |
11381 | if (QGraphicsProxyWidget *proxy = graphicsProxyWidget()) { | - |
11382 | | - |
11383 | if (proxy->cacheMode() == QGraphicsItem::NoCache) | - |
11384 | proxy->update(); | - |
11385 | else if (QGraphicsScene *scene = proxy->scene()) | - |
11386 | scene->update(proxy->sceneBoundingRect()); | - |
11387 | return; | - |
11388 | } | - |
11389 | #endif | - |
11390 | } | - |
11391 | | - |
11392 | void QWidgetPrivate::setWindowOpacity_sys(qreal level) | - |
11393 | { | - |
11394 | Q_Q(QWidget); | - |
11395 | if (q->windowHandle()) | - |
11396 | q->windowHandle()->setOpacity(level); | - |
11397 | } | - |
11398 | | - |
11399 | | - |
11400 | | - |
11401 | | - |
11402 | | - |
11403 | | - |
11404 | | - |
11405 | | - |
11406 | | - |
11407 | | - |
11408 | | - |
11409 | | - |
11410 | | - |
11411 | | - |
11412 | | - |
11413 | | - |
11414 | | - |
11415 | | - |
11416 | | - |
11417 | | - |
11418 | | - |
11419 | | - |
11420 | | - |
11421 | | - |
11422 | | - |
11423 | bool QWidget::isWindowModified() const | - |
11424 | { | - |
11425 | return testAttribute(Qt::WA_WindowModified); | - |
11426 | } | - |
11427 | | - |
11428 | void QWidget::setWindowModified(bool mod) | - |
11429 | { | - |
11430 | Q_D(QWidget); | - |
11431 | setAttribute(Qt::WA_WindowModified, mod); | - |
11432 | | - |
11433 | d->setWindowModified_helper(); | - |
11434 | | - |
11435 | QEvent e(QEvent::ModifiedChange); | - |
11436 | QApplication::sendEvent(this, &e); | - |
11437 | } | - |
11438 | | - |
11439 | void QWidgetPrivate::setWindowModified_helper() | - |
11440 | { | - |
11441 | Q_Q(QWidget); | - |
11442 | QWindow *window = q->windowHandle(); | - |
11443 | if (!window)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
11444 | return; never executed: return; | 0 |
11445 | QPlatformWindow *platformWindow = window->handle(); | - |
11446 | if (!platformWindow)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
11447 | return; never executed: return; | 0 |
11448 | bool on = q->testAttribute(Qt::WA_WindowModified); | - |
11449 | if (!platformWindow->setWindowModified(on)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
11450 | if (!(Q_UNLIKELY(on && !q->windowTitle().contains(QLatin1String("[*]")) && on)))))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
11451 | qWarning("QWidget::setWindowModified: The window title does not contain a '[*]' placeholder"); never executed: QMessageLogger(__FILE__, 11451, __PRETTY_FUNCTION__).warning("QWidget::setWindowModified: The window title does not contain a '[*]' placeholder"); | 0 |
11452 | setWindowTitle_helper(q->windowTitle()); | - |
11453 | setWindowIconText_helper(q->windowIconText()); | - |
11454 | } never executed: end of block | 0 |
11455 | } never executed: end of block | 0 |
11456 | | - |
11457 | #ifndef QT_NO_TOOLTIP | - |
11458 | | - |
11459 | | - |
11460 | | - |
11461 | | - |
11462 | | - |
11463 | | - |
11464 | | - |
11465 | | - |
11466 | | - |
11467 | | - |
11468 | | - |
11469 | | - |
11470 | | - |
11471 | | - |
11472 | | - |
11473 | | - |
11474 | | - |
11475 | | - |
11476 | void QWidget::setToolTip(const QString &s) | - |
11477 | { | - |
11478 | Q_D(QWidget); | - |
11479 | d->toolTip = s; | - |
11480 | | - |
11481 | QEvent event(QEvent::ToolTipChange); | - |
11482 | QApplication::sendEvent(this, &event); | - |
11483 | } | - |
11484 | | - |
11485 | QString QWidget::toolTip() const | - |
11486 | { | - |
11487 | Q_D(const QWidget); | - |
11488 | return d->toolTip; | - |
11489 | } | - |
11490 | | - |
11491 | | - |
11492 | | - |
11493 | | - |
11494 | | - |
11495 | | - |
11496 | | - |
11497 | | - |
11498 | | - |
11499 | | - |
11500 | | - |
11501 | | - |
11502 | void QWidget::setToolTipDuration(int msec) | - |
11503 | { | - |
11504 | Q_D(QWidget); | - |
11505 | d->toolTipDuration = msec; | - |
11506 | } | - |
11507 | | - |
11508 | int QWidget::toolTipDuration() const | - |
11509 | { | - |
11510 | Q_D(const QWidget); | - |
11511 | return d->toolTipDuration; | - |
11512 | } | - |
11513 | | - |
11514 | #endif // QT_NO_TOOLTIP | - |
11515 | | - |
11516 | | - |
11517 | #ifndef QT_NO_STATUSTIP | - |
11518 | | - |
11519 | | - |
11520 | | - |
11521 | | - |
11522 | | - |
11523 | | - |
11524 | | - |
11525 | | - |
11526 | void QWidget::setStatusTip(const QString &s) | - |
11527 | { | - |
11528 | Q_D(QWidget); | - |
11529 | d->statusTip = s; | - |
11530 | } | - |
11531 | | - |
11532 | QString QWidget::statusTip() const | - |
11533 | { | - |
11534 | Q_D(const QWidget); | - |
11535 | return d->statusTip; | - |
11536 | } | - |
11537 | #endif // QT_NO_STATUSTIP | - |
11538 | | - |
11539 | #ifndef QT_NO_WHATSTHIS | - |
11540 | | - |
11541 | | - |
11542 | | - |
11543 | | - |
11544 | | - |
11545 | | - |
11546 | | - |
11547 | | - |
11548 | | - |
11549 | void QWidget::setWhatsThis(const QString &s) | - |
11550 | { | - |
11551 | Q_D(QWidget); | - |
11552 | d->whatsThis = s; | - |
11553 | } | - |
11554 | | - |
11555 | QString QWidget::whatsThis() const | - |
11556 | { | - |
11557 | Q_D(const QWidget); | - |
11558 | return d->whatsThis; | - |
11559 | } | - |
11560 | #endif // QT_NO_WHATSTHIS | - |
11561 | | - |
11562 | #ifndef QT_NO_ACCESSIBILITY | - |
11563 | | - |
11564 | | - |
11565 | | - |
11566 | | - |
11567 | | - |
11568 | | - |
11569 | | - |
11570 | | - |
11571 | | - |
11572 | | - |
11573 | | - |
11574 | | - |
11575 | | - |
11576 | | - |
11577 | | - |
11578 | | - |
11579 | | - |
11580 | | - |
11581 | | - |
11582 | | - |
11583 | | - |
11584 | void QWidget::setAccessibleName(const QString &name) | - |
11585 | { | - |
11586 | Q_D(QWidget); | - |
11587 | d->accessibleName = name; | - |
11588 | QAccessibleEvent event(this, QAccessible::NameChanged); | - |
11589 | QAccessible::updateAccessibility(&event); | - |
11590 | } | - |
11591 | | - |
11592 | QString QWidget::accessibleName() const | - |
11593 | { | - |
11594 | Q_D(const QWidget); | - |
11595 | return d->accessibleName; | - |
11596 | } | - |
11597 | | - |
11598 | | - |
11599 | | - |
11600 | | - |
11601 | | - |
11602 | | - |
11603 | | - |
11604 | | - |
11605 | | - |
11606 | | - |
11607 | | - |
11608 | | - |
11609 | | - |
11610 | | - |
11611 | | - |
11612 | | - |
11613 | | - |
11614 | void QWidget::setAccessibleDescription(const QString &description) | - |
11615 | { | - |
11616 | Q_D(QWidget); | - |
11617 | d->accessibleDescription = description; | - |
11618 | QAccessibleEvent event(this, QAccessible::DescriptionChanged); | - |
11619 | QAccessible::updateAccessibility(&event); | - |
11620 | } | - |
11621 | | - |
11622 | QString QWidget::accessibleDescription() const | - |
11623 | { | - |
11624 | Q_D(const QWidget); | - |
11625 | return d->accessibleDescription; | - |
11626 | } | - |
11627 | #endif // QT_NO_ACCESSIBILITY | - |
11628 | | - |
11629 | #ifndef QT_NO_SHORTCUT | - |
11630 | | - |
11631 | | - |
11632 | | - |
11633 | | - |
11634 | | - |
11635 | | - |
11636 | | - |
11637 | | - |
11638 | | - |
11639 | | - |
11640 | | - |
11641 | | - |
11642 | | - |
11643 | | - |
11644 | | - |
11645 | | - |
11646 | | - |
11647 | | - |
11648 | | - |
11649 | | - |
11650 | | - |
11651 | | - |
11652 | | - |
11653 | int QWidget::grabShortcut(const QKeySequence &key, Qt::ShortcutContext context) | - |
11654 | { | - |
11655 | Q_ASSERT(qApp); | - |
11656 | if (key.isEmpty()) | - |
11657 | return 0; | - |
11658 | setAttribute(Qt::WA_GrabbedShortcut); | - |
11659 | return qApp->d_func()->shortcutMap.addShortcut(this, key, context, qWidgetShortcutContextMatcher); | - |
11660 | } | - |
11661 | | - |
11662 | | - |
11663 | | - |
11664 | | - |
11665 | | - |
11666 | | - |
11667 | | - |
11668 | | - |
11669 | | - |
11670 | | - |
11671 | | - |
11672 | | - |
11673 | | - |
11674 | | - |
11675 | | - |
11676 | | - |
11677 | void QWidget::releaseShortcut(int id) | - |
11678 | { | - |
11679 | Q_ASSERT(qApp); | - |
11680 | if (id) | - |
11681 | qApp->d_func()->shortcutMap.removeShortcut(id, this, 0); | - |
11682 | } | - |
11683 | | - |
11684 | | - |
11685 | | - |
11686 | | - |
11687 | | - |
11688 | | - |
11689 | | - |
11690 | | - |
11691 | | - |
11692 | | - |
11693 | | - |
11694 | | - |
11695 | | - |
11696 | void QWidget::setShortcutEnabled(int id, bool enable) | - |
11697 | { | - |
11698 | Q_ASSERT(qApp); | - |
11699 | if (id) | - |
11700 | qApp->d_func()->shortcutMap.setShortcutEnabled(enable, id, this, 0); | - |
11701 | } | - |
11702 | | - |
11703 | | - |
11704 | | - |
11705 | | - |
11706 | | - |
11707 | | - |
11708 | | - |
11709 | | - |
11710 | | - |
11711 | void QWidget::setShortcutAutoRepeat(int id, bool enable) | - |
11712 | { | - |
11713 | Q_ASSERT(qApp); | - |
11714 | if (id) | - |
11715 | qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enable, id, this, 0); | - |
11716 | } | - |
11717 | #endif // QT_NO_SHORTCUT | - |
11718 | | - |
11719 | | - |
11720 | | - |
11721 | | - |
11722 | void QWidget::updateMicroFocus() | - |
11723 | { | - |
11724 | | - |
11725 | if (this == QGuiApplication::focusObject()) | - |
11726 | QGuiApplication::inputMethod()->update(Qt::ImQueryAll); | - |
11727 | } | - |
11728 | | - |
11729 | | - |
11730 | | - |
11731 | | - |
11732 | | - |
11733 | | - |
11734 | | - |
11735 | | - |
11736 | | - |
11737 | | - |
11738 | | - |
11739 | | - |
11740 | | - |
11741 | void QWidget::raise() | - |
11742 | { | - |
11743 | Q_D(QWidget); | - |
11744 | if (!isWindow()) { | - |
11745 | QWidget *p = parentWidget(); | - |
11746 | const int parentChildCount = p->d_func()->children.size(); | - |
11747 | if (parentChildCount < 2) | - |
11748 | return; | - |
11749 | const int from = p->d_func()->children.indexOf(this); | - |
11750 | Q_ASSERT(from >= 0); | - |
11751 | | - |
11752 | if (from != parentChildCount -1) | - |
11753 | p->d_func()->children.move(from, parentChildCount - 1); | - |
11754 | if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created)) | - |
11755 | create(); | - |
11756 | else if (from == parentChildCount - 1) | - |
11757 | return; | - |
11758 | | - |
11759 | QRegion region(rect()); | - |
11760 | d->subtractOpaqueSiblings(region); | - |
11761 | d->invalidateBuffer(region); | - |
11762 | } | - |
11763 | if (testAttribute(Qt::WA_WState_Created)) | - |
11764 | d->raise_sys(); | - |
11765 | | - |
11766 | if (d->extra && d->extra->hasWindowContainer) | - |
11767 | QWindowContainer::parentWasRaised(this); | - |
11768 | | - |
11769 | QEvent e(QEvent::ZOrderChange); | - |
11770 | QApplication::sendEvent(this, &e); | - |
11771 | } | - |
11772 | | - |
11773 | void QWidgetPrivate::raise_sys() | - |
11774 | { | - |
11775 | Q_Q(QWidget); | - |
11776 | if (q->isWindow() || q->testAttribute(Qt::WA_NativeWindow)) { | - |
11777 | q->windowHandle()->raise(); | - |
11778 | } else if (renderToTexture) { | - |
11779 | if (QWidget *p = q->parentWidget()) { | - |
11780 | setDirtyOpaqueRegion(); | - |
11781 | p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); | - |
11782 | } | - |
11783 | } | - |
11784 | } | - |
11785 | | - |
11786 | | - |
11787 | | - |
11788 | | - |
11789 | | - |
11790 | | - |
11791 | | - |
11792 | | - |
11793 | | - |
11794 | | - |
11795 | void QWidget::lower() | - |
11796 | { | - |
11797 | Q_D(QWidget); | - |
11798 | if (!isWindow()) { | - |
11799 | QWidget *p = parentWidget(); | - |
11800 | const int parentChildCount = p->d_func()->children.size(); | - |
11801 | if (parentChildCount < 2) | - |
11802 | return; | - |
11803 | const int from = p->d_func()->children.indexOf(this); | - |
11804 | Q_ASSERT(from >= 0); | - |
11805 | | - |
11806 | if (from != 0) | - |
11807 | p->d_func()->children.move(from, 0); | - |
11808 | if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created)) | - |
11809 | create(); | - |
11810 | else if (from == 0) | - |
11811 | return; | - |
11812 | } | - |
11813 | if (testAttribute(Qt::WA_WState_Created)) | - |
11814 | d->lower_sys(); | - |
11815 | | - |
11816 | if (d->extra && d->extra->hasWindowContainer) | - |
11817 | QWindowContainer::parentWasLowered(this); | - |
11818 | | - |
11819 | QEvent e(QEvent::ZOrderChange); | - |
11820 | QApplication::sendEvent(this, &e); | - |
11821 | } | - |
11822 | | - |
11823 | void QWidgetPrivate::lower_sys() | - |
11824 | { | - |
11825 | Q_Q(QWidget); | - |
11826 | if (q->isWindow() || q->testAttribute(Qt::WA_NativeWindow)) { | - |
11827 | Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); | - |
11828 | q->windowHandle()->lower(); | - |
11829 | } else if (QWidget *p = q->parentWidget()) { | - |
11830 | setDirtyOpaqueRegion(); | - |
11831 | p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); | - |
11832 | } | - |
11833 | } | - |
11834 | | - |
11835 | | - |
11836 | | - |
11837 | | - |
11838 | | - |
11839 | | - |
11840 | | - |
11841 | | - |
11842 | void QWidget::stackUnder(QWidget* w) | - |
11843 | { | - |
11844 | Q_D(QWidget); | - |
11845 | QWidget *p = parentWidget(); | - |
11846 | if (!w || isWindow() || p != w->parentWidget() || this == w) | - |
11847 | return; | - |
11848 | if (p) { | - |
11849 | int from = p->d_func()->children.indexOf(this); | - |
11850 | int to = p->d_func()->children.indexOf(w); | - |
11851 | Q_ASSERT(from >= 0); | - |
11852 | Q_ASSERT(to >= 0); | - |
11853 | if (from < to) | - |
11854 | --to; | - |
11855 | | - |
11856 | if (from != to) | - |
11857 | p->d_func()->children.move(from, to); | - |
11858 | if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created)) | - |
11859 | create(); | - |
11860 | else if (from == to) | - |
11861 | return; | - |
11862 | } | - |
11863 | if (testAttribute(Qt::WA_WState_Created)) | - |
11864 | d->stackUnder_sys(w); | - |
11865 | | - |
11866 | QEvent e(QEvent::ZOrderChange); | - |
11867 | QApplication::sendEvent(this, &e); | - |
11868 | } | - |
11869 | | - |
11870 | void QWidgetPrivate::stackUnder_sys(QWidget*) | - |
11871 | { | - |
11872 | Q_Q(QWidget); | - |
11873 | if (QWidget *p = q->parentWidget()) { | - |
11874 | setDirtyOpaqueRegion(); | - |
11875 | p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); | - |
11876 | } | - |
11877 | } | - |
11878 | | - |
11879 | | - |
11880 | | - |
11881 | | - |
11882 | | - |
11883 | | - |
11884 | | - |
11885 | | - |
11886 | | - |
11887 | | - |
11888 | | - |
11889 | | - |
11890 | | - |
11891 | | - |
11892 | | - |
11893 | | - |
11894 | | - |
11895 | | - |
11896 | | - |
11897 | | - |
11898 | | - |
11899 | | - |
11900 | | - |
11901 | | - |
11902 | | - |
11903 | | - |
11904 | | - |
11905 | | - |
11906 | | - |
11907 | | - |
11908 | | - |
11909 | | - |
11910 | | - |
11911 | | - |
11912 | | - |
11913 | | - |
11914 | | - |
11915 | | - |
11916 | | - |
11917 | | - |
11918 | | - |
11919 | QRect QWidgetPrivate::frameStrut() const | - |
11920 | { | - |
11921 | Q_Q(const QWidget); | - |
11922 | if (!q->isWindow() || (q->windowType() == Qt::Desktop) || q->testAttribute(Qt::WA_DontShowOnScreen)) { | - |
11923 | | - |
11924 | return QRect(0, 0, 1, 1); | - |
11925 | } | - |
11926 | | - |
11927 | if (data.fstrut_dirty | - |
11928 | #ifndef Q_DEAD_CODE_FROM_QT4_WIN | - |
11929 | | - |
11930 | && q->isVisible() | - |
11931 | #endif | - |
11932 | && q->testAttribute(Qt::WA_WState_Created)) | - |
11933 | const_cast<QWidgetPrivate *>(this)->updateFrameStrut(); | - |
11934 | | - |
11935 | return maybeTopData() ? maybeTopData()->frameStrut : QRect(); | - |
11936 | } | - |
11937 | | - |
11938 | void QWidgetPrivate::updateFrameStrut() | - |
11939 | { | - |
11940 | Q_Q(QWidget); | - |
11941 | if (q->data->fstrut_dirty) { | - |
11942 | if (QTLWExtra *te = maybeTopData()) { | - |
11943 | if (te->window && te->window->handle()) { | - |
11944 | const QMargins margins = te->window->frameMargins(); | - |
11945 | if (!margins.isNull()) { | - |
11946 | te->frameStrut.setCoords(margins.left(), margins.top(), margins.right(), margins.bottom()); | - |
11947 | q->data->fstrut_dirty = false; | - |
11948 | } | - |
11949 | } | - |
11950 | } | - |
11951 | } | - |
11952 | } | - |
11953 | | - |
11954 | #ifdef QT_KEYPAD_NAVIGATION | - |
11955 | | - |
11956 | | - |
11957 | | - |
11958 | | - |
11959 | | - |
11960 | | - |
11961 | | - |
11962 | | - |
11963 | bool QWidgetPrivate::navigateToDirection(Direction direction) | - |
11964 | { | - |
11965 | QWidget *targetWidget = widgetInNavigationDirection(direction); | - |
11966 | if (targetWidget) | - |
11967 | targetWidget->setFocus(); | - |
11968 | return (targetWidget != 0); | - |
11969 | } | - |
11970 | | - |
11971 | | - |
11972 | | - |
11973 | | - |
11974 | | - |
11975 | | - |
11976 | | - |
11977 | | - |
11978 | | - |
11979 | | - |
11980 | QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction) | - |
11981 | { | - |
11982 | const QWidget *sourceWidget = QApplication::focusWidget(); | - |
11983 | if (!sourceWidget) | - |
11984 | return 0; | - |
11985 | const QRect sourceRect = sourceWidget->rect().translated(sourceWidget->mapToGlobal(QPoint())); | - |
11986 | const int sourceX = | - |
11987 | (direction == DirectionNorth || direction == DirectionSouth) ? | - |
11988 | (sourceRect.left() + (sourceRect.right() - sourceRect.left()) / 2) | - |
11989 | :(direction == DirectionEast ? sourceRect.right() : sourceRect.left()); | - |
11990 | const int sourceY = | - |
11991 | (direction == DirectionEast || direction == DirectionWest) ? | - |
11992 | (sourceRect.top() + (sourceRect.bottom() - sourceRect.top()) / 2) | - |
11993 | :(direction == DirectionSouth ? sourceRect.bottom() : sourceRect.top()); | - |
11994 | const QPoint sourcePoint(sourceX, sourceY); | - |
11995 | const QPoint sourceCenter = sourceRect.center(); | - |
11996 | const QWidget *sourceWindow = sourceWidget->window(); | - |
11997 | | - |
11998 | QWidget *targetWidget = 0; | - |
11999 | int shortestDistance = INT_MAX; | - |
12000 | | - |
12001 | foreachconst auto targetCandidates = QApplication::allWidgets(); | - |
12002 | for (QWidget *targetCandidate , QApplication::allWidgets()): targetCandidates) { | - |
12003 | | - |
12004 | const QRect targetCandidateRect = targetCandidate->rect().translated(targetCandidate->mapToGlobal(QPoint())); | - |
12005 | | - |
12006 | | - |
12007 | | - |
12008 | | - |
12009 | if (targetCandidate->focusProxy() || targetCandidateRect.isEmpty()) | - |
12010 | continue; | - |
12011 | | - |
12012 | | - |
12013 | if ( targetCandidate != sourceWidget | - |
12014 | | - |
12015 | && targetCandidate->focusPolicy() & Qt::TabFocus | - |
12016 | | - |
12017 | && !(direction == DirectionNorth && targetCandidateRect.bottom() > sourceRect.top()) | - |
12018 | | - |
12019 | && !(direction == DirectionEast && targetCandidateRect.left() < sourceRect.right()) | - |
12020 | | - |
12021 | && !(direction == DirectionSouth && targetCandidateRect.top() < sourceRect.bottom()) | - |
12022 | | - |
12023 | && !(direction == DirectionWest && targetCandidateRect.right() > sourceRect.left()) | - |
12024 | | - |
12025 | && targetCandidate->isEnabled() | - |
12026 | | - |
12027 | && targetCandidate->isVisible() | - |
12028 | | - |
12029 | && targetCandidate->window() == sourceWindow) { | - |
12030 | const int targetCandidateDistance = pointToRect(sourcePoint, targetCandidateRect); | - |
12031 | if (targetCandidateDistance < shortestDistance) { | - |
12032 | shortestDistance = targetCandidateDistance; | - |
12033 | targetWidget = targetCandidate; | - |
12034 | } | - |
12035 | } | - |
12036 | } | - |
12037 | return targetWidget; | - |
12038 | } | - |
12039 | | - |
12040 | | - |
12041 | | - |
12042 | | - |
12043 | | - |
12044 | | - |
12045 | | - |
12046 | | - |
12047 | | - |
12048 | | - |
12049 | | - |
12050 | | - |
12051 | bool QWidgetPrivate::canKeypadNavigate(Qt::Orientation orientation) | - |
12052 | { | - |
12053 | return orientation == Qt::Horizontal? | - |
12054 | (QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionEast) | - |
12055 | || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionWest)) | - |
12056 | :(QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionNorth) | - |
12057 | || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionSouth)); | - |
12058 | } | - |
12059 | | - |
12060 | | - |
12061 | | - |
12062 | | - |
12063 | | - |
12064 | | - |
12065 | | - |
12066 | | - |
12067 | | - |
12068 | | - |
12069 | | - |
12070 | | - |
12071 | bool QWidgetPrivate::inTabWidget(QWidget *widget) | - |
12072 | { | - |
12073 | for (QWidget *tabWidget = widget; tabWidget; tabWidget = tabWidget->parentWidget()) | - |
12074 | if (qobject_cast<const QTabWidget*>(tabWidget)) | - |
12075 | return true; | - |
12076 | return false; | - |
12077 | } | - |
12078 | #endif | - |
12079 | | - |
12080 | | - |
12081 | | - |
12082 | | - |
12083 | | - |
12084 | | - |
12085 | | - |
12086 | | - |
12087 | void QWidget::setBackingStore(QBackingStore *store) | - |
12088 | { | - |
12089 | | - |
12090 | | - |
12091 | if (!isTopLevel()) | - |
12092 | return; | - |
12093 | | - |
12094 | Q_D(QWidget); | - |
12095 | | - |
12096 | QTLWExtra *topData = d->topData(); | - |
12097 | if (topData->backingStore == store) | - |
12098 | return; | - |
12099 | | - |
12100 | QBackingStore *oldStore = topData->backingStore; | - |
12101 | deleteBackingStore(d); | - |
12102 | topData->backingStore = store; | - |
12103 | | - |
12104 | QWidgetBackingStore *bs = d->maybeBackingStore(); | - |
12105 | if (!bs) | - |
12106 | return; | - |
12107 | | - |
12108 | if (isTopLevel()) { | - |
12109 | if (bs->store != oldStore && bs->store != store) | - |
12110 | delete bs->store; | - |
12111 | bs->store = store; | - |
12112 | } | - |
12113 | } | - |
12114 | | - |
12115 | | - |
12116 | | - |
12117 | | - |
12118 | | - |
12119 | | - |
12120 | QBackingStore *QWidget::backingStore() const | - |
12121 | { | - |
12122 | Q_D(const QWidget); | - |
12123 | QTLWExtra *extra = d->maybeTopData(); | - |
12124 | if (extra && extra->backingStore) | - |
12125 | return extra->backingStore; | - |
12126 | | - |
12127 | QWidgetBackingStore *bs = d->maybeBackingStore(); | - |
12128 | | - |
12129 | return bs ? bs->store : 0; | - |
12130 | } | - |
12131 | | - |
12132 | void QWidgetPrivate::getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const | - |
12133 | { | - |
12134 | if (left) | - |
12135 | *left = (int)leftLayoutItemMargin; | - |
12136 | if (top) | - |
12137 | *top = (int)topLayoutItemMargin; | - |
12138 | if (right) | - |
12139 | *right = (int)rightLayoutItemMargin; | - |
12140 | if (bottom) | - |
12141 | *bottom = (int)bottomLayoutItemMargin; | - |
12142 | } | - |
12143 | | - |
12144 | void QWidgetPrivate::setLayoutItemMargins(int left, int top, int right, int bottom) | - |
12145 | { | - |
12146 | if (leftLayoutItemMargin == left | - |
12147 | && topLayoutItemMargin == top | - |
12148 | && rightLayoutItemMargin == right | - |
12149 | && bottomLayoutItemMargin == bottom) | - |
12150 | return; | - |
12151 | | - |
12152 | Q_Q(QWidget); | - |
12153 | leftLayoutItemMargin = (signed char)left; | - |
12154 | topLayoutItemMargin = (signed char)top; | - |
12155 | rightLayoutItemMargin = (signed char)right; | - |
12156 | bottomLayoutItemMargin = (signed char)bottom; | - |
12157 | q->updateGeometry(); | - |
12158 | } | - |
12159 | | - |
12160 | void QWidgetPrivate::setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt) | - |
12161 | { | - |
12162 | Q_Q(QWidget); | - |
12163 | QStyleOption myOpt; | - |
12164 | if (!opt) { | - |
12165 | myOpt.initFrom(q); | - |
12166 | myOpt.rect.setRect(0, 0, 32768, 32768); | - |
12167 | opt = &myOpt; | - |
12168 | } | - |
12169 | | - |
12170 | QRect liRect = q->style()->subElementRect(element, opt, q); | - |
12171 | if (liRect.isValid()) { | - |
12172 | leftLayoutItemMargin = (signed char)(opt->rect.left() - liRect.left()); | - |
12173 | topLayoutItemMargin = (signed char)(opt->rect.top() - liRect.top()); | - |
12174 | rightLayoutItemMargin = (signed char)(liRect.right() - opt->rect.right()); | - |
12175 | bottomLayoutItemMargin = (signed char)(liRect.bottom() - opt->rect.bottom()); | - |
12176 | } else { | - |
12177 | leftLayoutItemMargin = 0; | - |
12178 | topLayoutItemMargin = 0; | - |
12179 | rightLayoutItemMargin = 0; | - |
12180 | bottomLayoutItemMargin = 0; | - |
12181 | } | - |
12182 | } | - |
12183 | | - |
12184 | void QWidgetPrivate::adjustQuitOnCloseAttribute() | - |
12185 | { | - |
12186 | Q_Q(QWidget); | - |
12187 | | - |
12188 | if (!q->parentWidget()) { | - |
12189 | Qt::WindowType type = q->windowType(); | - |
12190 | if (type == Qt::Widget || type == Qt::SubWindow) | - |
12191 | type = Qt::Window; | - |
12192 | if (type != Qt::Widget && type != Qt::Window && type != Qt::Dialog) | - |
12193 | q->setAttribute(Qt::WA_QuitOnClose, false); | - |
12194 | } | - |
12195 | } | - |
12196 | | - |
12197 | QOpenGLContext *QWidgetPrivate::shareContext() const | - |
12198 | { | - |
12199 | #ifdef QT_NO_OPENGL | - |
12200 | return 0; | - |
12201 | #else | - |
12202 | if (Q_UNLIKELY(!extra || !extra->topextra || !extra->topextra->window))) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
12203 | qWarning("Asking for share context for widget that does not have a window handle"); | - |
12204 | return 0; never executed: return 0; | 0 |
12205 | } | - |
12206 | QWidgetPrivate *that = const_cast<QWidgetPrivate *>(this); | - |
12207 | if (!extra->topextra->shareContext) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
12208 | QOpenGLContext *ctx = new QOpenGLContext; | - |
12209 | ctx->setShareContext(qt_gl_global_share_context()); | - |
12210 | ctx->setFormat(extra->topextra->window->format()); | - |
12211 | ctx->setScreen(extra->topextra->window->screen()); | - |
12212 | ctx->create(); | - |
12213 | that->extra->topextra->shareContext = ctx; | - |
12214 | } never executed: end of block | 0 |
12215 | return that->extra->topextra->shareContext; never executed: return that->extra->topextra->shareContext; | 0 |
12216 | #endif // QT_NO_OPENGL | - |
12217 | } | - |
12218 | | - |
12219 | #ifndef QT_NO_OPENGL | - |
12220 | void QWidgetPrivate::sendComposeStatus(QWidget *w, bool end) | - |
12221 | { | - |
12222 | QWidgetPrivate *wd = QWidgetPrivate::get(w); | - |
12223 | if (!wd->textureChildSeen) | - |
12224 | return; | - |
12225 | if (end) | - |
12226 | wd->endCompose(); | - |
12227 | else | - |
12228 | wd->beginCompose(); | - |
12229 | for (int i = 0; i < wd->children.size(); ++i) { | - |
12230 | w = qobject_cast<QWidget *>(wd->children.at(i)); | - |
12231 | if (w && !w->isWindow() && !w->isHidden() && QWidgetPrivate::get(w)->textureChildSeen) | - |
12232 | sendComposeStatus(w, end); | - |
12233 | } | - |
12234 | } | - |
12235 | #endif // QT_NO_OPENGL | - |
12236 | | - |
12237 | Q_WIDGETS_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget) | - |
12238 | { | - |
12239 | return widget->data; | - |
12240 | } | - |
12241 | | - |
12242 | Q_WIDGETS_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget) | - |
12243 | { | - |
12244 | return widget->d_func(); | - |
12245 | } | - |
12246 | | - |
12247 | | - |
12248 | #ifndef QT_NO_GRAPHICSVIEW | - |
12249 | | - |
12250 | | - |
12251 | | - |
12252 | | - |
12253 | | - |
12254 | | - |
12255 | | - |
12256 | | - |
12257 | | - |
12258 | QGraphicsProxyWidget *QWidget::graphicsProxyWidget() const | - |
12259 | { | - |
12260 | Q_D(const QWidget); | - |
12261 | if (d->extra) { | - |
12262 | return d->extra->proxyWidget; | - |
12263 | } | - |
12264 | return 0; | - |
12265 | } | - |
12266 | #endif | - |
12267 | | - |
12268 | #ifndef QT_NO_GESTURES | - |
12269 | | - |
12270 | | - |
12271 | | - |
12272 | | - |
12273 | | - |
12274 | | - |
12275 | void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags) | - |
12276 | { | - |
12277 | Q_D(QWidget); | - |
12278 | d->gestureContext.insert(gesture, flags); | - |
12279 | (void)QGestureManager::instance(); | - |
12280 | } | - |
12281 | | - |
12282 | | - |
12283 | | - |
12284 | | - |
12285 | | - |
12286 | | - |
12287 | | - |
12288 | void QWidget::ungrabGesture(Qt::GestureType gesture) | - |
12289 | { | - |
12290 | | - |
12291 | Q_D(QWidget); | - |
12292 | if (d->gestureContext.remove(gesture)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
12293 | if (QGestureManager *manager = QGestureManager::instance())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
12294 | manager->cleanupCachedGestures(this, gesture); never executed: manager->cleanupCachedGestures(this, gesture); | 0 |
12295 | } never executed: end of block | 0 |
12296 | } never executed: end of block | 0 |
12297 | #endif // QT_NO_GESTURES | - |
12298 | | - |
12299 | | - |
12300 | | - |
12301 | | - |
12302 | | - |
12303 | | - |
12304 | | - |
12305 | | - |
12306 | | - |
12307 | | - |
12308 | | - |
12309 | | - |
12310 | | - |
12311 | | - |
12312 | void QWidget::destroy(bool destroyWindow, bool destroySubWindows) | - |
12313 | { | - |
12314 | Q_D(QWidget); | - |
12315 | | - |
12316 | d->aboutToDestroy(); | - |
12317 | if (!isWindow() && parentWidget()) | - |
12318 | parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry())); | - |
12319 | d->deactivateWidgetCleanup(); | - |
12320 | | - |
12321 | if ((windowType() == Qt::Popup) && qApp) | - |
12322 | qApp->d_func()->closePopup(this); | - |
12323 | | - |
12324 | if (this == QApplicationPrivate::active_window) | - |
12325 | QApplication::setActiveWindow(0); | - |
12326 | if (QWidget::mouseGrabber() == this) | - |
12327 | releaseMouse(); | - |
12328 | if (QWidget::keyboardGrabber() == this) | - |
12329 | releaseKeyboard(); | - |
12330 | | - |
12331 | setAttribute(Qt::WA_WState_Created, false); | - |
12332 | | - |
12333 | if (windowType() != Qt::Desktop) { | - |
12334 | if (destroySubWindows) { | - |
12335 | QObjectList childList(children()); | - |
12336 | for (int i = 0; i < childList.size(); i++) { | - |
12337 | QWidget *widget = qobject_cast<QWidget *>(childList.at(i)); | - |
12338 | if (widget && widget->testAttribute(Qt::WA_NativeWindow)) { | - |
12339 | if (widget->windowHandle()) { | - |
12340 | widget->destroy(); | - |
12341 | } | - |
12342 | } | - |
12343 | } | - |
12344 | } | - |
12345 | if (destroyWindow) { | - |
12346 | d->deleteTLSysExtra(); | - |
12347 | } else { | - |
12348 | if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) { | - |
12349 | d->hide_sys(); | - |
12350 | } | - |
12351 | } | - |
12352 | | - |
12353 | d->setWinId(0); | - |
12354 | } | - |
12355 | } | - |
12356 | | - |
12357 | | - |
12358 | | - |
12359 | | - |
12360 | | - |
12361 | | - |
12362 | | - |
12363 | | - |
12364 | | - |
12365 | | - |
12366 | | - |
12367 | QPaintEngine *QWidget::paintEngine() const | - |
12368 | { | - |
12369 | qWarning("QWidget::paintEngine: Should no longer be called"); | - |
12370 | | - |
12371 | #ifdef Q_OS_WIN | - |
12372 | | - |
12373 | | - |
12374 | | - |
12375 | | - |
12376 | | - |
12377 | | - |
12378 | | - |
12379 | | - |
12380 | | - |
12381 | | - |
12382 | | - |
12383 | | - |
12384 | | - |
12385 | | - |
12386 | const_cast<QWidgetPrivate *>(d_func())->noPaintOnScreen = 1; | - |
12387 | #endif | - |
12388 | | - |
12389 | return 0; | - |
12390 | } | - |
12391 | | - |
12392 | | - |
12393 | static inline bool canMapPosition(QWindow *window) | - |
12394 | { | - |
12395 | return window->handle() && !qt_window_private(window)->resizeEventPending; | - |
12396 | } | - |
12397 | | - |
12398 | #ifndef QT_NO_GRAPHICSVIEW | - |
12399 | static inline QGraphicsProxyWidget *graphicsProxyWidget(const QWidget *w) | - |
12400 | { | - |
12401 | QGraphicsProxyWidget *result = Q_NULLPTR; | - |
12402 | const QWidgetPrivate *d = qt_widget_private(const_cast<QWidget *>(w)); | - |
12403 | if (d->extra) | - |
12404 | result = d->extra->proxyWidget; | - |
12405 | return result; | - |
12406 | } | - |
12407 | #endif // !QT_NO_GRAPHICSVIEW | - |
12408 | | - |
12409 | struct MapToGlobalTransformResult { | - |
12410 | QTransform transform; | - |
12411 | QWindow *window; | - |
12412 | }; | - |
12413 | | - |
12414 | static MapToGlobalTransformResult mapToGlobalTransform(const QWidget *w) | - |
12415 | { | - |
12416 | MapToGlobalTransformResult result; | - |
12417 | result.window = Q_NULLPTR; | - |
12418 | for ( ; w ; w = w->parentWidget()) { | - |
12419 | #ifndef QT_NO_GRAPHICSVIEW | - |
12420 | if (QGraphicsProxyWidget *qgpw = graphicsProxyWidget(w)) { | - |
12421 | if (const QGraphicsScene *scene = qgpw->scene()) { | - |
12422 | const QList <QGraphicsView *> views = scene->views(); | - |
12423 | if (!views.isEmpty()) { | - |
12424 | result.transform *= qgpw->sceneTransform(); | - |
12425 | result.transform *= views.first()->viewportTransform(); | - |
12426 | w = views.first()->viewport(); | - |
12427 | } | - |
12428 | } | - |
12429 | } | - |
12430 | #endif // !QT_NO_GRAPHICSVIEW | - |
12431 | QWindow *window = w->windowHandle(); | - |
12432 | if (window && canMapPosition(window)) { | - |
12433 | result.window = window; | - |
12434 | break; | - |
12435 | } | - |
12436 | | - |
12437 | const QPoint topLeft = w->geometry().topLeft(); | - |
12438 | result.transform.translate(topLeft.x(), topLeft.y()); | - |
12439 | if (w->isWindow()) | - |
12440 | break; | - |
12441 | } | - |
12442 | return result; | - |
12443 | } | - |
12444 | | - |
12445 | | - |
12446 | | - |
12447 | | - |
12448 | | - |
12449 | | - |
12450 | | - |
12451 | | - |
12452 | | - |
12453 | | - |
12454 | QPoint QWidget::mapToGlobal(const QPoint &pos) const | - |
12455 | { | - |
12456 | const MapToGlobalTransformResult t = mapToGlobalTransform(this); | - |
12457 | const QPoint g = t.transform.map(pos); | - |
12458 | return t.window ? t.window->mapToGlobal(g) : g; | - |
12459 | } | - |
12460 | | - |
12461 | | - |
12462 | | - |
12463 | | - |
12464 | | - |
12465 | | - |
12466 | | - |
12467 | | - |
12468 | | - |
12469 | QPoint QWidget::mapFromGlobal(const QPoint &pos) const | - |
12470 | { | - |
12471 | const MapToGlobalTransformResult t = mapToGlobalTransform(this); | - |
12472 | const QPoint windowLocal = t.window ? t.window->mapFromGlobal(pos) : pos; | - |
12473 | return t.transform.inverted().map(windowLocal); | - |
12474 | } | - |
12475 | | - |
12476 | QWidget *qt_pressGrab = 0; | - |
12477 | QWidget *qt_mouseGrb = 0; | - |
12478 | static bool mouseGrabWithCursor = false; | - |
12479 | static QWidget *keyboardGrb = 0; | - |
12480 | | - |
12481 | static inline QWindow *grabberWindow(const QWidget *w) | - |
12482 | { | - |
12483 | QWindow *window = w->windowHandle(); | - |
12484 | if (!window) | - |
12485 | if (const QWidget *nativeParent = w->nativeParentWidget()) | - |
12486 | window = nativeParent->windowHandle(); | - |
12487 | return window; | - |
12488 | } | - |
12489 | | - |
12490 | #ifndef QT_NO_CURSOR | - |
12491 | static void grabMouseForWidget(QWidget *widget, const QCursor *cursor = 0) | - |
12492 | #else | - |
12493 | static void grabMouseForWidget(QWidget *widget) | - |
12494 | #endif | - |
12495 | { | - |
12496 | if (qt_mouseGrb) | - |
12497 | qt_mouseGrb->releaseMouse(); | - |
12498 | | - |
12499 | mouseGrabWithCursor = false; | - |
12500 | if (QWindow *window = grabberWindow(widget)) { | - |
12501 | #ifndef QT_NO_CURSOR | - |
12502 | if (cursor) { | - |
12503 | mouseGrabWithCursor = true; | - |
12504 | QGuiApplication::setOverrideCursor(*cursor); | - |
12505 | } | - |
12506 | #endif // !QT_NO_CURSOR | - |
12507 | window->setMouseGrabEnabled(true); | - |
12508 | } | - |
12509 | | - |
12510 | qt_mouseGrb = widget; | - |
12511 | qt_pressGrab = 0; | - |
12512 | } | - |
12513 | | - |
12514 | static void releaseMouseGrabOfWidget(QWidget *widget) | - |
12515 | { | - |
12516 | if (qt_mouseGrb == widget) { | - |
12517 | if (QWindow *window = grabberWindow(widget)) { | - |
12518 | #ifndef QT_NO_CURSOR | - |
12519 | if (mouseGrabWithCursor) { | - |
12520 | QGuiApplication::restoreOverrideCursor(); | - |
12521 | mouseGrabWithCursor = false; | - |
12522 | } | - |
12523 | #endif // !QT_NO_CURSOR | - |
12524 | window->setMouseGrabEnabled(false); | - |
12525 | } | - |
12526 | } | - |
12527 | qt_mouseGrb = 0; | - |
12528 | } | - |
12529 | | - |
12530 | | - |
12531 | | - |
12532 | | - |
12533 | | - |
12534 | | - |
12535 | | - |
12536 | | - |
12537 | | - |
12538 | | - |
12539 | | - |
12540 | | - |
12541 | | - |
12542 | | - |
12543 | | - |
12544 | | - |
12545 | | - |
12546 | | - |
12547 | | - |
12548 | | - |
12549 | | - |
12550 | | - |
12551 | | - |
12552 | | - |
12553 | | - |
12554 | | - |
12555 | | - |
12556 | | - |
12557 | | - |
12558 | void QWidget::grabMouse() | - |
12559 | { | - |
12560 | grabMouseForWidget(this); | - |
12561 | } | - |
12562 | | - |
12563 | | - |
12564 | | - |
12565 | | - |
12566 | | - |
12567 | | - |
12568 | | - |
12569 | | - |
12570 | | - |
12571 | | - |
12572 | | - |
12573 | | - |
12574 | | - |
12575 | | - |
12576 | | - |
12577 | | - |
12578 | | - |
12579 | #ifndef QT_NO_CURSOR | - |
12580 | void QWidget::grabMouse(const QCursor &cursor) | - |
12581 | { | - |
12582 | grabMouseForWidget(this, &cursor); | - |
12583 | } | - |
12584 | #endif | - |
12585 | | - |
12586 | bool QWidgetPrivate::stealMouseGrab(bool grab) | - |
12587 | { | - |
12588 | | - |
12589 | | - |
12590 | Q_Q(QWidget); | - |
12591 | QWindow *window = grabberWindow(q); | - |
12592 | return window ? window->setMouseGrabEnabled(grab) : false; | - |
12593 | } | - |
12594 | | - |
12595 | | - |
12596 | | - |
12597 | | - |
12598 | | - |
12599 | | - |
12600 | | - |
12601 | | - |
12602 | void QWidget::releaseMouse() | - |
12603 | { | - |
12604 | releaseMouseGrabOfWidget(this); | - |
12605 | } | - |
12606 | | - |
12607 | | - |
12608 | | - |
12609 | | - |
12610 | | - |
12611 | | - |
12612 | | - |
12613 | | - |
12614 | | - |
12615 | | - |
12616 | | - |
12617 | | - |
12618 | | - |
12619 | | - |
12620 | | - |
12621 | | - |
12622 | | - |
12623 | | - |
12624 | | - |
12625 | | - |
12626 | void QWidget::grabKeyboard() | - |
12627 | { | - |
12628 | if (keyboardGrb) | - |
12629 | keyboardGrb->releaseKeyboard(); | - |
12630 | if (QWindow *window = grabberWindow(this)) | - |
12631 | window->setKeyboardGrabEnabled(true); | - |
12632 | keyboardGrb = this; | - |
12633 | } | - |
12634 | | - |
12635 | bool QWidgetPrivate::stealKeyboardGrab(bool grab) | - |
12636 | { | - |
12637 | | - |
12638 | | - |
12639 | Q_Q(QWidget); | - |
12640 | QWindow *window = grabberWindow(q); | - |
12641 | return window ? window->setKeyboardGrabEnabled(grab) : false; | - |
12642 | } | - |
12643 | | - |
12644 | | - |
12645 | | - |
12646 | | - |
12647 | | - |
12648 | | - |
12649 | | - |
12650 | | - |
12651 | void QWidget::releaseKeyboard() | - |
12652 | { | - |
12653 | if (keyboardGrb == this) { | - |
12654 | if (QWindow *window = grabberWindow(this)) | - |
12655 | window->setKeyboardGrabEnabled(false); | - |
12656 | keyboardGrb = 0; | - |
12657 | } | - |
12658 | } | - |
12659 | | - |
12660 | | - |
12661 | | - |
12662 | | - |
12663 | | - |
12664 | | - |
12665 | | - |
12666 | | - |
12667 | | - |
12668 | | - |
12669 | | - |
12670 | QWidget *QWidget::mouseGrabber() | - |
12671 | { | - |
12672 | if (qt_mouseGrb) | - |
12673 | return qt_mouseGrb; | - |
12674 | return qt_pressGrab; | - |
12675 | } | - |
12676 | | - |
12677 | | - |
12678 | | - |
12679 | | - |
12680 | | - |
12681 | | - |
12682 | | - |
12683 | | - |
12684 | | - |
12685 | | - |
12686 | | - |
12687 | QWidget *QWidget::keyboardGrabber() | - |
12688 | { | - |
12689 | return keyboardGrb; | - |
12690 | } | - |
12691 | | - |
12692 | | - |
12693 | | - |
12694 | | - |
12695 | | - |
12696 | | - |
12697 | | - |
12698 | | - |
12699 | | - |
12700 | | - |
12701 | | - |
12702 | | - |
12703 | | - |
12704 | | - |
12705 | | - |
12706 | | - |
12707 | | - |
12708 | | - |
12709 | | - |
12710 | | - |
12711 | | - |
12712 | | - |
12713 | | - |
12714 | | - |
12715 | | - |
12716 | void QWidget::activateWindow() | - |
12717 | { | - |
12718 | QWindow *const wnd = window()->windowHandle(); | - |
12719 | | - |
12720 | if (wnd) | - |
12721 | wnd->requestActivate(); | - |
12722 | } | - |
12723 | | - |
12724 | | - |
12725 | | - |
12726 | | - |
12727 | | - |
12728 | | - |
12729 | | - |
12730 | | - |
12731 | | - |
12732 | int QWidget::metric(PaintDeviceMetric m) const | - |
12733 | { | - |
12734 | Q_D(const QWidget); | - |
12735 | | - |
12736 | QWindow *topLevelWindow = 0; | - |
12737 | QScreen *screen = 0; | - |
12738 | if (QWidget *topLevel = window()) { | - |
12739 | topLevelWindow = topLevel->windowHandle(); | - |
12740 | if (topLevelWindow) | - |
12741 | screen = topLevelWindow->screen(); | - |
12742 | } | - |
12743 | if (!screen && QGuiApplication::primaryScreen()) | - |
12744 | screen = QGuiApplication::primaryScreen(); | - |
12745 | | - |
12746 | if (!screen) { | - |
12747 | if (m == PdmDpiX || m == PdmDpiY) | - |
12748 | return 72; | - |
12749 | return QPaintDevice::metric(m); | - |
12750 | } | - |
12751 | int val; | - |
12752 | if (m == PdmWidth) { | - |
12753 | val = data->crect.width(); | - |
12754 | } else if (m == PdmWidthMM) { | - |
12755 | val = data->crect.width() * screen->physicalSize().width() / screen->geometry().width(); | - |
12756 | } else if (m == PdmHeight) { | - |
12757 | val = data->crect.height(); | - |
12758 | } else if (m == PdmHeightMM) { | - |
12759 | val = data->crect.height() * screen->physicalSize().height() / screen->geometry().height(); | - |
12760 | } else if (m == PdmDepth) { | - |
12761 | return screen->depth(); | - |
12762 | } else if (m == PdmDpiX) { | - |
12763 | if (d->extra && d->extra->customDpiX) | - |
12764 | return d->extra->customDpiX; | - |
12765 | else if (d->parent) | - |
12766 | return static_cast<QWidget *>(d->parent)->metric(m); | - |
12767 | return qRound(screen->logicalDotsPerInchX()); | - |
12768 | } else if (m == PdmDpiY) { | - |
12769 | if (d->extra && d->extra->customDpiY) | - |
12770 | return d->extra->customDpiY; | - |
12771 | else if (d->parent) | - |
12772 | return static_cast<QWidget *>(d->parent)->metric(m); | - |
12773 | return qRound(screen->logicalDotsPerInchY()); | - |
12774 | } else if (m == PdmPhysicalDpiX) { | - |
12775 | return qRound(screen->physicalDotsPerInchX()); | - |
12776 | } else if (m == PdmPhysicalDpiY) { | - |
12777 | return qRound(screen->physicalDotsPerInchY()); | - |
12778 | } else if (m == PdmDevicePixelRatio) { | - |
12779 | return topLevelWindow ? topLevelWindow->devicePixelRatio() : qApp->devicePixelRatio(); | - |
12780 | } else if (m == PdmDevicePixelRatioScaled) { | - |
12781 | return (QPaintDevice::devicePixelRatioFScale() * | - |
12782 | (topLevelWindow ? topLevelWindow->devicePixelRatio() : qApp->devicePixelRatio())); | - |
12783 | } else { | - |
12784 | val = QPaintDevice::metric(m); | - |
12785 | } | - |
12786 | return val; | - |
12787 | } | - |
12788 | | - |
12789 | | - |
12790 | | - |
12791 | | - |
12792 | | - |
12793 | | - |
12794 | void QWidget::initPainter(QPainter *painter) const | - |
12795 | { | - |
12796 | const QPalette &pal = palette(); | - |
12797 | painter->d_func()->state->pen = QPen(pal.brush(foregroundRole()), 1); | - |
12798 | painter->d_func()->state->bgBrush = pal.brush(backgroundRole()); | - |
12799 | QFont f(font(), const_cast<QWidget *>(this)); | - |
12800 | painter->d_func()->state->deviceFont = f; | - |
12801 | painter->d_func()->state->font = f; | - |
12802 | } | - |
12803 | | - |
12804 | | - |
12805 | | - |
12806 | | - |
12807 | | - |
12808 | | - |
12809 | QPaintDevice *QWidget::redirected(QPoint *offset) const | - |
12810 | { | - |
12811 | return d_func()->redirected(offset); | - |
12812 | } | - |
12813 | | - |
12814 | | - |
12815 | | - |
12816 | | - |
12817 | | - |
12818 | | - |
12819 | QPainter *QWidget::sharedPainter() const | - |
12820 | { | - |
12821 | | - |
12822 | if (!d_func()->redirectDev) | - |
12823 | return 0; | - |
12824 | | - |
12825 | QPainter *sp = d_func()->sharedPainter(); | - |
12826 | if (!sp || !sp->isActive()) | - |
12827 | return 0; | - |
12828 | | - |
12829 | if (sp->paintEngine()->paintDevice() != d_func()->redirectDev) | - |
12830 | return 0; | - |
12831 | | - |
12832 | return sp; | - |
12833 | } | - |
12834 | | - |
12835 | | - |
12836 | | - |
12837 | | - |
12838 | | - |
12839 | | - |
12840 | | - |
12841 | | - |
12842 | | - |
12843 | | - |
12844 | | - |
12845 | | - |
12846 | | - |
12847 | | - |
12848 | | - |
12849 | void QWidget::setMask(const QRegion &newMask) | - |
12850 | { | - |
12851 | Q_D(QWidget); | - |
12852 | | - |
12853 | d->createExtra(); | - |
12854 | if (newMask == d->extra->mask) | - |
12855 | return; | - |
12856 | | - |
12857 | #ifndef QT_NO_BACKINGSTORE | - |
12858 | const QRegion oldMask(d->extra->mask); | - |
12859 | #endif | - |
12860 | | - |
12861 | d->extra->mask = newMask; | - |
12862 | d->extra->hasMask = !newMask.isEmpty(); | - |
12863 | | - |
12864 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - |
12865 | if (!testAttribute(Qt::WA_WState_Created)) | - |
12866 | return; | - |
12867 | #endif | - |
12868 | | - |
12869 | d->setMask_sys(newMask); | - |
12870 | | - |
12871 | #ifndef QT_NO_BACKINGSTORE | - |
12872 | if (!isVisible()) | - |
12873 | return; | - |
12874 | | - |
12875 | if (!d->extra->hasMask) { | - |
12876 | | - |
12877 | QRegion expose(rect()); | - |
12878 | expose -= oldMask; | - |
12879 | if (!expose.isEmpty()) { | - |
12880 | d->setDirtyOpaqueRegion(); | - |
12881 | update(expose); | - |
12882 | } | - |
12883 | return; | - |
12884 | } | - |
12885 | | - |
12886 | if (!isWindow()) { | - |
12887 | | - |
12888 | QRegion parentExpose(rect()); | - |
12889 | parentExpose -= newMask; | - |
12890 | if (!parentExpose.isEmpty()) { | - |
12891 | d->setDirtyOpaqueRegion(); | - |
12892 | parentExpose.translate(data->crect.topLeft()); | - |
12893 | parentWidget()->update(parentExpose); | - |
12894 | } | - |
12895 | | - |
12896 | | - |
12897 | if (!oldMask.isEmpty()) | - |
12898 | update(newMask - oldMask); | - |
12899 | } | - |
12900 | #endif | - |
12901 | } | - |
12902 | | - |
12903 | void QWidgetPrivate::setMask_sys(const QRegion ®ion) | - |
12904 | { | - |
12905 | Q_Q(QWidget); | - |
12906 | if (QWindow *window = q->windowHandle()) | - |
12907 | window->setMask(region); | - |
12908 | } | - |
12909 | | - |
12910 | | - |
12911 | | - |
12912 | | - |
12913 | | - |
12914 | | - |
12915 | | - |
12916 | | - |
12917 | | - |
12918 | | - |
12919 | | - |
12920 | | - |
12921 | | - |
12922 | | - |
12923 | | - |
12924 | | - |
12925 | | - |
12926 | | - |
12927 | | - |
12928 | | - |
12929 | | - |
12930 | | - |
12931 | | - |
12932 | | - |
12933 | | - |
12934 | | - |
12935 | void QWidget::setMask(const QBitmap &bitmap) | - |
12936 | { | - |
12937 | setMask(QRegion(bitmap)); | - |
12938 | } | - |
12939 | | - |
12940 | | - |
12941 | | - |
12942 | | - |
12943 | | - |
12944 | | - |
12945 | | - |
12946 | | - |
12947 | void QWidget::clearMask() | - |
12948 | { | - |
12949 | setMask(QRegion()); | - |
12950 | } | - |
12951 | | - |
12952 | void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *newParent) | - |
12953 | { | - |
12954 | Q_ASSERT(widgetAsObject->isWidgetType()); | - |
12955 | Q_ASSERT(!newParent || newParent->isWidgetType()); | - |
12956 | QWidget *widget = static_cast<QWidget*>(widgetAsObject); | - |
12957 | widget->setParent(static_cast<QWidget*>(newParent)); | - |
12958 | } | - |
12959 | | - |
12960 | void QWidgetPrivate::setNetWmWindowTypes(bool skipIfMissing) | - |
12961 | { | - |
12962 | Q_Q(QWidget); | - |
12963 | | - |
12964 | if (!q->windowHandle()) | - |
12965 | return; | - |
12966 | | - |
12967 | int wmWindowType = 0; | - |
12968 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDesktop)) | - |
12969 | wmWindowType |= QXcbWindowFunctions::Desktop; | - |
12970 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDock)) | - |
12971 | wmWindowType |= QXcbWindowFunctions::Dock; | - |
12972 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolBar)) | - |
12973 | wmWindowType |= QXcbWindowFunctions::Toolbar; | - |
12974 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeMenu)) | - |
12975 | wmWindowType |= QXcbWindowFunctions::Menu; | - |
12976 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeUtility)) | - |
12977 | wmWindowType |= QXcbWindowFunctions::Utility; | - |
12978 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeSplash)) | - |
12979 | wmWindowType |= QXcbWindowFunctions::Splash; | - |
12980 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDialog)) | - |
12981 | wmWindowType |= QXcbWindowFunctions::Dialog; | - |
12982 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu)) | - |
12983 | wmWindowType |= QXcbWindowFunctions::DropDownMenu; | - |
12984 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypePopupMenu)) | - |
12985 | wmWindowType |= QXcbWindowFunctions::PopupMenu; | - |
12986 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolTip)) | - |
12987 | wmWindowType |= QXcbWindowFunctions::Tooltip; | - |
12988 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeNotification)) | - |
12989 | wmWindowType |= QXcbWindowFunctions::Notification; | - |
12990 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeCombo)) | - |
12991 | wmWindowType |= QXcbWindowFunctions::Combo; | - |
12992 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDND)) | - |
12993 | wmWindowType |= QXcbWindowFunctions::Dnd; | - |
12994 | | - |
12995 | if (wmWindowType == 0 && skipIfMissing) | - |
12996 | return; | - |
12997 | | - |
12998 | QXcbWindowFunctions::setWmWindowType(q->windowHandle(), static_cast<QXcbWindowFunctions::WmWindowType>(wmWindowType)); | - |
12999 | } | - |
13000 | | - |
13001 | #ifndef QT_NO_DEBUG_STREAM | - |
13002 | | - |
13003 | static inline void formatWidgetAttributes(QDebug debug, const QWidget *widget) | - |
13004 | { | - |
13005 | const QMetaObject *qtMo = qt_getEnumMetaObject(Qt::WA_AttributeCount); | - |
13006 | const QMetaEnum me = qtMo->enumerator(qtMo->indexOfEnumerator("WidgetAttribute")); | - |
13007 | debug << ", attributes=["; | - |
13008 | int count = 0; | - |
13009 | for (int a = 0; a < Qt::WA_AttributeCount; ++a) { | - |
13010 | if (widget->testAttribute(static_cast<Qt::WidgetAttribute>(a))) { | - |
13011 | if (count++) | - |
13012 | debug << ','; | - |
13013 | debug << me.valueToKey(a); | - |
13014 | } | - |
13015 | } | - |
13016 | debug << ']'; | - |
13017 | } | - |
13018 | | - |
13019 | QDebug operator<<(QDebug debug, const QWidget *widget) | - |
13020 | { | - |
13021 | const QDebugStateSaver saver(debug); | - |
13022 | debug.nospace(); | - |
13023 | if (widget) { | - |
13024 | debug << widget->metaObject()->className() << '(' << (const void *)widget; | - |
13025 | if (!widget->objectName().isEmpty()) | - |
13026 | debug << ", name=" << widget->objectName(); | - |
13027 | if (debug.verbosity() > 2) { | - |
13028 | const QRect geometry = widget->geometry(); | - |
13029 | const QRect frameGeometry = widget->frameGeometry(); | - |
13030 | if (widget->isVisible()) | - |
13031 | debug << ", visible"; | - |
13032 | if (!widget->isEnabled()) | - |
13033 | debug << ", disabled"; | - |
13034 | debug << ", states=" << widget->windowState() | - |
13035 | << ", type=" << widget->windowType() << ", flags=" << widget->windowFlags(); | - |
13036 | formatWidgetAttributes(debug, widget); | - |
13037 | if (widget->isWindow()) | - |
13038 | debug << ", window"; | - |
13039 | debug << ", " << geometry.width() << 'x' << geometry.height() | - |
13040 | << forcesign << geometry.x() << geometry.y() << noforcesign; | - |
13041 | if (frameGeometry != geometry) { | - |
13042 | const QMargins margins(geometry.x() - frameGeometry.x(), | - |
13043 | geometry.y() - frameGeometry.y(), | - |
13044 | frameGeometry.right() - geometry.right(), | - |
13045 | frameGeometry.bottom() - geometry.bottom()); | - |
13046 | debug << ", margins=" << margins; | - |
13047 | } | - |
13048 | debug << ", devicePixelRatio=" << widget->devicePixelRatioF(); | - |
13049 | if (const WId wid = widget->internalWinId()) | - |
13050 | debug << ", winId=0x" << hex << wid << dec; | - |
13051 | } | - |
13052 | debug << ')'; | - |
13053 | } else { | - |
13054 | debug << "QWidget(0x0)"; | - |
13055 | } | - |
13056 | return debug; | - |
13057 | } | - |
13058 | #endif // !QT_NO_DEBUG_STREAM | - |
13059 | | - |
13060 | | - |
13061 | | - |
13062 | | - |
13063 | | - |
13064 | | - |
13065 | | - |
13066 | | - |
13067 | | - |
13068 | | - |
13069 | | - |
13070 | | - |
13071 | | - |
13072 | | - |
13073 | | - |
13074 | | - |
13075 | | - |
13076 | | - |
13077 | | - |
13078 | | - |
13079 | | - |
13080 | | - |
13081 | | - |
13082 | | - |
13083 | | - |
13084 | | - |
13085 | | - |
13086 | | - |
13087 | | - |
13088 | | - |
13089 | | - |
13090 | | - |
13091 | | - |
13092 | | - |
13093 | | - |
13094 | | - |
13095 | | - |
13096 | | - |
13097 | | - |
13098 | | - |
13099 | QT_END_NAMESPACE | - |
13100 | | - |
13101 | #include "moc_qwidget.cpp" | - |
13102 | | - |
| | |