kernel/qwidget.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11static bool qt_enable_backingstore = true; -
12static inline bool qRectIntersects(const QRect &r1, const QRect &r2) -
13{ -
14 return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right()) && -
15 qMax(r1.top(), r2.top()) <= qMin(r1.bottom(), r2.bottom()));
-
16} -
17 -
18static inline bool hasBackingStoreSupport() -
19{ -
20 return true;
-
21} -
22 -
23 -
24 -
25 -
26 -
27extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); -
28extern QDesktopWidget *qt_desktopWidget; -
29QWidgetBackingStoreTracker::QWidgetBackingStoreTracker() -
30 : m_ptr(0) -
31{ -
32 -
33}
-
34 -
35QWidgetBackingStoreTracker::~QWidgetBackingStoreTracker() -
36{ -
37 delete m_ptr; -
38}
-
39 -
40 -
41 -
42 -
43 -
44 -
45 -
46void QWidgetBackingStoreTracker::create(QWidget *widget) -
47{ -
48 destroy(); -
49 m_ptr = new QWidgetBackingStore(widget); -
50}
-
51 -
52 -
53 -
54 -
55 -
56 -
57void QWidgetBackingStoreTracker::destroy() -
58{ -
59 delete m_ptr; -
60 m_ptr = 0; -
61 m_widgets.clear(); -
62}
-
63 -
64 -
65 -
66 -
67 -
68 -
69void QWidgetBackingStoreTracker::registerWidget(QWidget *w) -
70{ -
71 qt_noop(); -
72 qt_noop(); -
73 qt_noop(); -
74 m_widgets.insert(w); -
75}
-
76void QWidgetBackingStoreTracker::unregisterWidget(QWidget *w) -
77{ -
78 if (m_widgets.remove(w) && m_widgets.isEmpty()) {
-
79 delete m_ptr; -
80 m_ptr = 0; -
81 }
-
82}
-
83 -
84 -
85 -
86 -
87 -
88void QWidgetBackingStoreTracker::unregisterWidgetSubtree(QWidget *widget) -
89{ -
90 unregisterWidget(widget); -
91 for (QForeachContainer<__typeof__(widget->children())> _container_(widget->children()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QObject *child = *_container_.i;; __extension__ ({--_container_.brk; break;})) -
92 if (QWidget *childWidget = qobject_cast<QWidget *>(child))
-
93 unregisterWidgetSubtree(childWidget);
-
94}
-
95 -
96QWidgetPrivate::QWidgetPrivate(int version) -
97 : QObjectPrivate(version) -
98 , extra(0) -
99 , focus_next(0) -
100 , focus_prev(0) -
101 , focus_child(0) -
102 , layout(0) -
103 , needsFlush(0) -
104 , redirectDev(0) -
105 , widgetItem(0) -
106 , extraPaintEngine(0) -
107 , polished(0) -
108 , graphicsEffect(0) -
109 -
110 , imHints(Qt::ImhNone) -
111 -
112 , inheritedFontResolveMask(0) -
113 , inheritedPaletteResolveMask(0) -
114 , leftmargin(0) -
115 , topmargin(0) -
116 , rightmargin(0) -
117 , bottommargin(0) -
118 , leftLayoutItemMargin(0) -
119 , topLayoutItemMargin(0) -
120 , rightLayoutItemMargin(0) -
121 , bottomLayoutItemMargin(0) -
122 , hd(0) -
123 , size_policy(QSizePolicy::Preferred, QSizePolicy::Preferred) -
124 , fg_role(QPalette::NoRole) -
125 , bg_role(QPalette::NoRole) -
126 , dirtyOpaqueChildren(1) -
127 , isOpaque(0) -
128 , inDirtyList(0) -
129 , isScrolled(0) -
130 , isMoved(0) -
131 , usesDoubleBufferedGLContext(0) -
132 -
133 , inheritsInputMethodHints(0) -
134{ -
135 if (!(static_cast<QApplication *>(QCoreApplication::instance()))) {
-
136 QMessageLogger("kernel/qwidget.cpp", 285, __PRETTY_FUNCTION__).fatal("QWidget: Must construct a QApplication before a QPaintDevice"); -
137 return;
-
138 } -
139 -
140 if (version != QObjectPrivateVersion)
-
141 QMessageLogger("kernel/qwidget.cpp", 290, __PRETTY_FUNCTION__).fatal("Cannot mix incompatible Qt libraries");
-
142 -
143 isWidget = true; -
144 memset(high_attributes, 0, sizeof(high_attributes)); -
145}
-
146 -
147 -
148QWidgetPrivate::~QWidgetPrivate() -
149{ -
150 if (widgetItem)
-
151 widgetItem->wid = 0;
-
152 -
153 if (extra)
-
154 deleteExtra();
-
155 -
156 -
157 delete graphicsEffect; -
158 -
159}
-
160 -
161 -
162 -
163 -
164void QWidgetPrivate::scrollChildren(int dx, int dy) -
165{ -
166 QWidget * const q = q_func(); -
167 if (q->children().size() > 0) {
-
168 QPoint pd(dx, dy); -
169 QObjectList childObjects = q->children(); -
170 for (int i = 0; i < childObjects.size(); ++i) {
-
171 QWidget *w = qobject_cast<QWidget*>(childObjects.at(i)); -
172 if (w && !w->isWindow()) {
-
173 QPoint oldp = w->pos(); -
174 QRect r(w->pos() + pd, w->size()); -
175 w->data->crect = r; -
176 if (w->testAttribute(Qt::WA_WState_Created))
-
177 w->d_func()->setWSGeometry();
-
178 w->d_func()->setDirtyOpaqueRegion(); -
179 QMoveEvent e(r.topLeft(), oldp); -
180 QApplication::sendEvent(w, &e); -
181 }
-
182 }
-
183 }
-
184}
-
185 -
186void QWidgetPrivate::updateWidgetTransform() -
187{ -
188 QWidget * const q = q_func(); -
189 if (q == (static_cast<QGuiApplication *>(QCoreApplication::instance()))->focusObject()) {
-
190 QTransform t; -
191 QPoint p = q->mapTo(q->topLevelWidget(), QPoint(0,0)); -
192 t.translate(p.x(), p.y()); -
193 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->setInputItemTransform(t); -
194 }
-
195}
-
196bool QWidget::autoFillBackground() const -
197{ -
198 const QWidgetPrivate * const d = d_func(); -
199 return d->extra && d->extra->autoFillBackground;
-
200} -
201 -
202void QWidget::setAutoFillBackground(bool enabled) -
203{ -
204 QWidgetPrivate * const d = d_func(); -
205 if (!d->extra)
-
206 d->createExtra();
-
207 if (d->extra->autoFillBackground == enabled)
-
208 return;
-
209 -
210 d->extra->autoFillBackground = enabled; -
211 d->updateIsOpaque(); -
212 update(); -
213 d->updateIsOpaque(); -
214}
-
215QWidgetMapper *QWidgetPrivate::mapper = 0; -
216QWidgetSet *QWidgetPrivate::allWidgets = 0; -
217 -
218 -
219 -
220 -
221 -
222 -
223QRegion qt_dirtyRegion(QWidget *widget) -
224{ -
225 if (!widget)
-
226 return QRegion();
-
227 -
228 QWidgetBackingStore *bs = qt_widget_private(widget)->maybeBackingStore(); -
229 if (!bs)
-
230 return QRegion();
-
231 -
232 return bs->dirtyRegion(widget);
-
233} -
234struct QWidgetExceptionCleaner -
235{ -
236 -
237 static inline void cleanup(QWidget *that, QWidgetPrivate *d) -
238 { -
239 -
240 (void)that;; -
241 (void)d;; -
242 }
-
243}; -
244QWidget::QWidget(QWidget *parent, Qt::WindowFlags f) -
245 : QObject(*new QWidgetPrivate, 0), QPaintDevice() -
246{ -
247 if (true) {
-
248 d_func()->init(parent, f); -
249 } else {
-
250 QWidgetExceptionCleaner::cleanup(this, d_func()); -
251 qt_noop(); -
252 }
-
253} -
254 -
255 -
256 -
257 -
258QWidget::QWidget(QWidgetPrivate &dd, QWidget* parent, Qt::WindowFlags f) -
259 : QObject(dd, 0), QPaintDevice() -
260{ -
261 QWidgetPrivate * const d = d_func(); -
262 if (true) {
-
263 d->init(parent, f); -
264 } else {
-
265 QWidgetExceptionCleaner::cleanup(this, d_func()); -
266 qt_noop(); -
267 }
-
268} -
269 -
270 -
271 -
272 -
273int QWidget::devType() const -
274{ -
275 return QInternal::Widget;
-
276} -
277 -
278 -
279 -
280void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w) -
281{ -
282 bool customize = (flags & (Qt::CustomizeWindowHint -
283 | Qt::FramelessWindowHint -
284 | Qt::WindowTitleHint -
285 | Qt::WindowSystemMenuHint -
286 | Qt::WindowMinimizeButtonHint -
287 | Qt::WindowMaximizeButtonHint -
288 | Qt::WindowCloseButtonHint -
289 | Qt::WindowContextHelpButtonHint)); -
290 -
291 uint type = (flags & Qt::WindowType_Mask); -
292 -
293 if ((type == Qt::Widget || type == Qt::SubWindow) && w && !w->parent()) {
-
294 type = Qt::Window; -
295 flags |= Qt::Window; -
296 }
-
297 -
298 if (flags & Qt::CustomizeWindowHint) {
-
299 -
300 -
301 -
302 -
303 -
304 if (flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowContextHelpButtonHint)) {
-
305 flags |= Qt::WindowSystemMenuHint; -
306 -
307 -
308 -
309 -
310 flags |= Qt::WindowTitleHint; -
311 flags &= ~Qt::FramelessWindowHint; -
312 }
-
313 } else if (customize && !(flags & Qt::FramelessWindowHint)) {
-
314 -
315 -
316 -
317 flags |= Qt::WindowSystemMenuHint; -
318 flags |= Qt::WindowTitleHint; -
319 }
-
320 if (customize)
-
321 ;
-
322 else if (type == Qt::Dialog || type == Qt::Sheet)
-
323 -
324 flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint;
-
325 -
326 -
327 -
328 else if (type == Qt::Tool)
-
329 flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
-
330 else -
331 flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | -
332 Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint;
-
333 -
334} -
335 -
336void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) -
337{ -
338 QWidget * const q = q_func(); -
339 if (!qobject_cast<QApplication *>(QCoreApplication::instance()))
-
340 QMessageLogger("kernel/qwidget.cpp", 1092, __PRETTY_FUNCTION__).fatal("QWidget: Cannot create a QWidget without QApplication");
-
341 -
342 qt_noop(); -
343 if (allWidgets)
-
344 allWidgets->insert(q);
-
345 -
346 QWidget *desktopWidget = 0; -
347 if (parentWidget && parentWidget->windowType() == Qt::Desktop) {
-
348 desktopWidget = parentWidget; -
349 parentWidget = 0; -
350 }
-
351 -
352 q->data = &data; -
353 -
354 -
355 if (!parent) {
-
356 qt_noop(); -
357 -
358 }
-
359 if (desktopWidget) {
-
360 const int screen = desktopWidget->d_func()->topData()->screenIndex; -
361 if (QWindow *window = q->windowHandle())
-
362 window->setScreen(QGuiApplication::screens().value(screen, 0));
-
363 }
-
364 -
365 data.fstrut_dirty = true; -
366 -
367 data.winid = 0; -
368 data.widget_attributes = 0; -
369 data.window_flags = f; -
370 data.window_state = 0; -
371 data.focus_policy = 0; -
372 data.context_menu_policy = Qt::DefaultContextMenu; -
373 data.window_modality = Qt::NonModal; -
374 -
375 data.sizehint_forced = 0; -
376 data.is_closing = 0; -
377 data.in_show = 0; -
378 data.in_set_window_state = 0; -
379 data.in_destructor = false; -
380 -
381 -
382 if (f & Qt::MSWindowsOwnDC)
-
383 q->setAttribute(Qt::WA_NativeWindow);
-
384 -
385 -
386 -
387 -
388 -
389 q->setAttribute(Qt::WA_QuitOnClose); -
390 adjustQuitOnCloseAttribute(); -
391 -
392 q->setAttribute(Qt::WA_WState_Hidden); -
393 -
394 -
395 data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480);
-
396 focus_next = focus_prev = q; -
397 -
398 if ((f & Qt::WindowType_Mask) == Qt::Desktop)
-
399 q->create();
-
400 else if (parentWidget)
-
401 q->setParent(parentWidget, data.window_flags);
-
402 else { -
403 adjustFlags(data.window_flags, q); -
404 resolveLayoutDirection(); -
405 -
406 const QBrush &background = q->palette().brush(QPalette::Window); -
407 setOpaque(q->isWindow() && background.style() != Qt::NoBrush && background.isOpaque()); -
408 }
-
409 data.fnt = QFont(data.fnt, q); -
410 -
411 -
412 -
413 -
414 q->setAttribute(Qt::WA_PendingMoveEvent); -
415 q->setAttribute(Qt::WA_PendingResizeEvent); -
416 -
417 if (++QWidgetPrivate::instanceCounter > QWidgetPrivate::maxInstances)
-
418 QWidgetPrivate::maxInstances = QWidgetPrivate::instanceCounter;
-
419 -
420 if (QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation))
-
421 q->create();
-
422 -
423 QEvent e(QEvent::Create); -
424 QApplication::sendEvent(q, &e); -
425 QApplication::postEvent(q, new QEvent(QEvent::PolishRequest)); -
426 -
427 extraPaintEngine = 0; -
428}
-
429 -
430 -
431 -
432void QWidgetPrivate::createRecursively() -
433{ -
434 QWidget * const q = q_func(); -
435 q->create(0, true, true); -
436 for (int i = 0; i < children.size(); ++i) {
-
437 QWidget *child = qobject_cast<QWidget *>(children.at(i)); -
438 if (child && !child->isHidden() && !child->isWindow() && !child->testAttribute(Qt::WA_WState_Created))
-
439 child->d_func()->createRecursively();
-
440 }
-
441}
-
442void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) -
443{ -
444 QWidgetPrivate * const d = d_func(); -
445 if (testAttribute(Qt::WA_WState_Created) && window == 0 && internalWinId())
-
446 return;
-
447 -
448 if (d->data.in_destructor)
-
449 return;
-
450 -
451 Qt::WindowType type = windowType(); -
452 Qt::WindowFlags &flags = data->window_flags; -
453 -
454 if ((type == Qt::Widget || type == Qt::SubWindow) && !parentWidget()) {
-
455 type = Qt::Window; -
456 flags |= Qt::Window; -
457 }
-
458 -
459 if (QWidget *parent = parentWidget()) {
-
460 if (type & Qt::Window) {
-
461 if (!parent->testAttribute(Qt::WA_WState_Created))
-
462 parent->createWinId();
-
463 } else if (testAttribute(Qt::WA_NativeWindow) && !parent->internalWinId()
-
464 && !testAttribute(Qt::WA_DontCreateNativeAncestors)) {
-
465 -
466 -
467 -
468 d->createWinId(window); -
469 -
470 qt_noop(); -
471 qt_noop(); -
472 return;
-
473 } -
474 } -
475 -
476 -
477 static int paintOnScreenEnv = -1; -
478 if (paintOnScreenEnv == -1)
-
479 paintOnScreenEnv = qgetenv("QT_ONSCREEN_PAINT").toInt() > 0 ? 1 : 0;
-
480 if (paintOnScreenEnv == 1)
-
481 setAttribute(Qt::WA_PaintOnScreen);
-
482 -
483 if (QApplicationPrivate::testAttribute(Qt::AA_NativeWindows))
-
484 setAttribute(Qt::WA_NativeWindow);
-
485 d->updateIsOpaque(); -
486 -
487 setAttribute(Qt::WA_WState_Created); -
488 d->create_sys(window, initializeWindow, destroyOldWindow); -
489 -
490 -
491 if (isWindow() && windowType() != Qt::Desktop) {
-
492 d->topData()->backingStoreTracker.destroy(); -
493 if (hasBackingStoreSupport())
-
494 d->topData()->backingStoreTracker.create(this);
-
495 }
-
496 -
497 d->setModal_sys(); -
498 -
499 if (!isWindow() && parentWidget() && parentWidget()->testAttribute(Qt::WA_DropSiteRegistered))
-
500 setAttribute(Qt::WA_DropSiteRegistered, true);
-
501 -
502 -
503 -
504 -
505 -
506 -
507 -
508 if (testAttribute(Qt::WA_SetWindowIcon))
-
509 d->setWindowIcon_sys();
-
510 -
511 if (isWindow() && !d->topData()->iconText.isEmpty())
-
512 d->setWindowIconText_helper(d->topData()->iconText);
-
513 if (isWindow() && !d->topData()->caption.isEmpty())
-
514 d->setWindowTitle_helper(d->topData()->caption);
-
515 if (windowType() != Qt::Desktop) {
-
516 d->updateSystemBackground(); -
517 -
518 if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon))
-
519 d->setWindowIcon_sys();
-
520 }
-
521 -
522 -
523 -
524 -
525 -
526 -
527 d->updateFrameStrut(); -
528}
-
529QWidget::~QWidget() -
530{ -
531 QWidgetPrivate * const d = d_func(); -
532 d->data.in_destructor = true; -
533 -
534 -
535 -
536 -
537 -
538 -
539 -
540 for (QForeachContainer<__typeof__(d->gestureContext.keys())> _container_(d->gestureContext.keys()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (Qt::GestureType type = *_container_.i;; __extension__ ({--_container_.brk; break;})) -
541 ungrabGesture(type);
executed: ungrabGesture(type);
Execution Count:5414
5414
542 -
543 -
544 -
545 d->registerDropSite(false); -
546 -
547 -
548 -
549 for (int i = 0; i < d->actions.size(); ++i) {
evaluated: i < d->actions.size()
TRUEFALSE
yes
Evaluation Count:3290
yes
Evaluation Count:41486
3290-41486
550 QActionPrivate *apriv = d->actions.at(i)->d_func(); -
551 apriv->widgets.removeAll(this); -
552 }
executed: }
Execution Count:3290
3290
553 d->actions.clear(); -
554 -
555 -
556 -
557 -
558 -
559 if (!QApplicationPrivate::is_app_closing && testAttribute(Qt::WA_GrabbedShortcut))
evaluated: !QApplicationPrivate::is_app_closing
TRUEFALSE
yes
Evaluation Count:41270
yes
Evaluation Count:216
evaluated: testAttribute(Qt::WA_GrabbedShortcut)
TRUEFALSE
yes
Evaluation Count:1479
yes
Evaluation Count:39791
216-41270
560 (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(0, this, QKeySequence());
executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(0, this, QKeySequence());
Execution Count:1479
1479
561 -
562 -
563 -
564 delete d->layout; -
565 d->layout = 0; -
566 -
567 -
568 qt_noop(); -
569 qt_noop(); -
570 -
571 if (d->focus_next != this) {
evaluated: d->focus_next != this
TRUEFALSE
yes
Evaluation Count:36280
yes
Evaluation Count:5206
5206-36280
572 d->focus_next->d_func()->focus_prev = d->focus_prev; -
573 d->focus_prev->d_func()->focus_next = d->focus_next; -
574 d->focus_next = d->focus_prev = 0; -
575 }
executed: }
Execution Count:36280
36280
576 -
577 -
578 if (true) {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:41486
no
Evaluation Count:0
0-41486
579 -
580 const QWidget* w = this; -
581 while (w->d_func()->extra && w->d_func()->extra->focus_proxy)
evaluated: w->d_func()->extra
TRUEFALSE
yes
Evaluation Count:18077
yes
Evaluation Count:29703
evaluated: w->d_func()->extra->focus_proxy
TRUEFALSE
yes
Evaluation Count:6294
yes
Evaluation Count:11783
6294-29703
582 w = w->d_func()->extra->focus_proxy;
executed: w = w->d_func()->extra->focus_proxy;
Execution Count:6294
6294
583 QWidget *window = w->window(); -
584 QWExtra *e = window ? window->d_func()->extra : 0;
partially evaluated: window
TRUEFALSE
yes
Evaluation Count:41486
no
Evaluation Count:0
0-41486
585 if (!e || !e->proxyWidget)
evaluated: !e
TRUEFALSE
yes
Evaluation Count:10225
yes
Evaluation Count:31261
evaluated: !e->proxyWidget
TRUEFALSE
yes
Evaluation Count:31257
yes
Evaluation Count:4
4-31261
586 -
587 clearFocus();
executed: clearFocus();
Execution Count:41482
41482
588 } else {
executed: }
Execution Count:41486
41486
589 -
590 }
never executed: }
0
591 -
592 d->setDirtyOpaqueRegion(); -
593 -
594 if (isWindow() && isVisible() && internalWinId()) {
evaluated: isWindow()
TRUEFALSE
yes
Evaluation Count:5206
yes
Evaluation Count:36280
evaluated: isVisible()
TRUEFALSE
yes
Evaluation Count:2096
yes
Evaluation Count:3110
partially evaluated: internalWinId()
TRUEFALSE
yes
Evaluation Count:2096
no
Evaluation Count:0
0-36280
595 if (true) {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:2096
no
Evaluation Count:0
0-2096
596 d->close_helper(QWidgetPrivate::CloseNoEvent); -
597 } else {
executed: }
Execution Count:2096
2096
598 -
599 if (true) {
never evaluated: true
0
600 hide(); -
601 } else {
never executed: }
0
602 -
603 }
never executed: }
0
604 } -
605 } -
606 -
607 -
608 -
609 -
610 -
611 -
612 else if (isVisible()) {
evaluated: isVisible()
TRUEFALSE
yes
Evaluation Count:619
yes
Evaluation Count:38771
619-38771
613 (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->sendSyntheticEnterLeave(this); -
614 }
executed: }
Execution Count:619
619
615 -
616 if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
evaluated: QWidgetBackingStore *bs = d->maybeBackingStore()
TRUEFALSE
yes
Evaluation Count:19169
yes
Evaluation Count:22317
19169-22317
617 bs->removeDirtyWidget(this); -
618 if (testAttribute(Qt::WA_StaticContents))
evaluated: testAttribute(Qt::WA_StaticContents)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:19166
3-19166
619 bs->removeStaticWidget(this);
executed: bs->removeStaticWidget(this);
Execution Count:3
3
620 }
executed: }
Execution Count:19169
19169
621 -
622 delete d->needsFlush; -
623 d->needsFlush = 0; -
624 -
625 -
626 -
627 bool blocked = d->blockSig; -
628 d->blockSig = 0; -
629 -
630 if (d->isSignalConnected(0)) {
evaluated: d->isSignalConnected(0)
TRUEFALSE
yes
Evaluation Count:3688
yes
Evaluation Count:37798
3688-37798
631 if (true) {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:3688
no
Evaluation Count:0
0-3688
632 destroyed(this); -
633 } else {
executed: }
Execution Count:3688
3688
634 -
635 -
636 QMessageLogger("kernel/qwidget.cpp", 14431451, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); -
637 qt_noop(); -
638 }
never executed: }
0
639 } -
640 -
641 if (d->declarativeData) {
partially evaluated: d->declarativeData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:41486
0-41486
642 QAbstractDeclarativeData::destroyed(d->declarativeData, this); -
643 d->declarativeData = 0; -
644 }
never executed: }
0
645 -
646 d->blockSig = blocked; -
647 if (!d->children.isEmpty())
evaluated: !d->children.isEmpty()
TRUEFALSE
yes
Evaluation Count:18909
yes
Evaluation Count:22577
18909-22577
648 d->deleteChildren();
executed: d->deleteChildren();
Execution Count:18909
18909
649 -
650 QApplication::removePostedEvents(this); -
651 -
652 if (true) {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:41486
no
Evaluation Count:0
0-41486
653 destroy(); -
654 } else {
executed: }
Execution Count:41486
41486
655 -
656 }
never executed: }
0
657 --QWidgetPrivate::instanceCounter; -
658 -
659 if (QWidgetPrivate::allWidgets)
evaluated: QWidgetPrivate::allWidgets
TRUEFALSE
yes
Evaluation Count:41270
yes
Evaluation Count:216
216-41270
660 QWidgetPrivate::allWidgets->remove(this);
executed: QWidgetPrivate::allWidgets->remove(this);
Execution Count:41270
41270
661 -
662 if (true) {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:41486
no
Evaluation Count:0
0-41486
663 QEvent e(QEvent::Destroy); -
664 QCoreApplication::sendEvent(this, &e); -
665 } else {
executed: }
Execution Count:41486
41486
666 -
667 }
never executed: }
0
668} -
669 -
670int QWidgetPrivate::instanceCounter = 0; -
671int QWidgetPrivate::maxInstances = 0; -
672 -
673void QWidgetPrivate::setWinId(WId id) -
674{ -
675 QWidget * const q = q_func(); -
676 -
677 -
678 -
679 -
680 -
681 bool userDesktopWidget = qt_desktopWidget != 0 && qt_desktopWidget != q && q->windowType() == Qt::Desktop;
-
682 if (mapper && data.winid && !userDesktopWidget) {
-
683 mapper->remove(data.winid); -
684 }
-
685 -
686 const WId oldWinId = data.winid; -
687 -
688 data.winid = id; -
689 -
690 -
691 -
692 if (mapper && id && !userDesktopWidget) {
-
693 mapper->insert(data.winid, q); -
694 }
-
695 -
696 if(oldWinId != id) {
-
697 QEvent e(QEvent::WinIdChange); -
698 QCoreApplication::sendEvent(q, &e); -
699 }
-
700}
-
701 -
702void QWidgetPrivate::createTLExtra() -
703{ -
704 if (!extra)
-
705 createExtra();
-
706 if (!extra->topextra) {
-
707 QTLWExtra* x = extra->topextra = new QTLWExtra; -
708 x->icon = 0; -
709 x->backingStore = 0; -
710 x->sharedPainter = 0; -
711 x->incw = x->inch = 0; -
712 x->basew = x->baseh = 0; -
713 x->frameStrut.setCoords(0, 0, 0, 0); -
714 x->normalGeometry = QRect(0,0,-1,-1); -
715 x->savedFlags = 0; -
716 x->opacity = 255; -
717 x->posIncludesFrame = 0; -
718 x->sizeAdjusted = false; -
719 x->inTopLevelResize = false; -
720 x->inRepaint = false; -
721 x->embedded = 0; -
722 -
723 -
724 -
725 createTLSysExtra(); -
726 -
727 -
728 -
729 -
730 }
-
731}
-
732 -
733 -
734 -
735 -
736 -
737 -
738void QWidgetPrivate::createExtra() -
739{ -
740 if (!extra) {
-
741 extra = new QWExtra; -
742 extra->glContext = 0; -
743 extra->topextra = 0; -
744 -
745 extra->proxyWidget = 0; -
746 -
747 -
748 extra->curs = 0; -
749 -
750 extra->minw = 0; -
751 extra->minh = 0; -
752 extra->maxw = ((1<<24)-1); -
753 extra->maxh = ((1<<24)-1); -
754 extra->customDpiX = 0; -
755 extra->customDpiY = 0; -
756 extra->explicitMinSize = 0; -
757 extra->explicitMaxSize = 0; -
758 extra->autoFillBackground = 0; -
759 extra->nativeChildrenForced = 0; -
760 extra->inRenderWithPainter = 0; -
761 extra->hasMask = 0; -
762 createSysExtra(); -
763 -
764 -
765 -
766 -
767 }
-
768}
-
769 -
770 -
771 -
772 -
773 -
774 -
775 -
776void QWidgetPrivate::deleteExtra() -
777{ -
778 if (extra) {
-
779 -
780 delete extra->curs; -
781 -
782 deleteSysExtra(); -
783 -
784 -
785 if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(extra->style))
-
786 proxy->deref();
-
787 -
788 if (extra->topextra) {
-
789 deleteTLSysExtra(); -
790 -
791 delete extra->topextra->icon; -
792 delete extra->topextra; -
793 }
-
794 delete extra; -
795 -
796 extra = 0; -
797 }
-
798}
-
799 -
800 -
801 -
802 -
803 -
804 -
805bool QWidgetPrivate::isOverlapped(const QRect &rect) const -
806{ -
807 const QWidget * const q = q_func(); -
808 -
809 const QWidget *w = q; -
810 QRect r = rect; -
811 while (w) {
-
812 if (w->isWindow())
-
813 return false;
-
814 QWidgetPrivate *pd = w->parentWidget()->d_func(); -
815 bool above = false; -
816 for (int i = 0; i < pd->children.size(); ++i) {
-
817 QWidget *sibling = qobject_cast<QWidget *>(pd->children.at(i)); -
818 if (!sibling || !sibling->isVisible() || sibling->isWindow())
-
819 continue;
-
820 if (!above) {
-
821 above = (sibling == w); -
822 continue;
-
823 } -
824 -
825 if (qRectIntersects(sibling->d_func()->effectiveRectFor(sibling->data->crect), r)) {
-
826 const QWExtra *siblingExtra = sibling->d_func()->extra; -
827 if (siblingExtra && siblingExtra->hasMask && !sibling->d_func()->graphicsEffect
-
828 && !siblingExtra->mask.translated(sibling->data->crect.topLeft()).intersects(r)) {
-
829 continue;
-
830 } -
831 return true;
-
832 } -
833 }
-
834 w = w->parentWidget(); -
835 r.translate(pd->data.crect.topLeft()); -
836 }
-
837 return false;
-
838} -
839 -
840void QWidgetPrivate::syncBackingStore() -
841{ -
842 if (paintOnScreen()) {
-
843 repaint_sys(dirty); -
844 dirty = QRegion(); -
845 } else if (QWidgetBackingStore *bs = maybeBackingStore()) {
-
846 bs->sync(); -
847 }
-
848} -
849 -
850void QWidgetPrivate::syncBackingStore(const QRegion &region) -
851{ -
852 if (paintOnScreen())
-
853 repaint_sys(region);
-
854 else if (QWidgetBackingStore *bs = maybeBackingStore()) {
-
855 bs->sync(q_func(), region); -
856 }
-
857} -
858 -
859void QWidgetPrivate::setUpdatesEnabled_helper(bool enable) -
860{ -
861 QWidget * const q = q_func(); -
862 -
863 if (enable && !q->isWindow() && q->parentWidget() && !q->parentWidget()->updatesEnabled())
-
864 return;
-
865 -
866 if (enable != q->testAttribute(Qt::WA_UpdatesDisabled))
-
867 return;
-
868 -
869 q->setAttribute(Qt::WA_UpdatesDisabled, !enable); -
870 if (enable)
-
871 q->update();
-
872 -
873 Qt::WidgetAttribute attribute = enable ? Qt::WA_ForceUpdatesDisabled : Qt::WA_UpdatesDisabled;
-
874 for (int i = 0; i < children.size(); ++i) {
-
875 QWidget *w = qobject_cast<QWidget *>(children.at(i)); -
876 if (w && !w->isWindow() && !w->testAttribute(attribute))
-
877 w->d_func()->setUpdatesEnabled_helper(enable);
-
878 }
-
879}
-
880void QWidgetPrivate::propagatePaletteChange() -
881{ -
882 QWidget * const q = q_func(); -
883 -
884 -
885 if (!q->parentWidget() && extra && extra->proxyWidget) {
-
886 QGraphicsProxyWidget *p = extra->proxyWidget; -
887 inheritedPaletteResolveMask = p->d_func()->inheritedPaletteResolveMask | p->palette().resolve(); -
888 } else
-
889 -
890 if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
-
891 inheritedPaletteResolveMask = 0; -
892 }
-
893 int mask = data.pal.resolve() | inheritedPaletteResolveMask; -
894 -
895 QEvent pc(QEvent::PaletteChange); -
896 QApplication::sendEvent(q, &pc); -
897 for (int i = 0; i < children.size(); ++i) {
-
898 QWidget *w = qobject_cast<QWidget*>(children.at(i)); -
899 if (w && !w->testAttribute(Qt::WA_StyleSheet)
-
900 && (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) {
-
901 QWidgetPrivate *wd = w->d_func(); -
902 wd->inheritedPaletteResolveMask = mask; -
903 wd->resolvePalette(); -
904 }
-
905 }
-
906}
-
907 -
908 -
909 -
910 -
911QRect QWidgetPrivate::clipRect() const -
912{ -
913 const QWidget * const q = q_func(); -
914 const QWidget * w = q; -
915 if (!w->isVisible())
-
916 return QRect();
-
917 QRect r = effectiveRectFor(q->rect()); -
918 int ox = 0; -
919 int oy = 0; -
920 while (w
-
921 && w->isVisible()
-
922 && !w->isWindow()
-
923 && w->parentWidget()) {
-
924 ox -= w->x(); -
925 oy -= w->y(); -
926 w = w->parentWidget(); -
927 r &= QRect(ox, oy, w->width(), w->height()); -
928 }
-
929 return r;
-
930} -
931 -
932 -
933 -
934 -
935QRegion QWidgetPrivate::clipRegion() const -
936{ -
937 const QWidget * const q = q_func(); -
938 if (!q->isVisible())
-
939 return QRegion();
-
940 QRegion r(q->rect()); -
941 const QWidget * w = q; -
942 const QWidget *ignoreUpTo; -
943 int ox = 0; -
944 int oy = 0; -
945 while (w
-
946 && w->isVisible()
-
947 && !w->isWindow()
-
948 && w->parentWidget()) {
-
949 ox -= w->x(); -
950 oy -= w->y(); -
951 ignoreUpTo = w; -
952 w = w->parentWidget(); -
953 r &= QRegion(ox, oy, w->width(), w->height()); -
954 -
955 int i = 0; -
956 while(w->d_func()->children.at(i++) != static_cast<const QObject *>(ignoreUpTo))
-
957 ;
-
958 for ( ; i < w->d_func()->children.size(); ++i) {
-
959 if(QWidget *sibling = qobject_cast<QWidget *>(w->d_func()->children.at(i))) {
-
960 if(sibling->isVisible() && !sibling->isWindow()) {
-
961 QRect siblingRect(ox+sibling->x(), oy+sibling->y(), -
962 sibling->width(), sibling->height()); -
963 if (qRectIntersects(siblingRect, q->rect()))
-
964 r -= QRegion(siblingRect);
-
965 }
-
966 }
-
967 }
-
968 }
-
969 return r;
-
970} -
971 -
972void QWidgetPrivate::setSystemClip(QPaintDevice *paintDevice, const QRegion &region) -
973{ -
974 -
975 -
976 -
977 QPaintEngine *paintEngine = paintDevice->paintEngine(); -
978 -
979 -
980 -
981 -
982 -
983 -
984 -
985 paintEngine->d_func()->systemClip = region; -
986 -
987}
-
988 -
989 -
990void QWidgetPrivate::invalidateGraphicsEffectsRecursively() -
991{ -
992 QWidget * const q = q_func(); -
993 QWidget *w = q; -
994 do { -
995 if (w->graphicsEffect()) {
-
996 QWidgetEffectSourcePrivate *sourced = -
997 static_cast<QWidgetEffectSourcePrivate *>(w->graphicsEffect()->source()->d_func()); -
998 if (!sourced->updateDueToGraphicsEffect)
-
999 w->graphicsEffect()->source()->d_func()->invalidateCache();
-
1000 }
-
1001 w = w->parentWidget(); -
1002 } while (w);
-
1003}
-
1004 -
1005 -
1006void QWidgetPrivate::setDirtyOpaqueRegion() -
1007{ -
1008 QWidget * const q = q_func(); -
1009 -
1010 dirtyOpaqueChildren = true; -
1011 -
1012 -
1013 invalidateGraphicsEffectsRecursively(); -
1014 -
1015 -
1016 if (q->isWindow())
-
1017 return;
-
1018 -
1019 QWidget *parent = q->parentWidget(); -
1020 if (!parent)
-
1021 return;
-
1022 -
1023 -
1024 QWidgetPrivate *pd = parent->d_func(); -
1025 if (!pd->dirtyOpaqueChildren)
-
1026 pd->setDirtyOpaqueRegion();
-
1027}
-
1028 -
1029const QRegion &QWidgetPrivate::getOpaqueChildren() const -
1030{ -
1031 if (!dirtyOpaqueChildren)
-
1032 return opaqueChildren;
-
1033 -
1034 QWidgetPrivate *that = const_cast<QWidgetPrivate*>(this); -
1035 that->opaqueChildren = QRegion(); -
1036 -
1037 for (int i = 0; i < children.size(); ++i) {
-
1038 QWidget *child = qobject_cast<QWidget *>(children.at(i)); -
1039 if (!child || !child->isVisible() || child->isWindow())
-
1040 continue;
-
1041 -
1042 const QPoint offset = child->geometry().topLeft(); -
1043 QWidgetPrivate *childd = child->d_func(); -
1044 QRegion r = childd->isOpaque ? child->rect() : childd->getOpaqueChildren();
-
1045 if (childd->extra && childd->extra->hasMask)
-
1046 r &= childd->extra->mask;
-
1047 if (r.isEmpty())
-
1048 continue;
-
1049 r.translate(offset); -
1050 that->opaqueChildren += r; -
1051 }
-
1052 -
1053 that->opaqueChildren &= q_func()->rect(); -
1054 that->dirtyOpaqueChildren = false; -
1055 -
1056 return that->opaqueChildren;
-
1057} -
1058 -
1059void QWidgetPrivate::subtractOpaqueChildren(QRegion &source, const QRect &clipRect) const -
1060{ -
1061 if (children.isEmpty() || clipRect.isEmpty())
-
1062 return;
-
1063 -
1064 const QRegion &r = getOpaqueChildren(); -
1065 if (!r.isEmpty())
-
1066 source -= (r & clipRect);
-
1067}
-
1068 -
1069 -
1070void QWidgetPrivate::subtractOpaqueSiblings(QRegion &sourceRegion, bool *hasDirtySiblingsAbove, -
1071 bool alsoNonOpaque) const -
1072{ -
1073 const QWidget * const q = q_func(); -
1074 static int disableSubtractOpaqueSiblings = qgetenv("QT_NO_SUBTRACTOPAQUESIBLINGS").toInt(); -
1075 if (disableSubtractOpaqueSiblings || q->isWindow())
-
1076 return;
-
1077 -
1078 -
1079 -
1080 -
1081 -
1082 -
1083 QRect clipBoundingRect; -
1084 bool dirtyClipBoundingRect = true; -
1085 -
1086 QRegion parentClip; -
1087 bool dirtyParentClip = true; -
1088 -
1089 QPoint parentOffset = data.crect.topLeft(); -
1090 -
1091 const QWidget *w = q; -
1092 -
1093 while (w) {
-
1094 if (w->isWindow())
-
1095 break;
-
1096 QWidgetPrivate *pd = w->parentWidget()->d_func(); -
1097 const int myIndex = pd->children.indexOf(const_cast<QWidget *>(w)); -
1098 const QRect widgetGeometry = w->d_func()->effectiveRectFor(w->data->crect); -
1099 for (int i = myIndex + 1; i < pd->children.size(); ++i) {
-
1100 QWidget *sibling = qobject_cast<QWidget *>(pd->children.at(i)); -
1101 if (!sibling || !sibling->isVisible() || sibling->isWindow())
-
1102 continue;
-
1103 -
1104 const QRect siblingGeometry = sibling->d_func()->effectiveRectFor(sibling->data->crect); -
1105 if (!qRectIntersects(siblingGeometry, widgetGeometry))
-
1106 continue;
-
1107 -
1108 if (dirtyClipBoundingRect) {
-
1109 clipBoundingRect = sourceRegion.boundingRect(); -
1110 dirtyClipBoundingRect = false; -
1111 }
-
1112 -
1113 if (!qRectIntersects(siblingGeometry, clipBoundingRect.translated(parentOffset)))
-
1114 continue;
-
1115 -
1116 if (dirtyParentClip) {
-
1117 parentClip = sourceRegion.translated(parentOffset); -
1118 dirtyParentClip = false; -
1119 }
-
1120 -
1121 const QPoint siblingPos(sibling->data->crect.topLeft()); -
1122 const QRect siblingClipRect(sibling->d_func()->clipRect()); -
1123 QRegion siblingDirty(parentClip); -
1124 siblingDirty &= (siblingClipRect.translated(siblingPos)); -
1125 const bool hasMask = sibling->d_func()->extra && sibling->d_func()->extra->hasMask
-
1126 && !sibling->d_func()->graphicsEffect;
-
1127 if (hasMask)
-
1128 siblingDirty &= sibling->d_func()->extra->mask.translated(siblingPos);
-
1129 if (siblingDirty.isEmpty())
-
1130 continue;
-
1131 -
1132 if (sibling->d_func()->isOpaque || alsoNonOpaque) {
-
1133 if (hasMask) {
-
1134 siblingDirty.translate(-parentOffset); -
1135 sourceRegion -= siblingDirty; -
1136 } else {
-
1137 sourceRegion -= siblingGeometry.translated(-parentOffset); -
1138 }
-
1139 } else { -
1140 if (hasDirtySiblingsAbove)
-
1141 *hasDirtySiblingsAbove = true;
-
1142 if (sibling->d_func()->children.isEmpty())
-
1143 continue;
-
1144 QRegion opaqueSiblingChildren(sibling->d_func()->getOpaqueChildren()); -
1145 opaqueSiblingChildren.translate(-parentOffset + siblingPos); -
1146 sourceRegion -= opaqueSiblingChildren; -
1147 }
-
1148 if (sourceRegion.isEmpty())
-
1149 return;
-
1150 -
1151 dirtyClipBoundingRect = true; -
1152 dirtyParentClip = true; -
1153 }
-
1154 -
1155 w = w->parentWidget(); -
1156 parentOffset += pd->data.crect.topLeft(); -
1157 dirtyParentClip = true; -
1158 }
-
1159}
-
1160 -
1161void QWidgetPrivate::clipToEffectiveMask(QRegion &region) const -
1162{ -
1163 const QWidget * const q = q_func(); -
1164 -
1165 const QWidget *w = q; -
1166 QPoint offset; -
1167 -
1168 -
1169 if (graphicsEffect) {
-
1170 w = q->parentWidget(); -
1171 offset -= data.crect.topLeft(); -
1172 }
-
1173 -
1174 -
1175 while (w) {
-
1176 const QWidgetPrivate *wd = w->d_func(); -
1177 if (wd->extra && wd->extra->hasMask)
-
1178 region &= (w != q) ? wd->extra->mask.translated(offset) : wd->extra->mask;
-
1179 if (w->isWindow())
-
1180 return;
-
1181 offset -= wd->data.crect.topLeft(); -
1182 w = w->parentWidget(); -
1183 }
-
1184}
-
1185 -
1186bool QWidgetPrivate::paintOnScreen() const -
1187{ -
1188 -
1189 -
1190 -
1191 const QWidget * const q = q_func(); -
1192 if (q->testAttribute(Qt::WA_PaintOnScreen)
-
1193 || (!q->isWindow() && q->window()->testAttribute(Qt::WA_PaintOnScreen))) {
-
1194 return true;
-
1195 } -
1196 -
1197 return !qt_enable_backingstore;
-
1198 -
1199} -
1200 -
1201void QWidgetPrivate::updateIsOpaque() -
1202{ -
1203 -
1204 setDirtyOpaqueRegion(); -
1205 -
1206 -
1207 if (graphicsEffect) {
-
1208 -
1209 setOpaque(false); -
1210 return;
-
1211 } -
1212 -
1213 -
1214 QWidget * const q = q_func(); -
1215 -
1216 -
1217 -
1218 -
1219 -
1220 -
1221 -
1222 if (q->testAttribute(Qt::WA_OpaquePaintEvent) || q->testAttribute(Qt::WA_PaintOnScreen)) {
-
1223 setOpaque(true); -
1224 return;
-
1225 } -
1226 -
1227 const QPalette &pal = q->palette(); -
1228 -
1229 if (q->autoFillBackground()) {
-
1230 const QBrush &autoFillBrush = pal.brush(q->backgroundRole()); -
1231 if (autoFillBrush.style() != Qt::NoBrush && autoFillBrush.isOpaque()) {
-
1232 setOpaque(true); -
1233 return;
-
1234 } -
1235 }
-
1236 -
1237 if (q->isWindow() && !q->testAttribute(Qt::WA_NoSystemBackground)) {
-
1238 const QBrush &windowBrush = q->palette().brush(QPalette::Window); -
1239 if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) {
-
1240 setOpaque(true); -
1241 return;
-
1242 } -
1243 }
-
1244 setOpaque(false); -
1245}
-
1246 -
1247void QWidgetPrivate::setOpaque(bool opaque) -
1248{ -
1249 if (isOpaque != opaque) {
-
1250 isOpaque = opaque; -
1251 updateIsTranslucent(); -
1252 }
-
1253}
-
1254 -
1255void QWidgetPrivate::updateIsTranslucent() -
1256{ -
1257 QWidget * const q = q_func(); -
1258 if (QWindow *window = q->windowHandle()) {
evaluated: QWindow *window = q->windowHandle()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:28357
10-28357
1259 QSurfaceFormat format = window->setOpacity(isOpaque ? qreal(1format(); -
1260 const int oldAlpha = format.0) : qrealalphaBufferSize(); -
1261 const int newAlpha = q->testAttribute(Qt::WA_TranslucentBackground)? 8 : 0;
partially evaluated: q->testAttribute(Qt::WA_TranslucentBackground)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
1262 if (oldAlpha != newAlpha) {
partially evaluated: oldAlpha != newAlpha
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
1263 format.0));setAlphaBufferSize(newAlpha); -
1264 window->setFormat(format); -
1265 }
executed: }
Execution Count:10
10
1266 }
executed: }
Execution Count:10
10
1267}
executed: }
Execution Count:28367
28367
1268 -
1269static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrush &brush) -
1270{ -
1271 qt_noop(); -
1272 -
1273 if (brush.style() == Qt::TexturePattern) {
-
1274 -
1275 -
1276 -
1277 -
1278 -
1279 -
1280 -
1281 { -
1282 const QRect rect(rgn.boundingRect()); -
1283 painter->setClipRegion(rgn); -
1284 painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); -
1285 } -
1286 -
1287 -
1288 } else if (brush.gradient()
-
1289 && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode) {
-
1290 painter->save(); -
1291 painter->setClipRegion(rgn); -
1292 painter->fillRect(0, 0, painter->device()->width(), painter->device()->height(), brush); -
1293 painter->restore(); -
1294 } else {
-
1295 const QVector<QRect> &rects = rgn.rects(); -
1296 for (int i = 0; i < rects.size(); ++i)
-
1297 painter->fillRect(rects.at(i), brush);
-
1298 }
-
1299} -
1300 -
1301void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int flags) const -
1302{ -
1303 const QWidget * const q = q_func(); -
1304 -
1305 -
1306 bool resetBrushOrigin = false; -
1307 QPointF oldBrushOrigin; -
1308 -
1309 QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent); -
1310 if (scrollArea && scrollArea->viewport() == q) {
-
1311 QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr.data(); -
1312 QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate); -
1313 oldBrushOrigin = painter->brushOrigin(); -
1314 resetBrushOrigin = true; -
1315 painter->setBrushOrigin(-priv->contentsOffset()); -
1316 -
1317 }
-
1318 -
1319 -
1320 const QBrush autoFillBrush = q->palette().brush(q->backgroundRole()); -
1321 -
1322 if ((flags & DrawAsRoot) && !(q->autoFillBackground() && autoFillBrush.isOpaque())) {
-
1323 const QBrush bg = q->palette().brush(QPalette::Window); -
1324 if (!(flags & DontSetCompositionMode)) {
-
1325 -
1326 QPainter::CompositionMode oldMode = painter->compositionMode(); -
1327 painter->setCompositionMode(QPainter::CompositionMode_Source); -
1328 fillRegion(painter, rgn, bg); -
1329 painter->setCompositionMode(oldMode); -
1330 } else {
-
1331 fillRegion(painter, rgn, bg); -
1332 }
-
1333 } -
1334 -
1335 if (q->autoFillBackground())
-
1336 fillRegion(painter, rgn, autoFillBrush);
-
1337 -
1338 if (q->testAttribute(Qt::WA_StyledBackground)) {
-
1339 painter->setClipRegion(rgn); -
1340 QStyleOption opt; -
1341 opt.initFrom(q); -
1342 q->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, q); -
1343 }
-
1344 -
1345 -
1346 if (resetBrushOrigin)
-
1347 painter->setBrushOrigin(oldBrushOrigin);
-
1348 -
1349}
-
1350 extern QWidget *qt_button_down; -
1351 -
1352 -
1353void QWidgetPrivate::deactivateWidgetCleanup() -
1354{ -
1355 QWidget * const q = q_func(); -
1356 -
1357 if (QApplication::activeWindow() == q)
-
1358 QApplication::setActiveWindow(0);
-
1359 -
1360 if (q == qt_button_down)
-
1361 qt_button_down = 0;
-
1362}
-
1363QWidget *QWidget::find(WId id) -
1364{ -
1365 return QWidgetPrivate::mapper ? QWidgetPrivate::mapper->value(id, 0) : 0;
-
1366} -
1367WId QWidget::winId() const -
1368{ -
1369 if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
-
1370 -
1371 -
1372 -
1373 QWidget *that = const_cast<QWidget*>(this); -
1374 that->setAttribute(Qt::WA_NativeWindow); -
1375 that->d_func()->createWinId(); -
1376 return that->data->winid;
-
1377 } -
1378 return data->winid;
-
1379} -
1380 -
1381 -
1382void QWidgetPrivate::createWinId(WId winid) -
1383{ -
1384 QWidget * const q = q_func(); -
1385 -
1386 -
1387 -
1388 -
1389 const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow); -
1390 if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) {
-
1391 if (!q->isWindow()) {
-
1392 QWidget *parent = q->parentWidget(); -
1393 QWidgetPrivate *pd = parent->d_func(); -
1394 if (forceNativeWindow && !q->testAttribute(Qt::WA_DontCreateNativeAncestors))
-
1395 parent->setAttribute(Qt::WA_NativeWindow);
-
1396 if (!parent->internalWinId()) {
-
1397 pd->createWinId(); -
1398 }
-
1399 -
1400 for (int i = 0; i < pd->children.size(); ++i) {
-
1401 QWidget *w = qobject_cast<QWidget *>(pd->children.at(i)); -
1402 if (w && !w->isWindow() && (!w->testAttribute(Qt::WA_WState_Created)
-
1403 || (!w->internalWinId() && w->testAttribute(Qt::WA_NativeWindow)))) {
-
1404 if (w!=q) {
-
1405 w->create(); -
1406 } else {
-
1407 w->create(winid); -
1408 -
1409 -
1410 if (winid)
-
1411 w->raise();
-
1412 }
-
1413 } -
1414 }
-
1415 } else {
-
1416 q->create(); -
1417 }
-
1418 } -
1419}
-
1420void QWidget::createWinId() -
1421{ -
1422 QWidgetPrivate * const d = d_func(); -
1423 -
1424 -
1425 -
1426 -
1427 d->createWinId(); -
1428}
-
1429WId QWidget::effectiveWinId() const -
1430{ -
1431 const WId id = internalWinId(); -
1432 if (id || !testAttribute(Qt::WA_WState_Created))
-
1433 return id;
-
1434 if (const QWidget *realParent = nativeParentWidget())
-
1435 return realParent->internalWinId();
-
1436 return 0;
-
1437} -
1438QString QWidget::styleSheet() const -
1439{ -
1440 const QWidgetPrivate * const d = d_func(); -
1441 if (!d->extra)
-
1442 return QString();
-
1443 return d->extra->styleSheet;
-
1444} -
1445 -
1446void QWidget::setStyleSheet(const QString& styleSheet) -
1447{ -
1448 QWidgetPrivate * const d = d_func(); -
1449 d->createExtra(); -
1450 -
1451 QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(d->extra->style); -
1452 d->extra->styleSheet = styleSheet; -
1453 if (styleSheet.isEmpty()) {
-
1454 if (!proxy)
-
1455 return;
-
1456 -
1457 d->inheritStyle(); -
1458 return;
-
1459 } -
1460 -
1461 if (proxy) {
-
1462 proxy->repolish(this); -
1463 return;
-
1464 } -
1465 -
1466 if (testAttribute(Qt::WA_SetStyle)) {
-
1467 d->setStyle_helper(new QStyleSheetStyle(d->extra->style), true); -
1468 } else {
-
1469 d->setStyle_helper(new QStyleSheetStyle(0), true); -
1470 }
-
1471} -
1472 -
1473 -
1474 -
1475 -
1476 -
1477 -
1478 -
1479QStyle *QWidget::style() const -
1480{ -
1481 const QWidgetPrivate * const d = d_func(); -
1482 -
1483 if (d->extra && d->extra->style)
-
1484 return d->extra->style;
-
1485 return QApplication::style();
-
1486} -
1487void QWidget::setStyle(QStyle *style) -
1488{ -
1489 QWidgetPrivate * const d = d_func(); -
1490 setAttribute(Qt::WA_SetStyle, style != 0); -
1491 d->createExtra(); -
1492 -
1493 if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(style)) {
-
1494 -
1495 -
1496 proxy->ref(); -
1497 d->setStyle_helper(style, false); -
1498 } else if (qobject_cast<QStyleSheetStyle *>(d->extra->style) || !(static_cast<QApplication *>(QCoreApplication::instance()))->styleSheet().isEmpty()) {
-
1499 -
1500 d->setStyle_helper(new QStyleSheetStyle(style), true); -
1501 } else
-
1502 -
1503 d->setStyle_helper(style, false);
-
1504} -
1505 -
1506void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool -
1507 -
1508 -
1509 -
1510 ) -
1511{ -
1512 QWidget * const q = q_func(); -
1513 QStyle *oldStyle = q->style(); -
1514 -
1515 QPointer<QStyle> origStyle; -
1516 { -
1517 createExtra(); -
1518 -
1519 -
1520 origStyle = extra->style.data(); -
1521 -
1522 extra->style = newStyle; -
1523 } -
1524 -
1525 -
1526 if (q->windowType() != Qt::Desktop) {
-
1527 if (polished) {
-
1528 oldStyle->unpolish(q); -
1529 -
1530 -
1531 -
1532 -
1533 q->style()->polish(q); -
1534 -
1535 -
1536 -
1537 -
1538 }
-
1539 }
-
1540 -
1541 if (propagate) {
-
1542 -
1543 const QObjectList childrenList = children; -
1544 for (int i = 0; i < childrenList.size(); ++i) {
-
1545 QWidget *c = qobject_cast<QWidget*>(childrenList.at(i)); -
1546 if (c)
-
1547 c->d_func()->inheritStyle();
-
1548 }
-
1549 }
-
1550 -
1551 -
1552 if (!qobject_cast<QStyleSheetStyle*>(newStyle)) {
-
1553 if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle.data())) {
-
1554 cssStyle->clearWidgetFont(q); -
1555 }
-
1556 }
-
1557 -
1558 -
1559 QEvent e(QEvent::StyleChange); -
1560 QApplication::sendEvent(q, &e); -
1561 -
1562 -
1563 -
1564 if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle.data()))
-
1565 proxy->deref();
-
1566 -
1567}
-
1568 -
1569 -
1570void QWidgetPrivate::inheritStyle() -
1571{ -
1572 -
1573 QWidget * const q = q_func(); -
1574 -
1575 QStyleSheetStyle *proxy = extra ? qobject_cast<QStyleSheetStyle *>(extra->style) : 0;
-
1576 -
1577 if (!q->styleSheet().isEmpty()) {
-
1578 qt_noop(); -
1579 proxy->repolish(q); -
1580 return;
-
1581 } -
1582 -
1583 QStyle *origStyle = proxy ? proxy->base : (extra ? (QStyle*)extra->style : 0);
-
1584 QWidget *parent = q->parentWidget(); -
1585 QStyle *parentStyle = (parent && parent->d_func()->extra) ? (QStyle*)parent->d_func()->extra->style : 0;
-
1586 -
1587 -
1588 if (!(static_cast<QApplication *>(QCoreApplication::instance()))->styleSheet().isEmpty() || qobject_cast<QStyleSheetStyle *>(parentStyle)) {
-
1589 QStyle *newStyle = parentStyle; -
1590 if (q->testAttribute(Qt::WA_SetStyle))
-
1591 newStyle = new QStyleSheetStyle(origStyle);
-
1592 else if (QStyleSheetStyle *newProxy = qobject_cast<QStyleSheetStyle *>(parentStyle))
-
1593 newProxy->ref();
-
1594 -
1595 setStyle_helper(newStyle, true); -
1596 return;
-
1597 } -
1598 -
1599 -
1600 -
1601 if (origStyle == (extra ? (QStyle*)extra->style : 0))
-
1602 return;
-
1603 -
1604 -
1605 -
1606 -
1607 if (!q->testAttribute(Qt::WA_SetStyle))
-
1608 origStyle = 0;
-
1609 -
1610 setStyle_helper(origStyle, true); -
1611 -
1612}
-
1613Qt::WindowModality QWidget::windowModality() const -
1614{ -
1615 return static_cast<Qt::WindowModality>(data->window_modality);
-
1616} -
1617 -
1618void QWidget::setWindowModality(Qt::WindowModality windowModality) -
1619{ -
1620 data->window_modality = windowModality; -
1621 -
1622 setAttribute(Qt::WA_ShowModal, (data->window_modality != Qt::NonModal)); -
1623 setAttribute(Qt::WA_SetWindowModality, true); -
1624}
-
1625bool QWidget::isMinimized() const -
1626{ return data->window_state & Qt::WindowMinimized; }
-
1627void QWidget::showMinimized() -
1628{ -
1629 bool isMin = isMinimized(); -
1630 if (isMin && isVisible())
-
1631 return;
-
1632 -
1633 ensurePolished(); -
1634 -
1635 if (!isMin)
-
1636 setWindowState((windowState() & ~Qt::WindowActive) | Qt::WindowMinimized);
-
1637 setVisible(true); -
1638}
-
1639bool QWidget::isMaximized() const -
1640{ return data->window_state & Qt::WindowMaximized; }
-
1641Qt::WindowStates QWidget::windowState() const -
1642{ -
1643 return Qt::WindowStates(data->window_state);
-
1644} -
1645void QWidget::overrideWindowState(Qt::WindowStates newstate) -
1646{ -
1647 QWindowStateChangeEvent e(Qt::WindowStates(data->window_state), true); -
1648 data->window_state = newstate; -
1649 QApplication::sendEvent(this, &e); -
1650}
-
1651bool QWidget::isFullScreen() const -
1652{ return data->window_state & Qt::WindowFullScreen; }
-
1653void QWidget::showFullScreen() -
1654{ -
1655 ensurePolished(); -
1656 -
1657 setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowMaximized)) -
1658 | Qt::WindowFullScreen); -
1659 setVisible(true); -
1660 activateWindow(); -
1661}
-
1662void QWidget::showMaximized() -
1663{ -
1664 ensurePolished(); -
1665 -
1666 setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen)) -
1667 | Qt::WindowMaximized); -
1668 setVisible(true); -
1669}
-
1670void QWidget::showNormal() -
1671{ -
1672 ensurePolished(); -
1673 -
1674 setWindowState(windowState() & ~(Qt::WindowMinimized -
1675 | Qt::WindowMaximized -
1676 | Qt::WindowFullScreen)); -
1677 setVisible(true); -
1678}
-
1679bool QWidget::isEnabledTo(const QWidget *ancestor) const -
1680{ -
1681 const QWidget * w = this; -
1682 while (!w->testAttribute(Qt::WA_ForceDisabled)
-
1683 && !w->isWindow()
-
1684 && w->parentWidget()
-
1685 && w->parentWidget() != ancestor)
-
1686 w = w->parentWidget();
-
1687 return !w->testAttribute(Qt::WA_ForceDisabled);
-
1688} -
1689void QWidget::addAction(QAction *action) -
1690{ -
1691 insertAction(0, action); -
1692}
-
1693 -
1694 -
1695 -
1696 -
1697 -
1698 -
1699void QWidget::addActions(QList<QAction*> actions) -
1700{ -
1701 for(int i = 0; i < actions.count(); i++)
-
1702 insertAction(0, actions.at(i));
-
1703}
-
1704void QWidget::insertAction(QAction *before, QAction *action) -
1705{ -
1706 if(!action) {
-
1707 QMessageLogger("kernel/qwidget.cpp", 29372952, __PRETTY_FUNCTION__).warning("QWidget::insertAction: Attempt to insert null action"); -
1708 return;
-
1709 } -
1710 -
1711 QWidgetPrivate * const d = d_func(); -
1712 if(d->actions.contains(action))
-
1713 removeAction(action);
-
1714 -
1715 int pos = d->actions.indexOf(before); -
1716 if (pos < 0) {
-
1717 before = 0; -
1718 pos = d->actions.size(); -
1719 }
-
1720 d->actions.insert(pos, action); -
1721 -
1722 QActionPrivate *apriv = action->d_func(); -
1723 apriv->widgets.append(this); -
1724 -
1725 QActionEvent e(QEvent::ActionAdded, action, before); -
1726 QApplication::sendEvent(this, &e); -
1727}
-
1728void QWidget::insertActions(QAction *before, QList<QAction*> actions) -
1729{ -
1730 for(int i = 0; i < actions.count(); ++i)
-
1731 insertAction(before, actions.at(i));
-
1732}
-
1733 -
1734 -
1735 -
1736 -
1737 -
1738void QWidget::removeAction(QAction *action) -
1739{ -
1740 if (!action)
-
1741 return;
-
1742 -
1743 QWidgetPrivate * const d = d_func(); -
1744 -
1745 QActionPrivate *apriv = action->d_func(); -
1746 apriv->widgets.removeAll(this); -
1747 -
1748 if (d->actions.removeAll(action)) {
-
1749 QActionEvent e(QEvent::ActionRemoved, action); -
1750 QApplication::sendEvent(this, &e); -
1751 }
-
1752}
-
1753 -
1754 -
1755 -
1756 -
1757 -
1758 -
1759QList<QAction*> QWidget::actions() const -
1760{ -
1761 const QWidgetPrivate * const d = d_func(); -
1762 return d->actions;
-
1763} -
1764void QWidget::setEnabled(bool enable) -
1765{ -
1766 QWidgetPrivate * const d = d_func(); -
1767 setAttribute(Qt::WA_ForceDisabled, !enable); -
1768 d->setEnabled_helper(enable); -
1769}
-
1770 -
1771void QWidgetPrivate::setEnabled_helper(bool enable) -
1772{ -
1773 QWidget * const q = q_func(); -
1774 -
1775 if (enable && !q->isWindow() && q->parentWidget() && !q->parentWidget()->isEnabled())
-
1776 return;
-
1777 -
1778 if (enable != q->testAttribute(Qt::WA_Disabled))
-
1779 return;
-
1780 -
1781 q->setAttribute(Qt::WA_Disabled, !enable); -
1782 updateSystemBackground(); -
1783 -
1784 if (!enable && q->window()->focusWidget() == q) {
-
1785 bool parentIsEnabled = (!q->parentWidget() || q->parentWidget()->isEnabled());
-
1786 if (!parentIsEnabled || !q->focusNextChild())
-
1787 q->clearFocus();
-
1788 }
-
1789 -
1790 Qt::WidgetAttribute attribute = enable ? Qt::WA_ForceDisabled : Qt::WA_Disabled;
-
1791 for (int i = 0; i < children.size(); ++i) {
-
1792 QWidget *w = qobject_cast<QWidget *>(children.at(i)); -
1793 if (w && !w->testAttribute(attribute))
-
1794 w->d_func()->setEnabled_helper(enable);
-
1795 }
-
1796 if (q->testAttribute(Qt::WA_SetCursor) || q->isWindow()) {
-
1797 -
1798 -
1799 qt_qpa_set_cursor(q, false); -
1800 }
-
1801 -
1802 -
1803 -
1804 -
1805 -
1806 if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) {
-
1807 QWidget *focusWidget = effectiveFocusWidget(); -
1808 -
1809 if (enable) {
-
1810 if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
-
1811 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->update(Qt::ImEnabled);
-
1812 } else {
-
1813 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->commit(); -
1814 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->update(Qt::ImEnabled); -
1815 }
-
1816 } -
1817 -
1818 QEvent e(QEvent::EnabledChange); -
1819 QApplication::sendEvent(q, &e); -
1820}
-
1821bool QWidget::acceptDrops() const -
1822{ -
1823 return testAttribute(Qt::WA_AcceptDrops);
-
1824} -
1825 -
1826void QWidget::setAcceptDrops(bool on) -
1827{ -
1828 setAttribute(Qt::WA_AcceptDrops, on); -
1829 -
1830}
-
1831void QWidget::setDisabled(bool disable) -
1832{ -
1833 setEnabled(!disable); -
1834}
-
1835QRect QWidget::frameGeometry() const -
1836{ -
1837 const QWidgetPrivate * const d = d_func(); -
1838 if (isWindow() && ! (windowType() == Qt::Popup)) {
-
1839 QRect fs = d->frameStrut(); -
1840 return QRect(data->crect.x() - fs.left(), -
1841 data->crect.y() - fs.top(), -
1842 data->crect.width() + fs.left() + fs.right(), -
1843 data->crect.height() + fs.top() + fs.bottom());
-
1844 } -
1845 return data->crect;
-
1846} -
1847int QWidget::x() const -
1848{ -
1849 const QWidgetPrivate * const d = d_func(); -
1850 if (isWindow() && ! (windowType() == Qt::Popup))
-
1851 return data->crect.x() - d->frameStrut().left();
-
1852 return data->crect.x();
-
1853} -
1854int QWidget::y() const -
1855{ -
1856 const QWidgetPrivate * const d = d_func(); -
1857 if (isWindow() && ! (windowType() == Qt::Popup))
-
1858 return data->crect.y() - d->frameStrut().top();
-
1859 return data->crect.y();
-
1860} -
1861QPoint QWidget::pos() const -
1862{ -
1863 const QWidgetPrivate * const d = d_func(); -
1864 QPoint result = data->crect.topLeft(); -
1865 if (isWindow() && ! (windowType() == Qt::Popup))
-
1866 if (!d->maybeTopData() || !d->maybeTopData()->posIncludesFrame)
-
1867 result -= d->frameStrut().topLeft();
-
1868 return result;
-
1869} -
1870QRect QWidget::normalGeometry() const -
1871{ -
1872 const QWidgetPrivate * const d = d_func(); -
1873 if (!d->extra || !d->extra->topextra)
-
1874 return QRect();
-
1875 -
1876 if (!isMaximized() && !isFullScreen())
-
1877 return geometry();
-
1878 -
1879 return d->topData()->normalGeometry;
-
1880} -
1881QRect QWidget::childrenRect() const -
1882{ -
1883 const QWidgetPrivate * const d = d_func(); -
1884 QRect r(0, 0, 0, 0); -
1885 for (int i = 0; i < d->children.size(); ++i) {
-
1886 QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); -
1887 if (w && !w->isWindow() && !w->isHidden())
-
1888 r |= w->geometry();
-
1889 }
-
1890 return r;
-
1891} -
1892QRegion QWidget::childrenRegion() const -
1893{ -
1894 const QWidgetPrivate * const d = d_func(); -
1895 QRegion r; -
1896 for (int i = 0; i < d->children.size(); ++i) {
-
1897 QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); -
1898 if (w && !w->isWindow() && !w->isHidden()) {
-
1899 QRegion mask = w->mask(); -
1900 if (mask.isEmpty())
-
1901 r |= w->geometry();
-
1902 else -
1903 r |= mask.translated(w->pos());
-
1904 } -
1905 }
-
1906 return r;
-
1907} -
1908QSize QWidget::minimumSize() const -
1909{ -
1910 const QWidgetPrivate * const d = d_func(); -
1911 return d->extra ? QSize(d->extra->minw, d->extra->minh) : QSize(0, 0);
-
1912} -
1913QSize QWidget::maximumSize() const -
1914{ -
1915 const QWidgetPrivate * const d = d_func(); -
1916 return d->extra ? QSize(d->extra->maxw, d->extra->maxh) -
1917 : QSize(((1<<24)-1), ((1<<24)-1));
-
1918} -
1919QSize QWidget::sizeIncrement() const -
1920{ -
1921 const QWidgetPrivate * const d = d_func(); -
1922 return (d->extra && d->extra->topextra) -
1923 ? QSize(d->extra->topextra->incw, d->extra->topextra->inch) -
1924 : QSize(0, 0);
-
1925} -
1926QSize QWidget::baseSize() const -
1927{ -
1928 const QWidgetPrivate * const d = d_func(); -
1929 return (d->extra != 0 && d->extra->topextra != 0) -
1930 ? QSize(d->extra->topextra->basew, d->extra->topextra->baseh) -
1931 : QSize(0, 0);
-
1932} -
1933 -
1934bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh) -
1935{ -
1936 QWidget * const q = q_func(); -
1937 -
1938 int mw = minw, mh = minh; -
1939 if (mw == ((1<<24)-1))
-
1940 mw = 0;
-
1941 if (mh == ((1<<24)-1))
-
1942 mh = 0;
-
1943 if (minw > ((1<<24)-1) || minh > ((1<<24)-1)) {
-
1944 QMessageLogger("kernel/qwidget.cpp", 35783593, __PRETTY_FUNCTION__).warning("QWidget::setMinimumSize: (%s/%s) " -
1945 "The largest allowed size is (%d,%d)", -
1946 q->objectName().toLocal8Bit().data(), q->metaObject()->className(), ((1<<24)-1), -
1947 ((1<<24)-1)); -
1948 minw = mw = qMin<int>(minw, ((1<<24)-1)); -
1949 minh = mh = qMin<int>(minh, ((1<<24)-1)); -
1950 }
-
1951 if (minw < 0 || minh < 0) {
-
1952 QMessageLogger("kernel/qwidget.cpp", 35863601, __PRETTY_FUNCTION__).warning("QWidget::setMinimumSize: (%s/%s) Negative sizes (%d,%d) " -
1953 "are not possible", -
1954 q->objectName().toLocal8Bit().data(), q->metaObject()->className(), minw, minh); -
1955 minw = mw = qMax(minw, 0); -
1956 minh = mh = qMax(minh, 0); -
1957 }
-
1958 createExtra(); -
1959 if (extra->minw == mw && extra->minh == mh)
-
1960 return false;
-
1961 extra->minw = mw; -
1962 extra->minh = mh; -
1963 extra->explicitMinSize = (mw ? Qt::Horizontal : 0) | (mh ? Qt::Vertical : 0);
-
1964 return true;
-
1965} -
1966void QWidget::setMinimumSize(int minw, int minh) -
1967{ -
1968 QWidgetPrivate * const d = d_func(); -
1969 if (!d->setMinimumSize_helper(minw, minh))
-
1970 return;
-
1971 -
1972 if (isWindow())
-
1973 d->setConstraints_sys();
-
1974 if (minw > width() || minh > height()) {
-
1975 bool resized = testAttribute(Qt::WA_Resized); -
1976 bool maximized = isMaximized(); -
1977 resize(qMax(minw,width()), qMax(minh,height())); -
1978 setAttribute(Qt::WA_Resized, resized); -
1979 if (maximized)
-
1980 data->window_state = data->window_state | Qt::WindowMaximized;
-
1981 }
-
1982 -
1983 if (d->extra) {
-
1984 if (d->extra->proxyWidget)
-
1985 d->extra->proxyWidget->setMinimumSize(minw, minh);
-
1986 }
-
1987 -
1988 d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh); -
1989}
-
1990 -
1991bool QWidgetPrivate::setMaximumSize_helper(int &maxw, int &maxh) -
1992{ -
1993 QWidget * const q = q_func(); -
1994 if (maxw > ((1<<24)-1) || maxh > ((1<<24)-1)) {
-
1995 QMessageLogger("kernel/qwidget.cpp", 36383653, __PRETTY_FUNCTION__).warning("QWidget::setMaximumSize: (%s/%s) " -
1996 "The largest allowed size is (%d,%d)", -
1997 q->objectName().toLocal8Bit().data(), q->metaObject()->className(), ((1<<24)-1), -
1998 ((1<<24)-1)); -
1999 maxw = qMin<int>(maxw, ((1<<24)-1)); -
2000 maxh = qMin<int>(maxh, ((1<<24)-1)); -
2001 }
-
2002 if (maxw < 0 || maxh < 0) {
-
2003 QMessageLogger("kernel/qwidget.cpp", 36463661, __PRETTY_FUNCTION__).warning("QWidget::setMaximumSize: (%s/%s) Negative sizes (%d,%d) " -
2004 "are not possible", -
2005 q->objectName().toLocal8Bit().data(), q->metaObject()->className(), maxw, maxh); -
2006 maxw = qMax(maxw, 0); -
2007 maxh = qMax(maxh, 0); -
2008 }
-
2009 createExtra(); -
2010 if (extra->maxw == maxw && extra->maxh == maxh)
-
2011 return false;
-
2012 extra->maxw = maxw; -
2013 extra->maxh = maxh; -
2014 extra->explicitMaxSize = (maxw != ((1<<24)-1) ? Qt::Horizontal : 0) |
-
2015 (maxh != ((1<<24)-1) ? Qt::Vertical : 0); -
2016 return true;
-
2017} -
2018void QWidget::setMaximumSize(int maxw, int maxh) -
2019{ -
2020 QWidgetPrivate * const d = d_func(); -
2021 if (!d->setMaximumSize_helper(maxw, maxh))
-
2022 return;
-
2023 -
2024 if (isWindow())
-
2025 d->setConstraints_sys();
-
2026 if (maxw < width() || maxh < height()) {
-
2027 bool resized = testAttribute(Qt::WA_Resized); -
2028 resize(qMin(maxw,width()), qMin(maxh,height())); -
2029 setAttribute(Qt::WA_Resized, resized); -
2030 }
-
2031 -
2032 -
2033 if (d->extra) {
-
2034 if (d->extra->proxyWidget)
-
2035 d->extra->proxyWidget->setMaximumSize(maxw, maxh);
-
2036 }
-
2037 -
2038 -
2039 d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh); -
2040}
-
2041 -
2042 -
2043 -
2044 -
2045 -
2046 -
2047 -
2048void QWidget::setSizeIncrement(int w, int h) -
2049{ -
2050 QWidgetPrivate * const d = d_func(); -
2051 d->createTLExtra(); -
2052 QTLWExtra* x = d->topData(); -
2053 if (x->incw == w && x->inch == h)
-
2054 return;
-
2055 x->incw = w; -
2056 x->inch = h; -
2057 if (isWindow())
-
2058 d->setConstraints_sys();
-
2059}
-
2060 -
2061 -
2062 -
2063 -
2064 -
2065 -
2066 -
2067void QWidget::setBaseSize(int basew, int baseh) -
2068{ -
2069 QWidgetPrivate * const d = d_func(); -
2070 d->createTLExtra(); -
2071 QTLWExtra* x = d->topData(); -
2072 if (x->basew == basew && x->baseh == baseh)
-
2073 return;
-
2074 x->basew = basew; -
2075 x->baseh = baseh; -
2076 if (isWindow())
-
2077 d->setConstraints_sys();
-
2078}
-
2079void QWidget::setFixedSize(const QSize & s) -
2080{ -
2081 setFixedSize(s.width(), s.height()); -
2082}
-
2083void QWidget::setFixedSize(int w, int h) -
2084{ -
2085 QWidgetPrivate * const d = d_func(); -
2086 bool minSizeSet = d->setMinimumSize_helper(w, h); -
2087 bool maxSizeSet = d->setMaximumSize_helper(w, h); -
2088 if (!minSizeSet && !maxSizeSet)
-
2089 return;
-
2090 -
2091 if (isWindow())
-
2092 d->setConstraints_sys();
-
2093 else -
2094 d->updateGeometry_helper(true);
-
2095 -
2096 if (w != ((1<<24)-1) || h != ((1<<24)-1))
-
2097 resize(w, h);
-
2098}
-
2099 -
2100void QWidget::setMinimumWidth(int w) -
2101{ -
2102 QWidgetPrivate * const d = d_func(); -
2103 d->createExtra(); -
2104 uint expl = d->extra->explicitMinSize | (w ? Qt::Horizontal : 0); -
2105 setMinimumSize(w, minimumSize().height()); -
2106 d->extra->explicitMinSize = expl; -
2107}
-
2108 -
2109void QWidget::setMinimumHeight(int h) -
2110{ -
2111 QWidgetPrivate * const d = d_func(); -
2112 d->createExtra(); -
2113 uint expl = d->extra->explicitMinSize | (h ? Qt::Vertical : 0); -
2114 setMinimumSize(minimumSize().width(), h); -
2115 d->extra->explicitMinSize = expl; -
2116}
-
2117 -
2118void QWidget::setMaximumWidth(int w) -
2119{ -
2120 QWidgetPrivate * const d = d_func(); -
2121 d->createExtra(); -
2122 uint expl = d->extra->explicitMaxSize | (w == ((1<<24)-1) ? 0 : Qt::Horizontal); -
2123 setMaximumSize(w, maximumSize().height()); -
2124 d->extra->explicitMaxSize = expl; -
2125}
-
2126 -
2127void QWidget::setMaximumHeight(int h) -
2128{ -
2129 QWidgetPrivate * const d = d_func(); -
2130 d->createExtra(); -
2131 uint expl = d->extra->explicitMaxSize | (h == ((1<<24)-1) ? 0 : Qt::Vertical); -
2132 setMaximumSize(maximumSize().width(), h); -
2133 d->extra->explicitMaxSize = expl; -
2134}
-
2135void QWidget::setFixedWidth(int w) -
2136{ -
2137 QWidgetPrivate * const d = d_func(); -
2138 d->createExtra(); -
2139 uint explMin = d->extra->explicitMinSize | Qt::Horizontal; -
2140 uint explMax = d->extra->explicitMaxSize | Qt::Horizontal; -
2141 setMinimumSize(w, minimumSize().height()); -
2142 setMaximumSize(w, maximumSize().height()); -
2143 d->extra->explicitMinSize = explMin; -
2144 d->extra->explicitMaxSize = explMax; -
2145}
-
2146void QWidget::setFixedHeight(int h) -
2147{ -
2148 QWidgetPrivate * const d = d_func(); -
2149 d->createExtra(); -
2150 uint explMin = d->extra->explicitMinSize | Qt::Vertical; -
2151 uint explMax = d->extra->explicitMaxSize | Qt::Vertical; -
2152 setMinimumSize(minimumSize().width(), h); -
2153 setMaximumSize(maximumSize().width(), h); -
2154 d->extra->explicitMinSize = explMin; -
2155 d->extra->explicitMaxSize = explMax; -
2156}
-
2157QPoint QWidget::mapTo(const QWidget * parent, const QPoint & pos) const -
2158{ -
2159 QPoint p = pos; -
2160 if (parent) {
-
2161 const QWidget * w = this; -
2162 while (w != parent) {
-
2163 qt_noop(); -
2164 -
2165 p = w->mapToParent(p); -
2166 w = w->parentWidget(); -
2167 }
-
2168 }
-
2169 return p;
-
2170} -
2171QPoint QWidget::mapFrom(const QWidget * parent, const QPoint & pos) const -
2172{ -
2173 QPoint p(pos); -
2174 if (parent) {
-
2175 const QWidget * w = this; -
2176 while (w != parent) {
-
2177 qt_noop(); -
2178 -
2179 -
2180 p = w->mapFromParent(p); -
2181 w = w->parentWidget(); -
2182 }
-
2183 }
-
2184 return p;
-
2185} -
2186QPoint QWidget::mapToParent(const QPoint &pos) const -
2187{ -
2188 return pos + data->crect.topLeft();
-
2189} -
2190QPoint QWidget::mapFromParent(const QPoint &pos) const -
2191{ -
2192 return pos - data->crect.topLeft();
-
2193} -
2194QWidget *QWidget::window() const -
2195{ -
2196 QWidget *w = (QWidget *)this; -
2197 QWidget *p = w->parentWidget(); -
2198 while (!w->isWindow() && p) {
-
2199 w = p; -
2200 p = p->parentWidget(); -
2201 }
-
2202 return w;
-
2203} -
2204QWidget *QWidget::nativeParentWidget() const -
2205{ -
2206 QWidget *parent = parentWidget(); -
2207 while (parent && !parent->internalWinId())
-
2208 parent = parent->parentWidget();
-
2209 return parent;
-
2210} -
2211QPalette::ColorRole QWidget::backgroundRole() const -
2212{ -
2213 -
2214 const QWidget *w = this; -
2215 do { -
2216 QPalette::ColorRole role = w->d_func()->bg_role; -
2217 if (role != QPalette::NoRole)
-
2218 return role;
-
2219 if (w->isWindow() || w->windowType() == Qt::SubWindow)
-
2220 break;
-
2221 w = w->parentWidget(); -
2222 } while (w);
-
2223 return QPalette::Window;
-
2224} -
2225void QWidget::setBackgroundRole(QPalette::ColorRole role) -
2226{ -
2227 QWidgetPrivate * const d = d_func(); -
2228 d->bg_role = role; -
2229 d->updateSystemBackground(); -
2230 d->propagatePaletteChange(); -
2231 d->updateIsOpaque(); -
2232}
-
2233QPalette::ColorRole QWidget::foregroundRole() const -
2234{ -
2235 const QWidgetPrivate * const d = d_func(); -
2236 QPalette::ColorRole rl = QPalette::ColorRole(d->fg_role); -
2237 if (rl != QPalette::NoRole)
-
2238 return rl;
-
2239 QPalette::ColorRole role = QPalette::WindowText; -
2240 switch (backgroundRole()) { -
2241 case QPalette::Button: -
2242 role = QPalette::ButtonText; -
2243 break;
-
2244 case QPalette::Base: -
2245 role = QPalette::Text; -
2246 break;
-
2247 case QPalette::Dark: -
2248 case QPalette::Shadow: -
2249 role = QPalette::Light; -
2250 break;
-
2251 case QPalette::Highlight: -
2252 role = QPalette::HighlightedText; -
2253 break;
-
2254 case QPalette::ToolTipBase: -
2255 role = QPalette::ToolTipText; -
2256 break;
-
2257 default: -
2258 ; -
2259 }
-
2260 return role;
-
2261} -
2262void QWidget::setForegroundRole(QPalette::ColorRole role) -
2263{ -
2264 QWidgetPrivate * const d = d_func(); -
2265 d->fg_role = role; -
2266 d->updateSystemBackground(); -
2267 d->propagatePaletteChange(); -
2268}
-
2269const QPalette &QWidget::palette() const -
2270{ -
2271 if (!isEnabled()) {
-
2272 data->pal.setCurrentColorGroup(QPalette::Disabled); -
2273 } else if ((!isVisible() || isActiveWindow())
-
2274 -
2275 -
2276 -
2277 ) { -
2278 data->pal.setCurrentColorGroup(QPalette::Active); -
2279 } else {
-
2280 -
2281 -
2282 -
2283 -
2284 -
2285 -
2286 data->pal.setCurrentColorGroup(QPalette::Inactive); -
2287 }
-
2288 return data->pal;
-
2289} -
2290 -
2291void QWidget::setPalette(const QPalette &palette) -
2292{ -
2293 QWidgetPrivate * const d = d_func(); -
2294 setAttribute(Qt::WA_SetPalette, palette.resolve() != 0); -
2295 -
2296 -
2297 -
2298 -
2299 -
2300 QPalette naturalPalette = d->naturalWidgetPalette(d->inheritedPaletteResolveMask); -
2301 QPalette resolvedPalette = palette.resolve(naturalPalette); -
2302 d->setPalette_helper(resolvedPalette); -
2303}
-
2304QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const -
2305{ -
2306 const QWidget * const q = q_func(); -
2307 QPalette naturalPalette = QApplication::palette(q); -
2308 if (!q->testAttribute(Qt::WA_StyleSheet)
-
2309 && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
-
2310 -
2311 || (extra && extra->proxyWidget)
-
2312 -
2313 )) { -
2314 if (QWidget *p = q->parentWidget()) {
-
2315 if (!p->testAttribute(Qt::WA_StyleSheet)) {
-
2316 if (!naturalPalette.isCopyOf(QApplication::palette())) {
-
2317 QPalette inheritedPalette = p->palette(); -
2318 inheritedPalette.resolve(inheritedMask); -
2319 naturalPalette = inheritedPalette.resolve(naturalPalette); -
2320 } else {
-
2321 naturalPalette = p->palette(); -
2322 }
-
2323 } -
2324 }
-
2325 -
2326 else if (extra && extra->proxyWidget) {
-
2327 QPalette inheritedPalette = extra->proxyWidget->palette(); -
2328 inheritedPalette.resolve(inheritedMask); -
2329 naturalPalette = inheritedPalette.resolve(naturalPalette); -
2330 }
-
2331 -
2332 } -
2333 naturalPalette.resolve(0); -
2334 return naturalPalette;
-
2335} -
2336void QWidgetPrivate::resolvePalette() -
2337{ -
2338 QPalette naturalPalette = naturalWidgetPalette(inheritedPaletteResolveMask); -
2339 QPalette resolvedPalette = data.pal.resolve(naturalPalette); -
2340 setPalette_helper(resolvedPalette); -
2341}
-
2342 -
2343void QWidgetPrivate::setPalette_helper(const QPalette &palette) -
2344{ -
2345 QWidget * const q = q_func(); -
2346 if (data.pal == palette && data.pal.resolve() == palette.resolve())
-
2347 return;
-
2348 data.pal = palette; -
2349 updateSystemBackground(); -
2350 propagatePaletteChange(); -
2351 updateIsOpaque(); -
2352 q->update(); -
2353 updateIsOpaque(); -
2354}
-
2355void QWidget::setFont(const QFont &font) -
2356{ -
2357 QWidgetPrivate * const d = d_func(); -
2358 -
2359 -
2360 const QStyleSheetStyle* style; -
2361 if (d->extra && (style = qobject_cast<const QStyleSheetStyle*>(d->extra->style))) {
-
2362 style->saveWidgetFont(this, font); -
2363 }
-
2364 -
2365 -
2366 setAttribute(Qt::WA_SetFont, font.resolve() != 0); -
2367 -
2368 -
2369 -
2370 -
2371 -
2372 QFont naturalFont = d->naturalWidgetFont(d->inheritedFontResolveMask); -
2373 QFont resolvedFont = font.resolve(naturalFont); -
2374 d->setFont_helper(resolvedFont); -
2375}
-
2376QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const -
2377{ -
2378 const QWidget * const q = q_func(); -
2379 QFont naturalFont = QApplication::font(q); -
2380 if (!q->testAttribute(Qt::WA_StyleSheet)
-
2381 && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
-
2382 -
2383 || (extra && extra->proxyWidget)
-
2384 -
2385 )) { -
2386 if (QWidget *p = q->parentWidget()) {
-
2387 if (!p->testAttribute(Qt::WA_StyleSheet)) {
-
2388 if (!naturalFont.isCopyOf(QApplication::font())) {
-
2389 QFont inheritedFont = p->font(); -
2390 inheritedFont.resolve(inheritedMask); -
2391 naturalFont = inheritedFont.resolve(naturalFont); -
2392 } else {
-
2393 naturalFont = p->font(); -
2394 }
-
2395 } -
2396 }
-
2397 -
2398 else if (extra && extra->proxyWidget) {
-
2399 QFont inheritedFont = extra->proxyWidget->font(); -
2400 inheritedFont.resolve(inheritedMask); -
2401 naturalFont = inheritedFont.resolve(naturalFont); -
2402 }
-
2403 -
2404 } -
2405 naturalFont.resolve(0); -
2406 return naturalFont;
-
2407} -
2408void QWidgetPrivate::resolveFont() -
2409{ -
2410 QFont naturalFont = naturalWidgetFont(inheritedFontResolveMask); -
2411 QFont resolvedFont = data.fnt.resolve(naturalFont); -
2412 setFont_helper(resolvedFont); -
2413}
-
2414void QWidgetPrivate::updateFont(const QFont &font) -
2415{ -
2416 QWidget * const q = q_func(); -
2417 -
2418 const QStyleSheetStyle* cssStyle; -
2419 cssStyle = extra ? qobject_cast<const QStyleSheetStyle*>(extra->style) : 0;
-
2420 -
2421 -
2422 data.fnt = QFont(font, q); -
2423 -
2424 -
2425 -
2426 -
2427 -
2428 -
2429 if (!q->parentWidget() && extra && extra->proxyWidget) {
-
2430 QGraphicsProxyWidget *p = extra->proxyWidget; -
2431 inheritedFontResolveMask = p->d_func()->inheritedFontResolveMask | p->font().resolve(); -
2432 } else
-
2433 -
2434 if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
-
2435 inheritedFontResolveMask = 0; -
2436 }
-
2437 uint newMask = data.fnt.resolve() | inheritedFontResolveMask; -
2438 -
2439 for (int i = 0; i < children.size(); ++i) {
-
2440 QWidget *w = qobject_cast<QWidget*>(children.at(i)); -
2441 if (w) {
-
2442 if (0) {
-
2443 -
2444 } else if (w->testAttribute(Qt::WA_StyleSheet)) {
-
2445 -
2446 if (cssStyle)
-
2447 cssStyle->updateStyleSheetFont(w);
-
2448 -
2449 } else if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) {
-
2450 -
2451 QWidgetPrivate *wd = w->d_func(); -
2452 wd->inheritedFontResolveMask = newMask; -
2453 wd->resolveFont(); -
2454 }
-
2455 } -
2456 }
-
2457 -
2458 -
2459 if (cssStyle) {
-
2460 cssStyle->updateStyleSheetFont(q); -
2461 }
-
2462 -
2463 -
2464 QEvent e(QEvent::FontChange); -
2465 QApplication::sendEvent(q, &e); -
2466}
-
2467 -
2468void QWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction) -
2469{ -
2470 QWidget * const q = q_func(); -
2471 -
2472 if ( (direction == Qt::RightToLeft) == q->testAttribute(Qt::WA_RightToLeft))
-
2473 return;
-
2474 q->setAttribute(Qt::WA_RightToLeft, (direction == Qt::RightToLeft)); -
2475 if (!children.isEmpty()) {
-
2476 for (int i = 0; i < children.size(); ++i) {
-
2477 QWidget *w = qobject_cast<QWidget*>(children.at(i)); -
2478 if (w && !w->isWindow() && !w->testAttribute(Qt::WA_SetLayoutDirection))
-
2479 w->d_func()->setLayoutDirection_helper(direction);
-
2480 }
-
2481 }
-
2482 QEvent e(QEvent::LayoutDirectionChange); -
2483 QApplication::sendEvent(q, &e); -
2484}
-
2485 -
2486void QWidgetPrivate::resolveLayoutDirection() -
2487{ -
2488 const QWidget * const q = q_func(); -
2489 if (!q->testAttribute(Qt::WA_SetLayoutDirection))
-
2490 setLayoutDirection_helper(q->isWindow() ? QApplication::layoutDirection() : q->parentWidget()->layoutDirection());
-
2491}
-
2492void QWidget::setLayoutDirection(Qt::LayoutDirection direction) -
2493{ -
2494 QWidgetPrivate * const d = d_func(); -
2495 -
2496 if (direction == Qt::LayoutDirectionAuto) {
-
2497 unsetLayoutDirection(); -
2498 return;
-
2499 } -
2500 -
2501 setAttribute(Qt::WA_SetLayoutDirection); -
2502 d->setLayoutDirection_helper(direction); -
2503}
-
2504 -
2505Qt::LayoutDirection QWidget::layoutDirection() const -
2506{ -
2507 return testAttribute(Qt::WA_RightToLeft) ? Qt::RightToLeft : Qt::LeftToRight;
-
2508} -
2509 -
2510void QWidget::unsetLayoutDirection() -
2511{ -
2512 QWidgetPrivate * const d = d_func(); -
2513 setAttribute(Qt::WA_SetLayoutDirection, false); -
2514 d->resolveLayoutDirection(); -
2515}
-
2516QCursor QWidget::cursor() const -
2517{ -
2518 const QWidgetPrivate * const d = d_func(); -
2519 if (testAttribute(Qt::WA_SetCursor))
-
2520 return (d->extra && d->extra->curs) -
2521 ? *d->extra->curs -
2522 : QCursor(Qt::ArrowCursor);
-
2523 if (isWindow() || !parentWidget())
-
2524 return QCursor(Qt::ArrowCursor);
-
2525 return parentWidget()->cursor();
-
2526} -
2527 -
2528void QWidget::setCursor(const QCursor &cursor) -
2529{ -
2530 QWidgetPrivate * const d = d_func(); -
2531 -
2532 -
2533 if (cursor.shape() != Qt::ArrowCursor
-
2534 || (d->extra && d->extra->curs))
-
2535 -
2536 { -
2537 d->createExtra(); -
2538 QCursor *newCursor = new QCursor(cursor); -
2539 delete d->extra->curs; -
2540 d->extra->curs = newCursor; -
2541 }
-
2542 setAttribute(Qt::WA_SetCursor); -
2543 d->setCursor_sys(cursor); -
2544 -
2545 QEvent event(QEvent::CursorChange); -
2546 QApplication::sendEvent(this, &event); -
2547}
-
2548 -
2549void QWidget::unsetCursor() -
2550{ -
2551 QWidgetPrivate * const d = d_func(); -
2552 if (d->extra) {
-
2553 delete d->extra->curs; -
2554 d->extra->curs = 0; -
2555 }
-
2556 if (!isWindow())
-
2557 setAttribute(Qt::WA_SetCursor, false);
-
2558 d->unsetCursor_sys(); -
2559 -
2560 QEvent event(QEvent::CursorChange); -
2561 QApplication::sendEvent(this, &event); -
2562}
-
2563void QWidget::render(QPaintDevice *target, const QPoint &targetOffset, -
2564 const QRegion &sourceRegion, RenderFlags renderFlags) -
2565{ -
2566 d_func()->render(target, targetOffset, sourceRegion, renderFlags, false); -
2567}
-
2568void QWidget::render(QPainter *painter, const QPoint &targetOffset, -
2569 const QRegion &sourceRegion, RenderFlags renderFlags) -
2570{ -
2571 if (!painter) {
-
2572 QMessageLogger("kernel/qwidget.cpp", 46654680, __PRETTY_FUNCTION__).warning("QWidget::render: Null pointer to painter"); -
2573 return;
-
2574 } -
2575 -
2576 if (!painter->isActive()) {
-
2577 QMessageLogger("kernel/qwidget.cpp", 46704685, __PRETTY_FUNCTION__).warning("QWidget::render: Cannot render with an inactive painter"); -
2578 return;
-
2579 } -
2580 -
2581 const qreal opacity = painter->opacity(); -
2582 if (qFuzzyIsNull(opacity))
-
2583 return;
-
2584 -
2585 QWidgetPrivate * const d = d_func(); -
2586 const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter;
-
2587 const QRegion toBePainted = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags)
-
2588 : sourceRegion; -
2589 if (toBePainted.isEmpty())
-
2590 return;
-
2591 -
2592 if (!d->extra)
-
2593 d->createExtra();
-
2594 d->extra->inRenderWithPainter = true; -
2595 -
2596 -
2597 -
2598 -
2599 QPaintEngine *engine = painter->paintEngine(); -
2600 qt_noop(); -
2601 QPaintEnginePrivate *enginePriv = engine->d_func(); -
2602 qt_noop(); -
2603 QPaintDevice *target = engine->paintDevice(); -
2604 qt_noop(); -
2605 -
2606 -
2607 if (!inRenderWithPainter && (opacity < 1.0 || (target->devType() == QInternal::Printer))) {
-
2608 d->render_helper(painter, targetOffset, toBePainted, renderFlags); -
2609 d->extra->inRenderWithPainter = false; -
2610 return;
-
2611 } -
2612 -
2613 -
2614 QPainter *oldPainter = d->sharedPainter(); -
2615 d->setSharedPainter(painter); -
2616 -
2617 -
2618 const QTransform oldTransform = enginePriv->systemTransform; -
2619 const QRegion oldSystemClip = enginePriv->systemClip; -
2620 const QRegion oldSystemViewport = enginePriv->systemViewport; -
2621 -
2622 -
2623 if (painter->hasClipping()) {
-
2624 const QRegion painterClip = painter->deviceTransform().map(painter->clipRegion()); -
2625 enginePriv->setSystemViewport(oldSystemClip.isEmpty() ? painterClip : oldSystemClip & painterClip); -
2626 } else {
-
2627 enginePriv->setSystemViewport(oldSystemClip); -
2628 }
-
2629 -
2630 render(target, targetOffset, toBePainted, renderFlags); -
2631 -
2632 -
2633 enginePriv->systemClip = oldSystemClip; -
2634 enginePriv->setSystemViewport(oldSystemViewport); -
2635 enginePriv->setSystemTransform(oldTransform); -
2636 -
2637 -
2638 d->setSharedPainter(oldPainter); -
2639 -
2640 -
2641 d->extra->inRenderWithPainter = false; -
2642}
-
2643 -
2644static void sendResizeEvents(QWidget *target) -
2645{ -
2646 QResizeEvent e(target->size(), QSize()); -
2647 QApplication::sendEvent(target, &e); -
2648 -
2649 const QObjectList children = target->children(); -
2650 for (int i = 0; i < children.size(); ++i) {
-
2651 QWidget *child = static_cast<QWidget*>(children.at(i)); -
2652 if (child->isWidgetType() && !child->isWindow() && child->testAttribute(Qt::WA_PendingResizeEvent))
-
2653 sendResizeEvents(child);
-
2654 }
-
2655}
-
2656QPixmap QWidget::grab(const QRect &rectangle) -
2657{ -
2658 QWidgetPrivate * const d = d_func(); -
2659 if (testAttribute(Qt::WA_PendingResizeEvent) || !testAttribute(Qt::WA_WState_Created))
-
2660 sendResizeEvents(this);
-
2661 -
2662 const QWidget::RenderFlags renderFlags = QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask; -
2663 -
2664 const bool oldDirtyOpaqueChildren = d->dirtyOpaqueChildren; -
2665 QRect r(rectangle); -
2666 if (r.width() < 0 || r.height() < 0) {
-
2667 -
2668 -
2669 r = d->prepareToRender(QRegion(), renderFlags).boundingRect(); -
2670 r.setTopLeft(rectangle.topLeft()); -
2671 }
-
2672 -
2673 if (!r.intersects(rect()))
-
2674 return QPixmap();
-
2675 -
2676 QPixmap res(r.size()); -
2677 if (!d->isOpaque)
-
2678 res.fill(Qt::transparent);
-
2679 render(&res, QPoint(), QRegion(r), renderFlags); -
2680 -
2681 d->dirtyOpaqueChildren = oldDirtyOpaqueChildren; -
2682 return res;
-
2683} -
2684QGraphicsEffect *QWidget::graphicsEffect() const -
2685{ -
2686 const QWidgetPrivate * const d = d_func(); -
2687 return d->graphicsEffect;
-
2688} -
2689void QWidget::setGraphicsEffect(QGraphicsEffect *effect) -
2690{ -
2691 QWidgetPrivate * const d = d_func(); -
2692 if (d->graphicsEffect == effect)
-
2693 return;
-
2694 -
2695 if (d->graphicsEffect) {
-
2696 d->invalidateBuffer(rect()); -
2697 delete d->graphicsEffect; -
2698 d->graphicsEffect = 0; -
2699 }
-
2700 -
2701 if (effect) {
-
2702 -
2703 QGraphicsEffectSourcePrivate *sourced = new QWidgetEffectSourcePrivate(this); -
2704 QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced); -
2705 d->graphicsEffect = effect; -
2706 effect->d_func()->setGraphicsEffectSource(source); -
2707 update(); -
2708 }
-
2709 -
2710 d->updateIsOpaque(); -
2711}
-
2712 -
2713 -
2714bool QWidgetPrivate::isAboutToShow() const -
2715{ -
2716 if (data.in_show)
-
2717 return true;
-
2718 -
2719 const QWidget * const q = q_func(); -
2720 if (q->isHidden())
-
2721 return false;
-
2722 -
2723 -
2724 QWidget *parent = q->parentWidget(); -
2725 return parent ? parent->d_func()->isAboutToShow() : false;
-
2726} -
2727 -
2728QRegion QWidgetPrivate::prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags) -
2729{ -
2730 QWidget * const q = q_func(); -
2731 const bool isVisible = q->isVisible(); -
2732 -
2733 -
2734 if (!isVisible && !isAboutToShow()) {
-
2735 QWidget *topLevel = q->window(); -
2736 (void)topLevel->d_func()->topData(); -
2737 topLevel->ensurePolished(); -
2738 -
2739 -
2740 -
2741 QWidget *widget = q; -
2742 QWidgetList hiddenWidgets; -
2743 while (widget) {
-
2744 if (widget->isHidden()) {
-
2745 widget->setAttribute(Qt::WA_WState_Hidden, false); -
2746 hiddenWidgets.append(widget); -
2747 if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
-
2748 widget->d_func()->updateGeometry_helper(true);
-
2749 }
-
2750 widget = widget->parentWidget(); -
2751 }
-
2752 -
2753 -
2754 if (topLevel->d_func()->layout)
-
2755 topLevel->d_func()->layout->activate();
-
2756 -
2757 -
2758 QTLWExtra *topLevelExtra = topLevel->d_func()->maybeTopData(); -
2759 if (topLevelExtra && !topLevelExtra->sizeAdjusted
-
2760 && !topLevel->testAttribute(Qt::WA_Resized)) {
-
2761 topLevel->adjustSize(); -
2762 topLevel->setAttribute(Qt::WA_Resized, false); -
2763 }
-
2764 -
2765 -
2766 topLevel->d_func()->activateChildLayoutsRecursively(); -
2767 -
2768 -
2769 for (int i = 0; i < hiddenWidgets.size(); ++i) {
-
2770 QWidget *widget = hiddenWidgets.at(i); -
2771 widget->setAttribute(Qt::WA_WState_Hidden); -
2772 if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
-
2773 widget->parentWidget()->d_func()->layout->invalidate();
-
2774 }
-
2775 } else if (isVisible) {
-
2776 q->window()->d_func()->sendPendingMoveAndResizeEvents(true, true); -
2777 }
-
2778 -
2779 -
2780 QRegion toBePainted = !region.isEmpty() ? region : QRegion(q->rect());
-
2781 if (!(renderFlags & QWidget::IgnoreMask) && extra && extra->hasMask)
-
2782 toBePainted &= extra->mask;
-
2783 return toBePainted;
-
2784} -
2785 -
2786void QWidgetPrivate::render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &toBePainted, -
2787 QWidget::RenderFlags renderFlags) -
2788{ -
2789 qt_noop(); -
2790 qt_noop(); -
2791 -
2792 QWidget * const q = q_func(); -
2793 -
2794 const QTransform originalTransform = painter->worldTransform(); -
2795 const bool useDeviceCoordinates = originalTransform.isScaling(); -
2796 if (!useDeviceCoordinates) {
-
2797 -
2798 -
2799 const QRect rect = toBePainted.boundingRect(); -
2800 const QSize size = rect.size(); -
2801 if (size.isNull())
-
2802 return;
-
2803 -
2804 QPixmap pixmap(size); -
2805 if (!(renderFlags & QWidget::DrawWindowBackground) || !isOpaque)
-
2806 pixmap.fill(Qt::transparent);
-
2807 q->render(&pixmap, QPoint(), toBePainted, renderFlags); -
2808 -
2809 const bool restore = !(painter->renderHints() & QPainter::SmoothPixmapTransform); -
2810 painter->setRenderHints(QPainter::SmoothPixmapTransform, true); -
2811 -
2812 painter->drawPixmap(targetOffset, pixmap); -
2813 -
2814 if (restore)
-
2815 painter->setRenderHints(QPainter::SmoothPixmapTransform, false);
-
2816 -
2817 -
2818 } else {
-
2819 -
2820 QTransform transform = originalTransform; -
2821 transform.translate(targetOffset.x(), targetOffset.y()); -
2822 -
2823 QPaintDevice *device = painter->device(); -
2824 qt_noop(); -
2825 -
2826 -
2827 const QRectF rect(toBePainted.boundingRect()); -
2828 QRect deviceRect = transform.mapRect(QRectF(0, 0, rect.width(), rect.height())).toAlignedRect(); -
2829 deviceRect &= QRect(0, 0, device->width(), device->height()); -
2830 -
2831 QPixmap pixmap(deviceRect.size()); -
2832 pixmap.fill(Qt::transparent); -
2833 -
2834 -
2835 QPainter pixmapPainter(&pixmap); -
2836 pixmapPainter.setRenderHints(painter->renderHints()); -
2837 transform *= QTransform::fromTranslate(-deviceRect.x(), -deviceRect.y()); -
2838 pixmapPainter.setTransform(transform); -
2839 -
2840 q->render(&pixmapPainter, QPoint(), toBePainted, renderFlags); -
2841 pixmapPainter.end(); -
2842 -
2843 -
2844 painter->setTransform(QTransform()); -
2845 painter->drawPixmap(deviceRect.topLeft(), pixmap); -
2846 painter->setTransform(originalTransform); -
2847 }
-
2848 -
2849} -
2850 -
2851void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, -
2852 QPainter *sharedPainter, QWidgetBackingStore *backingStore) -
2853{ -
2854 if (rgn.isEmpty())
-
2855 return;
-
2856 QWidget * const q = q_func(); -
2857 -
2858 if (graphicsEffect && graphicsEffect->isEnabled()) {
-
2859 QGraphicsEffectSource *source = graphicsEffect->d_func()->source; -
2860 QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *> -
2861 (source->d_func()); -
2862 if (!sourced->context) {
-
2863 QWidgetPaintContext context(pdev, rgn, offset, flags, sharedPainter, backingStore); -
2864 sourced->context = &context; -
2865 if (!sharedPainter) {
-
2866 setSystemClip(pdev, rgn.translated(offset)); -
2867 QPainter p(pdev); -
2868 p.translate(offset); -
2869 context.painter = &p; -
2870 graphicsEffect->draw(&p); -
2871 setSystemClip(pdev, QRegion()); -
2872 } else {
-
2873 context.painter = sharedPainter; -
2874 if (sharedPainter->worldTransform() != sourced->lastEffectTransform) {
-
2875 sourced->invalidateCache(); -
2876 sourced->lastEffectTransform = sharedPainter->worldTransform(); -
2877 }
-
2878 sharedPainter->save(); -
2879 sharedPainter->translate(offset); -
2880 graphicsEffect->draw(sharedPainter); -
2881 sharedPainter->restore(); -
2882 }
-
2883 sourced->context = 0; -
2884 return;
-
2885 } -
2886 }
-
2887 -
2888 -
2889 const bool asRoot = flags & DrawAsRoot; -
2890 const bool alsoOnScreen = flags & DrawPaintOnScreen; -
2891 const bool recursive = flags & DrawRecursive; -
2892 const bool alsoInvisible = flags & DrawInvisible; -
2893 -
2894 qt_noop(); -
2895 -
2896 QRegion toBePainted(rgn); -
2897 if (asRoot && !alsoInvisible)
-
2898 toBePainted &= clipRect();
-
2899 if (!(flags & DontSubtractOpaqueChildren))
-
2900 subtractOpaqueChildren(toBePainted, q->rect());
-
2901 -
2902 if (!toBePainted.isEmpty()) {
-
2903 bool onScreen = paintOnScreen(); -
2904 if (!onScreen || alsoOnScreen) {
-
2905 -
2906 if (q->testAttribute(Qt::WA_WState_InPaintEvent))
-
2907 QMessageLogger("kernel/qwidget.cpp", 50615076, __PRETTY_FUNCTION__).warning("QWidget::repaint: Recursive repaint detected");
-
2908 q->setAttribute(Qt::WA_WState_InPaintEvent); -
2909 -
2910 -
2911 -
2912 -
2913 -
2914 QPaintEngine *paintEngine = pdev->paintEngine(); -
2915 if (paintEngine) {
-
2916 setRedirected(pdev, -offset); -
2917 if (sharedPainter)
-
2918 setSystemClip(pdev, toBePainted);
-
2919 else -
2920 paintEngine->d_func()->systemRect = q->data->crect;
-
2921 -
2922 -
2923 if ((asRoot || q->autoFillBackground() || onScreen || q->testAttribute(Qt::WA_StyledBackground))
-
2924 && !q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) {
-
2925 QPainter p(q); -
2926 paintBackground(&p, toBePainted, (asRoot || onScreen) ? flags | DrawAsRoot : 0); -
2927 }
-
2928 -
2929 if (!sharedPainter)
-
2930 setSystemClip(pdev, toBePainted.translated(offset));
-
2931 -
2932 if (!onScreen && !asRoot && !isOpaque && q->testAttribute(Qt::WA_TintedBackground)) {
-
2933 QPainter p(q); -
2934 QColor tint = q->palette().window().color(); -
2935 tint.setAlphaF(qreal(.6)); -
2936 p.fillRect(toBePainted.boundingRect(), tint); -
2937 }
-
2938 }
-
2939 QPaintEvent e(toBePainted); -
2940 QCoreApplication::sendSpontaneousEvent(q, &e); -
2941 -
2942 -
2943 if (backingStore && !onScreen && !asRoot && (q->internalWinId() || !q->nativeParentWidget()->isWindow()))
-
2944 backingStore->markDirtyOnScreen(toBePainted, q, offset);
-
2945 -
2946 -
2947 if (paintEngine) {
-
2948 -
2949 -
2950 -
2951 -
2952 restoreRedirected(); -
2953 if (!sharedPainter)
-
2954 paintEngine->d_func()->systemRect = QRect();
-
2955 else -
2956 paintEngine->d_func()->currentClipDevice = 0;
-
2957 -
2958 setSystemClip(pdev, QRegion()); -
2959 }
-
2960 q->setAttribute(Qt::WA_WState_InPaintEvent, false); -
2961 if (q->paintingActive())
-
2962 QMessageLogger("kernel/qwidget.cpp", 51345149, __PRETTY_FUNCTION__).warning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
-
2963 -
2964 if (paintEngine && paintEngine->autoDestruct()) {
-
2965 delete paintEngine; -
2966 }
-
2967 -
2968 -
2969 -
2970 -
2971 -
2972 } else if (q->isWindow()) {
-
2973 QPaintEngine *engine = pdev->paintEngine(); -
2974 if (engine) {
-
2975 QPainter p(pdev); -
2976 p.setClipRegion(toBePainted); -
2977 const QBrush bg = q->palette().brush(QPalette::Window); -
2978 if (bg.style() == Qt::TexturePattern)
-
2979 p.drawTiledPixmap(q->rect(), bg.texture());
-
2980 else -
2981 p.fillRect(q->rect(), bg);
-
2982 -
2983 if (engine->autoDestruct())
-
2984 delete engine;
-
2985 }
-
2986 }
-
2987 } -
2988 -
2989 if (recursive && !children.isEmpty()) {
-
2990 paintSiblingsRecursive(pdev, children, children.size() - 1, rgn, offset, flags & ~DrawAsRoot -
2991 , sharedPainter, backingStore); -
2992 }
-
2993}
-
2994 -
2995void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, -
2996 const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, -
2997 bool readyToRender) -
2998{ -
2999 if (!target) {
-
3000 QMessageLogger("kernel/qwidget.cpp", 51725187, __PRETTY_FUNCTION__).warning("QWidget::render: null pointer to paint device"); -
3001 return;
-
3002 } -
3003 -
3004 const bool inRenderWithPainter = extra && extra->inRenderWithPainter;
-
3005 QRegion paintRegion = !inRenderWithPainter && !readyToRender
-
3006 ? prepareToRender(sourceRegion, renderFlags) -
3007 : sourceRegion; -
3008 if (paintRegion.isEmpty())
-
3009 return;
-
3010 -
3011 -
3012 QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : 0;
-
3013 -
3014 -
3015 -
3016 if (target->devType() == QInternal::Widget) {
-
3017 QWidgetPrivate *targetPrivate = static_cast<QWidget *>(target)->d_func(); -
3018 if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) {
-
3019 QPainter *targetPainter = targetPrivate->sharedPainter(); -
3020 if (targetPainter && targetPainter->isActive())
-
3021 setSharedPainter(targetPainter);
-
3022 }
-
3023 }
-
3024 -
3025 -
3026 -
3027 -
3028 -
3029 QPoint offset = targetOffset; -
3030 offset -= paintRegion.boundingRect().topLeft(); -
3031 QPoint redirectionOffset; -
3032 QPaintDevice *redirected = 0; -
3033 -
3034 if (target->devType() == QInternal::Widget)
-
3035 redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset);
-
3036 if (!redirected)
-
3037 redirected = QPainter::redirected(target, &redirectionOffset);
-
3038 -
3039 if (redirected) {
-
3040 target = redirected; -
3041 offset -= redirectionOffset; -
3042 }
-
3043 -
3044 if (!inRenderWithPainter) {
-
3045 if (QPaintEngine *targetEngine = target->paintEngine()) {
-
3046 const QRegion targetSystemClip = targetEngine->systemClip(); -
3047 if (!targetSystemClip.isEmpty())
-
3048 paintRegion &= targetSystemClip.translated(-offset);
-
3049 }
-
3050 }
-
3051 -
3052 -
3053 int flags = DrawPaintOnScreen | DrawInvisible; -
3054 if (renderFlags & QWidget::DrawWindowBackground)
-
3055 flags |= DrawAsRoot;
-
3056 -
3057 if (renderFlags & QWidget::DrawChildren)
-
3058 flags |= DrawRecursive;
-
3059 else -
3060 flags |= DontSubtractOpaqueChildren;
-
3061 -
3062 flags |= DontSetCompositionMode; -
3063 -
3064 if (target->devType() == QInternal::Printer) {
-
3065 QPainter p(target); -
3066 render_helper(&p, targetOffset, paintRegion, renderFlags); -
3067 return;
-
3068 } -
3069 -
3070 -
3071 -
3072 drawWidget(target, paintRegion, offset, flags, sharedPainter()); -
3073 -
3074 -
3075 if (oldSharedPainter)
-
3076 setSharedPainter(oldSharedPainter);
-
3077 -
3078 -
3079 -
3080 -
3081}
-
3082 -
3083void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& siblings, int index, const QRegion &rgn, -
3084 const QPoint &offset, int flags -
3085 , QPainter *sharedPainter, QWidgetBackingStore *backingStore) -
3086{ -
3087 QWidget *w = 0; -
3088 QRect boundingRect; -
3089 bool dirtyBoundingRect = true; -
3090 const bool exludeOpaqueChildren = (flags & DontDrawOpaqueChildren); -
3091 const bool excludeNativeChildren = (flags & DontDrawNativeChildren); -
3092 -
3093 do { -
3094 QWidget *x = qobject_cast<QWidget*>(siblings.at(index)); -
3095 if (x && !(exludeOpaqueChildren && x->d_func()->isOpaque) && !x->isHidden() && !x->isWindow()
-
3096 && !(excludeNativeChildren && x->internalWinId())) {
-
3097 if (dirtyBoundingRect) {
-
3098 boundingRect = rgn.boundingRect(); -
3099 dirtyBoundingRect = false; -
3100 }
-
3101 -
3102 if (qRectIntersects(boundingRect, x->d_func()->effectiveRectFor(x->data->crect))) {
-
3103 w = x; -
3104 break;
-
3105 } -
3106 }
-
3107 --index; -
3108 } while (index >= 0);
-
3109 -
3110 if (!w)
-
3111 return;
-
3112 -
3113 QWidgetPrivate *wd = w->d_func(); -
3114 const QPoint widgetPos(w->data->crect.topLeft()); -
3115 const bool hasMask = wd->extra && wd->extra->hasMask && !wd->graphicsEffect;
-
3116 if (index > 0) {
-
3117 QRegion wr(rgn); -
3118 if (wd->isOpaque)
-
3119 wr -= hasMask ? wd->extra->mask.translated(widgetPos) : w->data->crect;
-
3120 paintSiblingsRecursive(pdev, siblings, --index, wr, offset, flags -
3121 , sharedPainter, backingStore); -
3122 }
-
3123 -
3124 if (w->updatesEnabled()
-
3125 -
3126 && (!w->d_func()->extra || !w->d_func()->extra->proxyWidget)
-
3127 -
3128 ) { -
3129 QRegion wRegion(rgn); -
3130 wRegion &= wd->effectiveRectFor(w->data->crect); -
3131 wRegion.translate(-widgetPos); -
3132 if (hasMask)
-
3133 wRegion &= wd->extra->mask;
-
3134 wd->drawWidget(pdev, wRegion, offset + widgetPos, flags, sharedPainter, backingStore); -
3135 }
-
3136}
-
3137 -
3138 -
3139QRectF QWidgetEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const -
3140{ -
3141 if (system != Qt::DeviceCoordinates)
-
3142 return m_widget->rect();
-
3143 -
3144 if (!context) {
-
3145 -
3146 QMessageLogger("kernel/qwidget.cpp", 53185333, __PRETTY_FUNCTION__).warning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context"); -
3147 return QRectF();
-
3148 } -
3149 -
3150 return context->painter->worldTransform().mapRect(m_widget->rect());
-
3151} -
3152 -
3153void QWidgetEffectSourcePrivate::draw(QPainter *painter) -
3154{ -
3155 if (!context || context->painter != painter) {
-
3156 m_widget->render(painter); -
3157 return;
-
3158 } -
3159 -
3160 -
3161 -
3162 QRegion toBePainted = context->rgn; -
3163 toBePainted &= m_widget->rect(); -
3164 QWidgetPrivate *wd = qt_widget_private(m_widget); -
3165 if (wd->extra && wd->extra->hasMask)
-
3166 toBePainted &= wd->extra->mask;
-
3167 -
3168 wd->drawWidget(context->pdev, toBePainted, context->offset, context->flags, -
3169 context->sharedPainter, context->backingStore); -
3170}
-
3171 -
3172QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset, -
3173 QGraphicsEffect::PixmapPadMode mode) const -
3174{ -
3175 const bool deviceCoordinates = (system == Qt::DeviceCoordinates); -
3176 if (!context && deviceCoordinates) {
-
3177 -
3178 QMessageLogger("kernel/qwidget.cpp", 53505365, __PRETTY_FUNCTION__).warning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); -
3179 return QPixmap();
-
3180 } -
3181 -
3182 QPoint pixmapOffset; -
3183 QRectF sourceRect = m_widget->rect(); -
3184 -
3185 if (deviceCoordinates) {
-
3186 const QTransform &painterTransform = context->painter->worldTransform(); -
3187 sourceRect = painterTransform.mapRect(sourceRect); -
3188 pixmapOffset = painterTransform.map(pixmapOffset); -
3189 }
-
3190 -
3191 QRect effectRect; -
3192 -
3193 if (mode == QGraphicsEffect::PadToEffectiveBoundingRect)
-
3194 effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect();
-
3195 else if (mode == QGraphicsEffect::PadToTransparentBorder)
-
3196 effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect();
-
3197 else -
3198 effectRect = sourceRect.toAlignedRect();
-
3199 -
3200 if (offset)
-
3201 *offset = effectRect.topLeft();
-
3202 -
3203 pixmapOffset -= effectRect.topLeft(); -
3204 -
3205 QPixmap pixmap(effectRect.size()); -
3206 pixmap.fill(Qt::transparent); -
3207 m_widget->render(&pixmap, pixmapOffset, QRegion(), QWidget::DrawChildren); -
3208 return pixmap;
-
3209} -
3210QGraphicsProxyWidget * QWidgetPrivate::nearestGraphicsProxyWidget(const QWidget *origin) -
3211{ -
3212 if (origin) {
-
3213 QWExtra *extra = origin->d_func()->extra; -
3214 if (extra && extra->proxyWidget)
-
3215 return extra->proxyWidget;
-
3216 return nearestGraphicsProxyWidget(origin->parentWidget());
-
3217 } -
3218 return 0;
-
3219} -
3220void QWidgetPrivate::setLocale_helper(const QLocale &loc, bool forceUpdate) -
3221{ -
3222 QWidget * const q = q_func(); -
3223 if (locale == loc && !forceUpdate)
-
3224 return;
-
3225 -
3226 locale = loc; -
3227 -
3228 if (!children.isEmpty()) {
-
3229 for (int i = 0; i < children.size(); ++i) {
-
3230 QWidget *w = qobject_cast<QWidget*>(children.at(i)); -
3231 if (!w)
-
3232 continue;
-
3233 if (w->testAttribute(Qt::WA_SetLocale))
-
3234 continue;
-
3235 if (w->isWindow() && !w->testAttribute(Qt::WA_WindowPropagation))
-
3236 continue;
-
3237 w->d_func()->setLocale_helper(loc, forceUpdate); -
3238 }
-
3239 }
-
3240 QEvent e(QEvent::LocaleChange); -
3241 QApplication::sendEvent(q, &e); -
3242}
-
3243 -
3244void QWidget::setLocale(const QLocale &locale) -
3245{ -
3246 QWidgetPrivate * const d = d_func(); -
3247 -
3248 setAttribute(Qt::WA_SetLocale); -
3249 d->setLocale_helper(locale); -
3250}
-
3251 -
3252QLocale QWidget::locale() const -
3253{ -
3254 const QWidgetPrivate * const d = d_func(); -
3255 -
3256 return d->locale;
-
3257} -
3258 -
3259void QWidgetPrivate::resolveLocale() -
3260{ -
3261 const QWidget * const q = q_func(); -
3262 -
3263 if (!q->testAttribute(Qt::WA_SetLocale)) {
-
3264 setLocale_helper(q->isWindow() -
3265 ? QLocale() -
3266 : q->parentWidget()->locale()); -
3267 }
-
3268}
-
3269 -
3270void QWidget::unsetLocale() -
3271{ -
3272 QWidgetPrivate * const d = d_func(); -
3273 setAttribute(Qt::WA_SetLocale, false); -
3274 d->resolveLocale(); -
3275}
-
3276QString QWidget::windowTitle() const -
3277{ -
3278 const QWidgetPrivate * const d = d_func(); -
3279 if (d->extra && d->extra->topextra) {
-
3280 if (!d->extra->topextra->caption.isEmpty())
-
3281 return d->extra->topextra->caption;
-
3282 if (!d->extra->topextra->filePath.isEmpty())
-
3283 return QFileInfo(d->extra->topextra->filePath).fileName() + QLatin1String("[*]");
-
3284 }
-
3285 return QString();
-
3286} -
3287QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widget) -
3288{ -
3289 qt_noop(); -
3290 -
3291 -
3292 -
3293 -
3294 -
3295 QString cap = title; -
3296 -
3297 -
3298 if (cap.isEmpty())
-
3299 return cap;
-
3300 -
3301 QLatin1String placeHolder("[*]"); -
3302 int index = cap.indexOf(placeHolder); -
3303 -
3304 -
3305 while (index != -1) {
-
3306 index += placeHolder.size(); -
3307 int count = 1; -
3308 while (cap.indexOf(placeHolder, index) == index) {
-
3309 ++count; -
3310 index += placeHolder.size(); -
3311 }
-
3312 -
3313 if (count%2) {
-
3314 int lastIndex = cap.lastIndexOf(placeHolder, index - 1); -
3315 if (widget->isWindowModified()
-
3316 && widget->style()->styleHint(QStyle::SH_TitleBar_ModifyNotification, 0, widget))
-
3317 cap.replace(lastIndex, 3, QWidget::tr("*"));
-
3318 else -
3319 cap.remove(lastIndex, 3);
-
3320 } -
3321 -
3322 index = cap.indexOf(placeHolder, index); -
3323 }
-
3324 -
3325 cap.replace(QLatin1String("[*][*]"), placeHolder); -
3326 -
3327 return cap;
-
3328} -
3329 -
3330void QWidgetPrivate::setWindowTitle_helper(const QString &title) -
3331{ -
3332 QWidget * const q = q_func(); -
3333 if (q->testAttribute(Qt::WA_WState_Created))
-
3334 setWindowTitle_sys(qt_setWindowTitle_helperHelper(title, q));
-
3335}
-
3336 -
3337void QWidgetPrivate::setWindowIconText_helper(const QString &title) -
3338{ -
3339 QWidget * const q = q_func(); -
3340 if (q->testAttribute(Qt::WA_WState_Created))
-
3341 setWindowIconText_sys(qt_setWindowTitle_helperHelper(title, q));
-
3342}
-
3343 -
3344void QWidget::setWindowIconText(const QString &iconText) -
3345{ -
3346 if (QWidget::windowIconText() == iconText)
-
3347 return;
-
3348 -
3349 QWidgetPrivate * const d = d_func(); -
3350 d->topData()->iconText = iconText; -
3351 d->setWindowIconText_helper(iconText); -
3352 -
3353 QEvent e(QEvent::IconTextChange); -
3354 QApplication::sendEvent(this, &e); -
3355}
-
3356 -
3357void QWidget::setWindowTitle(const QString &title) -
3358{ -
3359 if (QWidget::windowTitle() == title && !title.isEmpty() && !title.isNull())
-
3360 return;
-
3361 -
3362 QWidgetPrivate * const d = d_func(); -
3363 d->topData()->caption = title; -
3364 d->setWindowTitle_helper(title); -
3365 -
3366 QEvent e(QEvent::WindowTitleChange); -
3367 QApplication::sendEvent(this, &e); -
3368}
-
3369QIcon QWidget::windowIcon() const -
3370{ -
3371 const QWidget *w = this; -
3372 while (w) {
-
3373 const QWidgetPrivate *d = w->d_func(); -
3374 if (d->extra && d->extra->topextra && d->extra->topextra->icon)
-
3375 return *d->extra->topextra->icon;
-
3376 w = w->parentWidget(); -
3377 }
-
3378 return QApplication::windowIcon();
-
3379} -
3380 -
3381void QWidgetPrivate::setWindowIcon_helper() -
3382{ -
3383 QEvent e(QEvent::WindowIconChange); -
3384 QApplication::sendEvent(q_func(), &e); -
3385 for (int i = 0; i < children.size(); ++i) {
-
3386 QWidget *w = qobject_cast<QWidget *>(children.at(i)); -
3387 if (w && !w->isWindow())
-
3388 QApplication::sendEvent(w, &e);
-
3389 }
-
3390}
-
3391 -
3392void QWidget::setWindowIcon(const QIcon &icon) -
3393{ -
3394 QWidgetPrivate * const d = d_func(); -
3395 -
3396 setAttribute(Qt::WA_SetWindowIcon, !icon.isNull()); -
3397 d->createTLExtra(); -
3398 -
3399 if (!d->extra->topextra->icon)
-
3400 d->extra->topextra->icon = new QIcon();
-
3401 *d->extra->topextra->icon = icon; -
3402 -
3403 d->setWindowIcon_sys(); -
3404 d->setWindowIcon_helper(); -
3405}
-
3406QString QWidget::windowIconText() const -
3407{ -
3408 const QWidgetPrivate * const d = d_func(); -
3409 return (d->extra && d->extra->topextra) ? d->extra->topextra->iconText : QString();
-
3410} -
3411QString QWidget::windowFilePath() const -
3412{ -
3413 const QWidgetPrivate * const d = d_func(); -
3414 return (d->extra && d->extra->topextra) ? d->extra->topextra->filePath : QString();
-
3415} -
3416 -
3417void QWidget::setWindowFilePath(const QString &filePath) -
3418{ -
3419 if (filePath == windowFilePath())
-
3420 return;
-
3421 -
3422 QWidgetPrivate * const d = d_func(); -
3423 -
3424 d->createTLExtra(); -
3425 d->extra->topextra->filePath = filePath; -
3426 d->setWindowFilePath_helper(filePath); -
3427}
-
3428 -
3429void QWidgetPrivate::setWindowFilePath_helper(const QString &filePath) -
3430{ -
3431 if (extra->topextra && extra->topextra->caption.isEmpty()) {
-
3432 -
3433 -
3434 -
3435 QWidget * const q = q_func(); -
3436 (void)filePath;; -
3437 setWindowTitle_helper(q->windowTitle()); -
3438 -
3439 }
-
3440 -
3441 -
3442 -
3443}
-
3444 -
3445 -
3446 -
3447 -
3448 -
3449 -
3450 -
3451QString QWidget::windowRole() const -
3452{ -
3453 const QWidgetPrivate * const d = d_func(); -
3454 return (d->extra && d->extra->topextra) ? d->extra->topextra->role : QString();
-
3455} -
3456 -
3457 -
3458 -
3459 -
3460 -
3461void QWidget::setWindowRole(const QString &role) -
3462{ -
3463 -
3464 -
3465 -
3466 -
3467 -
3468 (void)role; -
3469 -
3470}
-
3471void QWidget::setFocusProxy(QWidget * w) -
3472{ -
3473 QWidgetPrivate * const d = d_func(); -
3474 if (!w && !d->extra)
-
3475 return;
-
3476 -
3477 for (QWidget* fp = w; fp; fp = fp->focusProxy()) {
-
3478 if (fp == this) {
-
3479 QMessageLogger("kernel/qwidget.cpp", 57955810, __PRETTY_FUNCTION__).warning("QWidget: %s (%s) already in focus proxy chain", metaObject()->className(), objectName().toLocal8Bit().constData()); -
3480 return;
-
3481 } -
3482 }
-
3483 -
3484 d->createExtra(); -
3485 d->extra->focus_proxy = w; -
3486}
-
3487QWidget * QWidget::focusProxy() const -
3488{ -
3489 const QWidgetPrivate * const d = d_func(); -
3490 return d->extra ? (QWidget *)d->extra->focus_proxy : 0;
-
3491} -
3492bool QWidget::hasFocus() const -
3493{ -
3494 const QWidget* w = this; -
3495 while (w->d_func()->extra && w->d_func()->extra->focus_proxy)
-
3496 w = w->d_func()->extra->focus_proxy;
-
3497 if (QWidget *window = w->window()) {
-
3498 -
3499 QWExtra *e = window->d_func()->extra; -
3500 if (e && e->proxyWidget && e->proxyWidget->hasFocus() && window->focusWidget() == w)
-
3501 return true;
-
3502 -
3503 }
-
3504 return (QApplication::focusWidget() == w);
-
3505} -
3506void QWidget::setFocus(Qt::FocusReason reason) -
3507{ -
3508 if (!isEnabled())
-
3509 return;
-
3510 -
3511 QWidget *f = this; -
3512 while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
-
3513 f = f->d_func()->extra->focus_proxy;
-
3514 -
3515 if (QApplication::focusWidget() == f
-
3516 -
3517 -
3518 -
3519 ) -
3520 return;
-
3521 -
3522 -
3523 QWidget *previousProxyFocus = 0; -
3524 if (QWExtra *topData = window()->d_func()->extra) {
-
3525 if (topData->proxyWidget && topData->proxyWidget->hasFocus()) {
-
3526 previousProxyFocus = topData->proxyWidget->widget()->focusWidget(); -
3527 if (previousProxyFocus && previousProxyFocus->focusProxy())
-
3528 previousProxyFocus = previousProxyFocus->focusProxy();
-
3529 if (previousProxyFocus == this && !topData->proxyWidget->d_func()->proxyIsGivingFocus)
-
3530 return;
-
3531 }
-
3532 }
-
3533 -
3534 -
3535 -
3536 -
3537 if (QWExtra *topData = window()->d_func()->extra) {
-
3538 if (topData->proxyWidget && !topData->proxyWidget->hasFocus()) {
-
3539 f->d_func()->updateFocusChild(); -
3540 topData->proxyWidget->d_func()->focusFromWidgetToProxy = 1; -
3541 topData->proxyWidget->setFocus(reason); -
3542 topData->proxyWidget->d_func()->focusFromWidgetToProxy = 0; -
3543 }
-
3544 }
-
3545 -
3546 -
3547 if (f->isActiveWindow()) {
-
3548 QWidget *prev = QApplicationPrivate::focus_widget; -
3549 if (prev) {
-
3550 if (reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
-
3551 && prev->testAttribute(Qt::WA_InputMethodEnabled)) {
-
3552 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->commit(); -
3553 }
-
3554 -
3555 if (reason != Qt::NoFocusReason) {
-
3556 QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, reason); -
3557 QApplication::sendEvent(prev, &focusAboutToChange); -
3558 }
-
3559 }
-
3560 -
3561 f->d_func()->updateFocusChild(); -
3562 -
3563 QApplicationPrivate::setFocusWidget(f, reason); -
3564 if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem")))
-
3565 -
3566 { -
3567 QAccessibleEvent event(f, QAccessible::Focus); -
3568 QAccessible::updateAccessibility(&event); -
3569 }
-
3570 -
3571 -
3572 if (QWExtra *topData = window()->d_func()->extra) {
-
3573 if (topData->proxyWidget) {
-
3574 if (previousProxyFocus && previousProxyFocus != f) {
-
3575 -
3576 QFocusEvent event(QEvent::FocusOut, reason); -
3577 QPointer<QWidget> that = previousProxyFocus; -
3578 QApplication::sendEvent(previousProxyFocus, &event); -
3579 if (that)
-
3580 QApplication::sendEvent(that->style(), &event);
-
3581 }
-
3582 if (!isHidden()) {
-
3583 -
3584 -
3585 if (QWExtra *topData = window()->d_func()->extra)
-
3586 if (topData->proxyWidget && topData->proxyWidget->hasFocus())
-
3587 topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget();
-
3588 -
3589 -
3590 QFocusEvent event(QEvent::FocusIn, reason); -
3591 QPointer<QWidget> that = f; -
3592 QApplication::sendEvent(f, &event); -
3593 if (that)
-
3594 QApplication::sendEvent(that->style(), &event);
-
3595 }
-
3596 }
-
3597 }
-
3598 -
3599 } else {
-
3600 f->d_func()->updateFocusChild(); -
3601 }
-
3602 -
3603 if (QTLWExtra *extra = f->window()->d_func()->maybeTopData()) {
-
3604 if (extra->window)
-
3605 extra->window->focusObjectChanged(f);
-
3606 }
-
3607}
-
3608 -
3609 -
3610void QWidgetPrivate::updateFocusChild() -
3611{ -
3612 QWidget * const q = q_func(); -
3613 -
3614 QWidget *w = q; -
3615 if (q->isHidden()) {
-
3616 while (w && w->isHidden()) {
-
3617 w->d_func()->focus_child = q; -
3618 w = w->isWindow() ? 0 : w->parentWidget();
-
3619 }
-
3620 } else {
-
3621 while (w) {
-
3622 w->d_func()->focus_child = q; -
3623 w = w->isWindow() ? 0 : w->parentWidget();
-
3624 }
-
3625 }
-
3626} -
3627void QWidget::clearFocus() -
3628{ -
3629 if (hasFocus()) {
-
3630 if (testAttribute(Qt::WA_InputMethodEnabled))
-
3631 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->commit();
-
3632 -
3633 QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); -
3634 QApplication::sendEvent(this, &focusAboutToChange); -
3635 }
-
3636 -
3637 QWidget *w = this; -
3638 while (w) {
-
3639 if (w->d_func()->focus_child == this)
-
3640 w->d_func()->focus_child = 0;
-
3641 w = w->parentWidget(); -
3642 }
-
3643 -
3644 QWExtra *topData = d_func()->extra; -
3645 if (topData && topData->proxyWidget)
-
3646 topData->proxyWidget->clearFocus();
-
3647 -
3648 -
3649 if (hasFocus()) {
-
3650 -
3651 QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason); -
3652 -
3653 -
3654 -
3655 -
3656 -
3657 { -
3658 -
3659 QAccessibleEvent event(this, QAccessible::Focus); -
3660 QAccessible::updateAccessibility(&event); -
3661 -
3662 } -
3663 }
-
3664}
-
3665bool QWidget::focusNextPrevChild(bool next) -
3666{ -
3667 QWidgetPrivate * const d = d_func(); -
3668 QWidget* p = parentWidget(); -
3669 bool isSubWindow = (windowType() == Qt::SubWindow); -
3670 if (!isWindow() && !isSubWindow && p)
-
3671 return p->focusNextPrevChild(next);
-
3672 -
3673 if (d->extra && d->extra->proxyWidget)
-
3674 return d->extra->proxyWidget->focusNextPrevChild(next);
-
3675 -
3676 QWidget *w = QApplicationPrivate::focusNextPrevChild_helper(this, next); -
3677 if (!w) return false;
-
3678 -
3679 w->setFocus(next ? Qt::TabFocusReason : Qt::BacktabFocusReason); -
3680 return true;
-
3681} -
3682QWidget *QWidget::focusWidget() const -
3683{ -
3684 return const_cast<QWidget *>(d_func()->focus_child);
-
3685} -
3686 -
3687 -
3688 -
3689 -
3690 -
3691 -
3692QWidget *QWidget::nextInFocusChain() const -
3693{ -
3694 return const_cast<QWidget *>(d_func()->focus_next);
-
3695} -
3696QWidget *QWidget::previousInFocusChain() const -
3697{ -
3698 return const_cast<QWidget *>(d_func()->focus_prev);
-
3699} -
3700bool QWidget::isActiveWindow() const -
3701{ -
3702 QWidget *tlw = window(); -
3703 if(tlw == QApplication::activeWindow() || (isVisible() && (tlw->windowType() == Qt::Popup)))
-
3704 return true;
-
3705 -
3706 -
3707 if (QWExtra *tlwExtra = tlw->d_func()->extra) {
-
3708 if (isVisible() && tlwExtra->proxyWidget)
-
3709 return tlwExtra->proxyWidget->isActiveWindow();
-
3710 }
-
3711 -
3712 -
3713 if(style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, this)) {
-
3714 if(tlw->windowType() == Qt::Tool &&
-
3715 !tlw->isModal() &&
-
3716 (!tlw->parentWidget() || tlw->parentWidget()->isActiveWindow()))
-
3717 return true;
-
3718 QWidget *w = QApplication::activeWindow(); -
3719 while(w && tlw->windowType() == Qt::Tool &&
-
3720 !w->isModal() && w->parentWidget()) {
-
3721 w = w->parentWidget()->window(); -
3722 if(w == tlw)
-
3723 return true;
-
3724 }
-
3725 }
-
3726 -
3727 -
3728 -
3729 -
3730 -
3731 -
3732 if (const QWindow *w = tlw->windowHandle()) {
-
3733 if (w->handle())
-
3734 return w->handle()->isActive();
-
3735 }
-
3736 -
3737 return false;
-
3738} -
3739void QWidget::setTabOrder(QWidget* first, QWidget *second) -
3740{ -
3741 if (!first || !second || first->focusPolicy() == Qt::NoFocus || second->focusPolicy() == Qt::NoFocus)
-
3742 return;
-
3743 -
3744 if (first->window() != second->window()) {
-
3745 QMessageLogger("kernel/qwidget.cpp", 62476262, __PRETTY_FUNCTION__).warning("QWidget::setTabOrder: 'first' and 'second' must be in the same window"); -
3746 return;
-
3747 } -
3748 -
3749 QWidget *fp = first->focusProxy(); -
3750 if (fp) {
-
3751 -
3752 -
3753 -
3754 -
3755 QList<QWidget *> l = first->findChildren<QWidget *>(); -
3756 for (int i = l.size()-1; i >= 0; --i) {
-
3757 QWidget * next = l.at(i); -
3758 if (next->window() == fp->window()) {
-
3759 fp = next; -
3760 if (fp->focusPolicy() != Qt::NoFocus)
-
3761 break;
-
3762 }
-
3763 }
-
3764 first = fp; -
3765 }
-
3766 -
3767 if (fp == second)
-
3768 return;
-
3769 -
3770 if (QWidget *sp = second->focusProxy())
-
3771 second = sp;
-
3772 -
3773 -
3774 QWidget *fn = first->d_func()->focus_next; -
3775 -
3776 if (fn == second || first == second)
-
3777 return;
-
3778 -
3779 QWidget *sp = second->d_func()->focus_prev; -
3780 QWidget *sn = second->d_func()->focus_next; -
3781 -
3782 fn->d_func()->focus_prev = second; -
3783 first->d_func()->focus_next = second; -
3784 -
3785 second->d_func()->focus_next = fn; -
3786 second->d_func()->focus_prev = first; -
3787 -
3788 sp->d_func()->focus_next = sn; -
3789 sn->d_func()->focus_prev = sp; -
3790 -
3791 -
3792 qt_noop(); -
3793 qt_noop(); -
3794 -
3795 qt_noop(); -
3796 qt_noop(); -
3797}
-
3798void QWidgetPrivate::reparentFocusWidgets(QWidget * oldtlw) -
3799{ -
3800 QWidget * const q = q_func(); -
3801 if (oldtlw == q->window())
-
3802 return;
-
3803 -
3804 if(focus_child)
-
3805 focus_child->clearFocus();
-
3806 -
3807 -
3808 QWidget *firstOld = 0; -
3809 -
3810 QWidget *o = 0; -
3811 QWidget *n = q; -
3812 -
3813 bool prevWasNew = true; -
3814 QWidget *w = focus_next; -
3815 -
3816 -
3817 -
3818 -
3819 while (w != q) {
-
3820 bool currentIsNew = q->isAncestorOf(w); -
3821 if (currentIsNew) {
-
3822 if (!prevWasNew) {
-
3823 -
3824 n->d_func()->focus_next = w; -
3825 w->d_func()->focus_prev = n; -
3826 }
-
3827 n = w; -
3828 } else {
-
3829 if (prevWasNew) {
-
3830 -
3831 if (o) {
-
3832 o->d_func()->focus_next = w; -
3833 w->d_func()->focus_prev = o; -
3834 } else {
-
3835 -
3836 firstOld = w; -
3837 }
-
3838 } -
3839 o = w; -
3840 }
-
3841 w = w->d_func()->focus_next; -
3842 prevWasNew = currentIsNew; -
3843 }
-
3844 -
3845 -
3846 if (firstOld) {
-
3847 o->d_func()->focus_next = firstOld; -
3848 firstOld->d_func()->focus_prev = o; -
3849 }
-
3850 -
3851 if (!q->isWindow()) {
-
3852 QWidget *topLevel = q->window(); -
3853 -
3854 -
3855 QWidget *prev = topLevel->d_func()->focus_prev; -
3856 -
3857 topLevel->d_func()->focus_prev = n; -
3858 prev->d_func()->focus_next = q; -
3859 -
3860 focus_prev = prev; -
3861 n->d_func()->focus_next = topLevel; -
3862 } else {
-
3863 -
3864 n->d_func()->focus_next = q; -
3865 focus_prev = n; -
3866 }
-
3867 -
3868} -
3869int QWidgetPrivate::pointToRect(const QPoint &p, const QRect &r) -
3870{ -
3871 int dx = 0; -
3872 int dy = 0; -
3873 if (p.x() < r.left())
-
3874 dx = r.left() - p.x();
-
3875 else if (p.x() > r.right())
-
3876 dx = p.x() - r.right();
-
3877 if (p.y() < r.top())
-
3878 dy = r.top() - p.y();
-
3879 else if (p.y() > r.bottom())
-
3880 dy = p.y() - r.bottom();
-
3881 return dx + dy;
-
3882} -
3883QSize QWidget::frameSize() const -
3884{ -
3885 const QWidgetPrivate * const d = d_func(); -
3886 if (isWindow() && !(windowType() == Qt::Popup)) {
-
3887 QRect fs = d->frameStrut(); -
3888 return QSize(data->crect.width() + fs.left() + fs.right(), -
3889 data->crect.height() + fs.top() + fs.bottom());
-
3890 } -
3891 return data->crect.size();
-
3892} -
3893void QWidget::move(const QPoint &p) -
3894{ -
3895 QWidgetPrivate * const d = d_func(); -
3896 setAttribute(Qt::WA_Moved); -
3897 if (testAttribute(Qt::WA_WState_Created)) {
-
3898 if (isWindow())
-
3899 d->topData()->posIncludesFrame = false;
-
3900 d->setGeometry_sys(p.x() + geometry().x() - QWidget::x(), -
3901 p.y() + geometry().y() - QWidget::y(), -
3902 width(), height(), true); -
3903 d->setDirtyOpaqueRegion(); -
3904 } else {
-
3905 -
3906 if (isWindow())
-
3907 d->topData()->posIncludesFrame = true;
-
3908 data->crect.moveTopLeft(p); -
3909 setAttribute(Qt::WA_PendingMoveEvent); -
3910 }
-
3911} -
3912 -
3913 -
3914 -
3915 -
3916 -
3917 -
3918 -
3919void QWidget::resize(const QSize &s) -
3920{ -
3921 QWidgetPrivate * const d = d_func(); -
3922 setAttribute(Qt::WA_Resized); -
3923 if (testAttribute(Qt::WA_WState_Created)) {
-
3924 d->fixPosIncludesFrame(); -
3925 d->setGeometry_sys(geometry().x(), geometry().y(), s.width(), s.height(), false); -
3926 d->setDirtyOpaqueRegion(); -
3927 } else {
-
3928 data->crect.setSize(s.boundedTo(maximumSize()).expandedTo(minimumSize())); -
3929 setAttribute(Qt::WA_PendingResizeEvent); -
3930 }
-
3931} -
3932 -
3933void QWidget::setGeometry(const QRect &r) -
3934{ -
3935 QWidgetPrivate * const d = d_func(); -
3936 setAttribute(Qt::WA_Resized); -
3937 setAttribute(Qt::WA_Moved); -
3938 if (isWindow())
-
3939 d->topData()->posIncludesFrame = 0;
-
3940 if (testAttribute(Qt::WA_WState_Created)) {
-
3941 d->setGeometry_sys(r.x(), r.y(), r.width(), r.height(), true); -
3942 d->setDirtyOpaqueRegion(); -
3943 } else {
-
3944 data->crect.setTopLeft(r.topLeft()); -
3945 data->crect.setSize(r.size().boundedTo(maximumSize()).expandedTo(minimumSize())); -
3946 setAttribute(Qt::WA_PendingMoveEvent); -
3947 setAttribute(Qt::WA_PendingResizeEvent); -
3948 }
-
3949} -
3950QByteArray QWidget::saveGeometry() const -
3951{ -
3952 QByteArray array; -
3953 QDataStream stream(&array, QIODevice::WriteOnly); -
3954 stream.setVersion(QDataStream::Qt_4_0); -
3955 const quint32 magicNumber = 0x1D9D0CB; -
3956 quint16 majorVersion = 1; -
3957 quint16 minorVersion = 0; -
3958 stream << magicNumber -
3959 << majorVersion -
3960 << minorVersion -
3961 -
3962 -
3963 -
3964 -
3965 << frameGeometry() -
3966 << normalGeometry() -
3967 -
3968 << qint32(QApplication::desktop()->screenNumber(this)) -
3969 << quint8(windowState() & Qt::WindowMaximized) -
3970 << quint8(windowState() & Qt::WindowFullScreen); -
3971 return array;
-
3972} -
3973bool QWidget::restoreGeometry(const QByteArray &geometry) -
3974{ -
3975 if (geometry.size() < 4)
-
3976 return false;
-
3977 QDataStream stream(geometry); -
3978 stream.setVersion(QDataStream::Qt_4_0); -
3979 -
3980 const quint32 magicNumber = 0x1D9D0CB; -
3981 quint32 storedMagicNumber; -
3982 stream >> storedMagicNumber; -
3983 if (storedMagicNumber != magicNumber)
-
3984 return false;
-
3985 -
3986 const quint16 currentMajorVersion = 1; -
3987 quint16 majorVersion = 0; -
3988 quint16 minorVersion = 0; -
3989 -
3990 stream >> majorVersion >> minorVersion; -
3991 -
3992 if (majorVersion != currentMajorVersion)
-
3993 return false;
-
3994 -
3995 -
3996 QRect restoredFrameGeometry; -
3997 QRect restoredNormalGeometry; -
3998 qint32 restoredScreenNumber; -
3999 quint8 maximized; -
4000 quint8 fullScreen; -
4001 -
4002 stream >> restoredFrameGeometry -
4003 >> restoredNormalGeometry -
4004 >> restoredScreenNumber -
4005 >> maximized -
4006 >> fullScreen; -
4007 -
4008 const int frameHeight = 20; -
4009 if (!restoredFrameGeometry.isValid())
-
4010 restoredFrameGeometry = QRect(QPoint(0,0), sizeHint());
-
4011 -
4012 if (!restoredNormalGeometry.isValid())
-
4013 restoredNormalGeometry = QRect(QPoint(0, frameHeight), sizeHint());
-
4014 if (!restoredNormalGeometry.isValid()) {
-
4015 -
4016 restoredNormalGeometry.setSize(restoredNormalGeometry -
4017 .size() -
4018 .expandedTo(d_func()->adjustedSize())); -
4019 }
-
4020 -
4021 const QDesktopWidget * const desktop = QApplication::desktop(); -
4022 if (restoredScreenNumber >= desktop->numScreens())
-
4023 restoredScreenNumber = desktop->primaryScreen();
-
4024 -
4025 const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber); -
4026 if (!restoredFrameGeometry.intersects(availableGeometry)) {
-
4027 restoredFrameGeometry.moveBottom(qMin(restoredFrameGeometry.bottom(), availableGeometry.bottom())); -
4028 restoredFrameGeometry.moveLeft(qMax(restoredFrameGeometry.left(), availableGeometry.left())); -
4029 restoredFrameGeometry.moveRight(qMin(restoredFrameGeometry.right(), availableGeometry.right())); -
4030 }
-
4031 restoredFrameGeometry.moveTop(qMax(restoredFrameGeometry.top(), availableGeometry.top())); -
4032 -
4033 if (!restoredNormalGeometry.intersects(availableGeometry)) {
-
4034 restoredNormalGeometry.moveBottom(qMin(restoredNormalGeometry.bottom(), availableGeometry.bottom())); -
4035 restoredNormalGeometry.moveLeft(qMax(restoredNormalGeometry.left(), availableGeometry.left())); -
4036 restoredNormalGeometry.moveRight(qMin(restoredNormalGeometry.right(), availableGeometry.right())); -
4037 }
-
4038 restoredNormalGeometry.moveTop(qMax(restoredNormalGeometry.top(), availableGeometry.top() + frameHeight)); -
4039 -
4040 if (maximized || fullScreen) {
-
4041 -
4042 -
4043 -
4044 -
4045 -
4046 setGeometry(restoredNormalGeometry); -
4047 -
4048 Qt::WindowStates ws = windowState(); -
4049 if (maximized)
-
4050 ws |= Qt::WindowMaximized;
-
4051 if (fullScreen)
-
4052 ws |= Qt::WindowFullScreen;
-
4053 setWindowState(ws); -
4054 d_func()->topData()->normalGeometry = restoredNormalGeometry; -
4055 } else {
-
4056 QPoint offset; -
4057 -
4058 -
4059 -
4060 -
4061 setWindowState(windowState() & ~(Qt::WindowMaximized | Qt::WindowFullScreen)); -
4062 move(restoredFrameGeometry.topLeft() + offset); -
4063 resize(restoredNormalGeometry.size()); -
4064 }
-
4065 return true;
-
4066} -
4067void QWidget::setContentsMargins(int left, int top, int right, int bottom) -
4068{ -
4069 QWidgetPrivate * const d = d_func(); -
4070 if (left == d->leftmargin && top == d->topmargin
-
4071 && right == d->rightmargin && bottom == d->bottommargin)
-
4072 return;
-
4073 d->leftmargin = left; -
4074 d->topmargin = top; -
4075 d->rightmargin = right; -
4076 d->bottommargin = bottom; -
4077 -
4078 if (QLayout *l=d->layout)
-
4079 l->update();
-
4080 else -
4081 updateGeometry();
-
4082 -
4083 if (isVisible()) {
-
4084 update(); -
4085 QResizeEvent e(data->crect.size(), data->crect.size()); -
4086 QApplication::sendEvent(this, &e); -
4087 } else {
-
4088 setAttribute(Qt::WA_PendingResizeEvent, true); -
4089 }
-
4090 -
4091 QEvent e(QEvent::ContentsRectChange); -
4092 QApplication::sendEvent(this, &e); -
4093}
-
4094void QWidget::setContentsMargins(const QMargins &margins) -
4095{ -
4096 setContentsMargins(margins.left(), margins.top(), -
4097 margins.right(), margins.bottom()); -
4098}
-
4099 -
4100 -
4101 -
4102 -
4103 -
4104 -
4105 -
4106void QWidget::getContentsMargins(int *left, int *top, int *right, int *bottom) const -
4107{ -
4108 const QWidgetPrivate * const d = d_func(); -
4109 if (left)
-
4110 *left = d->leftmargin;
-
4111 if (top)
-
4112 *top = d->topmargin;
-
4113 if (right)
-
4114 *right = d->rightmargin;
-
4115 if (bottom)
-
4116 *bottom = d->bottommargin;
-
4117}
-
4118QMargins QWidget::contentsMargins() const -
4119{ -
4120 const QWidgetPrivate * const d = d_func(); -
4121 return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin);
-
4122} -
4123 -
4124 -
4125 -
4126 -
4127 -
4128 -
4129 -
4130QRect QWidget::contentsRect() const -
4131{ -
4132 const QWidgetPrivate * const d = d_func(); -
4133 return QRect(QPoint(d->leftmargin, d->topmargin), -
4134 QPoint(data->crect.width() - 1 - d->rightmargin, -
4135 data->crect.height() - 1 - d->bottommargin));
-
4136 -
4137} -
4138Qt::ContextMenuPolicy QWidget::contextMenuPolicy() const -
4139{ -
4140 return (Qt::ContextMenuPolicy)data->context_menu_policy;
-
4141} -
4142 -
4143void QWidget::setContextMenuPolicy(Qt::ContextMenuPolicy policy) -
4144{ -
4145 data->context_menu_policy = (uint) policy; -
4146}
-
4147Qt::FocusPolicy QWidget::focusPolicy() const -
4148{ -
4149 return (Qt::FocusPolicy)data->focus_policy;
-
4150} -
4151 -
4152void QWidget::setFocusPolicy(Qt::FocusPolicy policy) -
4153{ -
4154 data->focus_policy = (uint) policy; -
4155 QWidgetPrivate * const d = d_func(); -
4156 if (d->extra && d->extra->focus_proxy)
-
4157 d->extra->focus_proxy->setFocusPolicy(policy);
-
4158}
-
4159void QWidget::setUpdatesEnabled(bool enable) -
4160{ -
4161 QWidgetPrivate * const d = d_func(); -
4162 setAttribute(Qt::WA_ForceUpdatesDisabled, !enable); -
4163 d->setUpdatesEnabled_helper(enable); -
4164}
-
4165void QWidget::show() -
4166{ -
4167 if (isWindow() && (static_cast<QApplication *>(QCoreApplication::instance()))->styleHints()->showIsFullScreen())
-
4168 showFullScreen();
-
4169 else -
4170 setVisible(true);
-
4171} -
4172 -
4173 -
4174 -
4175 -
4176 -
4177 -
4178void QWidgetPrivate::show_recursive() -
4179{ -
4180 QWidget * const q = q_func(); -
4181 -
4182 -
4183 if (!q->testAttribute(Qt::WA_WState_Created))
-
4184 createRecursively();
-
4185 q->ensurePolished(); -
4186 -
4187 if (!q->isWindow() && q->parentWidget()->d_func()->layout && !q->parentWidget()->data->in_show)
-
4188 q->parentWidget()->d_func()->layout->activate();
-
4189 -
4190 if (layout)
-
4191 layout->activate();
-
4192 -
4193 show_helper(); -
4194}
-
4195 -
4196void QWidgetPrivate::sendPendingMoveAndResizeEvents(bool recursive, bool disableUpdates) -
4197{ -
4198 QWidget * const q = q_func(); -
4199 -
4200 disableUpdates = disableUpdates && q->updatesEnabled();
-
4201 if (disableUpdates)
-
4202 q->setAttribute(Qt::WA_UpdatesDisabled);
-
4203 -
4204 if (q->testAttribute(Qt::WA_PendingMoveEvent)) {
-
4205 QMoveEvent e(data.crect.topLeft(), data.crect.topLeft()); -
4206 QApplication::sendEvent(q, &e); -
4207 q->setAttribute(Qt::WA_PendingMoveEvent, false); -
4208 }
-
4209 -
4210 if (q->testAttribute(Qt::WA_PendingResizeEvent)) {
-
4211 QResizeEvent e(data.crect.size(), QSize()); -
4212 QApplication::sendEvent(q, &e); -
4213 q->setAttribute(Qt::WA_PendingResizeEvent, false); -
4214 }
-
4215 -
4216 if (disableUpdates)
-
4217 q->setAttribute(Qt::WA_UpdatesDisabled, false);
-
4218 -
4219 if (!recursive)
-
4220 return;
-
4221 -
4222 for (int i = 0; i < children.size(); ++i) {
-
4223 if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
-
4224 child->d_func()->sendPendingMoveAndResizeEvents(recursive, disableUpdates);
-
4225 }
-
4226}
-
4227 -
4228void QWidgetPrivate::activateChildLayoutsRecursively() -
4229{ -
4230 sendPendingMoveAndResizeEvents(false, true); -
4231 -
4232 for (int i = 0; i < children.size(); ++i) {
-
4233 QWidget *child = qobject_cast<QWidget *>(children.at(i)); -
4234 if (!child || child->isHidden() || child->isWindow())
-
4235 continue;
-
4236 -
4237 child->ensurePolished(); -
4238 -
4239 -
4240 QWidgetPrivate *childPrivate = child->d_func(); -
4241 if (childPrivate->layout)
-
4242 childPrivate->layout->activate();
-
4243 -
4244 -
4245 const bool wasVisible = child->isVisible(); -
4246 if (!wasVisible)
-
4247 child->setAttribute(Qt::WA_WState_Visible);
-
4248 -
4249 -
4250 childPrivate->activateChildLayoutsRecursively(); -
4251 -
4252 -
4253 if (!wasVisible)
-
4254 child->setAttribute(Qt::WA_WState_Visible, false);
-
4255 }
-
4256}
-
4257 -
4258void QWidgetPrivate::show_helper() -
4259{ -
4260 QWidget * const q = q_func(); -
4261 data.in_show = true; -
4262 -
4263 sendPendingMoveAndResizeEvents(); -
4264 -
4265 -
4266 q->setAttribute(Qt::WA_WState_Visible); -
4267 -
4268 -
4269 showChildren(false); -
4270 -
4271 -
4272 -
4273 -
4274 -
4275 -
4276 if (q->isWindow()) {
-
4277 if ((q->windowType() == Qt::Tool) || (q->windowType() == Qt::Popup) || q->windowType() == Qt::ToolTip) {
-
4278 q->raise(); -
4279 if (q->parentWidget() && q->parentWidget()->window()->testAttribute(Qt::WA_KeyboardFocusChange))
-
4280 q->setAttribute(Qt::WA_KeyboardFocusChange);
-
4281 } else {
-
4282 while (QApplication::activePopupWidget()) {
-
4283 if (!QApplication::activePopupWidget()->close())
-
4284 break;
-
4285 }
-
4286 }
-
4287 } -
4288 -
4289 -
4290 -
4291 bool isEmbedded = false; -
4292 -
4293 if (q->isWindow()) {
-
4294 isEmbedded = q->graphicsProxyWidget() ? true : false;
-
4295 if (!isEmbedded && !bypassGraphicsProxyWidget(q)) {
-
4296 QGraphicsProxyWidget *ancestorProxy = nearestGraphicsProxyWidget(q->parentWidget()); -
4297 if (ancestorProxy) {
-
4298 isEmbedded = true; -
4299 ancestorProxy->d_func()->embedSubWindow(q); -
4300 }
-
4301 }
-
4302 }
-
4303 QShowEvent showEvent; -
4304 QApplication::sendEvent(q, &showEvent); -
4305 -
4306 show_sys(); -
4307 -
4308 if (!isEmbedded && q->windowType() == Qt::Popup)
-
4309 (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->openPopup(q);
-
4310 -
4311 -
4312 if (q->windowType() != Qt::ToolTip) {
-
4313 QAccessibleEvent event(q, QAccessible::ObjectShow); -
4314 QAccessible::updateAccessibility(&event); -
4315 }
-
4316 -
4317 -
4318 if (QApplicationPrivate::hidden_focus_widget == q) {
-
4319 QApplicationPrivate::hidden_focus_widget = 0; -
4320 q->setFocus(Qt::OtherFocusReason); -
4321 }
-
4322 -
4323 -
4324 -
4325 -
4326 if (!(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->in_exec && q->windowType() == Qt::SplashScreen)
-
4327 QApplication::processEvents();
-
4328 -
4329 data.in_show = false; -
4330}
-
4331void QWidget::hide() -
4332{ -
4333 setVisible(false); -
4334}
-
4335 -
4336 -
4337 -
4338void QWidgetPrivate::hide_helper() -
4339{ -
4340 QWidget * const q = q_func(); -
4341 -
4342 bool isEmbedded = false; -
4343 -
4344 isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != 0;
-
4345 -
4346 -
4347 -
4348 -
4349 if (!isEmbedded && (q->windowType() == Qt::Popup))
-
4350 (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->closePopup(q);
-
4351 -
4352 -
4353 -
4354 -
4355 -
4356 -
4357 -
4358 q->setAttribute(Qt::WA_Mapped, false); -
4359 hide_sys(); -
4360 -
4361 bool wasVisible = q->testAttribute(Qt::WA_WState_Visible); -
4362 -
4363 if (wasVisible) {
-
4364 q->setAttribute(Qt::WA_WState_Visible, false); -
4365 -
4366 }
-
4367 -
4368 QHideEvent hideEvent; -
4369 QApplication::sendEvent(q, &hideEvent); -
4370 hideChildren(false); -
4371 -
4372 -
4373 -
4374 if (wasVisible) {
-
4375 (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->sendSyntheticEnterLeave(q); -
4376 QWidget *fw = QApplication::focusWidget(); -
4377 while (fw && !fw->isWindow()) {
-
4378 if (fw == q) {
-
4379 q->focusNextPrevChild(true); -
4380 break;
-
4381 } -
4382 fw = fw->parentWidget(); -
4383 }
-
4384 }
-
4385 -
4386 if (QWidgetBackingStore *bs = maybeBackingStore())
-
4387 bs->removeDirtyWidget(q);
-
4388 -
4389 -
4390 if (wasVisible) {
-
4391 QAccessibleEvent event(q, QAccessible::ObjectHide); -
4392 QAccessible::updateAccessibility(&event); -
4393 }
-
4394 -
4395}
-
4396void QWidget::setVisible(bool visible) -
4397{ -
4398 if (visible) {
-
4399 if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
-
4400 return;
-
4401 -
4402 QWidgetPrivate * const d = d_func(); -
4403 -
4404 -
4405 if (!isWindow() && parentWidget() && parentWidget()->isVisible()
-
4406 && !parentWidget()->testAttribute(Qt::WA_WState_Created))
-
4407 parentWidget()->window()->d_func()->createRecursively();
-
4408 -
4409 -
4410 -
4411 QWidget *pw = parentWidget(); -
4412 if (!testAttribute(Qt::WA_WState_Created)
-
4413 && (isWindow() || pw->testAttribute(Qt::WA_WState_Created))) {
-
4414 create(); -
4415 }
-
4416 -
4417 -
4418 -
4419 -
4420 -
4421 -
4422 bool wasResized = testAttribute(Qt::WA_Resized); -
4423 Qt::WindowStates initialWindowState = windowState(); -
4424 -
4425 -
4426 ensurePolished(); -
4427 -
4428 -
4429 setAttribute(Qt::WA_WState_ExplicitShowHide); -
4430 -
4431 bool needUpdateGeometry = !isWindow() && testAttribute(Qt::WA_WState_Hidden);
-
4432 -
4433 setAttribute(Qt::WA_WState_Hidden, false); -
4434 -
4435 if (needUpdateGeometry)
-
4436 d->updateGeometry_helper(true);
-
4437 -
4438 -
4439 if (d->layout)
-
4440 d->layout->activate();
-
4441 -
4442 if (!isWindow()) {
-
4443 QWidget *parent = parentWidget(); -
4444 while (parent && parent->isVisible() && parent->d_func()->layout && !parent->data->in_show) {
-
4445 parent->d_func()->layout->activate(); -
4446 if (parent->isWindow())
-
4447 break;
-
4448 parent = parent->parentWidget(); -
4449 }
-
4450 if (parent)
-
4451 parent->d_func()->setDirtyOpaqueRegion();
-
4452 }
-
4453 -
4454 -
4455 if (!wasResized
-
4456 && (isWindow() || !parentWidget()->d_func()->layout)) {
-
4457 if (isWindow()) {
-
4458 adjustSize(); -
4459 if (windowState() != initialWindowState)
-
4460 setWindowState(initialWindowState);
-
4461 } else {
-
4462 adjustSize(); -
4463 }
-
4464 setAttribute(Qt::WA_Resized, false); -
4465 }
-
4466 -
4467 setAttribute(Qt::WA_KeyboardFocusChange, false); -
4468 -
4469 if (isWindow() || parentWidget()->isVisible()) {
-
4470 d->show_helper(); -
4471 -
4472 (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->sendSyntheticEnterLeave(this); -
4473 }
-
4474 -
4475 QEvent showToParentEvent(QEvent::ShowToParent); -
4476 QApplication::sendEvent(this, &showToParentEvent); -
4477 } else {
-
4478 if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
-
4479 return;
-
4480 if (QApplicationPrivate::hidden_focus_widget == this)
-
4481 QApplicationPrivate::hidden_focus_widget = 0;
-
4482 -
4483 QWidgetPrivate * const d = d_func(); -
4484 -
4485 -
4486 -
4487 -
4488 -
4489 if (!isWindow() && parentWidget())
-
4490 parentWidget()->d_func()->setDirtyOpaqueRegion();
-
4491 -
4492 setAttribute(Qt::WA_WState_Hidden); -
4493 setAttribute(Qt::WA_WState_ExplicitShowHide); -
4494 if (testAttribute(Qt::WA_WState_Created))
-
4495 d->hide_helper();
-
4496 -
4497 -
4498 if (!isWindow() && parentWidget()) {
-
4499 if (parentWidget()->d_func()->layout)
-
4500 parentWidget()->d_func()->layout->invalidate();
-
4501 else if (parentWidget()->isVisible())
-
4502 QApplication::postEvent(parentWidget(), new QEvent(QEvent::LayoutRequest));
-
4503 } -
4504 -
4505 QEvent hideToParentEvent(QEvent::HideToParent); -
4506 QApplication::sendEvent(this, &hideToParentEvent); -
4507 }
-
4508} -
4509 -
4510 -
4511 -
4512 -
4513void QWidget::setHidden(bool hidden) -
4514{ -
4515 setVisible(!hidden); -
4516}
-
4517 -
4518void QWidgetPrivate::_q_showIfNotHidden() -
4519{ -
4520 QWidget * const q = q_func(); -
4521 if ( !(q->isHidden() && q->testAttribute(Qt::WA_WState_ExplicitShowHide)) )
-
4522 q->setVisible(true);
-
4523}
-
4524 -
4525void QWidgetPrivate::showChildren(bool spontaneous) -
4526{ -
4527 QList<QObject*> childList = children; -
4528 for (int i = 0; i < childList.size(); ++i) {
-
4529 QWidget *widget = qobject_cast<QWidget*>(childList.at(i)); -
4530 if (!widget
-
4531 || widget->isWindow()
-
4532 || widget->testAttribute(Qt::WA_WState_Hidden))
-
4533 continue;
-
4534 if (spontaneous) {
-
4535 widget->setAttribute(Qt::WA_Mapped); -
4536 widget->d_func()->showChildren(true); -
4537 QShowEvent e; -
4538 QApplication::sendSpontaneousEvent(widget, &e); -
4539 } else {
-
4540 if (widget->testAttribute(Qt::WA_WState_ExplicitShowHide))
-
4541 widget->d_func()->show_recursive();
-
4542 else -
4543 widget->show();
-
4544 } -
4545 } -
4546}
-
4547 -
4548void QWidgetPrivate::hideChildren(bool spontaneous) -
4549{ -
4550 QList<QObject*> childList = children; -
4551 for (int i = 0; i < childList.size(); ++i) {
-
4552 QWidget *widget = qobject_cast<QWidget*>(childList.at(i)); -
4553 if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden))
-
4554 continue;
-
4555 if (spontaneous)
-
4556 widget->setAttribute(Qt::WA_Mapped, false);
-
4557 else -
4558 widget->setAttribute(Qt::WA_WState_Visible, false);
-
4559 widget->d_func()->hideChildren(spontaneous); -
4560 QHideEvent e; -
4561 if (spontaneous) {
-
4562 QApplication::sendSpontaneousEvent(widget, &e); -
4563 } else {
-
4564 QApplication::sendEvent(widget, &e); -
4565 if (widget->internalWinId()
-
4566 && widget->testAttribute(Qt::WA_DontCreateNativeAncestors)) {
-
4567 -
4568 -
4569 widget->d_func()->hide_sys(); -
4570 }
-
4571 }
-
4572 (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->sendSyntheticEnterLeave(widget); -
4573 -
4574 if (!spontaneous) {
-
4575 QAccessibleEvent event(widget, QAccessible::ObjectHide); -
4576 QAccessible::updateAccessibility(&event); -
4577 }
-
4578 -
4579 }
-
4580}
-
4581 -
4582bool QWidgetPrivate::close_helper(CloseMode mode) -
4583{ -
4584 if (data.is_closing)
-
4585 return true;
-
4586 -
4587 QWidget * const q = q_func(); -
4588 data.is_closing = 1; -
4589 -
4590 QPointer<QWidget> that = q; -
4591 QPointer<QWidget> parentWidget = q->parentWidget(); -
4592 -
4593 bool quitOnClose = q->testAttribute(Qt::WA_QuitOnClose); -
4594 if (mode != CloseNoEvent) {
-
4595 QCloseEvent e; -
4596 if (mode == CloseWithSpontaneousEvent)
-
4597 QApplication::sendSpontaneousEvent(q, &e);
-
4598 else -
4599 QApplication::sendEvent(q, &e);
-
4600 if (!that.isNull() && !e.isAccepted()) {
-
4601 data.is_closing = 0; -
4602 return false;
-
4603 } -
4604 }
-
4605 -
4606 if (!that.isNull() && !q->isHidden())
-
4607 q->hide();
-
4608 -
4609 -
4610 quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible());
-
4611 -
4612 if (quitOnClose) {
-
4613 -
4614 -
4615 -
4616 QWidgetList list = QApplication::topLevelWidgets(); -
4617 bool lastWindowClosed = true; -
4618 for (int i = 0; i < list.size(); ++i) {
-
4619 QWidget *w = list.at(i); -
4620 if (!w->isVisible() || w->parentWidget() || !w->testAttribute(Qt::WA_QuitOnClose))
-
4621 continue;
-
4622 lastWindowClosed = false; -
4623 break;
-
4624 } -
4625 if (lastWindowClosed) {
-
4626 QGuiApplicationPrivate::emitLastWindowClosed(); -
4627 QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance())); -
4628 applicationPrivate->maybeQuit(); -
4629 }
-
4630 }
-
4631 -
4632 -
4633 if (!that.isNull()) {
-
4634 data.is_closing = 0; -
4635 if (q->testAttribute(Qt::WA_DeleteOnClose)) {
-
4636 q->setAttribute(Qt::WA_DeleteOnClose, false); -
4637 q->deleteLater(); -
4638 }
-
4639 }
-
4640 return true;
-
4641} -
4642bool QWidget::close() -
4643{ -
4644 return d_func()->close_helper(QWidgetPrivate::CloseWithEvent);
-
4645} -
4646bool QWidget::isVisibleTo(const QWidget *ancestor) const -
4647{ -
4648 if (!ancestor)
-
4649 return isVisible();
-
4650 const QWidget * w = this; -
4651 while (!w->isHidden()
-
4652 && !w->isWindow()
-
4653 && w->parentWidget()
-
4654 && w->parentWidget() != ancestor)
-
4655 w = w->parentWidget();
-
4656 return !w->isHidden();
-
4657} -
4658QRegion QWidget::visibleRegion() const -
4659{ -
4660 const QWidgetPrivate * const d = d_func(); -
4661 -
4662 QRect clipRect = d->clipRect(); -
4663 if (clipRect.isEmpty())
-
4664 return QRegion();
-
4665 QRegion r(clipRect); -
4666 d->subtractOpaqueChildren(r, clipRect); -
4667 d->subtractOpaqueSiblings(r); -
4668 return r;
-
4669} -
4670 -
4671 -
4672QSize QWidgetPrivate::adjustedSize() const -
4673{ -
4674 const QWidget * const q = q_func(); -
4675 -
4676 QSize s = q->sizeHint(); -
4677 -
4678 if (q->isWindow()) {
-
4679 Qt::Orientations exp; -
4680 if (layout) {
-
4681 if (layout->hasHeightForWidth())
-
4682 s.setHeight(layout->totalHeightForWidth(s.width()));
-
4683 exp = layout->expandingDirections(); -
4684 } else
-
4685 { -
4686 if (q->sizePolicy().hasHeightForWidth())
-
4687 s.setHeight(q->heightForWidth(s.width()));
-
4688 exp = q->sizePolicy().expandingDirections(); -
4689 }
-
4690 if (exp & Qt::Horizontal)
-
4691 s.setWidth(qMax(s.width(), 200));
-
4692 if (exp & Qt::Vertical)
-
4693 s.setHeight(qMax(s.height(), 100));
-
4694 -
4695 -
4696 -
4697 QRect screen = QApplication::desktop()->screenGeometry(q->pos()); -
4698 -
4699 -
4700 -
4701 -
4702 -
4703 s.setWidth(qMin(s.width(), screen.width()*2/3)); -
4704 s.setHeight(qMin(s.height(), screen.height()*2/3)); -
4705 -
4706 if (QTLWExtra *extra = maybeTopData())
-
4707 extra->sizeAdjusted = true;
-
4708 }
-
4709 -
4710 if (!s.isValid()) {
-
4711 QRect r = q->childrenRect(); -
4712 if (r.isNull())
-
4713 return s;
-
4714 s = r.size() + QSize(2 * r.x(), 2 * r.y()); -
4715 }
-
4716 -
4717 return s;
-
4718} -
4719void QWidget::adjustSize() -
4720{ -
4721 QWidgetPrivate * const d = d_func(); -
4722 ensurePolished(); -
4723 QSize s = d->adjustedSize(); -
4724 -
4725 if (d->layout)
-
4726 d->layout->activate();
-
4727 -
4728 if (s.isValid())
-
4729 resize(s);
-
4730}
-
4731QSize QWidget::sizeHint() const -
4732{ -
4733 const QWidgetPrivate * const d = d_func(); -
4734 if (d->layout)
-
4735 return d->layout->totalSizeHint();
-
4736 return QSize(-1, -1);
-
4737} -
4738QSize QWidget::minimumSizeHint() const -
4739{ -
4740 const QWidgetPrivate * const d = d_func(); -
4741 if (d->layout)
-
4742 return d->layout->totalMinimumSize();
-
4743 return QSize(-1, -1);
-
4744} -
4745bool QWidget::isAncestorOf(const QWidget *child) const -
4746{ -
4747 while (child) {
-
4748 if (child == this)
-
4749 return true;
-
4750 if (child->isWindow())
-
4751 return false;
-
4752 child = child->parentWidget(); -
4753 }
-
4754 return false;
-
4755} -
4756bool QWidget::event(QEvent *event) -
4757{ -
4758 QWidgetPrivate * const d = d_func(); -
4759 -
4760 -
4761 if (!isEnabled()) {
-
4762 switch(event->type()) { -
4763 case QEvent::TabletPress: -
4764 case QEvent::TabletRelease: -
4765 case QEvent::TabletMove: -
4766 case QEvent::MouseButtonPress: -
4767 case QEvent::MouseButtonRelease: -
4768 case QEvent::MouseButtonDblClick: -
4769 case QEvent::MouseMove: -
4770 case QEvent::TouchBegin: -
4771 case QEvent::TouchUpdate: -
4772 case QEvent::TouchEnd: -
4773 case QEvent::TouchCancel: -
4774 case QEvent::ContextMenu: -
4775 case QEvent::KeyPress: -
4776 case QEvent::KeyRelease: -
4777 -
4778 case QEvent::Wheel: -
4779 -
4780 return false;
-
4781 default: -
4782 break;
-
4783 } -
4784 }
-
4785 switch (event->type()) { -
4786 case QEvent::MouseMove: -
4787 mouseMoveEvent((QMouseEvent*)event); -
4788 break;
-
4789 -
4790 case QEvent::MouseButtonPress: -
4791 mousePressEvent((QMouseEvent*)event); -
4792 break;
-
4793 -
4794 case QEvent::MouseButtonRelease: -
4795 mouseReleaseEvent((QMouseEvent*)event); -
4796 break;
-
4797 -
4798 case QEvent::MouseButtonDblClick: -
4799 mouseDoubleClickEvent((QMouseEvent*)event); -
4800 break;
-
4801 -
4802 case QEvent::Wheel: -
4803 wheelEvent((QWheelEvent*)event); -
4804 break;
-
4805 -
4806 -
4807 case QEvent::TabletMove: -
4808 case QEvent::TabletPress: -
4809 case QEvent::TabletRelease: -
4810 tabletEvent((QTabletEvent*)event); -
4811 break;
-
4812 -
4813 case QEvent::KeyPress: { -
4814 QKeyEvent *k = (QKeyEvent *)event; -
4815 bool res = false; -
4816 if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) {
-
4817 if (k->key() == Qt::Key_Backtab
-
4818 || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier)))
-
4819 res = focusNextPrevChild(false);
-
4820 else if (k->key() == Qt::Key_Tab)
-
4821 res = focusNextPrevChild(true);
-
4822 if (res)
-
4823 break;
-
4824 }
-
4825 keyPressEvent(k); -
4826 if (!k->isAccepted()
-
4827 && k->modifiers() & Qt::ShiftModifier && k->key() == Qt::Key_F1
-
4828 && d->whatsThis.size()) {
-
4829 QWhatsThis::showText(mapToGlobal(inputMethodQuery(Qt::ImCursorRectangle).toRect().center()), d->whatsThis, this); -
4830 k->accept(); -
4831 }
-
4832 -
4833 } -
4834 break;
-
4835 -
4836 case QEvent::KeyRelease: -
4837 keyReleaseEvent((QKeyEvent*)event); -
4838 -
4839 case QEvent::ShortcutOverride: -
4840 break;
-
4841 -
4842 case QEvent::InputMethod: -
4843 inputMethodEvent((QInputMethodEvent *) event); -
4844 break;
-
4845 -
4846 case QEvent::InputMethodQuery: -
4847 if (testAttribute(Qt::WA_InputMethodEnabled)) {
-
4848 QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(event); -
4849 Qt::InputMethodQueries queries = query->queries(); -
4850 for (uint i = 0; i < 32; ++i) {
-
4851 Qt::InputMethodQuery q = (Qt::InputMethodQuery)(int)(queries & (1<<i)); -
4852 if (q) {
-
4853 QVariant v = inputMethodQuery(q); -
4854 if (q == Qt::ImEnabled && !v.isValid() && isEnabled())
-
4855 v = QVariant(true);
-
4856 query->setValue(q, v); -
4857 }
-
4858 }
-
4859 query->accept(); -
4860 }
-
4861 break;
-
4862 -
4863 case QEvent::PolishRequest: -
4864 ensurePolished(); -
4865 break;
-
4866 -
4867 case QEvent::Polish: { -
4868 style()->polish(this); -
4869 setAttribute(Qt::WA_WState_Polished); -
4870 if (!QApplication::font(this).isCopyOf(QApplication::font()))
-
4871 d->resolveFont();
-
4872 if (!QApplication::palette(this).isCopyOf(QApplication::palette()))
-
4873 d->resolvePalette();
-
4874 } -
4875 break;
-
4876 -
4877 case QEvent::ApplicationWindowIconChange: -
4878 if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon)) {
-
4879 d->setWindowIcon_sys(); -
4880 d->setWindowIcon_helper(); -
4881 }
-
4882 break;
-
4883 case QEvent::FocusIn: -
4884 focusInEvent((QFocusEvent*)event); -
4885 d->updateWidgetTransform(); -
4886 break;
-
4887 -
4888 case QEvent::FocusOut: -
4889 focusOutEvent((QFocusEvent*)event); -
4890 break;
-
4891 -
4892 case QEvent::Enter: -
4893 -
4894 if (d->statusTip.size()) {
-
4895 QStatusTipEvent tip(d->statusTip); -
4896 QApplication::sendEvent(const_cast<QWidget *>(this), &tip); -
4897 }
-
4898 -
4899 enterEvent(event); -
4900 break;
-
4901 -
4902 case QEvent::Leave: -
4903 -
4904 if (d->statusTip.size()) {
-
4905 QString empty; -
4906 QStatusTipEvent tip(empty); -
4907 QApplication::sendEvent(const_cast<QWidget *>(this), &tip); -
4908 }
-
4909 -
4910 leaveEvent(event); -
4911 break;
-
4912 -
4913 case QEvent::HoverEnter: -
4914 case QEvent::HoverLeave: -
4915 update(); -
4916 break;
-
4917 -
4918 case QEvent::Paint: -
4919 -
4920 -
4921 -
4922 paintEvent((QPaintEvent*)event); -
4923 break;
-
4924 -
4925 case QEvent::Move: -
4926 moveEvent((QMoveEvent*)event); -
4927 d->updateWidgetTransform(); -
4928 break;
-
4929 -
4930 case QEvent::Resize: -
4931 resizeEvent((QResizeEvent*)event); -
4932 d->updateWidgetTransform(); -
4933 break;
-
4934 -
4935 case QEvent::Close: -
4936 closeEvent((QCloseEvent *)event); -
4937 break;
-
4938 -
4939 -
4940 case QEvent::ContextMenu: -
4941 switch (data->context_menu_policy) { -
4942 case Qt::PreventContextMenu: -
4943 break;
-
4944 case Qt::DefaultContextMenu: -
4945 contextMenuEvent(static_cast<QContextMenuEvent *>(event)); -
4946 break;
-
4947 case Qt::CustomContextMenu: -
4948 customContextMenuRequested(static_cast<QContextMenuEvent *>(event)->pos()); -
4949 break;
-
4950 -
4951 case Qt::ActionsContextMenu: -
4952 if (d->actions.count()) {
-
4953 QMenu::exec(d->actions, static_cast<QContextMenuEvent *>(event)->globalPos(), -
4954 0, this); -
4955 break;
-
4956 } -
4957 -
4958 -
4959 default:
-
4960 event->ignore(); -
4961 break;
-
4962 } -
4963 break;
-
4964 -
4965 -
4966 -
4967 case QEvent::Drop: -
4968 dropEvent((QDropEvent*) event); -
4969 break;
-
4970 -
4971 case QEvent::DragEnter: -
4972 dragEnterEvent((QDragEnterEvent*) event); -
4973 break;
-
4974 -
4975 case QEvent::DragMove: -
4976 dragMoveEvent((QDragMoveEvent*) event); -
4977 break;
-
4978 -
4979 case QEvent::DragLeave: -
4980 dragLeaveEvent((QDragLeaveEvent*) event); -
4981 break;
-
4982 -
4983 -
4984 case QEvent::Show: -
4985 showEvent((QShowEvent*) event); -
4986 break;
-
4987 -
4988 case QEvent::Hide: -
4989 hideEvent((QHideEvent*) event); -
4990 break;
-
4991 -
4992 case QEvent::ShowWindowRequest: -
4993 if (!isHidden())
-
4994 d->show_sys();
-
4995 break;
-
4996 -
4997 case QEvent::ApplicationFontChange: -
4998 d->resolveFont(); -
4999 break;
-
5000 case QEvent::ApplicationPaletteChange: -
5001 if (!(windowType() == Qt::Desktop))
-
5002 d->resolvePalette();
-
5003 break;
-
5004 -
5005 case QEvent::ToolBarChange: -
5006 case QEvent::ActivationChange: -
5007 case QEvent::EnabledChange: -
5008 case QEvent::FontChange: -
5009 case QEvent::StyleChange: -
5010 case QEvent::PaletteChange: -
5011 case QEvent::WindowTitleChange: -
5012 case QEvent::IconTextChange: -
5013 case QEvent::ModifiedChange: -
5014 case QEvent::MouseTrackingChange: -
5015 case QEvent::ParentChange: -
5016 case QEvent::WindowStateChange: -
5017 case QEvent::LocaleChange: -
5018 case QEvent::MacSizeChange: -
5019 case QEvent::ContentsRectChange: -
5020 case QEvent::ThemeChange: -
5021 changeEvent(event); -
5022 break;
-
5023 -
5024 case QEvent::WindowActivate: -
5025 case QEvent::WindowDeactivate: { -
5026 if (isVisible() && !palette().isEqual(QPalette::Active, QPalette::Inactive))
-
5027 update();
-
5028 QList<QObject*> childList = d->children; -
5029 for (int i = 0; i < childList.size(); ++i) {
-
5030 QWidget *w = qobject_cast<QWidget *>(childList.at(i)); -
5031 if (w && w->isVisible() && !w->isWindow())
-
5032 QApplication::sendEvent(w, event);
-
5033 }
-
5034 break; }
-
5035 -
5036 case QEvent::LanguageChange: -
5037 changeEvent(event); -
5038 { -
5039 QList<QObject*> childList = d->children; -
5040 for (int i = 0; i < childList.size(); ++i) {
-
5041 QObject *o = childList.at(i); -
5042 if (o)
-
5043 QApplication::sendEvent(o, event);
-
5044 }
-
5045 } -
5046 update(); -
5047 break;
-
5048 -
5049 case QEvent::ApplicationLayoutDirectionChange: -
5050 d->resolveLayoutDirection(); -
5051 break;
-
5052 -
5053 case QEvent::LayoutDirectionChange: -
5054 if (d->layout)
-
5055 d->layout->invalidate();
-
5056 update(); -
5057 changeEvent(event); -
5058 break;
-
5059 case QEvent::UpdateRequest: -
5060 d->syncBackingStore(); -
5061 break;
-
5062 case QEvent::UpdateLater: -
5063 update(static_cast<QUpdateLaterEvent*>(event)->region()); -
5064 break;
-
5065 case QEvent::StyleAnimationUpdate: -
5066 update(); -
5067 break;
-
5068 -
5069 case QEvent::WindowBlocked: -
5070 case QEvent::WindowUnblocked: -
5071 if (!d->children.isEmpty()) {
-
5072 QWidget *modalWidget = QApplication::activeModalWidget(); -
5073 for (int i = 0; i < d->children.size(); ++i) {
-
5074 QObject *o = d->children.at(i); -
5075 if (o && o != modalWidget && o->isWidgetType()) {
-
5076 QWidget *w = static_cast<QWidget *>(o); -
5077 -
5078 if (!w->isWindow())
-
5079 QApplication::sendEvent(w, event);
-
5080 }
-
5081 }
-
5082 }
-
5083 -
5084 -
5085 -
5086 break;
-
5087 -
5088 case QEvent::ToolTip: -
5089 if (!d->toolTip.isEmpty())
-
5090 QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip, this);
-
5091 else -
5092 event->ignore();
-
5093 break;
-
5094 -
5095 -
5096 case QEvent::WhatsThis: -
5097 if (d->whatsThis.size())
-
5098 QWhatsThis::showText(static_cast<QHelpEvent *>(event)->globalPos(), d->whatsThis, this);
-
5099 else -
5100 event->ignore();
-
5101 break;
-
5102 case QEvent::QueryWhatsThis: -
5103 if (d->whatsThis.isEmpty())
-
5104 event->ignore();
-
5105 break;
-
5106 -
5107 case QEvent::EmbeddingControl: -
5108 d->topData()->frameStrut.setCoords(0 ,0, 0, 0); -
5109 data->fstrut_dirty = false; -
5110 -
5111 -
5112 -
5113 break;
-
5114 -
5115 case QEvent::ActionAdded: -
5116 case QEvent::ActionRemoved: -
5117 case QEvent::ActionChanged: -
5118 actionEvent((QActionEvent*)event); -
5119 break;
-
5120 -
5121 -
5122 case QEvent::KeyboardLayoutChange: -
5123 { -
5124 changeEvent(event); -
5125 -
5126 -
5127 QList<QObject*> childList = d->children; -
5128 for (int i = 0; i < childList.size(); ++i) {
-
5129 QWidget *w = qobject_cast<QWidget *>(childList.at(i)); -
5130 if (w && w->isVisible() && !w->isWindow())
-
5131 QApplication::sendEvent(w, event);
-
5132 }
-
5133 break;
-
5134 } -
5135 -
5136 -
5137 -
5138 -
5139 -
5140 case QEvent::TouchBegin: -
5141 case QEvent::TouchUpdate: -
5142 case QEvent::TouchEnd: -
5143 case QEvent::TouchCancel: -
5144 { -
5145 event->ignore(); -
5146 break;
-
5147 } -
5148 -
5149 case QEvent::Gesture: -
5150 event->ignore(); -
5151 break;
-
5152 -
5153 -
5154 case QEvent::DynamicPropertyChange: { -
5155 const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName(); -
5156 if (!qstrncmp(propName, "_q_customDpi", 12) && propName.length() == 13) {
-
5157 uint value = property(propName.constData()).toUInt(); -
5158 if (!d->extra)
-
5159 d->createExtra();
-
5160 const char axis = propName.at(12); -
5161 if (axis == 'X')
-
5162 d->extra->customDpiX = value;
-
5163 else if (axis == 'Y')
-
5164 d->extra->customDpiY = value;
-
5165 d->updateFont(d->data.fnt); -
5166 }
-
5167 -
5168 } -
5169 -
5170 default: -
5171 return QObject::event(event);
-
5172 } -
5173 return true;
-
5174} -
5175void QWidget::changeEvent(QEvent * event) -
5176{ -
5177 switch(event->type()) { -
5178 case QEvent::EnabledChange: { -
5179 update(); -
5180 -
5181 QAccessible::State s; -
5182 s.disabled = true; -
5183 QAccessibleStateChangeEvent event(this, s); -
5184 QAccessible::updateAccessibility(&event); -
5185 -
5186 break;
-
5187 } -
5188 -
5189 case QEvent::FontChange: -
5190 case QEvent::StyleChange: { -
5191 QWidgetPrivate * const d = d_func(); -
5192 update(); -
5193 updateGeometry(); -
5194 if (d->layout)
-
5195 d->layout->invalidate();
-
5196 break;
-
5197 } -
5198 -
5199 case QEvent::PaletteChange: -
5200 update(); -
5201 break;
-
5202 -
5203 case QEvent::ThemeChange: -
5204 if (QApplication::desktopSettingsAware() && windowType() != Qt::Desktop
-
5205 && (static_cast<QApplication *>(QCoreApplication::instance())) && !QApplication::closingDown()) {
-
5206 if (testAttribute(Qt::WA_WState_Polished))
-
5207 QApplication::style()->unpolish(this);
-
5208 if (testAttribute(Qt::WA_WState_Polished))
-
5209 QApplication::style()->polish(this);
-
5210 QEvent styleChangedEvent(QEvent::StyleChange); -
5211 QCoreApplication::sendEvent(this, &styleChangedEvent); -
5212 if (isVisible())
-
5213 update();
-
5214 }
-
5215 break;
-
5216 default: -
5217 break;
-
5218 } -
5219}
-
5220void QWidget::mouseMoveEvent(QMouseEvent *event) -
5221{ -
5222 event->ignore(); -
5223}
-
5224void QWidget::mousePressEvent(QMouseEvent *event) -
5225{ -
5226 event->ignore(); -
5227 if ((windowType() == Qt::Popup)) {
-
5228 event->accept(); -
5229 QWidget* w; -
5230 while ((w = QApplication::activePopupWidget()) && w != this){
-
5231 w->close(); -
5232 if (QApplication::activePopupWidget() == w)
-
5233 w->hide();
-
5234 }
-
5235 if (!rect().contains(event->pos())){
-
5236 close(); -
5237 }
-
5238 }
-
5239}
-
5240void QWidget::mouseReleaseEvent(QMouseEvent *event) -
5241{ -
5242 event->ignore(); -
5243}
-
5244void QWidget::mouseDoubleClickEvent(QMouseEvent *event) -
5245{ -
5246 (void)event;;->ignore(); -
5247}
executed: }
Execution Count:12
12
5248void QWidget::wheelEvent(QWheelEvent *event) -
5249{ -
5250 event->ignore(); -
5251}
-
5252void QWidget::tabletEvent(QTabletEvent *event) -
5253{ -
5254 event->ignore(); -
5255}
-
5256void QWidget::keyPressEvent(QKeyEvent *event) -
5257{ -
5258 if ((windowType() == Qt::Popup) && event->key() == Qt::Key_Escape) {
-
5259 event->accept(); -
5260 close(); -
5261 } else {
-
5262 event->ignore(); -
5263 }
-
5264} -
5265void QWidget::keyReleaseEvent(QKeyEvent *event) -
5266{ -
5267 event->ignore(); -
5268}
-
5269void QWidget::focusInEvent(QFocusEvent *) -
5270{ -
5271 if (focusPolicy() != Qt::NoFocus || !isWindow()) {
-
5272 update(); -
5273 }
-
5274}
-
5275void QWidget::focusOutEvent(QFocusEvent *) -
5276{ -
5277 if (focusPolicy() != Qt::NoFocus || !isWindow())
-
5278 update();
-
5279}
-
5280void QWidget::enterEvent(QEvent *) -
5281{ -
5282} -
5283void QWidget::leaveEvent(QEvent *) -
5284{ -
5285} -
5286void QWidget::paintEvent(QPaintEvent *) -
5287{ -
5288} -
5289void QWidget::moveEvent(QMoveEvent *) -
5290{ -
5291} -
5292void QWidget::resizeEvent(QResizeEvent * ) -
5293{ -
5294} -
5295void QWidget::actionEvent(QActionEvent *) -
5296{ -
5297 -
5298} -
5299void QWidget::closeEvent(QCloseEvent *event) -
5300{ -
5301 event->accept(); -
5302}
-
5303void QWidget::contextMenuEvent(QContextMenuEvent *event) -
5304{ -
5305 event->ignore(); -
5306}
-
5307void QWidget::inputMethodEvent(QInputMethodEvent *event) -
5308{ -
5309 event->ignore(); -
5310}
-
5311QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const -
5312{ -
5313 switch(query) { -
5314 case Qt::ImCursorRectangle: -
5315 return QRect(width()/2, 0, 1, height());
-
5316 case Qt::ImFont: -
5317 return font();
-
5318 case Qt::ImAnchorPosition: -
5319 -
5320 return inputMethodQuery(Qt::ImCursorPosition);
-
5321 case Qt::ImHints: -
5322 return (int)inputMethodHints();
-
5323 default: -
5324 return QVariant();
-
5325 } -
5326}
-
5327Qt::InputMethodHints QWidget::inputMethodHints() const -
5328{ -
5329 -
5330 const QWidgetPrivate *priv = d_func(); -
5331 while (priv->inheritsInputMethodHints) {
-
5332 priv = priv->q_func()->parentWidget()->d_func(); -
5333 qt_noop(); -
5334 }
-
5335 return priv->imHints;
-
5336 -
5337 -
5338 -
5339} -
5340 -
5341void QWidget::setInputMethodHints(Qt::InputMethodHints hints) -
5342{ -
5343 -
5344 QWidgetPrivate * const d = d_func(); -
5345 if (d->imHints == hints)
evaluated: d->imHints == hints
TRUEFALSE
yes
Evaluation Count:2782
yes
Evaluation Count:461
461-2782
5346 return;
executed: return;
Execution Count:2782
2782
5347 d->imHints = hints; -
5348 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->update(Qt::ImHints); -
5349 -
5350}
executed: }
Execution Count:461
461
5351void QWidget::dragEnterEvent(QDragEnterEvent *) -
5352{ -
5353} -
5354void QWidget::dragMoveEvent(QDragMoveEvent *) -
5355{ -
5356} -
5357void QWidget::dragLeaveEvent(QDragLeaveEvent *) -
5358{ -
5359} -
5360void QWidget::dropEvent(QDropEvent *) -
5361{ -
5362} -
5363void QWidget::showEvent(QShowEvent *) -
5364{ -
5365} -
5366void QWidget::hideEvent(QHideEvent *) -
5367{ -
5368} -
5369bool QWidget::nativeEvent(const QByteArray &eventType, void *message, long *result) -
5370{ -
5371 (void)eventType;; -
5372 (void)message;; -
5373 (void)result;; -
5374 return false;
-
5375} -
5376void QWidget::ensurePolished() const -
5377{ -
5378 const QWidgetPrivate * const d = d_func(); -
5379 -
5380 const QMetaObject *m = metaObject(); -
5381 if (m == d->polished)
-
5382 return;
-
5383 d->polished = m; -
5384 -
5385 QEvent e(QEvent::Polish); -
5386 QCoreApplication::sendEvent(const_cast<QWidget *>(this), &e); -
5387 -
5388 -
5389 QList<QObject*> children = d->children; -
5390 for (int i = 0; i < children.size(); ++i) {
-
5391 QObject *o = children.at(i); -
5392 if(!o->isWidgetType())
-
5393 continue;
-
5394 if (QWidget *w = qobject_cast<QWidget *>(o))
-
5395 w->ensurePolished();
-
5396 }
-
5397 -
5398 if (d->parent && d->sendChildEvents) {
-
5399 QChildEvent e(QEvent::ChildPolished, const_cast<QWidget *>(this)); -
5400 QCoreApplication::sendEvent(d->parent, &e); -
5401 }
-
5402}
-
5403 -
5404 -
5405 -
5406 -
5407 -
5408 -
5409 -
5410QRegion QWidget::mask() const -
5411{ -
5412 const QWidgetPrivate * const d = d_func(); -
5413 return d->extra ? d->extra->mask : QRegion();
-
5414} -
5415QLayout *QWidget::layout() const -
5416{ -
5417 return d_func()->layout;
-
5418} -
5419void QWidget::setLayout(QLayout *l) -
5420{ -
5421 if (!l) {
-
5422 QMessageLogger("kernel/qwidget.cpp", 91009117, __PRETTY_FUNCTION__).warning("QWidget::setLayout: Cannot set layout to 0"); -
5423 return;
-
5424 } -
5425 if (layout()) {
-
5426 if (layout() != l)
-
5427 QMessageLogger("kernel/qwidget.cpp", 91059122, __PRETTY_FUNCTION__).warning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a" -
5428 " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(), -
5429 objectName().toLocal8Bit().data());
-
5430 return;
-
5431 } -
5432 -
5433 QObject *oldParent = l->parent(); -
5434 if (oldParent && oldParent != this) {
-
5435 if (oldParent->isWidgetType()) {
-
5436 -
5437 -
5438 QWidget *oldParentWidget = static_cast<QWidget *>(oldParent); -
5439 oldParentWidget->takeLayout(); -
5440 } else {
-
5441 QMessageLogger("kernel/qwidget.cpp", 91199136, __PRETTY_FUNCTION__).warning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent", -
5442 l->objectName().toLocal8Bit().data(), metaObject()->className(), -
5443 objectName().toLocal8Bit().data()); -
5444 return;
-
5445 } -
5446 } -
5447 -
5448 QWidgetPrivate * const d = d_func(); -
5449 l->d_func()->topLevel = true; -
5450 d->layout = l; -
5451 if (oldParent != this) {
-
5452 l->setParent(this); -
5453 l->d_func()->reparentChildWidgets(this); -
5454 l->invalidate(); -
5455 }
-
5456 -
5457 if (isWindow() && d->maybeTopData())
-
5458 d->topData()->sizeAdjusted = false;
-
5459}
-
5460QLayout *QWidget::takeLayout() -
5461{ -
5462 QWidgetPrivate * const d = d_func(); -
5463 QLayout *l = layout(); -
5464 if (!l)
-
5465 return 0;
-
5466 d->layout = 0; -
5467 l->setParent(0); -
5468 return l;
-
5469} -
5470QSizePolicy QWidget::sizePolicy() const -
5471{ -
5472 const QWidgetPrivate * const d = d_func(); -
5473 return d->size_policy;
-
5474} -
5475 -
5476void QWidget::setSizePolicy(QSizePolicy policy) -
5477{ -
5478 QWidgetPrivate * const d = d_func(); -
5479 setAttribute(Qt::WA_WState_OwnSizePolicy); -
5480 if (policy == d->size_policy)
-
5481 return;
-
5482 d->size_policy = policy; -
5483 -
5484 -
5485 if (QWExtra *extra = d->extra) {
-
5486 if (extra->proxyWidget)
-
5487 extra->proxyWidget->setSizePolicy(policy);
-
5488 }
-
5489 -
5490 -
5491 updateGeometry(); -
5492 -
5493 if (isWindow() && d->maybeTopData())
-
5494 d->topData()->sizeAdjusted = false;
-
5495}
-
5496int QWidget::heightForWidth(int w) const -
5497{ -
5498 if (layout() && layout()->hasHeightForWidth())
-
5499 return layout()->totalHeightForWidth(w);
-
5500 return -1;
-
5501} -
5502 -
5503 -
5504 -
5505 -
5506 -
5507 -
5508 -
5509bool QWidget::hasHeightForWidth() const -
5510{ -
5511 const QWidgetPrivate * const d = d_func(); -
5512 return d->layout ? d->layout->hasHeightForWidth() : d->size_policy.hasHeightForWidth();
-
5513} -
5514QWidget *QWidget::childAt(const QPoint &p) const -
5515{ -
5516 return d_func()->childAt_helper(p, false);
-
5517} -
5518 -
5519QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const -
5520{ -
5521 if (children.isEmpty())
-
5522 return 0;
-
5523 if (!pointInsideRectAndMask(p))
-
5524 return 0;
-
5525 return childAtRecursiveHelper(p, ignoreChildrenInDestructor);
-
5526} -
5527 -
5528QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor, bool includeFrame) const -
5529{ -
5530 -
5531 (void)includeFrame;; -
5532 -
5533 for (int i = children.size() - 1; i >= 0; --i) {
-
5534 QWidget *child = qobject_cast<QWidget *>(children.at(i)); -
5535 if (!child || child->isWindow() || child->isHidden() || child->testAttribute(Qt::WA_TransparentForMouseEvents)
-
5536 || (ignoreChildrenInDestructor && child->data->in_destructor)) {
-
5537 continue;
-
5538 } -
5539 -
5540 -
5541 QPoint childPoint = p; -
5542 childPoint -= child->data->crect.topLeft(); -
5543 -
5544 -
5545 if (!child->d_func()->pointInsideRectAndMask(childPoint))
-
5546 continue;
-
5547 -
5548 -
5549 if (QWidget *w = child->d_func()->childAtRecursiveHelper(childPoint, ignoreChildrenInDestructor))
-
5550 return w;
-
5551 -
5552 -
5553 return child;
-
5554 } -
5555 return 0;
-
5556} -
5557 -
5558void QWidgetPrivate::updateGeometry_helper(bool forceUpdate) -
5559{ -
5560 QWidget * const q = q_func(); -
5561 if (widgetItem)
-
5562 widgetItem->invalidateSizeCache();
-
5563 QWidget *parent; -
5564 if (forceUpdate || !extra || extra->minw != extra->maxw || extra->minh != extra->maxh) {
-
5565 if (!q->isWindow() && !q->isHidden() && (parent = q->parentWidget())) {
-
5566 if (parent->d_func()->layout)
-
5567 parent->d_func()->layout->invalidate();
-
5568 else if (parent->isVisible())
-
5569 QApplication::postEvent(parent, new QEvent(QEvent::LayoutRequest));
-
5570 } -
5571 }
-
5572}
-
5573void QWidget::updateGeometry() -
5574{ -
5575 QWidgetPrivate * const d = d_func(); -
5576 d->updateGeometry_helper(false); -
5577}
-
5578void QWidget::setWindowFlags(Qt::WindowFlags flags) -
5579{ -
5580 if (data->window_flags == flags)
-
5581 return;
-
5582 -
5583 QWidgetPrivate * const d = d_func(); -
5584 -
5585 if ((data->window_flags | flags) & Qt::Window) {
-
5586 -
5587 QPoint oldPos = pos(); -
5588 bool visible = isVisible(); -
5589 setParent(parentWidget(), flags); -
5590 -
5591 -
5592 -
5593 if (!((data->window_flags ^ flags) & Qt::Window)
-
5594 && (visible || testAttribute(Qt::WA_Moved))) {
-
5595 move(oldPos); -
5596 }
-
5597 -
5598 d->adjustQuitOnCloseAttribute(); -
5599 } else {
-
5600 data->window_flags = flags; -
5601 }
-
5602} -
5603void QWidget::overrideWindowFlags(Qt::WindowFlags flags) -
5604{ -
5605 data->window_flags = flags; -
5606}
-
5607void QWidget::setParent(QWidget *parent) -
5608{ -
5609 if (parent == parentWidget())
-
5610 return;
-
5611 setParent((QWidget*)parent, windowFlags() & ~Qt::WindowType_Mask); -
5612}
-
5613 -
5614 -
5615 -
5616 -
5617 -
5618 -
5619 -
5620void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) -
5621{ -
5622 QWidgetPrivate * const d = d_func(); -
5623 bool resized = testAttribute(Qt::WA_Resized); -
5624 bool wasCreated = testAttribute(Qt::WA_WState_Created); -
5625 QWidget *oldtlw = window(); -
5626 -
5627 QWidget *desktopWidget = 0; -
5628 if (parent && parent->windowType() == Qt::Desktop)
-
5629 desktopWidget = parent;
-
5630 bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget;
-
5631 -
5632 if (newParent && parent && !desktopWidget) {
-
5633 if (testAttribute(Qt::WA_NativeWindow) && !(static_cast<QApplication *>(QCoreApplication::instance()))->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)
-
5634 -
5635 -
5636 -
5637 -
5638 -
5639 ) -
5640 parent->d_func()->enforceNativeChildren();
-
5641 else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))
-
5642 setAttribute(Qt::WA_NativeWindow);
-
5643 } -
5644 -
5645 if (wasCreated) {
-
5646 if (!testAttribute(Qt::WA_WState_Hidden)) {
-
5647 hide(); -
5648 setAttribute(Qt::WA_WState_ExplicitShowHide, false); -
5649 }
-
5650 if (newParent) {
-
5651 QEvent e(QEvent::ParentAboutToChange); -
5652 QApplication::sendEvent(this, &e); -
5653 }
-
5654 }
-
5655 if (newParent && isAncestorOf(focusWidget()))
-
5656 focusWidget()->clearFocus();
-
5657 -
5658 QTLWExtra *oldTopExtra = window()->d_func()->maybeTopData(); -
5659 QWidgetBackingStoreTracker *oldBsTracker = oldTopExtra ? &oldTopExtra->backingStoreTracker : 0;
-
5660 -
5661 d->setParent_sys(parent, f); -
5662 -
5663 QTLWExtra *topExtra = window()->d_func()->maybeTopData(); -
5664 QWidgetBackingStoreTracker *bsTracker = topExtra ? &topExtra->backingStoreTracker : 0;
-
5665 if (oldBsTracker && oldBsTracker != bsTracker)
-
5666 oldBsTracker->unregisterWidgetSubtree(this);
-
5667 -
5668 if (desktopWidget)
-
5669 parent = 0;
-
5670 -
5671 if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {
-
5672 if (newParent)
-
5673 oldBs->removeDirtyWidget(this);
-
5674 -
5675 -
5676 oldBs->moveStaticWidgets(this); -
5677 }
-
5678 -
5679 if (QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation) && !testAttribute(Qt::WA_WState_Created))
-
5680 create();
-
5681 -
5682 d->reparentFocusWidgets(oldtlw); -
5683 setAttribute(Qt::WA_Resized, resized); -
5684 if (!testAttribute(Qt::WA_StyleSheet)
-
5685 && (!parent || !parent->testAttribute(Qt::WA_StyleSheet))) {
-
5686 d->resolveFont(); -
5687 d->resolvePalette(); -
5688 }
-
5689 d->resolveLayoutDirection(); -
5690 d->resolveLocale(); -
5691 -
5692 -
5693 -
5694 -
5695 -
5696 if (newParent
-
5697 -
5698 -
5699 -
5700 ) { -
5701 -
5702 if (!isWindow()) {
-
5703 if (!testAttribute(Qt::WA_ForceDisabled))
-
5704 d->setEnabled_helper(parent ? parent->isEnabled() : true);
-
5705 if (!testAttribute(Qt::WA_ForceUpdatesDisabled))
-
5706 d->setUpdatesEnabled_helper(parent ? parent->updatesEnabled() : true);
-
5707 }
-
5708 d->inheritStyle(); -
5709 -
5710 -
5711 if (parent && d->sendChildEvents) {
-
5712 QChildEvent e(QEvent::ChildAdded, this); -
5713 QApplication::sendEvent(parent, &e); -
5714 }
-
5715 if (parent && d->sendChildEvents && d->polished) {
-
5716 QChildEvent e(QEvent::ChildPolished, this); -
5717 QCoreApplication::sendEvent(parent, &e); -
5718 }
-
5719 -
5720 QEvent e(QEvent::ParentChange); -
5721 QApplication::sendEvent(this, &e); -
5722 }
-
5723 -
5724 if (!wasCreated) {
-
5725 if (isWindow() || parentWidget()->isVisible())
-
5726 setAttribute(Qt::WA_WState_Hidden, true);
-
5727 else if (!testAttribute(Qt::WA_WState_ExplicitShowHide))
-
5728 setAttribute(Qt::WA_WState_Hidden, false);
-
5729 } -
5730 -
5731 d->updateIsOpaque(); -
5732 -
5733 -
5734 -
5735 -
5736 if (oldtlw->graphicsProxyWidget()) {
-
5737 if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(oldtlw))
-
5738 ancestorProxy->d_func()->unembedSubWindow(this);
-
5739 }
-
5740 if (isWindow() && parent && !graphicsProxyWidget() && !bypassGraphicsProxyWidget(this)) {
-
5741 if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(parent))
-
5742 ancestorProxy->d_func()->embedSubWindow(this);
-
5743 }
-
5744 -
5745}
-
5746void QWidget::scroll(int dx, int dy) -
5747{ -
5748 if ((!updatesEnabled() && children().size() == 0) || !isVisible())
-
5749 return;
-
5750 if (dx == 0 && dy == 0)
-
5751 return;
-
5752 QWidgetPrivate * const d = d_func(); -
5753 -
5754 if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) {
-
5755 -
5756 -
5757 -
5758 if (!d->dirty.isEmpty()) {
-
5759 for (QForeachContainer<__typeof__((d->dirty.translated(dx, dy)).rects())> _container_((d->dirty.translated(dx, dy)).rects()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QRect &rect = *_container_.i;; __extension__ ({--_container_.brk; break;})) -
5760 proxy->update(rect);
-
5761 }
-
5762 proxy->scroll(dx, dy, proxy->subWidgetRect(this)); -
5763 return;
-
5764 } -
5765 -
5766 d->setDirtyOpaqueRegion(); -
5767 d->scroll_sys(dx, dy); -
5768}
-
5769void QWidget::scroll(int dx, int dy, const QRect &r) -
5770{ -
5771 -
5772 if ((!updatesEnabled() && children().size() == 0) || !isVisible())
-
5773 return;
-
5774 if (dx == 0 && dy == 0)
-
5775 return;
-
5776 QWidgetPrivate * const d = d_func(); -
5777 -
5778 if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) {
-
5779 -
5780 -
5781 -
5782 if (!d->dirty.isEmpty()) {
-
5783 for (QForeachContainer<__typeof__((d->dirty.translated(dx, dy) & r).rects())> _container_((d->dirty.translated(dx, dy) & r).rects()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QRect &rect = *_container_.i;; __extension__ ({--_container_.brk; break;})) -
5784 proxy->update(rect);
-
5785 }
-
5786 proxy->scroll(dx, dy, r.translated(proxy->subWidgetRect(this).topLeft().toPoint())); -
5787 return;
-
5788 } -
5789 -
5790 d->scroll_sys(dx, dy, r); -
5791}
-
5792void QWidget::repaint() -
5793{ -
5794 repaint(rect()); -
5795}
-
5796void QWidget::repaint(int x, int y, int w, int h) -
5797{ -
5798 if (x > data->crect.width() || y > data->crect.height())
-
5799 return;
-
5800 -
5801 if (w < 0)
-
5802 w = data->crect.width() - x;
-
5803 if (h < 0)
-
5804 h = data->crect.height() - y;
-
5805 -
5806 repaint(QRect(x, y, w, h)); -
5807}
-
5808 -
5809 -
5810 -
5811 -
5812 -
5813void QWidget::repaint(const QRect &rect) -
5814{ -
5815 QWidgetPrivate * const d = d_func(); -
5816 -
5817 if (testAttribute(Qt::WA_WState_ConfigPending)) {
-
5818 update(rect); -
5819 return;
-
5820 } -
5821 -
5822 if (!isVisible() || !updatesEnabled() || rect.isEmpty())
-
5823 return;
-
5824 -
5825 if (hasBackingStoreSupport()) {
-
5826 -
5827 -
5828 -
5829 -
5830 -
5831 -
5832 QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); -
5833 if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
-
5834 tlwExtra->inRepaint = true; -
5835 tlwExtra->backingStoreTracker->markDirty(rect, this, true); -
5836 tlwExtra->inRepaint = false; -
5837 }
-
5838 } else {
-
5839 d->repaint_sys(rect); -
5840 }
-
5841} -
5842 -
5843 -
5844 -
5845 -
5846 -
5847 -
5848void QWidget::repaint(const QRegion &rgn) -
5849{ -
5850 QWidgetPrivate * const d = d_func(); -
5851 -
5852 if (testAttribute(Qt::WA_WState_ConfigPending)) {
-
5853 update(rgn); -
5854 return;
-
5855 } -
5856 -
5857 if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
-
5858 return;
-
5859 -
5860 if (hasBackingStoreSupport()) {
-
5861 -
5862 -
5863 -
5864 -
5865 -
5866 -
5867 QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); -
5868 if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
-
5869 tlwExtra->inRepaint = true; -
5870 tlwExtra->backingStoreTracker->markDirty(rgn, this, true); -
5871 tlwExtra->inRepaint = false; -
5872 }
-
5873 } else {
-
5874 d->repaint_sys(rgn); -
5875 }
-
5876} -
5877void QWidget::update() -
5878{ -
5879 update(rect()); -
5880}
-
5881void QWidget::update(const QRect &rect) -
5882{ -
5883 if (!isVisible() || !updatesEnabled() || rect.isEmpty())
-
5884 return;
-
5885 -
5886 if (testAttribute(Qt::WA_WState_InPaintEvent)) {
-
5887 QApplication::postEvent(this, new QUpdateLaterEvent(rect)); -
5888 return;
-
5889 } -
5890 -
5891 if (hasBackingStoreSupport()) {
-
5892 -
5893 -
5894 -
5895 -
5896 -
5897 -
5898 QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); -
5899 if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
-
5900 tlwExtra->backingStoreTracker->markDirty(rect, this);
-
5901 } else {
-
5902 d_func()->repaint_sys(rect); -
5903 }
-
5904} -
5905 -
5906 -
5907 -
5908 -
5909 -
5910 -
5911void QWidget::update(const QRegion &rgn) -
5912{ -
5913 if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
-
5914 return;
-
5915 -
5916 if (testAttribute(Qt::WA_WState_InPaintEvent)) {
-
5917 QApplication::postEvent(this, new QUpdateLaterEvent(rgn)); -
5918 return;
-
5919 } -
5920 -
5921 if (hasBackingStoreSupport()) {
-
5922 -
5923 -
5924 -
5925 -
5926 -
5927 -
5928 QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); -
5929 if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
-
5930 tlwExtra->backingStoreTracker->markDirty(rgn, this);
-
5931 } else {
-
5932 d_func()->repaint_sys(rgn); -
5933 }
-
5934} -
5935 -
5936 -
5937 -
5938 -
5939 -
5940 -
5941 -
5942static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidgetData *data, -
5943 QWidgetPrivate *d) -
5944{ -
5945 if (attribute < int(8*sizeof(uint))) {
-
5946 if (on)
-
5947 data->widget_attributes |= (1<<attribute);
-
5948 else -
5949 data->widget_attributes &= ~(1<<attribute);
-
5950 } else { -
5951 const int x = attribute - 8*sizeof(uint); -
5952 const int int_off = x / (8*sizeof(uint)); -
5953 if (on)
-
5954 d->high_attributes[int_off] |= (1<<(x-(int_off*8*sizeof(uint))));
-
5955 else -
5956 d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint))));
-
5957 } -
5958} -
5959void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) -
5960{ -
5961 if (testAttribute(attribute) == on)
-
5962 return;
-
5963 -
5964 QWidgetPrivate * const d = d_func(); -
5965 qt_noop(); -
5966 setAttribute_internal(attribute, on, data, d); -
5967 -
5968 switch (attribute) { -
5969 -
5970 -
5971 case Qt::WA_AcceptDrops: { -
5972 if (on && !testAttribute(Qt::WA_DropSiteRegistered))
-
5973 setAttribute(Qt::WA_DropSiteRegistered, true);
-
5974 else if (!on && (isWindow() || !parentWidget() || !parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)))
-
5975 setAttribute(Qt::WA_DropSiteRegistered, false);
-
5976 QEvent e(QEvent::AcceptDropsChange); -
5977 QApplication::sendEvent(this, &e); -
5978 break;
-
5979 } -
5980 case Qt::WA_DropSiteRegistered: { -
5981 d->registerDropSite(on); -
5982 for (int i = 0; i < d->children.size(); ++i) {
-
5983 QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); -
5984 if (w && !w->isWindow() && !w->testAttribute(Qt::WA_AcceptDrops) && w->testAttribute(Qt::WA_DropSiteRegistered) != on)
-
5985 w->setAttribute(Qt::WA_DropSiteRegistered, on);
-
5986 }
-
5987 break;
-
5988 } -
5989 -
5990 -
5991 case Qt::WA_NoChildEventsForParent: -
5992 d->sendChildEvents = !on; -
5993 break;
-
5994 case Qt::WA_NoChildEventsFromChildren: -
5995 d->receiveChildEvents = !on; -
5996 break;
-
5997 case Qt::WA_MacBrushedMetal: -
5998 case Qt::WA_MacAlwaysShowToolWindow: -
5999 -
6000 -
6001 -
6002 break;
-
6003 case Qt::WA_MacNormalSize: -
6004 case Qt::WA_MacSmallSize: -
6005 case Qt::WA_MacMiniSize: -
6006 break;
-
6007 case Qt::WA_ShowModal: -
6008 if (!on) {
-
6009 -
6010 data->window_modality = Qt::NonModal; -
6011 } else if (data->window_modality == Qt::NonModal) {
-
6012 -
6013 -
6014 -
6015 -
6016 QWidget *w = parentWidget(); -
6017 if (w)
-
6018 w = w->window();
-
6019 while (w && !w->testAttribute(Qt::WA_GroupLeader)) {
-
6020 w = w->parentWidget(); -
6021 if (w)
-
6022 w = w->window();
-
6023 }
-
6024 data->window_modality = (w && w->testAttribute(Qt::WA_GroupLeader))
-
6025 ? Qt::WindowModal -
6026 : Qt::ApplicationModal; -
6027 -
6028 -
6029 -
6030 }
-
6031 if (testAttribute(Qt::WA_WState_Created)) {
-
6032 -
6033 d->setModal_sys(); -
6034 }
-
6035 break;
-
6036 case Qt::WA_MouseTracking: { -
6037 QEvent e(QEvent::MouseTrackingChange); -
6038 QApplication::sendEvent(this, &e); -
6039 break; }
-
6040 case Qt::WA_NativeWindow: { -
6041 d->createTLExtra(); -
6042 -
6043 QWidget *focusWidget = d->effectiveFocusWidget(); -
6044 if (on && !internalWinId() && hasFocus()
-
6045 && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
-
6046 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->commit(); -
6047 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->update(Qt::ImEnabled); -
6048 }
-
6049 if (!(static_cast<QApplication *>(QCoreApplication::instance()))->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()
-
6050 -
6051 -
6052 -
6053 -
6054 -
6055 ) -
6056 parentWidget()->d_func()->enforceNativeChildren();
-
6057 if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
-
6058 d->createWinId();
-
6059 if (isEnabled() && focusWidget->isEnabled()
-
6060 && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
-
6061 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->update(Qt::ImEnabled); -
6062 }
-
6063 -
6064 break;
-
6065 } -
6066 case Qt::WA_PaintOnScreen: -
6067 d->updateIsOpaque(); -
6068 case Qt::WA_OpaquePaintEvent:
-
6069 d->updateIsOpaque(); -
6070 break;
-
6071 case Qt::WA_NoSystemBackground: -
6072 d->updateIsOpaque(); -
6073 -
6074 case Qt::WA_UpdatesDisabled:
-
6075 d->updateSystemBackground(); -
6076 break;
-
6077 case Qt::WA_TransparentForMouseEvents: -
6078 -
6079 -
6080 -
6081 break;
-
6082 case Qt::WA_InputMethodEnabled: { -
6083 -
6084 if ((static_cast<QApplication *>(QCoreApplication::instance()))->focusObject() == this) {
-
6085 if (!on)
-
6086 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->commit();
-
6087 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->update(Qt::ImEnabled); -
6088 }
-
6089 -
6090 break;
-
6091 } -
6092 case Qt::WA_WindowPropagation: -
6093 d->resolvePalette(); -
6094 d->resolveFont(); -
6095 d->resolveLocale(); -
6096 break;
-
6097 case Qt::WA_DontShowOnScreen: { -
6098 if (on && isVisible()) {
-
6099 -
6100 -
6101 -
6102 d->hide_sys(); -
6103 d->show_sys(); -
6104 }
-
6105 break;
-
6106 } -
6107 case Qt::WA_StaticContents: -
6108 if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
-
6109 if (on)
-
6110 bs->addStaticWidget(this);
-
6111 else -
6112 bs->removeStaticWidget(this);
-
6113 } -
6114 break;
-
6115 case Qt::WA_TranslucentBackground: -
6116 if (on) {
-
6117 setAttribute(Qt::WA_NoSystemBackground); -
6118 d->updateIsTranslucent(); -
6119 }
-
6120 -
6121 break;
-
6122 case Qt::WA_AcceptTouchEvents: -
6123 -
6124 -
6125 -
6126 -
6127 break;
-
6128 default: -
6129 break;
-
6130 } -
6131}
-
6132bool QWidget::testAttribute_helper(Qt::WidgetAttribute attribute) const -
6133{ -
6134 const QWidgetPrivate * const d = d_func(); -
6135 const int x = attribute - 8*sizeof(uint); -
6136 const int int_off = x / (8*sizeof(uint)); -
6137 return (d->high_attributes[int_off] & (1<<(x-(int_off*8*sizeof(uint)))));
-
6138} -
6139qreal QWidget::windowOpacity() const -
6140{ -
6141 const QWidgetPrivate * const d = d_func(); -
6142 return (isWindow() && d->maybeTopData()) ? d->maybeTopData()->opacity / 255. : 1.0;
-
6143} -
6144 -
6145void QWidget::setWindowOpacity(qreal opacity) -
6146{ -
6147 QWidgetPrivate * const d = d_func(); -
6148 if (!isWindow())
-
6149 return;
-
6150 -
6151 opacity = qBound(qreal(0.0), opacity, qreal(1.0)); -
6152 QTLWExtra *extra = d->topData(); -
6153 extra->opacity = uint(opacity * 255); -
6154 setAttribute(Qt::WA_WState_WindowOpacitySet); -
6155 d->setWindowOpacity_sys(opacity); -
6156 -
6157 if (!testAttribute(Qt::WA_WState_Created))
-
6158 return;
-
6159 -
6160 -
6161 if (QGraphicsProxyWidget *proxy = graphicsProxyWidget()) {
-
6162 -
6163 if (proxy->cacheMode() == QGraphicsItem::NoCache)
-
6164 proxy->update();
-
6165 else if (QGraphicsScene *scene = proxy->scene())
-
6166 scene->update(proxy->sceneBoundingRect());
-
6167 return;
-
6168 } -
6169 -
6170}
-
6171bool QWidget::isWindowModified() const -
6172{ -
6173 return testAttribute(Qt::WA_WindowModified);
-
6174} -
6175 -
6176void QWidget::setWindowModified(bool mod) -
6177{ -
6178 QWidgetPrivate * const d = d_func(); -
6179 setAttribute(Qt::WA_WindowModified, mod); -
6180 -
6181 d->setWindowModified_helper(); -
6182 -
6183 QEvent e(QEvent::ModifiedChange); -
6184 QApplication::sendEvent(this, &e); -
6185}
-
6186 -
6187void QWidgetPrivate::setWindowModified_helper() -
6188{ -
6189 QWidget * const q = q_func(); -
6190 QWindow *window = q->windowHandle(); -
6191 if (!window)
-
6192 return;
-
6193 QPlatformWindow *platformWindow = window->handle(); -
6194 if (!platformWindow)
-
6195 return;
-
6196 bool on = q->testAttribute(Qt::WA_WindowModified); -
6197 if (!platformWindow->setWindowModified(on)) {
-
6198 if (!q->windowTitle().contains(QLatin1String("[*]")) && on)
-
6199 QMessageLogger("kernel/qwidget.cpp", 1031510332, __PRETTY_FUNCTION__).warning("QWidget::setWindowModified: The window title does not contain a '[*]' placeholder");
-
6200 setWindowTitle_helper(q->windowTitle()); -
6201 setWindowIconText_helper(q->windowIconText()); -
6202 }
-
6203}
-
6204void QWidget::setToolTip(const QString &s) -
6205{ -
6206 QWidgetPrivate * const d = d_func(); -
6207 d->toolTip = s; -
6208 -
6209 QEvent event(QEvent::ToolTipChange); -
6210 QApplication::sendEvent(this, &event); -
6211}
-
6212 -
6213QString QWidget::toolTip() const -
6214{ -
6215 const QWidgetPrivate * const d = d_func(); -
6216 return d->toolTip;
-
6217} -
6218void QWidget::setStatusTip(const QString &s) -
6219{ -
6220 QWidgetPrivate * const d = d_func(); -
6221 d->statusTip = s; -
6222}
-
6223 -
6224QString QWidget::statusTip() const -
6225{ -
6226 const QWidgetPrivate * const d = d_func(); -
6227 return d->statusTip;
-
6228} -
6229void QWidget::setWhatsThis(const QString &s) -
6230{ -
6231 QWidgetPrivate * const d = d_func(); -
6232 d->whatsThis = s; -
6233}
-
6234 -
6235QString QWidget::whatsThis() const -
6236{ -
6237 const QWidgetPrivate * const d = d_func(); -
6238 return d->whatsThis;
-
6239} -
6240void QWidget::setAccessibleName(const QString &name) -
6241{ -
6242 QWidgetPrivate * const d = d_func(); -
6243 d->accessibleName = name; -
6244 QAccessibleEvent event(this, QAccessible::NameChanged); -
6245 QAccessible::updateAccessibility(&event); -
6246}
-
6247 -
6248QString QWidget::accessibleName() const -
6249{ -
6250 const QWidgetPrivate * const d = d_func(); -
6251 return d->accessibleName;
-
6252} -
6253void QWidget::setAccessibleDescription(const QString &description) -
6254{ -
6255 QWidgetPrivate * const d = d_func(); -
6256 d->accessibleDescription = description; -
6257 QAccessibleEvent event(this, QAccessible::DescriptionChanged); -
6258 QAccessible::updateAccessibility(&event); -
6259}
-
6260 -
6261QString QWidget::accessibleDescription() const -
6262{ -
6263 const QWidgetPrivate * const d = d_func(); -
6264 return d->accessibleDescription;
-
6265} -
6266int QWidget::grabShortcut(const QKeySequence &key, Qt::ShortcutContext context) -
6267{ -
6268 qt_noop(); -
6269 if (key.isEmpty())
-
6270 return 0;
-
6271 setAttribute(Qt::WA_GrabbedShortcut); -
6272 return (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.addShortcut(this, key, context, qWidgetShortcutContextMatcher);
-
6273} -
6274void QWidget::releaseShortcut(int id) -
6275{ -
6276 qt_noop(); -
6277 if (id)
-
6278 (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(id, this, 0);
-
6279}
-
6280void QWidget::setShortcutEnabled(int id, bool enable) -
6281{ -
6282 qt_noop(); -
6283 if (id)
-
6284 (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.setShortcutEnabled(enable, id, this, 0);
-
6285}
-
6286void QWidget::setShortcutAutoRepeat(int id, bool enable) -
6287{ -
6288 qt_noop(); -
6289 if (id)
-
6290 (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.setShortcutAutoRepeat(enable, id, this, 0);
-
6291}
-
6292 -
6293 -
6294 -
6295 -
6296 -
6297void QWidget::updateMicroFocus() -
6298{ -
6299 -
6300 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->update(Qt::ImQueryAll); -
6301}
-
6302void QWidget::raise() -
6303{ -
6304 QWidgetPrivate * const d = d_func(); -
6305 if (!isWindow()) {
-
6306 QWidget *p = parentWidget(); -
6307 const int parentChildCount = p->d_func()->children.size(); -
6308 if (parentChildCount < 2)
-
6309 return;
-
6310 const int from = p->d_func()->children.indexOf(this); -
6311 qt_noop(); -
6312 -
6313 if (from != parentChildCount -1)
-
6314 p->d_func()->children.move(from, parentChildCount - 1);
-
6315 if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
-
6316 create();
-
6317 else if (from == parentChildCount - 1)
-
6318 return;
-
6319 -
6320 QRegion region(rect()); -
6321 d->subtractOpaqueSiblings(region); -
6322 d->invalidateBuffer(region); -
6323 }
-
6324 if (testAttribute(Qt::WA_WState_Created))
-
6325 d->raise_sys();
-
6326 -
6327 QEvent e(QEvent::ZOrderChange); -
6328 QApplication::sendEvent(this, &e); -
6329}
-
6330void QWidget::lower() -
6331{ -
6332 QWidgetPrivate * const d = d_func(); -
6333 if (!isWindow()) {
-
6334 QWidget *p = parentWidget(); -
6335 const int parentChildCount = p->d_func()->children.size(); -
6336 if (parentChildCount < 2)
-
6337 return;
-
6338 const int from = p->d_func()->children.indexOf(this); -
6339 qt_noop(); -
6340 -
6341 if (from != 0)
-
6342 p->d_func()->children.move(from, 0);
-
6343 if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
-
6344 create();
-
6345 else if (from == 0)
-
6346 return;
-
6347 } -
6348 if (testAttribute(Qt::WA_WState_Created))
-
6349 d->lower_sys();
-
6350 -
6351 QEvent e(QEvent::ZOrderChange); -
6352 QApplication::sendEvent(this, &e); -
6353}
-
6354void QWidget::stackUnder(QWidget* w) -
6355{ -
6356 QWidgetPrivate * const d = d_func(); -
6357 QWidget *p = parentWidget(); -
6358 if (!w || isWindow() || p != w->parentWidget() || this == w)
-
6359 return;
-
6360 if (p) {
-
6361 int from = p->d_func()->children.indexOf(this); -
6362 int to = p->d_func()->children.indexOf(w); -
6363 qt_noop(); -
6364 qt_noop(); -
6365 if (from < to)
-
6366 --to;
-
6367 -
6368 if (from != to)
-
6369 p->d_func()->children.move(from, to);
-
6370 if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
-
6371 create();
-
6372 else if (from == to)
-
6373 return;
-
6374 } -
6375 if (testAttribute(Qt::WA_WState_Created))
-
6376 d->stackUnder_sys(w);
-
6377 -
6378 QEvent e(QEvent::ZOrderChange); -
6379 QApplication::sendEvent(this, &e); -
6380}
-
6381QRect QWidgetPrivate::frameStrut() const -
6382{ -
6383 const QWidget * const q = q_func(); -
6384 if (!q->isWindow() || (q->windowType() == Qt::Desktop) || q->testAttribute(Qt::WA_DontShowOnScreen)) {
-
6385 -
6386 return QRect(0, 0, 1, 1);
-
6387 } -
6388 -
6389 if (data.fstrut_dirty
-
6390 -
6391 -
6392 && q->isVisible()
-
6393 -
6394 && q->testAttribute(Qt::WA_WState_Created))
-
6395 const_cast<QWidgetPrivate *>(this)->updateFrameStrut();
-
6396 -
6397 return maybeTopData() ? maybeTopData()->frameStrut : QRect();
-
6398} -
6399void QWidget::setBackingStore(QBackingStore *store) -
6400{ -
6401 -
6402 -
6403 if (!isTopLevel())
-
6404 return;
-
6405 -
6406 QWidgetPrivate * const d = d_func(); -
6407 -
6408 QTLWExtra *topData = d->topData(); -
6409 if (topData->backingStore == store)
-
6410 return;
-
6411 -
6412 QBackingStore *oldStore = topData->backingStore; -
6413 delete topData->backingStore; -
6414 topData->backingStore = store; -
6415 -
6416 QWidgetBackingStore *bs = d->maybeBackingStore(); -
6417 if (!bs)
-
6418 return;
-
6419 -
6420 if (isTopLevel()) {
-
6421 if (bs->store != oldStore && bs->store != store)
-
6422 delete bs->store;
-
6423 bs->store = store; -
6424 }
-
6425}
-
6426 -
6427 -
6428 -
6429 -
6430 -
6431 -
6432QBackingStore *QWidget::backingStore() const -
6433{ -
6434 const QWidgetPrivate * const d = d_func(); -
6435 QTLWExtra *extra = d->maybeTopData(); -
6436 if (extra && extra->backingStore)
-
6437 return extra->backingStore;
-
6438 -
6439 QWidgetBackingStore *bs = d->maybeBackingStore(); -
6440 -
6441 return bs ? bs->store : 0;
-
6442} -
6443 -
6444void QWidgetPrivate::getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const -
6445{ -
6446 if (left)
-
6447 *left = (int)leftLayoutItemMargin;
-
6448 if (top)
-
6449 *top = (int)topLayoutItemMargin;
-
6450 if (right)
-
6451 *right = (int)rightLayoutItemMargin;
-
6452 if (bottom)
-
6453 *bottom = (int)bottomLayoutItemMargin;
-
6454}
-
6455 -
6456void QWidgetPrivate::setLayoutItemMargins(int left, int top, int right, int bottom) -
6457{ -
6458 if (leftLayoutItemMargin == left
-
6459 && topLayoutItemMargin == top
-
6460 && rightLayoutItemMargin == right
-
6461 && bottomLayoutItemMargin == bottom)
-
6462 return;
-
6463 -
6464 QWidget * const q = q_func(); -
6465 leftLayoutItemMargin = (signed char)left; -
6466 topLayoutItemMargin = (signed char)top; -
6467 rightLayoutItemMargin = (signed char)right; -
6468 bottomLayoutItemMargin = (signed char)bottom; -
6469 q->updateGeometry(); -
6470}
-
6471 -
6472void QWidgetPrivate::setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt) -
6473{ -
6474 QWidget * const q = q_func(); -
6475 QStyleOption myOpt; -
6476 if (!opt) {
-
6477 myOpt.initFrom(q); -
6478 myOpt.rect.setRect(0, 0, 32768, 32768); -
6479 opt = &myOpt; -
6480 }
-
6481 -
6482 QRect liRect = q->style()->subElementRect(element, opt, q); -
6483 if (liRect.isValid()) {
-
6484 leftLayoutItemMargin = (signed char)(opt->rect.left() - liRect.left()); -
6485 topLayoutItemMargin = (signed char)(opt->rect.top() - liRect.top()); -
6486 rightLayoutItemMargin = (signed char)(liRect.right() - opt->rect.right()); -
6487 bottomLayoutItemMargin = (signed char)(liRect.bottom() - opt->rect.bottom()); -
6488 } else {
-
6489 leftLayoutItemMargin = 0; -
6490 topLayoutItemMargin = 0; -
6491 rightLayoutItemMargin = 0; -
6492 bottomLayoutItemMargin = 0; -
6493 }
-
6494} -
6495 -
6496void QWidgetPrivate::adjustQuitOnCloseAttribute() -
6497{ -
6498 QWidget * const q = q_func(); -
6499 -
6500 if (!q->parentWidget()) {
-
6501 Qt::WindowType type = q->windowType(); -
6502 if (type == Qt::Widget || type == Qt::SubWindow)
-
6503 type = Qt::Window;
-
6504 if (type != Qt::Widget && type != Qt::Window && type != Qt::Dialog)
-
6505 q->setAttribute(Qt::WA_QuitOnClose, false);
-
6506 }
-
6507}
-
6508 -
6509 -
6510 -
6511__attribute__((visibility("default"))) QWidgetData *qt_qwidget_data(QWidget *widget) -
6512{ -
6513 return widget->data;
-
6514} -
6515 -
6516__attribute__((visibility("default"))) QWidgetPrivate *qt_widget_private(QWidget *widget) -
6517{ -
6518 return widget->d_func();
-
6519} -
6520QGraphicsProxyWidget *QWidget::graphicsProxyWidget() const -
6521{ -
6522 const QWidgetPrivate * const d = d_func(); -
6523 if (d->extra) {
-
6524 return d->extra->proxyWidget;
-
6525 } -
6526 return 0;
-
6527} -
6528void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags) -
6529{ -
6530 QWidgetPrivate * const d = d_func(); -
6531 d->gestureContext.insert(gesture, flags); -
6532 (void)QGestureManager::instance(); -
6533}
-
6534 -
6535 -
6536 -
6537 -
6538 -
6539 -
6540 -
6541void QWidget::ungrabGesture(Qt::GestureType gesture) -
6542{ -
6543 QWidgetPrivate * const d = d_func(); -
6544 if (d->gestureContext.remove(gesture)) {
-
6545 if (QGestureManager *manager = QGestureManager::instance())
-
6546 manager->cleanupCachedGestures(this, gesture);
-
6547 }
-
6548}
-
6549void QWidget::initPainter(QPainter *painter) const -
6550{ -
6551 const QPalette &pal = palette(); -
6552 painter->d_func()->state->pen = QPen(pal.brush(foregroundRole()), 1); -
6553 painter->d_func()->state->bgBrush = pal.brush(backgroundRole()); -
6554 QFont f(font(), const_cast<QWidget *>(this)); -
6555 painter->d_func()->state->deviceFont = f; -
6556 painter->d_func()->state->font = f; -
6557}
-
6558 -
6559QPaintDevice *QWidget::redirected(QPoint *offset) const -
6560{ -
6561 return d_func()->redirected(offset);
-
6562} -
6563 -
6564QPainter *QWidget::sharedPainter() const -
6565{ -
6566 -
6567 if (!d_func()->redirectDev)
-
6568 return 0;
-
6569 -
6570 QPainter *sp = d_func()->sharedPainter(); -
6571 if (!sp || !sp->isActive())
-
6572 return 0;
-
6573 -
6574 if (sp->paintEngine()->paintDevice() != d_func()->redirectDev)
-
6575 return 0;
-
6576 -
6577 return sp;
-
6578} -
6579void QWidget::setMask(const QRegion &newMask) -
6580{ -
6581 QWidgetPrivate * const d = d_func(); -
6582 -
6583 d->createExtra(); -
6584 if (newMask == d->extra->mask)
-
6585 return;
-
6586 -
6587 -
6588 const QRegion oldMask(d->extra->mask); -
6589 -
6590 -
6591 d->extra->mask = newMask; -
6592 d->extra->hasMask = !newMask.isEmpty(); -
6593 -
6594 -
6595 if (!testAttribute(Qt::WA_WState_Created))
-
6596 return;
-
6597 -
6598 -
6599 d->setMask_sys(newMask); -
6600 -
6601 -
6602 if (!isVisible())
-
6603 return;
-
6604 -
6605 if (!d->extra->hasMask) {
-
6606 -
6607 QRegion expose(rect()); -
6608 expose -= oldMask; -
6609 if (!expose.isEmpty()) {
-
6610 d->setDirtyOpaqueRegion(); -
6611 update(expose); -
6612 }
-
6613 return;
-
6614 } -
6615 -
6616 if (!isWindow()) {
-
6617 -
6618 QRegion parentExpose(rect()); -
6619 parentExpose -= newMask; -
6620 if (!parentExpose.isEmpty()) {
-
6621 d->setDirtyOpaqueRegion(); -
6622 parentExpose.translate(data->crect.topLeft()); -
6623 parentWidget()->update(parentExpose); -
6624 }
-
6625 -
6626 -
6627 if (!oldMask.isEmpty())
-
6628 update(newMask - oldMask);
-
6629 }
-
6630 -
6631}
-
6632void QWidget::setMask(const QBitmap &bitmap) -
6633{ -
6634 setMask(QRegion(bitmap)); -
6635}
-
6636void QWidget::clearMask() -
6637{ -
6638 setMask(QRegion()); -
6639}
-
6640 -
6641 -
6642 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial