Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qwidget.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||||||||||||||
4 | ** Copyright (C) 2016 Intel Corporation. | - | ||||||||||||||||||||||||||||||||||||
5 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||||||||||||||
6 | ** | - | ||||||||||||||||||||||||||||||||||||
7 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||||||||||||||||||||||||||
8 | ** | - | ||||||||||||||||||||||||||||||||||||
9 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||||||||||||||
10 | ** Commercial License Usage | - | ||||||||||||||||||||||||||||||||||||
11 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||||||||||||||
12 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||||||||||||||
13 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||||||||||||||
14 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||||||||||||||
15 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||||||||||||||
16 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||||||||||||||
17 | ** | - | ||||||||||||||||||||||||||||||||||||
18 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||||||||||||||
19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||||||||||||||
20 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||||||||||||||
21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||||||||||||||
22 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||||||||||||||
23 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||||||||||||||
24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||||||||||||||
25 | ** | - | ||||||||||||||||||||||||||||||||||||
26 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||||||||||||||
27 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||||||||||||||
28 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||||||||||||||
29 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||||||||||||||
30 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||||||||||||||
31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||||||||||||||
32 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||||||||||||||
33 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||||||||||||||
34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||||||||||||||
35 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||||||||||||||
36 | ** | - | ||||||||||||||||||||||||||||||||||||
37 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||||||||||||||
38 | ** | - | ||||||||||||||||||||||||||||||||||||
39 | ****************************************************************************/ | - | ||||||||||||||||||||||||||||||||||||
40 | - | |||||||||||||||||||||||||||||||||||||
41 | #include "qapplication.h" | - | ||||||||||||||||||||||||||||||||||||
42 | #include "qapplication_p.h" | - | ||||||||||||||||||||||||||||||||||||
43 | #include "qbrush.h" | - | ||||||||||||||||||||||||||||||||||||
44 | #include "qcursor.h" | - | ||||||||||||||||||||||||||||||||||||
45 | #include "qdesktopwidget_p.h" | - | ||||||||||||||||||||||||||||||||||||
46 | #include "qevent.h" | - | ||||||||||||||||||||||||||||||||||||
47 | #include "qlayout.h" | - | ||||||||||||||||||||||||||||||||||||
48 | #include "qmenu.h" | - | ||||||||||||||||||||||||||||||||||||
49 | #include "qmetaobject.h" | - | ||||||||||||||||||||||||||||||||||||
50 | #include "qpixmap.h" | - | ||||||||||||||||||||||||||||||||||||
51 | #include "qpointer.h" | - | ||||||||||||||||||||||||||||||||||||
52 | #include "qstack.h" | - | ||||||||||||||||||||||||||||||||||||
53 | #include "qstyle.h" | - | ||||||||||||||||||||||||||||||||||||
54 | #include "qstylefactory.h" | - | ||||||||||||||||||||||||||||||||||||
55 | #include "qvariant.h" | - | ||||||||||||||||||||||||||||||||||||
56 | #include "qwidget.h" | - | ||||||||||||||||||||||||||||||||||||
57 | #include "qstyleoption.h" | - | ||||||||||||||||||||||||||||||||||||
58 | #include "qstylehints.h" | - | ||||||||||||||||||||||||||||||||||||
59 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
60 | # include "qaccessible.h" | - | ||||||||||||||||||||||||||||||||||||
61 | #endif | - | ||||||||||||||||||||||||||||||||||||
62 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
63 | # include "qt_mac_p.h" | - | ||||||||||||||||||||||||||||||||||||
64 | # include "qt_cocoa_helpers_mac_p.h" | - | ||||||||||||||||||||||||||||||||||||
65 | # include "qmainwindow.h" | - | ||||||||||||||||||||||||||||||||||||
66 | # include "qtoolbar.h" | - | ||||||||||||||||||||||||||||||||||||
67 | # include <private/qmainwindowlayout_p.h> | - | ||||||||||||||||||||||||||||||||||||
68 | #endif | - | ||||||||||||||||||||||||||||||||||||
69 | #include <qpa/qplatformwindow.h> | - | ||||||||||||||||||||||||||||||||||||
70 | #include <qpa/qplatformbackingstore.h> | - | ||||||||||||||||||||||||||||||||||||
71 | #include "private/qwidgetwindow_p.h" | - | ||||||||||||||||||||||||||||||||||||
72 | #include "qpainter.h" | - | ||||||||||||||||||||||||||||||||||||
73 | #include "qtooltip.h" | - | ||||||||||||||||||||||||||||||||||||
74 | #include "qwhatsthis.h" | - | ||||||||||||||||||||||||||||||||||||
75 | #include "qdebug.h" | - | ||||||||||||||||||||||||||||||||||||
76 | #include "private/qstylesheetstyle_p.h" | - | ||||||||||||||||||||||||||||||||||||
77 | #include "private/qstyle_p.h" | - | ||||||||||||||||||||||||||||||||||||
78 | #include "qfileinfo.h" | - | ||||||||||||||||||||||||||||||||||||
79 | #include <QtGui/private/qhighdpiscaling_p.h> | - | ||||||||||||||||||||||||||||||||||||
80 | #include <QtGui/qinputmethod.h> | - | ||||||||||||||||||||||||||||||||||||
81 | #include <QtGui/qopenglcontext.h> | - | ||||||||||||||||||||||||||||||||||||
82 | #include <QtGui/private/qopenglcontext_p.h> | - | ||||||||||||||||||||||||||||||||||||
83 | #include <QtGui/qoffscreensurface.h> | - | ||||||||||||||||||||||||||||||||||||
84 | - | |||||||||||||||||||||||||||||||||||||
85 | #include <private/qgraphicseffect_p.h> | - | ||||||||||||||||||||||||||||||||||||
86 | #include <qbackingstore.h> | - | ||||||||||||||||||||||||||||||||||||
87 | #include <private/qwidgetbackingstore_p.h> | - | ||||||||||||||||||||||||||||||||||||
88 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
89 | # include <private/qpaintengine_mac_p.h> | - | ||||||||||||||||||||||||||||||||||||
90 | #endif | - | ||||||||||||||||||||||||||||||||||||
91 | #include <private/qpaintengine_raster_p.h> | - | ||||||||||||||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||||||||||||||
93 | #include "qwidget_p.h" | - | ||||||||||||||||||||||||||||||||||||
94 | #include <QtGui/private/qwindow_p.h> | - | ||||||||||||||||||||||||||||||||||||
95 | #include "qaction_p.h" | - | ||||||||||||||||||||||||||||||||||||
96 | #include "qlayout_p.h" | - | ||||||||||||||||||||||||||||||||||||
97 | #include "QtWidgets/qgraphicsproxywidget.h" | - | ||||||||||||||||||||||||||||||||||||
98 | #include "QtWidgets/qgraphicsscene.h" | - | ||||||||||||||||||||||||||||||||||||
99 | #include "private/qgraphicsproxywidget_p.h" | - | ||||||||||||||||||||||||||||||||||||
100 | #include "QtWidgets/qabstractscrollarea.h" | - | ||||||||||||||||||||||||||||||||||||
101 | #include "private/qabstractscrollarea_p.h" | - | ||||||||||||||||||||||||||||||||||||
102 | #include "private/qevent_p.h" | - | ||||||||||||||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||||||||||||||
104 | #include "private/qgesturemanager_p.h" | - | ||||||||||||||||||||||||||||||||||||
105 | - | |||||||||||||||||||||||||||||||||||||
106 | #ifdef QT_KEYPAD_NAVIGATION | - | ||||||||||||||||||||||||||||||||||||
107 | #include "qtabwidget.h" // Needed in inTabWidget() | - | ||||||||||||||||||||||||||||||||||||
108 | #endif // QT_KEYPAD_NAVIGATION | - | ||||||||||||||||||||||||||||||||||||
109 | - | |||||||||||||||||||||||||||||||||||||
110 | #include "qwindowcontainer_p.h" | - | ||||||||||||||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||||||||||||||
112 | #include <QtPlatformHeaders/qxcbwindowfunctions.h> | - | ||||||||||||||||||||||||||||||||||||
113 | - | |||||||||||||||||||||||||||||||||||||
114 | // widget/widget data creation count | - | ||||||||||||||||||||||||||||||||||||
115 | //#define QWIDGET_EXTRA_DEBUG | - | ||||||||||||||||||||||||||||||||||||
116 | //#define ALIEN_DEBUG | - | ||||||||||||||||||||||||||||||||||||
117 | - | |||||||||||||||||||||||||||||||||||||
118 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||||||||||||||
120 | static bool qt_enable_backingstore = true; | - | ||||||||||||||||||||||||||||||||||||
121 | #ifdef Q_DEAD_CODE_FROM_QT4_X11 | - | ||||||||||||||||||||||||||||||||||||
122 | // for compatibility with Qt 4.0 | - | ||||||||||||||||||||||||||||||||||||
123 | Q_WIDGETS_EXPORT void qt_x11_set_global_double_buffer(bool enable) | - | ||||||||||||||||||||||||||||||||||||
124 | { | - | ||||||||||||||||||||||||||||||||||||
125 | qt_enable_backingstore = enable; | - | ||||||||||||||||||||||||||||||||||||
126 | } | - | ||||||||||||||||||||||||||||||||||||
127 | #endif | - | ||||||||||||||||||||||||||||||||||||
128 | - | |||||||||||||||||||||||||||||||||||||
129 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
130 | bool qt_mac_clearDirtyOnWidgetInsideDrawWidget = false; | - | ||||||||||||||||||||||||||||||||||||
131 | #endif | - | ||||||||||||||||||||||||||||||||||||
132 | - | |||||||||||||||||||||||||||||||||||||
133 | static inline bool qRectIntersects(const QRect &r1, const QRect &r2) | - | ||||||||||||||||||||||||||||||||||||
134 | { | - | ||||||||||||||||||||||||||||||||||||
135 | return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right()) && never executed: return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right()) && qMax(r1.top(), r2.top()) <= qMin(r1.bottom(), r2.bottom())); | 0 | ||||||||||||||||||||||||||||||||||||
136 | qMax(r1.top(), r2.top()) <= qMin(r1.bottom(), r2.bottom())); never executed: return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right()) && qMax(r1.top(), r2.top()) <= qMin(r1.bottom(), r2.bottom())); | 0 | ||||||||||||||||||||||||||||||||||||
137 | } | - | ||||||||||||||||||||||||||||||||||||
138 | - | |||||||||||||||||||||||||||||||||||||
139 | static inline bool hasBackingStoreSupport() | - | ||||||||||||||||||||||||||||||||||||
140 | { | - | ||||||||||||||||||||||||||||||||||||
141 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
142 | } | - | ||||||||||||||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||||||||||||||
144 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
145 | # define QT_NO_PAINT_DEBUG | - | ||||||||||||||||||||||||||||||||||||
146 | #endif | - | ||||||||||||||||||||||||||||||||||||
147 | - | |||||||||||||||||||||||||||||||||||||
148 | extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp | - | ||||||||||||||||||||||||||||||||||||
149 | extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp | - | ||||||||||||||||||||||||||||||||||||
150 | - | |||||||||||||||||||||||||||||||||||||
151 | /*! | - | ||||||||||||||||||||||||||||||||||||
152 | \internal | - | ||||||||||||||||||||||||||||||||||||
153 | \class QWidgetBackingStoreTracker | - | ||||||||||||||||||||||||||||||||||||
154 | \brief Class which allows tracking of which widgets are using a given backing store | - | ||||||||||||||||||||||||||||||||||||
155 | - | |||||||||||||||||||||||||||||||||||||
156 | QWidgetBackingStoreTracker is a thin wrapper around a QWidgetBackingStore pointer, | - | ||||||||||||||||||||||||||||||||||||
157 | which maintains a list of the QWidgets which are currently using the backing | - | ||||||||||||||||||||||||||||||||||||
158 | store. This list is modified via the registerWidget and unregisterWidget functions. | - | ||||||||||||||||||||||||||||||||||||
159 | */ | - | ||||||||||||||||||||||||||||||||||||
160 | - | |||||||||||||||||||||||||||||||||||||
161 | QWidgetBackingStoreTracker::QWidgetBackingStoreTracker() | - | ||||||||||||||||||||||||||||||||||||
162 | : m_ptr(0) | - | ||||||||||||||||||||||||||||||||||||
163 | { | - | ||||||||||||||||||||||||||||||||||||
164 | - | |||||||||||||||||||||||||||||||||||||
165 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
166 | - | |||||||||||||||||||||||||||||||||||||
167 | QWidgetBackingStoreTracker::~QWidgetBackingStoreTracker() | - | ||||||||||||||||||||||||||||||||||||
168 | { | - | ||||||||||||||||||||||||||||||||||||
169 | delete m_ptr; | - | ||||||||||||||||||||||||||||||||||||
170 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
171 | - | |||||||||||||||||||||||||||||||||||||
172 | /*! | - | ||||||||||||||||||||||||||||||||||||
173 | \internal | - | ||||||||||||||||||||||||||||||||||||
174 | Destroy the contained QWidgetBackingStore, if not null, and clear the list of | - | ||||||||||||||||||||||||||||||||||||
175 | widgets using the backing store, then create a new QWidgetBackingStore, providing | - | ||||||||||||||||||||||||||||||||||||
176 | the QWidget. | - | ||||||||||||||||||||||||||||||||||||
177 | */ | - | ||||||||||||||||||||||||||||||||||||
178 | void QWidgetBackingStoreTracker::create(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
179 | { | - | ||||||||||||||||||||||||||||||||||||
180 | destroy(); | - | ||||||||||||||||||||||||||||||||||||
181 | m_ptr = new QWidgetBackingStore(widget); | - | ||||||||||||||||||||||||||||||||||||
182 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
183 | - | |||||||||||||||||||||||||||||||||||||
184 | /*! | - | ||||||||||||||||||||||||||||||||||||
185 | \internal | - | ||||||||||||||||||||||||||||||||||||
186 | Destroy the contained QWidgetBackingStore, if not null, and clear the list of | - | ||||||||||||||||||||||||||||||||||||
187 | widgets using the backing store. | - | ||||||||||||||||||||||||||||||||||||
188 | */ | - | ||||||||||||||||||||||||||||||||||||
189 | void QWidgetBackingStoreTracker::destroy() | - | ||||||||||||||||||||||||||||||||||||
190 | { | - | ||||||||||||||||||||||||||||||||||||
191 | delete m_ptr; | - | ||||||||||||||||||||||||||||||||||||
192 | m_ptr = 0; | - | ||||||||||||||||||||||||||||||||||||
193 | m_widgets.clear(); | - | ||||||||||||||||||||||||||||||||||||
194 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
195 | - | |||||||||||||||||||||||||||||||||||||
196 | /*! | - | ||||||||||||||||||||||||||||||||||||
197 | \internal | - | ||||||||||||||||||||||||||||||||||||
198 | Add the widget to the list of widgets currently using the backing store. | - | ||||||||||||||||||||||||||||||||||||
199 | If the widget was already in the list, this function is a no-op. | - | ||||||||||||||||||||||||||||||||||||
200 | */ | - | ||||||||||||||||||||||||||||||||||||
201 | void QWidgetBackingStoreTracker::registerWidget(QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
202 | { | - | ||||||||||||||||||||||||||||||||||||
203 | Q_ASSERT(m_ptr); | - | ||||||||||||||||||||||||||||||||||||
204 | Q_ASSERT(w->internalWinId()); | - | ||||||||||||||||||||||||||||||||||||
205 | Q_ASSERT(qt_widget_private(w)->maybeBackingStore() == m_ptr); | - | ||||||||||||||||||||||||||||||||||||
206 | m_widgets.insert(w); | - | ||||||||||||||||||||||||||||||||||||
207 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
208 | - | |||||||||||||||||||||||||||||||||||||
209 | /*! | - | ||||||||||||||||||||||||||||||||||||
210 | \internal | - | ||||||||||||||||||||||||||||||||||||
211 | Remove the widget from the list of widgets currently using the backing store. | - | ||||||||||||||||||||||||||||||||||||
212 | If the widget was in the list, and removing it causes the list to be empty, | - | ||||||||||||||||||||||||||||||||||||
213 | the backing store is deleted. | - | ||||||||||||||||||||||||||||||||||||
214 | If the widget was not in the list, this function is a no-op. | - | ||||||||||||||||||||||||||||||||||||
215 | */ | - | ||||||||||||||||||||||||||||||||||||
216 | void QWidgetBackingStoreTracker::unregisterWidget(QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
217 | { | - | ||||||||||||||||||||||||||||||||||||
218 | if (m_widgets.remove(w) && m_widgets.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
219 | delete m_ptr; | - | ||||||||||||||||||||||||||||||||||||
220 | m_ptr = 0; | - | ||||||||||||||||||||||||||||||||||||
221 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
222 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
223 | - | |||||||||||||||||||||||||||||||||||||
224 | /*! | - | ||||||||||||||||||||||||||||||||||||
225 | \internal | - | ||||||||||||||||||||||||||||||||||||
226 | Recursively remove widget and all of its descendents. | - | ||||||||||||||||||||||||||||||||||||
227 | */ | - | ||||||||||||||||||||||||||||||||||||
228 | void QWidgetBackingStoreTracker::unregisterWidgetSubtree(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
229 | { | - | ||||||||||||||||||||||||||||||||||||
230 | unregisterWidget(widget); | - | ||||||||||||||||||||||||||||||||||||
231 | foreach (QObject *child, widget->children()) | - | ||||||||||||||||||||||||||||||||||||
232 | if (QWidget *childWidget = qobject_cast<QWidget *>(child))
| 0 | ||||||||||||||||||||||||||||||||||||
233 | unregisterWidgetSubtree(childWidget); never executed: unregisterWidgetSubtree(childWidget); | 0 | ||||||||||||||||||||||||||||||||||||
234 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
235 | - | |||||||||||||||||||||||||||||||||||||
236 | QWidgetPrivate::QWidgetPrivate(int version) | - | ||||||||||||||||||||||||||||||||||||
237 | : QObjectPrivate(version) | - | ||||||||||||||||||||||||||||||||||||
238 | , extra(0) | - | ||||||||||||||||||||||||||||||||||||
239 | , focus_next(0) | - | ||||||||||||||||||||||||||||||||||||
240 | , focus_prev(0) | - | ||||||||||||||||||||||||||||||||||||
241 | , focus_child(0) | - | ||||||||||||||||||||||||||||||||||||
242 | , layout(0) | - | ||||||||||||||||||||||||||||||||||||
243 | , needsFlush(0) | - | ||||||||||||||||||||||||||||||||||||
244 | , redirectDev(0) | - | ||||||||||||||||||||||||||||||||||||
245 | , widgetItem(0) | - | ||||||||||||||||||||||||||||||||||||
246 | , extraPaintEngine(0) | - | ||||||||||||||||||||||||||||||||||||
247 | , polished(0) | - | ||||||||||||||||||||||||||||||||||||
248 | , graphicsEffect(0) | - | ||||||||||||||||||||||||||||||||||||
249 | #if !defined(QT_NO_IM) | - | ||||||||||||||||||||||||||||||||||||
250 | , imHints(Qt::ImhNone) | - | ||||||||||||||||||||||||||||||||||||
251 | #endif | - | ||||||||||||||||||||||||||||||||||||
252 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||||||||||||||
253 | , toolTipDuration(-1) | - | ||||||||||||||||||||||||||||||||||||
254 | #endif | - | ||||||||||||||||||||||||||||||||||||
255 | , inheritedFontResolveMask(0) | - | ||||||||||||||||||||||||||||||||||||
256 | , inheritedPaletteResolveMask(0) | - | ||||||||||||||||||||||||||||||||||||
257 | , leftmargin(0) | - | ||||||||||||||||||||||||||||||||||||
258 | , topmargin(0) | - | ||||||||||||||||||||||||||||||||||||
259 | , rightmargin(0) | - | ||||||||||||||||||||||||||||||||||||
260 | , bottommargin(0) | - | ||||||||||||||||||||||||||||||||||||
261 | , leftLayoutItemMargin(0) | - | ||||||||||||||||||||||||||||||||||||
262 | , topLayoutItemMargin(0) | - | ||||||||||||||||||||||||||||||||||||
263 | , rightLayoutItemMargin(0) | - | ||||||||||||||||||||||||||||||||||||
264 | , bottomLayoutItemMargin(0) | - | ||||||||||||||||||||||||||||||||||||
265 | , hd(0) | - | ||||||||||||||||||||||||||||||||||||
266 | , size_policy(QSizePolicy::Preferred, QSizePolicy::Preferred) | - | ||||||||||||||||||||||||||||||||||||
267 | , fg_role(QPalette::NoRole) | - | ||||||||||||||||||||||||||||||||||||
268 | , bg_role(QPalette::NoRole) | - | ||||||||||||||||||||||||||||||||||||
269 | , dirtyOpaqueChildren(1) | - | ||||||||||||||||||||||||||||||||||||
270 | , isOpaque(0) | - | ||||||||||||||||||||||||||||||||||||
271 | , retainSizeWhenHiddenChanged(0) | - | ||||||||||||||||||||||||||||||||||||
272 | , inDirtyList(0) | - | ||||||||||||||||||||||||||||||||||||
273 | , isScrolled(0) | - | ||||||||||||||||||||||||||||||||||||
274 | , isMoved(0) | - | ||||||||||||||||||||||||||||||||||||
275 | , usesDoubleBufferedGLContext(0) | - | ||||||||||||||||||||||||||||||||||||
276 | , mustHaveWindowHandle(0) | - | ||||||||||||||||||||||||||||||||||||
277 | , renderToTexture(0) | - | ||||||||||||||||||||||||||||||||||||
278 | , textureChildSeen(0) | - | ||||||||||||||||||||||||||||||||||||
279 | #ifndef QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
280 | , inheritsInputMethodHints(0) | - | ||||||||||||||||||||||||||||||||||||
281 | #endif | - | ||||||||||||||||||||||||||||||||||||
282 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
283 | , renderToTextureReallyDirty(1) | - | ||||||||||||||||||||||||||||||||||||
284 | , renderToTextureComposeActive(0) | - | ||||||||||||||||||||||||||||||||||||
285 | #endif | - | ||||||||||||||||||||||||||||||||||||
286 | , childrenHiddenByWState(0) | - | ||||||||||||||||||||||||||||||||||||
287 | , childrenShownByExpose(0) | - | ||||||||||||||||||||||||||||||||||||
288 | #if defined(Q_OS_WIN) | - | ||||||||||||||||||||||||||||||||||||
289 | , noPaintOnScreen(0) | - | ||||||||||||||||||||||||||||||||||||
290 | #endif | - | ||||||||||||||||||||||||||||||||||||
291 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
292 | , picture(0) | - | ||||||||||||||||||||||||||||||||||||
293 | #elif defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
294 | #ifndef QT_NO_GESTURES | - | ||||||||||||||||||||||||||||||||||||
295 | , nativeGesturePanEnabled(0) | - | ||||||||||||||||||||||||||||||||||||
296 | #endif | - | ||||||||||||||||||||||||||||||||||||
297 | #elif defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
298 | , needWindowChange(0) | - | ||||||||||||||||||||||||||||||||||||
299 | , window_event(0) | - | ||||||||||||||||||||||||||||||||||||
300 | , qd_hd(0) | - | ||||||||||||||||||||||||||||||||||||
301 | #endif | - | ||||||||||||||||||||||||||||||||||||
302 | { | - | ||||||||||||||||||||||||||||||||||||
303 | if (Q_UNLIKELY(!qApp)) {
| 0 | ||||||||||||||||||||||||||||||||||||
304 | qFatal("QWidget: Must construct a QApplication before a QWidget"); | - | ||||||||||||||||||||||||||||||||||||
305 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
306 | } | - | ||||||||||||||||||||||||||||||||||||
307 | - | |||||||||||||||||||||||||||||||||||||
308 | #ifdef QT_BUILD_INTERNAL | - | ||||||||||||||||||||||||||||||||||||
309 | // Don't check the version parameter in internal builds. | - | ||||||||||||||||||||||||||||||||||||
310 | // This allows incompatible versions to be loaded, possibly for testing. | - | ||||||||||||||||||||||||||||||||||||
311 | Q_UNUSED(version); | - | ||||||||||||||||||||||||||||||||||||
312 | #else | - | ||||||||||||||||||||||||||||||||||||
313 | if (Q_UNLIKELY(version != QObjectPrivateVersion)) | - | ||||||||||||||||||||||||||||||||||||
314 | qFatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)", | - | ||||||||||||||||||||||||||||||||||||
315 | version, QObjectPrivateVersion); | - | ||||||||||||||||||||||||||||||||||||
316 | #endif | - | ||||||||||||||||||||||||||||||||||||
317 | - | |||||||||||||||||||||||||||||||||||||
318 | isWidget = true; | - | ||||||||||||||||||||||||||||||||||||
319 | memset(high_attributes, 0, sizeof(high_attributes)); | - | ||||||||||||||||||||||||||||||||||||
320 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
321 | drawRectOriginalAdded = false; | - | ||||||||||||||||||||||||||||||||||||
322 | originalDrawMethod = true; | - | ||||||||||||||||||||||||||||||||||||
323 | changeMethods = false; | - | ||||||||||||||||||||||||||||||||||||
324 | isInUnifiedToolbar = false; | - | ||||||||||||||||||||||||||||||||||||
325 | unifiedSurface = 0; | - | ||||||||||||||||||||||||||||||||||||
326 | toolbar_ancestor = 0; | - | ||||||||||||||||||||||||||||||||||||
327 | flushRequested = false; | - | ||||||||||||||||||||||||||||||||||||
328 | touchEventsEnabled = false; | - | ||||||||||||||||||||||||||||||||||||
329 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
330 | #ifdef QWIDGET_EXTRA_DEBUG | - | ||||||||||||||||||||||||||||||||||||
331 | static int count = 0; | - | ||||||||||||||||||||||||||||||||||||
332 | qDebug() << "widgets" << ++count; | - | ||||||||||||||||||||||||||||||||||||
333 | #endif | - | ||||||||||||||||||||||||||||||||||||
334 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
335 | - | |||||||||||||||||||||||||||||||||||||
336 | - | |||||||||||||||||||||||||||||||||||||
337 | QWidgetPrivate::~QWidgetPrivate() | - | ||||||||||||||||||||||||||||||||||||
338 | { | - | ||||||||||||||||||||||||||||||||||||
339 | if (widgetItem)
| 0 | ||||||||||||||||||||||||||||||||||||
340 | widgetItem->wid = 0; never executed: widgetItem->wid = 0; | 0 | ||||||||||||||||||||||||||||||||||||
341 | - | |||||||||||||||||||||||||||||||||||||
342 | if (extra)
| 0 | ||||||||||||||||||||||||||||||||||||
343 | deleteExtra(); never executed: deleteExtra(); | 0 | ||||||||||||||||||||||||||||||||||||
344 | - | |||||||||||||||||||||||||||||||||||||
345 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
346 | delete graphicsEffect; | - | ||||||||||||||||||||||||||||||||||||
347 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
348 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
349 | - | |||||||||||||||||||||||||||||||||||||
350 | /*! | - | ||||||||||||||||||||||||||||||||||||
351 | \internal | - | ||||||||||||||||||||||||||||||||||||
352 | */ | - | ||||||||||||||||||||||||||||||||||||
353 | void QWidgetPrivate::scrollChildren(int dx, int dy) | - | ||||||||||||||||||||||||||||||||||||
354 | { | - | ||||||||||||||||||||||||||||||||||||
355 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
356 | if (q->children().size() > 0) { // scroll children
| 0 | ||||||||||||||||||||||||||||||||||||
357 | QPoint pd(dx, dy); | - | ||||||||||||||||||||||||||||||||||||
358 | QObjectList childObjects = q->children(); | - | ||||||||||||||||||||||||||||||||||||
359 | for (int i = 0; i < childObjects.size(); ++i) { // move all children
| 0 | ||||||||||||||||||||||||||||||||||||
360 | QWidget *w = qobject_cast<QWidget*>(childObjects.at(i)); | - | ||||||||||||||||||||||||||||||||||||
361 | if (w && !w->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
362 | QPoint oldp = w->pos(); | - | ||||||||||||||||||||||||||||||||||||
363 | QRect r(w->pos() + pd, w->size()); | - | ||||||||||||||||||||||||||||||||||||
364 | w->data->crect = r; | - | ||||||||||||||||||||||||||||||||||||
365 | if (w->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
366 | w->d_func()->setWSGeometry(); never executed: w->d_func()->setWSGeometry(); | 0 | ||||||||||||||||||||||||||||||||||||
367 | w->d_func()->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
368 | QMoveEvent e(r.topLeft(), oldp); | - | ||||||||||||||||||||||||||||||||||||
369 | QApplication::sendEvent(w, &e); | - | ||||||||||||||||||||||||||||||||||||
370 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
371 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
372 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
373 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
374 | - | |||||||||||||||||||||||||||||||||||||
375 | void QWidgetPrivate::setWSGeometry() | - | ||||||||||||||||||||||||||||||||||||
376 | { | - | ||||||||||||||||||||||||||||||||||||
377 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
378 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
379 | window->setGeometry(data.crect); never executed: window->setGeometry(data.crect); | 0 | ||||||||||||||||||||||||||||||||||||
380 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
381 | - | |||||||||||||||||||||||||||||||||||||
382 | void QWidgetPrivate::updateWidgetTransform(QEvent *event) | - | ||||||||||||||||||||||||||||||||||||
383 | { | - | ||||||||||||||||||||||||||||||||||||
384 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
385 | if (q == QGuiApplication::focusObject() || event->type() == QEvent::FocusIn) {
| 0 | ||||||||||||||||||||||||||||||||||||
386 | QTransform t; | - | ||||||||||||||||||||||||||||||||||||
387 | QPoint p = q->mapTo(q->topLevelWidget(), QPoint(0,0)); | - | ||||||||||||||||||||||||||||||||||||
388 | t.translate(p.x(), p.y()); | - | ||||||||||||||||||||||||||||||||||||
389 | QGuiApplication::inputMethod()->setInputItemTransform(t); | - | ||||||||||||||||||||||||||||||||||||
390 | QGuiApplication::inputMethod()->setInputItemRectangle(q->rect()); | - | ||||||||||||||||||||||||||||||||||||
391 | QGuiApplication::inputMethod()->update(Qt::ImInputItemClipRectangle); | - | ||||||||||||||||||||||||||||||||||||
392 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
393 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
394 | - | |||||||||||||||||||||||||||||||||||||
395 | #ifdef QT_KEYPAD_NAVIGATION | - | ||||||||||||||||||||||||||||||||||||
396 | QPointer<QWidget> QWidgetPrivate::editingWidget; | - | ||||||||||||||||||||||||||||||||||||
397 | - | |||||||||||||||||||||||||||||||||||||
398 | /*! | - | ||||||||||||||||||||||||||||||||||||
399 | Returns \c true if this widget currently has edit focus; otherwise false. | - | ||||||||||||||||||||||||||||||||||||
400 | - | |||||||||||||||||||||||||||||||||||||
401 | This feature is only available in Qt for Embedded Linux. | - | ||||||||||||||||||||||||||||||||||||
402 | - | |||||||||||||||||||||||||||||||||||||
403 | \sa setEditFocus(), QApplication::keypadNavigationEnabled() | - | ||||||||||||||||||||||||||||||||||||
404 | */ | - | ||||||||||||||||||||||||||||||||||||
405 | bool QWidget::hasEditFocus() const | - | ||||||||||||||||||||||||||||||||||||
406 | { | - | ||||||||||||||||||||||||||||||||||||
407 | const QWidget* w = this; | - | ||||||||||||||||||||||||||||||||||||
408 | while (w->d_func()->extra && w->d_func()->extra->focus_proxy) | - | ||||||||||||||||||||||||||||||||||||
409 | w = w->d_func()->extra->focus_proxy; | - | ||||||||||||||||||||||||||||||||||||
410 | return QWidgetPrivate::editingWidget == w; | - | ||||||||||||||||||||||||||||||||||||
411 | } | - | ||||||||||||||||||||||||||||||||||||
412 | - | |||||||||||||||||||||||||||||||||||||
413 | /*! | - | ||||||||||||||||||||||||||||||||||||
414 | \fn void QWidget::setEditFocus(bool enable) | - | ||||||||||||||||||||||||||||||||||||
415 | - | |||||||||||||||||||||||||||||||||||||
416 | If \a enable is true, make this widget have edit focus, in which | - | ||||||||||||||||||||||||||||||||||||
417 | case Qt::Key_Up and Qt::Key_Down will be delivered to the widget | - | ||||||||||||||||||||||||||||||||||||
418 | normally; otherwise, Qt::Key_Up and Qt::Key_Down are used to | - | ||||||||||||||||||||||||||||||||||||
419 | change focus. | - | ||||||||||||||||||||||||||||||||||||
420 | - | |||||||||||||||||||||||||||||||||||||
421 | This feature is only available in Qt for Embedded Linux. | - | ||||||||||||||||||||||||||||||||||||
422 | - | |||||||||||||||||||||||||||||||||||||
423 | \sa hasEditFocus(), QApplication::keypadNavigationEnabled() | - | ||||||||||||||||||||||||||||||||||||
424 | */ | - | ||||||||||||||||||||||||||||||||||||
425 | void QWidget::setEditFocus(bool on) | - | ||||||||||||||||||||||||||||||||||||
426 | { | - | ||||||||||||||||||||||||||||||||||||
427 | QWidget *f = this; | - | ||||||||||||||||||||||||||||||||||||
428 | while (f->d_func()->extra && f->d_func()->extra->focus_proxy) | - | ||||||||||||||||||||||||||||||||||||
429 | f = f->d_func()->extra->focus_proxy; | - | ||||||||||||||||||||||||||||||||||||
430 | - | |||||||||||||||||||||||||||||||||||||
431 | if (QWidgetPrivate::editingWidget && QWidgetPrivate::editingWidget != f) | - | ||||||||||||||||||||||||||||||||||||
432 | QWidgetPrivate::editingWidget->setEditFocus(false); | - | ||||||||||||||||||||||||||||||||||||
433 | - | |||||||||||||||||||||||||||||||||||||
434 | if (on && !f->hasFocus()) | - | ||||||||||||||||||||||||||||||||||||
435 | f->setFocus(); | - | ||||||||||||||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||||||||||||||
437 | if ((!on && !QWidgetPrivate::editingWidget) | - | ||||||||||||||||||||||||||||||||||||
438 | || (on && QWidgetPrivate::editingWidget == f)) { | - | ||||||||||||||||||||||||||||||||||||
439 | return; | - | ||||||||||||||||||||||||||||||||||||
440 | } | - | ||||||||||||||||||||||||||||||||||||
441 | - | |||||||||||||||||||||||||||||||||||||
442 | if (!on && QWidgetPrivate::editingWidget == f) { | - | ||||||||||||||||||||||||||||||||||||
443 | QWidgetPrivate::editingWidget = 0; | - | ||||||||||||||||||||||||||||||||||||
444 | QEvent event(QEvent::LeaveEditFocus); | - | ||||||||||||||||||||||||||||||||||||
445 | QApplication::sendEvent(f, &event); | - | ||||||||||||||||||||||||||||||||||||
446 | QApplication::sendEvent(f->style(), &event); | - | ||||||||||||||||||||||||||||||||||||
447 | } else if (on) { | - | ||||||||||||||||||||||||||||||||||||
448 | QWidgetPrivate::editingWidget = f; | - | ||||||||||||||||||||||||||||||||||||
449 | QEvent event(QEvent::EnterEditFocus); | - | ||||||||||||||||||||||||||||||||||||
450 | QApplication::sendEvent(f, &event); | - | ||||||||||||||||||||||||||||||||||||
451 | QApplication::sendEvent(f->style(), &event); | - | ||||||||||||||||||||||||||||||||||||
452 | } | - | ||||||||||||||||||||||||||||||||||||
453 | } | - | ||||||||||||||||||||||||||||||||||||
454 | #endif | - | ||||||||||||||||||||||||||||||||||||
455 | - | |||||||||||||||||||||||||||||||||||||
456 | /*! | - | ||||||||||||||||||||||||||||||||||||
457 | \property QWidget::autoFillBackground | - | ||||||||||||||||||||||||||||||||||||
458 | \brief whether the widget background is filled automatically | - | ||||||||||||||||||||||||||||||||||||
459 | \since 4.1 | - | ||||||||||||||||||||||||||||||||||||
460 | - | |||||||||||||||||||||||||||||||||||||
461 | If enabled, this property will cause Qt to fill the background of the | - | ||||||||||||||||||||||||||||||||||||
462 | widget before invoking the paint event. The color used is defined by the | - | ||||||||||||||||||||||||||||||||||||
463 | QPalette::Window color role from the widget's \l{QPalette}{palette}. | - | ||||||||||||||||||||||||||||||||||||
464 | - | |||||||||||||||||||||||||||||||||||||
465 | In addition, Windows are always filled with QPalette::Window, unless the | - | ||||||||||||||||||||||||||||||||||||
466 | WA_OpaquePaintEvent or WA_NoSystemBackground attributes are set. | - | ||||||||||||||||||||||||||||||||||||
467 | - | |||||||||||||||||||||||||||||||||||||
468 | This property cannot be turned off (i.e., set to false) if a widget's | - | ||||||||||||||||||||||||||||||||||||
469 | parent has a static gradient for its background. | - | ||||||||||||||||||||||||||||||||||||
470 | - | |||||||||||||||||||||||||||||||||||||
471 | \warning Use this property with caution in conjunction with | - | ||||||||||||||||||||||||||||||||||||
472 | \l{Qt Style Sheets}. When a widget has a style sheet with a valid | - | ||||||||||||||||||||||||||||||||||||
473 | background or a border-image, this property is automatically disabled. | - | ||||||||||||||||||||||||||||||||||||
474 | - | |||||||||||||||||||||||||||||||||||||
475 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
476 | - | |||||||||||||||||||||||||||||||||||||
477 | \sa Qt::WA_OpaquePaintEvent, Qt::WA_NoSystemBackground, | - | ||||||||||||||||||||||||||||||||||||
478 | {QWidget#Transparency and Double Buffering}{Transparency and Double Buffering} | - | ||||||||||||||||||||||||||||||||||||
479 | */ | - | ||||||||||||||||||||||||||||||||||||
480 | bool QWidget::autoFillBackground() const | - | ||||||||||||||||||||||||||||||||||||
481 | { | - | ||||||||||||||||||||||||||||||||||||
482 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
483 | return d->extra && d->extra->autoFillBackground; never executed: return d->extra && d->extra->autoFillBackground; | 0 | ||||||||||||||||||||||||||||||||||||
484 | } | - | ||||||||||||||||||||||||||||||||||||
485 | - | |||||||||||||||||||||||||||||||||||||
486 | void QWidget::setAutoFillBackground(bool enabled) | - | ||||||||||||||||||||||||||||||||||||
487 | { | - | ||||||||||||||||||||||||||||||||||||
488 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
489 | if (!d->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
490 | d->createExtra(); never executed: d->createExtra(); | 0 | ||||||||||||||||||||||||||||||||||||
491 | if (d->extra->autoFillBackground == enabled)
| 0 | ||||||||||||||||||||||||||||||||||||
492 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
493 | - | |||||||||||||||||||||||||||||||||||||
494 | d->extra->autoFillBackground = enabled; | - | ||||||||||||||||||||||||||||||||||||
495 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
496 | update(); | - | ||||||||||||||||||||||||||||||||||||
497 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
498 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
499 | - | |||||||||||||||||||||||||||||||||||||
500 | /*! | - | ||||||||||||||||||||||||||||||||||||
501 | \class QWidget | - | ||||||||||||||||||||||||||||||||||||
502 | \brief The QWidget class is the base class of all user interface objects. | - | ||||||||||||||||||||||||||||||||||||
503 | - | |||||||||||||||||||||||||||||||||||||
504 | \ingroup basicwidgets | - | ||||||||||||||||||||||||||||||||||||
505 | \inmodule QtWidgets | - | ||||||||||||||||||||||||||||||||||||
506 | - | |||||||||||||||||||||||||||||||||||||
507 | The widget is the atom of the user interface: it receives mouse, keyboard | - | ||||||||||||||||||||||||||||||||||||
508 | and other events from the window system, and paints a representation of | - | ||||||||||||||||||||||||||||||||||||
509 | itself on the screen. Every widget is rectangular, and they are sorted in a | - | ||||||||||||||||||||||||||||||||||||
510 | Z-order. A widget is clipped by its parent and by the widgets in front of | - | ||||||||||||||||||||||||||||||||||||
511 | it. | - | ||||||||||||||||||||||||||||||||||||
512 | - | |||||||||||||||||||||||||||||||||||||
513 | A widget that is not embedded in a parent widget is called a window. | - | ||||||||||||||||||||||||||||||||||||
514 | Usually, windows have a frame and a title bar, although it is also possible | - | ||||||||||||||||||||||||||||||||||||
515 | to create windows without such decoration using suitable | - | ||||||||||||||||||||||||||||||||||||
516 | \l{Qt::WindowFlags}{window flags}). In Qt, QMainWindow and the various | - | ||||||||||||||||||||||||||||||||||||
517 | subclasses of QDialog are the most common window types. | - | ||||||||||||||||||||||||||||||||||||
518 | - | |||||||||||||||||||||||||||||||||||||
519 | Every widget's constructor accepts one or two standard arguments: | - | ||||||||||||||||||||||||||||||||||||
520 | - | |||||||||||||||||||||||||||||||||||||
521 | \list 1 | - | ||||||||||||||||||||||||||||||||||||
522 | \li \c{QWidget *parent = 0} is the parent of the new widget. If it is 0 | - | ||||||||||||||||||||||||||||||||||||
523 | (the default), the new widget will be a window. If not, it will be | - | ||||||||||||||||||||||||||||||||||||
524 | a child of \e parent, and be constrained by \e parent's geometry | - | ||||||||||||||||||||||||||||||||||||
525 | (unless you specify Qt::Window as window flag). | - | ||||||||||||||||||||||||||||||||||||
526 | \li \c{Qt::WindowFlags f = 0} (where available) sets the window flags; | - | ||||||||||||||||||||||||||||||||||||
527 | the default is suitable for almost all widgets, but to get, for | - | ||||||||||||||||||||||||||||||||||||
528 | example, a window without a window system frame, you must use | - | ||||||||||||||||||||||||||||||||||||
529 | special flags. | - | ||||||||||||||||||||||||||||||||||||
530 | \endlist | - | ||||||||||||||||||||||||||||||||||||
531 | - | |||||||||||||||||||||||||||||||||||||
532 | QWidget has many member functions, but some of them have little direct | - | ||||||||||||||||||||||||||||||||||||
533 | functionality; for example, QWidget has a font property, but never uses | - | ||||||||||||||||||||||||||||||||||||
534 | this itself. There are many subclasses which provide real functionality, | - | ||||||||||||||||||||||||||||||||||||
535 | such as QLabel, QPushButton, QListWidget, and QTabWidget. | - | ||||||||||||||||||||||||||||||||||||
536 | - | |||||||||||||||||||||||||||||||||||||
537 | - | |||||||||||||||||||||||||||||||||||||
538 | \section1 Top-Level and Child Widgets | - | ||||||||||||||||||||||||||||||||||||
539 | - | |||||||||||||||||||||||||||||||||||||
540 | A widget without a parent widget is always an independent window (top-level | - | ||||||||||||||||||||||||||||||||||||
541 | widget). For these widgets, setWindowTitle() and setWindowIcon() set the | - | ||||||||||||||||||||||||||||||||||||
542 | title bar and icon respectively. | - | ||||||||||||||||||||||||||||||||||||
543 | - | |||||||||||||||||||||||||||||||||||||
544 | Non-window widgets are child widgets, displayed within their parent | - | ||||||||||||||||||||||||||||||||||||
545 | widgets. Most widgets in Qt are mainly useful as child widgets. For | - | ||||||||||||||||||||||||||||||||||||
546 | example, it is possible to display a button as a top-level window, but most | - | ||||||||||||||||||||||||||||||||||||
547 | people prefer to put their buttons inside other widgets, such as QDialog. | - | ||||||||||||||||||||||||||||||||||||
548 | - | |||||||||||||||||||||||||||||||||||||
549 | \image parent-child-widgets.png A parent widget containing various child widgets. | - | ||||||||||||||||||||||||||||||||||||
550 | - | |||||||||||||||||||||||||||||||||||||
551 | The diagram above shows a QGroupBox widget being used to hold various child | - | ||||||||||||||||||||||||||||||||||||
552 | widgets in a layout provided by QGridLayout. The QLabel child widgets have | - | ||||||||||||||||||||||||||||||||||||
553 | been outlined to indicate their full sizes. | - | ||||||||||||||||||||||||||||||||||||
554 | - | |||||||||||||||||||||||||||||||||||||
555 | If you want to use a QWidget to hold child widgets you will usually want to | - | ||||||||||||||||||||||||||||||||||||
556 | add a layout to the parent QWidget. See \l{Layout Management} for more | - | ||||||||||||||||||||||||||||||||||||
557 | information. | - | ||||||||||||||||||||||||||||||||||||
558 | - | |||||||||||||||||||||||||||||||||||||
559 | - | |||||||||||||||||||||||||||||||||||||
560 | \section1 Composite Widgets | - | ||||||||||||||||||||||||||||||||||||
561 | - | |||||||||||||||||||||||||||||||||||||
562 | When a widget is used as a container to group a number of child widgets, it | - | ||||||||||||||||||||||||||||||||||||
563 | is known as a composite widget. These can be created by constructing a | - | ||||||||||||||||||||||||||||||||||||
564 | widget with the required visual properties - a QFrame, for example - and | - | ||||||||||||||||||||||||||||||||||||
565 | adding child widgets to it, usually managed by a layout. The above diagram | - | ||||||||||||||||||||||||||||||||||||
566 | shows such a composite widget that was created using Qt Designer. | - | ||||||||||||||||||||||||||||||||||||
567 | - | |||||||||||||||||||||||||||||||||||||
568 | Composite widgets can also be created by subclassing a standard widget, | - | ||||||||||||||||||||||||||||||||||||
569 | such as QWidget or QFrame, and adding the necessary layout and child | - | ||||||||||||||||||||||||||||||||||||
570 | widgets in the constructor of the subclass. Many of the \l{Qt Widgets Examples} | - | ||||||||||||||||||||||||||||||||||||
571 | {examples provided with Qt} use this approach, and it is also covered in | - | ||||||||||||||||||||||||||||||||||||
572 | the Qt \l{Tutorials}. | - | ||||||||||||||||||||||||||||||||||||
573 | - | |||||||||||||||||||||||||||||||||||||
574 | - | |||||||||||||||||||||||||||||||||||||
575 | \section1 Custom Widgets and Painting | - | ||||||||||||||||||||||||||||||||||||
576 | - | |||||||||||||||||||||||||||||||||||||
577 | Since QWidget is a subclass of QPaintDevice, subclasses can be used to | - | ||||||||||||||||||||||||||||||||||||
578 | display custom content that is composed using a series of painting | - | ||||||||||||||||||||||||||||||||||||
579 | operations with an instance of the QPainter class. This approach contrasts | - | ||||||||||||||||||||||||||||||||||||
580 | with the canvas-style approach used by the \l{Graphics View} | - | ||||||||||||||||||||||||||||||||||||
581 | {Graphics View Framework} where items are added to a scene by the | - | ||||||||||||||||||||||||||||||||||||
582 | application and are rendered by the framework itself. | - | ||||||||||||||||||||||||||||||||||||
583 | - | |||||||||||||||||||||||||||||||||||||
584 | Each widget performs all painting operations from within its paintEvent() | - | ||||||||||||||||||||||||||||||||||||
585 | function. This is called whenever the widget needs to be redrawn, either | - | ||||||||||||||||||||||||||||||||||||
586 | as a result of some external change or when requested by the application. | - | ||||||||||||||||||||||||||||||||||||
587 | - | |||||||||||||||||||||||||||||||||||||
588 | The \l{widgets/analogclock}{Analog Clock example} shows how a simple widget | - | ||||||||||||||||||||||||||||||||||||
589 | can handle paint events. | - | ||||||||||||||||||||||||||||||||||||
590 | - | |||||||||||||||||||||||||||||||||||||
591 | - | |||||||||||||||||||||||||||||||||||||
592 | \section1 Size Hints and Size Policies | - | ||||||||||||||||||||||||||||||||||||
593 | - | |||||||||||||||||||||||||||||||||||||
594 | When implementing a new widget, it is almost always useful to reimplement | - | ||||||||||||||||||||||||||||||||||||
595 | sizeHint() to provide a reasonable default size for the widget and to set | - | ||||||||||||||||||||||||||||||||||||
596 | the correct size policy with setSizePolicy(). | - | ||||||||||||||||||||||||||||||||||||
597 | - | |||||||||||||||||||||||||||||||||||||
598 | By default, composite widgets which do not provide a size hint will be | - | ||||||||||||||||||||||||||||||||||||
599 | sized according to the space requirements of their child widgets. | - | ||||||||||||||||||||||||||||||||||||
600 | - | |||||||||||||||||||||||||||||||||||||
601 | The size policy lets you supply good default behavior for the layout | - | ||||||||||||||||||||||||||||||||||||
602 | management system, so that other widgets can contain and manage yours | - | ||||||||||||||||||||||||||||||||||||
603 | easily. The default size policy indicates that the size hint represents | - | ||||||||||||||||||||||||||||||||||||
604 | the preferred size of the widget, and this is often good enough for many | - | ||||||||||||||||||||||||||||||||||||
605 | widgets. | - | ||||||||||||||||||||||||||||||||||||
606 | - | |||||||||||||||||||||||||||||||||||||
607 | \note The size of top-level widgets are constrained to 2/3 of the desktop's | - | ||||||||||||||||||||||||||||||||||||
608 | height and width. You can resize() the widget manually if these bounds are | - | ||||||||||||||||||||||||||||||||||||
609 | inadequate. | - | ||||||||||||||||||||||||||||||||||||
610 | - | |||||||||||||||||||||||||||||||||||||
611 | - | |||||||||||||||||||||||||||||||||||||
612 | \section1 Events | - | ||||||||||||||||||||||||||||||||||||
613 | - | |||||||||||||||||||||||||||||||||||||
614 | Widgets respond to events that are typically caused by user actions. Qt | - | ||||||||||||||||||||||||||||||||||||
615 | delivers events to widgets by calling specific event handler functions with | - | ||||||||||||||||||||||||||||||||||||
616 | instances of QEvent subclasses containing information about each event. | - | ||||||||||||||||||||||||||||||||||||
617 | - | |||||||||||||||||||||||||||||||||||||
618 | If your widget only contains child widgets, you probably do not need to | - | ||||||||||||||||||||||||||||||||||||
619 | implement any event handlers. If you want to detect a mouse click in a | - | ||||||||||||||||||||||||||||||||||||
620 | child widget call the child's underMouse() function inside the widget's | - | ||||||||||||||||||||||||||||||||||||
621 | mousePressEvent(). | - | ||||||||||||||||||||||||||||||||||||
622 | - | |||||||||||||||||||||||||||||||||||||
623 | The \l{widgets/scribble}{Scribble example} implements a wider set of | - | ||||||||||||||||||||||||||||||||||||
624 | events to handle mouse movement, button presses, and window resizing. | - | ||||||||||||||||||||||||||||||||||||
625 | - | |||||||||||||||||||||||||||||||||||||
626 | You will need to supply the behavior and content for your own widgets, but | - | ||||||||||||||||||||||||||||||||||||
627 | here is a brief overview of the events that are relevant to QWidget, | - | ||||||||||||||||||||||||||||||||||||
628 | starting with the most common ones: | - | ||||||||||||||||||||||||||||||||||||
629 | - | |||||||||||||||||||||||||||||||||||||
630 | \list | - | ||||||||||||||||||||||||||||||||||||
631 | \li paintEvent() is called whenever the widget needs to be repainted. | - | ||||||||||||||||||||||||||||||||||||
632 | Every widget displaying custom content must implement it. Painting | - | ||||||||||||||||||||||||||||||||||||
633 | using a QPainter can only take place in a paintEvent() or a | - | ||||||||||||||||||||||||||||||||||||
634 | function called by a paintEvent(). | - | ||||||||||||||||||||||||||||||||||||
635 | \li resizeEvent() is called when the widget has been resized. | - | ||||||||||||||||||||||||||||||||||||
636 | \li mousePressEvent() is called when a mouse button is pressed while | - | ||||||||||||||||||||||||||||||||||||
637 | the mouse cursor is inside the widget, or when the widget has | - | ||||||||||||||||||||||||||||||||||||
638 | grabbed the mouse using grabMouse(). Pressing the mouse without | - | ||||||||||||||||||||||||||||||||||||
639 | releasing it is effectively the same as calling grabMouse(). | - | ||||||||||||||||||||||||||||||||||||
640 | \li mouseReleaseEvent() is called when a mouse button is released. A | - | ||||||||||||||||||||||||||||||||||||
641 | widget receives mouse release events when it has received the | - | ||||||||||||||||||||||||||||||||||||
642 | corresponding mouse press event. This means that if the user | - | ||||||||||||||||||||||||||||||||||||
643 | presses the mouse inside \e your widget, then drags the mouse | - | ||||||||||||||||||||||||||||||||||||
644 | somewhere else before releasing the mouse button, \e your widget | - | ||||||||||||||||||||||||||||||||||||
645 | receives the release event. There is one exception: if a popup menu | - | ||||||||||||||||||||||||||||||||||||
646 | appears while the mouse button is held down, this popup immediately | - | ||||||||||||||||||||||||||||||||||||
647 | steals the mouse events. | - | ||||||||||||||||||||||||||||||||||||
648 | \li mouseDoubleClickEvent() is called when the user double-clicks in | - | ||||||||||||||||||||||||||||||||||||
649 | the widget. If the user double-clicks, the widget receives a mouse | - | ||||||||||||||||||||||||||||||||||||
650 | press event, a mouse release event, (a mouse click event,) a second | - | ||||||||||||||||||||||||||||||||||||
651 | mouse press, this event and finally a second mouse release event. | - | ||||||||||||||||||||||||||||||||||||
652 | (Some mouse move events may also be | - | ||||||||||||||||||||||||||||||||||||
653 | received if the mouse is not held steady during this operation.) It | - | ||||||||||||||||||||||||||||||||||||
654 | is \e{not possible} to distinguish a click from a double-click | - | ||||||||||||||||||||||||||||||||||||
655 | until the second click arrives. (This is one reason why most GUI | - | ||||||||||||||||||||||||||||||||||||
656 | books recommend that double-clicks be an extension of | - | ||||||||||||||||||||||||||||||||||||
657 | single-clicks, rather than trigger a different action.) | - | ||||||||||||||||||||||||||||||||||||
658 | \endlist | - | ||||||||||||||||||||||||||||||||||||
659 | - | |||||||||||||||||||||||||||||||||||||
660 | Widgets that accept keyboard input need to reimplement a few more event | - | ||||||||||||||||||||||||||||||||||||
661 | handlers: | - | ||||||||||||||||||||||||||||||||||||
662 | - | |||||||||||||||||||||||||||||||||||||
663 | \list | - | ||||||||||||||||||||||||||||||||||||
664 | \li keyPressEvent() is called whenever a key is pressed, and again when | - | ||||||||||||||||||||||||||||||||||||
665 | a key has been held down long enough for it to auto-repeat. The | - | ||||||||||||||||||||||||||||||||||||
666 | \uicontrol Tab and \uicontrol Shift+Tab keys are only passed to the widget if | - | ||||||||||||||||||||||||||||||||||||
667 | they are not used by the focus-change mechanisms. To force those | - | ||||||||||||||||||||||||||||||||||||
668 | keys to be processed by your widget, you must reimplement | - | ||||||||||||||||||||||||||||||||||||
669 | QWidget::event(). | - | ||||||||||||||||||||||||||||||||||||
670 | \li focusInEvent() is called when the widget gains keyboard focus | - | ||||||||||||||||||||||||||||||||||||
671 | (assuming you have called setFocusPolicy()). Well-behaved widgets | - | ||||||||||||||||||||||||||||||||||||
672 | indicate that they own the keyboard focus in a clear but discreet | - | ||||||||||||||||||||||||||||||||||||
673 | way. | - | ||||||||||||||||||||||||||||||||||||
674 | \li focusOutEvent() is called when the widget loses keyboard focus. | - | ||||||||||||||||||||||||||||||||||||
675 | \endlist | - | ||||||||||||||||||||||||||||||||||||
676 | - | |||||||||||||||||||||||||||||||||||||
677 | You may be required to also reimplement some of the less common event | - | ||||||||||||||||||||||||||||||||||||
678 | handlers: | - | ||||||||||||||||||||||||||||||||||||
679 | - | |||||||||||||||||||||||||||||||||||||
680 | \list | - | ||||||||||||||||||||||||||||||||||||
681 | \li mouseMoveEvent() is called whenever the mouse moves while a mouse | - | ||||||||||||||||||||||||||||||||||||
682 | button is held down. This can be useful during drag and drop | - | ||||||||||||||||||||||||||||||||||||
683 | operations. If you call \l{setMouseTracking()}{setMouseTracking}(true), | - | ||||||||||||||||||||||||||||||||||||
684 | you get mouse move events even when no buttons are held down. | - | ||||||||||||||||||||||||||||||||||||
685 | (See also the \l{Drag and Drop} guide.) | - | ||||||||||||||||||||||||||||||||||||
686 | \li keyReleaseEvent() is called whenever a key is released and while it | - | ||||||||||||||||||||||||||||||||||||
687 | is held down (if the key is auto-repeating). In that case, the | - | ||||||||||||||||||||||||||||||||||||
688 | widget will receive a pair of key release and key press event for | - | ||||||||||||||||||||||||||||||||||||
689 | every repeat. The \uicontrol Tab and \uicontrol Shift+Tab keys are only passed | - | ||||||||||||||||||||||||||||||||||||
690 | to the widget if they are not used by the focus-change mechanisms. | - | ||||||||||||||||||||||||||||||||||||
691 | To force those keys to be processed by your widget, you must | - | ||||||||||||||||||||||||||||||||||||
692 | reimplement QWidget::event(). | - | ||||||||||||||||||||||||||||||||||||
693 | \li wheelEvent() is called whenever the user turns the mouse wheel | - | ||||||||||||||||||||||||||||||||||||
694 | while the widget has the focus. | - | ||||||||||||||||||||||||||||||||||||
695 | \li enterEvent() is called when the mouse enters the widget's screen | - | ||||||||||||||||||||||||||||||||||||
696 | space. (This excludes screen space owned by any of the widget's | - | ||||||||||||||||||||||||||||||||||||
697 | children.) | - | ||||||||||||||||||||||||||||||||||||
698 | \li leaveEvent() is called when the mouse leaves the widget's screen | - | ||||||||||||||||||||||||||||||||||||
699 | space. If the mouse enters a child widget it will not cause a | - | ||||||||||||||||||||||||||||||||||||
700 | leaveEvent(). | - | ||||||||||||||||||||||||||||||||||||
701 | \li moveEvent() is called when the widget has been moved relative to | - | ||||||||||||||||||||||||||||||||||||
702 | its parent. | - | ||||||||||||||||||||||||||||||||||||
703 | \li closeEvent() is called when the user closes the widget (or when | - | ||||||||||||||||||||||||||||||||||||
704 | close() is called). | - | ||||||||||||||||||||||||||||||||||||
705 | \endlist | - | ||||||||||||||||||||||||||||||||||||
706 | - | |||||||||||||||||||||||||||||||||||||
707 | There are also some rather obscure events described in the documentation | - | ||||||||||||||||||||||||||||||||||||
708 | for QEvent::Type. To handle these events, you need to reimplement event() | - | ||||||||||||||||||||||||||||||||||||
709 | directly. | - | ||||||||||||||||||||||||||||||||||||
710 | - | |||||||||||||||||||||||||||||||||||||
711 | The default implementation of event() handles \uicontrol Tab and \uicontrol Shift+Tab | - | ||||||||||||||||||||||||||||||||||||
712 | (to move the keyboard focus), and passes on most of the other events to | - | ||||||||||||||||||||||||||||||||||||
713 | one of the more specialized handlers above. | - | ||||||||||||||||||||||||||||||||||||
714 | - | |||||||||||||||||||||||||||||||||||||
715 | Events and the mechanism used to deliver them are covered in | - | ||||||||||||||||||||||||||||||||||||
716 | \l{The Event System}. | - | ||||||||||||||||||||||||||||||||||||
717 | - | |||||||||||||||||||||||||||||||||||||
718 | \section1 Groups of Functions and Properties | - | ||||||||||||||||||||||||||||||||||||
719 | - | |||||||||||||||||||||||||||||||||||||
720 | \table | - | ||||||||||||||||||||||||||||||||||||
721 | \header \li Context \li Functions and Properties | - | ||||||||||||||||||||||||||||||||||||
722 | - | |||||||||||||||||||||||||||||||||||||
723 | \row \li Window functions \li | - | ||||||||||||||||||||||||||||||||||||
724 | show(), | - | ||||||||||||||||||||||||||||||||||||
725 | hide(), | - | ||||||||||||||||||||||||||||||||||||
726 | raise(), | - | ||||||||||||||||||||||||||||||||||||
727 | lower(), | - | ||||||||||||||||||||||||||||||||||||
728 | close(). | - | ||||||||||||||||||||||||||||||||||||
729 | - | |||||||||||||||||||||||||||||||||||||
730 | \row \li Top-level windows \li | - | ||||||||||||||||||||||||||||||||||||
731 | \l windowModified, \l windowTitle, \l windowIcon, | - | ||||||||||||||||||||||||||||||||||||
732 | \l isActiveWindow, activateWindow(), \l minimized, showMinimized(), | - | ||||||||||||||||||||||||||||||||||||
733 | \l maximized, showMaximized(), \l fullScreen, showFullScreen(), | - | ||||||||||||||||||||||||||||||||||||
734 | showNormal(). | - | ||||||||||||||||||||||||||||||||||||
735 | - | |||||||||||||||||||||||||||||||||||||
736 | \row \li Window contents \li | - | ||||||||||||||||||||||||||||||||||||
737 | update(), | - | ||||||||||||||||||||||||||||||||||||
738 | repaint(), | - | ||||||||||||||||||||||||||||||||||||
739 | scroll(). | - | ||||||||||||||||||||||||||||||||||||
740 | - | |||||||||||||||||||||||||||||||||||||
741 | \row \li Geometry \li | - | ||||||||||||||||||||||||||||||||||||
742 | \l pos, x(), y(), \l rect, \l size, width(), height(), move(), resize(), | - | ||||||||||||||||||||||||||||||||||||
743 | \l sizePolicy, sizeHint(), minimumSizeHint(), | - | ||||||||||||||||||||||||||||||||||||
744 | updateGeometry(), layout(), | - | ||||||||||||||||||||||||||||||||||||
745 | \l frameGeometry, \l geometry, \l childrenRect, \l childrenRegion, | - | ||||||||||||||||||||||||||||||||||||
746 | adjustSize(), | - | ||||||||||||||||||||||||||||||||||||
747 | mapFromGlobal(), mapToGlobal(), | - | ||||||||||||||||||||||||||||||||||||
748 | mapFromParent(), mapToParent(), | - | ||||||||||||||||||||||||||||||||||||
749 | \l maximumSize, \l minimumSize, \l sizeIncrement, | - | ||||||||||||||||||||||||||||||||||||
750 | \l baseSize, setFixedSize() | - | ||||||||||||||||||||||||||||||||||||
751 | - | |||||||||||||||||||||||||||||||||||||
752 | \row \li Mode \li | - | ||||||||||||||||||||||||||||||||||||
753 | \l visible, isVisibleTo(), | - | ||||||||||||||||||||||||||||||||||||
754 | \l enabled, isEnabledTo(), | - | ||||||||||||||||||||||||||||||||||||
755 | \l modal, | - | ||||||||||||||||||||||||||||||||||||
756 | isWindow(), | - | ||||||||||||||||||||||||||||||||||||
757 | \l mouseTracking, | - | ||||||||||||||||||||||||||||||||||||
758 | \l updatesEnabled, | - | ||||||||||||||||||||||||||||||||||||
759 | visibleRegion(). | - | ||||||||||||||||||||||||||||||||||||
760 | - | |||||||||||||||||||||||||||||||||||||
761 | \row \li Look and feel \li | - | ||||||||||||||||||||||||||||||||||||
762 | style(), | - | ||||||||||||||||||||||||||||||||||||
763 | setStyle(), | - | ||||||||||||||||||||||||||||||||||||
764 | \l styleSheet, | - | ||||||||||||||||||||||||||||||||||||
765 | \l cursor, | - | ||||||||||||||||||||||||||||||||||||
766 | \l font, | - | ||||||||||||||||||||||||||||||||||||
767 | \l palette, | - | ||||||||||||||||||||||||||||||||||||
768 | backgroundRole(), setBackgroundRole(), | - | ||||||||||||||||||||||||||||||||||||
769 | fontInfo(), fontMetrics(). | - | ||||||||||||||||||||||||||||||||||||
770 | - | |||||||||||||||||||||||||||||||||||||
771 | \row \li Keyboard focus functions \li | - | ||||||||||||||||||||||||||||||||||||
772 | \l focus, \l focusPolicy, | - | ||||||||||||||||||||||||||||||||||||
773 | setFocus(), clearFocus(), setTabOrder(), setFocusProxy(), | - | ||||||||||||||||||||||||||||||||||||
774 | focusNextChild(), focusPreviousChild(). | - | ||||||||||||||||||||||||||||||||||||
775 | - | |||||||||||||||||||||||||||||||||||||
776 | \row \li Mouse and keyboard grabbing \li | - | ||||||||||||||||||||||||||||||||||||
777 | grabMouse(), releaseMouse(), | - | ||||||||||||||||||||||||||||||||||||
778 | grabKeyboard(), releaseKeyboard(), | - | ||||||||||||||||||||||||||||||||||||
779 | mouseGrabber(), keyboardGrabber(). | - | ||||||||||||||||||||||||||||||||||||
780 | - | |||||||||||||||||||||||||||||||||||||
781 | \row \li Event handlers \li | - | ||||||||||||||||||||||||||||||||||||
782 | event(), | - | ||||||||||||||||||||||||||||||||||||
783 | mousePressEvent(), | - | ||||||||||||||||||||||||||||||||||||
784 | mouseReleaseEvent(), | - | ||||||||||||||||||||||||||||||||||||
785 | mouseDoubleClickEvent(), | - | ||||||||||||||||||||||||||||||||||||
786 | mouseMoveEvent(), | - | ||||||||||||||||||||||||||||||||||||
787 | keyPressEvent(), | - | ||||||||||||||||||||||||||||||||||||
788 | keyReleaseEvent(), | - | ||||||||||||||||||||||||||||||||||||
789 | focusInEvent(), | - | ||||||||||||||||||||||||||||||||||||
790 | focusOutEvent(), | - | ||||||||||||||||||||||||||||||||||||
791 | wheelEvent(), | - | ||||||||||||||||||||||||||||||||||||
792 | enterEvent(), | - | ||||||||||||||||||||||||||||||||||||
793 | leaveEvent(), | - | ||||||||||||||||||||||||||||||||||||
794 | paintEvent(), | - | ||||||||||||||||||||||||||||||||||||
795 | moveEvent(), | - | ||||||||||||||||||||||||||||||||||||
796 | resizeEvent(), | - | ||||||||||||||||||||||||||||||||||||
797 | closeEvent(), | - | ||||||||||||||||||||||||||||||||||||
798 | dragEnterEvent(), | - | ||||||||||||||||||||||||||||||||||||
799 | dragMoveEvent(), | - | ||||||||||||||||||||||||||||||||||||
800 | dragLeaveEvent(), | - | ||||||||||||||||||||||||||||||||||||
801 | dropEvent(), | - | ||||||||||||||||||||||||||||||||||||
802 | childEvent(), | - | ||||||||||||||||||||||||||||||||||||
803 | showEvent(), | - | ||||||||||||||||||||||||||||||||||||
804 | hideEvent(), | - | ||||||||||||||||||||||||||||||||||||
805 | customEvent(). | - | ||||||||||||||||||||||||||||||||||||
806 | changeEvent(), | - | ||||||||||||||||||||||||||||||||||||
807 | - | |||||||||||||||||||||||||||||||||||||
808 | \row \li System functions \li | - | ||||||||||||||||||||||||||||||||||||
809 | parentWidget(), window(), setParent(), winId(), | - | ||||||||||||||||||||||||||||||||||||
810 | find(), metric(). | - | ||||||||||||||||||||||||||||||||||||
811 | - | |||||||||||||||||||||||||||||||||||||
812 | \row \li Context menu \li | - | ||||||||||||||||||||||||||||||||||||
813 | contextMenuPolicy, contextMenuEvent(), | - | ||||||||||||||||||||||||||||||||||||
814 | customContextMenuRequested(), actions() | - | ||||||||||||||||||||||||||||||||||||
815 | - | |||||||||||||||||||||||||||||||||||||
816 | \row \li Interactive help \li | - | ||||||||||||||||||||||||||||||||||||
817 | setToolTip(), setWhatsThis() | - | ||||||||||||||||||||||||||||||||||||
818 | - | |||||||||||||||||||||||||||||||||||||
819 | \endtable | - | ||||||||||||||||||||||||||||||||||||
820 | - | |||||||||||||||||||||||||||||||||||||
821 | - | |||||||||||||||||||||||||||||||||||||
822 | \section1 Widget Style Sheets | - | ||||||||||||||||||||||||||||||||||||
823 | - | |||||||||||||||||||||||||||||||||||||
824 | In addition to the standard widget styles for each platform, widgets can | - | ||||||||||||||||||||||||||||||||||||
825 | also be styled according to rules specified in a \l{styleSheet} | - | ||||||||||||||||||||||||||||||||||||
826 | {style sheet}. This feature enables you to customize the appearance of | - | ||||||||||||||||||||||||||||||||||||
827 | specific widgets to provide visual cues to users about their purpose. For | - | ||||||||||||||||||||||||||||||||||||
828 | example, a button could be styled in a particular way to indicate that it | - | ||||||||||||||||||||||||||||||||||||
829 | performs a destructive action. | - | ||||||||||||||||||||||||||||||||||||
830 | - | |||||||||||||||||||||||||||||||||||||
831 | The use of widget style sheets is described in more detail in the | - | ||||||||||||||||||||||||||||||||||||
832 | \l{Qt Style Sheets} document. | - | ||||||||||||||||||||||||||||||||||||
833 | - | |||||||||||||||||||||||||||||||||||||
834 | - | |||||||||||||||||||||||||||||||||||||
835 | \section1 Transparency and Double Buffering | - | ||||||||||||||||||||||||||||||||||||
836 | - | |||||||||||||||||||||||||||||||||||||
837 | Since Qt 4.0, QWidget automatically double-buffers its painting, so there | - | ||||||||||||||||||||||||||||||||||||
838 | is no need to write double-buffering code in paintEvent() to avoid | - | ||||||||||||||||||||||||||||||||||||
839 | flicker. | - | ||||||||||||||||||||||||||||||||||||
840 | - | |||||||||||||||||||||||||||||||||||||
841 | Since Qt 4.1, the Qt::WA_ContentsPropagated widget attribute has been | - | ||||||||||||||||||||||||||||||||||||
842 | deprecated. Instead, the contents of parent widgets are propagated by | - | ||||||||||||||||||||||||||||||||||||
843 | default to each of their children as long as Qt::WA_PaintOnScreen is not | - | ||||||||||||||||||||||||||||||||||||
844 | set. Custom widgets can be written to take advantage of this feature by | - | ||||||||||||||||||||||||||||||||||||
845 | updating irregular regions (to create non-rectangular child widgets), or | - | ||||||||||||||||||||||||||||||||||||
846 | painting with colors that have less than full alpha component. The | - | ||||||||||||||||||||||||||||||||||||
847 | following diagram shows how attributes and properties of a custom widget | - | ||||||||||||||||||||||||||||||||||||
848 | can be fine-tuned to achieve different effects. | - | ||||||||||||||||||||||||||||||||||||
849 | - | |||||||||||||||||||||||||||||||||||||
850 | \image propagation-custom.png | - | ||||||||||||||||||||||||||||||||||||
851 | - | |||||||||||||||||||||||||||||||||||||
852 | In the above diagram, a semi-transparent rectangular child widget with an | - | ||||||||||||||||||||||||||||||||||||
853 | area removed is constructed and added to a parent widget (a QLabel showing | - | ||||||||||||||||||||||||||||||||||||
854 | a pixmap). Then, different properties and widget attributes are set to | - | ||||||||||||||||||||||||||||||||||||
855 | achieve different effects: | - | ||||||||||||||||||||||||||||||||||||
856 | - | |||||||||||||||||||||||||||||||||||||
857 | \list | - | ||||||||||||||||||||||||||||||||||||
858 | \li The left widget has no additional properties or widget attributes | - | ||||||||||||||||||||||||||||||||||||
859 | set. This default state suits most custom widgets using | - | ||||||||||||||||||||||||||||||||||||
860 | transparency, are irregularly-shaped, or do not paint over their | - | ||||||||||||||||||||||||||||||||||||
861 | entire area with an opaque brush. | - | ||||||||||||||||||||||||||||||||||||
862 | \li The center widget has the \l autoFillBackground property set. This | - | ||||||||||||||||||||||||||||||||||||
863 | property is used with custom widgets that rely on the widget to | - | ||||||||||||||||||||||||||||||||||||
864 | supply a default background, and do not paint over their entire | - | ||||||||||||||||||||||||||||||||||||
865 | area with an opaque brush. | - | ||||||||||||||||||||||||||||||||||||
866 | \li The right widget has the Qt::WA_OpaquePaintEvent widget attribute | - | ||||||||||||||||||||||||||||||||||||
867 | set. This indicates that the widget will paint over its entire area | - | ||||||||||||||||||||||||||||||||||||
868 | with opaque colors. The widget's area will initially be | - | ||||||||||||||||||||||||||||||||||||
869 | \e{uninitialized}, represented in the diagram with a red diagonal | - | ||||||||||||||||||||||||||||||||||||
870 | grid pattern that shines through the overpainted area. The | - | ||||||||||||||||||||||||||||||||||||
871 | Qt::WA_OpaquePaintArea attribute is useful for widgets that need to | - | ||||||||||||||||||||||||||||||||||||
872 | paint their own specialized contents quickly and do not need a | - | ||||||||||||||||||||||||||||||||||||
873 | default filled background. | - | ||||||||||||||||||||||||||||||||||||
874 | \endlist | - | ||||||||||||||||||||||||||||||||||||
875 | - | |||||||||||||||||||||||||||||||||||||
876 | To rapidly update custom widgets with simple background colors, such as | - | ||||||||||||||||||||||||||||||||||||
877 | real-time plotting or graphing widgets, it is better to define a suitable | - | ||||||||||||||||||||||||||||||||||||
878 | background color (using setBackgroundRole() with the | - | ||||||||||||||||||||||||||||||||||||
879 | QPalette::Window role), set the \l autoFillBackground property, and only | - | ||||||||||||||||||||||||||||||||||||
880 | implement the necessary drawing functionality in the widget's paintEvent(). | - | ||||||||||||||||||||||||||||||||||||
881 | - | |||||||||||||||||||||||||||||||||||||
882 | To rapidly update custom widgets that constantly paint over their entire | - | ||||||||||||||||||||||||||||||||||||
883 | areas with opaque content, e.g., video streaming widgets, it is better to | - | ||||||||||||||||||||||||||||||||||||
884 | set the widget's Qt::WA_OpaquePaintEvent, avoiding any unnecessary overhead | - | ||||||||||||||||||||||||||||||||||||
885 | associated with repainting the widget's background. | - | ||||||||||||||||||||||||||||||||||||
886 | - | |||||||||||||||||||||||||||||||||||||
887 | If a widget has both the Qt::WA_OpaquePaintEvent widget attribute \e{and} | - | ||||||||||||||||||||||||||||||||||||
888 | the \l autoFillBackground property set, the Qt::WA_OpaquePaintEvent | - | ||||||||||||||||||||||||||||||||||||
889 | attribute takes precedence. Depending on your requirements, you should | - | ||||||||||||||||||||||||||||||||||||
890 | choose either one of them. | - | ||||||||||||||||||||||||||||||||||||
891 | - | |||||||||||||||||||||||||||||||||||||
892 | Since Qt 4.1, the contents of parent widgets are also propagated to | - | ||||||||||||||||||||||||||||||||||||
893 | standard Qt widgets. This can lead to some unexpected results if the | - | ||||||||||||||||||||||||||||||||||||
894 | parent widget is decorated in a non-standard way, as shown in the diagram | - | ||||||||||||||||||||||||||||||||||||
895 | below. | - | ||||||||||||||||||||||||||||||||||||
896 | - | |||||||||||||||||||||||||||||||||||||
897 | \image propagation-standard.png | - | ||||||||||||||||||||||||||||||||||||
898 | - | |||||||||||||||||||||||||||||||||||||
899 | The scope for customizing the painting behavior of standard Qt widgets, | - | ||||||||||||||||||||||||||||||||||||
900 | without resorting to subclassing, is slightly less than that possible for | - | ||||||||||||||||||||||||||||||||||||
901 | custom widgets. Usually, the desired appearance of a standard widget can be | - | ||||||||||||||||||||||||||||||||||||
902 | achieved by setting its \l autoFillBackground property. | - | ||||||||||||||||||||||||||||||||||||
903 | - | |||||||||||||||||||||||||||||||||||||
904 | - | |||||||||||||||||||||||||||||||||||||
905 | \section1 Creating Translucent Windows | - | ||||||||||||||||||||||||||||||||||||
906 | - | |||||||||||||||||||||||||||||||||||||
907 | Since Qt 4.5, it has been possible to create windows with translucent regions | - | ||||||||||||||||||||||||||||||||||||
908 | on window systems that support compositing. | - | ||||||||||||||||||||||||||||||||||||
909 | - | |||||||||||||||||||||||||||||||||||||
910 | To enable this feature in a top-level widget, set its Qt::WA_TranslucentBackground | - | ||||||||||||||||||||||||||||||||||||
911 | attribute with setAttribute() and ensure that its background is painted with | - | ||||||||||||||||||||||||||||||||||||
912 | non-opaque colors in the regions you want to be partially transparent. | - | ||||||||||||||||||||||||||||||||||||
913 | - | |||||||||||||||||||||||||||||||||||||
914 | Platform notes: | - | ||||||||||||||||||||||||||||||||||||
915 | - | |||||||||||||||||||||||||||||||||||||
916 | \list | - | ||||||||||||||||||||||||||||||||||||
917 | \li X11: This feature relies on the use of an X server that supports ARGB visuals | - | ||||||||||||||||||||||||||||||||||||
918 | and a compositing window manager. | - | ||||||||||||||||||||||||||||||||||||
919 | \li Windows: The widget needs to have the Qt::FramelessWindowHint window flag set | - | ||||||||||||||||||||||||||||||||||||
920 | for the translucency to work. | - | ||||||||||||||||||||||||||||||||||||
921 | \endlist | - | ||||||||||||||||||||||||||||||||||||
922 | - | |||||||||||||||||||||||||||||||||||||
923 | - | |||||||||||||||||||||||||||||||||||||
924 | \section1 Native Widgets vs Alien Widgets | - | ||||||||||||||||||||||||||||||||||||
925 | - | |||||||||||||||||||||||||||||||||||||
926 | Introduced in Qt 4.4, alien widgets are widgets unknown to the windowing | - | ||||||||||||||||||||||||||||||||||||
927 | system. They do not have a native window handle associated with them. This | - | ||||||||||||||||||||||||||||||||||||
928 | feature significantly speeds up widget painting, resizing, and removes flicker. | - | ||||||||||||||||||||||||||||||||||||
929 | - | |||||||||||||||||||||||||||||||||||||
930 | Should you require the old behavior with native windows, you can choose | - | ||||||||||||||||||||||||||||||||||||
931 | one of the following options: | - | ||||||||||||||||||||||||||||||||||||
932 | - | |||||||||||||||||||||||||||||||||||||
933 | \list 1 | - | ||||||||||||||||||||||||||||||||||||
934 | \li Use the \c{QT_USE_NATIVE_WINDOWS=1} in your environment. | - | ||||||||||||||||||||||||||||||||||||
935 | \li Set the Qt::AA_NativeWindows attribute on your application. All | - | ||||||||||||||||||||||||||||||||||||
936 | widgets will be native widgets. | - | ||||||||||||||||||||||||||||||||||||
937 | \li Set the Qt::WA_NativeWindow attribute on widgets: The widget itself | - | ||||||||||||||||||||||||||||||||||||
938 | and all of its ancestors will become native (unless | - | ||||||||||||||||||||||||||||||||||||
939 | Qt::WA_DontCreateNativeAncestors is set). | - | ||||||||||||||||||||||||||||||||||||
940 | \li Call QWidget::winId to enforce a native window (this implies 3). | - | ||||||||||||||||||||||||||||||||||||
941 | \li Set the Qt::WA_PaintOnScreen attribute to enforce a native window | - | ||||||||||||||||||||||||||||||||||||
942 | (this implies 3). | - | ||||||||||||||||||||||||||||||||||||
943 | \endlist | - | ||||||||||||||||||||||||||||||||||||
944 | - | |||||||||||||||||||||||||||||||||||||
945 | \sa QEvent, QPainter, QGridLayout, QBoxLayout | - | ||||||||||||||||||||||||||||||||||||
946 | - | |||||||||||||||||||||||||||||||||||||
947 | */ | - | ||||||||||||||||||||||||||||||||||||
948 | - | |||||||||||||||||||||||||||||||||||||
949 | QWidgetMapper *QWidgetPrivate::mapper = 0; // widget with wid | - | ||||||||||||||||||||||||||||||||||||
950 | QWidgetSet *QWidgetPrivate::allWidgets = 0; // widgets with no wid | - | ||||||||||||||||||||||||||||||||||||
951 | - | |||||||||||||||||||||||||||||||||||||
952 | - | |||||||||||||||||||||||||||||||||||||
953 | /***************************************************************************** | - | ||||||||||||||||||||||||||||||||||||
954 | QWidget utility functions | - | ||||||||||||||||||||||||||||||||||||
955 | *****************************************************************************/ | - | ||||||||||||||||||||||||||||||||||||
956 | - | |||||||||||||||||||||||||||||||||||||
957 | QRegion qt_dirtyRegion(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
958 | { | - | ||||||||||||||||||||||||||||||||||||
959 | if (!widget)
| 0 | ||||||||||||||||||||||||||||||||||||
960 | return QRegion(); never executed: return QRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
961 | - | |||||||||||||||||||||||||||||||||||||
962 | QWidgetBackingStore *bs = qt_widget_private(widget)->maybeBackingStore(); | - | ||||||||||||||||||||||||||||||||||||
963 | if (!bs)
| 0 | ||||||||||||||||||||||||||||||||||||
964 | return QRegion(); never executed: return QRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
965 | - | |||||||||||||||||||||||||||||||||||||
966 | return bs->dirtyRegion(widget); never executed: return bs->dirtyRegion(widget); | 0 | ||||||||||||||||||||||||||||||||||||
967 | } | - | ||||||||||||||||||||||||||||||||||||
968 | - | |||||||||||||||||||||||||||||||||||||
969 | /***************************************************************************** | - | ||||||||||||||||||||||||||||||||||||
970 | QWidget member functions | - | ||||||||||||||||||||||||||||||||||||
971 | *****************************************************************************/ | - | ||||||||||||||||||||||||||||||||||||
972 | - | |||||||||||||||||||||||||||||||||||||
973 | /* | - | ||||||||||||||||||||||||||||||||||||
974 | Widget state flags: | - | ||||||||||||||||||||||||||||||||||||
975 | \list | - | ||||||||||||||||||||||||||||||||||||
976 | \li Qt::WA_WState_Created The widget has a valid winId(). | - | ||||||||||||||||||||||||||||||||||||
977 | \li Qt::WA_WState_Visible The widget is currently visible. | - | ||||||||||||||||||||||||||||||||||||
978 | \li Qt::WA_WState_Hidden The widget is hidden, i.e. it won't | - | ||||||||||||||||||||||||||||||||||||
979 | become visible unless you call show() on it. Qt::WA_WState_Hidden | - | ||||||||||||||||||||||||||||||||||||
980 | implies !Qt::WA_WState_Visible. | - | ||||||||||||||||||||||||||||||||||||
981 | \li Qt::WA_WState_CompressKeys Compress keyboard events. | - | ||||||||||||||||||||||||||||||||||||
982 | \li Qt::WA_WState_BlockUpdates Repaints and updates are disabled. | - | ||||||||||||||||||||||||||||||||||||
983 | \li Qt::WA_WState_InPaintEvent Currently processing a paint event. | - | ||||||||||||||||||||||||||||||||||||
984 | \li Qt::WA_WState_Reparented The widget has been reparented. | - | ||||||||||||||||||||||||||||||||||||
985 | \li Qt::WA_WState_ConfigPending A configuration (resize/move) event is pending. | - | ||||||||||||||||||||||||||||||||||||
986 | \li Qt::WA_WState_DND (Deprecated) The widget supports drag and drop, see setAcceptDrops(). | - | ||||||||||||||||||||||||||||||||||||
987 | \endlist | - | ||||||||||||||||||||||||||||||||||||
988 | */ | - | ||||||||||||||||||||||||||||||||||||
989 | - | |||||||||||||||||||||||||||||||||||||
990 | struct QWidgetExceptionCleaner | - | ||||||||||||||||||||||||||||||||||||
991 | { | - | ||||||||||||||||||||||||||||||||||||
992 | /* this cleans up when the constructor throws an exception */ | - | ||||||||||||||||||||||||||||||||||||
993 | static inline void cleanup(QWidget *that, QWidgetPrivate *d) | - | ||||||||||||||||||||||||||||||||||||
994 | { | - | ||||||||||||||||||||||||||||||||||||
995 | #ifdef QT_NO_EXCEPTIONS | - | ||||||||||||||||||||||||||||||||||||
996 | Q_UNUSED(that); | - | ||||||||||||||||||||||||||||||||||||
997 | Q_UNUSED(d); | - | ||||||||||||||||||||||||||||||||||||
998 | #else | - | ||||||||||||||||||||||||||||||||||||
999 | QWidgetPrivate::allWidgets->remove(that); | - | ||||||||||||||||||||||||||||||||||||
1000 | if (d->focus_next != that) { | - | ||||||||||||||||||||||||||||||||||||
1001 | if (d->focus_next) | - | ||||||||||||||||||||||||||||||||||||
1002 | d->focus_next->d_func()->focus_prev = d->focus_prev; | - | ||||||||||||||||||||||||||||||||||||
1003 | if (d->focus_prev) | - | ||||||||||||||||||||||||||||||||||||
1004 | d->focus_prev->d_func()->focus_next = d->focus_next; | - | ||||||||||||||||||||||||||||||||||||
1005 | } | - | ||||||||||||||||||||||||||||||||||||
1006 | #endif | - | ||||||||||||||||||||||||||||||||||||
1007 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1008 | }; | - | ||||||||||||||||||||||||||||||||||||
1009 | - | |||||||||||||||||||||||||||||||||||||
1010 | /*! | - | ||||||||||||||||||||||||||||||||||||
1011 | Constructs a widget which is a child of \a parent, with widget | - | ||||||||||||||||||||||||||||||||||||
1012 | flags set to \a f. | - | ||||||||||||||||||||||||||||||||||||
1013 | - | |||||||||||||||||||||||||||||||||||||
1014 | If \a parent is 0, the new widget becomes a window. If | - | ||||||||||||||||||||||||||||||||||||
1015 | \a parent is another widget, this widget becomes a child window | - | ||||||||||||||||||||||||||||||||||||
1016 | inside \a parent. The new widget is deleted when its \a parent is | - | ||||||||||||||||||||||||||||||||||||
1017 | deleted. | - | ||||||||||||||||||||||||||||||||||||
1018 | - | |||||||||||||||||||||||||||||||||||||
1019 | The widget flags argument, \a f, is normally 0, but it can be set | - | ||||||||||||||||||||||||||||||||||||
1020 | to customize the frame of a window (i.e. \a | - | ||||||||||||||||||||||||||||||||||||
1021 | parent must be 0). To customize the frame, use a value composed | - | ||||||||||||||||||||||||||||||||||||
1022 | from the bitwise OR of any of the \l{Qt::WindowFlags}{window flags}. | - | ||||||||||||||||||||||||||||||||||||
1023 | - | |||||||||||||||||||||||||||||||||||||
1024 | If you add a child widget to an already visible widget you must | - | ||||||||||||||||||||||||||||||||||||
1025 | explicitly show the child to make it visible. | - | ||||||||||||||||||||||||||||||||||||
1026 | - | |||||||||||||||||||||||||||||||||||||
1027 | Note that the X11 version of Qt may not be able to deliver all | - | ||||||||||||||||||||||||||||||||||||
1028 | combinations of style flags on all systems. This is because on | - | ||||||||||||||||||||||||||||||||||||
1029 | X11, Qt can only ask the window manager, and the window manager | - | ||||||||||||||||||||||||||||||||||||
1030 | can override the application's settings. On Windows, Qt can set | - | ||||||||||||||||||||||||||||||||||||
1031 | whatever flags you want. | - | ||||||||||||||||||||||||||||||||||||
1032 | - | |||||||||||||||||||||||||||||||||||||
1033 | \sa windowFlags | - | ||||||||||||||||||||||||||||||||||||
1034 | */ | - | ||||||||||||||||||||||||||||||||||||
1035 | QWidget::QWidget(QWidget *parent, Qt::WindowFlags f) | - | ||||||||||||||||||||||||||||||||||||
1036 | : QObject(*new QWidgetPrivate, 0), QPaintDevice() | - | ||||||||||||||||||||||||||||||||||||
1037 | { | - | ||||||||||||||||||||||||||||||||||||
1038 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1039 | d_func()->init(parent, f); | - | ||||||||||||||||||||||||||||||||||||
1040 | } QT_CATCH(...) { never executed: end of block dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1041 | QWidgetExceptionCleaner::cleanup(this, d_func()); dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1042 | QT_RETHROW; dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1043 | } dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1044 | } | - | ||||||||||||||||||||||||||||||||||||
1045 | - | |||||||||||||||||||||||||||||||||||||
1046 | - | |||||||||||||||||||||||||||||||||||||
1047 | /*! \internal | - | ||||||||||||||||||||||||||||||||||||
1048 | */ | - | ||||||||||||||||||||||||||||||||||||
1049 | QWidget::QWidget(QWidgetPrivate &dd, QWidget* parent, Qt::WindowFlags f) | - | ||||||||||||||||||||||||||||||||||||
1050 | : QObject(dd, 0), QPaintDevice() | - | ||||||||||||||||||||||||||||||||||||
1051 | { | - | ||||||||||||||||||||||||||||||||||||
1052 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1053 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1054 | d->init(parent, f); | - | ||||||||||||||||||||||||||||||||||||
1055 | } QT_CATCH(...) { never executed: end of block dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1056 | QWidgetExceptionCleaner::cleanup(this, d_func()); dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1057 | QT_RETHROW; dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1058 | } dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1059 | } | - | ||||||||||||||||||||||||||||||||||||
1060 | - | |||||||||||||||||||||||||||||||||||||
1061 | /*! | - | ||||||||||||||||||||||||||||||||||||
1062 | \internal | - | ||||||||||||||||||||||||||||||||||||
1063 | */ | - | ||||||||||||||||||||||||||||||||||||
1064 | int QWidget::devType() const | - | ||||||||||||||||||||||||||||||||||||
1065 | { | - | ||||||||||||||||||||||||||||||||||||
1066 | return QInternal::Widget; never executed: return QInternal::Widget; | 0 | ||||||||||||||||||||||||||||||||||||
1067 | } | - | ||||||||||||||||||||||||||||||||||||
1068 | - | |||||||||||||||||||||||||||||||||||||
1069 | - | |||||||||||||||||||||||||||||||||||||
1070 | //### w is a "this" ptr, passed as a param because QWorkspace needs special logic | - | ||||||||||||||||||||||||||||||||||||
1071 | void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
1072 | { | - | ||||||||||||||||||||||||||||||||||||
1073 | bool customize = (flags & (Qt::CustomizeWindowHint | - | ||||||||||||||||||||||||||||||||||||
1074 | | Qt::FramelessWindowHint | - | ||||||||||||||||||||||||||||||||||||
1075 | | Qt::WindowTitleHint | - | ||||||||||||||||||||||||||||||||||||
1076 | | Qt::WindowSystemMenuHint | - | ||||||||||||||||||||||||||||||||||||
1077 | | Qt::WindowMinimizeButtonHint | - | ||||||||||||||||||||||||||||||||||||
1078 | | Qt::WindowMaximizeButtonHint | - | ||||||||||||||||||||||||||||||||||||
1079 | | Qt::WindowCloseButtonHint | - | ||||||||||||||||||||||||||||||||||||
1080 | | Qt::WindowContextHelpButtonHint)); | - | ||||||||||||||||||||||||||||||||||||
1081 | - | |||||||||||||||||||||||||||||||||||||
1082 | uint type = (flags & Qt::WindowType_Mask); | - | ||||||||||||||||||||||||||||||||||||
1083 | - | |||||||||||||||||||||||||||||||||||||
1084 | if ((type == Qt::Widget || type == Qt::SubWindow) && w && !w->parent()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1085 | type = Qt::Window; | - | ||||||||||||||||||||||||||||||||||||
1086 | flags |= Qt::Window; | - | ||||||||||||||||||||||||||||||||||||
1087 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1088 | - | |||||||||||||||||||||||||||||||||||||
1089 | if (flags & Qt::CustomizeWindowHint) {
| 0 | ||||||||||||||||||||||||||||||||||||
1090 | // modify window flags to make them consistent. | - | ||||||||||||||||||||||||||||||||||||
1091 | // Only enable this on non-Mac platforms. Since the old way of doing this would | - | ||||||||||||||||||||||||||||||||||||
1092 | // interpret WindowSystemMenuHint as a close button and we can't change that behavior | - | ||||||||||||||||||||||||||||||||||||
1093 | // we can't just add this in. | - | ||||||||||||||||||||||||||||||||||||
1094 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1095 | if ((flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowContextHelpButtonHint))
| 0 | ||||||||||||||||||||||||||||||||||||
1096 | # ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
1097 | && type != Qt::Dialog // QTBUG-2027, allow for menu-less dialogs. | - | ||||||||||||||||||||||||||||||||||||
1098 | # endif | - | ||||||||||||||||||||||||||||||||||||
1099 | ) { | - | ||||||||||||||||||||||||||||||||||||
1100 | flags |= Qt::WindowSystemMenuHint; | - | ||||||||||||||||||||||||||||||||||||
1101 | #else | - | ||||||||||||||||||||||||||||||||||||
1102 | if (flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | - | ||||||||||||||||||||||||||||||||||||
1103 | | Qt::WindowSystemMenuHint)) { | - | ||||||||||||||||||||||||||||||||||||
1104 | #endif | - | ||||||||||||||||||||||||||||||||||||
1105 | flags |= Qt::WindowTitleHint; | - | ||||||||||||||||||||||||||||||||||||
1106 | flags &= ~Qt::FramelessWindowHint; | - | ||||||||||||||||||||||||||||||||||||
1107 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1108 | } else if (customize && !(flags & Qt::FramelessWindowHint)) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
1109 | // if any of the window hints that affect the titlebar are set | - | ||||||||||||||||||||||||||||||||||||
1110 | // and the window is supposed to have frame, we add a titlebar | - | ||||||||||||||||||||||||||||||||||||
1111 | // and system menu by default. | - | ||||||||||||||||||||||||||||||||||||
1112 | flags |= Qt::WindowSystemMenuHint; | - | ||||||||||||||||||||||||||||||||||||
1113 | flags |= Qt::WindowTitleHint; | - | ||||||||||||||||||||||||||||||||||||
1114 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1115 | if (customize)
| 0 | ||||||||||||||||||||||||||||||||||||
1116 | ; // don't modify window flags if the user explicitly set them. never executed: ; | 0 | ||||||||||||||||||||||||||||||||||||
1117 | else if (type == Qt::Dialog || type == Qt::Sheet)
| 0 | ||||||||||||||||||||||||||||||||||||
1118 | #ifndef Q_OS_WINCE | - | ||||||||||||||||||||||||||||||||||||
1119 | flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint; never executed: flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint; | 0 | ||||||||||||||||||||||||||||||||||||
1120 | #else | - | ||||||||||||||||||||||||||||||||||||
1121 | flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; | - | ||||||||||||||||||||||||||||||||||||
1122 | #endif | - | ||||||||||||||||||||||||||||||||||||
1123 | else if (type == Qt::Tool)
| 0 | ||||||||||||||||||||||||||||||||||||
1124 | flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; never executed: flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; | 0 | ||||||||||||||||||||||||||||||||||||
1125 | else | - | ||||||||||||||||||||||||||||||||||||
1126 | flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | never executed: flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint; | 0 | ||||||||||||||||||||||||||||||||||||
1127 | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint; never executed: flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint; | 0 | ||||||||||||||||||||||||||||||||||||
1128 | if (w->testAttribute(Qt::WA_TransparentForMouseEvents))
| 0 | ||||||||||||||||||||||||||||||||||||
1129 | flags |= Qt::WindowTransparentForInput; never executed: flags |= Qt::WindowTransparentForInput; | 0 | ||||||||||||||||||||||||||||||||||||
1130 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1131 | - | |||||||||||||||||||||||||||||||||||||
1132 | void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) | - | ||||||||||||||||||||||||||||||||||||
1133 | { | - | ||||||||||||||||||||||||||||||||||||
1134 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1135 | if (Q_UNLIKELY(!qobject_cast<QApplication *>(QCoreApplication::instance())))
| 0 | ||||||||||||||||||||||||||||||||||||
1136 | qFatal("QWidget: Cannot create a QWidget without QApplication"); never executed: QMessageLogger(__FILE__, 1136, __PRETTY_FUNCTION__).fatal("QWidget: Cannot create a QWidget without QApplication"); | 0 | ||||||||||||||||||||||||||||||||||||
1137 | - | |||||||||||||||||||||||||||||||||||||
1138 | Q_ASSERT(allWidgets); | - | ||||||||||||||||||||||||||||||||||||
1139 | if (allWidgets)
| 0 | ||||||||||||||||||||||||||||||||||||
1140 | allWidgets->insert(q); never executed: allWidgets->insert(q); | 0 | ||||||||||||||||||||||||||||||||||||
1141 | - | |||||||||||||||||||||||||||||||||||||
1142 | int targetScreen = -1; | - | ||||||||||||||||||||||||||||||||||||
1143 | if (parentWidget && parentWidget->windowType() == Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
1144 | const QDesktopScreenWidget *sw = qobject_cast<const QDesktopScreenWidget *>(parentWidget); | - | ||||||||||||||||||||||||||||||||||||
1145 | targetScreen = sw ? sw->screenNumber() : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
1146 | parentWidget = 0; | - | ||||||||||||||||||||||||||||||||||||
1147 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1148 | - | |||||||||||||||||||||||||||||||||||||
1149 | q->data = &data; | - | ||||||||||||||||||||||||||||||||||||
1150 | - | |||||||||||||||||||||||||||||||||||||
1151 | #ifndef QT_NO_THREAD | - | ||||||||||||||||||||||||||||||||||||
1152 | if (!parent) {
| 0 | ||||||||||||||||||||||||||||||||||||
1153 | Q_ASSERT_X(q->thread() == qApp->thread(), "QWidget", | - | ||||||||||||||||||||||||||||||||||||
1154 | "Widgets must be created in the GUI thread."); | - | ||||||||||||||||||||||||||||||||||||
1155 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1156 | #endif | - | ||||||||||||||||||||||||||||||||||||
1157 | - | |||||||||||||||||||||||||||||||||||||
1158 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
1159 | if (desktopWidget) { | - | ||||||||||||||||||||||||||||||||||||
1160 | // make sure the widget is created on the same screen as the | - | ||||||||||||||||||||||||||||||||||||
1161 | // programmer specified desktop widget | - | ||||||||||||||||||||||||||||||||||||
1162 | xinfo = desktopWidget->d_func()->xinfo; | - | ||||||||||||||||||||||||||||||||||||
1163 | } | - | ||||||||||||||||||||||||||||||||||||
1164 | #endif | - | ||||||||||||||||||||||||||||||||||||
1165 | if (targetScreen >= 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
1166 | topData()->initialScreenIndex = targetScreen; | - | ||||||||||||||||||||||||||||||||||||
1167 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
1168 | window->setScreen(QGuiApplication::screens().value(targetScreen, Q_NULLPTR)); never executed: window->setScreen(QGuiApplication::screens().value(targetScreen, nullptr)); | 0 | ||||||||||||||||||||||||||||||||||||
1169 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1170 | - | |||||||||||||||||||||||||||||||||||||
1171 | data.fstrut_dirty = true; | - | ||||||||||||||||||||||||||||||||||||
1172 | - | |||||||||||||||||||||||||||||||||||||
1173 | data.winid = 0; | - | ||||||||||||||||||||||||||||||||||||
1174 | data.widget_attributes = 0; | - | ||||||||||||||||||||||||||||||||||||
1175 | data.window_flags = f; | - | ||||||||||||||||||||||||||||||||||||
1176 | data.window_state = 0; | - | ||||||||||||||||||||||||||||||||||||
1177 | data.focus_policy = 0; | - | ||||||||||||||||||||||||||||||||||||
1178 | data.context_menu_policy = Qt::DefaultContextMenu; | - | ||||||||||||||||||||||||||||||||||||
1179 | data.window_modality = Qt::NonModal; | - | ||||||||||||||||||||||||||||||||||||
1180 | - | |||||||||||||||||||||||||||||||||||||
1181 | data.sizehint_forced = 0; | - | ||||||||||||||||||||||||||||||||||||
1182 | data.is_closing = 0; | - | ||||||||||||||||||||||||||||||||||||
1183 | data.in_show = 0; | - | ||||||||||||||||||||||||||||||||||||
1184 | data.in_set_window_state = 0; | - | ||||||||||||||||||||||||||||||||||||
1185 | data.in_destructor = false; | - | ||||||||||||||||||||||||||||||||||||
1186 | - | |||||||||||||||||||||||||||||||||||||
1187 | // Widgets with Qt::MSWindowsOwnDC (typically QGLWidget) must have a window handle. | - | ||||||||||||||||||||||||||||||||||||
1188 | if (f & Qt::MSWindowsOwnDC) {
| 0 | ||||||||||||||||||||||||||||||||||||
1189 | mustHaveWindowHandle = 1; | - | ||||||||||||||||||||||||||||||||||||
1190 | q->setAttribute(Qt::WA_NativeWindow); | - | ||||||||||||||||||||||||||||||||||||
1191 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1192 | //#ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1193 | // q->setAttribute(Qt::WA_NativeWindow); | - | ||||||||||||||||||||||||||||||||||||
1194 | //#endif | - | ||||||||||||||||||||||||||||||||||||
1195 | - | |||||||||||||||||||||||||||||||||||||
1196 | q->setAttribute(Qt::WA_QuitOnClose); // might be cleared in adjustQuitOnCloseAttribute() | - | ||||||||||||||||||||||||||||||||||||
1197 | adjustQuitOnCloseAttribute(); | - | ||||||||||||||||||||||||||||||||||||
1198 | - | |||||||||||||||||||||||||||||||||||||
1199 | q->setAttribute(Qt::WA_WState_Hidden); | - | ||||||||||||||||||||||||||||||||||||
1200 | - | |||||||||||||||||||||||||||||||||||||
1201 | //give potential windows a bigger "pre-initial" size; create_sys() will give them a new size later | - | ||||||||||||||||||||||||||||||||||||
1202 | data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480);
| 0 | ||||||||||||||||||||||||||||||||||||
1203 | focus_next = focus_prev = q; | - | ||||||||||||||||||||||||||||||||||||
1204 | - | |||||||||||||||||||||||||||||||||||||
1205 | if ((f & Qt::WindowType_Mask) == Qt::Desktop)
| 0 | ||||||||||||||||||||||||||||||||||||
1206 | q->create(); never executed: q->create(); | 0 | ||||||||||||||||||||||||||||||||||||
1207 | else if (parentWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
1208 | q->setParent(parentWidget, data.window_flags); never executed: q->setParent(parentWidget, data.window_flags); | 0 | ||||||||||||||||||||||||||||||||||||
1209 | else { | - | ||||||||||||||||||||||||||||||||||||
1210 | adjustFlags(data.window_flags, q); | - | ||||||||||||||||||||||||||||||||||||
1211 | resolveLayoutDirection(); | - | ||||||||||||||||||||||||||||||||||||
1212 | // opaque system background? | - | ||||||||||||||||||||||||||||||||||||
1213 | const QBrush &background = q->palette().brush(QPalette::Window); | - | ||||||||||||||||||||||||||||||||||||
1214 | setOpaque(q->isWindow() && background.style() != Qt::NoBrush && background.isOpaque()); | - | ||||||||||||||||||||||||||||||||||||
1215 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1216 | data.fnt = QFont(data.fnt, q); | - | ||||||||||||||||||||||||||||||||||||
1217 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
1218 | data.fnt.x11SetScreen(xinfo.screen()); | - | ||||||||||||||||||||||||||||||||||||
1219 | #endif // Q_DEAD_CODE_FROM_QT4_X11 | - | ||||||||||||||||||||||||||||||||||||
1220 | - | |||||||||||||||||||||||||||||||||||||
1221 | q->setAttribute(Qt::WA_PendingMoveEvent); | - | ||||||||||||||||||||||||||||||||||||
1222 | q->setAttribute(Qt::WA_PendingResizeEvent); | - | ||||||||||||||||||||||||||||||||||||
1223 | - | |||||||||||||||||||||||||||||||||||||
1224 | if (++QWidgetPrivate::instanceCounter > QWidgetPrivate::maxInstances)
| 0 | ||||||||||||||||||||||||||||||||||||
1225 | QWidgetPrivate::maxInstances = QWidgetPrivate::instanceCounter; never executed: QWidgetPrivate::maxInstances = QWidgetPrivate::instanceCounter; | 0 | ||||||||||||||||||||||||||||||||||||
1226 | - | |||||||||||||||||||||||||||||||||||||
1227 | if (QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation)) // ### fixme: Qt 6: Remove AA_ImmediateWidgetCreation.
| 0 | ||||||||||||||||||||||||||||||||||||
1228 | q->create(); never executed: q->create(); | 0 | ||||||||||||||||||||||||||||||||||||
1229 | - | |||||||||||||||||||||||||||||||||||||
1230 | QEvent e(QEvent::Create); | - | ||||||||||||||||||||||||||||||||||||
1231 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
1232 | QApplication::postEvent(q, new QEvent(QEvent::PolishRequest)); | - | ||||||||||||||||||||||||||||||||||||
1233 | - | |||||||||||||||||||||||||||||||||||||
1234 | extraPaintEngine = 0; | - | ||||||||||||||||||||||||||||||||||||
1235 | - | |||||||||||||||||||||||||||||||||||||
1236 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1237 | // If we add a child to the unified toolbar, we have to redirect the painting. | - | ||||||||||||||||||||||||||||||||||||
1238 | if (parentWidget && parentWidget->d_func() && parentWidget->d_func()->isInUnifiedToolbar) { | - | ||||||||||||||||||||||||||||||||||||
1239 | if (parentWidget->d_func()->unifiedSurface) { | - | ||||||||||||||||||||||||||||||||||||
1240 | QWidget *toolbar = parentWidget->d_func()->toolbar_ancestor; | - | ||||||||||||||||||||||||||||||||||||
1241 | parentWidget->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset); | - | ||||||||||||||||||||||||||||||||||||
1242 | } | - | ||||||||||||||||||||||||||||||||||||
1243 | } | - | ||||||||||||||||||||||||||||||||||||
1244 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1245 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1246 | - | |||||||||||||||||||||||||||||||||||||
1247 | - | |||||||||||||||||||||||||||||||||||||
1248 | - | |||||||||||||||||||||||||||||||||||||
1249 | void QWidgetPrivate::createRecursively() | - | ||||||||||||||||||||||||||||||||||||
1250 | { | - | ||||||||||||||||||||||||||||||||||||
1251 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1252 | q->create(0, true, true); | - | ||||||||||||||||||||||||||||||||||||
1253 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
1254 | QWidget *child = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
1255 | if (child && !child->isHidden() && !child->isWindow() && !child->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
1256 | child->d_func()->createRecursively(); never executed: child->d_func()->createRecursively(); | 0 | ||||||||||||||||||||||||||||||||||||
1257 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1258 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1259 | - | |||||||||||||||||||||||||||||||||||||
1260 | - | |||||||||||||||||||||||||||||||||||||
1261 | // ### fixme: Qt 6: Remove parameter window from QWidget::create() | - | ||||||||||||||||||||||||||||||||||||
1262 | - | |||||||||||||||||||||||||||||||||||||
1263 | /*! | - | ||||||||||||||||||||||||||||||||||||
1264 | Creates a new widget window. | - | ||||||||||||||||||||||||||||||||||||
1265 | - | |||||||||||||||||||||||||||||||||||||
1266 | The parameter \a window is ignored in Qt 5. Please use | - | ||||||||||||||||||||||||||||||||||||
1267 | QWindow::fromWinId() to create a QWindow wrapping a foreign | - | ||||||||||||||||||||||||||||||||||||
1268 | window and pass it to QWidget::createWindowContainer() instead. | - | ||||||||||||||||||||||||||||||||||||
1269 | - | |||||||||||||||||||||||||||||||||||||
1270 | Initializes the window (sets the geometry etc.) if \a | - | ||||||||||||||||||||||||||||||||||||
1271 | initializeWindow is true. If \a initializeWindow is false, no | - | ||||||||||||||||||||||||||||||||||||
1272 | initialization is performed. This parameter only makes sense if \a | - | ||||||||||||||||||||||||||||||||||||
1273 | window is a valid window. | - | ||||||||||||||||||||||||||||||||||||
1274 | - | |||||||||||||||||||||||||||||||||||||
1275 | Destroys the old window if \a destroyOldWindow is true. If \a | - | ||||||||||||||||||||||||||||||||||||
1276 | destroyOldWindow is false, you are responsible for destroying the | - | ||||||||||||||||||||||||||||||||||||
1277 | window yourself (using platform native code). | - | ||||||||||||||||||||||||||||||||||||
1278 | - | |||||||||||||||||||||||||||||||||||||
1279 | The QWidget constructor calls create(0,true,true) to create a | - | ||||||||||||||||||||||||||||||||||||
1280 | window for this widget. | - | ||||||||||||||||||||||||||||||||||||
1281 | - | |||||||||||||||||||||||||||||||||||||
1282 | \sa createWindowContainer(), QWindow::fromWinId() | - | ||||||||||||||||||||||||||||||||||||
1283 | */ | - | ||||||||||||||||||||||||||||||||||||
1284 | - | |||||||||||||||||||||||||||||||||||||
1285 | void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) | - | ||||||||||||||||||||||||||||||||||||
1286 | { | - | ||||||||||||||||||||||||||||||||||||
1287 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1288 | if (Q_UNLIKELY(window))
| 0 | ||||||||||||||||||||||||||||||||||||
1289 | qWarning("QWidget::create(): Parameter 'window' does not have any effect."); never executed: QMessageLogger(__FILE__, 1289, __PRETTY_FUNCTION__).warning("QWidget::create(): Parameter 'window' does not have any effect."); | 0 | ||||||||||||||||||||||||||||||||||||
1290 | if (testAttribute(Qt::WA_WState_Created) && window == 0 && internalWinId())
| 0 | ||||||||||||||||||||||||||||||||||||
1291 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
1292 | - | |||||||||||||||||||||||||||||||||||||
1293 | if (d->data.in_destructor)
| 0 | ||||||||||||||||||||||||||||||||||||
1294 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
1295 | - | |||||||||||||||||||||||||||||||||||||
1296 | Qt::WindowType type = windowType(); | - | ||||||||||||||||||||||||||||||||||||
1297 | Qt::WindowFlags &flags = data->window_flags; | - | ||||||||||||||||||||||||||||||||||||
1298 | - | |||||||||||||||||||||||||||||||||||||
1299 | if ((type == Qt::Widget || type == Qt::SubWindow) && !parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1300 | type = Qt::Window; | - | ||||||||||||||||||||||||||||||||||||
1301 | flags |= Qt::Window; | - | ||||||||||||||||||||||||||||||||||||
1302 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1303 | - | |||||||||||||||||||||||||||||||||||||
1304 | if (QWidget *parent = parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1305 | if (type & Qt::Window) {
| 0 | ||||||||||||||||||||||||||||||||||||
1306 | if (!parent->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
1307 | parent->createWinId(); never executed: parent->createWinId(); | 0 | ||||||||||||||||||||||||||||||||||||
1308 | } else if (testAttribute(Qt::WA_NativeWindow) && !parent->internalWinId() never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
1309 | && !testAttribute(Qt::WA_DontCreateNativeAncestors)) {
| 0 | ||||||||||||||||||||||||||||||||||||
1310 | // We're about to create a native child widget that doesn't have a native parent; | - | ||||||||||||||||||||||||||||||||||||
1311 | // enforce a native handle for the parent unless the Qt::WA_DontCreateNativeAncestors | - | ||||||||||||||||||||||||||||||||||||
1312 | // attribute is set. | - | ||||||||||||||||||||||||||||||||||||
1313 | d->createWinId(); | - | ||||||||||||||||||||||||||||||||||||
1314 | // Nothing more to do. | - | ||||||||||||||||||||||||||||||||||||
1315 | Q_ASSERT(testAttribute(Qt::WA_WState_Created)); | - | ||||||||||||||||||||||||||||||||||||
1316 | Q_ASSERT(internalWinId()); | - | ||||||||||||||||||||||||||||||||||||
1317 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
1318 | } | - | ||||||||||||||||||||||||||||||||||||
1319 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1320 | - | |||||||||||||||||||||||||||||||||||||
1321 | - | |||||||||||||||||||||||||||||||||||||
1322 | static const bool paintOnScreenEnv = qEnvironmentVariableIntValue("QT_ONSCREEN_PAINT") > 0; | - | ||||||||||||||||||||||||||||||||||||
1323 | if (paintOnScreenEnv)
| 0 | ||||||||||||||||||||||||||||||||||||
1324 | setAttribute(Qt::WA_PaintOnScreen); never executed: setAttribute(Qt::WA_PaintOnScreen); | 0 | ||||||||||||||||||||||||||||||||||||
1325 | - | |||||||||||||||||||||||||||||||||||||
1326 | if (QApplicationPrivate::testAttribute(Qt::AA_NativeWindows))
| 0 | ||||||||||||||||||||||||||||||||||||
1327 | setAttribute(Qt::WA_NativeWindow); never executed: setAttribute(Qt::WA_NativeWindow); | 0 | ||||||||||||||||||||||||||||||||||||
1328 | - | |||||||||||||||||||||||||||||||||||||
1329 | #ifdef ALIEN_DEBUG | - | ||||||||||||||||||||||||||||||||||||
1330 | qDebug() << "QWidget::create:" << this << "parent:" << parentWidget() | - | ||||||||||||||||||||||||||||||||||||
1331 | << "Alien?" << !testAttribute(Qt::WA_NativeWindow); | - | ||||||||||||||||||||||||||||||||||||
1332 | #endif | - | ||||||||||||||||||||||||||||||||||||
1333 | - | |||||||||||||||||||||||||||||||||||||
1334 | #if defined (Q_DEAD_CODE_FROM_QT4_WIN) && !defined(QT_NO_DRAGANDDROP) | - | ||||||||||||||||||||||||||||||||||||
1335 | // Unregister the dropsite (if already registered) before we | - | ||||||||||||||||||||||||||||||||||||
1336 | // re-create the widget with a native window. | - | ||||||||||||||||||||||||||||||||||||
1337 | if (testAttribute(Qt::WA_WState_Created) && !internalWinId() && testAttribute(Qt::WA_NativeWindow) | - | ||||||||||||||||||||||||||||||||||||
1338 | && d->extra && d->extra->dropTarget) { | - | ||||||||||||||||||||||||||||||||||||
1339 | d->registerDropSite(false); | - | ||||||||||||||||||||||||||||||||||||
1340 | } | - | ||||||||||||||||||||||||||||||||||||
1341 | #endif // defined (Q_DEAD_CODE_FROM_QT4_WIN) && !defined(QT_NO_DRAGANDDROP) | - | ||||||||||||||||||||||||||||||||||||
1342 | - | |||||||||||||||||||||||||||||||||||||
1343 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
1344 | - | |||||||||||||||||||||||||||||||||||||
1345 | setAttribute(Qt::WA_WState_Created); // set created flag | - | ||||||||||||||||||||||||||||||||||||
1346 | d->create_sys(window, initializeWindow, destroyOldWindow); | - | ||||||||||||||||||||||||||||||||||||
1347 | - | |||||||||||||||||||||||||||||||||||||
1348 | // a real toplevel window needs a backing store | - | ||||||||||||||||||||||||||||||||||||
1349 | if (isWindow() && windowType() != Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
1350 | d->topData()->backingStoreTracker.destroy(); | - | ||||||||||||||||||||||||||||||||||||
1351 | if (hasBackingStoreSupport())
| 0 | ||||||||||||||||||||||||||||||||||||
1352 | d->topData()->backingStoreTracker.create(this); never executed: d->topData()->backingStoreTracker.create(this); | 0 | ||||||||||||||||||||||||||||||||||||
1353 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1354 | - | |||||||||||||||||||||||||||||||||||||
1355 | d->setModal_sys(); | - | ||||||||||||||||||||||||||||||||||||
1356 | - | |||||||||||||||||||||||||||||||||||||
1357 | if (!isWindow() && parentWidget() && parentWidget()->testAttribute(Qt::WA_DropSiteRegistered))
| 0 | ||||||||||||||||||||||||||||||||||||
1358 | setAttribute(Qt::WA_DropSiteRegistered, true); never executed: setAttribute(Qt::WA_DropSiteRegistered, true); | 0 | ||||||||||||||||||||||||||||||||||||
1359 | - | |||||||||||||||||||||||||||||||||||||
1360 | #ifdef QT_EVAL | - | ||||||||||||||||||||||||||||||||||||
1361 | extern void qt_eval_init_widget(QWidget *w); | - | ||||||||||||||||||||||||||||||||||||
1362 | qt_eval_init_widget(this); | - | ||||||||||||||||||||||||||||||||||||
1363 | #endif | - | ||||||||||||||||||||||||||||||||||||
1364 | - | |||||||||||||||||||||||||||||||||||||
1365 | // need to force the resting of the icon after changing parents | - | ||||||||||||||||||||||||||||||||||||
1366 | if (testAttribute(Qt::WA_SetWindowIcon))
| 0 | ||||||||||||||||||||||||||||||||||||
1367 | d->setWindowIcon_sys(); never executed: d->setWindowIcon_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
1368 | - | |||||||||||||||||||||||||||||||||||||
1369 | if (isWindow() && !d->topData()->iconText.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
1370 | d->setWindowIconText_helper(d->topData()->iconText); never executed: d->setWindowIconText_helper(d->topData()->iconText); | 0 | ||||||||||||||||||||||||||||||||||||
1371 | if (isWindow() && !d->topData()->caption.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
1372 | d->setWindowTitle_helper(d->topData()->caption); never executed: d->setWindowTitle_helper(d->topData()->caption); | 0 | ||||||||||||||||||||||||||||||||||||
1373 | if (windowType() != Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
1374 | d->updateSystemBackground(); | - | ||||||||||||||||||||||||||||||||||||
1375 | - | |||||||||||||||||||||||||||||||||||||
1376 | if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon))
| 0 | ||||||||||||||||||||||||||||||||||||
1377 | d->setWindowIcon_sys(); never executed: d->setWindowIcon_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
1378 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1379 | - | |||||||||||||||||||||||||||||||||||||
1380 | // Frame strut update needed in cases where there are native widgets such as QGLWidget, | - | ||||||||||||||||||||||||||||||||||||
1381 | // as those force native window creation on their ancestors before they are shown. | - | ||||||||||||||||||||||||||||||||||||
1382 | // If the strut is not updated, any subsequent move of the top level window before show | - | ||||||||||||||||||||||||||||||||||||
1383 | // will cause window frame to be ignored when positioning the window. | - | ||||||||||||||||||||||||||||||||||||
1384 | // Note that this only helps on platforms that handle window creation synchronously. | - | ||||||||||||||||||||||||||||||||||||
1385 | d->updateFrameStrut(); | - | ||||||||||||||||||||||||||||||||||||
1386 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1387 | - | |||||||||||||||||||||||||||||||||||||
1388 | void q_createNativeChildrenAndSetParent(const QWidget *parentWidget) | - | ||||||||||||||||||||||||||||||||||||
1389 | { | - | ||||||||||||||||||||||||||||||||||||
1390 | QObjectList children = parentWidget->children(); | - | ||||||||||||||||||||||||||||||||||||
1391 | for (int i = 0; i < children.size(); i++) {
| 0 | ||||||||||||||||||||||||||||||||||||
1392 | if (children.at(i)->isWidgetType()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1393 | const QWidget *childWidget = qobject_cast<const QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
1394 | if (childWidget) { // should not be necessary
| 0 | ||||||||||||||||||||||||||||||||||||
1395 | if (childWidget->testAttribute(Qt::WA_NativeWindow)) {
| 0 | ||||||||||||||||||||||||||||||||||||
1396 | if (!childWidget->internalWinId())
| 0 | ||||||||||||||||||||||||||||||||||||
1397 | childWidget->winId(); never executed: childWidget->winId(); | 0 | ||||||||||||||||||||||||||||||||||||
1398 | if (childWidget->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1399 | if (childWidget->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1400 | childWidget->windowHandle()->setTransientParent(parentWidget->window()->windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
1401 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1402 | childWidget->windowHandle()->setParent(childWidget->nativeParentWidget()->windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
1403 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1404 | } | - | ||||||||||||||||||||||||||||||||||||
1405 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1406 | q_createNativeChildrenAndSetParent(childWidget); | - | ||||||||||||||||||||||||||||||||||||
1407 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1408 | } | - | ||||||||||||||||||||||||||||||||||||
1409 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1410 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1411 | - | |||||||||||||||||||||||||||||||||||||
1412 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1413 | - | |||||||||||||||||||||||||||||||||||||
1414 | void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow) | - | ||||||||||||||||||||||||||||||||||||
1415 | { | - | ||||||||||||||||||||||||||||||||||||
1416 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1417 | - | |||||||||||||||||||||||||||||||||||||
1418 | Q_UNUSED(window); | - | ||||||||||||||||||||||||||||||||||||
1419 | Q_UNUSED(initializeWindow); | - | ||||||||||||||||||||||||||||||||||||
1420 | Q_UNUSED(destroyOldWindow); | - | ||||||||||||||||||||||||||||||||||||
1421 | - | |||||||||||||||||||||||||||||||||||||
1422 | Qt::WindowFlags flags = data.window_flags; | - | ||||||||||||||||||||||||||||||||||||
1423 | - | |||||||||||||||||||||||||||||||||||||
1424 | if (!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
1425 | return; // we only care about real toplevels never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
1426 | - | |||||||||||||||||||||||||||||||||||||
1427 | QWindow *win = topData()->window; | - | ||||||||||||||||||||||||||||||||||||
1428 | // topData() ensures the extra is created but does not ensure 'window' is non-null | - | ||||||||||||||||||||||||||||||||||||
1429 | // in case the extra was already valid. | - | ||||||||||||||||||||||||||||||||||||
1430 | if (!win) {
| 0 | ||||||||||||||||||||||||||||||||||||
1431 | createTLSysExtra(); | - | ||||||||||||||||||||||||||||||||||||
1432 | win = topData()->window; | - | ||||||||||||||||||||||||||||||||||||
1433 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1434 | - | |||||||||||||||||||||||||||||||||||||
1435 | const auto dynamicPropertyNames = q->dynamicPropertyNames(); | - | ||||||||||||||||||||||||||||||||||||
1436 | for (const QByteArray &propertyName : dynamicPropertyNames) { | - | ||||||||||||||||||||||||||||||||||||
1437 | if (!qstrncmp(propertyName, "_q_platform_", 12))
| 0 | ||||||||||||||||||||||||||||||||||||
1438 | win->setProperty(propertyName, q->property(propertyName)); never executed: win->setProperty(propertyName, q->property(propertyName)); | 0 | ||||||||||||||||||||||||||||||||||||
1439 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1440 | - | |||||||||||||||||||||||||||||||||||||
1441 | if (q->testAttribute(Qt::WA_ShowWithoutActivating))
| 0 | ||||||||||||||||||||||||||||||||||||
1442 | win->setProperty("_q_showWithoutActivating", QVariant(true)); never executed: win->setProperty("_q_showWithoutActivating", QVariant(true)); | 0 | ||||||||||||||||||||||||||||||||||||
1443 | if (q->testAttribute(Qt::WA_MacAlwaysShowToolWindow))
| 0 | ||||||||||||||||||||||||||||||||||||
1444 | win->setProperty("_q_macAlwaysShowToolWindow", QVariant::fromValue(QVariant(true))); never executed: win->setProperty("_q_macAlwaysShowToolWindow", QVariant::fromValue(QVariant(true))); | 0 | ||||||||||||||||||||||||||||||||||||
1445 | setNetWmWindowTypes(true); // do nothing if none of WA_X11NetWmWindowType* is set | - | ||||||||||||||||||||||||||||||||||||
1446 | win->setFlags(data.window_flags); | - | ||||||||||||||||||||||||||||||||||||
1447 | fixPosIncludesFrame(); | - | ||||||||||||||||||||||||||||||||||||
1448 | if (q->testAttribute(Qt::WA_Moved)
| 0 | ||||||||||||||||||||||||||||||||||||
1449 | || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowManagement))
| 0 | ||||||||||||||||||||||||||||||||||||
1450 | win->setGeometry(q->geometry()); never executed: win->setGeometry(q->geometry()); | 0 | ||||||||||||||||||||||||||||||||||||
1451 | else | - | ||||||||||||||||||||||||||||||||||||
1452 | win->resize(q->size()); never executed: win->resize(q->size()); | 0 | ||||||||||||||||||||||||||||||||||||
1453 | if (win->isTopLevel()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1454 | int screenNumber = topData()->initialScreenIndex; | - | ||||||||||||||||||||||||||||||||||||
1455 | topData()->initialScreenIndex = -1; | - | ||||||||||||||||||||||||||||||||||||
1456 | if (screenNumber < 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
1457 | screenNumber = q->windowType() != Qt::Desktop
| 0 | ||||||||||||||||||||||||||||||||||||
1458 | ? QApplication::desktop()->screenNumber(q) : 0; | - | ||||||||||||||||||||||||||||||||||||
1459 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1460 | win->setScreen(QGuiApplication::screens().value(screenNumber, Q_NULLPTR)); | - | ||||||||||||||||||||||||||||||||||||
1461 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1462 | - | |||||||||||||||||||||||||||||||||||||
1463 | QSurfaceFormat format = win->requestedFormat(); | - | ||||||||||||||||||||||||||||||||||||
1464 | if ((flags & Qt::Window) && win->surfaceType() != QSurface::OpenGLSurface
| 0 | ||||||||||||||||||||||||||||||||||||
1465 | && q->testAttribute(Qt::WA_TranslucentBackground)) {
| 0 | ||||||||||||||||||||||||||||||||||||
1466 | format.setAlphaBufferSize(8); | - | ||||||||||||||||||||||||||||||||||||
1467 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1468 | win->setFormat(format); | - | ||||||||||||||||||||||||||||||||||||
1469 | - | |||||||||||||||||||||||||||||||||||||
1470 | if (QWidget *nativeParent = q->nativeParentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1471 | if (nativeParent->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1472 | if (flags & Qt::Window) {
| 0 | ||||||||||||||||||||||||||||||||||||
1473 | win->setTransientParent(nativeParent->window()->windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
1474 | win->setParent(0); | - | ||||||||||||||||||||||||||||||||||||
1475 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1476 | win->setTransientParent(0); | - | ||||||||||||||||||||||||||||||||||||
1477 | win->setParent(nativeParent->windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
1478 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1479 | } | - | ||||||||||||||||||||||||||||||||||||
1480 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1481 | - | |||||||||||||||||||||||||||||||||||||
1482 | qt_window_private(win)->positionPolicy = topData()->posIncludesFrame ?
| 0 | ||||||||||||||||||||||||||||||||||||
1483 | QWindowPrivate::WindowFrameInclusive : QWindowPrivate::WindowFrameExclusive; | - | ||||||||||||||||||||||||||||||||||||
1484 | win->create(); | - | ||||||||||||||||||||||||||||||||||||
1485 | // Enable nonclient-area events for QDockWidget and other NonClientArea-mouse event processing. | - | ||||||||||||||||||||||||||||||||||||
1486 | if ((flags & Qt::Desktop) == Qt::Window)
| 0 | ||||||||||||||||||||||||||||||||||||
1487 | win->handle()->setFrameStrutEventsEnabled(true); never executed: win->handle()->setFrameStrutEventsEnabled(true); | 0 | ||||||||||||||||||||||||||||||||||||
1488 | - | |||||||||||||||||||||||||||||||||||||
1489 | data.window_flags = win->flags(); | - | ||||||||||||||||||||||||||||||||||||
1490 | - | |||||||||||||||||||||||||||||||||||||
1491 | if (!topData()->role.isNull())
| 0 | ||||||||||||||||||||||||||||||||||||
1492 | QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1()); never executed: QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1()); | 0 | ||||||||||||||||||||||||||||||||||||
1493 | - | |||||||||||||||||||||||||||||||||||||
1494 | QBackingStore *store = q->backingStore(); | - | ||||||||||||||||||||||||||||||||||||
1495 | - | |||||||||||||||||||||||||||||||||||||
1496 | if (!store) {
| 0 | ||||||||||||||||||||||||||||||||||||
1497 | if (win && q->windowType() != Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
1498 | if (q->isTopLevel())
| 0 | ||||||||||||||||||||||||||||||||||||
1499 | q->setBackingStore(new QBackingStore(win)); never executed: q->setBackingStore(new QBackingStore(win)); | 0 | ||||||||||||||||||||||||||||||||||||
1500 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1501 | q->setAttribute(Qt::WA_PaintOnScreen, true); | - | ||||||||||||||||||||||||||||||||||||
1502 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1503 | } | - | ||||||||||||||||||||||||||||||||||||
1504 | - | |||||||||||||||||||||||||||||||||||||
1505 | setWindowModified_helper(); | - | ||||||||||||||||||||||||||||||||||||
1506 | WId id = win->winId(); | - | ||||||||||||||||||||||||||||||||||||
1507 | // See the QPlatformWindow::winId() documentation | - | ||||||||||||||||||||||||||||||||||||
1508 | Q_ASSERT(id != WId(0)); | - | ||||||||||||||||||||||||||||||||||||
1509 | setWinId(id); | - | ||||||||||||||||||||||||||||||||||||
1510 | - | |||||||||||||||||||||||||||||||||||||
1511 | // Check children and create windows for them if necessary | - | ||||||||||||||||||||||||||||||||||||
1512 | q_createNativeChildrenAndSetParent(q); | - | ||||||||||||||||||||||||||||||||||||
1513 | - | |||||||||||||||||||||||||||||||||||||
1514 | if (extra && !extra->mask.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
1515 | setMask_sys(extra->mask); never executed: setMask_sys(extra->mask); | 0 | ||||||||||||||||||||||||||||||||||||
1516 | - | |||||||||||||||||||||||||||||||||||||
1517 | if (data.crect.width() == 0 || data.crect.height() == 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
1518 | q->setAttribute(Qt::WA_OutsideWSRange, true); | - | ||||||||||||||||||||||||||||||||||||
1519 | } else if (q->isVisible()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
1520 | // If widget is already shown, set window visible, too | - | ||||||||||||||||||||||||||||||||||||
1521 | win->setVisible(true); | - | ||||||||||||||||||||||||||||||||||||
1522 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1523 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1524 | - | |||||||||||||||||||||||||||||||||||||
1525 | #ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
1526 | static const char activeXNativeParentHandleProperty[] = "_q_embedded_native_parent_handle"; | - | ||||||||||||||||||||||||||||||||||||
1527 | #endif | - | ||||||||||||||||||||||||||||||||||||
1528 | - | |||||||||||||||||||||||||||||||||||||
1529 | void QWidgetPrivate::createTLSysExtra() | - | ||||||||||||||||||||||||||||||||||||
1530 | { | - | ||||||||||||||||||||||||||||||||||||
1531 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1532 | if (!extra->topextra->window && (q->testAttribute(Qt::WA_NativeWindow) || q->isWindow())) {
| 0 | ||||||||||||||||||||||||||||||||||||
1533 | extra->topextra->window = new QWidgetWindow(q); | - | ||||||||||||||||||||||||||||||||||||
1534 | if (extra->minw || extra->minh)
| 0 | ||||||||||||||||||||||||||||||||||||
1535 | extra->topextra->window->setMinimumSize(QSize(extra->minw, extra->minh)); never executed: extra->topextra->window->setMinimumSize(QSize(extra->minw, extra->minh)); | 0 | ||||||||||||||||||||||||||||||||||||
1536 | if (extra->maxw != QWIDGETSIZE_MAX || extra->maxh != QWIDGETSIZE_MAX)
| 0 | ||||||||||||||||||||||||||||||||||||
1537 | extra->topextra->window->setMaximumSize(QSize(extra->maxw, extra->maxh)); never executed: extra->topextra->window->setMaximumSize(QSize(extra->maxw, extra->maxh)); | 0 | ||||||||||||||||||||||||||||||||||||
1538 | if (extra->topextra->opacity != 255 && q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
1539 | extra->topextra->window->setOpacity(qreal(extra->topextra->opacity) / qreal(255)); never executed: extra->topextra->window->setOpacity(qreal(extra->topextra->opacity) / qreal(255)); | 0 | ||||||||||||||||||||||||||||||||||||
1540 | #ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
1541 | // Pass on native parent handle for Widget embedded into Active X. | - | ||||||||||||||||||||||||||||||||||||
1542 | const QVariant activeXNativeParentHandle = q->property(activeXNativeParentHandleProperty); | - | ||||||||||||||||||||||||||||||||||||
1543 | if (activeXNativeParentHandle.isValid()) | - | ||||||||||||||||||||||||||||||||||||
1544 | extra->topextra->window->setProperty(activeXNativeParentHandleProperty, activeXNativeParentHandle); | - | ||||||||||||||||||||||||||||||||||||
1545 | if (q->inherits("QTipLabel") || q->inherits("QAlphaWidget")) | - | ||||||||||||||||||||||||||||||||||||
1546 | extra->topextra->window->setProperty("_q_windowsDropShadow", QVariant(true)); | - | ||||||||||||||||||||||||||||||||||||
1547 | #endif | - | ||||||||||||||||||||||||||||||||||||
1548 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1549 | - | |||||||||||||||||||||||||||||||||||||
1550 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1551 | - | |||||||||||||||||||||||||||||||||||||
1552 | /*! | - | ||||||||||||||||||||||||||||||||||||
1553 | Destroys the widget. | - | ||||||||||||||||||||||||||||||||||||
1554 | - | |||||||||||||||||||||||||||||||||||||
1555 | All this widget's children are deleted first. The application | - | ||||||||||||||||||||||||||||||||||||
1556 | exits if this widget is the main widget. | - | ||||||||||||||||||||||||||||||||||||
1557 | */ | - | ||||||||||||||||||||||||||||||||||||
1558 | - | |||||||||||||||||||||||||||||||||||||
1559 | QWidget::~QWidget() | - | ||||||||||||||||||||||||||||||||||||
1560 | { | - | ||||||||||||||||||||||||||||||||||||
1561 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1562 | d->data.in_destructor = true; | - | ||||||||||||||||||||||||||||||||||||
1563 | - | |||||||||||||||||||||||||||||||||||||
1564 | #if defined (QT_CHECK_STATE) | - | ||||||||||||||||||||||||||||||||||||
1565 | if (Q_UNLIKELY(paintingActive())) | - | ||||||||||||||||||||||||||||||||||||
1566 | qWarning("QWidget: %s (%s) deleted while being painted", className(), name()); | - | ||||||||||||||||||||||||||||||||||||
1567 | #endif | - | ||||||||||||||||||||||||||||||||||||
1568 | - | |||||||||||||||||||||||||||||||||||||
1569 | #ifndef QT_NO_GESTURES | - | ||||||||||||||||||||||||||||||||||||
1570 | if (QGestureManager *manager = QGestureManager::instance()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1571 | // \forall Qt::GestureType type : ungrabGesture(type) (inlined) | - | ||||||||||||||||||||||||||||||||||||
1572 | for (auto it = d->gestureContext.keyBegin(), end = d->gestureContext.keyEnd(); it != end; ++it)
| 0 | ||||||||||||||||||||||||||||||||||||
1573 | manager->cleanupCachedGestures(this, *it); never executed: manager->cleanupCachedGestures(this, *it); | 0 | ||||||||||||||||||||||||||||||||||||
1574 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1575 | d->gestureContext.clear(); | - | ||||||||||||||||||||||||||||||||||||
1576 | #endif | - | ||||||||||||||||||||||||||||||||||||
1577 | - | |||||||||||||||||||||||||||||||||||||
1578 | // force acceptDrops false before winId is destroyed. | - | ||||||||||||||||||||||||||||||||||||
1579 | d->registerDropSite(false); | - | ||||||||||||||||||||||||||||||||||||
1580 | - | |||||||||||||||||||||||||||||||||||||
1581 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||||||||||||||
1582 | // remove all actions from this widget | - | ||||||||||||||||||||||||||||||||||||
1583 | for (int i = 0; i < d->actions.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
1584 | QActionPrivate *apriv = d->actions.at(i)->d_func(); | - | ||||||||||||||||||||||||||||||||||||
1585 | apriv->widgets.removeAll(this); | - | ||||||||||||||||||||||||||||||||||||
1586 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1587 | d->actions.clear(); | - | ||||||||||||||||||||||||||||||||||||
1588 | #endif | - | ||||||||||||||||||||||||||||||||||||
1589 | - | |||||||||||||||||||||||||||||||||||||
1590 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||||||||||||||||||||
1591 | // Remove all shortcuts grabbed by this | - | ||||||||||||||||||||||||||||||||||||
1592 | // widget, unless application is closing | - | ||||||||||||||||||||||||||||||||||||
1593 | if (!QApplicationPrivate::is_app_closing && testAttribute(Qt::WA_GrabbedShortcut))
| 0 | ||||||||||||||||||||||||||||||||||||
1594 | qApp->d_func()->shortcutMap.removeShortcut(0, this, QKeySequence()); never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(0, this, QKeySequence()); | 0 | ||||||||||||||||||||||||||||||||||||
1595 | #endif | - | ||||||||||||||||||||||||||||||||||||
1596 | - | |||||||||||||||||||||||||||||||||||||
1597 | // delete layout while we still are a valid widget | - | ||||||||||||||||||||||||||||||||||||
1598 | delete d->layout; | - | ||||||||||||||||||||||||||||||||||||
1599 | d->layout = 0; | - | ||||||||||||||||||||||||||||||||||||
1600 | // Remove myself from focus list | - | ||||||||||||||||||||||||||||||||||||
1601 | - | |||||||||||||||||||||||||||||||||||||
1602 | Q_ASSERT(d->focus_next->d_func()->focus_prev == this); | - | ||||||||||||||||||||||||||||||||||||
1603 | Q_ASSERT(d->focus_prev->d_func()->focus_next == this); | - | ||||||||||||||||||||||||||||||||||||
1604 | - | |||||||||||||||||||||||||||||||||||||
1605 | if (d->focus_next != this) {
| 0 | ||||||||||||||||||||||||||||||||||||
1606 | d->focus_next->d_func()->focus_prev = d->focus_prev; | - | ||||||||||||||||||||||||||||||||||||
1607 | d->focus_prev->d_func()->focus_next = d->focus_next; | - | ||||||||||||||||||||||||||||||||||||
1608 | d->focus_next = d->focus_prev = 0; | - | ||||||||||||||||||||||||||||||||||||
1609 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1610 | - | |||||||||||||||||||||||||||||||||||||
1611 | - | |||||||||||||||||||||||||||||||||||||
1612 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1613 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
1614 | const QWidget* w = this; | - | ||||||||||||||||||||||||||||||||||||
1615 | while (w->d_func()->extra && w->d_func()->extra->focus_proxy)
| 0 | ||||||||||||||||||||||||||||||||||||
1616 | w = w->d_func()->extra->focus_proxy; never executed: w = w->d_func()->extra->focus_proxy; | 0 | ||||||||||||||||||||||||||||||||||||
1617 | QWidget *window = w->window(); | - | ||||||||||||||||||||||||||||||||||||
1618 | QWExtra *e = window ? window->d_func()->extra : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
1619 | if (!e || !e->proxyWidget || (w->parentWidget() && w->parentWidget()->d_func()->focus_child == this))
| 0 | ||||||||||||||||||||||||||||||||||||
1620 | #endif | - | ||||||||||||||||||||||||||||||||||||
1621 | clearFocus(); never executed: clearFocus(); | 0 | ||||||||||||||||||||||||||||||||||||
1622 | } QT_CATCH(...) { never executed: end of block dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1623 | // swallow this problem because we are in a destructor dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1624 | } dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1625 | - | |||||||||||||||||||||||||||||||||||||
1626 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
1627 | - | |||||||||||||||||||||||||||||||||||||
1628 | if (isWindow() && isVisible() && internalWinId()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1629 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1630 | d->close_helper(QWidgetPrivate::CloseNoEvent); | - | ||||||||||||||||||||||||||||||||||||
1631 | } QT_CATCH(...) { never executed: end of block dead code: { if (true) { hide(); } else { } } | - | ||||||||||||||||||||||||||||||||||||
1632 | // if we're out of memory, at least hide the window. dead code: { if (true) { hide(); } else { } } | - | ||||||||||||||||||||||||||||||||||||
1633 | QT_TRY { dead code: { if (true) { hide(); } else { } } | - | ||||||||||||||||||||||||||||||||||||
1634 | hide(); dead code: { if (true) { hide(); } else { } } | - | ||||||||||||||||||||||||||||||||||||
1635 | } QT_CATCH(...) { dead code: { if (true) { hide(); } else { } } dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1636 | // and if that also doesn't work, then give up dead code: { if (true) { hide(); } else { } } dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1637 | } dead code: { if (true) { hide(); } else { } } dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1638 | } dead code: { if (true) { hide(); } else { } } | - | ||||||||||||||||||||||||||||||||||||
1639 | } | - | ||||||||||||||||||||||||||||||||||||
1640 | - | |||||||||||||||||||||||||||||||||||||
1641 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_X11)|| defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
1642 | else if (!internalWinId() && isVisible()) { | - | ||||||||||||||||||||||||||||||||||||
1643 | qApp->d_func()->sendSyntheticEnterLeave(this); | - | ||||||||||||||||||||||||||||||||||||
1644 | } | - | ||||||||||||||||||||||||||||||||||||
1645 | #endif | - | ||||||||||||||||||||||||||||||||||||
1646 | else if (isVisible()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1647 | qApp->d_func()->sendSyntheticEnterLeave(this); | - | ||||||||||||||||||||||||||||||||||||
1648 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1649 | - | |||||||||||||||||||||||||||||||||||||
1650 | if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1651 | bs->removeDirtyWidget(this); | - | ||||||||||||||||||||||||||||||||||||
1652 | if (testAttribute(Qt::WA_StaticContents))
| 0 | ||||||||||||||||||||||||||||||||||||
1653 | bs->removeStaticWidget(this); never executed: bs->removeStaticWidget(this); | 0 | ||||||||||||||||||||||||||||||||||||
1654 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1655 | - | |||||||||||||||||||||||||||||||||||||
1656 | delete d->needsFlush; | - | ||||||||||||||||||||||||||||||||||||
1657 | d->needsFlush = 0; | - | ||||||||||||||||||||||||||||||||||||
1658 | - | |||||||||||||||||||||||||||||||||||||
1659 | // The next 20 lines are duplicated from QObject, but required here | - | ||||||||||||||||||||||||||||||||||||
1660 | // since QWidget deletes is children itself | - | ||||||||||||||||||||||||||||||||||||
1661 | bool blocked = d->blockSig; | - | ||||||||||||||||||||||||||||||||||||
1662 | d->blockSig = 0; // unblock signals so we always emit destroyed() | - | ||||||||||||||||||||||||||||||||||||
1663 | - | |||||||||||||||||||||||||||||||||||||
1664 | if (d->isSignalConnected(0)) {
| 0 | ||||||||||||||||||||||||||||||||||||
1665 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1666 | emit destroyed(this); | - | ||||||||||||||||||||||||||||||||||||
1667 | } QT_CATCH(...) { never executed: end of block dead code: { QMessageLogger(__FILE__, 1670, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1668 | // all the signal/slots connections are still in place - if we don't dead code: { QMessageLogger(__FILE__, 1670, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1669 | // quit now, we will crash pretty soon. dead code: { QMessageLogger(__FILE__, 1670, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1670 | qWarning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); dead code: { QMessageLogger(__FILE__, 1670, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1671 | QT_RETHROW; dead code: { QMessageLogger(__FILE__, 1670, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1672 | } dead code: { QMessageLogger(__FILE__, 1670, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1673 | } | - | ||||||||||||||||||||||||||||||||||||
1674 | - | |||||||||||||||||||||||||||||||||||||
1675 | if (d->declarativeData) {
| 0 | ||||||||||||||||||||||||||||||||||||
1676 | if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
| 0 | ||||||||||||||||||||||||||||||||||||
1677 | if (QAbstractDeclarativeData::destroyed_qml1)
| 0 | ||||||||||||||||||||||||||||||||||||
1678 | QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this); never executed: QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this); | 0 | ||||||||||||||||||||||||||||||||||||
1679 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1680 | if (QAbstractDeclarativeData::destroyed)
| 0 | ||||||||||||||||||||||||||||||||||||
1681 | QAbstractDeclarativeData::destroyed(d->declarativeData, this); never executed: QAbstractDeclarativeData::destroyed(d->declarativeData, this); | 0 | ||||||||||||||||||||||||||||||||||||
1682 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1683 | d->declarativeData = 0; // don't activate again in ~QObject | - | ||||||||||||||||||||||||||||||||||||
1684 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1685 | - | |||||||||||||||||||||||||||||||||||||
1686 | d->blockSig = blocked; | - | ||||||||||||||||||||||||||||||||||||
1687 | - | |||||||||||||||||||||||||||||||||||||
1688 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1689 | // QCocoaView holds a pointer back to this widget. Clear it now | - | ||||||||||||||||||||||||||||||||||||
1690 | // to make sure it's not followed later on. The lifetime of the | - | ||||||||||||||||||||||||||||||||||||
1691 | // QCocoaView might exceed the lifetime of this widget in cases | - | ||||||||||||||||||||||||||||||||||||
1692 | // where Cocoa itself holds references to it. | - | ||||||||||||||||||||||||||||||||||||
1693 | extern void qt_mac_clearCocoaViewQWidgetPointers(QWidget *); | - | ||||||||||||||||||||||||||||||||||||
1694 | qt_mac_clearCocoaViewQWidgetPointers(this); | - | ||||||||||||||||||||||||||||||||||||
1695 | #endif | - | ||||||||||||||||||||||||||||||||||||
1696 | - | |||||||||||||||||||||||||||||||||||||
1697 | if (!d->children.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
1698 | d->deleteChildren(); never executed: d->deleteChildren(); | 0 | ||||||||||||||||||||||||||||||||||||
1699 | - | |||||||||||||||||||||||||||||||||||||
1700 | QApplication::removePostedEvents(this); | - | ||||||||||||||||||||||||||||||||||||
1701 | - | |||||||||||||||||||||||||||||||||||||
1702 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1703 | destroy(); // platform-dependent cleanup | - | ||||||||||||||||||||||||||||||||||||
1704 | } QT_CATCH(...) { never executed: end of block dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1705 | // if this fails we can't do anything about it but at least we are not allowed to throw. dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1706 | } dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1707 | --QWidgetPrivate::instanceCounter; | - | ||||||||||||||||||||||||||||||||||||
1708 | - | |||||||||||||||||||||||||||||||||||||
1709 | if (QWidgetPrivate::allWidgets) // might have been deleted by ~QApplication
| 0 | ||||||||||||||||||||||||||||||||||||
1710 | QWidgetPrivate::allWidgets->remove(this); never executed: QWidgetPrivate::allWidgets->remove(this); | 0 | ||||||||||||||||||||||||||||||||||||
1711 | - | |||||||||||||||||||||||||||||||||||||
1712 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1713 | QEvent e(QEvent::Destroy); | - | ||||||||||||||||||||||||||||||||||||
1714 | QCoreApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
1715 | } QT_CATCH(const std::exception&) { never executed: end of block dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1716 | // if this fails we can't do anything about it but at least we are not allowed to throw. dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1717 | } dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1718 | } | - | ||||||||||||||||||||||||||||||||||||
1719 | - | |||||||||||||||||||||||||||||||||||||
1720 | int QWidgetPrivate::instanceCounter = 0; // Current number of widget instances | - | ||||||||||||||||||||||||||||||||||||
1721 | int QWidgetPrivate::maxInstances = 0; // Maximum number of widget instances | - | ||||||||||||||||||||||||||||||||||||
1722 | - | |||||||||||||||||||||||||||||||||||||
1723 | void QWidgetPrivate::setWinId(WId id) // set widget identifier | - | ||||||||||||||||||||||||||||||||||||
1724 | { | - | ||||||||||||||||||||||||||||||||||||
1725 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1726 | // the user might create a widget with Qt::Desktop window | - | ||||||||||||||||||||||||||||||||||||
1727 | // attribute (or create another QDesktopWidget instance), which | - | ||||||||||||||||||||||||||||||||||||
1728 | // will have the same windowid (the root window id) as the | - | ||||||||||||||||||||||||||||||||||||
1729 | // qt_desktopWidget. We should not add the second desktop widget | - | ||||||||||||||||||||||||||||||||||||
1730 | // to the mapper. | - | ||||||||||||||||||||||||||||||||||||
1731 | bool userDesktopWidget = qt_desktopWidget != 0 && qt_desktopWidget != q && q->windowType() == Qt::Desktop;
| 0 | ||||||||||||||||||||||||||||||||||||
1732 | if (mapper && data.winid && !userDesktopWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
1733 | mapper->remove(data.winid); | - | ||||||||||||||||||||||||||||||||||||
1734 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1735 | - | |||||||||||||||||||||||||||||||||||||
1736 | const WId oldWinId = data.winid; | - | ||||||||||||||||||||||||||||||||||||
1737 | - | |||||||||||||||||||||||||||||||||||||
1738 | data.winid = id; | - | ||||||||||||||||||||||||||||||||||||
1739 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
1740 | hd = id; // X11: hd == ident | - | ||||||||||||||||||||||||||||||||||||
1741 | #endif | - | ||||||||||||||||||||||||||||||||||||
1742 | if (mapper && id && !userDesktopWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
1743 | mapper->insert(data.winid, q); | - | ||||||||||||||||||||||||||||||||||||
1744 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1745 | - | |||||||||||||||||||||||||||||||||||||
1746 | if(oldWinId != id) {
| 0 | ||||||||||||||||||||||||||||||||||||
1747 | QEvent e(QEvent::WinIdChange); | - | ||||||||||||||||||||||||||||||||||||
1748 | QCoreApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
1749 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1750 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1751 | - | |||||||||||||||||||||||||||||||||||||
1752 | void QWidgetPrivate::createTLExtra() | - | ||||||||||||||||||||||||||||||||||||
1753 | { | - | ||||||||||||||||||||||||||||||||||||
1754 | if (!extra)
| 0 | ||||||||||||||||||||||||||||||||||||
1755 | createExtra(); never executed: createExtra(); | 0 | ||||||||||||||||||||||||||||||||||||
1756 | if (!extra->topextra) {
| 0 | ||||||||||||||||||||||||||||||||||||
1757 | QTLWExtra* x = extra->topextra = new QTLWExtra; | - | ||||||||||||||||||||||||||||||||||||
1758 | x->icon = 0; | - | ||||||||||||||||||||||||||||||||||||
1759 | x->backingStore = 0; | - | ||||||||||||||||||||||||||||||||||||
1760 | x->sharedPainter = 0; | - | ||||||||||||||||||||||||||||||||||||
1761 | x->incw = x->inch = 0; | - | ||||||||||||||||||||||||||||||||||||
1762 | x->basew = x->baseh = 0; | - | ||||||||||||||||||||||||||||||||||||
1763 | x->frameStrut.setCoords(0, 0, 0, 0); | - | ||||||||||||||||||||||||||||||||||||
1764 | x->normalGeometry = QRect(0,0,-1,-1); | - | ||||||||||||||||||||||||||||||||||||
1765 | x->savedFlags = 0; | - | ||||||||||||||||||||||||||||||||||||
1766 | x->opacity = 255; | - | ||||||||||||||||||||||||||||||||||||
1767 | x->posIncludesFrame = 0; | - | ||||||||||||||||||||||||||||||||||||
1768 | x->sizeAdjusted = false; | - | ||||||||||||||||||||||||||||||||||||
1769 | x->inTopLevelResize = false; | - | ||||||||||||||||||||||||||||||||||||
1770 | x->inRepaint = false; | - | ||||||||||||||||||||||||||||||||||||
1771 | x->embedded = 0; | - | ||||||||||||||||||||||||||||||||||||
1772 | x->window = 0; | - | ||||||||||||||||||||||||||||||||||||
1773 | x->shareContext = 0; | - | ||||||||||||||||||||||||||||||||||||
1774 | x->initialScreenIndex = -1; | - | ||||||||||||||||||||||||||||||||||||
1775 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1776 | x->wasMaximized = false; | - | ||||||||||||||||||||||||||||||||||||
1777 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1778 | #ifdef QWIDGET_EXTRA_DEBUG | - | ||||||||||||||||||||||||||||||||||||
1779 | static int count = 0; | - | ||||||||||||||||||||||||||||||||||||
1780 | qDebug() << "tlextra" << ++count; | - | ||||||||||||||||||||||||||||||||||||
1781 | #endif | - | ||||||||||||||||||||||||||||||||||||
1782 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1783 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1784 | - | |||||||||||||||||||||||||||||||||||||
1785 | /*! | - | ||||||||||||||||||||||||||||||||||||
1786 | \internal | - | ||||||||||||||||||||||||||||||||||||
1787 | Creates the widget extra data. | - | ||||||||||||||||||||||||||||||||||||
1788 | */ | - | ||||||||||||||||||||||||||||||||||||
1789 | - | |||||||||||||||||||||||||||||||||||||
1790 | void QWidgetPrivate::createExtra() | - | ||||||||||||||||||||||||||||||||||||
1791 | { | - | ||||||||||||||||||||||||||||||||||||
1792 | if (!extra) { // if not exists
| 0 | ||||||||||||||||||||||||||||||||||||
1793 | extra = new QWExtra; | - | ||||||||||||||||||||||||||||||||||||
1794 | extra->glContext = 0; | - | ||||||||||||||||||||||||||||||||||||
1795 | extra->topextra = 0; | - | ||||||||||||||||||||||||||||||||||||
1796 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
1797 | extra->proxyWidget = 0; | - | ||||||||||||||||||||||||||||||||||||
1798 | #endif | - | ||||||||||||||||||||||||||||||||||||
1799 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
1800 | extra->curs = 0; | - | ||||||||||||||||||||||||||||||||||||
1801 | #endif | - | ||||||||||||||||||||||||||||||||||||
1802 | extra->minw = 0; | - | ||||||||||||||||||||||||||||||||||||
1803 | extra->minh = 0; | - | ||||||||||||||||||||||||||||||||||||
1804 | extra->maxw = QWIDGETSIZE_MAX; | - | ||||||||||||||||||||||||||||||||||||
1805 | extra->maxh = QWIDGETSIZE_MAX; | - | ||||||||||||||||||||||||||||||||||||
1806 | extra->customDpiX = 0; | - | ||||||||||||||||||||||||||||||||||||
1807 | extra->customDpiY = 0; | - | ||||||||||||||||||||||||||||||||||||
1808 | extra->explicitMinSize = 0; | - | ||||||||||||||||||||||||||||||||||||
1809 | extra->explicitMaxSize = 0; | - | ||||||||||||||||||||||||||||||||||||
1810 | extra->autoFillBackground = 0; | - | ||||||||||||||||||||||||||||||||||||
1811 | extra->nativeChildrenForced = 0; | - | ||||||||||||||||||||||||||||||||||||
1812 | extra->inRenderWithPainter = 0; | - | ||||||||||||||||||||||||||||||||||||
1813 | extra->hasWindowContainer = false; | - | ||||||||||||||||||||||||||||||||||||
1814 | extra->hasMask = 0; | - | ||||||||||||||||||||||||||||||||||||
1815 | createSysExtra(); | - | ||||||||||||||||||||||||||||||||||||
1816 | #ifdef QWIDGET_EXTRA_DEBUG | - | ||||||||||||||||||||||||||||||||||||
1817 | static int count = 0; | - | ||||||||||||||||||||||||||||||||||||
1818 | qDebug() << "extra" << ++count; | - | ||||||||||||||||||||||||||||||||||||
1819 | #endif | - | ||||||||||||||||||||||||||||||||||||
1820 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1821 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1822 | - | |||||||||||||||||||||||||||||||||||||
1823 | void QWidgetPrivate::createSysExtra() | - | ||||||||||||||||||||||||||||||||||||
1824 | { | - | ||||||||||||||||||||||||||||||||||||
1825 | } | - | ||||||||||||||||||||||||||||||||||||
1826 | - | |||||||||||||||||||||||||||||||||||||
1827 | /*! | - | ||||||||||||||||||||||||||||||||||||
1828 | \internal | - | ||||||||||||||||||||||||||||||||||||
1829 | Deletes the widget extra data. | - | ||||||||||||||||||||||||||||||||||||
1830 | */ | - | ||||||||||||||||||||||||||||||||||||
1831 | - | |||||||||||||||||||||||||||||||||||||
1832 | void QWidgetPrivate::deleteExtra() | - | ||||||||||||||||||||||||||||||||||||
1833 | { | - | ||||||||||||||||||||||||||||||||||||
1834 | if (extra) { // if exists
| 0 | ||||||||||||||||||||||||||||||||||||
1835 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
1836 | delete extra->curs; | - | ||||||||||||||||||||||||||||||||||||
1837 | #endif | - | ||||||||||||||||||||||||||||||||||||
1838 | deleteSysExtra(); | - | ||||||||||||||||||||||||||||||||||||
1839 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
1840 | // dereference the stylesheet style | - | ||||||||||||||||||||||||||||||||||||
1841 | if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(extra->style))
| 0 | ||||||||||||||||||||||||||||||||||||
1842 | proxy->deref(); never executed: proxy->deref(); | 0 | ||||||||||||||||||||||||||||||||||||
1843 | #endif | - | ||||||||||||||||||||||||||||||||||||
1844 | if (extra->topextra) {
| 0 | ||||||||||||||||||||||||||||||||||||
1845 | deleteTLSysExtra(); | - | ||||||||||||||||||||||||||||||||||||
1846 | // extra->topextra->backingStore destroyed in QWidgetPrivate::deleteTLSysExtra() | - | ||||||||||||||||||||||||||||||||||||
1847 | delete extra->topextra->icon; | - | ||||||||||||||||||||||||||||||||||||
1848 | delete extra->topextra; | - | ||||||||||||||||||||||||||||||||||||
1849 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1850 | delete extra; | - | ||||||||||||||||||||||||||||||||||||
1851 | // extra->xic destroyed in QWidget::destroy() | - | ||||||||||||||||||||||||||||||||||||
1852 | extra = 0; | - | ||||||||||||||||||||||||||||||||||||
1853 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1854 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1855 | - | |||||||||||||||||||||||||||||||||||||
1856 | void QWidgetPrivate::deleteSysExtra() | - | ||||||||||||||||||||||||||||||||||||
1857 | { | - | ||||||||||||||||||||||||||||||||||||
1858 | } | - | ||||||||||||||||||||||||||||||||||||
1859 | - | |||||||||||||||||||||||||||||||||||||
1860 | static void deleteBackingStore(QWidgetPrivate *d) | - | ||||||||||||||||||||||||||||||||||||
1861 | { | - | ||||||||||||||||||||||||||||||||||||
1862 | QTLWExtra *topData = d->topData(); | - | ||||||||||||||||||||||||||||||||||||
1863 | - | |||||||||||||||||||||||||||||||||||||
1864 | // The context must be current when destroying the backing store as it may attempt to | - | ||||||||||||||||||||||||||||||||||||
1865 | // release resources like textures and shader programs. The window may not be suitable | - | ||||||||||||||||||||||||||||||||||||
1866 | // anymore as there will often not be a platform window underneath at this stage. Fall | - | ||||||||||||||||||||||||||||||||||||
1867 | // back to a QOffscreenSurface in this case. | - | ||||||||||||||||||||||||||||||||||||
1868 | QScopedPointer<QOffscreenSurface> tempSurface; | - | ||||||||||||||||||||||||||||||||||||
1869 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
1870 | if (d->textureChildSeen && topData->shareContext) {
| 0 | ||||||||||||||||||||||||||||||||||||
1871 | if (topData->window->handle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1872 | topData->shareContext->makeCurrent(topData->window); | - | ||||||||||||||||||||||||||||||||||||
1873 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1874 | tempSurface.reset(new QOffscreenSurface); | - | ||||||||||||||||||||||||||||||||||||
1875 | tempSurface->setFormat(topData->shareContext->format()); | - | ||||||||||||||||||||||||||||||||||||
1876 | tempSurface->create(); | - | ||||||||||||||||||||||||||||||||||||
1877 | topData->shareContext->makeCurrent(tempSurface.data()); | - | ||||||||||||||||||||||||||||||||||||
1878 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1879 | } | - | ||||||||||||||||||||||||||||||||||||
1880 | #endif | - | ||||||||||||||||||||||||||||||||||||
1881 | - | |||||||||||||||||||||||||||||||||||||
1882 | delete topData->backingStore; | - | ||||||||||||||||||||||||||||||||||||
1883 | topData->backingStore = 0; | - | ||||||||||||||||||||||||||||||||||||
1884 | - | |||||||||||||||||||||||||||||||||||||
1885 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
1886 | if (d->textureChildSeen && topData->shareContext)
| 0 | ||||||||||||||||||||||||||||||||||||
1887 | topData->shareContext->doneCurrent(); never executed: topData->shareContext->doneCurrent(); | 0 | ||||||||||||||||||||||||||||||||||||
1888 | #endif | - | ||||||||||||||||||||||||||||||||||||
1889 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1890 | - | |||||||||||||||||||||||||||||||||||||
1891 | void QWidgetPrivate::deleteTLSysExtra() | - | ||||||||||||||||||||||||||||||||||||
1892 | { | - | ||||||||||||||||||||||||||||||||||||
1893 | if (extra && extra->topextra) {
| 0 | ||||||||||||||||||||||||||||||||||||
1894 | //the qplatformbackingstore may hold a reference to the window, so the backingstore | - | ||||||||||||||||||||||||||||||||||||
1895 | //needs to be deleted first. If the backingstore holds GL resources, we need to | - | ||||||||||||||||||||||||||||||||||||
1896 | // make the context current here. This is taken care of by deleteBackingStore(). | - | ||||||||||||||||||||||||||||||||||||
1897 | - | |||||||||||||||||||||||||||||||||||||
1898 | extra->topextra->backingStoreTracker.destroy(); | - | ||||||||||||||||||||||||||||||||||||
1899 | deleteBackingStore(this); | - | ||||||||||||||||||||||||||||||||||||
1900 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
1901 | qDeleteAll(extra->topextra->widgetTextures); | - | ||||||||||||||||||||||||||||||||||||
1902 | extra->topextra->widgetTextures.clear(); | - | ||||||||||||||||||||||||||||||||||||
1903 | delete extra->topextra->shareContext; | - | ||||||||||||||||||||||||||||||||||||
1904 | extra->topextra->shareContext = 0; | - | ||||||||||||||||||||||||||||||||||||
1905 | #endif | - | ||||||||||||||||||||||||||||||||||||
1906 | - | |||||||||||||||||||||||||||||||||||||
1907 | //the toplevel might have a context with a "qglcontext associated with it. We need to | - | ||||||||||||||||||||||||||||||||||||
1908 | //delete the qglcontext before we delete the qplatformopenglcontext. | - | ||||||||||||||||||||||||||||||||||||
1909 | //One unfortunate thing about this is that we potentially create a glContext just to | - | ||||||||||||||||||||||||||||||||||||
1910 | //delete it straight afterwards. | - | ||||||||||||||||||||||||||||||||||||
1911 | if (extra->topextra->window) {
| 0 | ||||||||||||||||||||||||||||||||||||
1912 | extra->topextra->window->destroy(); | - | ||||||||||||||||||||||||||||||||||||
1913 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1914 | delete extra->topextra->window; | - | ||||||||||||||||||||||||||||||||||||
1915 | extra->topextra->window = 0; | - | ||||||||||||||||||||||||||||||||||||
1916 | - | |||||||||||||||||||||||||||||||||||||
1917 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1918 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1919 | - | |||||||||||||||||||||||||||||||||||||
1920 | /* | - | ||||||||||||||||||||||||||||||||||||
1921 | Returns \c true if there are widgets above this which overlap with | - | ||||||||||||||||||||||||||||||||||||
1922 | \a rect, which is in parent's coordinate system (same as crect). | - | ||||||||||||||||||||||||||||||||||||
1923 | */ | - | ||||||||||||||||||||||||||||||||||||
1924 | - | |||||||||||||||||||||||||||||||||||||
1925 | bool QWidgetPrivate::isOverlapped(const QRect &rect) const | - | ||||||||||||||||||||||||||||||||||||
1926 | { | - | ||||||||||||||||||||||||||||||||||||
1927 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
1928 | - | |||||||||||||||||||||||||||||||||||||
1929 | const QWidget *w = q; | - | ||||||||||||||||||||||||||||||||||||
1930 | QRect r = rect; | - | ||||||||||||||||||||||||||||||||||||
1931 | while (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
1932 | if (w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
1933 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
1934 | QWidgetPrivate *pd = w->parentWidget()->d_func(); | - | ||||||||||||||||||||||||||||||||||||
1935 | bool above = false; | - | ||||||||||||||||||||||||||||||||||||
1936 | for (int i = 0; i < pd->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
1937 | QWidget *sibling = qobject_cast<QWidget *>(pd->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
1938 | if (!sibling || !sibling->isVisible() || sibling->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
1939 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
1940 | if (!above) {
| 0 | ||||||||||||||||||||||||||||||||||||
1941 | above = (sibling == w); | - | ||||||||||||||||||||||||||||||||||||
1942 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
1943 | } | - | ||||||||||||||||||||||||||||||||||||
1944 | - | |||||||||||||||||||||||||||||||||||||
1945 | if (qRectIntersects(sibling->d_func()->effectiveRectFor(sibling->data->crect), r)) {
| 0 | ||||||||||||||||||||||||||||||||||||
1946 | const QWExtra *siblingExtra = sibling->d_func()->extra; | - | ||||||||||||||||||||||||||||||||||||
1947 | if (siblingExtra && siblingExtra->hasMask && !sibling->d_func()->graphicsEffect
| 0 | ||||||||||||||||||||||||||||||||||||
1948 | && !siblingExtra->mask.translated(sibling->data->crect.topLeft()).intersects(r)) {
| 0 | ||||||||||||||||||||||||||||||||||||
1949 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
1950 | } | - | ||||||||||||||||||||||||||||||||||||
1951 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
1952 | } | - | ||||||||||||||||||||||||||||||||||||
1953 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1954 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
1955 | r.translate(pd->data.crect.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
1956 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1957 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
1958 | } | - | ||||||||||||||||||||||||||||||||||||
1959 | - | |||||||||||||||||||||||||||||||||||||
1960 | void QWidgetPrivate::syncBackingStore() | - | ||||||||||||||||||||||||||||||||||||
1961 | { | - | ||||||||||||||||||||||||||||||||||||
1962 | if (paintOnScreen()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1963 | repaint_sys(dirty); | - | ||||||||||||||||||||||||||||||||||||
1964 | dirty = QRegion(); | - | ||||||||||||||||||||||||||||||||||||
1965 | } else if (QWidgetBackingStore *bs = maybeBackingStore()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
1966 | bs->sync(); | - | ||||||||||||||||||||||||||||||||||||
1967 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1968 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1969 | - | |||||||||||||||||||||||||||||||||||||
1970 | void QWidgetPrivate::syncBackingStore(const QRegion ®ion) | - | ||||||||||||||||||||||||||||||||||||
1971 | { | - | ||||||||||||||||||||||||||||||||||||
1972 | if (paintOnScreen())
| 0 | ||||||||||||||||||||||||||||||||||||
1973 | repaint_sys(region); never executed: repaint_sys(region); | 0 | ||||||||||||||||||||||||||||||||||||
1974 | else if (QWidgetBackingStore *bs = maybeBackingStore()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1975 | bs->sync(q_func(), region); | - | ||||||||||||||||||||||||||||||||||||
1976 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1977 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1978 | - | |||||||||||||||||||||||||||||||||||||
1979 | void QWidgetPrivate::setUpdatesEnabled_helper(bool enable) | - | ||||||||||||||||||||||||||||||||||||
1980 | { | - | ||||||||||||||||||||||||||||||||||||
1981 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1982 | - | |||||||||||||||||||||||||||||||||||||
1983 | if (enable && !q->isWindow() && q->parentWidget() && !q->parentWidget()->updatesEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
1984 | return; // nothing we can do never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
1985 | - | |||||||||||||||||||||||||||||||||||||
1986 | if (enable != q->testAttribute(Qt::WA_UpdatesDisabled))
| 0 | ||||||||||||||||||||||||||||||||||||
1987 | return; // nothing to do never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
1988 | - | |||||||||||||||||||||||||||||||||||||
1989 | q->setAttribute(Qt::WA_UpdatesDisabled, !enable); | - | ||||||||||||||||||||||||||||||||||||
1990 | if (enable)
| 0 | ||||||||||||||||||||||||||||||||||||
1991 | q->update(); never executed: q->update(); | 0 | ||||||||||||||||||||||||||||||||||||
1992 | - | |||||||||||||||||||||||||||||||||||||
1993 | Qt::WidgetAttribute attribute = enable ? Qt::WA_ForceUpdatesDisabled : Qt::WA_UpdatesDisabled;
| 0 | ||||||||||||||||||||||||||||||||||||
1994 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
1995 | QWidget *w = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
1996 | if (w && !w->isWindow() && !w->testAttribute(attribute))
| 0 | ||||||||||||||||||||||||||||||||||||
1997 | w->d_func()->setUpdatesEnabled_helper(enable); never executed: w->d_func()->setUpdatesEnabled_helper(enable); | 0 | ||||||||||||||||||||||||||||||||||||
1998 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1999 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2000 | - | |||||||||||||||||||||||||||||||||||||
2001 | /*! | - | ||||||||||||||||||||||||||||||||||||
2002 | \internal | - | ||||||||||||||||||||||||||||||||||||
2003 | - | |||||||||||||||||||||||||||||||||||||
2004 | Propagate this widget's palette to all children, except style sheet | - | ||||||||||||||||||||||||||||||||||||
2005 | widgets, and windows that don't enable window propagation (palettes don't | - | ||||||||||||||||||||||||||||||||||||
2006 | normally propagate to windows). | - | ||||||||||||||||||||||||||||||||||||
2007 | */ | - | ||||||||||||||||||||||||||||||||||||
2008 | void QWidgetPrivate::propagatePaletteChange() | - | ||||||||||||||||||||||||||||||||||||
2009 | { | - | ||||||||||||||||||||||||||||||||||||
2010 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2011 | // Propagate a new inherited mask to all children. | - | ||||||||||||||||||||||||||||||||||||
2012 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
2013 | if (!q->parentWidget() && extra && extra->proxyWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
2014 | QGraphicsProxyWidget *p = extra->proxyWidget; | - | ||||||||||||||||||||||||||||||||||||
2015 | inheritedPaletteResolveMask = p->d_func()->inheritedPaletteResolveMask | p->palette().resolve(); | - | ||||||||||||||||||||||||||||||||||||
2016 | } else never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2017 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
2018 | if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2019 | inheritedPaletteResolveMask = 0; | - | ||||||||||||||||||||||||||||||||||||
2020 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2021 | int mask = data.pal.resolve() | inheritedPaletteResolveMask; | - | ||||||||||||||||||||||||||||||||||||
2022 | - | |||||||||||||||||||||||||||||||||||||
2023 | const bool useStyleSheetPropagationInWidgetStyles = | - | ||||||||||||||||||||||||||||||||||||
2024 | QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); | - | ||||||||||||||||||||||||||||||||||||
2025 | - | |||||||||||||||||||||||||||||||||||||
2026 | QEvent pc(QEvent::PaletteChange); | - | ||||||||||||||||||||||||||||||||||||
2027 | QApplication::sendEvent(q, &pc); | - | ||||||||||||||||||||||||||||||||||||
2028 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
2029 | QWidget *w = qobject_cast<QWidget*>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
2030 | if (w && (!w->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles)
| 0 | ||||||||||||||||||||||||||||||||||||
2031 | && (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) {
| 0 | ||||||||||||||||||||||||||||||||||||
2032 | QWidgetPrivate *wd = w->d_func(); | - | ||||||||||||||||||||||||||||||||||||
2033 | wd->inheritedPaletteResolveMask = mask; | - | ||||||||||||||||||||||||||||||||||||
2034 | wd->resolvePalette(); | - | ||||||||||||||||||||||||||||||||||||
2035 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2036 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2037 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2038 | - | |||||||||||||||||||||||||||||||||||||
2039 | /* | - | ||||||||||||||||||||||||||||||||||||
2040 | Returns the widget's clipping rectangle. | - | ||||||||||||||||||||||||||||||||||||
2041 | */ | - | ||||||||||||||||||||||||||||||||||||
2042 | QRect QWidgetPrivate::clipRect() const | - | ||||||||||||||||||||||||||||||||||||
2043 | { | - | ||||||||||||||||||||||||||||||||||||
2044 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2045 | const QWidget * w = q; | - | ||||||||||||||||||||||||||||||||||||
2046 | if (!w->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
2047 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||||||||||||||
2048 | QRect r = effectiveRectFor(q->rect()); | - | ||||||||||||||||||||||||||||||||||||
2049 | int ox = 0; | - | ||||||||||||||||||||||||||||||||||||
2050 | int oy = 0; | - | ||||||||||||||||||||||||||||||||||||
2051 | while (w
| 0 | ||||||||||||||||||||||||||||||||||||
2052 | && w->isVisible()
| 0 | ||||||||||||||||||||||||||||||||||||
2053 | && !w->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
2054 | && w->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2055 | ox -= w->x(); | - | ||||||||||||||||||||||||||||||||||||
2056 | oy -= w->y(); | - | ||||||||||||||||||||||||||||||||||||
2057 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2058 | r &= QRect(ox, oy, w->width(), w->height()); | - | ||||||||||||||||||||||||||||||||||||
2059 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2060 | return r; never executed: return r; | 0 | ||||||||||||||||||||||||||||||||||||
2061 | } | - | ||||||||||||||||||||||||||||||||||||
2062 | - | |||||||||||||||||||||||||||||||||||||
2063 | /* | - | ||||||||||||||||||||||||||||||||||||
2064 | Returns the widget's clipping region (without siblings). | - | ||||||||||||||||||||||||||||||||||||
2065 | */ | - | ||||||||||||||||||||||||||||||||||||
2066 | QRegion QWidgetPrivate::clipRegion() const | - | ||||||||||||||||||||||||||||||||||||
2067 | { | - | ||||||||||||||||||||||||||||||||||||
2068 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2069 | if (!q->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
2070 | return QRegion(); never executed: return QRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
2071 | QRegion r(q->rect()); | - | ||||||||||||||||||||||||||||||||||||
2072 | const QWidget * w = q; | - | ||||||||||||||||||||||||||||||||||||
2073 | const QWidget *ignoreUpTo; | - | ||||||||||||||||||||||||||||||||||||
2074 | int ox = 0; | - | ||||||||||||||||||||||||||||||||||||
2075 | int oy = 0; | - | ||||||||||||||||||||||||||||||||||||
2076 | while (w
| 0 | ||||||||||||||||||||||||||||||||||||
2077 | && w->isVisible()
| 0 | ||||||||||||||||||||||||||||||||||||
2078 | && !w->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
2079 | && w->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2080 | ox -= w->x(); | - | ||||||||||||||||||||||||||||||||||||
2081 | oy -= w->y(); | - | ||||||||||||||||||||||||||||||||||||
2082 | ignoreUpTo = w; | - | ||||||||||||||||||||||||||||||||||||
2083 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2084 | r &= QRegion(ox, oy, w->width(), w->height()); | - | ||||||||||||||||||||||||||||||||||||
2085 | - | |||||||||||||||||||||||||||||||||||||
2086 | int i = 0; | - | ||||||||||||||||||||||||||||||||||||
2087 | while(w->d_func()->children.at(i++) != static_cast<const QObject *>(ignoreUpTo))
| 0 | ||||||||||||||||||||||||||||||||||||
2088 | ; never executed: ; | 0 | ||||||||||||||||||||||||||||||||||||
2089 | for ( ; i < w->d_func()->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
2090 | if(QWidget *sibling = qobject_cast<QWidget *>(w->d_func()->children.at(i))) {
| 0 | ||||||||||||||||||||||||||||||||||||
2091 | if(sibling->isVisible() && !sibling->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2092 | QRect siblingRect(ox+sibling->x(), oy+sibling->y(), | - | ||||||||||||||||||||||||||||||||||||
2093 | sibling->width(), sibling->height()); | - | ||||||||||||||||||||||||||||||||||||
2094 | if (qRectIntersects(siblingRect, q->rect()))
| 0 | ||||||||||||||||||||||||||||||||||||
2095 | r -= QRegion(siblingRect); never executed: r -= QRegion(siblingRect); | 0 | ||||||||||||||||||||||||||||||||||||
2096 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2097 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2098 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2099 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2100 | return r; never executed: return r; | 0 | ||||||||||||||||||||||||||||||||||||
2101 | } | - | ||||||||||||||||||||||||||||||||||||
2102 | - | |||||||||||||||||||||||||||||||||||||
2103 | void QWidgetPrivate::setSystemClip(QPaintDevice *paintDevice, const QRegion ®ion) | - | ||||||||||||||||||||||||||||||||||||
2104 | { | - | ||||||||||||||||||||||||||||||||||||
2105 | // Transform the system clip region from device-independent pixels to device pixels | - | ||||||||||||||||||||||||||||||||||||
2106 | QPaintEngine *paintEngine = paintDevice->paintEngine(); | - | ||||||||||||||||||||||||||||||||||||
2107 | QTransform scaleTransform; | - | ||||||||||||||||||||||||||||||||||||
2108 | const qreal devicePixelRatio = paintDevice->devicePixelRatioF(); | - | ||||||||||||||||||||||||||||||||||||
2109 | scaleTransform.scale(devicePixelRatio, devicePixelRatio); | - | ||||||||||||||||||||||||||||||||||||
2110 | paintEngine->d_func()->systemClip = scaleTransform.map(region); | - | ||||||||||||||||||||||||||||||||||||
2111 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2112 | - | |||||||||||||||||||||||||||||||||||||
2113 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2114 | void QWidgetPrivate::invalidateGraphicsEffectsRecursively() | - | ||||||||||||||||||||||||||||||||||||
2115 | { | - | ||||||||||||||||||||||||||||||||||||
2116 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2117 | QWidget *w = q; | - | ||||||||||||||||||||||||||||||||||||
2118 | do { | - | ||||||||||||||||||||||||||||||||||||
2119 | if (w->graphicsEffect()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2120 | QWidgetEffectSourcePrivate *sourced = | - | ||||||||||||||||||||||||||||||||||||
2121 | static_cast<QWidgetEffectSourcePrivate *>(w->graphicsEffect()->source()->d_func()); | - | ||||||||||||||||||||||||||||||||||||
2122 | if (!sourced->updateDueToGraphicsEffect)
| 0 | ||||||||||||||||||||||||||||||||||||
2123 | w->graphicsEffect()->source()->d_func()->invalidateCache(); never executed: w->graphicsEffect()->source()->d_func()->invalidateCache(); | 0 | ||||||||||||||||||||||||||||||||||||
2124 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2125 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2126 | } while (w); never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
2127 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2128 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2129 | - | |||||||||||||||||||||||||||||||||||||
2130 | void QWidgetPrivate::setDirtyOpaqueRegion() | - | ||||||||||||||||||||||||||||||||||||
2131 | { | - | ||||||||||||||||||||||||||||||||||||
2132 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2133 | - | |||||||||||||||||||||||||||||||||||||
2134 | dirtyOpaqueChildren = true; | - | ||||||||||||||||||||||||||||||||||||
2135 | - | |||||||||||||||||||||||||||||||||||||
2136 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2137 | invalidateGraphicsEffectsRecursively(); | - | ||||||||||||||||||||||||||||||||||||
2138 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2139 | - | |||||||||||||||||||||||||||||||||||||
2140 | if (q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
2141 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2142 | - | |||||||||||||||||||||||||||||||||||||
2143 | QWidget *parent = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2144 | if (!parent)
| 0 | ||||||||||||||||||||||||||||||||||||
2145 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2146 | - | |||||||||||||||||||||||||||||||||||||
2147 | // TODO: instead of setting dirtyflag, manipulate the dirtyregion directly? | - | ||||||||||||||||||||||||||||||||||||
2148 | QWidgetPrivate *pd = parent->d_func(); | - | ||||||||||||||||||||||||||||||||||||
2149 | if (!pd->dirtyOpaqueChildren)
| 0 | ||||||||||||||||||||||||||||||||||||
2150 | pd->setDirtyOpaqueRegion(); never executed: pd->setDirtyOpaqueRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
2151 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2152 | - | |||||||||||||||||||||||||||||||||||||
2153 | const QRegion &QWidgetPrivate::getOpaqueChildren() const | - | ||||||||||||||||||||||||||||||||||||
2154 | { | - | ||||||||||||||||||||||||||||||||||||
2155 | if (!dirtyOpaqueChildren)
| 0 | ||||||||||||||||||||||||||||||||||||
2156 | return opaqueChildren; never executed: return opaqueChildren; | 0 | ||||||||||||||||||||||||||||||||||||
2157 | - | |||||||||||||||||||||||||||||||||||||
2158 | QWidgetPrivate *that = const_cast<QWidgetPrivate*>(this); | - | ||||||||||||||||||||||||||||||||||||
2159 | that->opaqueChildren = QRegion(); | - | ||||||||||||||||||||||||||||||||||||
2160 | - | |||||||||||||||||||||||||||||||||||||
2161 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
2162 | QWidget *child = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
2163 | if (!child || !child->isVisible() || child->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
2164 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2165 | - | |||||||||||||||||||||||||||||||||||||
2166 | const QPoint offset = child->geometry().topLeft(); | - | ||||||||||||||||||||||||||||||||||||
2167 | QWidgetPrivate *childd = child->d_func(); | - | ||||||||||||||||||||||||||||||||||||
2168 | QRegion r = childd->isOpaque ? child->rect() : childd->getOpaqueChildren();
| 0 | ||||||||||||||||||||||||||||||||||||
2169 | if (childd->extra && childd->extra->hasMask)
| 0 | ||||||||||||||||||||||||||||||||||||
2170 | r &= childd->extra->mask; never executed: r &= childd->extra->mask; | 0 | ||||||||||||||||||||||||||||||||||||
2171 | if (r.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
2172 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2173 | r.translate(offset); | - | ||||||||||||||||||||||||||||||||||||
2174 | that->opaqueChildren += r; | - | ||||||||||||||||||||||||||||||||||||
2175 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2176 | - | |||||||||||||||||||||||||||||||||||||
2177 | that->opaqueChildren &= q_func()->rect(); | - | ||||||||||||||||||||||||||||||||||||
2178 | that->dirtyOpaqueChildren = false; | - | ||||||||||||||||||||||||||||||||||||
2179 | - | |||||||||||||||||||||||||||||||||||||
2180 | return that->opaqueChildren; never executed: return that->opaqueChildren; | 0 | ||||||||||||||||||||||||||||||||||||
2181 | } | - | ||||||||||||||||||||||||||||||||||||
2182 | - | |||||||||||||||||||||||||||||||||||||
2183 | void QWidgetPrivate::subtractOpaqueChildren(QRegion &source, const QRect &clipRect) const | - | ||||||||||||||||||||||||||||||||||||
2184 | { | - | ||||||||||||||||||||||||||||||||||||
2185 | if (children.isEmpty() || clipRect.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
2186 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2187 | - | |||||||||||||||||||||||||||||||||||||
2188 | const QRegion &r = getOpaqueChildren(); | - | ||||||||||||||||||||||||||||||||||||
2189 | if (!r.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
2190 | source -= (r & clipRect); never executed: source -= (r & clipRect); | 0 | ||||||||||||||||||||||||||||||||||||
2191 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2192 | - | |||||||||||||||||||||||||||||||||||||
2193 | //subtract any relatives that are higher up than me --- this is too expensive !!! | - | ||||||||||||||||||||||||||||||||||||
2194 | void QWidgetPrivate::subtractOpaqueSiblings(QRegion &sourceRegion, bool *hasDirtySiblingsAbove, | - | ||||||||||||||||||||||||||||||||||||
2195 | bool alsoNonOpaque) const | - | ||||||||||||||||||||||||||||||||||||
2196 | { | - | ||||||||||||||||||||||||||||||||||||
2197 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2198 | static int disableSubtractOpaqueSiblings = qEnvironmentVariableIntValue("QT_NO_SUBTRACTOPAQUESIBLINGS"); | - | ||||||||||||||||||||||||||||||||||||
2199 | if (disableSubtractOpaqueSiblings || q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
2200 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2201 | - | |||||||||||||||||||||||||||||||||||||
2202 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2203 | if (q->d_func()->isInUnifiedToolbar) | - | ||||||||||||||||||||||||||||||||||||
2204 | return; | - | ||||||||||||||||||||||||||||||||||||
2205 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2206 | - | |||||||||||||||||||||||||||||||||||||
2207 | QRect clipBoundingRect; | - | ||||||||||||||||||||||||||||||||||||
2208 | bool dirtyClipBoundingRect = true; | - | ||||||||||||||||||||||||||||||||||||
2209 | - | |||||||||||||||||||||||||||||||||||||
2210 | QRegion parentClip; | - | ||||||||||||||||||||||||||||||||||||
2211 | bool dirtyParentClip = true; | - | ||||||||||||||||||||||||||||||||||||
2212 | - | |||||||||||||||||||||||||||||||||||||
2213 | QPoint parentOffset = data.crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
2214 | - | |||||||||||||||||||||||||||||||||||||
2215 | const QWidget *w = q; | - | ||||||||||||||||||||||||||||||||||||
2216 | - | |||||||||||||||||||||||||||||||||||||
2217 | while (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
2218 | if (w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
2219 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
2220 | QWidgetPrivate *pd = w->parentWidget()->d_func(); | - | ||||||||||||||||||||||||||||||||||||
2221 | const int myIndex = pd->children.indexOf(const_cast<QWidget *>(w)); | - | ||||||||||||||||||||||||||||||||||||
2222 | const QRect widgetGeometry = w->d_func()->effectiveRectFor(w->data->crect); | - | ||||||||||||||||||||||||||||||||||||
2223 | for (int i = myIndex + 1; i < pd->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
2224 | QWidget *sibling = qobject_cast<QWidget *>(pd->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
2225 | if (!sibling || !sibling->isVisible() || sibling->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
2226 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2227 | - | |||||||||||||||||||||||||||||||||||||
2228 | const QRect siblingGeometry = sibling->d_func()->effectiveRectFor(sibling->data->crect); | - | ||||||||||||||||||||||||||||||||||||
2229 | if (!qRectIntersects(siblingGeometry, widgetGeometry))
| 0 | ||||||||||||||||||||||||||||||||||||
2230 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2231 | - | |||||||||||||||||||||||||||||||||||||
2232 | if (dirtyClipBoundingRect) {
| 0 | ||||||||||||||||||||||||||||||||||||
2233 | clipBoundingRect = sourceRegion.boundingRect(); | - | ||||||||||||||||||||||||||||||||||||
2234 | dirtyClipBoundingRect = false; | - | ||||||||||||||||||||||||||||||||||||
2235 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2236 | - | |||||||||||||||||||||||||||||||||||||
2237 | if (!qRectIntersects(siblingGeometry, clipBoundingRect.translated(parentOffset)))
| 0 | ||||||||||||||||||||||||||||||||||||
2238 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2239 | - | |||||||||||||||||||||||||||||||||||||
2240 | if (dirtyParentClip) {
| 0 | ||||||||||||||||||||||||||||||||||||
2241 | parentClip = sourceRegion.translated(parentOffset); | - | ||||||||||||||||||||||||||||||||||||
2242 | dirtyParentClip = false; | - | ||||||||||||||||||||||||||||||||||||
2243 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2244 | - | |||||||||||||||||||||||||||||||||||||
2245 | const QPoint siblingPos(sibling->data->crect.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
2246 | const QRect siblingClipRect(sibling->d_func()->clipRect()); | - | ||||||||||||||||||||||||||||||||||||
2247 | QRegion siblingDirty(parentClip); | - | ||||||||||||||||||||||||||||||||||||
2248 | siblingDirty &= (siblingClipRect.translated(siblingPos)); | - | ||||||||||||||||||||||||||||||||||||
2249 | const bool hasMask = sibling->d_func()->extra && sibling->d_func()->extra->hasMask
| 0 | ||||||||||||||||||||||||||||||||||||
2250 | && !sibling->d_func()->graphicsEffect;
| 0 | ||||||||||||||||||||||||||||||||||||
2251 | if (hasMask)
| 0 | ||||||||||||||||||||||||||||||||||||
2252 | siblingDirty &= sibling->d_func()->extra->mask.translated(siblingPos); never executed: siblingDirty &= sibling->d_func()->extra->mask.translated(siblingPos); | 0 | ||||||||||||||||||||||||||||||||||||
2253 | if (siblingDirty.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
2254 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2255 | - | |||||||||||||||||||||||||||||||||||||
2256 | if (sibling->d_func()->isOpaque || alsoNonOpaque) {
| 0 | ||||||||||||||||||||||||||||||||||||
2257 | if (hasMask) {
| 0 | ||||||||||||||||||||||||||||||||||||
2258 | siblingDirty.translate(-parentOffset); | - | ||||||||||||||||||||||||||||||||||||
2259 | sourceRegion -= siblingDirty; | - | ||||||||||||||||||||||||||||||||||||
2260 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2261 | sourceRegion -= siblingGeometry.translated(-parentOffset); | - | ||||||||||||||||||||||||||||||||||||
2262 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2263 | } else { | - | ||||||||||||||||||||||||||||||||||||
2264 | if (hasDirtySiblingsAbove)
| 0 | ||||||||||||||||||||||||||||||||||||
2265 | *hasDirtySiblingsAbove = true; never executed: *hasDirtySiblingsAbove = true; | 0 | ||||||||||||||||||||||||||||||||||||
2266 | if (sibling->d_func()->children.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
2267 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2268 | QRegion opaqueSiblingChildren(sibling->d_func()->getOpaqueChildren()); | - | ||||||||||||||||||||||||||||||||||||
2269 | opaqueSiblingChildren.translate(-parentOffset + siblingPos); | - | ||||||||||||||||||||||||||||||||||||
2270 | sourceRegion -= opaqueSiblingChildren; | - | ||||||||||||||||||||||||||||||||||||
2271 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2272 | if (sourceRegion.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
2273 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2274 | - | |||||||||||||||||||||||||||||||||||||
2275 | dirtyClipBoundingRect = true; | - | ||||||||||||||||||||||||||||||||||||
2276 | dirtyParentClip = true; | - | ||||||||||||||||||||||||||||||||||||
2277 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2278 | - | |||||||||||||||||||||||||||||||||||||
2279 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2280 | parentOffset += pd->data.crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
2281 | dirtyParentClip = true; | - | ||||||||||||||||||||||||||||||||||||
2282 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2283 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2284 | - | |||||||||||||||||||||||||||||||||||||
2285 | void QWidgetPrivate::clipToEffectiveMask(QRegion ®ion) const | - | ||||||||||||||||||||||||||||||||||||
2286 | { | - | ||||||||||||||||||||||||||||||||||||
2287 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2288 | - | |||||||||||||||||||||||||||||||||||||
2289 | const QWidget *w = q; | - | ||||||||||||||||||||||||||||||||||||
2290 | QPoint offset; | - | ||||||||||||||||||||||||||||||||||||
2291 | - | |||||||||||||||||||||||||||||||||||||
2292 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2293 | if (graphicsEffect) {
| 0 | ||||||||||||||||||||||||||||||||||||
2294 | w = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2295 | offset -= data.crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
2296 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2297 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2298 | - | |||||||||||||||||||||||||||||||||||||
2299 | while (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
2300 | const QWidgetPrivate *wd = w->d_func(); | - | ||||||||||||||||||||||||||||||||||||
2301 | if (wd->extra && wd->extra->hasMask)
| 0 | ||||||||||||||||||||||||||||||||||||
2302 | region &= (w != q) ? wd->extra->mask.translated(offset) : wd->extra->mask; never executed: region &= (w != q) ? wd->extra->mask.translated(offset) : wd->extra->mask;
| 0 | ||||||||||||||||||||||||||||||||||||
2303 | if (w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
2304 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2305 | offset -= wd->data.crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
2306 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2307 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2308 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2309 | - | |||||||||||||||||||||||||||||||||||||
2310 | bool QWidgetPrivate::paintOnScreen() const | - | ||||||||||||||||||||||||||||||||||||
2311 | { | - | ||||||||||||||||||||||||||||||||||||
2312 | #if defined(QT_NO_BACKINGSTORE) | - | ||||||||||||||||||||||||||||||||||||
2313 | return true; | - | ||||||||||||||||||||||||||||||||||||
2314 | #else | - | ||||||||||||||||||||||||||||||||||||
2315 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2316 | if (q->testAttribute(Qt::WA_PaintOnScreen)
| 0 | ||||||||||||||||||||||||||||||||||||
2317 | || (!q->isWindow() && q->window()->testAttribute(Qt::WA_PaintOnScreen))) {
| 0 | ||||||||||||||||||||||||||||||||||||
2318 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
2319 | } | - | ||||||||||||||||||||||||||||||||||||
2320 | - | |||||||||||||||||||||||||||||||||||||
2321 | return !qt_enable_backingstore; never executed: return !qt_enable_backingstore; | 0 | ||||||||||||||||||||||||||||||||||||
2322 | #endif | - | ||||||||||||||||||||||||||||||||||||
2323 | } | - | ||||||||||||||||||||||||||||||||||||
2324 | - | |||||||||||||||||||||||||||||||||||||
2325 | void QWidgetPrivate::updateIsOpaque() | - | ||||||||||||||||||||||||||||||||||||
2326 | { | - | ||||||||||||||||||||||||||||||||||||
2327 | // hw: todo: only needed if opacity actually changed | - | ||||||||||||||||||||||||||||||||||||
2328 | setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
2329 | - | |||||||||||||||||||||||||||||||||||||
2330 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2331 | if (graphicsEffect) {
| 0 | ||||||||||||||||||||||||||||||||||||
2332 | // ### We should probably add QGraphicsEffect::isOpaque at some point. | - | ||||||||||||||||||||||||||||||||||||
2333 | setOpaque(false); | - | ||||||||||||||||||||||||||||||||||||
2334 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2335 | } | - | ||||||||||||||||||||||||||||||||||||
2336 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2337 | - | |||||||||||||||||||||||||||||||||||||
2338 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2339 | #ifdef Q_DEAD_CODE_FROM_QT4_X11 | - | ||||||||||||||||||||||||||||||||||||
2340 | if (q->testAttribute(Qt::WA_X11OpenGLOverlay)) { | - | ||||||||||||||||||||||||||||||||||||
2341 | setOpaque(false); | - | ||||||||||||||||||||||||||||||||||||
2342 | return; | - | ||||||||||||||||||||||||||||||||||||
2343 | } | - | ||||||||||||||||||||||||||||||||||||
2344 | #endif | - | ||||||||||||||||||||||||||||||||||||
2345 | - | |||||||||||||||||||||||||||||||||||||
2346 | if (q->testAttribute(Qt::WA_OpaquePaintEvent) || q->testAttribute(Qt::WA_PaintOnScreen)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2347 | setOpaque(true); | - | ||||||||||||||||||||||||||||||||||||
2348 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2349 | } | - | ||||||||||||||||||||||||||||||||||||
2350 | - | |||||||||||||||||||||||||||||||||||||
2351 | const QPalette &pal = q->palette(); | - | ||||||||||||||||||||||||||||||||||||
2352 | - | |||||||||||||||||||||||||||||||||||||
2353 | if (q->autoFillBackground()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2354 | const QBrush &autoFillBrush = pal.brush(q->backgroundRole()); | - | ||||||||||||||||||||||||||||||||||||
2355 | if (autoFillBrush.style() != Qt::NoBrush && autoFillBrush.isOpaque()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2356 | setOpaque(true); | - | ||||||||||||||||||||||||||||||||||||
2357 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2358 | } | - | ||||||||||||||||||||||||||||||||||||
2359 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2360 | - | |||||||||||||||||||||||||||||||||||||
2361 | if (q->isWindow() && !q->testAttribute(Qt::WA_NoSystemBackground)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2362 | const QBrush &windowBrush = q->palette().brush(QPalette::Window); | - | ||||||||||||||||||||||||||||||||||||
2363 | if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2364 | setOpaque(true); | - | ||||||||||||||||||||||||||||||||||||
2365 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2366 | } | - | ||||||||||||||||||||||||||||||||||||
2367 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2368 | setOpaque(false); | - | ||||||||||||||||||||||||||||||||||||
2369 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2370 | - | |||||||||||||||||||||||||||||||||||||
2371 | void QWidgetPrivate::setOpaque(bool opaque) | - | ||||||||||||||||||||||||||||||||||||
2372 | { | - | ||||||||||||||||||||||||||||||||||||
2373 | if (isOpaque != opaque) {
| 0 | ||||||||||||||||||||||||||||||||||||
2374 | isOpaque = opaque; | - | ||||||||||||||||||||||||||||||||||||
2375 | updateIsTranslucent(); | - | ||||||||||||||||||||||||||||||||||||
2376 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2377 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2378 | - | |||||||||||||||||||||||||||||||||||||
2379 | void QWidgetPrivate::updateIsTranslucent() | - | ||||||||||||||||||||||||||||||||||||
2380 | { | - | ||||||||||||||||||||||||||||||||||||
2381 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2382 | if (QWindow *window = q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2383 | QSurfaceFormat format = window->format(); | - | ||||||||||||||||||||||||||||||||||||
2384 | const int oldAlpha = format.alphaBufferSize(); | - | ||||||||||||||||||||||||||||||||||||
2385 | const int newAlpha = q->testAttribute(Qt::WA_TranslucentBackground)? 8 : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
2386 | if (oldAlpha != newAlpha) {
| 0 | ||||||||||||||||||||||||||||||||||||
2387 | format.setAlphaBufferSize(newAlpha); | - | ||||||||||||||||||||||||||||||||||||
2388 | window->setFormat(format); | - | ||||||||||||||||||||||||||||||||||||
2389 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2390 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2391 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2392 | - | |||||||||||||||||||||||||||||||||||||
2393 | static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrush &brush) | - | ||||||||||||||||||||||||||||||||||||
2394 | { | - | ||||||||||||||||||||||||||||||||||||
2395 | Q_ASSERT(painter); | - | ||||||||||||||||||||||||||||||||||||
2396 | - | |||||||||||||||||||||||||||||||||||||
2397 | if (brush.style() == Qt::TexturePattern) {
| 0 | ||||||||||||||||||||||||||||||||||||
2398 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2399 | // Optimize pattern filling on mac by using HITheme directly | - | ||||||||||||||||||||||||||||||||||||
2400 | // when filling with the standard widget background. | - | ||||||||||||||||||||||||||||||||||||
2401 | // Defined in qmacstyle_mac.cpp | - | ||||||||||||||||||||||||||||||||||||
2402 | extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush); | - | ||||||||||||||||||||||||||||||||||||
2403 | qt_mac_fill_background(painter, rgn, brush); | - | ||||||||||||||||||||||||||||||||||||
2404 | #else | - | ||||||||||||||||||||||||||||||||||||
2405 | { | - | ||||||||||||||||||||||||||||||||||||
2406 | const QRect rect(rgn.boundingRect()); | - | ||||||||||||||||||||||||||||||||||||
2407 | painter->setClipRegion(rgn); | - | ||||||||||||||||||||||||||||||||||||
2408 | painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
2409 | } | - | ||||||||||||||||||||||||||||||||||||
2410 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2411 | - | |||||||||||||||||||||||||||||||||||||
2412 | } else if (brush.gradient() never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
2413 | && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode) {
| 0 | ||||||||||||||||||||||||||||||||||||
2414 | painter->save(); | - | ||||||||||||||||||||||||||||||||||||
2415 | painter->setClipRegion(rgn); | - | ||||||||||||||||||||||||||||||||||||
2416 | painter->fillRect(0, 0, painter->device()->width(), painter->device()->height(), brush); | - | ||||||||||||||||||||||||||||||||||||
2417 | painter->restore(); | - | ||||||||||||||||||||||||||||||||||||
2418 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2419 | const QVector<QRect> &rects = rgn.rects(); | - | ||||||||||||||||||||||||||||||||||||
2420 | for (int i = 0; i < rects.size(); ++i)
| 0 | ||||||||||||||||||||||||||||||||||||
2421 | painter->fillRect(rects.at(i), brush); never executed: painter->fillRect(rects.at(i), brush); | 0 | ||||||||||||||||||||||||||||||||||||
2422 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2423 | } | - | ||||||||||||||||||||||||||||||||||||
2424 | - | |||||||||||||||||||||||||||||||||||||
2425 | void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int flags) const | - | ||||||||||||||||||||||||||||||||||||
2426 | { | - | ||||||||||||||||||||||||||||||||||||
2427 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2428 | - | |||||||||||||||||||||||||||||||||||||
2429 | #ifndef QT_NO_SCROLLAREA | - | ||||||||||||||||||||||||||||||||||||
2430 | bool resetBrushOrigin = false; | - | ||||||||||||||||||||||||||||||||||||
2431 | QPointF oldBrushOrigin; | - | ||||||||||||||||||||||||||||||||||||
2432 | //If we are painting the viewport of a scrollarea, we must apply an offset to the brush in case we are drawing a texture | - | ||||||||||||||||||||||||||||||||||||
2433 | QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent); | - | ||||||||||||||||||||||||||||||||||||
2434 | if (scrollArea && scrollArea->viewport() == q) {
| 0 | ||||||||||||||||||||||||||||||||||||
2435 | QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr.data(); | - | ||||||||||||||||||||||||||||||||||||
2436 | QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate); | - | ||||||||||||||||||||||||||||||||||||
2437 | oldBrushOrigin = painter->brushOrigin(); | - | ||||||||||||||||||||||||||||||||||||
2438 | resetBrushOrigin = true; | - | ||||||||||||||||||||||||||||||||||||
2439 | painter->setBrushOrigin(-priv->contentsOffset()); | - | ||||||||||||||||||||||||||||||||||||
2440 | - | |||||||||||||||||||||||||||||||||||||
2441 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2442 | #endif // QT_NO_SCROLLAREA | - | ||||||||||||||||||||||||||||||||||||
2443 | - | |||||||||||||||||||||||||||||||||||||
2444 | const QBrush autoFillBrush = q->palette().brush(q->backgroundRole()); | - | ||||||||||||||||||||||||||||||||||||
2445 | - | |||||||||||||||||||||||||||||||||||||
2446 | if ((flags & DrawAsRoot) && !(q->autoFillBackground() && autoFillBrush.isOpaque())) {
| 0 | ||||||||||||||||||||||||||||||||||||
2447 | const QBrush bg = q->palette().brush(QPalette::Window); | - | ||||||||||||||||||||||||||||||||||||
2448 | if (!(flags & DontSetCompositionMode)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2449 | //copy alpha straight in | - | ||||||||||||||||||||||||||||||||||||
2450 | QPainter::CompositionMode oldMode = painter->compositionMode(); | - | ||||||||||||||||||||||||||||||||||||
2451 | painter->setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||||||||||||||||||||||||||||||||
2452 | fillRegion(painter, rgn, bg); | - | ||||||||||||||||||||||||||||||||||||
2453 | painter->setCompositionMode(oldMode); | - | ||||||||||||||||||||||||||||||||||||
2454 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2455 | fillRegion(painter, rgn, bg); | - | ||||||||||||||||||||||||||||||||||||
2456 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2457 | } | - | ||||||||||||||||||||||||||||||||||||
2458 | - | |||||||||||||||||||||||||||||||||||||
2459 | if (q->autoFillBackground())
| 0 | ||||||||||||||||||||||||||||||||||||
2460 | fillRegion(painter, rgn, autoFillBrush); never executed: fillRegion(painter, rgn, autoFillBrush); | 0 | ||||||||||||||||||||||||||||||||||||
2461 | - | |||||||||||||||||||||||||||||||||||||
2462 | if (q->testAttribute(Qt::WA_StyledBackground)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2463 | painter->setClipRegion(rgn); | - | ||||||||||||||||||||||||||||||||||||
2464 | QStyleOption opt; | - | ||||||||||||||||||||||||||||||||||||
2465 | opt.initFrom(q); | - | ||||||||||||||||||||||||||||||||||||
2466 | q->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, q); | - | ||||||||||||||||||||||||||||||||||||
2467 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2468 | - | |||||||||||||||||||||||||||||||||||||
2469 | #ifndef QT_NO_SCROLLAREA | - | ||||||||||||||||||||||||||||||||||||
2470 | if (resetBrushOrigin)
| 0 | ||||||||||||||||||||||||||||||||||||
2471 | painter->setBrushOrigin(oldBrushOrigin); never executed: painter->setBrushOrigin(oldBrushOrigin); | 0 | ||||||||||||||||||||||||||||||||||||
2472 | #endif // QT_NO_SCROLLAREA | - | ||||||||||||||||||||||||||||||||||||
2473 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2474 | - | |||||||||||||||||||||||||||||||||||||
2475 | /* | - | ||||||||||||||||||||||||||||||||||||
2476 | \internal | - | ||||||||||||||||||||||||||||||||||||
2477 | This function is called when a widget is hidden or destroyed. | - | ||||||||||||||||||||||||||||||||||||
2478 | It resets some application global pointers that should only refer active, | - | ||||||||||||||||||||||||||||||||||||
2479 | visible widgets. | - | ||||||||||||||||||||||||||||||||||||
2480 | */ | - | ||||||||||||||||||||||||||||||||||||
2481 | - | |||||||||||||||||||||||||||||||||||||
2482 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2483 | extern QPointer<QWidget> qt_button_down; | - | ||||||||||||||||||||||||||||||||||||
2484 | #else | - | ||||||||||||||||||||||||||||||||||||
2485 | extern QWidget *qt_button_down; | - | ||||||||||||||||||||||||||||||||||||
2486 | #endif | - | ||||||||||||||||||||||||||||||||||||
2487 | - | |||||||||||||||||||||||||||||||||||||
2488 | void QWidgetPrivate::deactivateWidgetCleanup() | - | ||||||||||||||||||||||||||||||||||||
2489 | { | - | ||||||||||||||||||||||||||||||||||||
2490 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2491 | // If this was the active application window, reset it | - | ||||||||||||||||||||||||||||||||||||
2492 | if (QApplication::activeWindow() == q)
| 0 | ||||||||||||||||||||||||||||||||||||
2493 | QApplication::setActiveWindow(0); never executed: QApplication::setActiveWindow(0); | 0 | ||||||||||||||||||||||||||||||||||||
2494 | // If the is the active mouse press widget, reset it | - | ||||||||||||||||||||||||||||||||||||
2495 | if (q == qt_button_down)
| 0 | ||||||||||||||||||||||||||||||||||||
2496 | qt_button_down = 0; never executed: qt_button_down = 0; | 0 | ||||||||||||||||||||||||||||||||||||
2497 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2498 | - | |||||||||||||||||||||||||||||||||||||
2499 | - | |||||||||||||||||||||||||||||||||||||
2500 | /*! | - | ||||||||||||||||||||||||||||||||||||
2501 | Returns a pointer to the widget with window identifer/handle \a | - | ||||||||||||||||||||||||||||||||||||
2502 | id. | - | ||||||||||||||||||||||||||||||||||||
2503 | - | |||||||||||||||||||||||||||||||||||||
2504 | The window identifier type depends on the underlying window | - | ||||||||||||||||||||||||||||||||||||
2505 | system, see \c qwindowdefs.h for the actual definition. If there | - | ||||||||||||||||||||||||||||||||||||
2506 | is no widget with this identifier, 0 is returned. | - | ||||||||||||||||||||||||||||||||||||
2507 | */ | - | ||||||||||||||||||||||||||||||||||||
2508 | - | |||||||||||||||||||||||||||||||||||||
2509 | QWidget *QWidget::find(WId id) | - | ||||||||||||||||||||||||||||||||||||
2510 | { | - | ||||||||||||||||||||||||||||||||||||
2511 | return QWidgetPrivate::mapper ? QWidgetPrivate::mapper->value(id, 0) : 0; never executed: return QWidgetPrivate::mapper ? QWidgetPrivate::mapper->value(id, 0) : 0; | 0 | ||||||||||||||||||||||||||||||||||||
2512 | } | - | ||||||||||||||||||||||||||||||||||||
2513 | - | |||||||||||||||||||||||||||||||||||||
2514 | - | |||||||||||||||||||||||||||||||||||||
2515 | - | |||||||||||||||||||||||||||||||||||||
2516 | /*! | - | ||||||||||||||||||||||||||||||||||||
2517 | \fn WId QWidget::internalWinId() const | - | ||||||||||||||||||||||||||||||||||||
2518 | \internal | - | ||||||||||||||||||||||||||||||||||||
2519 | Returns the window system identifier of the widget, or 0 if the widget is not created yet. | - | ||||||||||||||||||||||||||||||||||||
2520 | - | |||||||||||||||||||||||||||||||||||||
2521 | */ | - | ||||||||||||||||||||||||||||||||||||
2522 | - | |||||||||||||||||||||||||||||||||||||
2523 | /*! | - | ||||||||||||||||||||||||||||||||||||
2524 | \fn WId QWidget::winId() const | - | ||||||||||||||||||||||||||||||||||||
2525 | - | |||||||||||||||||||||||||||||||||||||
2526 | Returns the window system identifier of the widget. | - | ||||||||||||||||||||||||||||||||||||
2527 | - | |||||||||||||||||||||||||||||||||||||
2528 | Portable in principle, but if you use it you are probably about to | - | ||||||||||||||||||||||||||||||||||||
2529 | do something non-portable. Be careful. | - | ||||||||||||||||||||||||||||||||||||
2530 | - | |||||||||||||||||||||||||||||||||||||
2531 | If a widget is non-native (alien) and winId() is invoked on it, that widget | - | ||||||||||||||||||||||||||||||||||||
2532 | will be provided a native handle. | - | ||||||||||||||||||||||||||||||||||||
2533 | - | |||||||||||||||||||||||||||||||||||||
2534 | On \macos, the type returned depends on which framework Qt was linked | - | ||||||||||||||||||||||||||||||||||||
2535 | against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt | - | ||||||||||||||||||||||||||||||||||||
2536 | is using Cocoa, {WId} is a pointer to an NSView. | - | ||||||||||||||||||||||||||||||||||||
2537 | - | |||||||||||||||||||||||||||||||||||||
2538 | This value may change at run-time. An event with type QEvent::WinIdChange | - | ||||||||||||||||||||||||||||||||||||
2539 | will be sent to the widget following a change in window system identifier. | - | ||||||||||||||||||||||||||||||||||||
2540 | - | |||||||||||||||||||||||||||||||||||||
2541 | \sa find() | - | ||||||||||||||||||||||||||||||||||||
2542 | */ | - | ||||||||||||||||||||||||||||||||||||
2543 | WId QWidget::winId() const | - | ||||||||||||||||||||||||||||||||||||
2544 | { | - | ||||||||||||||||||||||||||||||||||||
2545 | if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2546 | #ifdef ALIEN_DEBUG | - | ||||||||||||||||||||||||||||||||||||
2547 | qDebug() << "QWidget::winId: creating native window for" << this; | - | ||||||||||||||||||||||||||||||||||||
2548 | #endif | - | ||||||||||||||||||||||||||||||||||||
2549 | QWidget *that = const_cast<QWidget*>(this); | - | ||||||||||||||||||||||||||||||||||||
2550 | that->setAttribute(Qt::WA_NativeWindow); | - | ||||||||||||||||||||||||||||||||||||
2551 | that->d_func()->createWinId(); | - | ||||||||||||||||||||||||||||||||||||
2552 | return that->data->winid; never executed: return that->data->winid; | 0 | ||||||||||||||||||||||||||||||||||||
2553 | } | - | ||||||||||||||||||||||||||||||||||||
2554 | return data->winid; never executed: return data->winid; | 0 | ||||||||||||||||||||||||||||||||||||
2555 | } | - | ||||||||||||||||||||||||||||||||||||
2556 | - | |||||||||||||||||||||||||||||||||||||
2557 | void QWidgetPrivate::createWinId() | - | ||||||||||||||||||||||||||||||||||||
2558 | { | - | ||||||||||||||||||||||||||||||||||||
2559 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2560 | - | |||||||||||||||||||||||||||||||||||||
2561 | #ifdef ALIEN_DEBUG | - | ||||||||||||||||||||||||||||||||||||
2562 | qDebug() << "QWidgetPrivate::createWinId for" << q; | - | ||||||||||||||||||||||||||||||||||||
2563 | #endif | - | ||||||||||||||||||||||||||||||||||||
2564 | const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow); | - | ||||||||||||||||||||||||||||||||||||
2565 | if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) {
| 0 | ||||||||||||||||||||||||||||||||||||
2566 | if (!q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2567 | QWidget *parent = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2568 | QWidgetPrivate *pd = parent->d_func(); | - | ||||||||||||||||||||||||||||||||||||
2569 | if (forceNativeWindow && !q->testAttribute(Qt::WA_DontCreateNativeAncestors))
| 0 | ||||||||||||||||||||||||||||||||||||
2570 | parent->setAttribute(Qt::WA_NativeWindow); never executed: parent->setAttribute(Qt::WA_NativeWindow); | 0 | ||||||||||||||||||||||||||||||||||||
2571 | if (!parent->internalWinId()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2572 | pd->createWinId(); | - | ||||||||||||||||||||||||||||||||||||
2573 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2574 | - | |||||||||||||||||||||||||||||||||||||
2575 | for (int i = 0; i < pd->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
2576 | QWidget *w = qobject_cast<QWidget *>(pd->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
2577 | if (w && !w->isWindow() && (!w->testAttribute(Qt::WA_WState_Created)
| 0 | ||||||||||||||||||||||||||||||||||||
2578 | || (!w->internalWinId() && w->testAttribute(Qt::WA_NativeWindow)))) {
| 0 | ||||||||||||||||||||||||||||||||||||
2579 | w->create(); | - | ||||||||||||||||||||||||||||||||||||
2580 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2581 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2582 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2583 | q->create(); | - | ||||||||||||||||||||||||||||||||||||
2584 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2585 | } | - | ||||||||||||||||||||||||||||||||||||
2586 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2587 | - | |||||||||||||||||||||||||||||||||||||
2588 | - | |||||||||||||||||||||||||||||||||||||
2589 | /*! | - | ||||||||||||||||||||||||||||||||||||
2590 | \internal | - | ||||||||||||||||||||||||||||||||||||
2591 | Ensures that the widget has a window system identifier, i.e. that it is known to the windowing system. | - | ||||||||||||||||||||||||||||||||||||
2592 | - | |||||||||||||||||||||||||||||||||||||
2593 | */ | - | ||||||||||||||||||||||||||||||||||||
2594 | - | |||||||||||||||||||||||||||||||||||||
2595 | void QWidget::createWinId() | - | ||||||||||||||||||||||||||||||||||||
2596 | { | - | ||||||||||||||||||||||||||||||||||||
2597 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2598 | #ifdef ALIEN_DEBUG | - | ||||||||||||||||||||||||||||||||||||
2599 | qDebug() << "QWidget::createWinId" << this; | - | ||||||||||||||||||||||||||||||||||||
2600 | #endif | - | ||||||||||||||||||||||||||||||||||||
2601 | // qWarning("QWidget::createWinId is obsolete, please fix your code."); | - | ||||||||||||||||||||||||||||||||||||
2602 | d->createWinId(); | - | ||||||||||||||||||||||||||||||||||||
2603 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2604 | - | |||||||||||||||||||||||||||||||||||||
2605 | /*! | - | ||||||||||||||||||||||||||||||||||||
2606 | \since 4.4 | - | ||||||||||||||||||||||||||||||||||||
2607 | - | |||||||||||||||||||||||||||||||||||||
2608 | Returns the effective window system identifier of the widget, i.e. the | - | ||||||||||||||||||||||||||||||||||||
2609 | native parent's window system identifier. | - | ||||||||||||||||||||||||||||||||||||
2610 | - | |||||||||||||||||||||||||||||||||||||
2611 | If the widget is native, this function returns the native widget ID. | - | ||||||||||||||||||||||||||||||||||||
2612 | Otherwise, the window ID of the first native parent widget, i.e., the | - | ||||||||||||||||||||||||||||||||||||
2613 | top-level widget that contains this widget, is returned. | - | ||||||||||||||||||||||||||||||||||||
2614 | - | |||||||||||||||||||||||||||||||||||||
2615 | \note We recommend that you do not store this value as it is likely to | - | ||||||||||||||||||||||||||||||||||||
2616 | change at run-time. | - | ||||||||||||||||||||||||||||||||||||
2617 | - | |||||||||||||||||||||||||||||||||||||
2618 | \sa nativeParentWidget() | - | ||||||||||||||||||||||||||||||||||||
2619 | */ | - | ||||||||||||||||||||||||||||||||||||
2620 | WId QWidget::effectiveWinId() const | - | ||||||||||||||||||||||||||||||||||||
2621 | { | - | ||||||||||||||||||||||||||||||||||||
2622 | const WId id = internalWinId(); | - | ||||||||||||||||||||||||||||||||||||
2623 | if (id || !testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
2624 | return id; never executed: return id; | 0 | ||||||||||||||||||||||||||||||||||||
2625 | if (const QWidget *realParent = nativeParentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
2626 | return realParent->internalWinId(); never executed: return realParent->internalWinId(); | 0 | ||||||||||||||||||||||||||||||||||||
2627 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
2628 | } | - | ||||||||||||||||||||||||||||||||||||
2629 | - | |||||||||||||||||||||||||||||||||||||
2630 | /*! | - | ||||||||||||||||||||||||||||||||||||
2631 | If this is a native widget, return the associated QWindow. | - | ||||||||||||||||||||||||||||||||||||
2632 | Otherwise return null. | - | ||||||||||||||||||||||||||||||||||||
2633 | - | |||||||||||||||||||||||||||||||||||||
2634 | Native widgets include toplevel widgets, QGLWidget, and child widgets | - | ||||||||||||||||||||||||||||||||||||
2635 | on which winId() was called. | - | ||||||||||||||||||||||||||||||||||||
2636 | - | |||||||||||||||||||||||||||||||||||||
2637 | \since 5.0 | - | ||||||||||||||||||||||||||||||||||||
2638 | - | |||||||||||||||||||||||||||||||||||||
2639 | \sa winId() | - | ||||||||||||||||||||||||||||||||||||
2640 | */ | - | ||||||||||||||||||||||||||||||||||||
2641 | QWindow *QWidget::windowHandle() const | - | ||||||||||||||||||||||||||||||||||||
2642 | { | - | ||||||||||||||||||||||||||||||||||||
2643 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2644 | QTLWExtra *extra = d->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
2645 | if (extra)
| 0 | ||||||||||||||||||||||||||||||||||||
2646 | return extra->window; never executed: return extra->window; | 0 | ||||||||||||||||||||||||||||||||||||
2647 | - | |||||||||||||||||||||||||||||||||||||
2648 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
2649 | } | - | ||||||||||||||||||||||||||||||||||||
2650 | - | |||||||||||||||||||||||||||||||||||||
2651 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2652 | - | |||||||||||||||||||||||||||||||||||||
2653 | /*! | - | ||||||||||||||||||||||||||||||||||||
2654 | \property QWidget::styleSheet | - | ||||||||||||||||||||||||||||||||||||
2655 | \brief the widget's style sheet | - | ||||||||||||||||||||||||||||||||||||
2656 | \since 4.2 | - | ||||||||||||||||||||||||||||||||||||
2657 | - | |||||||||||||||||||||||||||||||||||||
2658 | The style sheet contains a textual description of customizations to the | - | ||||||||||||||||||||||||||||||||||||
2659 | widget's style, as described in the \l{Qt Style Sheets} document. | - | ||||||||||||||||||||||||||||||||||||
2660 | - | |||||||||||||||||||||||||||||||||||||
2661 | Since Qt 4.5, Qt style sheets fully supports \macos. | - | ||||||||||||||||||||||||||||||||||||
2662 | - | |||||||||||||||||||||||||||||||||||||
2663 | \warning Qt style sheets are currently not supported for custom QStyle | - | ||||||||||||||||||||||||||||||||||||
2664 | subclasses. We plan to address this in some future release. | - | ||||||||||||||||||||||||||||||||||||
2665 | - | |||||||||||||||||||||||||||||||||||||
2666 | \sa setStyle(), QApplication::styleSheet, {Qt Style Sheets} | - | ||||||||||||||||||||||||||||||||||||
2667 | */ | - | ||||||||||||||||||||||||||||||||||||
2668 | QString QWidget::styleSheet() const | - | ||||||||||||||||||||||||||||||||||||
2669 | { | - | ||||||||||||||||||||||||||||||||||||
2670 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2671 | if (!d->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
2672 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||||||||
2673 | return d->extra->styleSheet; never executed: return d->extra->styleSheet; | 0 | ||||||||||||||||||||||||||||||||||||
2674 | } | - | ||||||||||||||||||||||||||||||||||||
2675 | - | |||||||||||||||||||||||||||||||||||||
2676 | void QWidget::setStyleSheet(const QString& styleSheet) | - | ||||||||||||||||||||||||||||||||||||
2677 | { | - | ||||||||||||||||||||||||||||||||||||
2678 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2679 | if (data->in_destructor)
| 0 | ||||||||||||||||||||||||||||||||||||
2680 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2681 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
2682 | - | |||||||||||||||||||||||||||||||||||||
2683 | QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(d->extra->style); | - | ||||||||||||||||||||||||||||||||||||
2684 | d->extra->styleSheet = styleSheet; | - | ||||||||||||||||||||||||||||||||||||
2685 | if (styleSheet.isEmpty()) { // stylesheet removed
| 0 | ||||||||||||||||||||||||||||||||||||
2686 | if (!proxy)
| 0 | ||||||||||||||||||||||||||||||||||||
2687 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2688 | - | |||||||||||||||||||||||||||||||||||||
2689 | d->inheritStyle(); | - | ||||||||||||||||||||||||||||||||||||
2690 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2691 | } | - | ||||||||||||||||||||||||||||||||||||
2692 | - | |||||||||||||||||||||||||||||||||||||
2693 | if (proxy) { // style sheet update
| 0 | ||||||||||||||||||||||||||||||||||||
2694 | if (d->polished)
| 0 | ||||||||||||||||||||||||||||||||||||
2695 | proxy->repolish(this); never executed: proxy->repolish(this); | 0 | ||||||||||||||||||||||||||||||||||||
2696 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2697 | } | - | ||||||||||||||||||||||||||||||||||||
2698 | - | |||||||||||||||||||||||||||||||||||||
2699 | if (testAttribute(Qt::WA_SetStyle)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2700 | d->setStyle_helper(new QStyleSheetStyle(d->extra->style), true); | - | ||||||||||||||||||||||||||||||||||||
2701 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2702 | d->setStyle_helper(new QStyleSheetStyle(0), true); | - | ||||||||||||||||||||||||||||||||||||
2703 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2704 | } | - | ||||||||||||||||||||||||||||||||||||
2705 | - | |||||||||||||||||||||||||||||||||||||
2706 | #endif // QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2707 | - | |||||||||||||||||||||||||||||||||||||
2708 | /*! | - | ||||||||||||||||||||||||||||||||||||
2709 | \sa QWidget::setStyle(), QApplication::setStyle(), QApplication::style() | - | ||||||||||||||||||||||||||||||||||||
2710 | */ | - | ||||||||||||||||||||||||||||||||||||
2711 | - | |||||||||||||||||||||||||||||||||||||
2712 | QStyle *QWidget::style() const | - | ||||||||||||||||||||||||||||||||||||
2713 | { | - | ||||||||||||||||||||||||||||||||||||
2714 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2715 | - | |||||||||||||||||||||||||||||||||||||
2716 | if (d->extra && d->extra->style)
| 0 | ||||||||||||||||||||||||||||||||||||
2717 | return d->extra->style; never executed: return d->extra->style; | 0 | ||||||||||||||||||||||||||||||||||||
2718 | return QApplication::style(); never executed: return QApplication::style(); | 0 | ||||||||||||||||||||||||||||||||||||
2719 | } | - | ||||||||||||||||||||||||||||||||||||
2720 | - | |||||||||||||||||||||||||||||||||||||
2721 | /*! | - | ||||||||||||||||||||||||||||||||||||
2722 | Sets the widget's GUI style to \a style. The ownership of the style | - | ||||||||||||||||||||||||||||||||||||
2723 | object is not transferred. | - | ||||||||||||||||||||||||||||||||||||
2724 | - | |||||||||||||||||||||||||||||||||||||
2725 | If no style is set, the widget uses the application's style, | - | ||||||||||||||||||||||||||||||||||||
2726 | QApplication::style() instead. | - | ||||||||||||||||||||||||||||||||||||
2727 | - | |||||||||||||||||||||||||||||||||||||
2728 | Setting a widget's style has no effect on existing or future child | - | ||||||||||||||||||||||||||||||||||||
2729 | widgets. | - | ||||||||||||||||||||||||||||||||||||
2730 | - | |||||||||||||||||||||||||||||||||||||
2731 | \warning This function is particularly useful for demonstration | - | ||||||||||||||||||||||||||||||||||||
2732 | purposes, where you want to show Qt's styling capabilities. Real | - | ||||||||||||||||||||||||||||||||||||
2733 | applications should avoid it and use one consistent GUI style | - | ||||||||||||||||||||||||||||||||||||
2734 | instead. | - | ||||||||||||||||||||||||||||||||||||
2735 | - | |||||||||||||||||||||||||||||||||||||
2736 | \warning Qt style sheets are currently not supported for custom QStyle | - | ||||||||||||||||||||||||||||||||||||
2737 | subclasses. We plan to address this in some future release. | - | ||||||||||||||||||||||||||||||||||||
2738 | - | |||||||||||||||||||||||||||||||||||||
2739 | \sa style(), QStyle, QApplication::style(), QApplication::setStyle() | - | ||||||||||||||||||||||||||||||||||||
2740 | */ | - | ||||||||||||||||||||||||||||||||||||
2741 | - | |||||||||||||||||||||||||||||||||||||
2742 | void QWidget::setStyle(QStyle *style) | - | ||||||||||||||||||||||||||||||||||||
2743 | { | - | ||||||||||||||||||||||||||||||||||||
2744 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2745 | setAttribute(Qt::WA_SetStyle, style != 0); | - | ||||||||||||||||||||||||||||||||||||
2746 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
2747 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2748 | if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(style)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2749 | //if for some reason someone try to set a QStyleSheetStyle, ref it | - | ||||||||||||||||||||||||||||||||||||
2750 | //(this may happen for exemple in QButtonDialogBox which propagates its style) | - | ||||||||||||||||||||||||||||||||||||
2751 | proxy->ref(); | - | ||||||||||||||||||||||||||||||||||||
2752 | d->setStyle_helper(style, false); | - | ||||||||||||||||||||||||||||||||||||
2753 | } else if (qobject_cast<QStyleSheetStyle *>(d->extra->style) || !qApp->styleSheet().isEmpty()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
2754 | // if we have an application stylesheet or have a proxy already, propagate | - | ||||||||||||||||||||||||||||||||||||
2755 | d->setStyle_helper(new QStyleSheetStyle(style), true); | - | ||||||||||||||||||||||||||||||||||||
2756 | } else never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2757 | #endif | - | ||||||||||||||||||||||||||||||||||||
2758 | d->setStyle_helper(style, false); never executed: d->setStyle_helper(style, false); | 0 | ||||||||||||||||||||||||||||||||||||
2759 | } | - | ||||||||||||||||||||||||||||||||||||
2760 | - | |||||||||||||||||||||||||||||||||||||
2761 | void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool | - | ||||||||||||||||||||||||||||||||||||
2762 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2763 | metalHack | - | ||||||||||||||||||||||||||||||||||||
2764 | #endif | - | ||||||||||||||||||||||||||||||||||||
2765 | ) | - | ||||||||||||||||||||||||||||||||||||
2766 | { | - | ||||||||||||||||||||||||||||||||||||
2767 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2768 | QStyle *oldStyle = q->style(); | - | ||||||||||||||||||||||||||||||||||||
2769 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2770 | QPointer<QStyle> origStyle; | - | ||||||||||||||||||||||||||||||||||||
2771 | #endif | - | ||||||||||||||||||||||||||||||||||||
2772 | - | |||||||||||||||||||||||||||||||||||||
2773 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2774 | // the metalhack boolean allows Qt/Mac to do a proper re-polish depending | - | ||||||||||||||||||||||||||||||||||||
2775 | // on how the Qt::WA_MacBrushedMetal attribute is set. It is only ever | - | ||||||||||||||||||||||||||||||||||||
2776 | // set when changing that attribute and passes the widget's CURRENT style. | - | ||||||||||||||||||||||||||||||||||||
2777 | // therefore no need to do a reassignment. | - | ||||||||||||||||||||||||||||||||||||
2778 | if (!metalHack) | - | ||||||||||||||||||||||||||||||||||||
2779 | #endif | - | ||||||||||||||||||||||||||||||||||||
2780 | { | - | ||||||||||||||||||||||||||||||||||||
2781 | createExtra(); | - | ||||||||||||||||||||||||||||||||||||
2782 | - | |||||||||||||||||||||||||||||||||||||
2783 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2784 | origStyle = extra->style.data(); | - | ||||||||||||||||||||||||||||||||||||
2785 | #endif | - | ||||||||||||||||||||||||||||||||||||
2786 | extra->style = newStyle; | - | ||||||||||||||||||||||||||||||||||||
2787 | } | - | ||||||||||||||||||||||||||||||||||||
2788 | - | |||||||||||||||||||||||||||||||||||||
2789 | // repolish | - | ||||||||||||||||||||||||||||||||||||
2790 | if (q->windowType() != Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
2791 | if (polished) {
| 0 | ||||||||||||||||||||||||||||||||||||
2792 | oldStyle->unpolish(q); | - | ||||||||||||||||||||||||||||||||||||
2793 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2794 | if (metalHack) | - | ||||||||||||||||||||||||||||||||||||
2795 | macUpdateMetalAttribute(); | - | ||||||||||||||||||||||||||||||||||||
2796 | #endif | - | ||||||||||||||||||||||||||||||||||||
2797 | q->style()->polish(q); | - | ||||||||||||||||||||||||||||||||||||
2798 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2799 | } else if (metalHack) { | - | ||||||||||||||||||||||||||||||||||||
2800 | macUpdateMetalAttribute(); | - | ||||||||||||||||||||||||||||||||||||
2801 | #endif | - | ||||||||||||||||||||||||||||||||||||
2802 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2803 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2804 | - | |||||||||||||||||||||||||||||||||||||
2805 | if (propagate) {
| 0 | ||||||||||||||||||||||||||||||||||||
2806 | // We copy the list because the order may be modified | - | ||||||||||||||||||||||||||||||||||||
2807 | const QObjectList childrenList = children; | - | ||||||||||||||||||||||||||||||||||||
2808 | for (int i = 0; i < childrenList.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
2809 | QWidget *c = qobject_cast<QWidget*>(childrenList.at(i)); | - | ||||||||||||||||||||||||||||||||||||
2810 | if (c)
| 0 | ||||||||||||||||||||||||||||||||||||
2811 | c->d_func()->inheritStyle(); never executed: c->d_func()->inheritStyle(); | 0 | ||||||||||||||||||||||||||||||||||||
2812 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2813 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2814 | - | |||||||||||||||||||||||||||||||||||||
2815 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2816 | if (!qobject_cast<QStyleSheetStyle*>(newStyle)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2817 | if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle.data())) {
| 0 | ||||||||||||||||||||||||||||||||||||
2818 | cssStyle->clearWidgetFont(q); | - | ||||||||||||||||||||||||||||||||||||
2819 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2820 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2821 | #endif | - | ||||||||||||||||||||||||||||||||||||
2822 | - | |||||||||||||||||||||||||||||||||||||
2823 | QEvent e(QEvent::StyleChange); | - | ||||||||||||||||||||||||||||||||||||
2824 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
2825 | - | |||||||||||||||||||||||||||||||||||||
2826 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2827 | // dereference the old stylesheet style | - | ||||||||||||||||||||||||||||||||||||
2828 | if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle.data()))
| 0 | ||||||||||||||||||||||||||||||||||||
2829 | proxy->deref(); never executed: proxy->deref(); | 0 | ||||||||||||||||||||||||||||||||||||
2830 | #endif | - | ||||||||||||||||||||||||||||||||||||
2831 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2832 | - | |||||||||||||||||||||||||||||||||||||
2833 | // Inherits style from the current parent and propagates it as necessary | - | ||||||||||||||||||||||||||||||||||||
2834 | void QWidgetPrivate::inheritStyle() | - | ||||||||||||||||||||||||||||||||||||
2835 | { | - | ||||||||||||||||||||||||||||||||||||
2836 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2837 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2838 | - | |||||||||||||||||||||||||||||||||||||
2839 | QStyleSheetStyle *proxy = extra ? qobject_cast<QStyleSheetStyle *>(extra->style) : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
2840 | - | |||||||||||||||||||||||||||||||||||||
2841 | if (!q->styleSheet().isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2842 | Q_ASSERT(proxy); | - | ||||||||||||||||||||||||||||||||||||
2843 | proxy->repolish(q); | - | ||||||||||||||||||||||||||||||||||||
2844 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2845 | } | - | ||||||||||||||||||||||||||||||||||||
2846 | - | |||||||||||||||||||||||||||||||||||||
2847 | QStyle *origStyle = proxy ? proxy->base : (extra ? (QStyle*)extra->style : 0);
| 0 | ||||||||||||||||||||||||||||||||||||
2848 | QWidget *parent = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2849 | QStyle *parentStyle = (parent && parent->d_func()->extra) ? (QStyle*)parent->d_func()->extra->style : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
2850 | // If we have stylesheet on app or parent has stylesheet style, we need | - | ||||||||||||||||||||||||||||||||||||
2851 | // to be running a proxy | - | ||||||||||||||||||||||||||||||||||||
2852 | if (!qApp->styleSheet().isEmpty() || qobject_cast<QStyleSheetStyle *>(parentStyle)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2853 | QStyle *newStyle = parentStyle; | - | ||||||||||||||||||||||||||||||||||||
2854 | if (q->testAttribute(Qt::WA_SetStyle))
| 0 | ||||||||||||||||||||||||||||||||||||
2855 | newStyle = new QStyleSheetStyle(origStyle); never executed: newStyle = new QStyleSheetStyle(origStyle); | 0 | ||||||||||||||||||||||||||||||||||||
2856 | else if (QStyleSheetStyle *newProxy = qobject_cast<QStyleSheetStyle *>(parentStyle))
| 0 | ||||||||||||||||||||||||||||||||||||
2857 | newProxy->ref(); never executed: newProxy->ref(); | 0 | ||||||||||||||||||||||||||||||||||||
2858 | - | |||||||||||||||||||||||||||||||||||||
2859 | setStyle_helper(newStyle, true); | - | ||||||||||||||||||||||||||||||||||||
2860 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2861 | } | - | ||||||||||||||||||||||||||||||||||||
2862 | - | |||||||||||||||||||||||||||||||||||||
2863 | // So, we have no stylesheet on parent/app and we have an empty stylesheet | - | ||||||||||||||||||||||||||||||||||||
2864 | // we just need our original style back | - | ||||||||||||||||||||||||||||||||||||
2865 | if (origStyle == (extra ? (QStyle*)extra->style : 0)) // is it any different?
| 0 | ||||||||||||||||||||||||||||||||||||
2866 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2867 | - | |||||||||||||||||||||||||||||||||||||
2868 | // We could have inherited the proxy from our parent (which has a custom style) | - | ||||||||||||||||||||||||||||||||||||
2869 | // In such a case we need to start following the application style (i.e revert | - | ||||||||||||||||||||||||||||||||||||
2870 | // the propagation behavior of QStyleSheetStyle) | - | ||||||||||||||||||||||||||||||||||||
2871 | if (!q->testAttribute(Qt::WA_SetStyle))
| 0 | ||||||||||||||||||||||||||||||||||||
2872 | origStyle = 0; never executed: origStyle = 0; | 0 | ||||||||||||||||||||||||||||||||||||
2873 | - | |||||||||||||||||||||||||||||||||||||
2874 | setStyle_helper(origStyle, true); | - | ||||||||||||||||||||||||||||||||||||
2875 | #endif // QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2876 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2877 | - | |||||||||||||||||||||||||||||||||||||
2878 | - | |||||||||||||||||||||||||||||||||||||
2879 | /*! | - | ||||||||||||||||||||||||||||||||||||
2880 | \fn bool QWidget::isWindow() const | - | ||||||||||||||||||||||||||||||||||||
2881 | - | |||||||||||||||||||||||||||||||||||||
2882 | Returns \c true if the widget is an independent window, otherwise | - | ||||||||||||||||||||||||||||||||||||
2883 | returns \c false. | - | ||||||||||||||||||||||||||||||||||||
2884 | - | |||||||||||||||||||||||||||||||||||||
2885 | A window is a widget that isn't visually the child of any other | - | ||||||||||||||||||||||||||||||||||||
2886 | widget and that usually has a frame and a | - | ||||||||||||||||||||||||||||||||||||
2887 | \l{QWidget::setWindowTitle()}{window title}. | - | ||||||||||||||||||||||||||||||||||||
2888 | - | |||||||||||||||||||||||||||||||||||||
2889 | A window can have a \l{QWidget::parentWidget()}{parent widget}. | - | ||||||||||||||||||||||||||||||||||||
2890 | It will then be grouped with its parent and deleted when the | - | ||||||||||||||||||||||||||||||||||||
2891 | parent is deleted, minimized when the parent is minimized etc. If | - | ||||||||||||||||||||||||||||||||||||
2892 | supported by the window manager, it will also have a common | - | ||||||||||||||||||||||||||||||||||||
2893 | taskbar entry with its parent. | - | ||||||||||||||||||||||||||||||||||||
2894 | - | |||||||||||||||||||||||||||||||||||||
2895 | QDialog and QMainWindow widgets are by default windows, even if a | - | ||||||||||||||||||||||||||||||||||||
2896 | parent widget is specified in the constructor. This behavior is | - | ||||||||||||||||||||||||||||||||||||
2897 | specified by the Qt::Window flag. | - | ||||||||||||||||||||||||||||||||||||
2898 | - | |||||||||||||||||||||||||||||||||||||
2899 | \sa window(), isModal(), parentWidget() | - | ||||||||||||||||||||||||||||||||||||
2900 | */ | - | ||||||||||||||||||||||||||||||||||||
2901 | - | |||||||||||||||||||||||||||||||||||||
2902 | /*! | - | ||||||||||||||||||||||||||||||||||||
2903 | \property QWidget::modal | - | ||||||||||||||||||||||||||||||||||||
2904 | \brief whether the widget is a modal widget | - | ||||||||||||||||||||||||||||||||||||
2905 | - | |||||||||||||||||||||||||||||||||||||
2906 | This property only makes sense for windows. A modal widget | - | ||||||||||||||||||||||||||||||||||||
2907 | prevents widgets in all other windows from getting any input. | - | ||||||||||||||||||||||||||||||||||||
2908 | - | |||||||||||||||||||||||||||||||||||||
2909 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
2910 | - | |||||||||||||||||||||||||||||||||||||
2911 | \sa isWindow(), windowModality, QDialog | - | ||||||||||||||||||||||||||||||||||||
2912 | */ | - | ||||||||||||||||||||||||||||||||||||
2913 | - | |||||||||||||||||||||||||||||||||||||
2914 | /*! | - | ||||||||||||||||||||||||||||||||||||
2915 | \property QWidget::windowModality | - | ||||||||||||||||||||||||||||||||||||
2916 | \brief which windows are blocked by the modal widget | - | ||||||||||||||||||||||||||||||||||||
2917 | \since 4.1 | - | ||||||||||||||||||||||||||||||||||||
2918 | - | |||||||||||||||||||||||||||||||||||||
2919 | This property only makes sense for windows. A modal widget | - | ||||||||||||||||||||||||||||||||||||
2920 | prevents widgets in other windows from getting input. The value of | - | ||||||||||||||||||||||||||||||||||||
2921 | this property controls which windows are blocked when the widget | - | ||||||||||||||||||||||||||||||||||||
2922 | is visible. Changing this property while the window is visible has | - | ||||||||||||||||||||||||||||||||||||
2923 | no effect; you must hide() the widget first, then show() it again. | - | ||||||||||||||||||||||||||||||||||||
2924 | - | |||||||||||||||||||||||||||||||||||||
2925 | By default, this property is Qt::NonModal. | - | ||||||||||||||||||||||||||||||||||||
2926 | - | |||||||||||||||||||||||||||||||||||||
2927 | \sa isWindow(), QWidget::modal, QDialog | - | ||||||||||||||||||||||||||||||||||||
2928 | */ | - | ||||||||||||||||||||||||||||||||||||
2929 | - | |||||||||||||||||||||||||||||||||||||
2930 | Qt::WindowModality QWidget::windowModality() const | - | ||||||||||||||||||||||||||||||||||||
2931 | { | - | ||||||||||||||||||||||||||||||||||||
2932 | return static_cast<Qt::WindowModality>(data->window_modality); never executed: return static_cast<Qt::WindowModality>(data->window_modality); | 0 | ||||||||||||||||||||||||||||||||||||
2933 | } | - | ||||||||||||||||||||||||||||||||||||
2934 | - | |||||||||||||||||||||||||||||||||||||
2935 | void QWidget::setWindowModality(Qt::WindowModality windowModality) | - | ||||||||||||||||||||||||||||||||||||
2936 | { | - | ||||||||||||||||||||||||||||||||||||
2937 | data->window_modality = windowModality; | - | ||||||||||||||||||||||||||||||||||||
2938 | // setModal_sys() will be called by setAttribute() | - | ||||||||||||||||||||||||||||||||||||
2939 | setAttribute(Qt::WA_ShowModal, (data->window_modality != Qt::NonModal)); | - | ||||||||||||||||||||||||||||||||||||
2940 | setAttribute(Qt::WA_SetWindowModality, true); | - | ||||||||||||||||||||||||||||||||||||
2941 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2942 | - | |||||||||||||||||||||||||||||||||||||
2943 | void QWidgetPrivate::setModal_sys() | - | ||||||||||||||||||||||||||||||||||||
2944 | { | - | ||||||||||||||||||||||||||||||||||||
2945 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2946 | if (q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
2947 | q->windowHandle()->setModality(q->windowModality()); never executed: q->windowHandle()->setModality(q->windowModality()); | 0 | ||||||||||||||||||||||||||||||||||||
2948 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2949 | - | |||||||||||||||||||||||||||||||||||||
2950 | /*! | - | ||||||||||||||||||||||||||||||||||||
2951 | \fn bool QWidget::underMouse() const | - | ||||||||||||||||||||||||||||||||||||
2952 | - | |||||||||||||||||||||||||||||||||||||
2953 | Returns \c true if the widget is under the mouse cursor; otherwise | - | ||||||||||||||||||||||||||||||||||||
2954 | returns \c false. | - | ||||||||||||||||||||||||||||||||||||
2955 | - | |||||||||||||||||||||||||||||||||||||
2956 | This value is not updated properly during drag and drop | - | ||||||||||||||||||||||||||||||||||||
2957 | operations. | - | ||||||||||||||||||||||||||||||||||||
2958 | - | |||||||||||||||||||||||||||||||||||||
2959 | \sa enterEvent(), leaveEvent() | - | ||||||||||||||||||||||||||||||||||||
2960 | */ | - | ||||||||||||||||||||||||||||||||||||
2961 | - | |||||||||||||||||||||||||||||||||||||
2962 | /*! | - | ||||||||||||||||||||||||||||||||||||
2963 | \property QWidget::minimized | - | ||||||||||||||||||||||||||||||||||||
2964 | \brief whether this widget is minimized (iconified) | - | ||||||||||||||||||||||||||||||||||||
2965 | - | |||||||||||||||||||||||||||||||||||||
2966 | This property is only relevant for windows. | - | ||||||||||||||||||||||||||||||||||||
2967 | - | |||||||||||||||||||||||||||||||||||||
2968 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
2969 | - | |||||||||||||||||||||||||||||||||||||
2970 | \sa showMinimized(), visible, show(), hide(), showNormal(), maximized | - | ||||||||||||||||||||||||||||||||||||
2971 | */ | - | ||||||||||||||||||||||||||||||||||||
2972 | bool QWidget::isMinimized() const | - | ||||||||||||||||||||||||||||||||||||
2973 | { never executed: return data->window_state & Qt::WindowMinimized; }return data->window_state & Qt::WindowMinimized; never executed: return data->window_state & Qt::WindowMinimized; | 0 | ||||||||||||||||||||||||||||||||||||
2974 | - | |||||||||||||||||||||||||||||||||||||
2975 | /*! | - | ||||||||||||||||||||||||||||||||||||
2976 | Shows the widget minimized, as an icon. | - | ||||||||||||||||||||||||||||||||||||
2977 | - | |||||||||||||||||||||||||||||||||||||
2978 | Calling this function only affects \l{isWindow()}{windows}. | - | ||||||||||||||||||||||||||||||||||||
2979 | - | |||||||||||||||||||||||||||||||||||||
2980 | \sa showNormal(), showMaximized(), show(), hide(), isVisible(), | - | ||||||||||||||||||||||||||||||||||||
2981 | isMinimized() | - | ||||||||||||||||||||||||||||||||||||
2982 | */ | - | ||||||||||||||||||||||||||||||||||||
2983 | void QWidget::showMinimized() | - | ||||||||||||||||||||||||||||||||||||
2984 | { | - | ||||||||||||||||||||||||||||||||||||
2985 | bool isMin = isMinimized(); | - | ||||||||||||||||||||||||||||||||||||
2986 | if (isMin && isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
2987 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2988 | - | |||||||||||||||||||||||||||||||||||||
2989 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
2990 | - | |||||||||||||||||||||||||||||||||||||
2991 | if (!isMin)
| 0 | ||||||||||||||||||||||||||||||||||||
2992 | setWindowState((windowState() & ~Qt::WindowActive) | Qt::WindowMinimized); never executed: setWindowState((windowState() & ~Qt::WindowActive) | Qt::WindowMinimized); | 0 | ||||||||||||||||||||||||||||||||||||
2993 | setVisible(true); | - | ||||||||||||||||||||||||||||||||||||
2994 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2995 | - | |||||||||||||||||||||||||||||||||||||
2996 | /*! | - | ||||||||||||||||||||||||||||||||||||
2997 | \property QWidget::maximized | - | ||||||||||||||||||||||||||||||||||||
2998 | \brief whether this widget is maximized | - | ||||||||||||||||||||||||||||||||||||
2999 | - | |||||||||||||||||||||||||||||||||||||
3000 | This property is only relevant for windows. | - | ||||||||||||||||||||||||||||||||||||
3001 | - | |||||||||||||||||||||||||||||||||||||
3002 | \note Due to limitations on some window systems, this does not always | - | ||||||||||||||||||||||||||||||||||||
3003 | report the expected results (e.g., if the user on X11 maximizes the | - | ||||||||||||||||||||||||||||||||||||
3004 | window via the window manager, Qt has no way of distinguishing this | - | ||||||||||||||||||||||||||||||||||||
3005 | from any other resize). This is expected to improve as window manager | - | ||||||||||||||||||||||||||||||||||||
3006 | protocols evolve. | - | ||||||||||||||||||||||||||||||||||||
3007 | - | |||||||||||||||||||||||||||||||||||||
3008 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
3009 | - | |||||||||||||||||||||||||||||||||||||
3010 | \sa windowState(), showMaximized(), visible, show(), hide(), showNormal(), minimized | - | ||||||||||||||||||||||||||||||||||||
3011 | */ | - | ||||||||||||||||||||||||||||||||||||
3012 | bool QWidget::isMaximized() const | - | ||||||||||||||||||||||||||||||||||||
3013 | { never executed: return data->window_state & Qt::WindowMaximized; }return data->window_state & Qt::WindowMaximized; never executed: return data->window_state & Qt::WindowMaximized; | 0 | ||||||||||||||||||||||||||||||||||||
3014 | - | |||||||||||||||||||||||||||||||||||||
3015 | - | |||||||||||||||||||||||||||||||||||||
3016 | - | |||||||||||||||||||||||||||||||||||||
3017 | /*! | - | ||||||||||||||||||||||||||||||||||||
3018 | Returns the current window state. The window state is a OR'ed | - | ||||||||||||||||||||||||||||||||||||
3019 | combination of Qt::WindowState: Qt::WindowMinimized, | - | ||||||||||||||||||||||||||||||||||||
3020 | Qt::WindowMaximized, Qt::WindowFullScreen, and Qt::WindowActive. | - | ||||||||||||||||||||||||||||||||||||
3021 | - | |||||||||||||||||||||||||||||||||||||
3022 | \sa Qt::WindowState, setWindowState() | - | ||||||||||||||||||||||||||||||||||||
3023 | */ | - | ||||||||||||||||||||||||||||||||||||
3024 | Qt::WindowStates QWidget::windowState() const | - | ||||||||||||||||||||||||||||||||||||
3025 | { | - | ||||||||||||||||||||||||||||||||||||
3026 | return Qt::WindowStates(data->window_state); never executed: return Qt::WindowStates(data->window_state); | 0 | ||||||||||||||||||||||||||||||||||||
3027 | } | - | ||||||||||||||||||||||||||||||||||||
3028 | - | |||||||||||||||||||||||||||||||||||||
3029 | /*!\internal | - | ||||||||||||||||||||||||||||||||||||
3030 | - | |||||||||||||||||||||||||||||||||||||
3031 | The function sets the window state on child widgets similar to | - | ||||||||||||||||||||||||||||||||||||
3032 | setWindowState(). The difference is that the window state changed | - | ||||||||||||||||||||||||||||||||||||
3033 | event has the isOverride() flag set. It exists mainly to keep | - | ||||||||||||||||||||||||||||||||||||
3034 | QWorkspace working. | - | ||||||||||||||||||||||||||||||||||||
3035 | */ | - | ||||||||||||||||||||||||||||||||||||
3036 | void QWidget::overrideWindowState(Qt::WindowStates newstate) | - | ||||||||||||||||||||||||||||||||||||
3037 | { | - | ||||||||||||||||||||||||||||||||||||
3038 | QWindowStateChangeEvent e(Qt::WindowStates(data->window_state), true); | - | ||||||||||||||||||||||||||||||||||||
3039 | data->window_state = newstate; | - | ||||||||||||||||||||||||||||||||||||
3040 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
3041 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3042 | - | |||||||||||||||||||||||||||||||||||||
3043 | Qt::WindowState effectiveState(Qt::WindowStates state) | - | ||||||||||||||||||||||||||||||||||||
3044 | { | - | ||||||||||||||||||||||||||||||||||||
3045 | if (state & Qt::WindowMinimized)
| 0 | ||||||||||||||||||||||||||||||||||||
3046 | return Qt::WindowMinimized; never executed: return Qt::WindowMinimized; | 0 | ||||||||||||||||||||||||||||||||||||
3047 | else if (state & Qt::WindowFullScreen)
| 0 | ||||||||||||||||||||||||||||||||||||
3048 | return Qt::WindowFullScreen; never executed: return Qt::WindowFullScreen; | 0 | ||||||||||||||||||||||||||||||||||||
3049 | else if (state & Qt::WindowMaximized)
| 0 | ||||||||||||||||||||||||||||||||||||
3050 | return Qt::WindowMaximized; never executed: return Qt::WindowMaximized; | 0 | ||||||||||||||||||||||||||||||||||||
3051 | return Qt::WindowNoState; never executed: return Qt::WindowNoState; | 0 | ||||||||||||||||||||||||||||||||||||
3052 | } | - | ||||||||||||||||||||||||||||||||||||
3053 | - | |||||||||||||||||||||||||||||||||||||
3054 | /*! | - | ||||||||||||||||||||||||||||||||||||
3055 | \fn void QWidget::setWindowState(Qt::WindowStates windowState) | - | ||||||||||||||||||||||||||||||||||||
3056 | - | |||||||||||||||||||||||||||||||||||||
3057 | Sets the window state to \a windowState. The window state is a OR'ed | - | ||||||||||||||||||||||||||||||||||||
3058 | combination of Qt::WindowState: Qt::WindowMinimized, | - | ||||||||||||||||||||||||||||||||||||
3059 | Qt::WindowMaximized, Qt::WindowFullScreen, and Qt::WindowActive. | - | ||||||||||||||||||||||||||||||||||||
3060 | - | |||||||||||||||||||||||||||||||||||||
3061 | If the window is not visible (i.e. isVisible() returns \c false), the | - | ||||||||||||||||||||||||||||||||||||
3062 | window state will take effect when show() is called. For visible | - | ||||||||||||||||||||||||||||||||||||
3063 | windows, the change is immediate. For example, to toggle between | - | ||||||||||||||||||||||||||||||||||||
3064 | full-screen and normal mode, use the following code: | - | ||||||||||||||||||||||||||||||||||||
3065 | - | |||||||||||||||||||||||||||||||||||||
3066 | \snippet code/src_gui_kernel_qwidget.cpp 0 | - | ||||||||||||||||||||||||||||||||||||
3067 | - | |||||||||||||||||||||||||||||||||||||
3068 | In order to restore and activate a minimized window (while | - | ||||||||||||||||||||||||||||||||||||
3069 | preserving its maximized and/or full-screen state), use the following: | - | ||||||||||||||||||||||||||||||||||||
3070 | - | |||||||||||||||||||||||||||||||||||||
3071 | \snippet code/src_gui_kernel_qwidget.cpp 1 | - | ||||||||||||||||||||||||||||||||||||
3072 | - | |||||||||||||||||||||||||||||||||||||
3073 | Calling this function will hide the widget. You must call show() to make | - | ||||||||||||||||||||||||||||||||||||
3074 | the widget visible again. | - | ||||||||||||||||||||||||||||||||||||
3075 | - | |||||||||||||||||||||||||||||||||||||
3076 | \note On some window systems Qt::WindowActive is not immediate, and may be | - | ||||||||||||||||||||||||||||||||||||
3077 | ignored in certain cases. | - | ||||||||||||||||||||||||||||||||||||
3078 | - | |||||||||||||||||||||||||||||||||||||
3079 | When the window state changes, the widget receives a changeEvent() | - | ||||||||||||||||||||||||||||||||||||
3080 | of type QEvent::WindowStateChange. | - | ||||||||||||||||||||||||||||||||||||
3081 | - | |||||||||||||||||||||||||||||||||||||
3082 | \sa Qt::WindowState, windowState() | - | ||||||||||||||||||||||||||||||||||||
3083 | */ | - | ||||||||||||||||||||||||||||||||||||
3084 | void QWidget::setWindowState(Qt::WindowStates newstate) | - | ||||||||||||||||||||||||||||||||||||
3085 | { | - | ||||||||||||||||||||||||||||||||||||
3086 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3087 | Qt::WindowStates oldstate = windowState(); | - | ||||||||||||||||||||||||||||||||||||
3088 | if (oldstate == newstate)
| 0 | ||||||||||||||||||||||||||||||||||||
3089 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
3090 | if (isWindow() && !testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
3091 | create(); never executed: create(); | 0 | ||||||||||||||||||||||||||||||||||||
3092 | - | |||||||||||||||||||||||||||||||||||||
3093 | data->window_state = newstate; | - | ||||||||||||||||||||||||||||||||||||
3094 | data->in_set_window_state = 1; | - | ||||||||||||||||||||||||||||||||||||
3095 | Qt::WindowState newEffectiveState = effectiveState(newstate); | - | ||||||||||||||||||||||||||||||||||||
3096 | Qt::WindowState oldEffectiveState = effectiveState(oldstate); | - | ||||||||||||||||||||||||||||||||||||
3097 | if (isWindow() && newEffectiveState != oldEffectiveState) {
| 0 | ||||||||||||||||||||||||||||||||||||
3098 | // Ensure the initial size is valid, since we store it as normalGeometry below. | - | ||||||||||||||||||||||||||||||||||||
3099 | if (!testAttribute(Qt::WA_Resized) && !isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
3100 | adjustSize(); never executed: adjustSize(); | 0 | ||||||||||||||||||||||||||||||||||||
3101 | - | |||||||||||||||||||||||||||||||||||||
3102 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
3103 | if (oldEffectiveState == Qt::WindowNoState)
| 0 | ||||||||||||||||||||||||||||||||||||
3104 | d->topData()->normalGeometry = geometry(); never executed: d->topData()->normalGeometry = geometry(); | 0 | ||||||||||||||||||||||||||||||||||||
3105 | - | |||||||||||||||||||||||||||||||||||||
3106 | Q_ASSERT(windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
3107 | windowHandle()->setWindowState(newEffectiveState); | - | ||||||||||||||||||||||||||||||||||||
3108 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3109 | data->in_set_window_state = 0; | - | ||||||||||||||||||||||||||||||||||||
3110 | - | |||||||||||||||||||||||||||||||||||||
3111 | if (newstate & Qt::WindowActive)
| 0 | ||||||||||||||||||||||||||||||||||||
3112 | activateWindow(); never executed: activateWindow(); | 0 | ||||||||||||||||||||||||||||||||||||
3113 | - | |||||||||||||||||||||||||||||||||||||
3114 | QWindowStateChangeEvent e(oldstate); | - | ||||||||||||||||||||||||||||||||||||
3115 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
3116 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3117 | - | |||||||||||||||||||||||||||||||||||||
3118 | /*! | - | ||||||||||||||||||||||||||||||||||||
3119 | \property QWidget::fullScreen | - | ||||||||||||||||||||||||||||||||||||
3120 | \brief whether the widget is shown in full screen mode | - | ||||||||||||||||||||||||||||||||||||
3121 | - | |||||||||||||||||||||||||||||||||||||
3122 | A widget in full screen mode occupies the whole screen area and does not | - | ||||||||||||||||||||||||||||||||||||
3123 | display window decorations, such as a title bar. | - | ||||||||||||||||||||||||||||||||||||
3124 | - | |||||||||||||||||||||||||||||||||||||
3125 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
3126 | - | |||||||||||||||||||||||||||||||||||||
3127 | \sa windowState(), minimized, maximized | - | ||||||||||||||||||||||||||||||||||||
3128 | */ | - | ||||||||||||||||||||||||||||||||||||
3129 | bool QWidget::isFullScreen() const | - | ||||||||||||||||||||||||||||||||||||
3130 | { never executed: return data->window_state & Qt::WindowFullScreen; }return data->window_state & Qt::WindowFullScreen; never executed: return data->window_state & Qt::WindowFullScreen; | 0 | ||||||||||||||||||||||||||||||||||||
3131 | - | |||||||||||||||||||||||||||||||||||||
3132 | /*! | - | ||||||||||||||||||||||||||||||||||||
3133 | Shows the widget in full-screen mode. | - | ||||||||||||||||||||||||||||||||||||
3134 | - | |||||||||||||||||||||||||||||||||||||
3135 | Calling this function only affects \l{isWindow()}{windows}. | - | ||||||||||||||||||||||||||||||||||||
3136 | - | |||||||||||||||||||||||||||||||||||||
3137 | To return from full-screen mode, call showNormal(). | - | ||||||||||||||||||||||||||||||||||||
3138 | - | |||||||||||||||||||||||||||||||||||||
3139 | Full-screen mode works fine under Windows, but has certain | - | ||||||||||||||||||||||||||||||||||||
3140 | problems under X. These problems are due to limitations of the | - | ||||||||||||||||||||||||||||||||||||
3141 | ICCCM protocol that specifies the communication between X11 | - | ||||||||||||||||||||||||||||||||||||
3142 | clients and the window manager. ICCCM simply does not understand | - | ||||||||||||||||||||||||||||||||||||
3143 | the concept of non-decorated full-screen windows. Therefore, the | - | ||||||||||||||||||||||||||||||||||||
3144 | best we can do is to request a borderless window and place and | - | ||||||||||||||||||||||||||||||||||||
3145 | resize it to fill the entire screen. Depending on the window | - | ||||||||||||||||||||||||||||||||||||
3146 | manager, this may or may not work. The borderless window is | - | ||||||||||||||||||||||||||||||||||||
3147 | requested using MOTIF hints, which are at least partially | - | ||||||||||||||||||||||||||||||||||||
3148 | supported by virtually all modern window managers. | - | ||||||||||||||||||||||||||||||||||||
3149 | - | |||||||||||||||||||||||||||||||||||||
3150 | An alternative would be to bypass the window manager entirely and | - | ||||||||||||||||||||||||||||||||||||
3151 | create a window with the Qt::X11BypassWindowManagerHint flag. This | - | ||||||||||||||||||||||||||||||||||||
3152 | has other severe problems though, like totally broken keyboard focus | - | ||||||||||||||||||||||||||||||||||||
3153 | and very strange effects on desktop changes or when the user raises | - | ||||||||||||||||||||||||||||||||||||
3154 | other windows. | - | ||||||||||||||||||||||||||||||||||||
3155 | - | |||||||||||||||||||||||||||||||||||||
3156 | X11 window managers that follow modern post-ICCCM specifications | - | ||||||||||||||||||||||||||||||||||||
3157 | support full-screen mode properly. | - | ||||||||||||||||||||||||||||||||||||
3158 | - | |||||||||||||||||||||||||||||||||||||
3159 | \sa showNormal(), showMaximized(), show(), hide(), isVisible() | - | ||||||||||||||||||||||||||||||||||||
3160 | */ | - | ||||||||||||||||||||||||||||||||||||
3161 | void QWidget::showFullScreen() | - | ||||||||||||||||||||||||||||||||||||
3162 | { | - | ||||||||||||||||||||||||||||||||||||
3163 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
3164 | // If the unified toolbar is enabled, we have to disable it before going fullscreen. | - | ||||||||||||||||||||||||||||||||||||
3165 | QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); | - | ||||||||||||||||||||||||||||||||||||
3166 | if (mainWindow && mainWindow->unifiedTitleAndToolBarOnMac()) { | - | ||||||||||||||||||||||||||||||||||||
3167 | mainWindow->setUnifiedTitleAndToolBarOnMac(false); | - | ||||||||||||||||||||||||||||||||||||
3168 | QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); | - | ||||||||||||||||||||||||||||||||||||
3169 | mainLayout->activateUnifiedToolbarAfterFullScreen = true; | - | ||||||||||||||||||||||||||||||||||||
3170 | } | - | ||||||||||||||||||||||||||||||||||||
3171 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
3172 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
3173 | - | |||||||||||||||||||||||||||||||||||||
3174 | setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowMaximized)) | - | ||||||||||||||||||||||||||||||||||||
3175 | | Qt::WindowFullScreen); | - | ||||||||||||||||||||||||||||||||||||
3176 | setVisible(true); | - | ||||||||||||||||||||||||||||||||||||
3177 | #if !defined Q_OS_QNX // On QNX this window will be activated anyway from libscreen | - | ||||||||||||||||||||||||||||||||||||
3178 | // activating it here before libscreen activates it causes problems | - | ||||||||||||||||||||||||||||||||||||
3179 | activateWindow(); | - | ||||||||||||||||||||||||||||||||||||
3180 | #endif | - | ||||||||||||||||||||||||||||||||||||
3181 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3182 | - | |||||||||||||||||||||||||||||||||||||
3183 | /*! | - | ||||||||||||||||||||||||||||||||||||
3184 | Shows the widget maximized. | - | ||||||||||||||||||||||||||||||||||||
3185 | - | |||||||||||||||||||||||||||||||||||||
3186 | Calling this function only affects \l{isWindow()}{windows}. | - | ||||||||||||||||||||||||||||||||||||
3187 | - | |||||||||||||||||||||||||||||||||||||
3188 | On X11, this function may not work properly with certain window | - | ||||||||||||||||||||||||||||||||||||
3189 | managers. See the \l{Window Geometry} documentation for an explanation. | - | ||||||||||||||||||||||||||||||||||||
3190 | - | |||||||||||||||||||||||||||||||||||||
3191 | \sa setWindowState(), showNormal(), showMinimized(), show(), hide(), isVisible() | - | ||||||||||||||||||||||||||||||||||||
3192 | */ | - | ||||||||||||||||||||||||||||||||||||
3193 | void QWidget::showMaximized() | - | ||||||||||||||||||||||||||||||||||||
3194 | { | - | ||||||||||||||||||||||||||||||||||||
3195 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
3196 | - | |||||||||||||||||||||||||||||||||||||
3197 | setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen)) | - | ||||||||||||||||||||||||||||||||||||
3198 | | Qt::WindowMaximized); | - | ||||||||||||||||||||||||||||||||||||
3199 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
3200 | // If the unified toolbar was enabled before going fullscreen, we have to enable it back. | - | ||||||||||||||||||||||||||||||||||||
3201 | QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); | - | ||||||||||||||||||||||||||||||||||||
3202 | if (mainWindow) | - | ||||||||||||||||||||||||||||||||||||
3203 | { | - | ||||||||||||||||||||||||||||||||||||
3204 | QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); | - | ||||||||||||||||||||||||||||||||||||
3205 | if (mainLayout->activateUnifiedToolbarAfterFullScreen) { | - | ||||||||||||||||||||||||||||||||||||
3206 | mainWindow->setUnifiedTitleAndToolBarOnMac(true); | - | ||||||||||||||||||||||||||||||||||||
3207 | mainLayout->activateUnifiedToolbarAfterFullScreen = false; | - | ||||||||||||||||||||||||||||||||||||
3208 | } | - | ||||||||||||||||||||||||||||||||||||
3209 | } | - | ||||||||||||||||||||||||||||||||||||
3210 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
3211 | setVisible(true); | - | ||||||||||||||||||||||||||||||||||||
3212 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3213 | - | |||||||||||||||||||||||||||||||||||||
3214 | /*! | - | ||||||||||||||||||||||||||||||||||||
3215 | Restores the widget after it has been maximized or minimized. | - | ||||||||||||||||||||||||||||||||||||
3216 | - | |||||||||||||||||||||||||||||||||||||
3217 | Calling this function only affects \l{isWindow()}{windows}. | - | ||||||||||||||||||||||||||||||||||||
3218 | - | |||||||||||||||||||||||||||||||||||||
3219 | \sa setWindowState(), showMinimized(), showMaximized(), show(), hide(), isVisible() | - | ||||||||||||||||||||||||||||||||||||
3220 | */ | - | ||||||||||||||||||||||||||||||||||||
3221 | void QWidget::showNormal() | - | ||||||||||||||||||||||||||||||||||||
3222 | { | - | ||||||||||||||||||||||||||||||||||||
3223 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
3224 | - | |||||||||||||||||||||||||||||||||||||
3225 | setWindowState(windowState() & ~(Qt::WindowMinimized | - | ||||||||||||||||||||||||||||||||||||
3226 | | Qt::WindowMaximized | - | ||||||||||||||||||||||||||||||||||||
3227 | | Qt::WindowFullScreen)); | - | ||||||||||||||||||||||||||||||||||||
3228 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
3229 | // If the unified toolbar was enabled before going fullscreen, we have to enable it back. | - | ||||||||||||||||||||||||||||||||||||
3230 | QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); | - | ||||||||||||||||||||||||||||||||||||
3231 | if (mainWindow) | - | ||||||||||||||||||||||||||||||||||||
3232 | { | - | ||||||||||||||||||||||||||||||||||||
3233 | QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); | - | ||||||||||||||||||||||||||||||||||||
3234 | if (mainLayout->activateUnifiedToolbarAfterFullScreen) { | - | ||||||||||||||||||||||||||||||||||||
3235 | mainWindow->setUnifiedTitleAndToolBarOnMac(true); | - | ||||||||||||||||||||||||||||||||||||
3236 | mainLayout->activateUnifiedToolbarAfterFullScreen = false; | - | ||||||||||||||||||||||||||||||||||||
3237 | } | - | ||||||||||||||||||||||||||||||||||||
3238 | } | - | ||||||||||||||||||||||||||||||||||||
3239 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
3240 | setVisible(true); | - | ||||||||||||||||||||||||||||||||||||
3241 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3242 | - | |||||||||||||||||||||||||||||||||||||
3243 | /*! | - | ||||||||||||||||||||||||||||||||||||
3244 | Returns \c true if this widget would become enabled if \a ancestor is | - | ||||||||||||||||||||||||||||||||||||
3245 | enabled; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
3246 | - | |||||||||||||||||||||||||||||||||||||
3247 | - | |||||||||||||||||||||||||||||||||||||
3248 | - | |||||||||||||||||||||||||||||||||||||
3249 | This is the case if neither the widget itself nor every parent up | - | ||||||||||||||||||||||||||||||||||||
3250 | to but excluding \a ancestor has been explicitly disabled. | - | ||||||||||||||||||||||||||||||||||||
3251 | - | |||||||||||||||||||||||||||||||||||||
3252 | isEnabledTo(0) returns false if this widget or any if its ancestors | - | ||||||||||||||||||||||||||||||||||||
3253 | was explicitly disabled. | - | ||||||||||||||||||||||||||||||||||||
3254 | - | |||||||||||||||||||||||||||||||||||||
3255 | The word ancestor here means a parent widget within the same window. | - | ||||||||||||||||||||||||||||||||||||
3256 | - | |||||||||||||||||||||||||||||||||||||
3257 | Therefore isEnabledTo(0) stops at this widget's window, unlike | - | ||||||||||||||||||||||||||||||||||||
3258 | isEnabled() which also takes parent windows into considerations. | - | ||||||||||||||||||||||||||||||||||||
3259 | - | |||||||||||||||||||||||||||||||||||||
3260 | \sa setEnabled(), enabled | - | ||||||||||||||||||||||||||||||||||||
3261 | */ | - | ||||||||||||||||||||||||||||||||||||
3262 | - | |||||||||||||||||||||||||||||||||||||
3263 | bool QWidget::isEnabledTo(const QWidget *ancestor) const | - | ||||||||||||||||||||||||||||||||||||
3264 | { | - | ||||||||||||||||||||||||||||||||||||
3265 | const QWidget * w = this; | - | ||||||||||||||||||||||||||||||||||||
3266 | while (!w->testAttribute(Qt::WA_ForceDisabled)
| 0 | ||||||||||||||||||||||||||||||||||||
3267 | && !w->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
3268 | && w->parentWidget()
| 0 | ||||||||||||||||||||||||||||||||||||
3269 | && w->parentWidget() != ancestor)
| 0 | ||||||||||||||||||||||||||||||||||||
3270 | w = w->parentWidget(); never executed: w = w->parentWidget(); | 0 | ||||||||||||||||||||||||||||||||||||
3271 | return !w->testAttribute(Qt::WA_ForceDisabled); never executed: return !w->testAttribute(Qt::WA_ForceDisabled); | 0 | ||||||||||||||||||||||||||||||||||||
3272 | } | - | ||||||||||||||||||||||||||||||||||||
3273 | - | |||||||||||||||||||||||||||||||||||||
3274 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||||||||||||||
3275 | /*! | - | ||||||||||||||||||||||||||||||||||||
3276 | Appends the action \a action to this widget's list of actions. | - | ||||||||||||||||||||||||||||||||||||
3277 | - | |||||||||||||||||||||||||||||||||||||
3278 | All QWidgets have a list of \l{QAction}s, however they can be | - | ||||||||||||||||||||||||||||||||||||
3279 | represented graphically in many different ways. The default use of | - | ||||||||||||||||||||||||||||||||||||
3280 | the QAction list (as returned by actions()) is to create a context | - | ||||||||||||||||||||||||||||||||||||
3281 | QMenu. | - | ||||||||||||||||||||||||||||||||||||
3282 | - | |||||||||||||||||||||||||||||||||||||
3283 | A QWidget should only have one of each action and adding an action | - | ||||||||||||||||||||||||||||||||||||
3284 | it already has will not cause the same action to be in the widget twice. | - | ||||||||||||||||||||||||||||||||||||
3285 | - | |||||||||||||||||||||||||||||||||||||
3286 | The ownership of \a action is not transferred to this QWidget. | - | ||||||||||||||||||||||||||||||||||||
3287 | - | |||||||||||||||||||||||||||||||||||||
3288 | \sa removeAction(), insertAction(), actions(), QMenu | - | ||||||||||||||||||||||||||||||||||||
3289 | */ | - | ||||||||||||||||||||||||||||||||||||
3290 | void QWidget::addAction(QAction *action) | - | ||||||||||||||||||||||||||||||||||||
3291 | { | - | ||||||||||||||||||||||||||||||||||||
3292 | insertAction(0, action); | - | ||||||||||||||||||||||||||||||||||||
3293 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3294 | - | |||||||||||||||||||||||||||||||||||||
3295 | /*! | - | ||||||||||||||||||||||||||||||||||||
3296 | Appends the actions \a actions to this widget's list of actions. | - | ||||||||||||||||||||||||||||||||||||
3297 | - | |||||||||||||||||||||||||||||||||||||
3298 | \sa removeAction(), QMenu, addAction() | - | ||||||||||||||||||||||||||||||||||||
3299 | */ | - | ||||||||||||||||||||||||||||||||||||
3300 | #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) | - | ||||||||||||||||||||||||||||||||||||
3301 | void QWidget::addActions(const QList<QAction *> &actions) | - | ||||||||||||||||||||||||||||||||||||
3302 | #else | - | ||||||||||||||||||||||||||||||||||||
3303 | void QWidget::addActions(QList<QAction*> actions) | - | ||||||||||||||||||||||||||||||||||||
3304 | #endif | - | ||||||||||||||||||||||||||||||||||||
3305 | { | - | ||||||||||||||||||||||||||||||||||||
3306 | for(int i = 0; i < actions.count(); i++)
| 0 | ||||||||||||||||||||||||||||||||||||
3307 | insertAction(0, actions.at(i)); never executed: insertAction(0, actions.at(i)); | 0 | ||||||||||||||||||||||||||||||||||||
3308 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3309 | - | |||||||||||||||||||||||||||||||||||||
3310 | /*! | - | ||||||||||||||||||||||||||||||||||||
3311 | Inserts the action \a action to this widget's list of actions, | - | ||||||||||||||||||||||||||||||||||||
3312 | before the action \a before. It appends the action if \a before is 0 or | - | ||||||||||||||||||||||||||||||||||||
3313 | \a before is not a valid action for this widget. | - | ||||||||||||||||||||||||||||||||||||
3314 | - | |||||||||||||||||||||||||||||||||||||
3315 | A QWidget should only have one of each action. | - | ||||||||||||||||||||||||||||||||||||
3316 | - | |||||||||||||||||||||||||||||||||||||
3317 | \sa removeAction(), addAction(), QMenu, contextMenuPolicy, actions() | - | ||||||||||||||||||||||||||||||||||||
3318 | */ | - | ||||||||||||||||||||||||||||||||||||
3319 | void QWidget::insertAction(QAction *before, QAction *action) | - | ||||||||||||||||||||||||||||||||||||
3320 | { | - | ||||||||||||||||||||||||||||||||||||
3321 | if (Q_UNLIKELY(!action)) {
| 0 | ||||||||||||||||||||||||||||||||||||
3322 | qWarning("QWidget::insertAction: Attempt to insert null action"); | - | ||||||||||||||||||||||||||||||||||||
3323 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
3324 | } | - | ||||||||||||||||||||||||||||||||||||
3325 | - | |||||||||||||||||||||||||||||||||||||
3326 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3327 | if(d->actions.contains(action))
| 0 | ||||||||||||||||||||||||||||||||||||
3328 | removeAction(action); never executed: removeAction(action); | 0 | ||||||||||||||||||||||||||||||||||||
3329 | - | |||||||||||||||||||||||||||||||||||||
3330 | int pos = d->actions.indexOf(before); | - | ||||||||||||||||||||||||||||||||||||
3331 | if (pos < 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
3332 | before = 0; | - | ||||||||||||||||||||||||||||||||||||
3333 | pos = d->actions.size(); | - | ||||||||||||||||||||||||||||||||||||
3334 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3335 | d->actions.insert(pos, action); | - | ||||||||||||||||||||||||||||||||||||
3336 | - | |||||||||||||||||||||||||||||||||||||
3337 | QActionPrivate *apriv = action->d_func(); | - | ||||||||||||||||||||||||||||||||||||
3338 | apriv->widgets.append(this); | - | ||||||||||||||||||||||||||||||||||||
3339 | - | |||||||||||||||||||||||||||||||||||||
3340 | QActionEvent e(QEvent::ActionAdded, action, before); | - | ||||||||||||||||||||||||||||||||||||
3341 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
3342 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3343 | - | |||||||||||||||||||||||||||||||||||||
3344 | /*! | - | ||||||||||||||||||||||||||||||||||||
3345 | Inserts the actions \a actions to this widget's list of actions, | - | ||||||||||||||||||||||||||||||||||||
3346 | before the action \a before. It appends the action if \a before is 0 or | - | ||||||||||||||||||||||||||||||||||||
3347 | \a before is not a valid action for this widget. | - | ||||||||||||||||||||||||||||||||||||
3348 | - | |||||||||||||||||||||||||||||||||||||
3349 | A QWidget can have at most one of each action. | - | ||||||||||||||||||||||||||||||||||||
3350 | - | |||||||||||||||||||||||||||||||||||||
3351 | \sa removeAction(), QMenu, insertAction(), contextMenuPolicy | - | ||||||||||||||||||||||||||||||||||||
3352 | */ | - | ||||||||||||||||||||||||||||||||||||
3353 | #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) | - | ||||||||||||||||||||||||||||||||||||
3354 | void QWidget::insertActions(QAction *before, const QList<QAction*> &actions) | - | ||||||||||||||||||||||||||||||||||||
3355 | #else | - | ||||||||||||||||||||||||||||||||||||
3356 | void QWidget::insertActions(QAction *before, QList<QAction*> actions) | - | ||||||||||||||||||||||||||||||||||||
3357 | #endif | - | ||||||||||||||||||||||||||||||||||||
3358 | { | - | ||||||||||||||||||||||||||||||||||||
3359 | for(int i = 0; i < actions.count(); ++i)
| 0 | ||||||||||||||||||||||||||||||||||||
3360 | insertAction(before, actions.at(i)); never executed: insertAction(before, actions.at(i)); | 0 | ||||||||||||||||||||||||||||||||||||
3361 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3362 | - | |||||||||||||||||||||||||||||||||||||
3363 | /*! | - | ||||||||||||||||||||||||||||||||||||
3364 | Removes the action \a action from this widget's list of actions. | - | ||||||||||||||||||||||||||||||||||||
3365 | \sa insertAction(), actions(), insertAction() | - | ||||||||||||||||||||||||||||||||||||
3366 | */ | - | ||||||||||||||||||||||||||||||||||||
3367 | void QWidget::removeAction(QAction *action) | - | ||||||||||||||||||||||||||||||||||||
3368 | { | - | ||||||||||||||||||||||||||||||||||||
3369 | if (!action)
| 0 | ||||||||||||||||||||||||||||||||||||
3370 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
3371 | - | |||||||||||||||||||||||||||||||||||||
3372 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3373 | - | |||||||||||||||||||||||||||||||||||||
3374 | QActionPrivate *apriv = action->d_func(); | - | ||||||||||||||||||||||||||||||||||||
3375 | apriv->widgets.removeAll(this); | - | ||||||||||||||||||||||||||||||||||||
3376 | - | |||||||||||||||||||||||||||||||||||||
3377 | if (d->actions.removeAll(action)) {
| 0 | ||||||||||||||||||||||||||||||||||||
3378 | QActionEvent e(QEvent::ActionRemoved, action); | - | ||||||||||||||||||||||||||||||||||||
3379 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
3380 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3381 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3382 | - | |||||||||||||||||||||||||||||||||||||
3383 | /*! | - | ||||||||||||||||||||||||||||||||||||
3384 | Returns the (possibly empty) list of this widget's actions. | - | ||||||||||||||||||||||||||||||||||||
3385 | - | |||||||||||||||||||||||||||||||||||||
3386 | \sa contextMenuPolicy, insertAction(), removeAction() | - | ||||||||||||||||||||||||||||||||||||
3387 | */ | - | ||||||||||||||||||||||||||||||||||||
3388 | QList<QAction*> QWidget::actions() const | - | ||||||||||||||||||||||||||||||||||||
3389 | { | - | ||||||||||||||||||||||||||||||||||||
3390 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3391 | return d->actions; never executed: return d->actions; | 0 | ||||||||||||||||||||||||||||||||||||
3392 | } | - | ||||||||||||||||||||||||||||||||||||
3393 | #endif // QT_NO_ACTION | - | ||||||||||||||||||||||||||||||||||||
3394 | - | |||||||||||||||||||||||||||||||||||||
3395 | /*! | - | ||||||||||||||||||||||||||||||||||||
3396 | \fn bool QWidget::isEnabledToTLW() const | - | ||||||||||||||||||||||||||||||||||||
3397 | \obsolete | - | ||||||||||||||||||||||||||||||||||||
3398 | - | |||||||||||||||||||||||||||||||||||||
3399 | This function is deprecated. It is equivalent to isEnabled() | - | ||||||||||||||||||||||||||||||||||||
3400 | */ | - | ||||||||||||||||||||||||||||||||||||
3401 | - | |||||||||||||||||||||||||||||||||||||
3402 | /*! | - | ||||||||||||||||||||||||||||||||||||
3403 | \property QWidget::enabled | - | ||||||||||||||||||||||||||||||||||||
3404 | \brief whether the widget is enabled | - | ||||||||||||||||||||||||||||||||||||
3405 | - | |||||||||||||||||||||||||||||||||||||
3406 | In general an enabled widget handles keyboard and mouse events; a disabled | - | ||||||||||||||||||||||||||||||||||||
3407 | widget does not. An exception is made with \l{QAbstractButton}. | - | ||||||||||||||||||||||||||||||||||||
3408 | - | |||||||||||||||||||||||||||||||||||||
3409 | Some widgets display themselves differently when they are | - | ||||||||||||||||||||||||||||||||||||
3410 | disabled. For example a button might draw its label grayed out. If | - | ||||||||||||||||||||||||||||||||||||
3411 | your widget needs to know when it becomes enabled or disabled, you | - | ||||||||||||||||||||||||||||||||||||
3412 | can use the changeEvent() with type QEvent::EnabledChange. | - | ||||||||||||||||||||||||||||||||||||
3413 | - | |||||||||||||||||||||||||||||||||||||
3414 | Disabling a widget implicitly disables all its children. Enabling | - | ||||||||||||||||||||||||||||||||||||
3415 | respectively enables all child widgets unless they have been | - | ||||||||||||||||||||||||||||||||||||
3416 | explicitly disabled. It it not possible to explicitly enable a child | - | ||||||||||||||||||||||||||||||||||||
3417 | widget which is not a window while its parent widget remains disabled. | - | ||||||||||||||||||||||||||||||||||||
3418 | - | |||||||||||||||||||||||||||||||||||||
3419 | By default, this property is \c true. | - | ||||||||||||||||||||||||||||||||||||
3420 | - | |||||||||||||||||||||||||||||||||||||
3421 | \sa isEnabledTo(), QKeyEvent, QMouseEvent, changeEvent() | - | ||||||||||||||||||||||||||||||||||||
3422 | */ | - | ||||||||||||||||||||||||||||||||||||
3423 | void QWidget::setEnabled(bool enable) | - | ||||||||||||||||||||||||||||||||||||
3424 | { | - | ||||||||||||||||||||||||||||||||||||
3425 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3426 | setAttribute(Qt::WA_ForceDisabled, !enable); | - | ||||||||||||||||||||||||||||||||||||
3427 | d->setEnabled_helper(enable); | - | ||||||||||||||||||||||||||||||||||||
3428 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3429 | - | |||||||||||||||||||||||||||||||||||||
3430 | void QWidgetPrivate::setEnabled_helper(bool enable) | - | ||||||||||||||||||||||||||||||||||||
3431 | { | - | ||||||||||||||||||||||||||||||||||||
3432 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3433 | - | |||||||||||||||||||||||||||||||||||||
3434 | if (enable && !q->isWindow() && q->parentWidget() && !q->parentWidget()->isEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
3435 | return; // nothing we can do never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
3436 | - | |||||||||||||||||||||||||||||||||||||
3437 | if (enable != q->testAttribute(Qt::WA_Disabled))
| 0 | ||||||||||||||||||||||||||||||||||||
3438 | return; // nothing to do never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
3439 | - | |||||||||||||||||||||||||||||||||||||
3440 | q->setAttribute(Qt::WA_Disabled, !enable); | - | ||||||||||||||||||||||||||||||||||||
3441 | updateSystemBackground(); | - | ||||||||||||||||||||||||||||||||||||
3442 | - | |||||||||||||||||||||||||||||||||||||
3443 | if (!enable && q->window()->focusWidget() == q) {
| 0 | ||||||||||||||||||||||||||||||||||||
3444 | bool parentIsEnabled = (!q->parentWidget() || q->parentWidget()->isEnabled());
| 0 | ||||||||||||||||||||||||||||||||||||
3445 | if (!parentIsEnabled || !q->focusNextChild())
| 0 | ||||||||||||||||||||||||||||||||||||
3446 | q->clearFocus(); never executed: q->clearFocus(); | 0 | ||||||||||||||||||||||||||||||||||||
3447 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3448 | - | |||||||||||||||||||||||||||||||||||||
3449 | Qt::WidgetAttribute attribute = enable ? Qt::WA_ForceDisabled : Qt::WA_Disabled;
| 0 | ||||||||||||||||||||||||||||||||||||
3450 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
3451 | QWidget *w = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
3452 | if (w && !w->testAttribute(attribute))
| 0 | ||||||||||||||||||||||||||||||||||||
3453 | w->d_func()->setEnabled_helper(enable); never executed: w->d_func()->setEnabled_helper(enable); | 0 | ||||||||||||||||||||||||||||||||||||
3454 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3455 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
3456 | if (q->testAttribute(Qt::WA_SetCursor) || q->isWindow()) { | - | ||||||||||||||||||||||||||||||||||||
3457 | // enforce the windows behavior of clearing the cursor on | - | ||||||||||||||||||||||||||||||||||||
3458 | // disabled widgets | - | ||||||||||||||||||||||||||||||||||||
3459 | qt_x11_enforce_cursor(q); | - | ||||||||||||||||||||||||||||||||||||
3460 | } | - | ||||||||||||||||||||||||||||||||||||
3461 | #endif | - | ||||||||||||||||||||||||||||||||||||
3462 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
3463 | if (q->testAttribute(Qt::WA_SetCursor) || q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
3464 | // enforce the windows behavior of clearing the cursor on | - | ||||||||||||||||||||||||||||||||||||
3465 | // disabled widgets | - | ||||||||||||||||||||||||||||||||||||
3466 | qt_qpa_set_cursor(q, false); | - | ||||||||||||||||||||||||||||||||||||
3467 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3468 | #endif | - | ||||||||||||||||||||||||||||||||||||
3469 | #if defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
3470 | setEnabled_helper_sys(enable); | - | ||||||||||||||||||||||||||||||||||||
3471 | #endif | - | ||||||||||||||||||||||||||||||||||||
3472 | #ifndef QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
3473 | if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) {
| 0 | ||||||||||||||||||||||||||||||||||||
3474 | QWidget *focusWidget = effectiveFocusWidget(); | - | ||||||||||||||||||||||||||||||||||||
3475 | - | |||||||||||||||||||||||||||||||||||||
3476 | if (enable) {
| 0 | ||||||||||||||||||||||||||||||||||||
3477 | if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
| 0 | ||||||||||||||||||||||||||||||||||||
3478 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); never executed: QGuiApplication::inputMethod()->update(Qt::ImEnabled); | 0 | ||||||||||||||||||||||||||||||||||||
3479 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3480 | QGuiApplication::inputMethod()->commit(); | - | ||||||||||||||||||||||||||||||||||||
3481 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); | - | ||||||||||||||||||||||||||||||||||||
3482 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3483 | } | - | ||||||||||||||||||||||||||||||||||||
3484 | #endif //QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
3485 | QEvent e(QEvent::EnabledChange); | - | ||||||||||||||||||||||||||||||||||||
3486 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
3487 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3488 | - | |||||||||||||||||||||||||||||||||||||
3489 | /*! | - | ||||||||||||||||||||||||||||||||||||
3490 | \property QWidget::acceptDrops | - | ||||||||||||||||||||||||||||||||||||
3491 | \brief whether drop events are enabled for this widget | - | ||||||||||||||||||||||||||||||||||||
3492 | - | |||||||||||||||||||||||||||||||||||||
3493 | Setting this property to true announces to the system that this | - | ||||||||||||||||||||||||||||||||||||
3494 | widget \e may be able to accept drop events. | - | ||||||||||||||||||||||||||||||||||||
3495 | - | |||||||||||||||||||||||||||||||||||||
3496 | If the widget is the desktop (windowType() == Qt::Desktop), this may | - | ||||||||||||||||||||||||||||||||||||
3497 | fail if another application is using the desktop; you can call | - | ||||||||||||||||||||||||||||||||||||
3498 | acceptDrops() to test if this occurs. | - | ||||||||||||||||||||||||||||||||||||
3499 | - | |||||||||||||||||||||||||||||||||||||
3500 | \warning Do not modify this property in a drag and drop event handler. | - | ||||||||||||||||||||||||||||||||||||
3501 | - | |||||||||||||||||||||||||||||||||||||
3502 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
3503 | - | |||||||||||||||||||||||||||||||||||||
3504 | \sa {Drag and Drop} | - | ||||||||||||||||||||||||||||||||||||
3505 | */ | - | ||||||||||||||||||||||||||||||||||||
3506 | bool QWidget::acceptDrops() const | - | ||||||||||||||||||||||||||||||||||||
3507 | { | - | ||||||||||||||||||||||||||||||||||||
3508 | return testAttribute(Qt::WA_AcceptDrops); never executed: return testAttribute(Qt::WA_AcceptDrops); | 0 | ||||||||||||||||||||||||||||||||||||
3509 | } | - | ||||||||||||||||||||||||||||||||||||
3510 | - | |||||||||||||||||||||||||||||||||||||
3511 | void QWidget::setAcceptDrops(bool on) | - | ||||||||||||||||||||||||||||||||||||
3512 | { | - | ||||||||||||||||||||||||||||||||||||
3513 | setAttribute(Qt::WA_AcceptDrops, on); | - | ||||||||||||||||||||||||||||||||||||
3514 | - | |||||||||||||||||||||||||||||||||||||
3515 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3516 | - | |||||||||||||||||||||||||||||||||||||
3517 | void QWidgetPrivate::registerDropSite(bool on) | - | ||||||||||||||||||||||||||||||||||||
3518 | { | - | ||||||||||||||||||||||||||||||||||||
3519 | Q_UNUSED(on); | - | ||||||||||||||||||||||||||||||||||||
3520 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3521 | - | |||||||||||||||||||||||||||||||||||||
3522 | /*! | - | ||||||||||||||||||||||||||||||||||||
3523 | Disables widget input events if \a disable is true; otherwise | - | ||||||||||||||||||||||||||||||||||||
3524 | enables input events. | - | ||||||||||||||||||||||||||||||||||||
3525 | - | |||||||||||||||||||||||||||||||||||||
3526 | See the \l enabled documentation for more information. | - | ||||||||||||||||||||||||||||||||||||
3527 | - | |||||||||||||||||||||||||||||||||||||
3528 | \sa isEnabledTo(), QKeyEvent, QMouseEvent, changeEvent() | - | ||||||||||||||||||||||||||||||||||||
3529 | */ | - | ||||||||||||||||||||||||||||||||||||
3530 | void QWidget::setDisabled(bool disable) | - | ||||||||||||||||||||||||||||||||||||
3531 | { | - | ||||||||||||||||||||||||||||||||||||
3532 | setEnabled(!disable); | - | ||||||||||||||||||||||||||||||||||||
3533 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3534 | - | |||||||||||||||||||||||||||||||||||||
3535 | /*! | - | ||||||||||||||||||||||||||||||||||||
3536 | \property QWidget::frameGeometry | - | ||||||||||||||||||||||||||||||||||||
3537 | \brief geometry of the widget relative to its parent including any | - | ||||||||||||||||||||||||||||||||||||
3538 | window frame | - | ||||||||||||||||||||||||||||||||||||
3539 | - | |||||||||||||||||||||||||||||||||||||
3540 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3541 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3542 | - | |||||||||||||||||||||||||||||||||||||
3543 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
3544 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
3545 | - | |||||||||||||||||||||||||||||||||||||
3546 | \sa geometry(), x(), y(), pos() | - | ||||||||||||||||||||||||||||||||||||
3547 | */ | - | ||||||||||||||||||||||||||||||||||||
3548 | QRect QWidget::frameGeometry() const | - | ||||||||||||||||||||||||||||||||||||
3549 | { | - | ||||||||||||||||||||||||||||||||||||
3550 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3551 | if (isWindow() && ! (windowType() == Qt::Popup)) {
| 0 | ||||||||||||||||||||||||||||||||||||
3552 | QRect fs = d->frameStrut(); | - | ||||||||||||||||||||||||||||||||||||
3553 | return QRect(data->crect.x() - fs.left(), never executed: return QRect(data->crect.x() - fs.left(), data->crect.y() - fs.top(), data->crect.width() + fs.left() + fs.right(), data->crect.height() + fs.top() + fs.bottom()); | 0 | ||||||||||||||||||||||||||||||||||||
3554 | data->crect.y() - fs.top(), never executed: return QRect(data->crect.x() - fs.left(), data->crect.y() - fs.top(), data->crect.width() + fs.left() + fs.right(), data->crect.height() + fs.top() + fs.bottom()); | 0 | ||||||||||||||||||||||||||||||||||||
3555 | data->crect.width() + fs.left() + fs.right(), never executed: return QRect(data->crect.x() - fs.left(), data->crect.y() - fs.top(), data->crect.width() + fs.left() + fs.right(), data->crect.height() + fs.top() + fs.bottom()); | 0 | ||||||||||||||||||||||||||||||||||||
3556 | data->crect.height() + fs.top() + fs.bottom()); never executed: return QRect(data->crect.x() - fs.left(), data->crect.y() - fs.top(), data->crect.width() + fs.left() + fs.right(), data->crect.height() + fs.top() + fs.bottom()); | 0 | ||||||||||||||||||||||||||||||||||||
3557 | } | - | ||||||||||||||||||||||||||||||||||||
3558 | return data->crect; never executed: return data->crect; | 0 | ||||||||||||||||||||||||||||||||||||
3559 | } | - | ||||||||||||||||||||||||||||||||||||
3560 | - | |||||||||||||||||||||||||||||||||||||
3561 | /*! | - | ||||||||||||||||||||||||||||||||||||
3562 | \property QWidget::x | - | ||||||||||||||||||||||||||||||||||||
3563 | - | |||||||||||||||||||||||||||||||||||||
3564 | \brief the x coordinate of the widget relative to its parent including | - | ||||||||||||||||||||||||||||||||||||
3565 | any window frame | - | ||||||||||||||||||||||||||||||||||||
3566 | - | |||||||||||||||||||||||||||||||||||||
3567 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3568 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3569 | - | |||||||||||||||||||||||||||||||||||||
3570 | By default, this property has a value of 0. | - | ||||||||||||||||||||||||||||||||||||
3571 | - | |||||||||||||||||||||||||||||||||||||
3572 | \sa frameGeometry, y, pos | - | ||||||||||||||||||||||||||||||||||||
3573 | */ | - | ||||||||||||||||||||||||||||||||||||
3574 | int QWidget::x() const | - | ||||||||||||||||||||||||||||||||||||
3575 | { | - | ||||||||||||||||||||||||||||||||||||
3576 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3577 | if (isWindow() && ! (windowType() == Qt::Popup))
| 0 | ||||||||||||||||||||||||||||||||||||
3578 | return data->crect.x() - d->frameStrut().left(); never executed: return data->crect.x() - d->frameStrut().left(); | 0 | ||||||||||||||||||||||||||||||||||||
3579 | return data->crect.x(); never executed: return data->crect.x(); | 0 | ||||||||||||||||||||||||||||||||||||
3580 | } | - | ||||||||||||||||||||||||||||||||||||
3581 | - | |||||||||||||||||||||||||||||||||||||
3582 | /*! | - | ||||||||||||||||||||||||||||||||||||
3583 | \property QWidget::y | - | ||||||||||||||||||||||||||||||||||||
3584 | \brief the y coordinate of the widget relative to its parent and | - | ||||||||||||||||||||||||||||||||||||
3585 | including any window frame | - | ||||||||||||||||||||||||||||||||||||
3586 | - | |||||||||||||||||||||||||||||||||||||
3587 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3588 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3589 | - | |||||||||||||||||||||||||||||||||||||
3590 | By default, this property has a value of 0. | - | ||||||||||||||||||||||||||||||||||||
3591 | - | |||||||||||||||||||||||||||||||||||||
3592 | \sa frameGeometry, x, pos | - | ||||||||||||||||||||||||||||||||||||
3593 | */ | - | ||||||||||||||||||||||||||||||||||||
3594 | int QWidget::y() const | - | ||||||||||||||||||||||||||||||||||||
3595 | { | - | ||||||||||||||||||||||||||||||||||||
3596 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3597 | if (isWindow() && ! (windowType() == Qt::Popup))
| 0 | ||||||||||||||||||||||||||||||||||||
3598 | return data->crect.y() - d->frameStrut().top(); never executed: return data->crect.y() - d->frameStrut().top(); | 0 | ||||||||||||||||||||||||||||||||||||
3599 | return data->crect.y(); never executed: return data->crect.y(); | 0 | ||||||||||||||||||||||||||||||||||||
3600 | } | - | ||||||||||||||||||||||||||||||||||||
3601 | - | |||||||||||||||||||||||||||||||||||||
3602 | /*! | - | ||||||||||||||||||||||||||||||||||||
3603 | \property QWidget::pos | - | ||||||||||||||||||||||||||||||||||||
3604 | \brief the position of the widget within its parent widget | - | ||||||||||||||||||||||||||||||||||||
3605 | - | |||||||||||||||||||||||||||||||||||||
3606 | If the widget is a window, the position is that of the widget on | - | ||||||||||||||||||||||||||||||||||||
3607 | the desktop, including its frame. | - | ||||||||||||||||||||||||||||||||||||
3608 | - | |||||||||||||||||||||||||||||||||||||
3609 | When changing the position, the widget, if visible, receives a | - | ||||||||||||||||||||||||||||||||||||
3610 | move event (moveEvent()) immediately. If the widget is not | - | ||||||||||||||||||||||||||||||||||||
3611 | currently visible, it is guaranteed to receive an event before it | - | ||||||||||||||||||||||||||||||||||||
3612 | is shown. | - | ||||||||||||||||||||||||||||||||||||
3613 | - | |||||||||||||||||||||||||||||||||||||
3614 | By default, this property contains a position that refers to the | - | ||||||||||||||||||||||||||||||||||||
3615 | origin. | - | ||||||||||||||||||||||||||||||||||||
3616 | - | |||||||||||||||||||||||||||||||||||||
3617 | \warning Calling move() or setGeometry() inside moveEvent() can | - | ||||||||||||||||||||||||||||||||||||
3618 | lead to infinite recursion. | - | ||||||||||||||||||||||||||||||||||||
3619 | - | |||||||||||||||||||||||||||||||||||||
3620 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3621 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3622 | - | |||||||||||||||||||||||||||||||||||||
3623 | \sa frameGeometry, size, x(), y() | - | ||||||||||||||||||||||||||||||||||||
3624 | */ | - | ||||||||||||||||||||||||||||||||||||
3625 | QPoint QWidget::pos() const | - | ||||||||||||||||||||||||||||||||||||
3626 | { | - | ||||||||||||||||||||||||||||||||||||
3627 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3628 | QPoint result = data->crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
3629 | if (isWindow() && ! (windowType() == Qt::Popup))
| 0 | ||||||||||||||||||||||||||||||||||||
3630 | if (!d->maybeTopData() || !d->maybeTopData()->posIncludesFrame)
| 0 | ||||||||||||||||||||||||||||||||||||
3631 | result -= d->frameStrut().topLeft(); never executed: result -= d->frameStrut().topLeft(); | 0 | ||||||||||||||||||||||||||||||||||||
3632 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||||||||||||||
3633 | } | - | ||||||||||||||||||||||||||||||||||||
3634 | - | |||||||||||||||||||||||||||||||||||||
3635 | /*! | - | ||||||||||||||||||||||||||||||||||||
3636 | \property QWidget::geometry | - | ||||||||||||||||||||||||||||||||||||
3637 | \brief the geometry of the widget relative to its parent and | - | ||||||||||||||||||||||||||||||||||||
3638 | excluding the window frame | - | ||||||||||||||||||||||||||||||||||||
3639 | - | |||||||||||||||||||||||||||||||||||||
3640 | When changing the geometry, the widget, if visible, receives a | - | ||||||||||||||||||||||||||||||||||||
3641 | move event (moveEvent()) and/or a resize event (resizeEvent()) | - | ||||||||||||||||||||||||||||||||||||
3642 | immediately. If the widget is not currently visible, it is | - | ||||||||||||||||||||||||||||||||||||
3643 | guaranteed to receive appropriate events before it is shown. | - | ||||||||||||||||||||||||||||||||||||
3644 | - | |||||||||||||||||||||||||||||||||||||
3645 | The size component is adjusted if it lies outside the range | - | ||||||||||||||||||||||||||||||||||||
3646 | defined by minimumSize() and maximumSize(). | - | ||||||||||||||||||||||||||||||||||||
3647 | - | |||||||||||||||||||||||||||||||||||||
3648 | \warning Calling setGeometry() inside resizeEvent() or moveEvent() | - | ||||||||||||||||||||||||||||||||||||
3649 | can lead to infinite recursion. | - | ||||||||||||||||||||||||||||||||||||
3650 | - | |||||||||||||||||||||||||||||||||||||
3651 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3652 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3653 | - | |||||||||||||||||||||||||||||||||||||
3654 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
3655 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
3656 | - | |||||||||||||||||||||||||||||||||||||
3657 | \sa frameGeometry(), rect(), move(), resize(), moveEvent(), | - | ||||||||||||||||||||||||||||||||||||
3658 | resizeEvent(), minimumSize(), maximumSize() | - | ||||||||||||||||||||||||||||||||||||
3659 | */ | - | ||||||||||||||||||||||||||||||||||||
3660 | - | |||||||||||||||||||||||||||||||||||||
3661 | /*! | - | ||||||||||||||||||||||||||||||||||||
3662 | \property QWidget::normalGeometry | - | ||||||||||||||||||||||||||||||||||||
3663 | - | |||||||||||||||||||||||||||||||||||||
3664 | \brief the geometry of the widget as it will appear when shown as | - | ||||||||||||||||||||||||||||||||||||
3665 | a normal (not maximized or full screen) top-level widget | - | ||||||||||||||||||||||||||||||||||||
3666 | - | |||||||||||||||||||||||||||||||||||||
3667 | For child widgets this property always holds an empty rectangle. | - | ||||||||||||||||||||||||||||||||||||
3668 | - | |||||||||||||||||||||||||||||||||||||
3669 | By default, this property contains an empty rectangle. | - | ||||||||||||||||||||||||||||||||||||
3670 | - | |||||||||||||||||||||||||||||||||||||
3671 | \sa QWidget::windowState(), QWidget::geometry | - | ||||||||||||||||||||||||||||||||||||
3672 | */ | - | ||||||||||||||||||||||||||||||||||||
3673 | - | |||||||||||||||||||||||||||||||||||||
3674 | /*! | - | ||||||||||||||||||||||||||||||||||||
3675 | \property QWidget::size | - | ||||||||||||||||||||||||||||||||||||
3676 | \brief the size of the widget excluding any window frame | - | ||||||||||||||||||||||||||||||||||||
3677 | - | |||||||||||||||||||||||||||||||||||||
3678 | If the widget is visible when it is being resized, it receives a resize event | - | ||||||||||||||||||||||||||||||||||||
3679 | (resizeEvent()) immediately. If the widget is not currently | - | ||||||||||||||||||||||||||||||||||||
3680 | visible, it is guaranteed to receive an event before it is shown. | - | ||||||||||||||||||||||||||||||||||||
3681 | - | |||||||||||||||||||||||||||||||||||||
3682 | The size is adjusted if it lies outside the range defined by | - | ||||||||||||||||||||||||||||||||||||
3683 | minimumSize() and maximumSize(). | - | ||||||||||||||||||||||||||||||||||||
3684 | - | |||||||||||||||||||||||||||||||||||||
3685 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
3686 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
3687 | - | |||||||||||||||||||||||||||||||||||||
3688 | \warning Calling resize() or setGeometry() inside resizeEvent() can | - | ||||||||||||||||||||||||||||||||||||
3689 | lead to infinite recursion. | - | ||||||||||||||||||||||||||||||||||||
3690 | - | |||||||||||||||||||||||||||||||||||||
3691 | \note Setting the size to \c{QSize(0, 0)} will cause the widget to not | - | ||||||||||||||||||||||||||||||||||||
3692 | appear on screen. This also applies to windows. | - | ||||||||||||||||||||||||||||||||||||
3693 | - | |||||||||||||||||||||||||||||||||||||
3694 | \sa pos, geometry, minimumSize, maximumSize, resizeEvent(), adjustSize() | - | ||||||||||||||||||||||||||||||||||||
3695 | */ | - | ||||||||||||||||||||||||||||||||||||
3696 | - | |||||||||||||||||||||||||||||||||||||
3697 | /*! | - | ||||||||||||||||||||||||||||||||||||
3698 | \property QWidget::width | - | ||||||||||||||||||||||||||||||||||||
3699 | \brief the width of the widget excluding any window frame | - | ||||||||||||||||||||||||||||||||||||
3700 | - | |||||||||||||||||||||||||||||||||||||
3701 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3702 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3703 | - | |||||||||||||||||||||||||||||||||||||
3704 | \note Do not use this function to find the width of a screen on | - | ||||||||||||||||||||||||||||||||||||
3705 | a \l{QDesktopWidget}{multiple screen desktop}. Read | - | ||||||||||||||||||||||||||||||||||||
3706 | \l{QDesktopWidget#Screen Geometry}{this note} for details. | - | ||||||||||||||||||||||||||||||||||||
3707 | - | |||||||||||||||||||||||||||||||||||||
3708 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
3709 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
3710 | - | |||||||||||||||||||||||||||||||||||||
3711 | \sa geometry, height, size | - | ||||||||||||||||||||||||||||||||||||
3712 | */ | - | ||||||||||||||||||||||||||||||||||||
3713 | - | |||||||||||||||||||||||||||||||||||||
3714 | /*! | - | ||||||||||||||||||||||||||||||||||||
3715 | \property QWidget::height | - | ||||||||||||||||||||||||||||||||||||
3716 | \brief the height of the widget excluding any window frame | - | ||||||||||||||||||||||||||||||||||||
3717 | - | |||||||||||||||||||||||||||||||||||||
3718 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3719 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3720 | - | |||||||||||||||||||||||||||||||||||||
3721 | \note Do not use this function to find the height of a screen | - | ||||||||||||||||||||||||||||||||||||
3722 | on a \l{QDesktopWidget}{multiple screen desktop}. Read | - | ||||||||||||||||||||||||||||||||||||
3723 | \l{QDesktopWidget#Screen Geometry}{this note} for details. | - | ||||||||||||||||||||||||||||||||||||
3724 | - | |||||||||||||||||||||||||||||||||||||
3725 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
3726 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
3727 | - | |||||||||||||||||||||||||||||||||||||
3728 | \sa geometry, width, size | - | ||||||||||||||||||||||||||||||||||||
3729 | */ | - | ||||||||||||||||||||||||||||||||||||
3730 | - | |||||||||||||||||||||||||||||||||||||
3731 | /*! | - | ||||||||||||||||||||||||||||||||||||
3732 | \property QWidget::rect | - | ||||||||||||||||||||||||||||||||||||
3733 | \brief the internal geometry of the widget excluding any window | - | ||||||||||||||||||||||||||||||||||||
3734 | frame | - | ||||||||||||||||||||||||||||||||||||
3735 | - | |||||||||||||||||||||||||||||||||||||
3736 | The rect property equals QRect(0, 0, width(), height()). | - | ||||||||||||||||||||||||||||||||||||
3737 | - | |||||||||||||||||||||||||||||||||||||
3738 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3739 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3740 | - | |||||||||||||||||||||||||||||||||||||
3741 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
3742 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
3743 | - | |||||||||||||||||||||||||||||||||||||
3744 | \sa size | - | ||||||||||||||||||||||||||||||||||||
3745 | */ | - | ||||||||||||||||||||||||||||||||||||
3746 | - | |||||||||||||||||||||||||||||||||||||
3747 | - | |||||||||||||||||||||||||||||||||||||
3748 | QRect QWidget::normalGeometry() const | - | ||||||||||||||||||||||||||||||||||||
3749 | { | - | ||||||||||||||||||||||||||||||||||||
3750 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3751 | if (!d->extra || !d->extra->topextra)
| 0 | ||||||||||||||||||||||||||||||||||||
3752 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||||||||||||||
3753 | - | |||||||||||||||||||||||||||||||||||||
3754 | if (!isMaximized() && !isFullScreen())
| 0 | ||||||||||||||||||||||||||||||||||||
3755 | return geometry(); never executed: return geometry(); | 0 | ||||||||||||||||||||||||||||||||||||
3756 | - | |||||||||||||||||||||||||||||||||||||
3757 | return d->topData()->normalGeometry; never executed: return d->topData()->normalGeometry; | 0 | ||||||||||||||||||||||||||||||||||||
3758 | } | - | ||||||||||||||||||||||||||||||||||||
3759 | - | |||||||||||||||||||||||||||||||||||||
3760 | - | |||||||||||||||||||||||||||||||||||||
3761 | /*! | - | ||||||||||||||||||||||||||||||||||||
3762 | \property QWidget::childrenRect | - | ||||||||||||||||||||||||||||||||||||
3763 | \brief the bounding rectangle of the widget's children | - | ||||||||||||||||||||||||||||||||||||
3764 | - | |||||||||||||||||||||||||||||||||||||
3765 | Hidden children are excluded. | - | ||||||||||||||||||||||||||||||||||||
3766 | - | |||||||||||||||||||||||||||||||||||||
3767 | By default, for a widget with no children, this property contains a | - | ||||||||||||||||||||||||||||||||||||
3768 | rectangle with zero width and height located at the origin. | - | ||||||||||||||||||||||||||||||||||||
3769 | - | |||||||||||||||||||||||||||||||||||||
3770 | \sa childrenRegion(), geometry() | - | ||||||||||||||||||||||||||||||||||||
3771 | */ | - | ||||||||||||||||||||||||||||||||||||
3772 | - | |||||||||||||||||||||||||||||||||||||
3773 | QRect QWidget::childrenRect() const | - | ||||||||||||||||||||||||||||||||||||
3774 | { | - | ||||||||||||||||||||||||||||||||||||
3775 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3776 | QRect r(0, 0, 0, 0); | - | ||||||||||||||||||||||||||||||||||||
3777 | for (int i = 0; i < d->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
3778 | QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
3779 | if (w && !w->isWindow() && !w->isHidden())
| 0 | ||||||||||||||||||||||||||||||||||||
3780 | r |= w->geometry(); never executed: r |= w->geometry(); | 0 | ||||||||||||||||||||||||||||||||||||
3781 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3782 | return r; never executed: return r; | 0 | ||||||||||||||||||||||||||||||||||||
3783 | } | - | ||||||||||||||||||||||||||||||||||||
3784 | - | |||||||||||||||||||||||||||||||||||||
3785 | /*! | - | ||||||||||||||||||||||||||||||||||||
3786 | \property QWidget::childrenRegion | - | ||||||||||||||||||||||||||||||||||||
3787 | \brief the combined region occupied by the widget's children | - | ||||||||||||||||||||||||||||||||||||
3788 | - | |||||||||||||||||||||||||||||||||||||
3789 | Hidden children are excluded. | - | ||||||||||||||||||||||||||||||||||||
3790 | - | |||||||||||||||||||||||||||||||||||||
3791 | By default, for a widget with no children, this property contains an | - | ||||||||||||||||||||||||||||||||||||
3792 | empty region. | - | ||||||||||||||||||||||||||||||||||||
3793 | - | |||||||||||||||||||||||||||||||||||||
3794 | \sa childrenRect(), geometry(), mask() | - | ||||||||||||||||||||||||||||||||||||
3795 | */ | - | ||||||||||||||||||||||||||||||||||||
3796 | - | |||||||||||||||||||||||||||||||||||||
3797 | QRegion QWidget::childrenRegion() const | - | ||||||||||||||||||||||||||||||||||||
3798 | { | - | ||||||||||||||||||||||||||||||||||||
3799 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3800 | QRegion r; | - | ||||||||||||||||||||||||||||||||||||
3801 | for (int i = 0; i < d->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
3802 | QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
3803 | if (w && !w->isWindow() && !w->isHidden()) {
| 0 | ||||||||||||||||||||||||||||||||||||
3804 | QRegion mask = w->mask(); | - | ||||||||||||||||||||||||||||||||||||
3805 | if (mask.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
3806 | r |= w->geometry(); never executed: r |= w->geometry(); | 0 | ||||||||||||||||||||||||||||||||||||
3807 | else | - | ||||||||||||||||||||||||||||||||||||
3808 | r |= mask.translated(w->pos()); never executed: r |= mask.translated(w->pos()); | 0 | ||||||||||||||||||||||||||||||||||||
3809 | } | - | ||||||||||||||||||||||||||||||||||||
3810 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3811 | return r; never executed: return r; | 0 | ||||||||||||||||||||||||||||||||||||
3812 | } | - | ||||||||||||||||||||||||||||||||||||
3813 | - | |||||||||||||||||||||||||||||||||||||
3814 | - | |||||||||||||||||||||||||||||||||||||
3815 | /*! | - | ||||||||||||||||||||||||||||||||||||
3816 | \property QWidget::minimumSize | - | ||||||||||||||||||||||||||||||||||||
3817 | \brief the widget's minimum size | - | ||||||||||||||||||||||||||||||||||||
3818 | - | |||||||||||||||||||||||||||||||||||||
3819 | The widget cannot be resized to a smaller size than the minimum | - | ||||||||||||||||||||||||||||||||||||
3820 | widget size. The widget's size is forced to the minimum size if | - | ||||||||||||||||||||||||||||||||||||
3821 | the current size is smaller. | - | ||||||||||||||||||||||||||||||||||||
3822 | - | |||||||||||||||||||||||||||||||||||||
3823 | The minimum size set by this function will override the minimum size | - | ||||||||||||||||||||||||||||||||||||
3824 | defined by QLayout. In order to unset the minimum size, use a | - | ||||||||||||||||||||||||||||||||||||
3825 | value of \c{QSize(0, 0)}. | - | ||||||||||||||||||||||||||||||||||||
3826 | - | |||||||||||||||||||||||||||||||||||||
3827 | By default, this property contains a size with zero width and height. | - | ||||||||||||||||||||||||||||||||||||
3828 | - | |||||||||||||||||||||||||||||||||||||
3829 | \sa minimumWidth, minimumHeight, maximumSize, sizeIncrement | - | ||||||||||||||||||||||||||||||||||||
3830 | */ | - | ||||||||||||||||||||||||||||||||||||
3831 | - | |||||||||||||||||||||||||||||||||||||
3832 | QSize QWidget::minimumSize() const | - | ||||||||||||||||||||||||||||||||||||
3833 | { | - | ||||||||||||||||||||||||||||||||||||
3834 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3835 | return d->extra ? QSize(d->extra->minw, d->extra->minh) : QSize(0, 0); never executed: return d->extra ? QSize(d->extra->minw, d->extra->minh) : QSize(0, 0); | 0 | ||||||||||||||||||||||||||||||||||||
3836 | } | - | ||||||||||||||||||||||||||||||||||||
3837 | - | |||||||||||||||||||||||||||||||||||||
3838 | /*! | - | ||||||||||||||||||||||||||||||||||||
3839 | \property QWidget::maximumSize | - | ||||||||||||||||||||||||||||||||||||
3840 | \brief the widget's maximum size in pixels | - | ||||||||||||||||||||||||||||||||||||
3841 | - | |||||||||||||||||||||||||||||||||||||
3842 | The widget cannot be resized to a larger size than the maximum | - | ||||||||||||||||||||||||||||||||||||
3843 | widget size. | - | ||||||||||||||||||||||||||||||||||||
3844 | - | |||||||||||||||||||||||||||||||||||||
3845 | By default, this property contains a size in which both width and height | - | ||||||||||||||||||||||||||||||||||||
3846 | have values of 16777215. | - | ||||||||||||||||||||||||||||||||||||
3847 | - | |||||||||||||||||||||||||||||||||||||
3848 | \note The definition of the \c QWIDGETSIZE_MAX macro limits the maximum size | - | ||||||||||||||||||||||||||||||||||||
3849 | of widgets. | - | ||||||||||||||||||||||||||||||||||||
3850 | - | |||||||||||||||||||||||||||||||||||||
3851 | \sa maximumWidth, maximumHeight, minimumSize, sizeIncrement | - | ||||||||||||||||||||||||||||||||||||
3852 | */ | - | ||||||||||||||||||||||||||||||||||||
3853 | - | |||||||||||||||||||||||||||||||||||||
3854 | QSize QWidget::maximumSize() const | - | ||||||||||||||||||||||||||||||||||||
3855 | { | - | ||||||||||||||||||||||||||||||||||||
3856 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3857 | return d->extra ? QSize(d->extra->maxw, d->extra->maxh) never executed: return d->extra ? QSize(d->extra->maxw, d->extra->maxh) : QSize(((1<<24)-1), ((1<<24)-1)); | 0 | ||||||||||||||||||||||||||||||||||||
3858 | : QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); never executed: return d->extra ? QSize(d->extra->maxw, d->extra->maxh) : QSize(((1<<24)-1), ((1<<24)-1)); | 0 | ||||||||||||||||||||||||||||||||||||
3859 | } | - | ||||||||||||||||||||||||||||||||||||
3860 | - | |||||||||||||||||||||||||||||||||||||
3861 | - | |||||||||||||||||||||||||||||||||||||
3862 | /*! | - | ||||||||||||||||||||||||||||||||||||
3863 | \property QWidget::minimumWidth | - | ||||||||||||||||||||||||||||||||||||
3864 | \brief the widget's minimum width in pixels | - | ||||||||||||||||||||||||||||||||||||
3865 | - | |||||||||||||||||||||||||||||||||||||
3866 | This property corresponds to the width held by the \l minimumSize property. | - | ||||||||||||||||||||||||||||||||||||
3867 | - | |||||||||||||||||||||||||||||||||||||
3868 | By default, this property has a value of 0. | - | ||||||||||||||||||||||||||||||||||||
3869 | - | |||||||||||||||||||||||||||||||||||||
3870 | \sa minimumSize, minimumHeight | - | ||||||||||||||||||||||||||||||||||||
3871 | */ | - | ||||||||||||||||||||||||||||||||||||
3872 | - | |||||||||||||||||||||||||||||||||||||
3873 | /*! | - | ||||||||||||||||||||||||||||||||||||
3874 | \property QWidget::minimumHeight | - | ||||||||||||||||||||||||||||||||||||
3875 | \brief the widget's minimum height in pixels | - | ||||||||||||||||||||||||||||||||||||
3876 | - | |||||||||||||||||||||||||||||||||||||
3877 | This property corresponds to the height held by the \l minimumSize property. | - | ||||||||||||||||||||||||||||||||||||
3878 | - | |||||||||||||||||||||||||||||||||||||
3879 | By default, this property has a value of 0. | - | ||||||||||||||||||||||||||||||||||||
3880 | - | |||||||||||||||||||||||||||||||||||||
3881 | \sa minimumSize, minimumWidth | - | ||||||||||||||||||||||||||||||||||||
3882 | */ | - | ||||||||||||||||||||||||||||||||||||
3883 | - | |||||||||||||||||||||||||||||||||||||
3884 | /*! | - | ||||||||||||||||||||||||||||||||||||
3885 | \property QWidget::maximumWidth | - | ||||||||||||||||||||||||||||||||||||
3886 | \brief the widget's maximum width in pixels | - | ||||||||||||||||||||||||||||||||||||
3887 | - | |||||||||||||||||||||||||||||||||||||
3888 | This property corresponds to the width held by the \l maximumSize property. | - | ||||||||||||||||||||||||||||||||||||
3889 | - | |||||||||||||||||||||||||||||||||||||
3890 | By default, this property contains a value of 16777215. | - | ||||||||||||||||||||||||||||||||||||
3891 | - | |||||||||||||||||||||||||||||||||||||
3892 | \note The definition of the \c QWIDGETSIZE_MAX macro limits the maximum size | - | ||||||||||||||||||||||||||||||||||||
3893 | of widgets. | - | ||||||||||||||||||||||||||||||||||||
3894 | - | |||||||||||||||||||||||||||||||||||||
3895 | \sa maximumSize, maximumHeight | - | ||||||||||||||||||||||||||||||||||||
3896 | */ | - | ||||||||||||||||||||||||||||||||||||
3897 | - | |||||||||||||||||||||||||||||||||||||
3898 | /*! | - | ||||||||||||||||||||||||||||||||||||
3899 | \property QWidget::maximumHeight | - | ||||||||||||||||||||||||||||||||||||
3900 | \brief the widget's maximum height in pixels | - | ||||||||||||||||||||||||||||||||||||
3901 | - | |||||||||||||||||||||||||||||||||||||
3902 | This property corresponds to the height held by the \l maximumSize property. | - | ||||||||||||||||||||||||||||||||||||
3903 | - | |||||||||||||||||||||||||||||||||||||
3904 | By default, this property contains a value of 16777215. | - | ||||||||||||||||||||||||||||||||||||
3905 | - | |||||||||||||||||||||||||||||||||||||
3906 | \note The definition of the \c QWIDGETSIZE_MAX macro limits the maximum size | - | ||||||||||||||||||||||||||||||||||||
3907 | of widgets. | - | ||||||||||||||||||||||||||||||||||||
3908 | - | |||||||||||||||||||||||||||||||||||||
3909 | \sa maximumSize, maximumWidth | - | ||||||||||||||||||||||||||||||||||||
3910 | */ | - | ||||||||||||||||||||||||||||||||||||
3911 | - | |||||||||||||||||||||||||||||||||||||
3912 | /*! | - | ||||||||||||||||||||||||||||||||||||
3913 | \property QWidget::sizeIncrement | - | ||||||||||||||||||||||||||||||||||||
3914 | \brief the size increment of the widget | - | ||||||||||||||||||||||||||||||||||||
3915 | - | |||||||||||||||||||||||||||||||||||||
3916 | When the user resizes the window, the size will move in steps of | - | ||||||||||||||||||||||||||||||||||||
3917 | sizeIncrement().width() pixels horizontally and | - | ||||||||||||||||||||||||||||||||||||
3918 | sizeIncrement.height() pixels vertically, with baseSize() as the | - | ||||||||||||||||||||||||||||||||||||
3919 | basis. Preferred widget sizes are for non-negative integers \e i | - | ||||||||||||||||||||||||||||||||||||
3920 | and \e j: | - | ||||||||||||||||||||||||||||||||||||
3921 | \snippet code/src_gui_kernel_qwidget.cpp 2 | - | ||||||||||||||||||||||||||||||||||||
3922 | - | |||||||||||||||||||||||||||||||||||||
3923 | Note that while you can set the size increment for all widgets, it | - | ||||||||||||||||||||||||||||||||||||
3924 | only affects windows. | - | ||||||||||||||||||||||||||||||||||||
3925 | - | |||||||||||||||||||||||||||||||||||||
3926 | By default, this property contains a size with zero width and height. | - | ||||||||||||||||||||||||||||||||||||
3927 | - | |||||||||||||||||||||||||||||||||||||
3928 | \warning The size increment has no effect under Windows, and may | - | ||||||||||||||||||||||||||||||||||||
3929 | be disregarded by the window manager on X11. | - | ||||||||||||||||||||||||||||||||||||
3930 | - | |||||||||||||||||||||||||||||||||||||
3931 | \sa size, minimumSize, maximumSize | - | ||||||||||||||||||||||||||||||||||||
3932 | */ | - | ||||||||||||||||||||||||||||||||||||
3933 | QSize QWidget::sizeIncrement() const | - | ||||||||||||||||||||||||||||||||||||
3934 | { | - | ||||||||||||||||||||||||||||||||||||
3935 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3936 | return (d->extra && d->extra->topextra) never executed: return (d->extra && d->extra->topextra) ? QSize(d->extra->topextra->incw, d->extra->topextra->inch) : QSize(0, 0); | 0 | ||||||||||||||||||||||||||||||||||||
3937 | ? QSize(d->extra->topextra->incw, d->extra->topextra->inch) never executed: return (d->extra && d->extra->topextra) ? QSize(d->extra->topextra->incw, d->extra->topextra->inch) : QSize(0, 0); | 0 | ||||||||||||||||||||||||||||||||||||
3938 | : QSize(0, 0); never executed: return (d->extra && d->extra->topextra) ? QSize(d->extra->topextra->incw, d->extra->topextra->inch) : QSize(0, 0); | 0 | ||||||||||||||||||||||||||||||||||||
3939 | } | - | ||||||||||||||||||||||||||||||||||||
3940 | - | |||||||||||||||||||||||||||||||||||||
3941 | /*! | - | ||||||||||||||||||||||||||||||||||||
3942 | \property QWidget::baseSize | - | ||||||||||||||||||||||||||||||||||||
3943 | \brief the base size of the widget | - | ||||||||||||||||||||||||||||||||||||
3944 | - | |||||||||||||||||||||||||||||||||||||
3945 | The base size is used to calculate a proper widget size if the | - | ||||||||||||||||||||||||||||||||||||
3946 | widget defines sizeIncrement(). | - | ||||||||||||||||||||||||||||||||||||
3947 | - | |||||||||||||||||||||||||||||||||||||
3948 | By default, for a newly-created widget, this property contains a size with | - | ||||||||||||||||||||||||||||||||||||
3949 | zero width and height. | - | ||||||||||||||||||||||||||||||||||||
3950 | - | |||||||||||||||||||||||||||||||||||||
3951 | \sa setSizeIncrement() | - | ||||||||||||||||||||||||||||||||||||
3952 | */ | - | ||||||||||||||||||||||||||||||||||||
3953 | - | |||||||||||||||||||||||||||||||||||||
3954 | QSize QWidget::baseSize() const | - | ||||||||||||||||||||||||||||||||||||
3955 | { | - | ||||||||||||||||||||||||||||||||||||
3956 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3957 | return (d->extra != 0 && d->extra->topextra != 0) never executed: return (d->extra != 0 && d->extra->topextra != 0) ? QSize(d->extra->topextra->basew, d->extra->topextra->baseh) : QSize(0, 0); | 0 | ||||||||||||||||||||||||||||||||||||
3958 | ? QSize(d->extra->topextra->basew, d->extra->topextra->baseh) never executed: return (d->extra != 0 && d->extra->topextra != 0) ? QSize(d->extra->topextra->basew, d->extra->topextra->baseh) : QSize(0, 0); | 0 | ||||||||||||||||||||||||||||||||||||
3959 | : QSize(0, 0); never executed: return (d->extra != 0 && d->extra->topextra != 0) ? QSize(d->extra->topextra->basew, d->extra->topextra->baseh) : QSize(0, 0); | 0 | ||||||||||||||||||||||||||||||||||||
3960 | } | - | ||||||||||||||||||||||||||||||||||||
3961 | - | |||||||||||||||||||||||||||||||||||||
3962 | bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh) | - | ||||||||||||||||||||||||||||||||||||
3963 | { | - | ||||||||||||||||||||||||||||||||||||
3964 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3965 | - | |||||||||||||||||||||||||||||||||||||
3966 | int mw = minw, mh = minh; | - | ||||||||||||||||||||||||||||||||||||
3967 | if (mw == QWIDGETSIZE_MAX)
| 0 | ||||||||||||||||||||||||||||||||||||
3968 | mw = 0; never executed: mw = 0; | 0 | ||||||||||||||||||||||||||||||||||||
3969 | if (mh == QWIDGETSIZE_MAX)
| 0 | ||||||||||||||||||||||||||||||||||||
3970 | mh = 0; never executed: mh = 0; | 0 | ||||||||||||||||||||||||||||||||||||
3971 | if (Q_UNLIKELY(minw > QWIDGETSIZE_MAX || minh > QWIDGETSIZE_MAX)) {
| 0 | ||||||||||||||||||||||||||||||||||||
3972 | qWarning("QWidget::setMinimumSize: (%s/%s) " | - | ||||||||||||||||||||||||||||||||||||
3973 | "The largest allowed size is (%d,%d)", | - | ||||||||||||||||||||||||||||||||||||
3974 | q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX, | - | ||||||||||||||||||||||||||||||||||||
3975 | QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||||||||
3976 | minw = mw = qMin<int>(minw, QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||||||||
3977 | minh = mh = qMin<int>(minh, QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||||||||
3978 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3979 | if (Q_UNLIKELY(minw < 0 || minh < 0)) {
| 0 | ||||||||||||||||||||||||||||||||||||
3980 | qWarning("QWidget::setMinimumSize: (%s/%s) Negative sizes (%d,%d) " | - | ||||||||||||||||||||||||||||||||||||
3981 | "are not possible", | - | ||||||||||||||||||||||||||||||||||||
3982 | q->objectName().toLocal8Bit().data(), q->metaObject()->className(), minw, minh); | - | ||||||||||||||||||||||||||||||||||||
3983 | minw = mw = qMax(minw, 0); | - | ||||||||||||||||||||||||||||||||||||
3984 | minh = mh = qMax(minh, 0); | - | ||||||||||||||||||||||||||||||||||||
3985 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3986 | createExtra(); | - | ||||||||||||||||||||||||||||||||||||
3987 | if (extra->minw == mw && extra->minh == mh)
| 0 | ||||||||||||||||||||||||||||||||||||
3988 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
3989 | extra->minw = mw; | - | ||||||||||||||||||||||||||||||||||||
3990 | extra->minh = mh; | - | ||||||||||||||||||||||||||||||||||||
3991 | extra->explicitMinSize = (mw ? Qt::Horizontal : 0) | (mh ? Qt::Vertical : 0);
| 0 | ||||||||||||||||||||||||||||||||||||
3992 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
3993 | } | - | ||||||||||||||||||||||||||||||||||||
3994 | - | |||||||||||||||||||||||||||||||||||||
3995 | void QWidgetPrivate::setConstraints_sys() | - | ||||||||||||||||||||||||||||||||||||
3996 | { | - | ||||||||||||||||||||||||||||||||||||
3997 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3998 | if (extra && q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
3999 | QWindow *win = q->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
4000 | QWindowPrivate *winp = qt_window_private(win); | - | ||||||||||||||||||||||||||||||||||||
4001 | - | |||||||||||||||||||||||||||||||||||||
4002 | winp->minimumSize = QSize(extra->minw, extra->minh); | - | ||||||||||||||||||||||||||||||||||||
4003 | winp->maximumSize = QSize(extra->maxw, extra->maxh); | - | ||||||||||||||||||||||||||||||||||||
4004 | - | |||||||||||||||||||||||||||||||||||||
4005 | if (extra->topextra) {
| 0 | ||||||||||||||||||||||||||||||||||||
4006 | winp->baseSize = QSize(extra->topextra->basew, extra->topextra->baseh); | - | ||||||||||||||||||||||||||||||||||||
4007 | winp->sizeIncrement = QSize(extra->topextra->incw, extra->topextra->inch); | - | ||||||||||||||||||||||||||||||||||||
4008 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4009 | - | |||||||||||||||||||||||||||||||||||||
4010 | if (winp->platformWindow) {
| 0 | ||||||||||||||||||||||||||||||||||||
4011 | fixPosIncludesFrame(); | - | ||||||||||||||||||||||||||||||||||||
4012 | winp->platformWindow->propagateSizeHints(); | - | ||||||||||||||||||||||||||||||||||||
4013 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4014 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4015 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4016 | - | |||||||||||||||||||||||||||||||||||||
4017 | /*! | - | ||||||||||||||||||||||||||||||||||||
4018 | \overload | - | ||||||||||||||||||||||||||||||||||||
4019 | - | |||||||||||||||||||||||||||||||||||||
4020 | This function corresponds to setMinimumSize(QSize(minw, minh)). | - | ||||||||||||||||||||||||||||||||||||
4021 | Sets the minimum width to \a minw and the minimum height to \a | - | ||||||||||||||||||||||||||||||||||||
4022 | minh. | - | ||||||||||||||||||||||||||||||||||||
4023 | */ | - | ||||||||||||||||||||||||||||||||||||
4024 | - | |||||||||||||||||||||||||||||||||||||
4025 | void QWidget::setMinimumSize(int minw, int minh) | - | ||||||||||||||||||||||||||||||||||||
4026 | { | - | ||||||||||||||||||||||||||||||||||||
4027 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4028 | if (!d->setMinimumSize_helper(minw, minh))
| 0 | ||||||||||||||||||||||||||||||||||||
4029 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4030 | - | |||||||||||||||||||||||||||||||||||||
4031 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
4032 | d->setConstraints_sys(); never executed: d->setConstraints_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
4033 | if (minw > width() || minh > height()) {
| 0 | ||||||||||||||||||||||||||||||||||||
4034 | bool resized = testAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||||||||||||||
4035 | bool maximized = isMaximized(); | - | ||||||||||||||||||||||||||||||||||||
4036 | resize(qMax(minw,width()), qMax(minh,height())); | - | ||||||||||||||||||||||||||||||||||||
4037 | setAttribute(Qt::WA_Resized, resized); //not a user resize | - | ||||||||||||||||||||||||||||||||||||
4038 | if (maximized)
| 0 | ||||||||||||||||||||||||||||||||||||
4039 | data->window_state = data->window_state | Qt::WindowMaximized; never executed: data->window_state = data->window_state | Qt::WindowMaximized; | 0 | ||||||||||||||||||||||||||||||||||||
4040 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4041 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4042 | if (d->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
4043 | if (d->extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
4044 | d->extra->proxyWidget->setMinimumSize(minw, minh); never executed: d->extra->proxyWidget->setMinimumSize(minw, minh); | 0 | ||||||||||||||||||||||||||||||||||||
4045 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4046 | #endif | - | ||||||||||||||||||||||||||||||||||||
4047 | d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh); | - | ||||||||||||||||||||||||||||||||||||
4048 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4049 | - | |||||||||||||||||||||||||||||||||||||
4050 | bool QWidgetPrivate::setMaximumSize_helper(int &maxw, int &maxh) | - | ||||||||||||||||||||||||||||||||||||
4051 | { | - | ||||||||||||||||||||||||||||||||||||
4052 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4053 | if (Q_UNLIKELY(maxw > QWIDGETSIZE_MAX || maxh > QWIDGETSIZE_MAX)) {
| 0 | ||||||||||||||||||||||||||||||||||||
4054 | qWarning("QWidget::setMaximumSize: (%s/%s) " | - | ||||||||||||||||||||||||||||||||||||
4055 | "The largest allowed size is (%d,%d)", | - | ||||||||||||||||||||||||||||||||||||
4056 | q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX, | - | ||||||||||||||||||||||||||||||||||||
4057 | QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||||||||
4058 | maxw = qMin<int>(maxw, QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||||||||
4059 | maxh = qMin<int>(maxh, QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||||||||
4060 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4061 | if (Q_UNLIKELY(maxw < 0 || maxh < 0)) {
| 0 | ||||||||||||||||||||||||||||||||||||
4062 | qWarning("QWidget::setMaximumSize: (%s/%s) Negative sizes (%d,%d) " | - | ||||||||||||||||||||||||||||||||||||
4063 | "are not possible", | - | ||||||||||||||||||||||||||||||||||||
4064 | q->objectName().toLocal8Bit().data(), q->metaObject()->className(), maxw, maxh); | - | ||||||||||||||||||||||||||||||||||||
4065 | maxw = qMax(maxw, 0); | - | ||||||||||||||||||||||||||||||||||||
4066 | maxh = qMax(maxh, 0); | - | ||||||||||||||||||||||||||||||||||||
4067 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4068 | createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4069 | if (extra->maxw == maxw && extra->maxh == maxh)
| 0 | ||||||||||||||||||||||||||||||||||||
4070 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
4071 | extra->maxw = maxw; | - | ||||||||||||||||||||||||||||||||||||
4072 | extra->maxh = maxh; | - | ||||||||||||||||||||||||||||||||||||
4073 | extra->explicitMaxSize = (maxw != QWIDGETSIZE_MAX ? Qt::Horizontal : 0) |
| 0 | ||||||||||||||||||||||||||||||||||||
4074 | (maxh != QWIDGETSIZE_MAX ? Qt::Vertical : 0); | - | ||||||||||||||||||||||||||||||||||||
4075 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
4076 | } | - | ||||||||||||||||||||||||||||||||||||
4077 | - | |||||||||||||||||||||||||||||||||||||
4078 | /*! | - | ||||||||||||||||||||||||||||||||||||
4079 | \overload | - | ||||||||||||||||||||||||||||||||||||
4080 | - | |||||||||||||||||||||||||||||||||||||
4081 | This function corresponds to setMaximumSize(QSize(\a maxw, \a | - | ||||||||||||||||||||||||||||||||||||
4082 | maxh)). Sets the maximum width to \a maxw and the maximum height | - | ||||||||||||||||||||||||||||||||||||
4083 | to \a maxh. | - | ||||||||||||||||||||||||||||||||||||
4084 | */ | - | ||||||||||||||||||||||||||||||||||||
4085 | void QWidget::setMaximumSize(int maxw, int maxh) | - | ||||||||||||||||||||||||||||||||||||
4086 | { | - | ||||||||||||||||||||||||||||||||||||
4087 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4088 | if (!d->setMaximumSize_helper(maxw, maxh))
| 0 | ||||||||||||||||||||||||||||||||||||
4089 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4090 | - | |||||||||||||||||||||||||||||||||||||
4091 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
4092 | d->setConstraints_sys(); never executed: d->setConstraints_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
4093 | if (maxw < width() || maxh < height()) {
| 0 | ||||||||||||||||||||||||||||||||||||
4094 | bool resized = testAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||||||||||||||
4095 | resize(qMin(maxw,width()), qMin(maxh,height())); | - | ||||||||||||||||||||||||||||||||||||
4096 | setAttribute(Qt::WA_Resized, resized); //not a user resize | - | ||||||||||||||||||||||||||||||||||||
4097 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4098 | - | |||||||||||||||||||||||||||||||||||||
4099 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4100 | if (d->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
4101 | if (d->extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
4102 | d->extra->proxyWidget->setMaximumSize(maxw, maxh); never executed: d->extra->proxyWidget->setMaximumSize(maxw, maxh); | 0 | ||||||||||||||||||||||||||||||||||||
4103 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4104 | #endif | - | ||||||||||||||||||||||||||||||||||||
4105 | - | |||||||||||||||||||||||||||||||||||||
4106 | d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh); | - | ||||||||||||||||||||||||||||||||||||
4107 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4108 | - | |||||||||||||||||||||||||||||||||||||
4109 | /*! | - | ||||||||||||||||||||||||||||||||||||
4110 | \overload | - | ||||||||||||||||||||||||||||||||||||
4111 | - | |||||||||||||||||||||||||||||||||||||
4112 | Sets the x (width) size increment to \a w and the y (height) size | - | ||||||||||||||||||||||||||||||||||||
4113 | increment to \a h. | - | ||||||||||||||||||||||||||||||||||||
4114 | */ | - | ||||||||||||||||||||||||||||||||||||
4115 | void QWidget::setSizeIncrement(int w, int h) | - | ||||||||||||||||||||||||||||||||||||
4116 | { | - | ||||||||||||||||||||||||||||||||||||
4117 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4118 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
4119 | QTLWExtra* x = d->topData(); | - | ||||||||||||||||||||||||||||||||||||
4120 | if (x->incw == w && x->inch == h)
| 0 | ||||||||||||||||||||||||||||||||||||
4121 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4122 | x->incw = w; | - | ||||||||||||||||||||||||||||||||||||
4123 | x->inch = h; | - | ||||||||||||||||||||||||||||||||||||
4124 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
4125 | d->setConstraints_sys(); never executed: d->setConstraints_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
4126 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4127 | - | |||||||||||||||||||||||||||||||||||||
4128 | /*! | - | ||||||||||||||||||||||||||||||||||||
4129 | \overload | - | ||||||||||||||||||||||||||||||||||||
4130 | - | |||||||||||||||||||||||||||||||||||||
4131 | This corresponds to setBaseSize(QSize(\a basew, \a baseh)). Sets | - | ||||||||||||||||||||||||||||||||||||
4132 | the widgets base size to width \a basew and height \a baseh. | - | ||||||||||||||||||||||||||||||||||||
4133 | */ | - | ||||||||||||||||||||||||||||||||||||
4134 | void QWidget::setBaseSize(int basew, int baseh) | - | ||||||||||||||||||||||||||||||||||||
4135 | { | - | ||||||||||||||||||||||||||||||||||||
4136 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4137 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
4138 | QTLWExtra* x = d->topData(); | - | ||||||||||||||||||||||||||||||||||||
4139 | if (x->basew == basew && x->baseh == baseh)
| 0 | ||||||||||||||||||||||||||||||||||||
4140 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4141 | x->basew = basew; | - | ||||||||||||||||||||||||||||||||||||
4142 | x->baseh = baseh; | - | ||||||||||||||||||||||||||||||||||||
4143 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
4144 | d->setConstraints_sys(); never executed: d->setConstraints_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
4145 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4146 | - | |||||||||||||||||||||||||||||||||||||
4147 | /*! | - | ||||||||||||||||||||||||||||||||||||
4148 | Sets both the minimum and maximum sizes of the widget to \a s, | - | ||||||||||||||||||||||||||||||||||||
4149 | thereby preventing it from ever growing or shrinking. | - | ||||||||||||||||||||||||||||||||||||
4150 | - | |||||||||||||||||||||||||||||||||||||
4151 | This will override the default size constraints set by QLayout. | - | ||||||||||||||||||||||||||||||||||||
4152 | - | |||||||||||||||||||||||||||||||||||||
4153 | To remove constraints, set the size to QWIDGETSIZE_MAX. | - | ||||||||||||||||||||||||||||||||||||
4154 | - | |||||||||||||||||||||||||||||||||||||
4155 | Alternatively, if you want the widget to have a | - | ||||||||||||||||||||||||||||||||||||
4156 | fixed size based on its contents, you can call | - | ||||||||||||||||||||||||||||||||||||
4157 | QLayout::setSizeConstraint(QLayout::SetFixedSize); | - | ||||||||||||||||||||||||||||||||||||
4158 | - | |||||||||||||||||||||||||||||||||||||
4159 | \sa maximumSize, minimumSize | - | ||||||||||||||||||||||||||||||||||||
4160 | */ | - | ||||||||||||||||||||||||||||||||||||
4161 | - | |||||||||||||||||||||||||||||||||||||
4162 | void QWidget::setFixedSize(const QSize & s) | - | ||||||||||||||||||||||||||||||||||||
4163 | { | - | ||||||||||||||||||||||||||||||||||||
4164 | setFixedSize(s.width(), s.height()); | - | ||||||||||||||||||||||||||||||||||||
4165 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4166 | - | |||||||||||||||||||||||||||||||||||||
4167 | - | |||||||||||||||||||||||||||||||||||||
4168 | /*! | - | ||||||||||||||||||||||||||||||||||||
4169 | \fn void QWidget::setFixedSize(int w, int h) | - | ||||||||||||||||||||||||||||||||||||
4170 | \overload | - | ||||||||||||||||||||||||||||||||||||
4171 | - | |||||||||||||||||||||||||||||||||||||
4172 | Sets the width of the widget to \a w and the height to \a h. | - | ||||||||||||||||||||||||||||||||||||
4173 | */ | - | ||||||||||||||||||||||||||||||||||||
4174 | - | |||||||||||||||||||||||||||||||||||||
4175 | void QWidget::setFixedSize(int w, int h) | - | ||||||||||||||||||||||||||||||||||||
4176 | { | - | ||||||||||||||||||||||||||||||||||||
4177 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4178 | bool minSizeSet = d->setMinimumSize_helper(w, h); | - | ||||||||||||||||||||||||||||||||||||
4179 | bool maxSizeSet = d->setMaximumSize_helper(w, h); | - | ||||||||||||||||||||||||||||||||||||
4180 | if (!minSizeSet && !maxSizeSet)
| 0 | ||||||||||||||||||||||||||||||||||||
4181 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4182 | - | |||||||||||||||||||||||||||||||||||||
4183 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
4184 | d->setConstraints_sys(); never executed: d->setConstraints_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
4185 | else | - | ||||||||||||||||||||||||||||||||||||
4186 | d->updateGeometry_helper(true); never executed: d->updateGeometry_helper(true); | 0 | ||||||||||||||||||||||||||||||||||||
4187 | - | |||||||||||||||||||||||||||||||||||||
4188 | if (w != QWIDGETSIZE_MAX || h != QWIDGETSIZE_MAX)
| 0 | ||||||||||||||||||||||||||||||||||||
4189 | resize(w, h); never executed: resize(w, h); | 0 | ||||||||||||||||||||||||||||||||||||
4190 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4191 | - | |||||||||||||||||||||||||||||||||||||
4192 | void QWidget::setMinimumWidth(int w) | - | ||||||||||||||||||||||||||||||||||||
4193 | { | - | ||||||||||||||||||||||||||||||||||||
4194 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4195 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4196 | uint expl = d->extra->explicitMinSize | (w ? Qt::Horizontal : 0); | - | ||||||||||||||||||||||||||||||||||||
4197 | setMinimumSize(w, minimumSize().height()); | - | ||||||||||||||||||||||||||||||||||||
4198 | d->extra->explicitMinSize = expl; | - | ||||||||||||||||||||||||||||||||||||
4199 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4200 | - | |||||||||||||||||||||||||||||||||||||
4201 | void QWidget::setMinimumHeight(int h) | - | ||||||||||||||||||||||||||||||||||||
4202 | { | - | ||||||||||||||||||||||||||||||||||||
4203 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4204 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4205 | uint expl = d->extra->explicitMinSize | (h ? Qt::Vertical : 0); | - | ||||||||||||||||||||||||||||||||||||
4206 | setMinimumSize(minimumSize().width(), h); | - | ||||||||||||||||||||||||||||||||||||
4207 | d->extra->explicitMinSize = expl; | - | ||||||||||||||||||||||||||||||||||||
4208 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4209 | - | |||||||||||||||||||||||||||||||||||||
4210 | void QWidget::setMaximumWidth(int w) | - | ||||||||||||||||||||||||||||||||||||
4211 | { | - | ||||||||||||||||||||||||||||||||||||
4212 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4213 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4214 | uint expl = d->extra->explicitMaxSize | (w == QWIDGETSIZE_MAX ? 0 : Qt::Horizontal); | - | ||||||||||||||||||||||||||||||||||||
4215 | setMaximumSize(w, maximumSize().height()); | - | ||||||||||||||||||||||||||||||||||||
4216 | d->extra->explicitMaxSize = expl; | - | ||||||||||||||||||||||||||||||||||||
4217 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4218 | - | |||||||||||||||||||||||||||||||||||||
4219 | void QWidget::setMaximumHeight(int h) | - | ||||||||||||||||||||||||||||||||||||
4220 | { | - | ||||||||||||||||||||||||||||||||||||
4221 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4222 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4223 | uint expl = d->extra->explicitMaxSize | (h == QWIDGETSIZE_MAX ? 0 : Qt::Vertical); | - | ||||||||||||||||||||||||||||||||||||
4224 | setMaximumSize(maximumSize().width(), h); | - | ||||||||||||||||||||||||||||||||||||
4225 | d->extra->explicitMaxSize = expl; | - | ||||||||||||||||||||||||||||||||||||
4226 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4227 | - | |||||||||||||||||||||||||||||||||||||
4228 | /*! | - | ||||||||||||||||||||||||||||||||||||
4229 | Sets both the minimum and maximum width of the widget to \a w | - | ||||||||||||||||||||||||||||||||||||
4230 | without changing the heights. Provided for convenience. | - | ||||||||||||||||||||||||||||||||||||
4231 | - | |||||||||||||||||||||||||||||||||||||
4232 | \sa sizeHint(), minimumSize(), maximumSize(), setFixedSize() | - | ||||||||||||||||||||||||||||||||||||
4233 | */ | - | ||||||||||||||||||||||||||||||||||||
4234 | - | |||||||||||||||||||||||||||||||||||||
4235 | void QWidget::setFixedWidth(int w) | - | ||||||||||||||||||||||||||||||||||||
4236 | { | - | ||||||||||||||||||||||||||||||||||||
4237 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4238 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4239 | uint explMin = d->extra->explicitMinSize | Qt::Horizontal; | - | ||||||||||||||||||||||||||||||||||||
4240 | uint explMax = d->extra->explicitMaxSize | Qt::Horizontal; | - | ||||||||||||||||||||||||||||||||||||
4241 | setMinimumSize(w, minimumSize().height()); | - | ||||||||||||||||||||||||||||||||||||
4242 | setMaximumSize(w, maximumSize().height()); | - | ||||||||||||||||||||||||||||||||||||
4243 | d->extra->explicitMinSize = explMin; | - | ||||||||||||||||||||||||||||||||||||
4244 | d->extra->explicitMaxSize = explMax; | - | ||||||||||||||||||||||||||||||||||||
4245 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4246 | - | |||||||||||||||||||||||||||||||||||||
4247 | - | |||||||||||||||||||||||||||||||||||||
4248 | /*! | - | ||||||||||||||||||||||||||||||||||||
4249 | Sets both the minimum and maximum heights of the widget to \a h | - | ||||||||||||||||||||||||||||||||||||
4250 | without changing the widths. Provided for convenience. | - | ||||||||||||||||||||||||||||||||||||
4251 | - | |||||||||||||||||||||||||||||||||||||
4252 | \sa sizeHint(), minimumSize(), maximumSize(), setFixedSize() | - | ||||||||||||||||||||||||||||||||||||
4253 | */ | - | ||||||||||||||||||||||||||||||||||||
4254 | - | |||||||||||||||||||||||||||||||||||||
4255 | void QWidget::setFixedHeight(int h) | - | ||||||||||||||||||||||||||||||||||||
4256 | { | - | ||||||||||||||||||||||||||||||||||||
4257 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4258 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4259 | uint explMin = d->extra->explicitMinSize | Qt::Vertical; | - | ||||||||||||||||||||||||||||||||||||
4260 | uint explMax = d->extra->explicitMaxSize | Qt::Vertical; | - | ||||||||||||||||||||||||||||||||||||
4261 | setMinimumSize(minimumSize().width(), h); | - | ||||||||||||||||||||||||||||||||||||
4262 | setMaximumSize(maximumSize().width(), h); | - | ||||||||||||||||||||||||||||||||||||
4263 | d->extra->explicitMinSize = explMin; | - | ||||||||||||||||||||||||||||||||||||
4264 | d->extra->explicitMaxSize = explMax; | - | ||||||||||||||||||||||||||||||||||||
4265 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4266 | - | |||||||||||||||||||||||||||||||||||||
4267 | - | |||||||||||||||||||||||||||||||||||||
4268 | /*! | - | ||||||||||||||||||||||||||||||||||||
4269 | Translates the widget coordinate \a pos to the coordinate system | - | ||||||||||||||||||||||||||||||||||||
4270 | of \a parent. The \a parent must not be 0 and must be a parent | - | ||||||||||||||||||||||||||||||||||||
4271 | of the calling widget. | - | ||||||||||||||||||||||||||||||||||||
4272 | - | |||||||||||||||||||||||||||||||||||||
4273 | \sa mapFrom(), mapToParent(), mapToGlobal(), underMouse() | - | ||||||||||||||||||||||||||||||||||||
4274 | */ | - | ||||||||||||||||||||||||||||||||||||
4275 | - | |||||||||||||||||||||||||||||||||||||
4276 | QPoint QWidget::mapTo(const QWidget * parent, const QPoint & pos) const | - | ||||||||||||||||||||||||||||||||||||
4277 | { | - | ||||||||||||||||||||||||||||||||||||
4278 | QPoint p = pos; | - | ||||||||||||||||||||||||||||||||||||
4279 | if (parent) {
| 0 | ||||||||||||||||||||||||||||||||||||
4280 | const QWidget * w = this; | - | ||||||||||||||||||||||||||||||||||||
4281 | while (w != parent) {
| 0 | ||||||||||||||||||||||||||||||||||||
4282 | Q_ASSERT_X(w, "QWidget::mapTo(const QWidget *parent, const QPoint &pos)", | - | ||||||||||||||||||||||||||||||||||||
4283 | "parent must be in parent hierarchy"); | - | ||||||||||||||||||||||||||||||||||||
4284 | p = w->mapToParent(p); | - | ||||||||||||||||||||||||||||||||||||
4285 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
4286 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4287 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4288 | return p; never executed: return p; | 0 | ||||||||||||||||||||||||||||||||||||
4289 | } | - | ||||||||||||||||||||||||||||||||||||
4290 | - | |||||||||||||||||||||||||||||||||||||
4291 | - | |||||||||||||||||||||||||||||||||||||
4292 | /*! | - | ||||||||||||||||||||||||||||||||||||
4293 | Translates the widget coordinate \a pos from the coordinate system | - | ||||||||||||||||||||||||||||||||||||
4294 | of \a parent to this widget's coordinate system. The \a parent | - | ||||||||||||||||||||||||||||||||||||
4295 | must not be 0 and must be a parent of the calling widget. | - | ||||||||||||||||||||||||||||||||||||
4296 | - | |||||||||||||||||||||||||||||||||||||
4297 | \sa mapTo(), mapFromParent(), mapFromGlobal(), underMouse() | - | ||||||||||||||||||||||||||||||||||||
4298 | */ | - | ||||||||||||||||||||||||||||||||||||
4299 | - | |||||||||||||||||||||||||||||||||||||
4300 | QPoint QWidget::mapFrom(const QWidget * parent, const QPoint & pos) const | - | ||||||||||||||||||||||||||||||||||||
4301 | { | - | ||||||||||||||||||||||||||||||||||||
4302 | QPoint p(pos); | - | ||||||||||||||||||||||||||||||||||||
4303 | if (parent) {
| 0 | ||||||||||||||||||||||||||||||||||||
4304 | const QWidget * w = this; | - | ||||||||||||||||||||||||||||||||||||
4305 | while (w != parent) {
| 0 | ||||||||||||||||||||||||||||||||||||
4306 | Q_ASSERT_X(w, "QWidget::mapFrom(const QWidget *parent, const QPoint &pos)", | - | ||||||||||||||||||||||||||||||||||||
4307 | "parent must be in parent hierarchy"); | - | ||||||||||||||||||||||||||||||||||||
4308 | - | |||||||||||||||||||||||||||||||||||||
4309 | p = w->mapFromParent(p); | - | ||||||||||||||||||||||||||||||||||||
4310 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
4311 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4312 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4313 | return p; never executed: return p; | 0 | ||||||||||||||||||||||||||||||||||||
4314 | } | - | ||||||||||||||||||||||||||||||||||||
4315 | - | |||||||||||||||||||||||||||||||||||||
4316 | - | |||||||||||||||||||||||||||||||||||||
4317 | /*! | - | ||||||||||||||||||||||||||||||||||||
4318 | Translates the widget coordinate \a pos to a coordinate in the | - | ||||||||||||||||||||||||||||||||||||
4319 | parent widget. | - | ||||||||||||||||||||||||||||||||||||
4320 | - | |||||||||||||||||||||||||||||||||||||
4321 | Same as mapToGlobal() if the widget has no parent. | - | ||||||||||||||||||||||||||||||||||||
4322 | - | |||||||||||||||||||||||||||||||||||||
4323 | \sa mapFromParent(), mapTo(), mapToGlobal(), underMouse() | - | ||||||||||||||||||||||||||||||||||||
4324 | */ | - | ||||||||||||||||||||||||||||||||||||
4325 | - | |||||||||||||||||||||||||||||||||||||
4326 | QPoint QWidget::mapToParent(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
4327 | { | - | ||||||||||||||||||||||||||||||||||||
4328 | return pos + data->crect.topLeft(); never executed: return pos + data->crect.topLeft(); | 0 | ||||||||||||||||||||||||||||||||||||
4329 | } | - | ||||||||||||||||||||||||||||||||||||
4330 | - | |||||||||||||||||||||||||||||||||||||
4331 | /*! | - | ||||||||||||||||||||||||||||||||||||
4332 | Translates the parent widget coordinate \a pos to widget | - | ||||||||||||||||||||||||||||||||||||
4333 | coordinates. | - | ||||||||||||||||||||||||||||||||||||
4334 | - | |||||||||||||||||||||||||||||||||||||
4335 | Same as mapFromGlobal() if the widget has no parent. | - | ||||||||||||||||||||||||||||||||||||
4336 | - | |||||||||||||||||||||||||||||||||||||
4337 | \sa mapToParent(), mapFrom(), mapFromGlobal(), underMouse() | - | ||||||||||||||||||||||||||||||||||||
4338 | */ | - | ||||||||||||||||||||||||||||||||||||
4339 | - | |||||||||||||||||||||||||||||||||||||
4340 | QPoint QWidget::mapFromParent(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
4341 | { | - | ||||||||||||||||||||||||||||||||||||
4342 | return pos - data->crect.topLeft(); never executed: return pos - data->crect.topLeft(); | 0 | ||||||||||||||||||||||||||||||||||||
4343 | } | - | ||||||||||||||||||||||||||||||||||||
4344 | - | |||||||||||||||||||||||||||||||||||||
4345 | - | |||||||||||||||||||||||||||||||||||||
4346 | /*! | - | ||||||||||||||||||||||||||||||||||||
4347 | Returns the window for this widget, i.e. the next ancestor widget | - | ||||||||||||||||||||||||||||||||||||
4348 | that has (or could have) a window-system frame. | - | ||||||||||||||||||||||||||||||||||||
4349 | - | |||||||||||||||||||||||||||||||||||||
4350 | If the widget is a window, the widget itself is returned. | - | ||||||||||||||||||||||||||||||||||||
4351 | - | |||||||||||||||||||||||||||||||||||||
4352 | Typical usage is changing the window title: | - | ||||||||||||||||||||||||||||||||||||
4353 | - | |||||||||||||||||||||||||||||||||||||
4354 | \snippet code/src_gui_kernel_qwidget.cpp 3 | - | ||||||||||||||||||||||||||||||||||||
4355 | - | |||||||||||||||||||||||||||||||||||||
4356 | \sa isWindow() | - | ||||||||||||||||||||||||||||||||||||
4357 | */ | - | ||||||||||||||||||||||||||||||||||||
4358 | - | |||||||||||||||||||||||||||||||||||||
4359 | QWidget *QWidget::window() const | - | ||||||||||||||||||||||||||||||||||||
4360 | { | - | ||||||||||||||||||||||||||||||||||||
4361 | QWidget *w = const_cast<QWidget *>(this); | - | ||||||||||||||||||||||||||||||||||||
4362 | QWidget *p = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
4363 | while (!w->isWindow() && p) {
| 0 | ||||||||||||||||||||||||||||||||||||
4364 | w = p; | - | ||||||||||||||||||||||||||||||||||||
4365 | p = p->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
4366 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4367 | return w; never executed: return w; | 0 | ||||||||||||||||||||||||||||||||||||
4368 | } | - | ||||||||||||||||||||||||||||||||||||
4369 | - | |||||||||||||||||||||||||||||||||||||
4370 | /*! | - | ||||||||||||||||||||||||||||||||||||
4371 | \since 4.4 | - | ||||||||||||||||||||||||||||||||||||
4372 | - | |||||||||||||||||||||||||||||||||||||
4373 | Returns the native parent for this widget, i.e. the next ancestor widget | - | ||||||||||||||||||||||||||||||||||||
4374 | that has a system identifier, or 0 if it does not have any native parent. | - | ||||||||||||||||||||||||||||||||||||
4375 | - | |||||||||||||||||||||||||||||||||||||
4376 | \sa effectiveWinId() | - | ||||||||||||||||||||||||||||||||||||
4377 | */ | - | ||||||||||||||||||||||||||||||||||||
4378 | QWidget *QWidget::nativeParentWidget() const | - | ||||||||||||||||||||||||||||||||||||
4379 | { | - | ||||||||||||||||||||||||||||||||||||
4380 | QWidget *parent = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
4381 | while (parent && !parent->internalWinId())
| 0 | ||||||||||||||||||||||||||||||||||||
4382 | parent = parent->parentWidget(); never executed: parent = parent->parentWidget(); | 0 | ||||||||||||||||||||||||||||||||||||
4383 | return parent; never executed: return parent; | 0 | ||||||||||||||||||||||||||||||||||||
4384 | } | - | ||||||||||||||||||||||||||||||||||||
4385 | - | |||||||||||||||||||||||||||||||||||||
4386 | /*! \fn QWidget *QWidget::topLevelWidget() const | - | ||||||||||||||||||||||||||||||||||||
4387 | \obsolete | - | ||||||||||||||||||||||||||||||||||||
4388 | - | |||||||||||||||||||||||||||||||||||||
4389 | Use window() instead. | - | ||||||||||||||||||||||||||||||||||||
4390 | */ | - | ||||||||||||||||||||||||||||||||||||
4391 | - | |||||||||||||||||||||||||||||||||||||
4392 | - | |||||||||||||||||||||||||||||||||||||
4393 | - | |||||||||||||||||||||||||||||||||||||
4394 | /*! | - | ||||||||||||||||||||||||||||||||||||
4395 | Returns the background role of the widget. | - | ||||||||||||||||||||||||||||||||||||
4396 | - | |||||||||||||||||||||||||||||||||||||
4397 | The background role defines the brush from the widget's \l palette that | - | ||||||||||||||||||||||||||||||||||||
4398 | is used to render the background. | - | ||||||||||||||||||||||||||||||||||||
4399 | - | |||||||||||||||||||||||||||||||||||||
4400 | If no explicit background role is set, the widget inherts its parent | - | ||||||||||||||||||||||||||||||||||||
4401 | widget's background role. | - | ||||||||||||||||||||||||||||||||||||
4402 | - | |||||||||||||||||||||||||||||||||||||
4403 | \sa setBackgroundRole(), foregroundRole() | - | ||||||||||||||||||||||||||||||||||||
4404 | */ | - | ||||||||||||||||||||||||||||||||||||
4405 | QPalette::ColorRole QWidget::backgroundRole() const | - | ||||||||||||||||||||||||||||||||||||
4406 | { | - | ||||||||||||||||||||||||||||||||||||
4407 | - | |||||||||||||||||||||||||||||||||||||
4408 | const QWidget *w = this; | - | ||||||||||||||||||||||||||||||||||||
4409 | do { | - | ||||||||||||||||||||||||||||||||||||
4410 | QPalette::ColorRole role = w->d_func()->bg_role; | - | ||||||||||||||||||||||||||||||||||||
4411 | if (role != QPalette::NoRole)
| 0 | ||||||||||||||||||||||||||||||||||||
4412 | return role; never executed: return role; | 0 | ||||||||||||||||||||||||||||||||||||
4413 | if (w->isWindow() || w->windowType() == Qt::SubWindow)
| 0 | ||||||||||||||||||||||||||||||||||||
4414 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
4415 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
4416 | } while (w); never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
4417 | return QPalette::Window; never executed: return QPalette::Window; | 0 | ||||||||||||||||||||||||||||||||||||
4418 | } | - | ||||||||||||||||||||||||||||||||||||
4419 | - | |||||||||||||||||||||||||||||||||||||
4420 | /*! | - | ||||||||||||||||||||||||||||||||||||
4421 | Sets the background role of the widget to \a role. | - | ||||||||||||||||||||||||||||||||||||
4422 | - | |||||||||||||||||||||||||||||||||||||
4423 | The background role defines the brush from the widget's \l palette that | - | ||||||||||||||||||||||||||||||||||||
4424 | is used to render the background. | - | ||||||||||||||||||||||||||||||||||||
4425 | - | |||||||||||||||||||||||||||||||||||||
4426 | If \a role is QPalette::NoRole, then the widget inherits its | - | ||||||||||||||||||||||||||||||||||||
4427 | parent's background role. | - | ||||||||||||||||||||||||||||||||||||
4428 | - | |||||||||||||||||||||||||||||||||||||
4429 | Note that styles are free to choose any color from the palette. | - | ||||||||||||||||||||||||||||||||||||
4430 | You can modify the palette or set a style sheet if you don't | - | ||||||||||||||||||||||||||||||||||||
4431 | achieve the result you want with setBackgroundRole(). | - | ||||||||||||||||||||||||||||||||||||
4432 | - | |||||||||||||||||||||||||||||||||||||
4433 | \sa backgroundRole(), foregroundRole() | - | ||||||||||||||||||||||||||||||||||||
4434 | */ | - | ||||||||||||||||||||||||||||||||||||
4435 | - | |||||||||||||||||||||||||||||||||||||
4436 | void QWidget::setBackgroundRole(QPalette::ColorRole role) | - | ||||||||||||||||||||||||||||||||||||
4437 | { | - | ||||||||||||||||||||||||||||||||||||
4438 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4439 | d->bg_role = role; | - | ||||||||||||||||||||||||||||||||||||
4440 | d->updateSystemBackground(); | - | ||||||||||||||||||||||||||||||||||||
4441 | d->propagatePaletteChange(); | - | ||||||||||||||||||||||||||||||||||||
4442 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
4443 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4444 | - | |||||||||||||||||||||||||||||||||||||
4445 | /*! | - | ||||||||||||||||||||||||||||||||||||
4446 | Returns the foreground role. | - | ||||||||||||||||||||||||||||||||||||
4447 | - | |||||||||||||||||||||||||||||||||||||
4448 | The foreground role defines the color from the widget's \l palette that | - | ||||||||||||||||||||||||||||||||||||
4449 | is used to draw the foreground. | - | ||||||||||||||||||||||||||||||||||||
4450 | - | |||||||||||||||||||||||||||||||||||||
4451 | If no explicit foreground role is set, the function returns a role | - | ||||||||||||||||||||||||||||||||||||
4452 | that contrasts with the background role. | - | ||||||||||||||||||||||||||||||||||||
4453 | - | |||||||||||||||||||||||||||||||||||||
4454 | \sa setForegroundRole(), backgroundRole() | - | ||||||||||||||||||||||||||||||||||||
4455 | */ | - | ||||||||||||||||||||||||||||||||||||
4456 | QPalette::ColorRole QWidget::foregroundRole() const | - | ||||||||||||||||||||||||||||||||||||
4457 | { | - | ||||||||||||||||||||||||||||||||||||
4458 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
4459 | QPalette::ColorRole rl = QPalette::ColorRole(d->fg_role); | - | ||||||||||||||||||||||||||||||||||||
4460 | if (rl != QPalette::NoRole)
| 0 | ||||||||||||||||||||||||||||||||||||
4461 | return rl; never executed: return rl; | 0 | ||||||||||||||||||||||||||||||||||||
4462 | QPalette::ColorRole role = QPalette::WindowText; | - | ||||||||||||||||||||||||||||||||||||
4463 | switch (backgroundRole()) { | - | ||||||||||||||||||||||||||||||||||||
4464 | case QPalette::Button: never executed: case QPalette::Button: | 0 | ||||||||||||||||||||||||||||||||||||
4465 | role = QPalette::ButtonText; | - | ||||||||||||||||||||||||||||||||||||
4466 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
4467 | case QPalette::Base: never executed: case QPalette::Base: | 0 | ||||||||||||||||||||||||||||||||||||
4468 | role = QPalette::Text; | - | ||||||||||||||||||||||||||||||||||||
4469 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
4470 | case QPalette::Dark: never executed: case QPalette::Dark: | 0 | ||||||||||||||||||||||||||||||||||||
4471 | case QPalette::Shadow: never executed: case QPalette::Shadow: | 0 | ||||||||||||||||||||||||||||||||||||
4472 | role = QPalette::Light; | - | ||||||||||||||||||||||||||||||||||||
4473 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
4474 | case QPalette::Highlight: never executed: case QPalette::Highlight: | 0 | ||||||||||||||||||||||||||||||||||||
4475 | role = QPalette::HighlightedText; | - | ||||||||||||||||||||||||||||||||||||
4476 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
4477 | case QPalette::ToolTipBase: never executed: case QPalette::ToolTipBase: | 0 | ||||||||||||||||||||||||||||||||||||
4478 | role = QPalette::ToolTipText; | - | ||||||||||||||||||||||||||||||||||||
4479 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
4480 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
4481 | ; | - | ||||||||||||||||||||||||||||||||||||
4482 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4483 | return role; never executed: return role; | 0 | ||||||||||||||||||||||||||||||||||||
4484 | } | - | ||||||||||||||||||||||||||||||||||||
4485 | - | |||||||||||||||||||||||||||||||||||||
4486 | /*! | - | ||||||||||||||||||||||||||||||||||||
4487 | Sets the foreground role of the widget to \a role. | - | ||||||||||||||||||||||||||||||||||||
4488 | - | |||||||||||||||||||||||||||||||||||||
4489 | The foreground role defines the color from the widget's \l palette that | - | ||||||||||||||||||||||||||||||||||||
4490 | is used to draw the foreground. | - | ||||||||||||||||||||||||||||||||||||
4491 | - | |||||||||||||||||||||||||||||||||||||
4492 | If \a role is QPalette::NoRole, the widget uses a foreground role | - | ||||||||||||||||||||||||||||||||||||
4493 | that contrasts with the background role. | - | ||||||||||||||||||||||||||||||||||||
4494 | - | |||||||||||||||||||||||||||||||||||||
4495 | Note that styles are free to choose any color from the palette. | - | ||||||||||||||||||||||||||||||||||||
4496 | You can modify the palette or set a style sheet if you don't | - | ||||||||||||||||||||||||||||||||||||
4497 | achieve the result you want with setForegroundRole(). | - | ||||||||||||||||||||||||||||||||||||
4498 | - | |||||||||||||||||||||||||||||||||||||
4499 | \sa foregroundRole(), backgroundRole() | - | ||||||||||||||||||||||||||||||||||||
4500 | */ | - | ||||||||||||||||||||||||||||||||||||
4501 | void QWidget::setForegroundRole(QPalette::ColorRole role) | - | ||||||||||||||||||||||||||||||||||||
4502 | { | - | ||||||||||||||||||||||||||||||||||||
4503 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4504 | d->fg_role = role; | - | ||||||||||||||||||||||||||||||||||||
4505 | d->updateSystemBackground(); | - | ||||||||||||||||||||||||||||||||||||
4506 | d->propagatePaletteChange(); | - | ||||||||||||||||||||||||||||||||||||
4507 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4508 | - | |||||||||||||||||||||||||||||||||||||
4509 | /*! | - | ||||||||||||||||||||||||||||||||||||
4510 | \property QWidget::palette | - | ||||||||||||||||||||||||||||||||||||
4511 | \brief the widget's palette | - | ||||||||||||||||||||||||||||||||||||
4512 | - | |||||||||||||||||||||||||||||||||||||
4513 | This property describes the widget's palette. The palette is used by the | - | ||||||||||||||||||||||||||||||||||||
4514 | widget's style when rendering standard components, and is available as a | - | ||||||||||||||||||||||||||||||||||||
4515 | means to ensure that custom widgets can maintain consistency with the | - | ||||||||||||||||||||||||||||||||||||
4516 | native platform's look and feel. It's common that different platforms, or | - | ||||||||||||||||||||||||||||||||||||
4517 | different styles, have different palettes. | - | ||||||||||||||||||||||||||||||||||||
4518 | - | |||||||||||||||||||||||||||||||||||||
4519 | When you assign a new palette to a widget, the color roles from this | - | ||||||||||||||||||||||||||||||||||||
4520 | palette are combined with the widget's default palette to form the | - | ||||||||||||||||||||||||||||||||||||
4521 | widget's final palette. The palette entry for the widget's background role | - | ||||||||||||||||||||||||||||||||||||
4522 | is used to fill the widget's background (see QWidget::autoFillBackground), | - | ||||||||||||||||||||||||||||||||||||
4523 | and the foreground role initializes QPainter's pen. | - | ||||||||||||||||||||||||||||||||||||
4524 | - | |||||||||||||||||||||||||||||||||||||
4525 | The default depends on the system environment. QApplication maintains a | - | ||||||||||||||||||||||||||||||||||||
4526 | system/theme palette which serves as a default for all widgets. There may | - | ||||||||||||||||||||||||||||||||||||
4527 | also be special palette defaults for certain types of widgets (e.g., on | - | ||||||||||||||||||||||||||||||||||||
4528 | Windows XP and Vista, all classes that derive from QMenuBar have a special | - | ||||||||||||||||||||||||||||||||||||
4529 | default palette). You can also define default palettes for widgets | - | ||||||||||||||||||||||||||||||||||||
4530 | yourself by passing a custom palette and the name of a widget to | - | ||||||||||||||||||||||||||||||||||||
4531 | QApplication::setPalette(). Finally, the style always has the option of | - | ||||||||||||||||||||||||||||||||||||
4532 | polishing the palette as it's assigned (see QStyle::polish()). | - | ||||||||||||||||||||||||||||||||||||
4533 | - | |||||||||||||||||||||||||||||||||||||
4534 | QWidget propagates explicit palette roles from parent to child. If you | - | ||||||||||||||||||||||||||||||||||||
4535 | assign a brush or color to a specific role on a palette and assign that | - | ||||||||||||||||||||||||||||||||||||
4536 | palette to a widget, that role will propagate to all the widget's | - | ||||||||||||||||||||||||||||||||||||
4537 | children, overriding any system defaults for that role. Note that palettes | - | ||||||||||||||||||||||||||||||||||||
4538 | by default don't propagate to windows (see isWindow()) unless the | - | ||||||||||||||||||||||||||||||||||||
4539 | Qt::WA_WindowPropagation attribute is enabled. | - | ||||||||||||||||||||||||||||||||||||
4540 | - | |||||||||||||||||||||||||||||||||||||
4541 | QWidget's palette propagation is similar to its font propagation. | - | ||||||||||||||||||||||||||||||||||||
4542 | - | |||||||||||||||||||||||||||||||||||||
4543 | The current style, which is used to render the content of all standard Qt | - | ||||||||||||||||||||||||||||||||||||
4544 | widgets, is free to choose colors and brushes from the widget palette, or | - | ||||||||||||||||||||||||||||||||||||
4545 | in some cases, to ignore the palette (partially, or completely). In | - | ||||||||||||||||||||||||||||||||||||
4546 | particular, certain styles like GTK style, Mac style, Windows XP, and | - | ||||||||||||||||||||||||||||||||||||
4547 | Vista style, depend on third party APIs to render the content of widgets, | - | ||||||||||||||||||||||||||||||||||||
4548 | and these styles typically do not follow the palette. Because of this, | - | ||||||||||||||||||||||||||||||||||||
4549 | assigning roles to a widget's palette is not guaranteed to change the | - | ||||||||||||||||||||||||||||||||||||
4550 | appearance of the widget. Instead, you may choose to apply a \l | - | ||||||||||||||||||||||||||||||||||||
4551 | styleSheet. You can refer to our Knowledge Base article | - | ||||||||||||||||||||||||||||||||||||
4552 | \l{http://qt.nokia.com/developer/knowledgebase/22}{here} for more | - | ||||||||||||||||||||||||||||||||||||
4553 | information. | - | ||||||||||||||||||||||||||||||||||||
4554 | - | |||||||||||||||||||||||||||||||||||||
4555 | \warning Do not use this function in conjunction with \l{Qt Style Sheets}. | - | ||||||||||||||||||||||||||||||||||||
4556 | When using style sheets, the palette of a widget can be customized using | - | ||||||||||||||||||||||||||||||||||||
4557 | the "color", "background-color", "selection-color", | - | ||||||||||||||||||||||||||||||||||||
4558 | "selection-background-color" and "alternate-background-color". | - | ||||||||||||||||||||||||||||||||||||
4559 | - | |||||||||||||||||||||||||||||||||||||
4560 | \sa QApplication::palette(), QWidget::font() | - | ||||||||||||||||||||||||||||||||||||
4561 | */ | - | ||||||||||||||||||||||||||||||||||||
4562 | const QPalette &QWidget::palette() const | - | ||||||||||||||||||||||||||||||||||||
4563 | { | - | ||||||||||||||||||||||||||||||||||||
4564 | if (!isEnabled()) {
| 0 | ||||||||||||||||||||||||||||||||||||
4565 | data->pal.setCurrentColorGroup(QPalette::Disabled); | - | ||||||||||||||||||||||||||||||||||||
4566 | } else if ((!isVisible() || isActiveWindow()) never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
4567 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) | - | ||||||||||||||||||||||||||||||||||||
4568 | && !QApplicationPrivate::isBlockedByModal(const_cast<QWidget *>(this)) | - | ||||||||||||||||||||||||||||||||||||
4569 | #endif | - | ||||||||||||||||||||||||||||||||||||
4570 | ) { | - | ||||||||||||||||||||||||||||||||||||
4571 | data->pal.setCurrentColorGroup(QPalette::Active); | - | ||||||||||||||||||||||||||||||||||||
4572 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4573 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
4574 | extern bool qt_mac_can_clickThrough(const QWidget *); //qwidget_mac.cpp | - | ||||||||||||||||||||||||||||||||||||
4575 | if (qt_mac_can_clickThrough(this)) | - | ||||||||||||||||||||||||||||||||||||
4576 | data->pal.setCurrentColorGroup(QPalette::Active); | - | ||||||||||||||||||||||||||||||||||||
4577 | else | - | ||||||||||||||||||||||||||||||||||||
4578 | #endif | - | ||||||||||||||||||||||||||||||||||||
4579 | data->pal.setCurrentColorGroup(QPalette::Inactive); | - | ||||||||||||||||||||||||||||||||||||
4580 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4581 | return data->pal; never executed: return data->pal; | 0 | ||||||||||||||||||||||||||||||||||||
4582 | } | - | ||||||||||||||||||||||||||||||||||||
4583 | - | |||||||||||||||||||||||||||||||||||||
4584 | void QWidget::setPalette(const QPalette &palette) | - | ||||||||||||||||||||||||||||||||||||
4585 | { | - | ||||||||||||||||||||||||||||||||||||
4586 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4587 | setAttribute(Qt::WA_SetPalette, palette.resolve() != 0); | - | ||||||||||||||||||||||||||||||||||||
4588 | - | |||||||||||||||||||||||||||||||||||||
4589 | // Determine which palette is inherited from this widget's ancestors and | - | ||||||||||||||||||||||||||||||||||||
4590 | // QApplication::palette, resolve this against \a palette (attributes from | - | ||||||||||||||||||||||||||||||||||||
4591 | // the inherited palette are copied over this widget's palette). Then | - | ||||||||||||||||||||||||||||||||||||
4592 | // propagate this palette to this widget's children. | - | ||||||||||||||||||||||||||||||||||||
4593 | QPalette naturalPalette = d->naturalWidgetPalette(d->inheritedPaletteResolveMask); | - | ||||||||||||||||||||||||||||||||||||
4594 | QPalette resolvedPalette = palette.resolve(naturalPalette); | - | ||||||||||||||||||||||||||||||||||||
4595 | d->setPalette_helper(resolvedPalette); | - | ||||||||||||||||||||||||||||||||||||
4596 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4597 | - | |||||||||||||||||||||||||||||||||||||
4598 | /*! | - | ||||||||||||||||||||||||||||||||||||
4599 | \internal | - | ||||||||||||||||||||||||||||||||||||
4600 | - | |||||||||||||||||||||||||||||||||||||
4601 | Returns the palette that the widget \a w inherits from its ancestors and | - | ||||||||||||||||||||||||||||||||||||
4602 | QApplication::palette. \a inheritedMask is the combination of the widget's | - | ||||||||||||||||||||||||||||||||||||
4603 | ancestors palette request masks (i.e., which attributes from the parent | - | ||||||||||||||||||||||||||||||||||||
4604 | widget's palette are implicitly imposed on this widget by the user). Note | - | ||||||||||||||||||||||||||||||||||||
4605 | that this font does not take into account the palette set on \a w itself. | - | ||||||||||||||||||||||||||||||||||||
4606 | */ | - | ||||||||||||||||||||||||||||||||||||
4607 | QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const | - | ||||||||||||||||||||||||||||||||||||
4608 | { | - | ||||||||||||||||||||||||||||||||||||
4609 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
4610 | - | |||||||||||||||||||||||||||||||||||||
4611 | const bool useStyleSheetPropagationInWidgetStyles = | - | ||||||||||||||||||||||||||||||||||||
4612 | QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); | - | ||||||||||||||||||||||||||||||||||||
4613 | - | |||||||||||||||||||||||||||||||||||||
4614 | QPalette naturalPalette = QApplication::palette(q); | - | ||||||||||||||||||||||||||||||||||||
4615 | if ((!q->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles)
| 0 | ||||||||||||||||||||||||||||||||||||
4616 | && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
| 0 | ||||||||||||||||||||||||||||||||||||
4617 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4618 | || (extra && extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
4619 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4620 | )) { | - | ||||||||||||||||||||||||||||||||||||
4621 | if (QWidget *p = q->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
4622 | if (!p->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles) {
| 0 | ||||||||||||||||||||||||||||||||||||
4623 | if (!naturalPalette.isCopyOf(QApplication::palette())) {
| 0 | ||||||||||||||||||||||||||||||||||||
4624 | QPalette inheritedPalette = p->palette(); | - | ||||||||||||||||||||||||||||||||||||
4625 | inheritedPalette.resolve(inheritedMask); | - | ||||||||||||||||||||||||||||||||||||
4626 | naturalPalette = inheritedPalette.resolve(naturalPalette); | - | ||||||||||||||||||||||||||||||||||||
4627 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4628 | naturalPalette = p->palette(); | - | ||||||||||||||||||||||||||||||||||||
4629 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4630 | } | - | ||||||||||||||||||||||||||||||||||||
4631 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4632 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4633 | else if (extra && extra->proxyWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
4634 | QPalette inheritedPalette = extra->proxyWidget->palette(); | - | ||||||||||||||||||||||||||||||||||||
4635 | inheritedPalette.resolve(inheritedMask); | - | ||||||||||||||||||||||||||||||||||||
4636 | naturalPalette = inheritedPalette.resolve(naturalPalette); | - | ||||||||||||||||||||||||||||||||||||
4637 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4638 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4639 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4640 | naturalPalette.resolve(0); | - | ||||||||||||||||||||||||||||||||||||
4641 | return naturalPalette; never executed: return naturalPalette; | 0 | ||||||||||||||||||||||||||||||||||||
4642 | } | - | ||||||||||||||||||||||||||||||||||||
4643 | /*! | - | ||||||||||||||||||||||||||||||||||||
4644 | \internal | - | ||||||||||||||||||||||||||||||||||||
4645 | - | |||||||||||||||||||||||||||||||||||||
4646 | Determine which palette is inherited from this widget's ancestors and | - | ||||||||||||||||||||||||||||||||||||
4647 | QApplication::palette, resolve this against this widget's palette | - | ||||||||||||||||||||||||||||||||||||
4648 | (attributes from the inherited palette are copied over this widget's | - | ||||||||||||||||||||||||||||||||||||
4649 | palette). Then propagate this palette to this widget's children. | - | ||||||||||||||||||||||||||||||||||||
4650 | */ | - | ||||||||||||||||||||||||||||||||||||
4651 | void QWidgetPrivate::resolvePalette() | - | ||||||||||||||||||||||||||||||||||||
4652 | { | - | ||||||||||||||||||||||||||||||||||||
4653 | QPalette naturalPalette = naturalWidgetPalette(inheritedPaletteResolveMask); | - | ||||||||||||||||||||||||||||||||||||
4654 | QPalette resolvedPalette = data.pal.resolve(naturalPalette); | - | ||||||||||||||||||||||||||||||||||||
4655 | setPalette_helper(resolvedPalette); | - | ||||||||||||||||||||||||||||||||||||
4656 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4657 | - | |||||||||||||||||||||||||||||||||||||
4658 | void QWidgetPrivate::setPalette_helper(const QPalette &palette) | - | ||||||||||||||||||||||||||||||||||||
4659 | { | - | ||||||||||||||||||||||||||||||||||||
4660 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4661 | if (data.pal == palette && data.pal.resolve() == palette.resolve())
| 0 | ||||||||||||||||||||||||||||||||||||
4662 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4663 | data.pal = palette; | - | ||||||||||||||||||||||||||||||||||||
4664 | updateSystemBackground(); | - | ||||||||||||||||||||||||||||||||||||
4665 | propagatePaletteChange(); | - | ||||||||||||||||||||||||||||||||||||
4666 | updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
4667 | q->update(); | - | ||||||||||||||||||||||||||||||||||||
4668 | updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
4669 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4670 | - | |||||||||||||||||||||||||||||||||||||
4671 | void QWidgetPrivate::updateSystemBackground() | - | ||||||||||||||||||||||||||||||||||||
4672 | { | - | ||||||||||||||||||||||||||||||||||||
4673 | } | - | ||||||||||||||||||||||||||||||||||||
4674 | - | |||||||||||||||||||||||||||||||||||||
4675 | /*! | - | ||||||||||||||||||||||||||||||||||||
4676 | \property QWidget::font | - | ||||||||||||||||||||||||||||||||||||
4677 | \brief the font currently set for the widget | - | ||||||||||||||||||||||||||||||||||||
4678 | - | |||||||||||||||||||||||||||||||||||||
4679 | This property describes the widget's requested font. The font is used by | - | ||||||||||||||||||||||||||||||||||||
4680 | the widget's style when rendering standard components, and is available as | - | ||||||||||||||||||||||||||||||||||||
4681 | a means to ensure that custom widgets can maintain consistency with the | - | ||||||||||||||||||||||||||||||||||||
4682 | native platform's look and feel. It's common that different platforms, or | - | ||||||||||||||||||||||||||||||||||||
4683 | different styles, define different fonts for an application. | - | ||||||||||||||||||||||||||||||||||||
4684 | - | |||||||||||||||||||||||||||||||||||||
4685 | When you assign a new font to a widget, the properties from this font are | - | ||||||||||||||||||||||||||||||||||||
4686 | combined with the widget's default font to form the widget's final | - | ||||||||||||||||||||||||||||||||||||
4687 | font. You can call fontInfo() to get a copy of the widget's final | - | ||||||||||||||||||||||||||||||||||||
4688 | font. The final font is also used to initialize QPainter's font. | - | ||||||||||||||||||||||||||||||||||||
4689 | - | |||||||||||||||||||||||||||||||||||||
4690 | The default depends on the system environment. QApplication maintains a | - | ||||||||||||||||||||||||||||||||||||
4691 | system/theme font which serves as a default for all widgets. There may | - | ||||||||||||||||||||||||||||||||||||
4692 | also be special font defaults for certain types of widgets. You can also | - | ||||||||||||||||||||||||||||||||||||
4693 | define default fonts for widgets yourself by passing a custom font and the | - | ||||||||||||||||||||||||||||||||||||
4694 | name of a widget to QApplication::setFont(). Finally, the font is matched | - | ||||||||||||||||||||||||||||||||||||
4695 | against Qt's font database to find the best match. | - | ||||||||||||||||||||||||||||||||||||
4696 | - | |||||||||||||||||||||||||||||||||||||
4697 | QWidget propagates explicit font properties from parent to child. If you | - | ||||||||||||||||||||||||||||||||||||
4698 | change a specific property on a font and assign that font to a widget, | - | ||||||||||||||||||||||||||||||||||||
4699 | that property will propagate to all the widget's children, overriding any | - | ||||||||||||||||||||||||||||||||||||
4700 | system defaults for that property. Note that fonts by default don't | - | ||||||||||||||||||||||||||||||||||||
4701 | propagate to windows (see isWindow()) unless the Qt::WA_WindowPropagation | - | ||||||||||||||||||||||||||||||||||||
4702 | attribute is enabled. | - | ||||||||||||||||||||||||||||||||||||
4703 | - | |||||||||||||||||||||||||||||||||||||
4704 | QWidget's font propagation is similar to its palette propagation. | - | ||||||||||||||||||||||||||||||||||||
4705 | - | |||||||||||||||||||||||||||||||||||||
4706 | The current style, which is used to render the content of all standard Qt | - | ||||||||||||||||||||||||||||||||||||
4707 | widgets, is free to choose to use the widget font, or in some cases, to | - | ||||||||||||||||||||||||||||||||||||
4708 | ignore it (partially, or completely). In particular, certain styles like | - | ||||||||||||||||||||||||||||||||||||
4709 | GTK style, Mac style, Windows XP, and Vista style, apply special | - | ||||||||||||||||||||||||||||||||||||
4710 | modifications to the widget font to match the platform's native look and | - | ||||||||||||||||||||||||||||||||||||
4711 | feel. Because of this, assigning properties to a widget's font is not | - | ||||||||||||||||||||||||||||||||||||
4712 | guaranteed to change the appearance of the widget. Instead, you may choose | - | ||||||||||||||||||||||||||||||||||||
4713 | to apply a \l styleSheet. | - | ||||||||||||||||||||||||||||||||||||
4714 | - | |||||||||||||||||||||||||||||||||||||
4715 | \note If \l{Qt Style Sheets} are used on the same widget as setFont(), | - | ||||||||||||||||||||||||||||||||||||
4716 | style sheets will take precedence if the settings conflict. | - | ||||||||||||||||||||||||||||||||||||
4717 | - | |||||||||||||||||||||||||||||||||||||
4718 | \sa fontInfo(), fontMetrics() | - | ||||||||||||||||||||||||||||||||||||
4719 | */ | - | ||||||||||||||||||||||||||||||||||||
4720 | - | |||||||||||||||||||||||||||||||||||||
4721 | void QWidget::setFont(const QFont &font) | - | ||||||||||||||||||||||||||||||||||||
4722 | { | - | ||||||||||||||||||||||||||||||||||||
4723 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4724 | - | |||||||||||||||||||||||||||||||||||||
4725 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
4726 | const QStyleSheetStyle* style; | - | ||||||||||||||||||||||||||||||||||||
4727 | if (d->extra && (style = qobject_cast<const QStyleSheetStyle*>(d->extra->style))) {
| 0 | ||||||||||||||||||||||||||||||||||||
4728 | style->saveWidgetFont(this, font); | - | ||||||||||||||||||||||||||||||||||||
4729 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4730 | #endif | - | ||||||||||||||||||||||||||||||||||||
4731 | - | |||||||||||||||||||||||||||||||||||||
4732 | setAttribute(Qt::WA_SetFont, font.resolve() != 0); | - | ||||||||||||||||||||||||||||||||||||
4733 | - | |||||||||||||||||||||||||||||||||||||
4734 | // Determine which font is inherited from this widget's ancestors and | - | ||||||||||||||||||||||||||||||||||||
4735 | // QApplication::font, resolve this against \a font (attributes from the | - | ||||||||||||||||||||||||||||||||||||
4736 | // inherited font are copied over). Then propagate this font to this | - | ||||||||||||||||||||||||||||||||||||
4737 | // widget's children. | - | ||||||||||||||||||||||||||||||||||||
4738 | QFont naturalFont = d->naturalWidgetFont(d->inheritedFontResolveMask); | - | ||||||||||||||||||||||||||||||||||||
4739 | QFont resolvedFont = font.resolve(naturalFont); | - | ||||||||||||||||||||||||||||||||||||
4740 | d->setFont_helper(resolvedFont); | - | ||||||||||||||||||||||||||||||||||||
4741 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4742 | - | |||||||||||||||||||||||||||||||||||||
4743 | /* | - | ||||||||||||||||||||||||||||||||||||
4744 | \internal | - | ||||||||||||||||||||||||||||||||||||
4745 | - | |||||||||||||||||||||||||||||||||||||
4746 | Returns the font that the widget \a w inherits from its ancestors and | - | ||||||||||||||||||||||||||||||||||||
4747 | QApplication::font. \a inheritedMask is the combination of the widget's | - | ||||||||||||||||||||||||||||||||||||
4748 | ancestors font request masks (i.e., which attributes from the parent | - | ||||||||||||||||||||||||||||||||||||
4749 | widget's font are implicitly imposed on this widget by the user). Note | - | ||||||||||||||||||||||||||||||||||||
4750 | that this font does not take into account the font set on \a w itself. | - | ||||||||||||||||||||||||||||||||||||
4751 | - | |||||||||||||||||||||||||||||||||||||
4752 | ### Stylesheet has a different font propagation mechanism. When a stylesheet | - | ||||||||||||||||||||||||||||||||||||
4753 | is applied, fonts are not propagated anymore | - | ||||||||||||||||||||||||||||||||||||
4754 | */ | - | ||||||||||||||||||||||||||||||||||||
4755 | QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const | - | ||||||||||||||||||||||||||||||||||||
4756 | { | - | ||||||||||||||||||||||||||||||||||||
4757 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
4758 | - | |||||||||||||||||||||||||||||||||||||
4759 | const bool useStyleSheetPropagationInWidgetStyles = | - | ||||||||||||||||||||||||||||||||||||
4760 | QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); | - | ||||||||||||||||||||||||||||||||||||
4761 | - | |||||||||||||||||||||||||||||||||||||
4762 | QFont naturalFont = QApplication::font(q); | - | ||||||||||||||||||||||||||||||||||||
4763 | if ((!q->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles)
| 0 | ||||||||||||||||||||||||||||||||||||
4764 | && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
| 0 | ||||||||||||||||||||||||||||||||||||
4765 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4766 | || (extra && extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
4767 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4768 | )) { | - | ||||||||||||||||||||||||||||||||||||
4769 | if (QWidget *p = q->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
4770 | if (!p->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles) {
| 0 | ||||||||||||||||||||||||||||||||||||
4771 | if (!naturalFont.isCopyOf(QApplication::font())) {
| 0 | ||||||||||||||||||||||||||||||||||||
4772 | if (inheritedMask != 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
4773 | QFont inheritedFont = p->font(); | - | ||||||||||||||||||||||||||||||||||||
4774 | inheritedFont.resolve(inheritedMask); | - | ||||||||||||||||||||||||||||||||||||
4775 | naturalFont = inheritedFont.resolve(naturalFont); | - | ||||||||||||||||||||||||||||||||||||
4776 | } // else nothing to do (naturalFont = naturalFont) never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4777 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4778 | naturalFont = p->font(); | - | ||||||||||||||||||||||||||||||||||||
4779 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4780 | } | - | ||||||||||||||||||||||||||||||||||||
4781 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4782 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4783 | else if (extra && extra->proxyWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
4784 | if (inheritedMask != 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
4785 | QFont inheritedFont = extra->proxyWidget->font(); | - | ||||||||||||||||||||||||||||||||||||
4786 | inheritedFont.resolve(inheritedMask); | - | ||||||||||||||||||||||||||||||||||||
4787 | naturalFont = inheritedFont.resolve(naturalFont); | - | ||||||||||||||||||||||||||||||||||||
4788 | } // else nothing to do (naturalFont = naturalFont) never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4789 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4790 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4791 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4792 | naturalFont.resolve(0); | - | ||||||||||||||||||||||||||||||||||||
4793 | return naturalFont; never executed: return naturalFont; | 0 | ||||||||||||||||||||||||||||||||||||
4794 | } | - | ||||||||||||||||||||||||||||||||||||
4795 | - | |||||||||||||||||||||||||||||||||||||
4796 | /*! | - | ||||||||||||||||||||||||||||||||||||
4797 | \internal | - | ||||||||||||||||||||||||||||||||||||
4798 | - | |||||||||||||||||||||||||||||||||||||
4799 | Determine which font is implicitly imposed on this widget by its ancestors | - | ||||||||||||||||||||||||||||||||||||
4800 | and QApplication::font, resolve this against its own font (attributes from | - | ||||||||||||||||||||||||||||||||||||
4801 | the implicit font are copied over). Then propagate this font to this | - | ||||||||||||||||||||||||||||||||||||
4802 | widget's children. | - | ||||||||||||||||||||||||||||||||||||
4803 | */ | - | ||||||||||||||||||||||||||||||||||||
4804 | void QWidgetPrivate::resolveFont() | - | ||||||||||||||||||||||||||||||||||||
4805 | { | - | ||||||||||||||||||||||||||||||||||||
4806 | QFont naturalFont = naturalWidgetFont(inheritedFontResolveMask); | - | ||||||||||||||||||||||||||||||||||||
4807 | QFont resolvedFont = data.fnt.resolve(naturalFont); | - | ||||||||||||||||||||||||||||||||||||
4808 | setFont_helper(resolvedFont); | - | ||||||||||||||||||||||||||||||||||||
4809 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4810 | - | |||||||||||||||||||||||||||||||||||||
4811 | /*! | - | ||||||||||||||||||||||||||||||||||||
4812 | \internal | - | ||||||||||||||||||||||||||||||||||||
4813 | - | |||||||||||||||||||||||||||||||||||||
4814 | Assign \a font to this widget, and propagate it to all children, except | - | ||||||||||||||||||||||||||||||||||||
4815 | style sheet widgets (handled differently) and windows that don't enable | - | ||||||||||||||||||||||||||||||||||||
4816 | window propagation. \a implicitMask is the union of all ancestor widgets' | - | ||||||||||||||||||||||||||||||||||||
4817 | font request masks, and determines which attributes from this widget's | - | ||||||||||||||||||||||||||||||||||||
4818 | font should propagate. | - | ||||||||||||||||||||||||||||||||||||
4819 | */ | - | ||||||||||||||||||||||||||||||||||||
4820 | void QWidgetPrivate::updateFont(const QFont &font) | - | ||||||||||||||||||||||||||||||||||||
4821 | { | - | ||||||||||||||||||||||||||||||||||||
4822 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4823 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
4824 | const QStyleSheetStyle* cssStyle; | - | ||||||||||||||||||||||||||||||||||||
4825 | cssStyle = extra ? qobject_cast<const QStyleSheetStyle*>(extra->style) : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
4826 | const bool useStyleSheetPropagationInWidgetStyles = | - | ||||||||||||||||||||||||||||||||||||
4827 | QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); | - | ||||||||||||||||||||||||||||||||||||
4828 | #endif | - | ||||||||||||||||||||||||||||||||||||
4829 | - | |||||||||||||||||||||||||||||||||||||
4830 | data.fnt = QFont(font, q); | - | ||||||||||||||||||||||||||||||||||||
4831 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
4832 | // make sure the font set on this widget is associated with the correct screen | - | ||||||||||||||||||||||||||||||||||||
4833 | data.fnt.x11SetScreen(xinfo.screen()); | - | ||||||||||||||||||||||||||||||||||||
4834 | #endif | - | ||||||||||||||||||||||||||||||||||||
4835 | // Combine new mask with natural mask and propagate to children. | - | ||||||||||||||||||||||||||||||||||||
4836 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4837 | if (!q->parentWidget() && extra && extra->proxyWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
4838 | QGraphicsProxyWidget *p = extra->proxyWidget; | - | ||||||||||||||||||||||||||||||||||||
4839 | inheritedFontResolveMask = p->d_func()->inheritedFontResolveMask | p->font().resolve(); | - | ||||||||||||||||||||||||||||||||||||
4840 | } else never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4841 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4842 | if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
| 0 | ||||||||||||||||||||||||||||||||||||
4843 | inheritedFontResolveMask = 0; | - | ||||||||||||||||||||||||||||||||||||
4844 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4845 | uint newMask = data.fnt.resolve() | inheritedFontResolveMask; | - | ||||||||||||||||||||||||||||||||||||
4846 | - | |||||||||||||||||||||||||||||||||||||
4847 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
4848 | QWidget *w = qobject_cast<QWidget*>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
4849 | if (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
4850 | if (0) { dead code: { } | - | ||||||||||||||||||||||||||||||||||||
4851 | #ifndef QT_NO_STYLE_STYLESHEET dead code: { } | - | ||||||||||||||||||||||||||||||||||||
4852 | } else if (!useStyleSheetPropagationInWidgetStyles && w->testAttribute(Qt::WA_StyleSheet)) { dead code: { }
| - | ||||||||||||||||||||||||||||||||||||
4853 | // Style sheets follow a different font propagation scheme. | - | ||||||||||||||||||||||||||||||||||||
4854 | if (cssStyle)
| 0 | ||||||||||||||||||||||||||||||||||||
4855 | cssStyle->updateStyleSheetFont(w); never executed: cssStyle->updateStyleSheetFont(w); | 0 | ||||||||||||||||||||||||||||||||||||
4856 | #endif | - | ||||||||||||||||||||||||||||||||||||
4857 | } else if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
4858 | // Propagate font changes. | - | ||||||||||||||||||||||||||||||||||||
4859 | QWidgetPrivate *wd = w->d_func(); | - | ||||||||||||||||||||||||||||||||||||
4860 | wd->inheritedFontResolveMask = newMask; | - | ||||||||||||||||||||||||||||||||||||
4861 | wd->resolveFont(); | - | ||||||||||||||||||||||||||||||||||||
4862 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4863 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4864 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4865 | - | |||||||||||||||||||||||||||||||||||||
4866 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
4867 | if (!useStyleSheetPropagationInWidgetStyles && cssStyle) {
| 0 | ||||||||||||||||||||||||||||||||||||
4868 | cssStyle->updateStyleSheetFont(q); | - | ||||||||||||||||||||||||||||||||||||
4869 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4870 | #endif | - | ||||||||||||||||||||||||||||||||||||
4871 | - | |||||||||||||||||||||||||||||||||||||
4872 | QEvent e(QEvent::FontChange); | - | ||||||||||||||||||||||||||||||||||||
4873 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
4874 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4875 | - | |||||||||||||||||||||||||||||||||||||
4876 | void QWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction) | - | ||||||||||||||||||||||||||||||||||||
4877 | { | - | ||||||||||||||||||||||||||||||||||||
4878 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4879 | - | |||||||||||||||||||||||||||||||||||||
4880 | if ( (direction == Qt::RightToLeft) == q->testAttribute(Qt::WA_RightToLeft))
| 0 | ||||||||||||||||||||||||||||||||||||
4881 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4882 | q->setAttribute(Qt::WA_RightToLeft, (direction == Qt::RightToLeft)); | - | ||||||||||||||||||||||||||||||||||||
4883 | if (!children.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
4884 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
4885 | QWidget *w = qobject_cast<QWidget*>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
4886 | if (w && !w->isWindow() && !w->testAttribute(Qt::WA_SetLayoutDirection))
| 0 | ||||||||||||||||||||||||||||||||||||
4887 | w->d_func()->setLayoutDirection_helper(direction); never executed: w->d_func()->setLayoutDirection_helper(direction); | 0 | ||||||||||||||||||||||||||||||||||||
4888 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4889 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4890 | QEvent e(QEvent::LayoutDirectionChange); | - | ||||||||||||||||||||||||||||||||||||
4891 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
4892 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4893 | - | |||||||||||||||||||||||||||||||||||||
4894 | void QWidgetPrivate::resolveLayoutDirection() | - | ||||||||||||||||||||||||||||||||||||
4895 | { | - | ||||||||||||||||||||||||||||||||||||
4896 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
4897 | if (!q->testAttribute(Qt::WA_SetLayoutDirection))
| 0 | ||||||||||||||||||||||||||||||||||||
4898 | setLayoutDirection_helper(q->isWindow() ? QApplication::layoutDirection() : q->parentWidget()->layoutDirection()); never executed: setLayoutDirection_helper(q->isWindow() ? QApplication::layoutDirection() : q->parentWidget()->layoutDirection()); | 0 | ||||||||||||||||||||||||||||||||||||
4899 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4900 | - | |||||||||||||||||||||||||||||||||||||
4901 | /*! | - | ||||||||||||||||||||||||||||||||||||
4902 | \property QWidget::layoutDirection | - | ||||||||||||||||||||||||||||||||||||
4903 | - | |||||||||||||||||||||||||||||||||||||
4904 | \brief the layout direction for this widget | - | ||||||||||||||||||||||||||||||||||||
4905 | - | |||||||||||||||||||||||||||||||||||||
4906 | By default, this property is set to Qt::LeftToRight. | - | ||||||||||||||||||||||||||||||||||||
4907 | - | |||||||||||||||||||||||||||||||||||||
4908 | When the layout direction is set on a widget, it will propagate to | - | ||||||||||||||||||||||||||||||||||||
4909 | the widget's children, but not to a child that is a window and not | - | ||||||||||||||||||||||||||||||||||||
4910 | to a child for which setLayoutDirection() has been explicitly | - | ||||||||||||||||||||||||||||||||||||
4911 | called. Also, child widgets added \e after setLayoutDirection() | - | ||||||||||||||||||||||||||||||||||||
4912 | has been called for the parent do not inherit the parent's layout | - | ||||||||||||||||||||||||||||||||||||
4913 | direction. | - | ||||||||||||||||||||||||||||||||||||
4914 | - | |||||||||||||||||||||||||||||||||||||
4915 | This method no longer affects text layout direction since Qt 4.7. | - | ||||||||||||||||||||||||||||||||||||
4916 | - | |||||||||||||||||||||||||||||||||||||
4917 | \sa QApplication::layoutDirection | - | ||||||||||||||||||||||||||||||||||||
4918 | */ | - | ||||||||||||||||||||||||||||||||||||
4919 | void QWidget::setLayoutDirection(Qt::LayoutDirection direction) | - | ||||||||||||||||||||||||||||||||||||
4920 | { | - | ||||||||||||||||||||||||||||||||||||
4921 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4922 | - | |||||||||||||||||||||||||||||||||||||
4923 | if (direction == Qt::LayoutDirectionAuto) {
| 0 | ||||||||||||||||||||||||||||||||||||
4924 | unsetLayoutDirection(); | - | ||||||||||||||||||||||||||||||||||||
4925 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4926 | } | - | ||||||||||||||||||||||||||||||||||||
4927 | - | |||||||||||||||||||||||||||||||||||||
4928 | setAttribute(Qt::WA_SetLayoutDirection); | - | ||||||||||||||||||||||||||||||||||||
4929 | d->setLayoutDirection_helper(direction); | - | ||||||||||||||||||||||||||||||||||||
4930 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4931 | - | |||||||||||||||||||||||||||||||||||||
4932 | Qt::LayoutDirection QWidget::layoutDirection() const | - | ||||||||||||||||||||||||||||||||||||
4933 | { | - | ||||||||||||||||||||||||||||||||||||
4934 | return testAttribute(Qt::WA_RightToLeft) ? Qt::RightToLeft : Qt::LeftToRight; never executed: return testAttribute(Qt::WA_RightToLeft) ? Qt::RightToLeft : Qt::LeftToRight; | 0 | ||||||||||||||||||||||||||||||||||||
4935 | } | - | ||||||||||||||||||||||||||||||||||||
4936 | - | |||||||||||||||||||||||||||||||||||||
4937 | void QWidget::unsetLayoutDirection() | - | ||||||||||||||||||||||||||||||||||||
4938 | { | - | ||||||||||||||||||||||||||||||||||||
4939 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4940 | setAttribute(Qt::WA_SetLayoutDirection, false); | - | ||||||||||||||||||||||||||||||||||||
4941 | d->resolveLayoutDirection(); | - | ||||||||||||||||||||||||||||||||||||
4942 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4943 | - | |||||||||||||||||||||||||||||||||||||
4944 | /*! | - | ||||||||||||||||||||||||||||||||||||
4945 | \fn QFontMetrics QWidget::fontMetrics() const | - | ||||||||||||||||||||||||||||||||||||
4946 | - | |||||||||||||||||||||||||||||||||||||
4947 | Returns the font metrics for the widget's current font. | - | ||||||||||||||||||||||||||||||||||||
4948 | Equivalent to \c QFontMetrics(widget->font()). | - | ||||||||||||||||||||||||||||||||||||
4949 | - | |||||||||||||||||||||||||||||||||||||
4950 | \sa font(), fontInfo(), setFont() | - | ||||||||||||||||||||||||||||||||||||
4951 | */ | - | ||||||||||||||||||||||||||||||||||||
4952 | - | |||||||||||||||||||||||||||||||||||||
4953 | /*! | - | ||||||||||||||||||||||||||||||||||||
4954 | \fn QFontInfo QWidget::fontInfo() const | - | ||||||||||||||||||||||||||||||||||||
4955 | - | |||||||||||||||||||||||||||||||||||||
4956 | Returns the font info for the widget's current font. | - | ||||||||||||||||||||||||||||||||||||
4957 | Equivalent to \c QFontInfo(widget->font()). | - | ||||||||||||||||||||||||||||||||||||
4958 | - | |||||||||||||||||||||||||||||||||||||
4959 | \sa font(), fontMetrics(), setFont() | - | ||||||||||||||||||||||||||||||||||||
4960 | */ | - | ||||||||||||||||||||||||||||||||||||
4961 | - | |||||||||||||||||||||||||||||||||||||
4962 | - | |||||||||||||||||||||||||||||||||||||
4963 | /*! | - | ||||||||||||||||||||||||||||||||||||
4964 | \property QWidget::cursor | - | ||||||||||||||||||||||||||||||||||||
4965 | \brief the cursor shape for this widget | - | ||||||||||||||||||||||||||||||||||||
4966 | - | |||||||||||||||||||||||||||||||||||||
4967 | The mouse cursor will assume this shape when it's over this | - | ||||||||||||||||||||||||||||||||||||
4968 | widget. See the \l{Qt::CursorShape}{list of predefined cursor objects} for a range of useful shapes. | - | ||||||||||||||||||||||||||||||||||||
4969 | - | |||||||||||||||||||||||||||||||||||||
4970 | An editor widget might use an I-beam cursor: | - | ||||||||||||||||||||||||||||||||||||
4971 | \snippet code/src_gui_kernel_qwidget.cpp 6 | - | ||||||||||||||||||||||||||||||||||||
4972 | - | |||||||||||||||||||||||||||||||||||||
4973 | If no cursor has been set, or after a call to unsetCursor(), the | - | ||||||||||||||||||||||||||||||||||||
4974 | parent's cursor is used. | - | ||||||||||||||||||||||||||||||||||||
4975 | - | |||||||||||||||||||||||||||||||||||||
4976 | By default, this property contains a cursor with the Qt::ArrowCursor | - | ||||||||||||||||||||||||||||||||||||
4977 | shape. | - | ||||||||||||||||||||||||||||||||||||
4978 | - | |||||||||||||||||||||||||||||||||||||
4979 | Some underlying window implementations will reset the cursor if it | - | ||||||||||||||||||||||||||||||||||||
4980 | leaves a widget even if the mouse is grabbed. If you want to have | - | ||||||||||||||||||||||||||||||||||||
4981 | a cursor set for all widgets, even when outside the window, consider | - | ||||||||||||||||||||||||||||||||||||
4982 | QApplication::setOverrideCursor(). | - | ||||||||||||||||||||||||||||||||||||
4983 | - | |||||||||||||||||||||||||||||||||||||
4984 | \sa QApplication::setOverrideCursor() | - | ||||||||||||||||||||||||||||||||||||
4985 | */ | - | ||||||||||||||||||||||||||||||||||||
4986 | - | |||||||||||||||||||||||||||||||||||||
4987 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
4988 | QCursor QWidget::cursor() const | - | ||||||||||||||||||||||||||||||||||||
4989 | { | - | ||||||||||||||||||||||||||||||||||||
4990 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
4991 | if (testAttribute(Qt::WA_SetCursor))
| 0 | ||||||||||||||||||||||||||||||||||||
4992 | return (d->extra && d->extra->curs) never executed: return (d->extra && d->extra->curs) ? *d->extra->curs : QCursor(Qt::ArrowCursor); | 0 | ||||||||||||||||||||||||||||||||||||
4993 | ? *d->extra->curs never executed: return (d->extra && d->extra->curs) ? *d->extra->curs : QCursor(Qt::ArrowCursor); | 0 | ||||||||||||||||||||||||||||||||||||
4994 | : QCursor(Qt::ArrowCursor); never executed: return (d->extra && d->extra->curs) ? *d->extra->curs : QCursor(Qt::ArrowCursor); | 0 | ||||||||||||||||||||||||||||||||||||
4995 | if (isWindow() || !parentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
4996 | return QCursor(Qt::ArrowCursor); never executed: return QCursor(Qt::ArrowCursor); | 0 | ||||||||||||||||||||||||||||||||||||
4997 | return parentWidget()->cursor(); never executed: return parentWidget()->cursor(); | 0 | ||||||||||||||||||||||||||||||||||||
4998 | } | - | ||||||||||||||||||||||||||||||||||||
4999 | - | |||||||||||||||||||||||||||||||||||||
5000 | void QWidget::setCursor(const QCursor &cursor) | - | ||||||||||||||||||||||||||||||||||||
5001 | { | - | ||||||||||||||||||||||||||||||||||||
5002 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5003 | // On Mac we must set the cursor even if it is the ArrowCursor. | - | ||||||||||||||||||||||||||||||||||||
5004 | #if !defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
5005 | if (cursor.shape() != Qt::ArrowCursor
| 0 | ||||||||||||||||||||||||||||||||||||
5006 | || (d->extra && d->extra->curs))
| 0 | ||||||||||||||||||||||||||||||||||||
5007 | #endif | - | ||||||||||||||||||||||||||||||||||||
5008 | { | - | ||||||||||||||||||||||||||||||||||||
5009 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
5010 | QCursor *newCursor = new QCursor(cursor); | - | ||||||||||||||||||||||||||||||||||||
5011 | delete d->extra->curs; | - | ||||||||||||||||||||||||||||||||||||
5012 | d->extra->curs = newCursor; | - | ||||||||||||||||||||||||||||||||||||
5013 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5014 | setAttribute(Qt::WA_SetCursor); | - | ||||||||||||||||||||||||||||||||||||
5015 | d->setCursor_sys(cursor); | - | ||||||||||||||||||||||||||||||||||||
5016 | - | |||||||||||||||||||||||||||||||||||||
5017 | QEvent event(QEvent::CursorChange); | - | ||||||||||||||||||||||||||||||||||||
5018 | QApplication::sendEvent(this, &event); | - | ||||||||||||||||||||||||||||||||||||
5019 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5020 | - | |||||||||||||||||||||||||||||||||||||
5021 | void QWidgetPrivate::setCursor_sys(const QCursor &cursor) | - | ||||||||||||||||||||||||||||||||||||
5022 | { | - | ||||||||||||||||||||||||||||||||||||
5023 | Q_UNUSED(cursor); | - | ||||||||||||||||||||||||||||||||||||
5024 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5025 | qt_qpa_set_cursor(q, false); | - | ||||||||||||||||||||||||||||||||||||
5026 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5027 | - | |||||||||||||||||||||||||||||||||||||
5028 | void QWidget::unsetCursor() | - | ||||||||||||||||||||||||||||||||||||
5029 | { | - | ||||||||||||||||||||||||||||||||||||
5030 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5031 | if (d->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
5032 | delete d->extra->curs; | - | ||||||||||||||||||||||||||||||||||||
5033 | d->extra->curs = 0; | - | ||||||||||||||||||||||||||||||||||||
5034 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5035 | if (!isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
5036 | setAttribute(Qt::WA_SetCursor, false); never executed: setAttribute(Qt::WA_SetCursor, false); | 0 | ||||||||||||||||||||||||||||||||||||
5037 | d->unsetCursor_sys(); | - | ||||||||||||||||||||||||||||||||||||
5038 | - | |||||||||||||||||||||||||||||||||||||
5039 | QEvent event(QEvent::CursorChange); | - | ||||||||||||||||||||||||||||||||||||
5040 | QApplication::sendEvent(this, &event); | - | ||||||||||||||||||||||||||||||||||||
5041 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5042 | - | |||||||||||||||||||||||||||||||||||||
5043 | void QWidgetPrivate::unsetCursor_sys() | - | ||||||||||||||||||||||||||||||||||||
5044 | { | - | ||||||||||||||||||||||||||||||||||||
5045 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5046 | qt_qpa_set_cursor(q, false); | - | ||||||||||||||||||||||||||||||||||||
5047 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5048 | - | |||||||||||||||||||||||||||||||||||||
5049 | static inline void applyCursor(QWidget *w, const QCursor &c) | - | ||||||||||||||||||||||||||||||||||||
5050 | { | - | ||||||||||||||||||||||||||||||||||||
5051 | if (QWindow *window = w->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
5052 | window->setCursor(c); never executed: window->setCursor(c); | 0 | ||||||||||||||||||||||||||||||||||||
5053 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5054 | - | |||||||||||||||||||||||||||||||||||||
5055 | static inline void unsetCursor(QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
5056 | { | - | ||||||||||||||||||||||||||||||||||||
5057 | if (QWindow *window = w->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
5058 | window->unsetCursor(); never executed: window->unsetCursor(); | 0 | ||||||||||||||||||||||||||||||||||||
5059 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5060 | - | |||||||||||||||||||||||||||||||||||||
5061 | void qt_qpa_set_cursor(QWidget *w, bool force) | - | ||||||||||||||||||||||||||||||||||||
5062 | { | - | ||||||||||||||||||||||||||||||||||||
5063 | if (!w->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
5064 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5065 | - | |||||||||||||||||||||||||||||||||||||
5066 | static QPointer<QWidget> lastUnderMouse = 0; | - | ||||||||||||||||||||||||||||||||||||
5067 | if (force) {
| 0 | ||||||||||||||||||||||||||||||||||||
5068 | lastUnderMouse = w; | - | ||||||||||||||||||||||||||||||||||||
5069 | } else if (lastUnderMouse) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
5070 | const WId lastWinId = lastUnderMouse->effectiveWinId(); | - | ||||||||||||||||||||||||||||||||||||
5071 | const WId winId = w->effectiveWinId(); | - | ||||||||||||||||||||||||||||||||||||
5072 | if (lastWinId && lastWinId == winId)
| 0 | ||||||||||||||||||||||||||||||||||||
5073 | w = lastUnderMouse; never executed: w = lastUnderMouse; | 0 | ||||||||||||||||||||||||||||||||||||
5074 | } else if (!w->internalWinId()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
5075 | return; // The mouse is not under this widget, and it's not native, so don't change it. never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5076 | } | - | ||||||||||||||||||||||||||||||||||||
5077 | - | |||||||||||||||||||||||||||||||||||||
5078 | while (!w->internalWinId() && w->parentWidget() && !w->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
5079 | && !w->testAttribute(Qt::WA_SetCursor))
| 0 | ||||||||||||||||||||||||||||||||||||
5080 | w = w->parentWidget(); never executed: w = w->parentWidget(); | 0 | ||||||||||||||||||||||||||||||||||||
5081 | - | |||||||||||||||||||||||||||||||||||||
5082 | QWidget *nativeParent = w; | - | ||||||||||||||||||||||||||||||||||||
5083 | if (!w->internalWinId())
| 0 | ||||||||||||||||||||||||||||||||||||
5084 | nativeParent = w->nativeParentWidget(); never executed: nativeParent = w->nativeParentWidget(); | 0 | ||||||||||||||||||||||||||||||||||||
5085 | if (!nativeParent || !nativeParent->internalWinId())
| 0 | ||||||||||||||||||||||||||||||||||||
5086 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5087 | - | |||||||||||||||||||||||||||||||||||||
5088 | if (w->isWindow() || w->testAttribute(Qt::WA_SetCursor)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5089 | if (w->isEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
5090 | applyCursor(nativeParent, w->cursor()); never executed: applyCursor(nativeParent, w->cursor()); | 0 | ||||||||||||||||||||||||||||||||||||
5091 | else | - | ||||||||||||||||||||||||||||||||||||
5092 | // Enforce the windows behavior of clearing the cursor on | - | ||||||||||||||||||||||||||||||||||||
5093 | // disabled widgets. | - | ||||||||||||||||||||||||||||||||||||
5094 | unsetCursor(nativeParent); never executed: unsetCursor(nativeParent); | 0 | ||||||||||||||||||||||||||||||||||||
5095 | } else { | - | ||||||||||||||||||||||||||||||||||||
5096 | unsetCursor(nativeParent); | - | ||||||||||||||||||||||||||||||||||||
5097 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5098 | } | - | ||||||||||||||||||||||||||||||||||||
5099 | #endif | - | ||||||||||||||||||||||||||||||||||||
5100 | - | |||||||||||||||||||||||||||||||||||||
5101 | /*! | - | ||||||||||||||||||||||||||||||||||||
5102 | \enum QWidget::RenderFlag | - | ||||||||||||||||||||||||||||||||||||
5103 | - | |||||||||||||||||||||||||||||||||||||
5104 | This enum describes how to render the widget when calling QWidget::render(). | - | ||||||||||||||||||||||||||||||||||||
5105 | - | |||||||||||||||||||||||||||||||||||||
5106 | \value DrawWindowBackground If you enable this option, the widget's background | - | ||||||||||||||||||||||||||||||||||||
5107 | is rendered into the target even if autoFillBackground is not set. By default, | - | ||||||||||||||||||||||||||||||||||||
5108 | this option is enabled. | - | ||||||||||||||||||||||||||||||||||||
5109 | - | |||||||||||||||||||||||||||||||||||||
5110 | \value DrawChildren If you enable this option, the widget's children | - | ||||||||||||||||||||||||||||||||||||
5111 | are rendered recursively into the target. By default, this option is enabled. | - | ||||||||||||||||||||||||||||||||||||
5112 | - | |||||||||||||||||||||||||||||||||||||
5113 | \value IgnoreMask If you enable this option, the widget's QWidget::mask() | - | ||||||||||||||||||||||||||||||||||||
5114 | is ignored when rendering into the target. By default, this option is disabled. | - | ||||||||||||||||||||||||||||||||||||
5115 | - | |||||||||||||||||||||||||||||||||||||
5116 | \since 4.3 | - | ||||||||||||||||||||||||||||||||||||
5117 | */ | - | ||||||||||||||||||||||||||||||||||||
5118 | - | |||||||||||||||||||||||||||||||||||||
5119 | /*! | - | ||||||||||||||||||||||||||||||||||||
5120 | \since 4.3 | - | ||||||||||||||||||||||||||||||||||||
5121 | - | |||||||||||||||||||||||||||||||||||||
5122 | Renders the \a sourceRegion of this widget into the \a target | - | ||||||||||||||||||||||||||||||||||||
5123 | using \a renderFlags to determine how to render. Rendering | - | ||||||||||||||||||||||||||||||||||||
5124 | starts at \a targetOffset in the \a target. For example: | - | ||||||||||||||||||||||||||||||||||||
5125 | - | |||||||||||||||||||||||||||||||||||||
5126 | \snippet code/src_gui_kernel_qwidget.cpp 7 | - | ||||||||||||||||||||||||||||||||||||
5127 | - | |||||||||||||||||||||||||||||||||||||
5128 | If \a sourceRegion is a null region, this function will use QWidget::rect() as | - | ||||||||||||||||||||||||||||||||||||
5129 | the region, i.e. the entire widget. | - | ||||||||||||||||||||||||||||||||||||
5130 | - | |||||||||||||||||||||||||||||||||||||
5131 | Ensure that you call QPainter::end() for the \a target device's | - | ||||||||||||||||||||||||||||||||||||
5132 | active painter (if any) before rendering. For example: | - | ||||||||||||||||||||||||||||||||||||
5133 | - | |||||||||||||||||||||||||||||||||||||
5134 | \snippet code/src_gui_kernel_qwidget.cpp 8 | - | ||||||||||||||||||||||||||||||||||||
5135 | - | |||||||||||||||||||||||||||||||||||||
5136 | \note To obtain the contents of an OpenGL widget, use QGLWidget::grabFrameBuffer() | - | ||||||||||||||||||||||||||||||||||||
5137 | or QGLWidget::renderPixmap() instead. | - | ||||||||||||||||||||||||||||||||||||
5138 | */ | - | ||||||||||||||||||||||||||||||||||||
5139 | void QWidget::render(QPaintDevice *target, const QPoint &targetOffset, | - | ||||||||||||||||||||||||||||||||||||
5140 | const QRegion &sourceRegion, RenderFlags renderFlags) | - | ||||||||||||||||||||||||||||||||||||
5141 | { | - | ||||||||||||||||||||||||||||||||||||
5142 | QPainter p(target); | - | ||||||||||||||||||||||||||||||||||||
5143 | render(&p, targetOffset, sourceRegion, renderFlags); | - | ||||||||||||||||||||||||||||||||||||
5144 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5145 | - | |||||||||||||||||||||||||||||||||||||
5146 | /*! | - | ||||||||||||||||||||||||||||||||||||
5147 | \overload | - | ||||||||||||||||||||||||||||||||||||
5148 | - | |||||||||||||||||||||||||||||||||||||
5149 | Renders the widget into the \a painter's QPainter::device(). | - | ||||||||||||||||||||||||||||||||||||
5150 | - | |||||||||||||||||||||||||||||||||||||
5151 | Transformations and settings applied to the \a painter will be used | - | ||||||||||||||||||||||||||||||||||||
5152 | when rendering. | - | ||||||||||||||||||||||||||||||||||||
5153 | - | |||||||||||||||||||||||||||||||||||||
5154 | \note The \a painter must be active. On \macos the widget will be | - | ||||||||||||||||||||||||||||||||||||
5155 | rendered into a QPixmap and then drawn by the \a painter. | - | ||||||||||||||||||||||||||||||||||||
5156 | - | |||||||||||||||||||||||||||||||||||||
5157 | \sa QPainter::device() | - | ||||||||||||||||||||||||||||||||||||
5158 | */ | - | ||||||||||||||||||||||||||||||||||||
5159 | void QWidget::render(QPainter *painter, const QPoint &targetOffset, | - | ||||||||||||||||||||||||||||||||||||
5160 | const QRegion &sourceRegion, RenderFlags renderFlags) | - | ||||||||||||||||||||||||||||||||||||
5161 | { | - | ||||||||||||||||||||||||||||||||||||
5162 | if (Q_UNLIKELY(!painter)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5163 | qWarning("QWidget::render: Null pointer to painter"); | - | ||||||||||||||||||||||||||||||||||||
5164 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5165 | } | - | ||||||||||||||||||||||||||||||||||||
5166 | - | |||||||||||||||||||||||||||||||||||||
5167 | if (Q_UNLIKELY(!painter->isActive())) {
| 0 | ||||||||||||||||||||||||||||||||||||
5168 | qWarning("QWidget::render: Cannot render with an inactive painter"); | - | ||||||||||||||||||||||||||||||||||||
5169 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5170 | } | - | ||||||||||||||||||||||||||||||||||||
5171 | - | |||||||||||||||||||||||||||||||||||||
5172 | const qreal opacity = painter->opacity(); | - | ||||||||||||||||||||||||||||||||||||
5173 | if (qFuzzyIsNull(opacity))
| 0 | ||||||||||||||||||||||||||||||||||||
5174 | return; // Fully transparent. never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5175 | - | |||||||||||||||||||||||||||||||||||||
5176 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5177 | const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter;
| 0 | ||||||||||||||||||||||||||||||||||||
5178 | const QRegion toBePainted = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags)
| 0 | ||||||||||||||||||||||||||||||||||||
5179 | : sourceRegion; | - | ||||||||||||||||||||||||||||||||||||
5180 | if (toBePainted.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
5181 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5182 | - | |||||||||||||||||||||||||||||||||||||
5183 | if (!d->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
5184 | d->createExtra(); never executed: d->createExtra(); | 0 | ||||||||||||||||||||||||||||||||||||
5185 | d->extra->inRenderWithPainter = true; | - | ||||||||||||||||||||||||||||||||||||
5186 | - | |||||||||||||||||||||||||||||||||||||
5187 | QPaintEngine *engine = painter->paintEngine(); | - | ||||||||||||||||||||||||||||||||||||
5188 | Q_ASSERT(engine); | - | ||||||||||||||||||||||||||||||||||||
5189 | QPaintEnginePrivate *enginePriv = engine->d_func(); | - | ||||||||||||||||||||||||||||||||||||
5190 | Q_ASSERT(enginePriv); | - | ||||||||||||||||||||||||||||||||||||
5191 | QPaintDevice *target = engine->paintDevice(); | - | ||||||||||||||||||||||||||||||||||||
5192 | Q_ASSERT(target); | - | ||||||||||||||||||||||||||||||||||||
5193 | - | |||||||||||||||||||||||||||||||||||||
5194 | // Render via a pixmap when dealing with non-opaque painters or printers. | - | ||||||||||||||||||||||||||||||||||||
5195 | if (!inRenderWithPainter && (opacity < 1.0 || (target->devType() == QInternal::Printer))) {
| 0 | ||||||||||||||||||||||||||||||||||||
5196 | d->render_helper(painter, targetOffset, toBePainted, renderFlags); | - | ||||||||||||||||||||||||||||||||||||
5197 | d->extra->inRenderWithPainter = inRenderWithPainter; | - | ||||||||||||||||||||||||||||||||||||
5198 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5199 | } | - | ||||||||||||||||||||||||||||||||||||
5200 | - | |||||||||||||||||||||||||||||||||||||
5201 | // Set new shared painter. | - | ||||||||||||||||||||||||||||||||||||
5202 | QPainter *oldPainter = d->sharedPainter(); | - | ||||||||||||||||||||||||||||||||||||
5203 | d->setSharedPainter(painter); | - | ||||||||||||||||||||||||||||||||||||
5204 | - | |||||||||||||||||||||||||||||||||||||
5205 | // Save current system clip, viewport and transform, | - | ||||||||||||||||||||||||||||||||||||
5206 | const QTransform oldTransform = enginePriv->systemTransform; | - | ||||||||||||||||||||||||||||||||||||
5207 | const QRegion oldSystemClip = enginePriv->systemClip; | - | ||||||||||||||||||||||||||||||||||||
5208 | const QRegion oldSystemViewport = enginePriv->systemViewport; | - | ||||||||||||||||||||||||||||||||||||
5209 | - | |||||||||||||||||||||||||||||||||||||
5210 | // This ensures that all painting triggered by render() is clipped to the current engine clip. | - | ||||||||||||||||||||||||||||||||||||
5211 | if (painter->hasClipping()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5212 | const QRegion painterClip = painter->deviceTransform().map(painter->clipRegion()); | - | ||||||||||||||||||||||||||||||||||||
5213 | enginePriv->setSystemViewport(oldSystemClip.isEmpty() ? painterClip : oldSystemClip & painterClip); | - | ||||||||||||||||||||||||||||||||||||
5214 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5215 | enginePriv->setSystemViewport(oldSystemClip); | - | ||||||||||||||||||||||||||||||||||||
5216 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5217 | - | |||||||||||||||||||||||||||||||||||||
5218 | d->render(target, targetOffset, toBePainted, renderFlags); | - | ||||||||||||||||||||||||||||||||||||
5219 | - | |||||||||||||||||||||||||||||||||||||
5220 | // Restore system clip, viewport and transform. | - | ||||||||||||||||||||||||||||||||||||
5221 | enginePriv->setSystemViewport(oldSystemViewport); | - | ||||||||||||||||||||||||||||||||||||
5222 | enginePriv->setSystemTransform(oldTransform); | - | ||||||||||||||||||||||||||||||||||||
5223 | enginePriv->systemClip = oldSystemClip; | - | ||||||||||||||||||||||||||||||||||||
5224 | - | |||||||||||||||||||||||||||||||||||||
5225 | // Restore shared painter. | - | ||||||||||||||||||||||||||||||||||||
5226 | d->setSharedPainter(oldPainter); | - | ||||||||||||||||||||||||||||||||||||
5227 | - | |||||||||||||||||||||||||||||||||||||
5228 | d->extra->inRenderWithPainter = inRenderWithPainter; | - | ||||||||||||||||||||||||||||||||||||
5229 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5230 | - | |||||||||||||||||||||||||||||||||||||
5231 | static void sendResizeEvents(QWidget *target) | - | ||||||||||||||||||||||||||||||||||||
5232 | { | - | ||||||||||||||||||||||||||||||||||||
5233 | QResizeEvent e(target->size(), QSize()); | - | ||||||||||||||||||||||||||||||||||||
5234 | QApplication::sendEvent(target, &e); | - | ||||||||||||||||||||||||||||||||||||
5235 | - | |||||||||||||||||||||||||||||||||||||
5236 | const QObjectList children = target->children(); | - | ||||||||||||||||||||||||||||||||||||
5237 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
5238 | if (!children.at(i)->isWidgetType())
| 0 | ||||||||||||||||||||||||||||||||||||
5239 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
5240 | QWidget *child = static_cast<QWidget*>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
5241 | if (!child->isWindow() && child->testAttribute(Qt::WA_PendingResizeEvent))
| 0 | ||||||||||||||||||||||||||||||||||||
5242 | sendResizeEvents(child); never executed: sendResizeEvents(child); | 0 | ||||||||||||||||||||||||||||||||||||
5243 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5244 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5245 | - | |||||||||||||||||||||||||||||||||||||
5246 | /*! | - | ||||||||||||||||||||||||||||||||||||
5247 | \since 5.0 | - | ||||||||||||||||||||||||||||||||||||
5248 | - | |||||||||||||||||||||||||||||||||||||
5249 | Renders the widget into a pixmap restricted by the | - | ||||||||||||||||||||||||||||||||||||
5250 | given \a rectangle. If the widget has any children, then | - | ||||||||||||||||||||||||||||||||||||
5251 | they are also painted in the appropriate positions. | - | ||||||||||||||||||||||||||||||||||||
5252 | - | |||||||||||||||||||||||||||||||||||||
5253 | If a rectangle with an invalid size is specified (the default), | - | ||||||||||||||||||||||||||||||||||||
5254 | the entire widget is painted. | - | ||||||||||||||||||||||||||||||||||||
5255 | - | |||||||||||||||||||||||||||||||||||||
5256 | \sa render(), QPixmap | - | ||||||||||||||||||||||||||||||||||||
5257 | */ | - | ||||||||||||||||||||||||||||||||||||
5258 | - | |||||||||||||||||||||||||||||||||||||
5259 | /* INVOKABLE since used by QPixmap::grabWidget(). */ | - | ||||||||||||||||||||||||||||||||||||
5260 | QPixmap QWidget::grab(const QRect &rectangle) | - | ||||||||||||||||||||||||||||||||||||
5261 | { | - | ||||||||||||||||||||||||||||||||||||
5262 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5263 | if (testAttribute(Qt::WA_PendingResizeEvent) || !testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
5264 | sendResizeEvents(this); never executed: sendResizeEvents(this); | 0 | ||||||||||||||||||||||||||||||||||||
5265 | - | |||||||||||||||||||||||||||||||||||||
5266 | const QWidget::RenderFlags renderFlags = QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask; | - | ||||||||||||||||||||||||||||||||||||
5267 | - | |||||||||||||||||||||||||||||||||||||
5268 | const bool oldDirtyOpaqueChildren = d->dirtyOpaqueChildren; | - | ||||||||||||||||||||||||||||||||||||
5269 | QRect r(rectangle); | - | ||||||||||||||||||||||||||||||||||||
5270 | if (r.width() < 0 || r.height() < 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
5271 | // For grabbing widgets that haven't been shown yet, | - | ||||||||||||||||||||||||||||||||||||
5272 | // we trigger the layouting mechanism to determine the widget's size. | - | ||||||||||||||||||||||||||||||||||||
5273 | r = d->prepareToRender(QRegion(), renderFlags).boundingRect(); | - | ||||||||||||||||||||||||||||||||||||
5274 | r.setTopLeft(rectangle.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
5275 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5276 | - | |||||||||||||||||||||||||||||||||||||
5277 | if (!r.intersects(rect()))
| 0 | ||||||||||||||||||||||||||||||||||||
5278 | return QPixmap(); never executed: return QPixmap(); | 0 | ||||||||||||||||||||||||||||||||||||
5279 | - | |||||||||||||||||||||||||||||||||||||
5280 | const qreal dpr = devicePixelRatioF(); | - | ||||||||||||||||||||||||||||||||||||
5281 | QPixmap res((QSizeF(r.size()) * dpr).toSize()); | - | ||||||||||||||||||||||||||||||||||||
5282 | res.setDevicePixelRatio(dpr); | - | ||||||||||||||||||||||||||||||||||||
5283 | if (!d->isOpaque)
| 0 | ||||||||||||||||||||||||||||||||||||
5284 | res.fill(Qt::transparent); never executed: res.fill(Qt::transparent); | 0 | ||||||||||||||||||||||||||||||||||||
5285 | d->render(&res, QPoint(), QRegion(r), renderFlags); | - | ||||||||||||||||||||||||||||||||||||
5286 | - | |||||||||||||||||||||||||||||||||||||
5287 | d->dirtyOpaqueChildren = oldDirtyOpaqueChildren; | - | ||||||||||||||||||||||||||||||||||||
5288 | return res; never executed: return res; | 0 | ||||||||||||||||||||||||||||||||||||
5289 | } | - | ||||||||||||||||||||||||||||||||||||
5290 | - | |||||||||||||||||||||||||||||||||||||
5291 | /*! | - | ||||||||||||||||||||||||||||||||||||
5292 | \brief The graphicsEffect function returns a pointer to the | - | ||||||||||||||||||||||||||||||||||||
5293 | widget's graphics effect. | - | ||||||||||||||||||||||||||||||||||||
5294 | - | |||||||||||||||||||||||||||||||||||||
5295 | If the widget has no graphics effect, 0 is returned. | - | ||||||||||||||||||||||||||||||||||||
5296 | - | |||||||||||||||||||||||||||||||||||||
5297 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
5298 | - | |||||||||||||||||||||||||||||||||||||
5299 | \sa setGraphicsEffect() | - | ||||||||||||||||||||||||||||||||||||
5300 | */ | - | ||||||||||||||||||||||||||||||||||||
5301 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5302 | QGraphicsEffect *QWidget::graphicsEffect() const | - | ||||||||||||||||||||||||||||||||||||
5303 | { | - | ||||||||||||||||||||||||||||||||||||
5304 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
5305 | return d->graphicsEffect; never executed: return d->graphicsEffect; | 0 | ||||||||||||||||||||||||||||||||||||
5306 | } | - | ||||||||||||||||||||||||||||||||||||
5307 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5308 | - | |||||||||||||||||||||||||||||||||||||
5309 | /*! | - | ||||||||||||||||||||||||||||||||||||
5310 | - | |||||||||||||||||||||||||||||||||||||
5311 | \brief The setGraphicsEffect function is for setting the widget's graphics effect. | - | ||||||||||||||||||||||||||||||||||||
5312 | - | |||||||||||||||||||||||||||||||||||||
5313 | Sets \a effect as the widget's effect. If there already is an effect installed | - | ||||||||||||||||||||||||||||||||||||
5314 | on this widget, QWidget will delete the existing effect before installing | - | ||||||||||||||||||||||||||||||||||||
5315 | the new \a effect. | - | ||||||||||||||||||||||||||||||||||||
5316 | - | |||||||||||||||||||||||||||||||||||||
5317 | If \a effect is the installed effect on a different widget, setGraphicsEffect() will remove | - | ||||||||||||||||||||||||||||||||||||
5318 | the effect from the widget and install it on this widget. | - | ||||||||||||||||||||||||||||||||||||
5319 | - | |||||||||||||||||||||||||||||||||||||
5320 | QWidget takes ownership of \a effect. | - | ||||||||||||||||||||||||||||||||||||
5321 | - | |||||||||||||||||||||||||||||||||||||
5322 | \note This function will apply the effect on itself and all its children. | - | ||||||||||||||||||||||||||||||||||||
5323 | - | |||||||||||||||||||||||||||||||||||||
5324 | \note Graphics effects are not supported for OpenGL-based widgets, such as QGLWidget, | - | ||||||||||||||||||||||||||||||||||||
5325 | QOpenGLWidget and QQuickWidget. | - | ||||||||||||||||||||||||||||||||||||
5326 | - | |||||||||||||||||||||||||||||||||||||
5327 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
5328 | - | |||||||||||||||||||||||||||||||||||||
5329 | \sa graphicsEffect() | - | ||||||||||||||||||||||||||||||||||||
5330 | */ | - | ||||||||||||||||||||||||||||||||||||
5331 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5332 | void QWidget::setGraphicsEffect(QGraphicsEffect *effect) | - | ||||||||||||||||||||||||||||||||||||
5333 | { | - | ||||||||||||||||||||||||||||||||||||
5334 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5335 | if (d->graphicsEffect == effect)
| 0 | ||||||||||||||||||||||||||||||||||||
5336 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5337 | - | |||||||||||||||||||||||||||||||||||||
5338 | if (d->graphicsEffect) {
| 0 | ||||||||||||||||||||||||||||||||||||
5339 | d->invalidateBuffer(rect()); | - | ||||||||||||||||||||||||||||||||||||
5340 | delete d->graphicsEffect; | - | ||||||||||||||||||||||||||||||||||||
5341 | d->graphicsEffect = 0; | - | ||||||||||||||||||||||||||||||||||||
5342 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5343 | - | |||||||||||||||||||||||||||||||||||||
5344 | if (effect) {
| 0 | ||||||||||||||||||||||||||||||||||||
5345 | // Set new effect. | - | ||||||||||||||||||||||||||||||||||||
5346 | QGraphicsEffectSourcePrivate *sourced = new QWidgetEffectSourcePrivate(this); | - | ||||||||||||||||||||||||||||||||||||
5347 | QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced); | - | ||||||||||||||||||||||||||||||||||||
5348 | d->graphicsEffect = effect; | - | ||||||||||||||||||||||||||||||||||||
5349 | effect->d_func()->setGraphicsEffectSource(source); | - | ||||||||||||||||||||||||||||||||||||
5350 | update(); | - | ||||||||||||||||||||||||||||||||||||
5351 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5352 | - | |||||||||||||||||||||||||||||||||||||
5353 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
5354 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5355 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5356 | - | |||||||||||||||||||||||||||||||||||||
5357 | bool QWidgetPrivate::isAboutToShow() const | - | ||||||||||||||||||||||||||||||||||||
5358 | { | - | ||||||||||||||||||||||||||||||||||||
5359 | if (data.in_show)
| 0 | ||||||||||||||||||||||||||||||||||||
5360 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
5361 | - | |||||||||||||||||||||||||||||||||||||
5362 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
5363 | if (q->isHidden())
| 0 | ||||||||||||||||||||||||||||||||||||
5364 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
5365 | - | |||||||||||||||||||||||||||||||||||||
5366 | // The widget will be shown if any of its ancestors are about to show. | - | ||||||||||||||||||||||||||||||||||||
5367 | QWidget *parent = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
5368 | return parent ? parent->d_func()->isAboutToShow() : false; never executed: return parent ? parent->d_func()->isAboutToShow() : false; | 0 | ||||||||||||||||||||||||||||||||||||
5369 | } | - | ||||||||||||||||||||||||||||||||||||
5370 | - | |||||||||||||||||||||||||||||||||||||
5371 | QRegion QWidgetPrivate::prepareToRender(const QRegion ®ion, QWidget::RenderFlags renderFlags) | - | ||||||||||||||||||||||||||||||||||||
5372 | { | - | ||||||||||||||||||||||||||||||||||||
5373 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5374 | const bool isVisible = q->isVisible(); | - | ||||||||||||||||||||||||||||||||||||
5375 | - | |||||||||||||||||||||||||||||||||||||
5376 | // Make sure the widget is laid out correctly. | - | ||||||||||||||||||||||||||||||||||||
5377 | if (!isVisible && !isAboutToShow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5378 | QWidget *topLevel = q->window(); | - | ||||||||||||||||||||||||||||||||||||
5379 | (void)topLevel->d_func()->topData(); // Make sure we at least have top-data. | - | ||||||||||||||||||||||||||||||||||||
5380 | topLevel->ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
5381 | - | |||||||||||||||||||||||||||||||||||||
5382 | // Invalidate the layout of hidden ancestors (incl. myself) and pretend | - | ||||||||||||||||||||||||||||||||||||
5383 | // they're not explicitly hidden. | - | ||||||||||||||||||||||||||||||||||||
5384 | QWidget *widget = q; | - | ||||||||||||||||||||||||||||||||||||
5385 | QWidgetList hiddenWidgets; | - | ||||||||||||||||||||||||||||||||||||
5386 | while (widget) {
| 0 | ||||||||||||||||||||||||||||||||||||
5387 | if (widget->isHidden()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5388 | widget->setAttribute(Qt::WA_WState_Hidden, false); | - | ||||||||||||||||||||||||||||||||||||
5389 | hiddenWidgets.append(widget); | - | ||||||||||||||||||||||||||||||||||||
5390 | if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
5391 | widget->d_func()->updateGeometry_helper(true); never executed: widget->d_func()->updateGeometry_helper(true); | 0 | ||||||||||||||||||||||||||||||||||||
5392 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5393 | widget = widget->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
5394 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5395 | - | |||||||||||||||||||||||||||||||||||||
5396 | // Activate top-level layout. | - | ||||||||||||||||||||||||||||||||||||
5397 | if (topLevel->d_func()->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
5398 | topLevel->d_func()->layout->activate(); never executed: topLevel->d_func()->layout->activate(); | 0 | ||||||||||||||||||||||||||||||||||||
5399 | - | |||||||||||||||||||||||||||||||||||||
5400 | // Adjust size if necessary. | - | ||||||||||||||||||||||||||||||||||||
5401 | QTLWExtra *topLevelExtra = topLevel->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
5402 | if (topLevelExtra && !topLevelExtra->sizeAdjusted
| 0 | ||||||||||||||||||||||||||||||||||||
5403 | && !topLevel->testAttribute(Qt::WA_Resized)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5404 | topLevel->adjustSize(); | - | ||||||||||||||||||||||||||||||||||||
5405 | topLevel->setAttribute(Qt::WA_Resized, false); | - | ||||||||||||||||||||||||||||||||||||
5406 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5407 | - | |||||||||||||||||||||||||||||||||||||
5408 | // Activate child layouts. | - | ||||||||||||||||||||||||||||||||||||
5409 | topLevel->d_func()->activateChildLayoutsRecursively(); | - | ||||||||||||||||||||||||||||||||||||
5410 | - | |||||||||||||||||||||||||||||||||||||
5411 | // We're not cheating with WA_WState_Hidden anymore. | - | ||||||||||||||||||||||||||||||||||||
5412 | for (int i = 0; i < hiddenWidgets.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
5413 | QWidget *widget = hiddenWidgets.at(i); | - | ||||||||||||||||||||||||||||||||||||
5414 | widget->setAttribute(Qt::WA_WState_Hidden); | - | ||||||||||||||||||||||||||||||||||||
5415 | if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
5416 | widget->parentWidget()->d_func()->layout->invalidate(); never executed: widget->parentWidget()->d_func()->layout->invalidate(); | 0 | ||||||||||||||||||||||||||||||||||||
5417 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5418 | } else if (isVisible) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
5419 | q->window()->d_func()->sendPendingMoveAndResizeEvents(true, true); | - | ||||||||||||||||||||||||||||||||||||
5420 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5421 | - | |||||||||||||||||||||||||||||||||||||
5422 | // Calculate the region to be painted. | - | ||||||||||||||||||||||||||||||||||||
5423 | QRegion toBePainted = !region.isEmpty() ? region : QRegion(q->rect());
| 0 | ||||||||||||||||||||||||||||||||||||
5424 | if (!(renderFlags & QWidget::IgnoreMask) && extra && extra->hasMask)
| 0 | ||||||||||||||||||||||||||||||||||||
5425 | toBePainted &= extra->mask; never executed: toBePainted &= extra->mask; | 0 | ||||||||||||||||||||||||||||||||||||
5426 | return toBePainted; never executed: return toBePainted; | 0 | ||||||||||||||||||||||||||||||||||||
5427 | } | - | ||||||||||||||||||||||||||||||||||||
5428 | - | |||||||||||||||||||||||||||||||||||||
5429 | void QWidgetPrivate::render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &toBePainted, | - | ||||||||||||||||||||||||||||||||||||
5430 | QWidget::RenderFlags renderFlags) | - | ||||||||||||||||||||||||||||||||||||
5431 | { | - | ||||||||||||||||||||||||||||||||||||
5432 | Q_ASSERT(painter); | - | ||||||||||||||||||||||||||||||||||||
5433 | Q_ASSERT(!toBePainted.isEmpty()); | - | ||||||||||||||||||||||||||||||||||||
5434 | - | |||||||||||||||||||||||||||||||||||||
5435 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5436 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
5437 | const QTransform originalTransform = painter->worldTransform(); | - | ||||||||||||||||||||||||||||||||||||
5438 | const bool useDeviceCoordinates = originalTransform.isScaling(); | - | ||||||||||||||||||||||||||||||||||||
5439 | if (!useDeviceCoordinates) {
| 0 | ||||||||||||||||||||||||||||||||||||
5440 | #endif | - | ||||||||||||||||||||||||||||||||||||
5441 | // Render via a pixmap. | - | ||||||||||||||||||||||||||||||||||||
5442 | const QRect rect = toBePainted.boundingRect(); | - | ||||||||||||||||||||||||||||||||||||
5443 | const QSize size = rect.size(); | - | ||||||||||||||||||||||||||||||||||||
5444 | if (size.isNull())
| 0 | ||||||||||||||||||||||||||||||||||||
5445 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5446 | - | |||||||||||||||||||||||||||||||||||||
5447 | const qreal pixmapDevicePixelRatio = painter->device()->devicePixelRatioF(); | - | ||||||||||||||||||||||||||||||||||||
5448 | QPixmap pixmap(size * pixmapDevicePixelRatio); | - | ||||||||||||||||||||||||||||||||||||
5449 | pixmap.setDevicePixelRatio(pixmapDevicePixelRatio); | - | ||||||||||||||||||||||||||||||||||||
5450 | - | |||||||||||||||||||||||||||||||||||||
5451 | if (!(renderFlags & QWidget::DrawWindowBackground) || !isOpaque)
| 0 | ||||||||||||||||||||||||||||||||||||
5452 | pixmap.fill(Qt::transparent); never executed: pixmap.fill(Qt::transparent); | 0 | ||||||||||||||||||||||||||||||||||||
5453 | q->render(&pixmap, QPoint(), toBePainted, renderFlags); | - | ||||||||||||||||||||||||||||||||||||
5454 | - | |||||||||||||||||||||||||||||||||||||
5455 | const bool restore = !(painter->renderHints() & QPainter::SmoothPixmapTransform); | - | ||||||||||||||||||||||||||||||||||||
5456 | painter->setRenderHints(QPainter::SmoothPixmapTransform, true); | - | ||||||||||||||||||||||||||||||||||||
5457 | - | |||||||||||||||||||||||||||||||||||||
5458 | painter->drawPixmap(targetOffset, pixmap); | - | ||||||||||||||||||||||||||||||||||||
5459 | - | |||||||||||||||||||||||||||||||||||||
5460 | if (restore)
| 0 | ||||||||||||||||||||||||||||||||||||
5461 | painter->setRenderHints(QPainter::SmoothPixmapTransform, false); never executed: painter->setRenderHints(QPainter::SmoothPixmapTransform, false); | 0 | ||||||||||||||||||||||||||||||||||||
5462 | - | |||||||||||||||||||||||||||||||||||||
5463 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
5464 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5465 | // Render via a pixmap in device coordinates (to avoid pixmap scaling). | - | ||||||||||||||||||||||||||||||||||||
5466 | QTransform transform = originalTransform; | - | ||||||||||||||||||||||||||||||||||||
5467 | transform.translate(targetOffset.x(), targetOffset.y()); | - | ||||||||||||||||||||||||||||||||||||
5468 | - | |||||||||||||||||||||||||||||||||||||
5469 | QPaintDevice *device = painter->device(); | - | ||||||||||||||||||||||||||||||||||||
5470 | Q_ASSERT(device); | - | ||||||||||||||||||||||||||||||||||||
5471 | - | |||||||||||||||||||||||||||||||||||||
5472 | // Calculate device rect. | - | ||||||||||||||||||||||||||||||||||||
5473 | const QRectF rect(toBePainted.boundingRect()); | - | ||||||||||||||||||||||||||||||||||||
5474 | QRect deviceRect = transform.mapRect(QRectF(0, 0, rect.width(), rect.height())).toAlignedRect(); | - | ||||||||||||||||||||||||||||||||||||
5475 | deviceRect &= QRect(0, 0, device->width(), device->height()); | - | ||||||||||||||||||||||||||||||||||||
5476 | - | |||||||||||||||||||||||||||||||||||||
5477 | QPixmap pixmap(deviceRect.size()); | - | ||||||||||||||||||||||||||||||||||||
5478 | pixmap.fill(Qt::transparent); | - | ||||||||||||||||||||||||||||||||||||
5479 | - | |||||||||||||||||||||||||||||||||||||
5480 | // Create a pixmap device coordinate painter. | - | ||||||||||||||||||||||||||||||||||||
5481 | QPainter pixmapPainter(&pixmap); | - | ||||||||||||||||||||||||||||||||||||
5482 | pixmapPainter.setRenderHints(painter->renderHints()); | - | ||||||||||||||||||||||||||||||||||||
5483 | transform *= QTransform::fromTranslate(-deviceRect.x(), -deviceRect.y()); | - | ||||||||||||||||||||||||||||||||||||
5484 | pixmapPainter.setTransform(transform); | - | ||||||||||||||||||||||||||||||||||||
5485 | - | |||||||||||||||||||||||||||||||||||||
5486 | q->render(&pixmapPainter, QPoint(), toBePainted, renderFlags); | - | ||||||||||||||||||||||||||||||||||||
5487 | pixmapPainter.end(); | - | ||||||||||||||||||||||||||||||||||||
5488 | - | |||||||||||||||||||||||||||||||||||||
5489 | // And then draw the pixmap. | - | ||||||||||||||||||||||||||||||||||||
5490 | painter->setTransform(QTransform()); | - | ||||||||||||||||||||||||||||||||||||
5491 | painter->drawPixmap(deviceRect.topLeft(), pixmap); | - | ||||||||||||||||||||||||||||||||||||
5492 | painter->setTransform(originalTransform); | - | ||||||||||||||||||||||||||||||||||||
5493 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5494 | #endif | - | ||||||||||||||||||||||||||||||||||||
5495 | } | - | ||||||||||||||||||||||||||||||||||||
5496 | - | |||||||||||||||||||||||||||||||||||||
5497 | void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, | - | ||||||||||||||||||||||||||||||||||||
5498 | QPainter *sharedPainter, QWidgetBackingStore *backingStore) | - | ||||||||||||||||||||||||||||||||||||
5499 | { | - | ||||||||||||||||||||||||||||||||||||
5500 | if (rgn.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
5501 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5502 | - | |||||||||||||||||||||||||||||||||||||
5503 | const bool asRoot = flags & DrawAsRoot; | - | ||||||||||||||||||||||||||||||||||||
5504 | bool onScreen = paintOnScreen(); | - | ||||||||||||||||||||||||||||||||||||
5505 | - | |||||||||||||||||||||||||||||||||||||
5506 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5507 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5508 | if (graphicsEffect && graphicsEffect->isEnabled()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5509 | QGraphicsEffectSource *source = graphicsEffect->d_func()->source; | - | ||||||||||||||||||||||||||||||||||||
5510 | QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *> | - | ||||||||||||||||||||||||||||||||||||
5511 | (source->d_func()); | - | ||||||||||||||||||||||||||||||||||||
5512 | if (!sourced->context) {
| 0 | ||||||||||||||||||||||||||||||||||||
5513 | QWidgetPaintContext context(pdev, rgn, offset, flags, sharedPainter, backingStore); | - | ||||||||||||||||||||||||||||||||||||
5514 | sourced->context = &context; | - | ||||||||||||||||||||||||||||||||||||
5515 | if (!sharedPainter) {
| 0 | ||||||||||||||||||||||||||||||||||||
5516 | setSystemClip(pdev, rgn.translated(offset)); | - | ||||||||||||||||||||||||||||||||||||
5517 | QPainter p(pdev); | - | ||||||||||||||||||||||||||||||||||||
5518 | p.translate(offset); | - | ||||||||||||||||||||||||||||||||||||
5519 | context.painter = &p; | - | ||||||||||||||||||||||||||||||||||||
5520 | graphicsEffect->draw(&p); | - | ||||||||||||||||||||||||||||||||||||
5521 | setSystemClip(pdev, QRegion()); | - | ||||||||||||||||||||||||||||||||||||
5522 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5523 | context.painter = sharedPainter; | - | ||||||||||||||||||||||||||||||||||||
5524 | if (sharedPainter->worldTransform() != sourced->lastEffectTransform) {
| 0 | ||||||||||||||||||||||||||||||||||||
5525 | sourced->invalidateCache(); | - | ||||||||||||||||||||||||||||||||||||
5526 | sourced->lastEffectTransform = sharedPainter->worldTransform(); | - | ||||||||||||||||||||||||||||||||||||
5527 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5528 | sharedPainter->save(); | - | ||||||||||||||||||||||||||||||||||||
5529 | sharedPainter->translate(offset); | - | ||||||||||||||||||||||||||||||||||||
5530 | graphicsEffect->draw(sharedPainter); | - | ||||||||||||||||||||||||||||||||||||
5531 | sharedPainter->restore(); | - | ||||||||||||||||||||||||||||||||||||
5532 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5533 | sourced->context = 0; | - | ||||||||||||||||||||||||||||||||||||
5534 | - | |||||||||||||||||||||||||||||||||||||
5535 | // Native widgets need to be marked dirty on screen so painting will be done in correct context | - | ||||||||||||||||||||||||||||||||||||
5536 | // Same check as in the no effects case below. | - | ||||||||||||||||||||||||||||||||||||
5537 | if (backingStore && !onScreen && !asRoot && (q->internalWinId() || !q->nativeParentWidget()->isWindow()))
| 0 | ||||||||||||||||||||||||||||||||||||
5538 | backingStore->markDirtyOnScreen(rgn, q, offset); never executed: backingStore->markDirtyOnScreen(rgn, q, offset); | 0 | ||||||||||||||||||||||||||||||||||||
5539 | - | |||||||||||||||||||||||||||||||||||||
5540 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5541 | } | - | ||||||||||||||||||||||||||||||||||||
5542 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5543 | #endif //QT_NO_GRAFFICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5544 | - | |||||||||||||||||||||||||||||||||||||
5545 | const bool alsoOnScreen = flags & DrawPaintOnScreen; | - | ||||||||||||||||||||||||||||||||||||
5546 | const bool recursive = flags & DrawRecursive; | - | ||||||||||||||||||||||||||||||||||||
5547 | const bool alsoInvisible = flags & DrawInvisible; | - | ||||||||||||||||||||||||||||||||||||
5548 | - | |||||||||||||||||||||||||||||||||||||
5549 | Q_ASSERT(sharedPainter ? sharedPainter->isActive() : true); | - | ||||||||||||||||||||||||||||||||||||
5550 | - | |||||||||||||||||||||||||||||||||||||
5551 | QRegion toBePainted(rgn); | - | ||||||||||||||||||||||||||||||||||||
5552 | if (asRoot && !alsoInvisible)
| 0 | ||||||||||||||||||||||||||||||||||||
5553 | toBePainted &= clipRect(); //(rgn & visibleRegion()); never executed: toBePainted &= clipRect(); | 0 | ||||||||||||||||||||||||||||||||||||
5554 | if (!(flags & DontSubtractOpaqueChildren))
| 0 | ||||||||||||||||||||||||||||||||||||
5555 | subtractOpaqueChildren(toBePainted, q->rect()); never executed: subtractOpaqueChildren(toBePainted, q->rect()); | 0 | ||||||||||||||||||||||||||||||||||||
5556 | - | |||||||||||||||||||||||||||||||||||||
5557 | if (!toBePainted.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5558 | if (!onScreen || alsoOnScreen) {
| 0 | ||||||||||||||||||||||||||||||||||||
5559 | //update the "in paint event" flag | - | ||||||||||||||||||||||||||||||||||||
5560 | if (Q_UNLIKELY(q->testAttribute(Qt::WA_WState_InPaintEvent)))
| 0 | ||||||||||||||||||||||||||||||||||||
5561 | qWarning("QWidget::repaint: Recursive repaint detected"); never executed: QMessageLogger(__FILE__, 5561, __PRETTY_FUNCTION__).warning("QWidget::repaint: Recursive repaint detected"); | 0 | ||||||||||||||||||||||||||||||||||||
5562 | q->setAttribute(Qt::WA_WState_InPaintEvent); | - | ||||||||||||||||||||||||||||||||||||
5563 | - | |||||||||||||||||||||||||||||||||||||
5564 | //clip away the new area | - | ||||||||||||||||||||||||||||||||||||
5565 | #ifndef QT_NO_PAINT_DEBUG | - | ||||||||||||||||||||||||||||||||||||
5566 | bool flushed = QWidgetBackingStore::flushPaint(q, toBePainted); | - | ||||||||||||||||||||||||||||||||||||
5567 | #endif | - | ||||||||||||||||||||||||||||||||||||
5568 | QPaintEngine *paintEngine = pdev->paintEngine(); | - | ||||||||||||||||||||||||||||||||||||
5569 | if (paintEngine) {
| 0 | ||||||||||||||||||||||||||||||||||||
5570 | setRedirected(pdev, -offset); | - | ||||||||||||||||||||||||||||||||||||
5571 | - | |||||||||||||||||||||||||||||||||||||
5572 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
5573 | // (Alien support) Special case for Mac when redirecting: If the paint device | - | ||||||||||||||||||||||||||||||||||||
5574 | // is of the Widget type we need to set WA_WState_InPaintEvent since painting | - | ||||||||||||||||||||||||||||||||||||
5575 | // outside the paint event is not supported on QWidgets. The attributeis | - | ||||||||||||||||||||||||||||||||||||
5576 | // restored further down. | - | ||||||||||||||||||||||||||||||||||||
5577 | if (pdev->devType() == QInternal::Widget) | - | ||||||||||||||||||||||||||||||||||||
5578 | static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent); | - | ||||||||||||||||||||||||||||||||||||
5579 | - | |||||||||||||||||||||||||||||||||||||
5580 | #endif | - | ||||||||||||||||||||||||||||||||||||
5581 | if (sharedPainter)
| 0 | ||||||||||||||||||||||||||||||||||||
5582 | setSystemClip(pdev, toBePainted); never executed: setSystemClip(pdev, toBePainted); | 0 | ||||||||||||||||||||||||||||||||||||
5583 | else | - | ||||||||||||||||||||||||||||||||||||
5584 | paintEngine->d_func()->systemRect = q->data->crect; never executed: paintEngine->d_func()->systemRect = q->data->crect; | 0 | ||||||||||||||||||||||||||||||||||||
5585 | - | |||||||||||||||||||||||||||||||||||||
5586 | //paint the background | - | ||||||||||||||||||||||||||||||||||||
5587 | if ((asRoot || q->autoFillBackground() || onScreen || q->testAttribute(Qt::WA_StyledBackground))
| 0 | ||||||||||||||||||||||||||||||||||||
5588 | && !q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5589 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5590 | beginBackingStorePainting(); | - | ||||||||||||||||||||||||||||||||||||
5591 | #endif | - | ||||||||||||||||||||||||||||||||||||
5592 | QPainter p(q); | - | ||||||||||||||||||||||||||||||||||||
5593 | paintBackground(&p, toBePainted, (asRoot || onScreen) ? flags | DrawAsRoot : 0); | - | ||||||||||||||||||||||||||||||||||||
5594 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5595 | endBackingStorePainting(); | - | ||||||||||||||||||||||||||||||||||||
5596 | #endif | - | ||||||||||||||||||||||||||||||||||||
5597 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5598 | - | |||||||||||||||||||||||||||||||||||||
5599 | if (!sharedPainter)
| 0 | ||||||||||||||||||||||||||||||||||||
5600 | setSystemClip(pdev, toBePainted.translated(offset)); never executed: setSystemClip(pdev, toBePainted.translated(offset)); | 0 | ||||||||||||||||||||||||||||||||||||
5601 | - | |||||||||||||||||||||||||||||||||||||
5602 | if (!onScreen && !asRoot && !isOpaque && q->testAttribute(Qt::WA_TintedBackground)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5603 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5604 | beginBackingStorePainting(); | - | ||||||||||||||||||||||||||||||||||||
5605 | #endif | - | ||||||||||||||||||||||||||||||||||||
5606 | QPainter p(q); | - | ||||||||||||||||||||||||||||||||||||
5607 | QColor tint = q->palette().window().color(); | - | ||||||||||||||||||||||||||||||||||||
5608 | tint.setAlphaF(qreal(.6)); | - | ||||||||||||||||||||||||||||||||||||
5609 | p.fillRect(toBePainted.boundingRect(), tint); | - | ||||||||||||||||||||||||||||||||||||
5610 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5611 | endBackingStorePainting(); | - | ||||||||||||||||||||||||||||||||||||
5612 | #endif | - | ||||||||||||||||||||||||||||||||||||
5613 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5614 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5615 | - | |||||||||||||||||||||||||||||||||||||
5616 | #if 0 | - | ||||||||||||||||||||||||||||||||||||
5617 | qDebug() << "painting" << q << "opaque ==" << isOpaque(); | - | ||||||||||||||||||||||||||||||||||||
5618 | qDebug() << "clipping to" << toBePainted << "location == " << offset | - | ||||||||||||||||||||||||||||||||||||
5619 | << "geometry ==" << QRect(q->mapTo(q->window(), QPoint(0, 0)), q->size()); | - | ||||||||||||||||||||||||||||||||||||
5620 | #endif | - | ||||||||||||||||||||||||||||||||||||
5621 | - | |||||||||||||||||||||||||||||||||||||
5622 | bool skipPaintEvent = false; | - | ||||||||||||||||||||||||||||||||||||
5623 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5624 | if (renderToTexture) {
| 0 | ||||||||||||||||||||||||||||||||||||
5625 | // This widget renders into a texture which is composed later. We just need to | - | ||||||||||||||||||||||||||||||||||||
5626 | // punch a hole in the backingstore, so the texture will be visible. | - | ||||||||||||||||||||||||||||||||||||
5627 | if (!q->testAttribute(Qt::WA_AlwaysStackOnTop)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5628 | beginBackingStorePainting(); | - | ||||||||||||||||||||||||||||||||||||
5629 | QPainter p(q); | - | ||||||||||||||||||||||||||||||||||||
5630 | if (backingStore) {
| 0 | ||||||||||||||||||||||||||||||||||||
5631 | p.setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||||||||||||||||||||||||||||||||
5632 | p.fillRect(q->rect(), Qt::transparent); | - | ||||||||||||||||||||||||||||||||||||
5633 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5634 | // We are not drawing to a backingstore: fall back to QImage | - | ||||||||||||||||||||||||||||||||||||
5635 | p.drawImage(q->rect(), grabFramebuffer()); | - | ||||||||||||||||||||||||||||||||||||
5636 | skipPaintEvent = true; | - | ||||||||||||||||||||||||||||||||||||
5637 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5638 | endBackingStorePainting(); | - | ||||||||||||||||||||||||||||||||||||
5639 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5640 | if (renderToTextureReallyDirty)
| 0 | ||||||||||||||||||||||||||||||||||||
5641 | renderToTextureReallyDirty = 0; never executed: renderToTextureReallyDirty = 0; | 0 | ||||||||||||||||||||||||||||||||||||
5642 | else | - | ||||||||||||||||||||||||||||||||||||
5643 | skipPaintEvent = true; never executed: skipPaintEvent = true; | 0 | ||||||||||||||||||||||||||||||||||||
5644 | } | - | ||||||||||||||||||||||||||||||||||||
5645 | #endif // QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5646 | - | |||||||||||||||||||||||||||||||||||||
5647 | if (!skipPaintEvent) {
| 0 | ||||||||||||||||||||||||||||||||||||
5648 | //actually send the paint event | - | ||||||||||||||||||||||||||||||||||||
5649 | sendPaintEvent(toBePainted); | - | ||||||||||||||||||||||||||||||||||||
5650 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5651 | - | |||||||||||||||||||||||||||||||||||||
5652 | // Native widgets need to be marked dirty on screen so painting will be done in correct context | - | ||||||||||||||||||||||||||||||||||||
5653 | if (backingStore && !onScreen && !asRoot && (q->internalWinId() || (q->nativeParentWidget() && !q->nativeParentWidget()->isWindow())))
| 0 | ||||||||||||||||||||||||||||||||||||
5654 | backingStore->markDirtyOnScreen(toBePainted, q, offset); never executed: backingStore->markDirtyOnScreen(toBePainted, q, offset); | 0 | ||||||||||||||||||||||||||||||||||||
5655 | - | |||||||||||||||||||||||||||||||||||||
5656 | //restore | - | ||||||||||||||||||||||||||||||||||||
5657 | if (paintEngine) {
| 0 | ||||||||||||||||||||||||||||||||||||
5658 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
5659 | if (pdev->devType() == QInternal::Widget) | - | ||||||||||||||||||||||||||||||||||||
5660 | static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent, false); | - | ||||||||||||||||||||||||||||||||||||
5661 | #endif | - | ||||||||||||||||||||||||||||||||||||
5662 | restoreRedirected(); | - | ||||||||||||||||||||||||||||||||||||
5663 | if (!sharedPainter)
| 0 | ||||||||||||||||||||||||||||||||||||
5664 | paintEngine->d_func()->systemRect = QRect(); never executed: paintEngine->d_func()->systemRect = QRect(); | 0 | ||||||||||||||||||||||||||||||||||||
5665 | else | - | ||||||||||||||||||||||||||||||||||||
5666 | paintEngine->d_func()->currentClipDevice = 0; never executed: paintEngine->d_func()->currentClipDevice = 0; | 0 | ||||||||||||||||||||||||||||||||||||
5667 | - | |||||||||||||||||||||||||||||||||||||
5668 | setSystemClip(pdev, QRegion()); | - | ||||||||||||||||||||||||||||||||||||
5669 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5670 | q->setAttribute(Qt::WA_WState_InPaintEvent, false); | - | ||||||||||||||||||||||||||||||||||||
5671 | if (Q_UNLIKELY(q->paintingActive()))
| 0 | ||||||||||||||||||||||||||||||||||||
5672 | qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent"); never executed: QMessageLogger(__FILE__, 5672, __PRETTY_FUNCTION__).warning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent"); | 0 | ||||||||||||||||||||||||||||||||||||
5673 | - | |||||||||||||||||||||||||||||||||||||
5674 | if (paintEngine && paintEngine->autoDestruct()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5675 | delete paintEngine; | - | ||||||||||||||||||||||||||||||||||||
5676 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5677 | - | |||||||||||||||||||||||||||||||||||||
5678 | #ifndef QT_NO_PAINT_DEBUG | - | ||||||||||||||||||||||||||||||||||||
5679 | if (flushed)
| 0 | ||||||||||||||||||||||||||||||||||||
5680 | QWidgetBackingStore::unflushPaint(q, toBePainted); never executed: QWidgetBackingStore::unflushPaint(q, toBePainted); | 0 | ||||||||||||||||||||||||||||||||||||
5681 | #endif | - | ||||||||||||||||||||||||||||||||||||
5682 | } else if (q->isWindow()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
5683 | QPaintEngine *engine = pdev->paintEngine(); | - | ||||||||||||||||||||||||||||||||||||
5684 | if (engine) {
| 0 | ||||||||||||||||||||||||||||||||||||
5685 | QPainter p(pdev); | - | ||||||||||||||||||||||||||||||||||||
5686 | p.setClipRegion(toBePainted); | - | ||||||||||||||||||||||||||||||||||||
5687 | const QBrush bg = q->palette().brush(QPalette::Window); | - | ||||||||||||||||||||||||||||||||||||
5688 | if (bg.style() == Qt::TexturePattern)
| 0 | ||||||||||||||||||||||||||||||||||||
5689 | p.drawTiledPixmap(q->rect(), bg.texture()); never executed: p.drawTiledPixmap(q->rect(), bg.texture()); | 0 | ||||||||||||||||||||||||||||||||||||
5690 | else | - | ||||||||||||||||||||||||||||||||||||
5691 | p.fillRect(q->rect(), bg); never executed: p.fillRect(q->rect(), bg); | 0 | ||||||||||||||||||||||||||||||||||||
5692 | - | |||||||||||||||||||||||||||||||||||||
5693 | if (engine->autoDestruct())
| 0 | ||||||||||||||||||||||||||||||||||||
5694 | delete engine; never executed: delete engine; | 0 | ||||||||||||||||||||||||||||||||||||
5695 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5696 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5697 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5698 | - | |||||||||||||||||||||||||||||||||||||
5699 | if (recursive && !children.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5700 | paintSiblingsRecursive(pdev, children, children.size() - 1, rgn, offset, flags & ~DrawAsRoot | - | ||||||||||||||||||||||||||||||||||||
5701 | , sharedPainter, backingStore); | - | ||||||||||||||||||||||||||||||||||||
5702 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5703 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5704 | - | |||||||||||||||||||||||||||||||||||||
5705 | void QWidgetPrivate::sendPaintEvent(const QRegion &toBePainted) | - | ||||||||||||||||||||||||||||||||||||
5706 | { | - | ||||||||||||||||||||||||||||||||||||
5707 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5708 | QPaintEvent e(toBePainted); | - | ||||||||||||||||||||||||||||||||||||
5709 | QCoreApplication::sendSpontaneousEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
5710 | - | |||||||||||||||||||||||||||||||||||||
5711 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5712 | if (renderToTexture)
| 0 | ||||||||||||||||||||||||||||||||||||
5713 | resolveSamples(); never executed: resolveSamples(); | 0 | ||||||||||||||||||||||||||||||||||||
5714 | #endif // QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5715 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5716 | - | |||||||||||||||||||||||||||||||||||||
5717 | void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, | - | ||||||||||||||||||||||||||||||||||||
5718 | const QRegion &sourceRegion, QWidget::RenderFlags renderFlags) | - | ||||||||||||||||||||||||||||||||||||
5719 | { | - | ||||||||||||||||||||||||||||||||||||
5720 | if (Q_UNLIKELY(!target)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5721 | qWarning("QWidget::render: null pointer to paint device"); | - | ||||||||||||||||||||||||||||||||||||
5722 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5723 | } | - | ||||||||||||||||||||||||||||||||||||
5724 | - | |||||||||||||||||||||||||||||||||||||
5725 | const bool inRenderWithPainter = extra && extra->inRenderWithPainter;
| 0 | ||||||||||||||||||||||||||||||||||||
5726 | QRegion paintRegion = !inRenderWithPainter
| 0 | ||||||||||||||||||||||||||||||||||||
5727 | ? prepareToRender(sourceRegion, renderFlags) | - | ||||||||||||||||||||||||||||||||||||
5728 | : sourceRegion; | - | ||||||||||||||||||||||||||||||||||||
5729 | if (paintRegion.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
5730 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5731 | - | |||||||||||||||||||||||||||||||||||||
5732 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
5733 | QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
5734 | - | |||||||||||||||||||||||||||||||||||||
5735 | // Use the target's shared painter if set (typically set when doing | - | ||||||||||||||||||||||||||||||||||||
5736 | // "other->render(widget);" in the widget's paintEvent. | - | ||||||||||||||||||||||||||||||||||||
5737 | if (target->devType() == QInternal::Widget) {
| 0 | ||||||||||||||||||||||||||||||||||||
5738 | QWidgetPrivate *targetPrivate = static_cast<QWidget *>(target)->d_func(); | - | ||||||||||||||||||||||||||||||||||||
5739 | if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) {
| 0 | ||||||||||||||||||||||||||||||||||||
5740 | QPainter *targetPainter = targetPrivate->sharedPainter(); | - | ||||||||||||||||||||||||||||||||||||
5741 | if (targetPainter && targetPainter->isActive())
| 0 | ||||||||||||||||||||||||||||||||||||
5742 | setSharedPainter(targetPainter); never executed: setSharedPainter(targetPainter); | 0 | ||||||||||||||||||||||||||||||||||||
5743 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5744 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5745 | #endif | - | ||||||||||||||||||||||||||||||||||||
5746 | - | |||||||||||||||||||||||||||||||||||||
5747 | // Use the target's redirected device if set and adjust offset and paint | - | ||||||||||||||||||||||||||||||||||||
5748 | // region accordingly. This is typically the case when people call render | - | ||||||||||||||||||||||||||||||||||||
5749 | // from the paintEvent. | - | ||||||||||||||||||||||||||||||||||||
5750 | QPoint offset = targetOffset; | - | ||||||||||||||||||||||||||||||||||||
5751 | offset -= paintRegion.boundingRect().topLeft(); | - | ||||||||||||||||||||||||||||||||||||
5752 | QPoint redirectionOffset; | - | ||||||||||||||||||||||||||||||||||||
5753 | QPaintDevice *redirected = 0; | - | ||||||||||||||||||||||||||||||||||||
5754 | - | |||||||||||||||||||||||||||||||||||||
5755 | if (target->devType() == QInternal::Widget)
| 0 | ||||||||||||||||||||||||||||||||||||
5756 | redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset); never executed: redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset); | 0 | ||||||||||||||||||||||||||||||||||||
5757 | if (!redirected)
| 0 | ||||||||||||||||||||||||||||||||||||
5758 | redirected = QPainter::redirected(target, &redirectionOffset); never executed: redirected = QPainter::redirected(target, &redirectionOffset); | 0 | ||||||||||||||||||||||||||||||||||||
5759 | - | |||||||||||||||||||||||||||||||||||||
5760 | if (redirected) {
| 0 | ||||||||||||||||||||||||||||||||||||
5761 | target = redirected; | - | ||||||||||||||||||||||||||||||||||||
5762 | offset -= redirectionOffset; | - | ||||||||||||||||||||||||||||||||||||
5763 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5764 | - | |||||||||||||||||||||||||||||||||||||
5765 | if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp).
| 0 | ||||||||||||||||||||||||||||||||||||
5766 | if (QPaintEngine *targetEngine = target->paintEngine()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5767 | const QRegion targetSystemClip = targetEngine->systemClip(); | - | ||||||||||||||||||||||||||||||||||||
5768 | if (!targetSystemClip.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
5769 | paintRegion &= targetSystemClip.translated(-offset); never executed: paintRegion &= targetSystemClip.translated(-offset); | 0 | ||||||||||||||||||||||||||||||||||||
5770 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5771 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5772 | - | |||||||||||||||||||||||||||||||||||||
5773 | // Set backingstore flags. | - | ||||||||||||||||||||||||||||||||||||
5774 | int flags = DrawPaintOnScreen | DrawInvisible; | - | ||||||||||||||||||||||||||||||||||||
5775 | if (renderFlags & QWidget::DrawWindowBackground)
| 0 | ||||||||||||||||||||||||||||||||||||
5776 | flags |= DrawAsRoot; never executed: flags |= DrawAsRoot; | 0 | ||||||||||||||||||||||||||||||||||||
5777 | - | |||||||||||||||||||||||||||||||||||||
5778 | if (renderFlags & QWidget::DrawChildren)
| 0 | ||||||||||||||||||||||||||||||||||||
5779 | flags |= DrawRecursive; never executed: flags |= DrawRecursive; | 0 | ||||||||||||||||||||||||||||||||||||
5780 | else | - | ||||||||||||||||||||||||||||||||||||
5781 | flags |= DontSubtractOpaqueChildren; never executed: flags |= DontSubtractOpaqueChildren; | 0 | ||||||||||||||||||||||||||||||||||||
5782 | - | |||||||||||||||||||||||||||||||||||||
5783 | flags |= DontSetCompositionMode; | - | ||||||||||||||||||||||||||||||||||||
5784 | - | |||||||||||||||||||||||||||||||||||||
5785 | // Render via backingstore. | - | ||||||||||||||||||||||||||||||||||||
5786 | drawWidget(target, paintRegion, offset, flags, sharedPainter()); | - | ||||||||||||||||||||||||||||||||||||
5787 | - | |||||||||||||||||||||||||||||||||||||
5788 | // Restore shared painter. | - | ||||||||||||||||||||||||||||||||||||
5789 | if (oldSharedPainter)
| 0 | ||||||||||||||||||||||||||||||||||||
5790 | setSharedPainter(oldSharedPainter); never executed: setSharedPainter(oldSharedPainter); | 0 | ||||||||||||||||||||||||||||||||||||
5791 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5792 | - | |||||||||||||||||||||||||||||||||||||
5793 | void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& siblings, int index, const QRegion &rgn, | - | ||||||||||||||||||||||||||||||||||||
5794 | const QPoint &offset, int flags | - | ||||||||||||||||||||||||||||||||||||
5795 | , QPainter *sharedPainter, QWidgetBackingStore *backingStore) | - | ||||||||||||||||||||||||||||||||||||
5796 | { | - | ||||||||||||||||||||||||||||||||||||
5797 | QWidget *w = 0; | - | ||||||||||||||||||||||||||||||||||||
5798 | QRect boundingRect; | - | ||||||||||||||||||||||||||||||||||||
5799 | bool dirtyBoundingRect = true; | - | ||||||||||||||||||||||||||||||||||||
5800 | const bool exludeOpaqueChildren = (flags & DontDrawOpaqueChildren); | - | ||||||||||||||||||||||||||||||||||||
5801 | const bool excludeNativeChildren = (flags & DontDrawNativeChildren); | - | ||||||||||||||||||||||||||||||||||||
5802 | - | |||||||||||||||||||||||||||||||||||||
5803 | do { | - | ||||||||||||||||||||||||||||||||||||
5804 | QWidget *x = qobject_cast<QWidget*>(siblings.at(index)); | - | ||||||||||||||||||||||||||||||||||||
5805 | if (x && !(exludeOpaqueChildren && x->d_func()->isOpaque) && !x->isHidden() && !x->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
5806 | && !(excludeNativeChildren && x->internalWinId())) {
| 0 | ||||||||||||||||||||||||||||||||||||
5807 | if (dirtyBoundingRect) {
| 0 | ||||||||||||||||||||||||||||||||||||
5808 | boundingRect = rgn.boundingRect(); | - | ||||||||||||||||||||||||||||||||||||
5809 | dirtyBoundingRect = false; | - | ||||||||||||||||||||||||||||||||||||
5810 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5811 | - | |||||||||||||||||||||||||||||||||||||
5812 | if (qRectIntersects(boundingRect, x->d_func()->effectiveRectFor(x->data->crect))) {
| 0 | ||||||||||||||||||||||||||||||||||||
5813 | w = x; | - | ||||||||||||||||||||||||||||||||||||
5814 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
5815 | } | - | ||||||||||||||||||||||||||||||||||||
5816 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5817 | --index; | - | ||||||||||||||||||||||||||||||||||||
5818 | } while (index >= 0); never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
5819 | - | |||||||||||||||||||||||||||||||||||||
5820 | if (!w)
| 0 | ||||||||||||||||||||||||||||||||||||
5821 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5822 | - | |||||||||||||||||||||||||||||||||||||
5823 | QWidgetPrivate *wd = w->d_func(); | - | ||||||||||||||||||||||||||||||||||||
5824 | const QPoint widgetPos(w->data->crect.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
5825 | const bool hasMask = wd->extra && wd->extra->hasMask && !wd->graphicsEffect;
| 0 | ||||||||||||||||||||||||||||||||||||
5826 | if (index > 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
5827 | QRegion wr(rgn); | - | ||||||||||||||||||||||||||||||||||||
5828 | if (wd->isOpaque)
| 0 | ||||||||||||||||||||||||||||||||||||
5829 | wr -= hasMask ? wd->extra->mask.translated(widgetPos) : w->data->crect; never executed: wr -= hasMask ? wd->extra->mask.translated(widgetPos) : w->data->crect;
| 0 | ||||||||||||||||||||||||||||||||||||
5830 | paintSiblingsRecursive(pdev, siblings, --index, wr, offset, flags | - | ||||||||||||||||||||||||||||||||||||
5831 | , sharedPainter, backingStore); | - | ||||||||||||||||||||||||||||||||||||
5832 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5833 | - | |||||||||||||||||||||||||||||||||||||
5834 | if (w->updatesEnabled()
| 0 | ||||||||||||||||||||||||||||||||||||
5835 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
5836 | && (!w->d_func()->extra || !w->d_func()->extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
5837 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
5838 | ) { | - | ||||||||||||||||||||||||||||||||||||
5839 | QRegion wRegion(rgn); | - | ||||||||||||||||||||||||||||||||||||
5840 | wRegion &= wd->effectiveRectFor(w->data->crect); | - | ||||||||||||||||||||||||||||||||||||
5841 | wRegion.translate(-widgetPos); | - | ||||||||||||||||||||||||||||||||||||
5842 | if (hasMask)
| 0 | ||||||||||||||||||||||||||||||||||||
5843 | wRegion &= wd->extra->mask; never executed: wRegion &= wd->extra->mask; | 0 | ||||||||||||||||||||||||||||||||||||
5844 | wd->drawWidget(pdev, wRegion, offset + widgetPos, flags, sharedPainter, backingStore); | - | ||||||||||||||||||||||||||||||||||||
5845 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5846 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5847 | - | |||||||||||||||||||||||||||||||||||||
5848 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5849 | QRectF QWidgetEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const | - | ||||||||||||||||||||||||||||||||||||
5850 | { | - | ||||||||||||||||||||||||||||||||||||
5851 | if (system != Qt::DeviceCoordinates)
| 0 | ||||||||||||||||||||||||||||||||||||
5852 | return m_widget->rect(); never executed: return m_widget->rect(); | 0 | ||||||||||||||||||||||||||||||||||||
5853 | - | |||||||||||||||||||||||||||||||||||||
5854 | if (Q_UNLIKELY(!context)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5855 | // Device coordinates without context not yet supported. | - | ||||||||||||||||||||||||||||||||||||
5856 | qWarning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context"); | - | ||||||||||||||||||||||||||||||||||||
5857 | return QRectF(); never executed: return QRectF(); | 0 | ||||||||||||||||||||||||||||||||||||
5858 | } | - | ||||||||||||||||||||||||||||||||||||
5859 | - | |||||||||||||||||||||||||||||||||||||
5860 | return context->painter->worldTransform().mapRect(m_widget->rect()); never executed: return context->painter->worldTransform().mapRect(m_widget->rect()); | 0 | ||||||||||||||||||||||||||||||||||||
5861 | } | - | ||||||||||||||||||||||||||||||||||||
5862 | - | |||||||||||||||||||||||||||||||||||||
5863 | void QWidgetEffectSourcePrivate::draw(QPainter *painter) | - | ||||||||||||||||||||||||||||||||||||
5864 | { | - | ||||||||||||||||||||||||||||||||||||
5865 | if (!context || context->painter != painter) {
| 0 | ||||||||||||||||||||||||||||||||||||
5866 | m_widget->render(painter); | - | ||||||||||||||||||||||||||||||||||||
5867 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5868 | } | - | ||||||||||||||||||||||||||||||||||||
5869 | - | |||||||||||||||||||||||||||||||||||||
5870 | // The region saved in the context is neither clipped to the rect | - | ||||||||||||||||||||||||||||||||||||
5871 | // nor the mask, so we have to clip it here before calling drawWidget. | - | ||||||||||||||||||||||||||||||||||||
5872 | QRegion toBePainted = context->rgn; | - | ||||||||||||||||||||||||||||||||||||
5873 | toBePainted &= m_widget->rect(); | - | ||||||||||||||||||||||||||||||||||||
5874 | QWidgetPrivate *wd = qt_widget_private(m_widget); | - | ||||||||||||||||||||||||||||||||||||
5875 | if (wd->extra && wd->extra->hasMask)
| 0 | ||||||||||||||||||||||||||||||||||||
5876 | toBePainted &= wd->extra->mask; never executed: toBePainted &= wd->extra->mask; | 0 | ||||||||||||||||||||||||||||||||||||
5877 | - | |||||||||||||||||||||||||||||||||||||
5878 | wd->drawWidget(context->pdev, toBePainted, context->offset, context->flags, | - | ||||||||||||||||||||||||||||||||||||
5879 | context->sharedPainter, context->backingStore); | - | ||||||||||||||||||||||||||||||||||||
5880 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5881 | - | |||||||||||||||||||||||||||||||||||||
5882 | QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset, | - | ||||||||||||||||||||||||||||||||||||
5883 | QGraphicsEffect::PixmapPadMode mode) const | - | ||||||||||||||||||||||||||||||||||||
5884 | { | - | ||||||||||||||||||||||||||||||||||||
5885 | const bool deviceCoordinates = (system == Qt::DeviceCoordinates); | - | ||||||||||||||||||||||||||||||||||||
5886 | if (Q_UNLIKELY(!context && deviceCoordinates)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5887 | // Device coordinates without context not yet supported. | - | ||||||||||||||||||||||||||||||||||||
5888 | qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); | - | ||||||||||||||||||||||||||||||||||||
5889 | return QPixmap(); never executed: return QPixmap(); | 0 | ||||||||||||||||||||||||||||||||||||
5890 | } | - | ||||||||||||||||||||||||||||||||||||
5891 | - | |||||||||||||||||||||||||||||||||||||
5892 | QPoint pixmapOffset; | - | ||||||||||||||||||||||||||||||||||||
5893 | QRectF sourceRect = m_widget->rect(); | - | ||||||||||||||||||||||||||||||||||||
5894 | - | |||||||||||||||||||||||||||||||||||||
5895 | if (deviceCoordinates) {
| 0 | ||||||||||||||||||||||||||||||||||||
5896 | const QTransform &painterTransform = context->painter->worldTransform(); | - | ||||||||||||||||||||||||||||||||||||
5897 | sourceRect = painterTransform.mapRect(sourceRect); | - | ||||||||||||||||||||||||||||||||||||
5898 | pixmapOffset = painterTransform.map(pixmapOffset); | - | ||||||||||||||||||||||||||||||||||||
5899 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5900 | - | |||||||||||||||||||||||||||||||||||||
5901 | QRect effectRect; | - | ||||||||||||||||||||||||||||||||||||
5902 | - | |||||||||||||||||||||||||||||||||||||
5903 | if (mode == QGraphicsEffect::PadToEffectiveBoundingRect)
| 0 | ||||||||||||||||||||||||||||||||||||
5904 | effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); never executed: effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); | 0 | ||||||||||||||||||||||||||||||||||||
5905 | else if (mode == QGraphicsEffect::PadToTransparentBorder)
| 0 | ||||||||||||||||||||||||||||||||||||
5906 | effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); never executed: effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); | 0 | ||||||||||||||||||||||||||||||||||||
5907 | else | - | ||||||||||||||||||||||||||||||||||||
5908 | effectRect = sourceRect.toAlignedRect(); never executed: effectRect = sourceRect.toAlignedRect(); | 0 | ||||||||||||||||||||||||||||||||||||
5909 | - | |||||||||||||||||||||||||||||||||||||
5910 | if (offset)
| 0 | ||||||||||||||||||||||||||||||||||||
5911 | *offset = effectRect.topLeft(); never executed: *offset = effectRect.topLeft(); | 0 | ||||||||||||||||||||||||||||||||||||
5912 | - | |||||||||||||||||||||||||||||||||||||
5913 | pixmapOffset -= effectRect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
5914 | - | |||||||||||||||||||||||||||||||||||||
5915 | const qreal dpr = context->painter->device()->devicePixelRatio(); | - | ||||||||||||||||||||||||||||||||||||
5916 | QPixmap pixmap(effectRect.size() * dpr); | - | ||||||||||||||||||||||||||||||||||||
5917 | pixmap.setDevicePixelRatio(dpr); | - | ||||||||||||||||||||||||||||||||||||
5918 | - | |||||||||||||||||||||||||||||||||||||
5919 | pixmap.fill(Qt::transparent); | - | ||||||||||||||||||||||||||||||||||||
5920 | m_widget->render(&pixmap, pixmapOffset, QRegion(), QWidget::DrawChildren); | - | ||||||||||||||||||||||||||||||||||||
5921 | return pixmap; never executed: return pixmap; | 0 | ||||||||||||||||||||||||||||||||||||
5922 | } | - | ||||||||||||||||||||||||||||||||||||
5923 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5924 | - | |||||||||||||||||||||||||||||||||||||
5925 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
5926 | /*! | - | ||||||||||||||||||||||||||||||||||||
5927 | \internal | - | ||||||||||||||||||||||||||||||||||||
5928 | - | |||||||||||||||||||||||||||||||||||||
5929 | Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this | - | ||||||||||||||||||||||||||||||||||||
5930 | widget and its ancestors. The search starts at \a origin (inclusive). | - | ||||||||||||||||||||||||||||||||||||
5931 | If successful, the function returns the proxy that embeds the widget, or 0 if no embedded | - | ||||||||||||||||||||||||||||||||||||
5932 | widget was found. | - | ||||||||||||||||||||||||||||||||||||
5933 | */ | - | ||||||||||||||||||||||||||||||||||||
5934 | QGraphicsProxyWidget * QWidgetPrivate::nearestGraphicsProxyWidget(const QWidget *origin) | - | ||||||||||||||||||||||||||||||||||||
5935 | { | - | ||||||||||||||||||||||||||||||||||||
5936 | if (origin) {
| 0 | ||||||||||||||||||||||||||||||||||||
5937 | QWExtra *extra = origin->d_func()->extra; | - | ||||||||||||||||||||||||||||||||||||
5938 | if (extra && extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
5939 | return extra->proxyWidget; never executed: return extra->proxyWidget; | 0 | ||||||||||||||||||||||||||||||||||||
5940 | return nearestGraphicsProxyWidget(origin->parentWidget()); never executed: return nearestGraphicsProxyWidget(origin->parentWidget()); | 0 | ||||||||||||||||||||||||||||||||||||
5941 | } | - | ||||||||||||||||||||||||||||||||||||
5942 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
5943 | } | - | ||||||||||||||||||||||||||||||||||||
5944 | #endif | - | ||||||||||||||||||||||||||||||||||||
5945 | - | |||||||||||||||||||||||||||||||||||||
5946 | /*! | - | ||||||||||||||||||||||||||||||||||||
5947 | \property QWidget::locale | - | ||||||||||||||||||||||||||||||||||||
5948 | \brief the widget's locale | - | ||||||||||||||||||||||||||||||||||||
5949 | \since 4.3 | - | ||||||||||||||||||||||||||||||||||||
5950 | - | |||||||||||||||||||||||||||||||||||||
5951 | As long as no special locale has been set, this is either | - | ||||||||||||||||||||||||||||||||||||
5952 | the parent's locale or (if this widget is a top level widget), | - | ||||||||||||||||||||||||||||||||||||
5953 | the default locale. | - | ||||||||||||||||||||||||||||||||||||
5954 | - | |||||||||||||||||||||||||||||||||||||
5955 | If the widget displays dates or numbers, these should be formatted | - | ||||||||||||||||||||||||||||||||||||
5956 | using the widget's locale. | - | ||||||||||||||||||||||||||||||||||||
5957 | - | |||||||||||||||||||||||||||||||||||||
5958 | \sa QLocale, QLocale::setDefault() | - | ||||||||||||||||||||||||||||||||||||
5959 | */ | - | ||||||||||||||||||||||||||||||||||||
5960 | - | |||||||||||||||||||||||||||||||||||||
5961 | void QWidgetPrivate::setLocale_helper(const QLocale &loc, bool forceUpdate) | - | ||||||||||||||||||||||||||||||||||||
5962 | { | - | ||||||||||||||||||||||||||||||||||||
5963 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5964 | if (locale == loc && !forceUpdate)
| 0 | ||||||||||||||||||||||||||||||||||||
5965 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5966 | - | |||||||||||||||||||||||||||||||||||||
5967 | locale = loc; | - | ||||||||||||||||||||||||||||||||||||
5968 | - | |||||||||||||||||||||||||||||||||||||
5969 | if (!children.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5970 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
5971 | QWidget *w = qobject_cast<QWidget*>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
5972 | if (!w)
| 0 | ||||||||||||||||||||||||||||||||||||
5973 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
5974 | if (w->testAttribute(Qt::WA_SetLocale))
| 0 | ||||||||||||||||||||||||||||||||||||
5975 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
5976 | if (w->isWindow() && !w->testAttribute(Qt::WA_WindowPropagation))
| 0 | ||||||||||||||||||||||||||||||||||||
5977 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
5978 | w->d_func()->setLocale_helper(loc, forceUpdate); | - | ||||||||||||||||||||||||||||||||||||
5979 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5980 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5981 | QEvent e(QEvent::LocaleChange); | - | ||||||||||||||||||||||||||||||||||||
5982 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
5983 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5984 | - | |||||||||||||||||||||||||||||||||||||
5985 | void QWidget::setLocale(const QLocale &locale) | - | ||||||||||||||||||||||||||||||||||||
5986 | { | - | ||||||||||||||||||||||||||||||||||||
5987 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5988 | - | |||||||||||||||||||||||||||||||||||||
5989 | setAttribute(Qt::WA_SetLocale); | - | ||||||||||||||||||||||||||||||||||||
5990 | d->setLocale_helper(locale); | - | ||||||||||||||||||||||||||||||||||||
5991 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5992 | - | |||||||||||||||||||||||||||||||||||||
5993 | QLocale QWidget::locale() const | - | ||||||||||||||||||||||||||||||||||||
5994 | { | - | ||||||||||||||||||||||||||||||||||||
5995 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
5996 | - | |||||||||||||||||||||||||||||||||||||
5997 | return d->locale; never executed: return d->locale; | 0 | ||||||||||||||||||||||||||||||||||||
5998 | } | - | ||||||||||||||||||||||||||||||||||||
5999 | - | |||||||||||||||||||||||||||||||||||||
6000 | void QWidgetPrivate::resolveLocale() | - | ||||||||||||||||||||||||||||||||||||
6001 | { | - | ||||||||||||||||||||||||||||||||||||
6002 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
6003 | - | |||||||||||||||||||||||||||||||||||||
6004 | if (!q->testAttribute(Qt::WA_SetLocale)) {
| 0 | ||||||||||||||||||||||||||||||||||||
6005 | setLocale_helper(q->isWindow() | - | ||||||||||||||||||||||||||||||||||||
6006 | ? QLocale() | - | ||||||||||||||||||||||||||||||||||||
6007 | : q->parentWidget()->locale()); | - | ||||||||||||||||||||||||||||||||||||
6008 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6009 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6010 | - | |||||||||||||||||||||||||||||||||||||
6011 | void QWidget::unsetLocale() | - | ||||||||||||||||||||||||||||||||||||
6012 | { | - | ||||||||||||||||||||||||||||||||||||
6013 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6014 | setAttribute(Qt::WA_SetLocale, false); | - | ||||||||||||||||||||||||||||||||||||
6015 | d->resolveLocale(); | - | ||||||||||||||||||||||||||||||||||||
6016 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6017 | - | |||||||||||||||||||||||||||||||||||||
6018 | /*! | - | ||||||||||||||||||||||||||||||||||||
6019 | \property QWidget::windowTitle | - | ||||||||||||||||||||||||||||||||||||
6020 | \brief the window title (caption) | - | ||||||||||||||||||||||||||||||||||||
6021 | - | |||||||||||||||||||||||||||||||||||||
6022 | This property only makes sense for top-level widgets, such as | - | ||||||||||||||||||||||||||||||||||||
6023 | windows and dialogs. If no caption has been set, the title is based of the | - | ||||||||||||||||||||||||||||||||||||
6024 | \l windowFilePath. If neither of these is set, then the title is | - | ||||||||||||||||||||||||||||||||||||
6025 | an empty string. | - | ||||||||||||||||||||||||||||||||||||
6026 | - | |||||||||||||||||||||||||||||||||||||
6027 | If you use the \l windowModified mechanism, the window title must | - | ||||||||||||||||||||||||||||||||||||
6028 | contain a "[*]" placeholder, which indicates where the '*' should | - | ||||||||||||||||||||||||||||||||||||
6029 | appear. Normally, it should appear right after the file name | - | ||||||||||||||||||||||||||||||||||||
6030 | (e.g., "document1.txt[*] - Text Editor"). If the \l | - | ||||||||||||||||||||||||||||||||||||
6031 | windowModified property is \c false (the default), the placeholder | - | ||||||||||||||||||||||||||||||||||||
6032 | is simply removed. | - | ||||||||||||||||||||||||||||||||||||
6033 | - | |||||||||||||||||||||||||||||||||||||
6034 | On some desktop platforms (including Windows and Unix), the application name | - | ||||||||||||||||||||||||||||||||||||
6035 | (from QGuiApplication::applicationDisplayName) is added at the end of the | - | ||||||||||||||||||||||||||||||||||||
6036 | window title, if set. This is done by the QPA plugin, so it is shown to the | - | ||||||||||||||||||||||||||||||||||||
6037 | user, but isn't part of the windowTitle string. | - | ||||||||||||||||||||||||||||||||||||
6038 | - | |||||||||||||||||||||||||||||||||||||
6039 | \sa windowIcon, windowModified, windowFilePath | - | ||||||||||||||||||||||||||||||||||||
6040 | */ | - | ||||||||||||||||||||||||||||||||||||
6041 | QString QWidget::windowTitle() const | - | ||||||||||||||||||||||||||||||||||||
6042 | { | - | ||||||||||||||||||||||||||||||||||||
6043 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
6044 | if (d->extra && d->extra->topextra) {
| 0 | ||||||||||||||||||||||||||||||||||||
6045 | if (!d->extra->topextra->caption.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
6046 | return d->extra->topextra->caption; never executed: return d->extra->topextra->caption; | 0 | ||||||||||||||||||||||||||||||||||||
6047 | if (!d->extra->topextra->filePath.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
6048 | return QFileInfo(d->extra->topextra->filePath).fileName() + QLatin1String("[*]"); never executed: return QFileInfo(d->extra->topextra->filePath).fileName() + QLatin1String("[*]"); | 0 | ||||||||||||||||||||||||||||||||||||
6049 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6050 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||||||||
6051 | } | - | ||||||||||||||||||||||||||||||||||||
6052 | - | |||||||||||||||||||||||||||||||||||||
6053 | /*! | - | ||||||||||||||||||||||||||||||||||||
6054 | Returns a modified window title with the [*] place holder | - | ||||||||||||||||||||||||||||||||||||
6055 | replaced according to the rules described in QWidget::setWindowTitle | - | ||||||||||||||||||||||||||||||||||||
6056 | - | |||||||||||||||||||||||||||||||||||||
6057 | This function assumes that "[*]" can be quoted by another | - | ||||||||||||||||||||||||||||||||||||
6058 | "[*]", so it will replace two place holders by one and | - | ||||||||||||||||||||||||||||||||||||
6059 | a single last one by either "*" or nothing depending on | - | ||||||||||||||||||||||||||||||||||||
6060 | the modified flag. | - | ||||||||||||||||||||||||||||||||||||
6061 | - | |||||||||||||||||||||||||||||||||||||
6062 | \internal | - | ||||||||||||||||||||||||||||||||||||
6063 | */ | - | ||||||||||||||||||||||||||||||||||||
6064 | QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
6065 | { | - | ||||||||||||||||||||||||||||||||||||
6066 | Q_ASSERT(widget); | - | ||||||||||||||||||||||||||||||||||||
6067 | - | |||||||||||||||||||||||||||||||||||||
6068 | #ifdef QT_EVAL | - | ||||||||||||||||||||||||||||||||||||
6069 | extern QString qt_eval_adapt_window_title(const QString &title); | - | ||||||||||||||||||||||||||||||||||||
6070 | QString cap = qt_eval_adapt_window_title(title); | - | ||||||||||||||||||||||||||||||||||||
6071 | #else | - | ||||||||||||||||||||||||||||||||||||
6072 | QString cap = title; | - | ||||||||||||||||||||||||||||||||||||
6073 | #endif | - | ||||||||||||||||||||||||||||||||||||
6074 | - | |||||||||||||||||||||||||||||||||||||
6075 | if (cap.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
6076 | return cap; never executed: return cap; | 0 | ||||||||||||||||||||||||||||||||||||
6077 | - | |||||||||||||||||||||||||||||||||||||
6078 | QLatin1String placeHolder("[*]"); | - | ||||||||||||||||||||||||||||||||||||
6079 | int index = cap.indexOf(placeHolder); | - | ||||||||||||||||||||||||||||||||||||
6080 | - | |||||||||||||||||||||||||||||||||||||
6081 | // here the magic begins | - | ||||||||||||||||||||||||||||||||||||
6082 | while (index != -1) {
| 0 | ||||||||||||||||||||||||||||||||||||
6083 | index += placeHolder.size(); | - | ||||||||||||||||||||||||||||||||||||
6084 | int count = 1; | - | ||||||||||||||||||||||||||||||||||||
6085 | while (cap.indexOf(placeHolder, index) == index) {
| 0 | ||||||||||||||||||||||||||||||||||||
6086 | ++count; | - | ||||||||||||||||||||||||||||||||||||
6087 | index += placeHolder.size(); | - | ||||||||||||||||||||||||||||||||||||
6088 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6089 | - | |||||||||||||||||||||||||||||||||||||
6090 | if (count%2) { // odd number of [*] -> replace last one
| 0 | ||||||||||||||||||||||||||||||||||||
6091 | int lastIndex = cap.lastIndexOf(placeHolder, index - 1); | - | ||||||||||||||||||||||||||||||||||||
6092 | if (widget->isWindowModified()
| 0 | ||||||||||||||||||||||||||||||||||||
6093 | && widget->style()->styleHint(QStyle::SH_TitleBar_ModifyNotification, 0, widget))
| 0 | ||||||||||||||||||||||||||||||||||||
6094 | cap.replace(lastIndex, 3, QWidget::tr("*")); never executed: cap.replace(lastIndex, 3, QWidget::tr("*")); | 0 | ||||||||||||||||||||||||||||||||||||
6095 | else | - | ||||||||||||||||||||||||||||||||||||
6096 | cap.remove(lastIndex, 3); never executed: cap.remove(lastIndex, 3); | 0 | ||||||||||||||||||||||||||||||||||||
6097 | } | - | ||||||||||||||||||||||||||||||||||||
6098 | - | |||||||||||||||||||||||||||||||||||||
6099 | index = cap.indexOf(placeHolder, index); | - | ||||||||||||||||||||||||||||||||||||
6100 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6101 | - | |||||||||||||||||||||||||||||||||||||
6102 | cap.replace(QLatin1String("[*][*]"), placeHolder); | - | ||||||||||||||||||||||||||||||||||||
6103 | - | |||||||||||||||||||||||||||||||||||||
6104 | return cap; never executed: return cap; | 0 | ||||||||||||||||||||||||||||||||||||
6105 | } | - | ||||||||||||||||||||||||||||||||||||
6106 | - | |||||||||||||||||||||||||||||||||||||
6107 | void QWidgetPrivate::setWindowTitle_helper(const QString &title) | - | ||||||||||||||||||||||||||||||||||||
6108 | { | - | ||||||||||||||||||||||||||||||||||||
6109 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6110 | if (q->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
6111 | setWindowTitle_sys(qt_setWindowTitle_helperHelper(title, q)); never executed: setWindowTitle_sys(qt_setWindowTitle_helperHelper(title, q)); | 0 | ||||||||||||||||||||||||||||||||||||
6112 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6113 | - | |||||||||||||||||||||||||||||||||||||
6114 | void QWidgetPrivate::setWindowTitle_sys(const QString &caption) | - | ||||||||||||||||||||||||||||||||||||
6115 | { | - | ||||||||||||||||||||||||||||||||||||
6116 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6117 | if (!q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
6118 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6119 | - | |||||||||||||||||||||||||||||||||||||
6120 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
6121 | window->setTitle(caption); never executed: window->setTitle(caption); | 0 | ||||||||||||||||||||||||||||||||||||
6122 | - | |||||||||||||||||||||||||||||||||||||
6123 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6124 | - | |||||||||||||||||||||||||||||||||||||
6125 | void QWidgetPrivate::setWindowIconText_helper(const QString &title) | - | ||||||||||||||||||||||||||||||||||||
6126 | { | - | ||||||||||||||||||||||||||||||||||||
6127 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6128 | if (q->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
6129 | setWindowIconText_sys(qt_setWindowTitle_helperHelper(title, q)); never executed: setWindowIconText_sys(qt_setWindowTitle_helperHelper(title, q)); | 0 | ||||||||||||||||||||||||||||||||||||
6130 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6131 | - | |||||||||||||||||||||||||||||||||||||
6132 | void QWidgetPrivate::setWindowIconText_sys(const QString &iconText) | - | ||||||||||||||||||||||||||||||||||||
6133 | { | - | ||||||||||||||||||||||||||||||||||||
6134 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6135 | // ### The QWidget property is deprecated, but the XCB window function is not. | - | ||||||||||||||||||||||||||||||||||||
6136 | // It should remain available for the rare application that needs it. | - | ||||||||||||||||||||||||||||||||||||
6137 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
6138 | QXcbWindowFunctions::setWmWindowIconText(window, iconText); never executed: QXcbWindowFunctions::setWmWindowIconText(window, iconText); | 0 | ||||||||||||||||||||||||||||||||||||
6139 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6140 | - | |||||||||||||||||||||||||||||||||||||
6141 | /*! | - | ||||||||||||||||||||||||||||||||||||
6142 | \fn void QWidget::windowIconTextChanged(const QString &iconText) | - | ||||||||||||||||||||||||||||||||||||
6143 | - | |||||||||||||||||||||||||||||||||||||
6144 | This signal is emitted when the window's icon text has changed, with the | - | ||||||||||||||||||||||||||||||||||||
6145 | new \a iconText as an argument. | - | ||||||||||||||||||||||||||||||||||||
6146 | - | |||||||||||||||||||||||||||||||||||||
6147 | \since 5.2 | - | ||||||||||||||||||||||||||||||||||||
6148 | \obsolete | - | ||||||||||||||||||||||||||||||||||||
6149 | - | |||||||||||||||||||||||||||||||||||||
6150 | This signal is deprecated. | - | ||||||||||||||||||||||||||||||||||||
6151 | */ | - | ||||||||||||||||||||||||||||||||||||
6152 | - | |||||||||||||||||||||||||||||||||||||
6153 | void QWidget::setWindowIconText(const QString &iconText) | - | ||||||||||||||||||||||||||||||||||||
6154 | { | - | ||||||||||||||||||||||||||||||||||||
6155 | if (QWidget::windowIconText() == iconText)
| 0 | ||||||||||||||||||||||||||||||||||||
6156 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6157 | - | |||||||||||||||||||||||||||||||||||||
6158 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6159 | d->topData()->iconText = iconText; | - | ||||||||||||||||||||||||||||||||||||
6160 | d->setWindowIconText_helper(iconText); | - | ||||||||||||||||||||||||||||||||||||
6161 | - | |||||||||||||||||||||||||||||||||||||
6162 | QEvent e(QEvent::IconTextChange); | - | ||||||||||||||||||||||||||||||||||||
6163 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
6164 | - | |||||||||||||||||||||||||||||||||||||
6165 | emit windowIconTextChanged(iconText); | - | ||||||||||||||||||||||||||||||||||||
6166 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6167 | - | |||||||||||||||||||||||||||||||||||||
6168 | /*! | - | ||||||||||||||||||||||||||||||||||||
6169 | \fn void QWidget::windowTitleChanged(const QString &title) | - | ||||||||||||||||||||||||||||||||||||
6170 | - | |||||||||||||||||||||||||||||||||||||
6171 | This signal is emitted when the window's title has changed, with the | - | ||||||||||||||||||||||||||||||||||||
6172 | new \a title as an argument. | - | ||||||||||||||||||||||||||||||||||||
6173 | - | |||||||||||||||||||||||||||||||||||||
6174 | \since 5.2 | - | ||||||||||||||||||||||||||||||||||||
6175 | */ | - | ||||||||||||||||||||||||||||||||||||
6176 | - | |||||||||||||||||||||||||||||||||||||
6177 | void QWidget::setWindowTitle(const QString &title) | - | ||||||||||||||||||||||||||||||||||||
6178 | { | - | ||||||||||||||||||||||||||||||||||||
6179 | if (QWidget::windowTitle() == title && !title.isEmpty() && !title.isNull())
| 0 | ||||||||||||||||||||||||||||||||||||
6180 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6181 | - | |||||||||||||||||||||||||||||||||||||
6182 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6183 | d->topData()->caption = title; | - | ||||||||||||||||||||||||||||||||||||
6184 | d->setWindowTitle_helper(title); | - | ||||||||||||||||||||||||||||||||||||
6185 | - | |||||||||||||||||||||||||||||||||||||
6186 | QEvent e(QEvent::WindowTitleChange); | - | ||||||||||||||||||||||||||||||||||||
6187 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
6188 | - | |||||||||||||||||||||||||||||||||||||
6189 | emit windowTitleChanged(title); | - | ||||||||||||||||||||||||||||||||||||
6190 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6191 | - | |||||||||||||||||||||||||||||||||||||
6192 | - | |||||||||||||||||||||||||||||||||||||
6193 | /*! | - | ||||||||||||||||||||||||||||||||||||
6194 | \property QWidget::windowIcon | - | ||||||||||||||||||||||||||||||||||||
6195 | \brief the widget's icon | - | ||||||||||||||||||||||||||||||||||||
6196 | - | |||||||||||||||||||||||||||||||||||||
6197 | This property only makes sense for windows. If no icon | - | ||||||||||||||||||||||||||||||||||||
6198 | has been set, windowIcon() returns the application icon | - | ||||||||||||||||||||||||||||||||||||
6199 | (QApplication::windowIcon()). | - | ||||||||||||||||||||||||||||||||||||
6200 | - | |||||||||||||||||||||||||||||||||||||
6201 | \sa windowTitle | - | ||||||||||||||||||||||||||||||||||||
6202 | */ | - | ||||||||||||||||||||||||||||||||||||
6203 | QIcon QWidget::windowIcon() const | - | ||||||||||||||||||||||||||||||||||||
6204 | { | - | ||||||||||||||||||||||||||||||||||||
6205 | const QWidget *w = this; | - | ||||||||||||||||||||||||||||||||||||
6206 | while (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
6207 | const QWidgetPrivate *d = w->d_func(); | - | ||||||||||||||||||||||||||||||||||||
6208 | if (d->extra && d->extra->topextra && d->extra->topextra->icon)
| 0 | ||||||||||||||||||||||||||||||||||||
6209 | return *d->extra->topextra->icon; never executed: return *d->extra->topextra->icon; | 0 | ||||||||||||||||||||||||||||||||||||
6210 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
6211 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6212 | return QApplication::windowIcon(); never executed: return QApplication::windowIcon(); | 0 | ||||||||||||||||||||||||||||||||||||
6213 | } | - | ||||||||||||||||||||||||||||||||||||
6214 | - | |||||||||||||||||||||||||||||||||||||
6215 | void QWidgetPrivate::setWindowIcon_helper() | - | ||||||||||||||||||||||||||||||||||||
6216 | { | - | ||||||||||||||||||||||||||||||||||||
6217 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6218 | QEvent e(QEvent::WindowIconChange); | - | ||||||||||||||||||||||||||||||||||||
6219 | - | |||||||||||||||||||||||||||||||||||||
6220 | // Do not send the event if the widget is a top level. | - | ||||||||||||||||||||||||||||||||||||
6221 | // In that case, setWindowIcon_sys does it, and event propagation from | - | ||||||||||||||||||||||||||||||||||||
6222 | // QWidgetWindow to the top level QWidget ensures that the event reaches | - | ||||||||||||||||||||||||||||||||||||
6223 | // the top level anyhow | - | ||||||||||||||||||||||||||||||||||||
6224 | if (!q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
6225 | QApplication::sendEvent(q, &e); never executed: QApplication::sendEvent(q, &e); | 0 | ||||||||||||||||||||||||||||||||||||
6226 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
6227 | QWidget *w = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
6228 | if (w && !w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
6229 | QApplication::sendEvent(w, &e); never executed: QApplication::sendEvent(w, &e); | 0 | ||||||||||||||||||||||||||||||||||||
6230 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6231 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6232 | - | |||||||||||||||||||||||||||||||||||||
6233 | /*! | - | ||||||||||||||||||||||||||||||||||||
6234 | \fn void QWidget::windowIconChanged(const QIcon &icon) | - | ||||||||||||||||||||||||||||||||||||
6235 | - | |||||||||||||||||||||||||||||||||||||
6236 | This signal is emitted when the window's icon has changed, with the | - | ||||||||||||||||||||||||||||||||||||
6237 | new \a icon as an argument. | - | ||||||||||||||||||||||||||||||||||||
6238 | - | |||||||||||||||||||||||||||||||||||||
6239 | \since 5.2 | - | ||||||||||||||||||||||||||||||||||||
6240 | */ | - | ||||||||||||||||||||||||||||||||||||
6241 | - | |||||||||||||||||||||||||||||||||||||
6242 | void QWidget::setWindowIcon(const QIcon &icon) | - | ||||||||||||||||||||||||||||||||||||
6243 | { | - | ||||||||||||||||||||||||||||||||||||
6244 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6245 | - | |||||||||||||||||||||||||||||||||||||
6246 | setAttribute(Qt::WA_SetWindowIcon, !icon.isNull()); | - | ||||||||||||||||||||||||||||||||||||
6247 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
6248 | - | |||||||||||||||||||||||||||||||||||||
6249 | if (!d->extra->topextra->icon)
| 0 | ||||||||||||||||||||||||||||||||||||
6250 | d->extra->topextra->icon = new QIcon(); never executed: d->extra->topextra->icon = new QIcon(); | 0 | ||||||||||||||||||||||||||||||||||||
6251 | *d->extra->topextra->icon = icon; | - | ||||||||||||||||||||||||||||||||||||
6252 | - | |||||||||||||||||||||||||||||||||||||
6253 | d->setWindowIcon_sys(); | - | ||||||||||||||||||||||||||||||||||||
6254 | d->setWindowIcon_helper(); | - | ||||||||||||||||||||||||||||||||||||
6255 | - | |||||||||||||||||||||||||||||||||||||
6256 | emit windowIconChanged(icon); | - | ||||||||||||||||||||||||||||||||||||
6257 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6258 | - | |||||||||||||||||||||||||||||||||||||
6259 | void QWidgetPrivate::setWindowIcon_sys() | - | ||||||||||||||||||||||||||||||||||||
6260 | { | - | ||||||||||||||||||||||||||||||||||||
6261 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6262 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
6263 | window->setIcon(q->windowIcon()); never executed: window->setIcon(q->windowIcon()); | 0 | ||||||||||||||||||||||||||||||||||||
6264 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6265 | - | |||||||||||||||||||||||||||||||||||||
6266 | /*! | - | ||||||||||||||||||||||||||||||||||||
6267 | \property QWidget::windowIconText | - | ||||||||||||||||||||||||||||||||||||
6268 | \brief the text to be displayed on the icon of a minimized window | - | ||||||||||||||||||||||||||||||||||||
6269 | - | |||||||||||||||||||||||||||||||||||||
6270 | This property only makes sense for windows. If no icon | - | ||||||||||||||||||||||||||||||||||||
6271 | text has been set, this accessor returns an empty string. | - | ||||||||||||||||||||||||||||||||||||
6272 | It is only implemented on the X11 platform, and only certain | - | ||||||||||||||||||||||||||||||||||||
6273 | window managers use this window property. | - | ||||||||||||||||||||||||||||||||||||
6274 | - | |||||||||||||||||||||||||||||||||||||
6275 | \obsolete | - | ||||||||||||||||||||||||||||||||||||
6276 | This property is deprecated. | - | ||||||||||||||||||||||||||||||||||||
6277 | - | |||||||||||||||||||||||||||||||||||||
6278 | \sa windowIcon, windowTitle | - | ||||||||||||||||||||||||||||||||||||
6279 | */ | - | ||||||||||||||||||||||||||||||||||||
6280 | - | |||||||||||||||||||||||||||||||||||||
6281 | QString QWidget::windowIconText() const | - | ||||||||||||||||||||||||||||||||||||
6282 | { | - | ||||||||||||||||||||||||||||||||||||
6283 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
6284 | return (d->extra && d->extra->topextra) ? d->extra->topextra->iconText : QString(); never executed: return (d->extra && d->extra->topextra) ? d->extra->topextra->iconText : QString(); | 0 | ||||||||||||||||||||||||||||||||||||
6285 | } | - | ||||||||||||||||||||||||||||||||||||
6286 | - | |||||||||||||||||||||||||||||||||||||
6287 | /*! | - | ||||||||||||||||||||||||||||||||||||
6288 | \property QWidget::windowFilePath | - | ||||||||||||||||||||||||||||||||||||
6289 | \since 4.4 | - | ||||||||||||||||||||||||||||||||||||
6290 | \brief the file path associated with a widget | - | ||||||||||||||||||||||||||||||||||||
6291 | - | |||||||||||||||||||||||||||||||||||||
6292 | This property only makes sense for windows. It associates a file path with | - | ||||||||||||||||||||||||||||||||||||
6293 | a window. If you set the file path, but have not set the window title, Qt | - | ||||||||||||||||||||||||||||||||||||
6294 | sets the window title to the file name of the specified path, obtained using | - | ||||||||||||||||||||||||||||||||||||
6295 | QFileInfo::fileName(). | - | ||||||||||||||||||||||||||||||||||||
6296 | - | |||||||||||||||||||||||||||||||||||||
6297 | If the window title is set at any point, then the window title takes precedence and | - | ||||||||||||||||||||||||||||||||||||
6298 | will be shown instead of the file path string. | - | ||||||||||||||||||||||||||||||||||||
6299 | - | |||||||||||||||||||||||||||||||||||||
6300 | Additionally, on \macos, this has an added benefit that it sets the | - | ||||||||||||||||||||||||||||||||||||
6301 | \l{http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGWindows/chapter_17_section_3.html}{proxy icon} | - | ||||||||||||||||||||||||||||||||||||
6302 | for the window, assuming that the file path exists. | - | ||||||||||||||||||||||||||||||||||||
6303 | - | |||||||||||||||||||||||||||||||||||||
6304 | If no file path is set, this property contains an empty string. | - | ||||||||||||||||||||||||||||||||||||
6305 | - | |||||||||||||||||||||||||||||||||||||
6306 | By default, this property contains an empty string. | - | ||||||||||||||||||||||||||||||||||||
6307 | - | |||||||||||||||||||||||||||||||||||||
6308 | \sa windowTitle, windowIcon | - | ||||||||||||||||||||||||||||||||||||
6309 | */ | - | ||||||||||||||||||||||||||||||||||||
6310 | - | |||||||||||||||||||||||||||||||||||||
6311 | QString QWidget::windowFilePath() const | - | ||||||||||||||||||||||||||||||||||||
6312 | { | - | ||||||||||||||||||||||||||||||||||||
6313 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
6314 | return (d->extra && d->extra->topextra) ? d->extra->topextra->filePath : QString(); never executed: return (d->extra && d->extra->topextra) ? d->extra->topextra->filePath : QString(); | 0 | ||||||||||||||||||||||||||||||||||||
6315 | } | - | ||||||||||||||||||||||||||||||||||||
6316 | - | |||||||||||||||||||||||||||||||||||||
6317 | void QWidget::setWindowFilePath(const QString &filePath) | - | ||||||||||||||||||||||||||||||||||||
6318 | { | - | ||||||||||||||||||||||||||||||||||||
6319 | if (filePath == windowFilePath())
| 0 | ||||||||||||||||||||||||||||||||||||
6320 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6321 | - | |||||||||||||||||||||||||||||||||||||
6322 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6323 | - | |||||||||||||||||||||||||||||||||||||
6324 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
6325 | d->extra->topextra->filePath = filePath; | - | ||||||||||||||||||||||||||||||||||||
6326 | d->setWindowFilePath_helper(filePath); | - | ||||||||||||||||||||||||||||||||||||
6327 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6328 | - | |||||||||||||||||||||||||||||||||||||
6329 | void QWidgetPrivate::setWindowFilePath_helper(const QString &filePath) | - | ||||||||||||||||||||||||||||||||||||
6330 | { | - | ||||||||||||||||||||||||||||||||||||
6331 | if (extra->topextra && extra->topextra->caption.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6332 | #ifdef Q_OS_MAC | - | ||||||||||||||||||||||||||||||||||||
6333 | setWindowTitle_helper(QFileInfo(filePath).fileName()); | - | ||||||||||||||||||||||||||||||||||||
6334 | #else | - | ||||||||||||||||||||||||||||||||||||
6335 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6336 | Q_UNUSED(filePath); | - | ||||||||||||||||||||||||||||||||||||
6337 | setWindowTitle_helper(q->windowTitle()); | - | ||||||||||||||||||||||||||||||||||||
6338 | #endif | - | ||||||||||||||||||||||||||||||||||||
6339 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6340 | #ifdef Q_OS_MAC | - | ||||||||||||||||||||||||||||||||||||
6341 | setWindowFilePath_sys(filePath); | - | ||||||||||||||||||||||||||||||||||||
6342 | #endif | - | ||||||||||||||||||||||||||||||||||||
6343 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6344 | - | |||||||||||||||||||||||||||||||||||||
6345 | void QWidgetPrivate::setWindowFilePath_sys(const QString &filePath) | - | ||||||||||||||||||||||||||||||||||||
6346 | { | - | ||||||||||||||||||||||||||||||||||||
6347 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6348 | if (!q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
6349 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6350 | - | |||||||||||||||||||||||||||||||||||||
6351 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
6352 | window->setFilePath(filePath); never executed: window->setFilePath(filePath); | 0 | ||||||||||||||||||||||||||||||||||||
6353 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6354 | - | |||||||||||||||||||||||||||||||||||||
6355 | /*! | - | ||||||||||||||||||||||||||||||||||||
6356 | Returns the window's role, or an empty string. | - | ||||||||||||||||||||||||||||||||||||
6357 | - | |||||||||||||||||||||||||||||||||||||
6358 | \sa windowIcon, windowTitle | - | ||||||||||||||||||||||||||||||||||||
6359 | */ | - | ||||||||||||||||||||||||||||||||||||
6360 | - | |||||||||||||||||||||||||||||||||||||
6361 | QString QWidget::windowRole() const | - | ||||||||||||||||||||||||||||||||||||
6362 | { | - | ||||||||||||||||||||||||||||||||||||
6363 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
6364 | return (d->extra && d->extra->topextra) ? d->extra->topextra->role : QString(); never executed: return (d->extra && d->extra->topextra) ? d->extra->topextra->role : QString(); | 0 | ||||||||||||||||||||||||||||||||||||
6365 | } | - | ||||||||||||||||||||||||||||||||||||
6366 | - | |||||||||||||||||||||||||||||||||||||
6367 | /*! | - | ||||||||||||||||||||||||||||||||||||
6368 | Sets the window's role to \a role. This only makes sense for | - | ||||||||||||||||||||||||||||||||||||
6369 | windows on X11. | - | ||||||||||||||||||||||||||||||||||||
6370 | */ | - | ||||||||||||||||||||||||||||||||||||
6371 | void QWidget::setWindowRole(const QString &role) | - | ||||||||||||||||||||||||||||||||||||
6372 | { | - | ||||||||||||||||||||||||||||||||||||
6373 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6374 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
6375 | d->topData()->role = role; | - | ||||||||||||||||||||||||||||||||||||
6376 | if (windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
6377 | QXcbWindowFunctions::setWmWindowRole(windowHandle(), role.toLatin1()); never executed: QXcbWindowFunctions::setWmWindowRole(windowHandle(), role.toLatin1()); | 0 | ||||||||||||||||||||||||||||||||||||
6378 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6379 | - | |||||||||||||||||||||||||||||||||||||
6380 | /*! | - | ||||||||||||||||||||||||||||||||||||
6381 | \property QWidget::mouseTracking | - | ||||||||||||||||||||||||||||||||||||
6382 | \brief whether mouse tracking is enabled for the widget | - | ||||||||||||||||||||||||||||||||||||
6383 | - | |||||||||||||||||||||||||||||||||||||
6384 | If mouse tracking is disabled (the default), the widget only | - | ||||||||||||||||||||||||||||||||||||
6385 | receives mouse move events when at least one mouse button is | - | ||||||||||||||||||||||||||||||||||||
6386 | pressed while the mouse is being moved. | - | ||||||||||||||||||||||||||||||||||||
6387 | - | |||||||||||||||||||||||||||||||||||||
6388 | If mouse tracking is enabled, the widget receives mouse move | - | ||||||||||||||||||||||||||||||||||||
6389 | events even if no buttons are pressed. | - | ||||||||||||||||||||||||||||||||||||
6390 | - | |||||||||||||||||||||||||||||||||||||
6391 | \sa mouseMoveEvent() | - | ||||||||||||||||||||||||||||||||||||
6392 | */ | - | ||||||||||||||||||||||||||||||||||||
6393 | - | |||||||||||||||||||||||||||||||||||||
6394 | - | |||||||||||||||||||||||||||||||||||||
6395 | /*! | - | ||||||||||||||||||||||||||||||||||||
6396 | Sets the widget's focus proxy to widget \a w. If \a w is 0, the | - | ||||||||||||||||||||||||||||||||||||
6397 | function resets this widget to have no focus proxy. | - | ||||||||||||||||||||||||||||||||||||
6398 | - | |||||||||||||||||||||||||||||||||||||
6399 | Some widgets can "have focus", but create a child widget, such as | - | ||||||||||||||||||||||||||||||||||||
6400 | QLineEdit, to actually handle the focus. In this case, the widget | - | ||||||||||||||||||||||||||||||||||||
6401 | can set the line edit to be its focus proxy. | - | ||||||||||||||||||||||||||||||||||||
6402 | - | |||||||||||||||||||||||||||||||||||||
6403 | setFocusProxy() sets the widget which will actually get focus when | - | ||||||||||||||||||||||||||||||||||||
6404 | "this widget" gets it. If there is a focus proxy, setFocus() and | - | ||||||||||||||||||||||||||||||||||||
6405 | hasFocus() operate on the focus proxy. | - | ||||||||||||||||||||||||||||||||||||
6406 | - | |||||||||||||||||||||||||||||||||||||
6407 | \sa focusProxy() | - | ||||||||||||||||||||||||||||||||||||
6408 | */ | - | ||||||||||||||||||||||||||||||||||||
6409 | - | |||||||||||||||||||||||||||||||||||||
6410 | void QWidget::setFocusProxy(QWidget * w) | - | ||||||||||||||||||||||||||||||||||||
6411 | { | - | ||||||||||||||||||||||||||||||||||||
6412 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6413 | if (!w && !d->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
6414 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6415 | - | |||||||||||||||||||||||||||||||||||||
6416 | for (QWidget* fp = w; fp; fp = fp->focusProxy()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6417 | if (Q_UNLIKELY(fp == this)) {
| 0 | ||||||||||||||||||||||||||||||||||||
6418 | qWarning("QWidget: %s (%s) already in focus proxy chain", metaObject()->className(), objectName().toLocal8Bit().constData()); | - | ||||||||||||||||||||||||||||||||||||
6419 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6420 | } | - | ||||||||||||||||||||||||||||||||||||
6421 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6422 | - | |||||||||||||||||||||||||||||||||||||
6423 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
6424 | d->extra->focus_proxy = w; | - | ||||||||||||||||||||||||||||||||||||
6425 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6426 | - | |||||||||||||||||||||||||||||||||||||
6427 | - | |||||||||||||||||||||||||||||||||||||
6428 | /*! | - | ||||||||||||||||||||||||||||||||||||
6429 | Returns the focus proxy, or 0 if there is no focus proxy. | - | ||||||||||||||||||||||||||||||||||||
6430 | - | |||||||||||||||||||||||||||||||||||||
6431 | \sa setFocusProxy() | - | ||||||||||||||||||||||||||||||||||||
6432 | */ | - | ||||||||||||||||||||||||||||||||||||
6433 | - | |||||||||||||||||||||||||||||||||||||
6434 | QWidget * QWidget::focusProxy() const | - | ||||||||||||||||||||||||||||||||||||
6435 | { | - | ||||||||||||||||||||||||||||||||||||
6436 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
6437 | return d->extra ? (QWidget *)d->extra->focus_proxy : 0; never executed: return d->extra ? (QWidget *)d->extra->focus_proxy : 0; | 0 | ||||||||||||||||||||||||||||||||||||
6438 | } | - | ||||||||||||||||||||||||||||||||||||
6439 | - | |||||||||||||||||||||||||||||||||||||
6440 | - | |||||||||||||||||||||||||||||||||||||
6441 | /*! | - | ||||||||||||||||||||||||||||||||||||
6442 | \property QWidget::focus | - | ||||||||||||||||||||||||||||||||||||
6443 | \brief whether this widget (or its focus proxy) has the keyboard | - | ||||||||||||||||||||||||||||||||||||
6444 | input focus | - | ||||||||||||||||||||||||||||||||||||
6445 | - | |||||||||||||||||||||||||||||||||||||
6446 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
6447 | - | |||||||||||||||||||||||||||||||||||||
6448 | \note Obtaining the value of this property for a widget is effectively equivalent | - | ||||||||||||||||||||||||||||||||||||
6449 | to checking whether QApplication::focusWidget() refers to the widget. | - | ||||||||||||||||||||||||||||||||||||
6450 | - | |||||||||||||||||||||||||||||||||||||
6451 | \sa setFocus(), clearFocus(), setFocusPolicy(), QApplication::focusWidget() | - | ||||||||||||||||||||||||||||||||||||
6452 | */ | - | ||||||||||||||||||||||||||||||||||||
6453 | bool QWidget::hasFocus() const | - | ||||||||||||||||||||||||||||||||||||
6454 | { | - | ||||||||||||||||||||||||||||||||||||
6455 | const QWidget* w = this; | - | ||||||||||||||||||||||||||||||||||||
6456 | while (w->d_func()->extra && w->d_func()->extra->focus_proxy)
| 0 | ||||||||||||||||||||||||||||||||||||
6457 | w = w->d_func()->extra->focus_proxy; never executed: w = w->d_func()->extra->focus_proxy; | 0 | ||||||||||||||||||||||||||||||||||||
6458 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6459 | if (QWidget *window = w->window()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6460 | QWExtra *e = window->d_func()->extra; | - | ||||||||||||||||||||||||||||||||||||
6461 | if (e && e->proxyWidget && e->proxyWidget->hasFocus() && window->focusWidget() == w)
| 0 | ||||||||||||||||||||||||||||||||||||
6462 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
6463 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6464 | #endif // !QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6465 | return (QApplication::focusWidget() == w); never executed: return (QApplication::focusWidget() == w); | 0 | ||||||||||||||||||||||||||||||||||||
6466 | } | - | ||||||||||||||||||||||||||||||||||||
6467 | - | |||||||||||||||||||||||||||||||||||||
6468 | /*! | - | ||||||||||||||||||||||||||||||||||||
6469 | Gives the keyboard input focus to this widget (or its focus | - | ||||||||||||||||||||||||||||||||||||
6470 | proxy) if this widget or one of its parents is the \l{isActiveWindow()}{active window}. The \a reason argument will | - | ||||||||||||||||||||||||||||||||||||
6471 | be passed into any focus event sent from this function, it is used | - | ||||||||||||||||||||||||||||||||||||
6472 | to give an explanation of what caused the widget to get focus. | - | ||||||||||||||||||||||||||||||||||||
6473 | If the window is not active, the widget will be given the focus when | - | ||||||||||||||||||||||||||||||||||||
6474 | the window becomes active. | - | ||||||||||||||||||||||||||||||||||||
6475 | - | |||||||||||||||||||||||||||||||||||||
6476 | First, a focus about to change event is sent to the focus widget (if any) to | - | ||||||||||||||||||||||||||||||||||||
6477 | tell it that it is about to lose the focus. Then focus is changed, a | - | ||||||||||||||||||||||||||||||||||||
6478 | focus out event is sent to the previous focus item and a focus in event is sent | - | ||||||||||||||||||||||||||||||||||||
6479 | to the new item to tell it that it just received the focus. | - | ||||||||||||||||||||||||||||||||||||
6480 | (Nothing happens if the focus in and focus out widgets are the | - | ||||||||||||||||||||||||||||||||||||
6481 | same.) | - | ||||||||||||||||||||||||||||||||||||
6482 | - | |||||||||||||||||||||||||||||||||||||
6483 | \note On embedded platforms, setFocus() will not cause an input panel | - | ||||||||||||||||||||||||||||||||||||
6484 | to be opened by the input method. If you want this to happen, you | - | ||||||||||||||||||||||||||||||||||||
6485 | have to send a QEvent::RequestSoftwareInputPanel event to the | - | ||||||||||||||||||||||||||||||||||||
6486 | widget yourself. | - | ||||||||||||||||||||||||||||||||||||
6487 | - | |||||||||||||||||||||||||||||||||||||
6488 | setFocus() gives focus to a widget regardless of its focus policy, | - | ||||||||||||||||||||||||||||||||||||
6489 | but does not clear any keyboard grab (see grabKeyboard()). | - | ||||||||||||||||||||||||||||||||||||
6490 | - | |||||||||||||||||||||||||||||||||||||
6491 | Be aware that if the widget is hidden, it will not accept focus | - | ||||||||||||||||||||||||||||||||||||
6492 | until it is shown. | - | ||||||||||||||||||||||||||||||||||||
6493 | - | |||||||||||||||||||||||||||||||||||||
6494 | \warning If you call setFocus() in a function which may itself be | - | ||||||||||||||||||||||||||||||||||||
6495 | called from focusOutEvent() or focusInEvent(), you may get an | - | ||||||||||||||||||||||||||||||||||||
6496 | infinite recursion. | - | ||||||||||||||||||||||||||||||||||||
6497 | - | |||||||||||||||||||||||||||||||||||||
6498 | \sa hasFocus(), clearFocus(), focusInEvent(), focusOutEvent(), | - | ||||||||||||||||||||||||||||||||||||
6499 | setFocusPolicy(), focusWidget(), QApplication::focusWidget(), grabKeyboard(), | - | ||||||||||||||||||||||||||||||||||||
6500 | grabMouse(), {Keyboard Focus in Widgets}, QEvent::RequestSoftwareInputPanel | - | ||||||||||||||||||||||||||||||||||||
6501 | */ | - | ||||||||||||||||||||||||||||||||||||
6502 | - | |||||||||||||||||||||||||||||||||||||
6503 | void QWidget::setFocus(Qt::FocusReason reason) | - | ||||||||||||||||||||||||||||||||||||
6504 | { | - | ||||||||||||||||||||||||||||||||||||
6505 | if (!isEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
6506 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6507 | - | |||||||||||||||||||||||||||||||||||||
6508 | QWidget *f = this; | - | ||||||||||||||||||||||||||||||||||||
6509 | while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
| 0 | ||||||||||||||||||||||||||||||||||||
6510 | f = f->d_func()->extra->focus_proxy; never executed: f = f->d_func()->extra->focus_proxy; | 0 | ||||||||||||||||||||||||||||||||||||
6511 | - | |||||||||||||||||||||||||||||||||||||
6512 | if (QApplication::focusWidget() == f
| 0 | ||||||||||||||||||||||||||||||||||||
6513 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
6514 | && GetFocus() == f->internalWinId() | - | ||||||||||||||||||||||||||||||||||||
6515 | #endif | - | ||||||||||||||||||||||||||||||||||||
6516 | ) | - | ||||||||||||||||||||||||||||||||||||
6517 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6518 | - | |||||||||||||||||||||||||||||||||||||
6519 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6520 | QWidget *previousProxyFocus = 0; | - | ||||||||||||||||||||||||||||||||||||
6521 | if (QWExtra *topData = window()->d_func()->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
6522 | if (topData->proxyWidget && topData->proxyWidget->hasFocus()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6523 | previousProxyFocus = topData->proxyWidget->widget()->focusWidget(); | - | ||||||||||||||||||||||||||||||||||||
6524 | if (previousProxyFocus && previousProxyFocus->focusProxy())
| 0 | ||||||||||||||||||||||||||||||||||||
6525 | previousProxyFocus = previousProxyFocus->focusProxy(); never executed: previousProxyFocus = previousProxyFocus->focusProxy(); | 0 | ||||||||||||||||||||||||||||||||||||
6526 | if (previousProxyFocus == this && !topData->proxyWidget->d_func()->proxyIsGivingFocus)
| 0 | ||||||||||||||||||||||||||||||||||||
6527 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6528 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6529 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6530 | #endif | - | ||||||||||||||||||||||||||||||||||||
6531 | - | |||||||||||||||||||||||||||||||||||||
6532 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6533 | // Update proxy state | - | ||||||||||||||||||||||||||||||||||||
6534 | if (QWExtra *topData = window()->d_func()->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
6535 | if (topData->proxyWidget && !topData->proxyWidget->hasFocus()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6536 | f->d_func()->updateFocusChild(); | - | ||||||||||||||||||||||||||||||||||||
6537 | topData->proxyWidget->d_func()->focusFromWidgetToProxy = 1; | - | ||||||||||||||||||||||||||||||||||||
6538 | topData->proxyWidget->setFocus(reason); | - | ||||||||||||||||||||||||||||||||||||
6539 | topData->proxyWidget->d_func()->focusFromWidgetToProxy = 0; | - | ||||||||||||||||||||||||||||||||||||
6540 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6541 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6542 | #endif | - | ||||||||||||||||||||||||||||||||||||
6543 | - | |||||||||||||||||||||||||||||||||||||
6544 | if (f->isActiveWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6545 | QWidget *prev = QApplicationPrivate::focus_widget; | - | ||||||||||||||||||||||||||||||||||||
6546 | if (prev) {
| 0 | ||||||||||||||||||||||||||||||||||||
6547 | if (reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
| 0 | ||||||||||||||||||||||||||||||||||||
6548 | && prev->testAttribute(Qt::WA_InputMethodEnabled)) {
| 0 | ||||||||||||||||||||||||||||||||||||
6549 | QGuiApplication::inputMethod()->commit(); | - | ||||||||||||||||||||||||||||||||||||
6550 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6551 | - | |||||||||||||||||||||||||||||||||||||
6552 | if (reason != Qt::NoFocusReason) {
| 0 | ||||||||||||||||||||||||||||||||||||
6553 | QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, reason); | - | ||||||||||||||||||||||||||||||||||||
6554 | QApplication::sendEvent(prev, &focusAboutToChange); | - | ||||||||||||||||||||||||||||||||||||
6555 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6556 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6557 | - | |||||||||||||||||||||||||||||||||||||
6558 | f->d_func()->updateFocusChild(); | - | ||||||||||||||||||||||||||||||||||||
6559 | - | |||||||||||||||||||||||||||||||||||||
6560 | QApplicationPrivate::setFocusWidget(f, reason); | - | ||||||||||||||||||||||||||||||||||||
6561 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
6562 | # ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
6563 | // The negation of the condition in setFocus_sys | - | ||||||||||||||||||||||||||||||||||||
6564 | if (!(testAttribute(Qt::WA_WState_Created) && window()->windowType() != Qt::Popup && internalWinId())) | - | ||||||||||||||||||||||||||||||||||||
6565 | //setFocusWidget will already post a focus event for us (that the AT client receives) on Windows | - | ||||||||||||||||||||||||||||||||||||
6566 | # endif | - | ||||||||||||||||||||||||||||||||||||
6567 | // menus update the focus manually and this would create bogus events | - | ||||||||||||||||||||||||||||||||||||
6568 | if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem")))
| 0 | ||||||||||||||||||||||||||||||||||||
6569 | { | - | ||||||||||||||||||||||||||||||||||||
6570 | QAccessibleEvent event(f, QAccessible::Focus); | - | ||||||||||||||||||||||||||||||||||||
6571 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
6572 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6573 | #endif | - | ||||||||||||||||||||||||||||||||||||
6574 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6575 | if (QWExtra *topData = window()->d_func()->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
6576 | if (topData->proxyWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
6577 | if (previousProxyFocus && previousProxyFocus != f) {
| 0 | ||||||||||||||||||||||||||||||||||||
6578 | // Send event to self | - | ||||||||||||||||||||||||||||||||||||
6579 | QFocusEvent event(QEvent::FocusOut, reason); | - | ||||||||||||||||||||||||||||||||||||
6580 | QPointer<QWidget> that = previousProxyFocus; | - | ||||||||||||||||||||||||||||||||||||
6581 | QApplication::sendEvent(previousProxyFocus, &event); | - | ||||||||||||||||||||||||||||||||||||
6582 | if (that)
| 0 | ||||||||||||||||||||||||||||||||||||
6583 | QApplication::sendEvent(that->style(), &event); never executed: QApplication::sendEvent(that->style(), &event); | 0 | ||||||||||||||||||||||||||||||||||||
6584 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6585 | if (!isHidden()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6586 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6587 | // Update proxy state | - | ||||||||||||||||||||||||||||||||||||
6588 | if (QWExtra *topData = window()->d_func()->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
6589 | if (topData->proxyWidget && topData->proxyWidget->hasFocus())
| 0 | ||||||||||||||||||||||||||||||||||||
6590 | topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget(); never executed: topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget(); | 0 | ||||||||||||||||||||||||||||||||||||
6591 | #endif | - | ||||||||||||||||||||||||||||||||||||
6592 | // Send event to self | - | ||||||||||||||||||||||||||||||||||||
6593 | QFocusEvent event(QEvent::FocusIn, reason); | - | ||||||||||||||||||||||||||||||||||||
6594 | QPointer<QWidget> that = f; | - | ||||||||||||||||||||||||||||||||||||
6595 | QApplication::sendEvent(f, &event); | - | ||||||||||||||||||||||||||||||||||||
6596 | if (that)
| 0 | ||||||||||||||||||||||||||||||||||||
6597 | QApplication::sendEvent(that->style(), &event); never executed: QApplication::sendEvent(that->style(), &event); | 0 | ||||||||||||||||||||||||||||||||||||
6598 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6599 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6600 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6601 | #endif | - | ||||||||||||||||||||||||||||||||||||
6602 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6603 | f->d_func()->updateFocusChild(); | - | ||||||||||||||||||||||||||||||||||||
6604 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6605 | - | |||||||||||||||||||||||||||||||||||||
6606 | if (QTLWExtra *extra = f->window()->d_func()->maybeTopData()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6607 | if (extra->window)
| 0 | ||||||||||||||||||||||||||||||||||||
6608 | emit extra->window->focusObjectChanged(f); never executed: extra->window->focusObjectChanged(f); | 0 | ||||||||||||||||||||||||||||||||||||
6609 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6610 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6611 | - | |||||||||||||||||||||||||||||||||||||
6612 | void QWidgetPrivate::setFocus_sys() | - | ||||||||||||||||||||||||||||||||||||
6613 | { | - | ||||||||||||||||||||||||||||||||||||
6614 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6615 | // Embedded native widget may have taken the focus; get it back to toplevel if that is the case | - | ||||||||||||||||||||||||||||||||||||
6616 | const QWidget *topLevel = q->window(); | - | ||||||||||||||||||||||||||||||||||||
6617 | if (topLevel->windowType() != Qt::Popup) {
| 0 | ||||||||||||||||||||||||||||||||||||
6618 | if (QWindow *nativeWindow = q->window()->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6619 | if (nativeWindow != QGuiApplication::focusWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
6620 | && q->testAttribute(Qt::WA_WState_Created)) {
| 0 | ||||||||||||||||||||||||||||||||||||
6621 | nativeWindow->requestActivate(); | - | ||||||||||||||||||||||||||||||||||||
6622 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6623 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6624 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6625 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6626 | - | |||||||||||||||||||||||||||||||||||||
6627 | // updates focus_child on parent widgets to point into this widget | - | ||||||||||||||||||||||||||||||||||||
6628 | void QWidgetPrivate::updateFocusChild() | - | ||||||||||||||||||||||||||||||||||||
6629 | { | - | ||||||||||||||||||||||||||||||||||||
6630 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6631 | - | |||||||||||||||||||||||||||||||||||||
6632 | QWidget *w = q; | - | ||||||||||||||||||||||||||||||||||||
6633 | if (q->isHidden()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6634 | while (w && w->isHidden()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6635 | w->d_func()->focus_child = q; | - | ||||||||||||||||||||||||||||||||||||
6636 | w = w->isWindow() ? 0 : w->parentWidget();
| 0 | ||||||||||||||||||||||||||||||||||||
6637 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6638 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6639 | while (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
6640 | w->d_func()->focus_child = q; | - | ||||||||||||||||||||||||||||||||||||
6641 | w = w->isWindow() ? 0 : w->parentWidget();
| 0 | ||||||||||||||||||||||||||||||||||||
6642 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6643 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6644 | } | - | ||||||||||||||||||||||||||||||||||||
6645 | - | |||||||||||||||||||||||||||||||||||||
6646 | /*! | - | ||||||||||||||||||||||||||||||||||||
6647 | \fn void QWidget::setFocus() | - | ||||||||||||||||||||||||||||||||||||
6648 | \overload | - | ||||||||||||||||||||||||||||||||||||
6649 | - | |||||||||||||||||||||||||||||||||||||
6650 | Gives the keyboard input focus to this widget (or its focus | - | ||||||||||||||||||||||||||||||||||||
6651 | proxy) if this widget or one of its parents is the | - | ||||||||||||||||||||||||||||||||||||
6652 | \l{isActiveWindow()}{active window}. | - | ||||||||||||||||||||||||||||||||||||
6653 | */ | - | ||||||||||||||||||||||||||||||||||||
6654 | - | |||||||||||||||||||||||||||||||||||||
6655 | /*! | - | ||||||||||||||||||||||||||||||||||||
6656 | Takes keyboard input focus from the widget. | - | ||||||||||||||||||||||||||||||||||||
6657 | - | |||||||||||||||||||||||||||||||||||||
6658 | If the widget has active focus, a \l{focusOutEvent()}{focus out event} is sent to this widget to tell it that it has | - | ||||||||||||||||||||||||||||||||||||
6659 | lost the focus. | - | ||||||||||||||||||||||||||||||||||||
6660 | - | |||||||||||||||||||||||||||||||||||||
6661 | This widget must enable focus setting in order to get the keyboard | - | ||||||||||||||||||||||||||||||||||||
6662 | input focus, i.e. it must call setFocusPolicy(). | - | ||||||||||||||||||||||||||||||||||||
6663 | - | |||||||||||||||||||||||||||||||||||||
6664 | \sa hasFocus(), setFocus(), focusInEvent(), focusOutEvent(), | - | ||||||||||||||||||||||||||||||||||||
6665 | setFocusPolicy(), QApplication::focusWidget() | - | ||||||||||||||||||||||||||||||||||||
6666 | */ | - | ||||||||||||||||||||||||||||||||||||
6667 | - | |||||||||||||||||||||||||||||||||||||
6668 | void QWidget::clearFocus() | - | ||||||||||||||||||||||||||||||||||||
6669 | { | - | ||||||||||||||||||||||||||||||||||||
6670 | if (hasFocus()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6671 | if (testAttribute(Qt::WA_InputMethodEnabled))
| 0 | ||||||||||||||||||||||||||||||||||||
6672 | QGuiApplication::inputMethod()->commit(); never executed: QGuiApplication::inputMethod()->commit(); | 0 | ||||||||||||||||||||||||||||||||||||
6673 | - | |||||||||||||||||||||||||||||||||||||
6674 | QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); | - | ||||||||||||||||||||||||||||||||||||
6675 | QApplication::sendEvent(this, &focusAboutToChange); | - | ||||||||||||||||||||||||||||||||||||
6676 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6677 | - | |||||||||||||||||||||||||||||||||||||
6678 | QWidget *w = this; | - | ||||||||||||||||||||||||||||||||||||
6679 | while (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
6680 | // Just like setFocus(), we update (clear) the focus_child of our parents | - | ||||||||||||||||||||||||||||||||||||
6681 | if (w->d_func()->focus_child == this)
| 0 | ||||||||||||||||||||||||||||||||||||
6682 | w->d_func()->focus_child = 0; never executed: w->d_func()->focus_child = 0; | 0 | ||||||||||||||||||||||||||||||||||||
6683 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
6684 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6685 | // Since focus_child is the basis for the top level QWidgetWindow's focusObject() | - | ||||||||||||||||||||||||||||||||||||
6686 | // we need to report this change to the rest of Qt, but we match setFocus() and | - | ||||||||||||||||||||||||||||||||||||
6687 | // do it at the end of the function. | - | ||||||||||||||||||||||||||||||||||||
6688 | - | |||||||||||||||||||||||||||||||||||||
6689 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6690 | QWExtra *topData = d_func()->extra; | - | ||||||||||||||||||||||||||||||||||||
6691 | if (topData && topData->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
6692 | topData->proxyWidget->clearFocus(); never executed: topData->proxyWidget->clearFocus(); | 0 | ||||||||||||||||||||||||||||||||||||
6693 | #endif | - | ||||||||||||||||||||||||||||||||||||
6694 | - | |||||||||||||||||||||||||||||||||||||
6695 | if (hasFocus()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6696 | // Update proxy state | - | ||||||||||||||||||||||||||||||||||||
6697 | QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason); | - | ||||||||||||||||||||||||||||||||||||
6698 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
6699 | if (!(windowType() == Qt::Popup) && GetFocus() == internalWinId()) | - | ||||||||||||||||||||||||||||||||||||
6700 | SetFocus(0); | - | ||||||||||||||||||||||||||||||||||||
6701 | else | - | ||||||||||||||||||||||||||||||||||||
6702 | #endif | - | ||||||||||||||||||||||||||||||||||||
6703 | { | - | ||||||||||||||||||||||||||||||||||||
6704 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
6705 | QAccessibleEvent event(this, QAccessible::Focus); | - | ||||||||||||||||||||||||||||||||||||
6706 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
6707 | #endif | - | ||||||||||||||||||||||||||||||||||||
6708 | } | - | ||||||||||||||||||||||||||||||||||||
6709 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6710 | - | |||||||||||||||||||||||||||||||||||||
6711 | // Since we've unconditionally cleared the focus_child of our parents, we need | - | ||||||||||||||||||||||||||||||||||||
6712 | // to report this to the rest of Qt. Note that the focus_child is not the same | - | ||||||||||||||||||||||||||||||||||||
6713 | // thing as the application's focusWidget, which is why this piece of code is | - | ||||||||||||||||||||||||||||||||||||
6714 | // not inside the hasFocus() block above. | - | ||||||||||||||||||||||||||||||||||||
6715 | if (QTLWExtra *extra = window()->d_func()->maybeTopData()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6716 | if (extra->window)
| 0 | ||||||||||||||||||||||||||||||||||||
6717 | emit extra->window->focusObjectChanged(extra->window->focusObject()); never executed: extra->window->focusObjectChanged(extra->window->focusObject()); | 0 | ||||||||||||||||||||||||||||||||||||
6718 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6719 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6720 | - | |||||||||||||||||||||||||||||||||||||
6721 | - | |||||||||||||||||||||||||||||||||||||
6722 | /*! | - | ||||||||||||||||||||||||||||||||||||
6723 | \fn bool QWidget::focusNextChild() | - | ||||||||||||||||||||||||||||||||||||
6724 | - | |||||||||||||||||||||||||||||||||||||
6725 | Finds a new widget to give the keyboard focus to, as appropriate | - | ||||||||||||||||||||||||||||||||||||
6726 | for \uicontrol Tab, and returns \c true if it can find a new widget, or | - | ||||||||||||||||||||||||||||||||||||
6727 | false if it can't. | - | ||||||||||||||||||||||||||||||||||||
6728 | - | |||||||||||||||||||||||||||||||||||||
6729 | \sa focusPreviousChild() | - | ||||||||||||||||||||||||||||||||||||
6730 | */ | - | ||||||||||||||||||||||||||||||||||||
6731 | - | |||||||||||||||||||||||||||||||||||||
6732 | /*! | - | ||||||||||||||||||||||||||||||||||||
6733 | \fn bool QWidget::focusPreviousChild() | - | ||||||||||||||||||||||||||||||||||||
6734 | - | |||||||||||||||||||||||||||||||||||||
6735 | Finds a new widget to give the keyboard focus to, as appropriate | - | ||||||||||||||||||||||||||||||||||||
6736 | for \uicontrol Shift+Tab, and returns \c true if it can find a new widget, | - | ||||||||||||||||||||||||||||||||||||
6737 | or false if it can't. | - | ||||||||||||||||||||||||||||||||||||
6738 | - | |||||||||||||||||||||||||||||||||||||
6739 | \sa focusNextChild() | - | ||||||||||||||||||||||||||||||||||||
6740 | */ | - | ||||||||||||||||||||||||||||||||||||
6741 | - | |||||||||||||||||||||||||||||||||||||
6742 | /*! | - | ||||||||||||||||||||||||||||||||||||
6743 | Finds a new widget to give the keyboard focus to, as appropriate | - | ||||||||||||||||||||||||||||||||||||
6744 | for Tab and Shift+Tab, and returns \c true if it can find a new | - | ||||||||||||||||||||||||||||||||||||
6745 | widget, or false if it can't. | - | ||||||||||||||||||||||||||||||||||||
6746 | - | |||||||||||||||||||||||||||||||||||||
6747 | If \a next is true, this function searches forward, if \a next | - | ||||||||||||||||||||||||||||||||||||
6748 | is false, it searches backward. | - | ||||||||||||||||||||||||||||||||||||
6749 | - | |||||||||||||||||||||||||||||||||||||
6750 | Sometimes, you will want to reimplement this function. For | - | ||||||||||||||||||||||||||||||||||||
6751 | example, a web browser might reimplement it to move its "current | - | ||||||||||||||||||||||||||||||||||||
6752 | active link" forward or backward, and call | - | ||||||||||||||||||||||||||||||||||||
6753 | focusNextPrevChild() only when it reaches the last or | - | ||||||||||||||||||||||||||||||||||||
6754 | first link on the "page". | - | ||||||||||||||||||||||||||||||||||||
6755 | - | |||||||||||||||||||||||||||||||||||||
6756 | Child widgets call focusNextPrevChild() on their parent widgets, | - | ||||||||||||||||||||||||||||||||||||
6757 | but only the window that contains the child widgets decides where | - | ||||||||||||||||||||||||||||||||||||
6758 | to redirect focus. By reimplementing this function for an object, | - | ||||||||||||||||||||||||||||||||||||
6759 | you thus gain control of focus traversal for all child widgets. | - | ||||||||||||||||||||||||||||||||||||
6760 | - | |||||||||||||||||||||||||||||||||||||
6761 | \sa focusNextChild(), focusPreviousChild() | - | ||||||||||||||||||||||||||||||||||||
6762 | */ | - | ||||||||||||||||||||||||||||||||||||
6763 | - | |||||||||||||||||||||||||||||||||||||
6764 | bool QWidget::focusNextPrevChild(bool next) | - | ||||||||||||||||||||||||||||||||||||
6765 | { | - | ||||||||||||||||||||||||||||||||||||
6766 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6767 | QWidget* p = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
6768 | bool isSubWindow = (windowType() == Qt::SubWindow); | - | ||||||||||||||||||||||||||||||||||||
6769 | if (!isWindow() && !isSubWindow && p)
| 0 | ||||||||||||||||||||||||||||||||||||
6770 | return p->focusNextPrevChild(next); never executed: return p->focusNextPrevChild(next); | 0 | ||||||||||||||||||||||||||||||||||||
6771 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6772 | if (d->extra && d->extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
6773 | return d->extra->proxyWidget->focusNextPrevChild(next); never executed: return d->extra->proxyWidget->focusNextPrevChild(next); | 0 | ||||||||||||||||||||||||||||||||||||
6774 | #endif | - | ||||||||||||||||||||||||||||||||||||
6775 | - | |||||||||||||||||||||||||||||||||||||
6776 | bool wrappingOccurred = false; | - | ||||||||||||||||||||||||||||||||||||
6777 | QWidget *w = QApplicationPrivate::focusNextPrevChild_helper(this, next, | - | ||||||||||||||||||||||||||||||||||||
6778 | &wrappingOccurred); | - | ||||||||||||||||||||||||||||||||||||
6779 | if (!w) return false; never executed: return false;
| 0 | ||||||||||||||||||||||||||||||||||||
6780 | - | |||||||||||||||||||||||||||||||||||||
6781 | Qt::FocusReason reason = next ? Qt::TabFocusReason : Qt::BacktabFocusReason;
| 0 | ||||||||||||||||||||||||||||||||||||
6782 | - | |||||||||||||||||||||||||||||||||||||
6783 | /* If we are about to wrap the focus chain, give the platform | - | ||||||||||||||||||||||||||||||||||||
6784 | * implementation a chance to alter the wrapping behavior. This is | - | ||||||||||||||||||||||||||||||||||||
6785 | * especially needed when the window is embedded in a window created by | - | ||||||||||||||||||||||||||||||||||||
6786 | * another process. | - | ||||||||||||||||||||||||||||||||||||
6787 | */ | - | ||||||||||||||||||||||||||||||||||||
6788 | if (wrappingOccurred) {
| 0 | ||||||||||||||||||||||||||||||||||||
6789 | QWindow *window = windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
6790 | if (window != 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
6791 | QWindowPrivate *winp = qt_window_private(window); | - | ||||||||||||||||||||||||||||||||||||
6792 | - | |||||||||||||||||||||||||||||||||||||
6793 | if (winp->platformWindow != 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
6794 | QFocusEvent event(QEvent::FocusIn, reason); | - | ||||||||||||||||||||||||||||||||||||
6795 | event.ignore(); | - | ||||||||||||||||||||||||||||||||||||
6796 | winp->platformWindow->windowEvent(&event); | - | ||||||||||||||||||||||||||||||||||||
6797 | if (event.isAccepted()) return true; never executed: return true;
| 0 | ||||||||||||||||||||||||||||||||||||
6798 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6799 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6800 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6801 | - | |||||||||||||||||||||||||||||||||||||
6802 | w->setFocus(reason); | - | ||||||||||||||||||||||||||||||||||||
6803 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
6804 | } | - | ||||||||||||||||||||||||||||||||||||
6805 | - | |||||||||||||||||||||||||||||||||||||
6806 | /*! | - | ||||||||||||||||||||||||||||||||||||
6807 | Returns the last child of this widget that setFocus had been | - | ||||||||||||||||||||||||||||||||||||
6808 | called on. For top level widgets this is the widget that will get | - | ||||||||||||||||||||||||||||||||||||
6809 | focus in case this window gets activated | - | ||||||||||||||||||||||||||||||||||||
6810 | - | |||||||||||||||||||||||||||||||||||||
6811 | This is not the same as QApplication::focusWidget(), which returns | - | ||||||||||||||||||||||||||||||||||||
6812 | the focus widget in the currently active window. | - | ||||||||||||||||||||||||||||||||||||
6813 | */ | - | ||||||||||||||||||||||||||||||||||||
6814 | - | |||||||||||||||||||||||||||||||||||||
6815 | QWidget *QWidget::focusWidget() const | - | ||||||||||||||||||||||||||||||||||||
6816 | { | - | ||||||||||||||||||||||||||||||||||||
6817 | return const_cast<QWidget *>(d_func()->focus_child); never executed: return const_cast<QWidget *>(d_func()->focus_child); | 0 | ||||||||||||||||||||||||||||||||||||
6818 | } | - | ||||||||||||||||||||||||||||||||||||
6819 | - | |||||||||||||||||||||||||||||||||||||
6820 | /*! | - | ||||||||||||||||||||||||||||||||||||
6821 | Returns the next widget in this widget's focus chain. | - | ||||||||||||||||||||||||||||||||||||
6822 | - | |||||||||||||||||||||||||||||||||||||
6823 | \sa previousInFocusChain() | - | ||||||||||||||||||||||||||||||||||||
6824 | */ | - | ||||||||||||||||||||||||||||||||||||
6825 | QWidget *QWidget::nextInFocusChain() const | - | ||||||||||||||||||||||||||||||||||||
6826 | { | - | ||||||||||||||||||||||||||||||||||||
6827 | return const_cast<QWidget *>(d_func()->focus_next); never executed: return const_cast<QWidget *>(d_func()->focus_next); | 0 | ||||||||||||||||||||||||||||||||||||
6828 | } | - | ||||||||||||||||||||||||||||||||||||
6829 | - | |||||||||||||||||||||||||||||||||||||
6830 | /*! | - | ||||||||||||||||||||||||||||||||||||
6831 | \brief The previousInFocusChain function returns the previous | - | ||||||||||||||||||||||||||||||||||||
6832 | widget in this widget's focus chain. | - | ||||||||||||||||||||||||||||||||||||
6833 | - | |||||||||||||||||||||||||||||||||||||
6834 | \sa nextInFocusChain() | - | ||||||||||||||||||||||||||||||||||||
6835 | - | |||||||||||||||||||||||||||||||||||||
6836 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
6837 | */ | - | ||||||||||||||||||||||||||||||||||||
6838 | QWidget *QWidget::previousInFocusChain() const | - | ||||||||||||||||||||||||||||||||||||
6839 | { | - | ||||||||||||||||||||||||||||||||||||
6840 | return const_cast<QWidget *>(d_func()->focus_prev); never executed: return const_cast<QWidget *>(d_func()->focus_prev); | 0 | ||||||||||||||||||||||||||||||||||||
6841 | } | - | ||||||||||||||||||||||||||||||||||||
6842 | - | |||||||||||||||||||||||||||||||||||||
6843 | /*! | - | ||||||||||||||||||||||||||||||||||||
6844 | \property QWidget::isActiveWindow | - | ||||||||||||||||||||||||||||||||||||
6845 | \brief whether this widget's window is the active window | - | ||||||||||||||||||||||||||||||||||||
6846 | - | |||||||||||||||||||||||||||||||||||||
6847 | The active window is the window that contains the widget that has | - | ||||||||||||||||||||||||||||||||||||
6848 | keyboard focus (The window may still have focus if it has no | - | ||||||||||||||||||||||||||||||||||||
6849 | widgets or none of its widgets accepts keyboard focus). | - | ||||||||||||||||||||||||||||||||||||
6850 | - | |||||||||||||||||||||||||||||||||||||
6851 | When popup windows are visible, this property is \c true for both the | - | ||||||||||||||||||||||||||||||||||||
6852 | active window \e and for the popup. | - | ||||||||||||||||||||||||||||||||||||
6853 | - | |||||||||||||||||||||||||||||||||||||
6854 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
6855 | - | |||||||||||||||||||||||||||||||||||||
6856 | \sa activateWindow(), QApplication::activeWindow() | - | ||||||||||||||||||||||||||||||||||||
6857 | */ | - | ||||||||||||||||||||||||||||||||||||
6858 | bool QWidget::isActiveWindow() const | - | ||||||||||||||||||||||||||||||||||||
6859 | { | - | ||||||||||||||||||||||||||||||||||||
6860 | QWidget *tlw = window(); | - | ||||||||||||||||||||||||||||||||||||
6861 | if(tlw == QApplication::activeWindow() || (isVisible() && (tlw->windowType() == Qt::Popup)))
| 0 | ||||||||||||||||||||||||||||||||||||
6862 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
6863 | - | |||||||||||||||||||||||||||||||||||||
6864 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6865 | if (QWExtra *tlwExtra = tlw->d_func()->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
6866 | if (isVisible() && tlwExtra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
6867 | return tlwExtra->proxyWidget->isActiveWindow(); never executed: return tlwExtra->proxyWidget->isActiveWindow(); | 0 | ||||||||||||||||||||||||||||||||||||
6868 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6869 | #endif | - | ||||||||||||||||||||||||||||||||||||
6870 | - | |||||||||||||||||||||||||||||||||||||
6871 | if(style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, this)) {
| 0 | ||||||||||||||||||||||||||||||||||||
6872 | if(tlw->windowType() == Qt::Tool &&
| 0 | ||||||||||||||||||||||||||||||||||||
6873 | !tlw->isModal() &&
| 0 | ||||||||||||||||||||||||||||||||||||
6874 | (!tlw->parentWidget() || tlw->parentWidget()->isActiveWindow()))
| 0 | ||||||||||||||||||||||||||||||||||||
6875 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
6876 | QWidget *w = QApplication::activeWindow(); | - | ||||||||||||||||||||||||||||||||||||
6877 | while(w && tlw->windowType() == Qt::Tool &&
| 0 | ||||||||||||||||||||||||||||||||||||
6878 | !w->isModal() && w->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6879 | w = w->parentWidget()->window(); | - | ||||||||||||||||||||||||||||||||||||
6880 | if(w == tlw)
| 0 | ||||||||||||||||||||||||||||||||||||
6881 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
6882 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6883 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6884 | - | |||||||||||||||||||||||||||||||||||||
6885 | // Check for an active window container | - | ||||||||||||||||||||||||||||||||||||
6886 | if (QWindow *ww = QGuiApplication::focusWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6887 | while (ww) {
| 0 | ||||||||||||||||||||||||||||||||||||
6888 | QWidgetWindow *qww = qobject_cast<QWidgetWindow *>(ww); | - | ||||||||||||||||||||||||||||||||||||
6889 | QWindowContainer *qwc = qww ? qobject_cast<QWindowContainer *>(qww->widget()) : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
6890 | if (qwc && qwc->topLevelWidget() == tlw)
| 0 | ||||||||||||||||||||||||||||||||||||
6891 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
6892 | ww = ww->parent(); | - | ||||||||||||||||||||||||||||||||||||
6893 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6894 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6895 | - | |||||||||||||||||||||||||||||||||||||
6896 | // Check if platform adaptation thinks the window is active. This is necessary for | - | ||||||||||||||||||||||||||||||||||||
6897 | // example in case of ActiveQt servers that are embedded into another application. | - | ||||||||||||||||||||||||||||||||||||
6898 | // Those are separate processes that are not part of the parent application Qt window/widget | - | ||||||||||||||||||||||||||||||||||||
6899 | // hierarchy, so they need to rely on native methods to determine if they are part of the | - | ||||||||||||||||||||||||||||||||||||
6900 | // active window. | - | ||||||||||||||||||||||||||||||||||||
6901 | if (const QWindow *w = tlw->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6902 | if (w->handle())
| 0 | ||||||||||||||||||||||||||||||||||||
6903 | return w->handle()->isActive(); never executed: return w->handle()->isActive(); | 0 | ||||||||||||||||||||||||||||||||||||
6904 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6905 | - | |||||||||||||||||||||||||||||||||||||
6906 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
6907 | } | - | ||||||||||||||||||||||||||||||||||||
6908 | - | |||||||||||||||||||||||||||||||||||||
6909 | /*! | - | ||||||||||||||||||||||||||||||||||||
6910 | Puts the \a second widget after the \a first widget in the focus order. | - | ||||||||||||||||||||||||||||||||||||
6911 | - | |||||||||||||||||||||||||||||||||||||
6912 | Note that since the tab order of the \a second widget is changed, you | - | ||||||||||||||||||||||||||||||||||||
6913 | should order a chain like this: | - | ||||||||||||||||||||||||||||||||||||
6914 | - | |||||||||||||||||||||||||||||||||||||
6915 | \snippet code/src_gui_kernel_qwidget.cpp 9 | - | ||||||||||||||||||||||||||||||||||||
6916 | - | |||||||||||||||||||||||||||||||||||||
6917 | \e not like this: | - | ||||||||||||||||||||||||||||||||||||
6918 | - | |||||||||||||||||||||||||||||||||||||
6919 | \snippet code/src_gui_kernel_qwidget.cpp 10 | - | ||||||||||||||||||||||||||||||||||||
6920 | - | |||||||||||||||||||||||||||||||||||||
6921 | If \a first or \a second has a focus proxy, setTabOrder() | - | ||||||||||||||||||||||||||||||||||||
6922 | correctly substitutes the proxy. | - | ||||||||||||||||||||||||||||||||||||
6923 | - | |||||||||||||||||||||||||||||||||||||
6924 | \sa setFocusPolicy(), setFocusProxy(), {Keyboard Focus in Widgets} | - | ||||||||||||||||||||||||||||||||||||
6925 | */ | - | ||||||||||||||||||||||||||||||||||||
6926 | void QWidget::setTabOrder(QWidget* first, QWidget *second) | - | ||||||||||||||||||||||||||||||||||||
6927 | { | - | ||||||||||||||||||||||||||||||||||||
6928 | if (!first || !second || first->focusPolicy() == Qt::NoFocus || second->focusPolicy() == Qt::NoFocus)
| 0 | ||||||||||||||||||||||||||||||||||||
6929 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6930 | - | |||||||||||||||||||||||||||||||||||||
6931 | if (Q_UNLIKELY(first->window() != second->window())) {
| 0 | ||||||||||||||||||||||||||||||||||||
6932 | qWarning("QWidget::setTabOrder: 'first' and 'second' must be in the same window"); | - | ||||||||||||||||||||||||||||||||||||
6933 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6934 | } | - | ||||||||||||||||||||||||||||||||||||
6935 | - | |||||||||||||||||||||||||||||||||||||
6936 | QWidget *fp = first->focusProxy(); | - | ||||||||||||||||||||||||||||||||||||
6937 | if (fp) {
| 0 | ||||||||||||||||||||||||||||||||||||
6938 | // If first is redirected, set first to the last child of first | - | ||||||||||||||||||||||||||||||||||||
6939 | // that can take keyboard focus so that second is inserted after | - | ||||||||||||||||||||||||||||||||||||
6940 | // that last child, and the focus order within first is (more | - | ||||||||||||||||||||||||||||||||||||
6941 | // likely to be) preserved. | - | ||||||||||||||||||||||||||||||||||||
6942 | QList<QWidget *> l = first->findChildren<QWidget *>(); | - | ||||||||||||||||||||||||||||||||||||
6943 | for (int i = l.size()-1; i >= 0; --i) {
| 0 | ||||||||||||||||||||||||||||||||||||
6944 | QWidget * next = l.at(i); | - | ||||||||||||||||||||||||||||||||||||
6945 | if (next->window() == fp->window()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6946 | fp = next; | - | ||||||||||||||||||||||||||||||||||||
6947 | if (fp->focusPolicy() != Qt::NoFocus)
| 0 | ||||||||||||||||||||||||||||||||||||
6948 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
6949 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6950 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6951 | first = fp; | - | ||||||||||||||||||||||||||||||||||||
6952 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6953 | - | |||||||||||||||||||||||||||||||||||||
6954 | if (fp == second)
| 0 | ||||||||||||||||||||||||||||||||||||
6955 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6956 | - | |||||||||||||||||||||||||||||||||||||
6957 | if (QWidget *sp = second->focusProxy())
| 0 | ||||||||||||||||||||||||||||||||||||
6958 | second = sp; never executed: second = sp; | 0 | ||||||||||||||||||||||||||||||||||||
6959 | - | |||||||||||||||||||||||||||||||||||||
6960 | // QWidget *fp = first->d_func()->focus_prev; | - | ||||||||||||||||||||||||||||||||||||
6961 | QWidget *fn = first->d_func()->focus_next; | - | ||||||||||||||||||||||||||||||||||||
6962 | - | |||||||||||||||||||||||||||||||||||||
6963 | if (fn == second || first == second)
| 0 | ||||||||||||||||||||||||||||||||||||
6964 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6965 | - | |||||||||||||||||||||||||||||||||||||
6966 | QWidget *sp = second->d_func()->focus_prev; | - | ||||||||||||||||||||||||||||||||||||
6967 | QWidget *sn = second->d_func()->focus_next; | - | ||||||||||||||||||||||||||||||||||||
6968 | - | |||||||||||||||||||||||||||||||||||||
6969 | fn->d_func()->focus_prev = second; | - | ||||||||||||||||||||||||||||||||||||
6970 | first->d_func()->focus_next = second; | - | ||||||||||||||||||||||||||||||||||||
6971 | - | |||||||||||||||||||||||||||||||||||||
6972 | second->d_func()->focus_next = fn; | - | ||||||||||||||||||||||||||||||||||||
6973 | second->d_func()->focus_prev = first; | - | ||||||||||||||||||||||||||||||||||||
6974 | - | |||||||||||||||||||||||||||||||||||||
6975 | sp->d_func()->focus_next = sn; | - | ||||||||||||||||||||||||||||||||||||
6976 | sn->d_func()->focus_prev = sp; | - | ||||||||||||||||||||||||||||||||||||
6977 | - | |||||||||||||||||||||||||||||||||||||
6978 | - | |||||||||||||||||||||||||||||||||||||
6979 | Q_ASSERT(first->d_func()->focus_next->d_func()->focus_prev == first); | - | ||||||||||||||||||||||||||||||||||||
6980 | Q_ASSERT(first->d_func()->focus_prev->d_func()->focus_next == first); | - | ||||||||||||||||||||||||||||||||||||
6981 | - | |||||||||||||||||||||||||||||||||||||
6982 | Q_ASSERT(second->d_func()->focus_next->d_func()->focus_prev == second); | - | ||||||||||||||||||||||||||||||||||||
6983 | Q_ASSERT(second->d_func()->focus_prev->d_func()->focus_next == second); | - | ||||||||||||||||||||||||||||||||||||
6984 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6985 | - | |||||||||||||||||||||||||||||||||||||
6986 | /*!\internal | - | ||||||||||||||||||||||||||||||||||||
6987 | - | |||||||||||||||||||||||||||||||||||||
6988 | Moves the relevant subwidgets of this widget from the \a oldtlw's | - | ||||||||||||||||||||||||||||||||||||
6989 | tab chain to that of the new parent, if there's anything to move and | - | ||||||||||||||||||||||||||||||||||||
6990 | we're really moving | - | ||||||||||||||||||||||||||||||||||||
6991 | - | |||||||||||||||||||||||||||||||||||||
6992 | This function is called from QWidget::reparent() *after* the widget | - | ||||||||||||||||||||||||||||||||||||
6993 | has been reparented. | - | ||||||||||||||||||||||||||||||||||||
6994 | - | |||||||||||||||||||||||||||||||||||||
6995 | \sa reparent() | - | ||||||||||||||||||||||||||||||||||||
6996 | */ | - | ||||||||||||||||||||||||||||||||||||
6997 | - | |||||||||||||||||||||||||||||||||||||
6998 | void QWidgetPrivate::reparentFocusWidgets(QWidget * oldtlw) | - | ||||||||||||||||||||||||||||||||||||
6999 | { | - | ||||||||||||||||||||||||||||||||||||
7000 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7001 | if (oldtlw == q->window())
| 0 | ||||||||||||||||||||||||||||||||||||
7002 | return; // nothing to do never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
7003 | - | |||||||||||||||||||||||||||||||||||||
7004 | if(focus_child)
| 0 | ||||||||||||||||||||||||||||||||||||
7005 | focus_child->clearFocus(); never executed: focus_child->clearFocus(); | 0 | ||||||||||||||||||||||||||||||||||||
7006 | - | |||||||||||||||||||||||||||||||||||||
7007 | // separate the focus chain into new (children of myself) and old (the rest) | - | ||||||||||||||||||||||||||||||||||||
7008 | QWidget *firstOld = 0; | - | ||||||||||||||||||||||||||||||||||||
7009 | //QWidget *firstNew = q; //invariant | - | ||||||||||||||||||||||||||||||||||||
7010 | QWidget *o = 0; // last in the old list | - | ||||||||||||||||||||||||||||||||||||
7011 | QWidget *n = q; // last in the new list | - | ||||||||||||||||||||||||||||||||||||
7012 | - | |||||||||||||||||||||||||||||||||||||
7013 | bool prevWasNew = true; | - | ||||||||||||||||||||||||||||||||||||
7014 | QWidget *w = focus_next; | - | ||||||||||||||||||||||||||||||||||||
7015 | - | |||||||||||||||||||||||||||||||||||||
7016 | //Note: for efficiency, we do not maintain the list invariant inside the loop | - | ||||||||||||||||||||||||||||||||||||
7017 | //we append items to the relevant list, and we optimize by not changing pointers | - | ||||||||||||||||||||||||||||||||||||
7018 | //when subsequent items are going into the same list. | - | ||||||||||||||||||||||||||||||||||||
7019 | while (w != q) {
| 0 | ||||||||||||||||||||||||||||||||||||
7020 | bool currentIsNew = q->isAncestorOf(w); | - | ||||||||||||||||||||||||||||||||||||
7021 | if (currentIsNew) {
| 0 | ||||||||||||||||||||||||||||||||||||
7022 | if (!prevWasNew) {
| 0 | ||||||||||||||||||||||||||||||||||||
7023 | //prev was old -- append to new list | - | ||||||||||||||||||||||||||||||||||||
7024 | n->d_func()->focus_next = w; | - | ||||||||||||||||||||||||||||||||||||
7025 | w->d_func()->focus_prev = n; | - | ||||||||||||||||||||||||||||||||||||
7026 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7027 | n = w; | - | ||||||||||||||||||||||||||||||||||||
7028 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7029 | if (prevWasNew) {
| 0 | ||||||||||||||||||||||||||||||||||||
7030 | //prev was new -- append to old list, if there is one | - | ||||||||||||||||||||||||||||||||||||
7031 | if (o) {
| 0 | ||||||||||||||||||||||||||||||||||||
7032 | o->d_func()->focus_next = w; | - | ||||||||||||||||||||||||||||||||||||
7033 | w->d_func()->focus_prev = o; | - | ||||||||||||||||||||||||||||||||||||
7034 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7035 | // "create" the old list | - | ||||||||||||||||||||||||||||||||||||
7036 | firstOld = w; | - | ||||||||||||||||||||||||||||||||||||
7037 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7038 | } | - | ||||||||||||||||||||||||||||||||||||
7039 | o = w; | - | ||||||||||||||||||||||||||||||||||||
7040 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7041 | w = w->d_func()->focus_next; | - | ||||||||||||||||||||||||||||||||||||
7042 | prevWasNew = currentIsNew; | - | ||||||||||||||||||||||||||||||||||||
7043 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7044 | - | |||||||||||||||||||||||||||||||||||||
7045 | //repair the old list: | - | ||||||||||||||||||||||||||||||||||||
7046 | if (firstOld) {
| 0 | ||||||||||||||||||||||||||||||||||||
7047 | o->d_func()->focus_next = firstOld; | - | ||||||||||||||||||||||||||||||||||||
7048 | firstOld->d_func()->focus_prev = o; | - | ||||||||||||||||||||||||||||||||||||
7049 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7050 | - | |||||||||||||||||||||||||||||||||||||
7051 | if (!q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7052 | QWidget *topLevel = q->window(); | - | ||||||||||||||||||||||||||||||||||||
7053 | //insert new chain into toplevel's chain | - | ||||||||||||||||||||||||||||||||||||
7054 | - | |||||||||||||||||||||||||||||||||||||
7055 | QWidget *prev = topLevel->d_func()->focus_prev; | - | ||||||||||||||||||||||||||||||||||||
7056 | - | |||||||||||||||||||||||||||||||||||||
7057 | topLevel->d_func()->focus_prev = n; | - | ||||||||||||||||||||||||||||||||||||
7058 | prev->d_func()->focus_next = q; | - | ||||||||||||||||||||||||||||||||||||
7059 | - | |||||||||||||||||||||||||||||||||||||
7060 | focus_prev = prev; | - | ||||||||||||||||||||||||||||||||||||
7061 | n->d_func()->focus_next = topLevel; | - | ||||||||||||||||||||||||||||||||||||
7062 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7063 | //repair the new list | - | ||||||||||||||||||||||||||||||||||||
7064 | n->d_func()->focus_next = q; | - | ||||||||||||||||||||||||||||||||||||
7065 | focus_prev = n; | - | ||||||||||||||||||||||||||||||||||||
7066 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7067 | - | |||||||||||||||||||||||||||||||||||||
7068 | } | - | ||||||||||||||||||||||||||||||||||||
7069 | - | |||||||||||||||||||||||||||||||||||||
7070 | /*!\internal | - | ||||||||||||||||||||||||||||||||||||
7071 | - | |||||||||||||||||||||||||||||||||||||
7072 | Measures the shortest distance from a point to a rect. | - | ||||||||||||||||||||||||||||||||||||
7073 | - | |||||||||||||||||||||||||||||||||||||
7074 | This function is called from QDesktopwidget::screen(QPoint) to find the | - | ||||||||||||||||||||||||||||||||||||
7075 | closest screen for a point. | - | ||||||||||||||||||||||||||||||||||||
7076 | In directional KeypadNavigation, it is called to find the closest | - | ||||||||||||||||||||||||||||||||||||
7077 | widget to the current focus widget center. | - | ||||||||||||||||||||||||||||||||||||
7078 | */ | - | ||||||||||||||||||||||||||||||||||||
7079 | int QWidgetPrivate::pointToRect(const QPoint &p, const QRect &r) | - | ||||||||||||||||||||||||||||||||||||
7080 | { | - | ||||||||||||||||||||||||||||||||||||
7081 | int dx = 0; | - | ||||||||||||||||||||||||||||||||||||
7082 | int dy = 0; | - | ||||||||||||||||||||||||||||||||||||
7083 | if (p.x() < r.left())
| 0 | ||||||||||||||||||||||||||||||||||||
7084 | dx = r.left() - p.x(); never executed: dx = r.left() - p.x(); | 0 | ||||||||||||||||||||||||||||||||||||
7085 | else if (p.x() > r.right())
| 0 | ||||||||||||||||||||||||||||||||||||
7086 | dx = p.x() - r.right(); never executed: dx = p.x() - r.right(); | 0 | ||||||||||||||||||||||||||||||||||||
7087 | if (p.y() < r.top())
| 0 | ||||||||||||||||||||||||||||||||||||
7088 | dy = r.top() - p.y(); never executed: dy = r.top() - p.y(); | 0 | ||||||||||||||||||||||||||||||||||||
7089 | else if (p.y() > r.bottom())
| 0 | ||||||||||||||||||||||||||||||||||||
7090 | dy = p.y() - r.bottom(); never executed: dy = p.y() - r.bottom(); | 0 | ||||||||||||||||||||||||||||||||||||
7091 | return dx + dy; never executed: return dx + dy; | 0 | ||||||||||||||||||||||||||||||||||||
7092 | } | - | ||||||||||||||||||||||||||||||||||||
7093 | - | |||||||||||||||||||||||||||||||||||||
7094 | /*! | - | ||||||||||||||||||||||||||||||||||||
7095 | \property QWidget::frameSize | - | ||||||||||||||||||||||||||||||||||||
7096 | \brief the size of the widget including any window frame | - | ||||||||||||||||||||||||||||||||||||
7097 | - | |||||||||||||||||||||||||||||||||||||
7098 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
7099 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
7100 | */ | - | ||||||||||||||||||||||||||||||||||||
7101 | QSize QWidget::frameSize() const | - | ||||||||||||||||||||||||||||||||||||
7102 | { | - | ||||||||||||||||||||||||||||||||||||
7103 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
7104 | if (isWindow() && !(windowType() == Qt::Popup)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7105 | QRect fs = d->frameStrut(); | - | ||||||||||||||||||||||||||||||||||||
7106 | return QSize(data->crect.width() + fs.left() + fs.right(), never executed: return QSize(data->crect.width() + fs.left() + fs.right(), data->crect.height() + fs.top() + fs.bottom()); | 0 | ||||||||||||||||||||||||||||||||||||
7107 | data->crect.height() + fs.top() + fs.bottom()); never executed: return QSize(data->crect.width() + fs.left() + fs.right(), data->crect.height() + fs.top() + fs.bottom()); | 0 | ||||||||||||||||||||||||||||||||||||
7108 | } | - | ||||||||||||||||||||||||||||||||||||
7109 | return data->crect.size(); never executed: return data->crect.size(); | 0 | ||||||||||||||||||||||||||||||||||||
7110 | } | - | ||||||||||||||||||||||||||||||||||||
7111 | - | |||||||||||||||||||||||||||||||||||||
7112 | /*! \fn void QWidget::move(int x, int y) | - | ||||||||||||||||||||||||||||||||||||
7113 | - | |||||||||||||||||||||||||||||||||||||
7114 | \overload | - | ||||||||||||||||||||||||||||||||||||
7115 | - | |||||||||||||||||||||||||||||||||||||
7116 | This corresponds to move(QPoint(\a x, \a y)). | - | ||||||||||||||||||||||||||||||||||||
7117 | */ | - | ||||||||||||||||||||||||||||||||||||
7118 | - | |||||||||||||||||||||||||||||||||||||
7119 | void QWidget::move(const QPoint &p) | - | ||||||||||||||||||||||||||||||||||||
7120 | { | - | ||||||||||||||||||||||||||||||||||||
7121 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7122 | setAttribute(Qt::WA_Moved); | - | ||||||||||||||||||||||||||||||||||||
7123 | if (testAttribute(Qt::WA_WState_Created)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7124 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7125 | d->topData()->posIncludesFrame = false; never executed: d->topData()->posIncludesFrame = false; | 0 | ||||||||||||||||||||||||||||||||||||
7126 | d->setGeometry_sys(p.x() + geometry().x() - QWidget::x(), | - | ||||||||||||||||||||||||||||||||||||
7127 | p.y() + geometry().y() - QWidget::y(), | - | ||||||||||||||||||||||||||||||||||||
7128 | width(), height(), true); | - | ||||||||||||||||||||||||||||||||||||
7129 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
7130 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7131 | // no frame yet: see also QWidgetPrivate::fixPosIncludesFrame(), QWindowPrivate::PositionPolicy. | - | ||||||||||||||||||||||||||||||||||||
7132 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7133 | d->topData()->posIncludesFrame = true; never executed: d->topData()->posIncludesFrame = true; | 0 | ||||||||||||||||||||||||||||||||||||
7134 | data->crect.moveTopLeft(p); // no frame yet | - | ||||||||||||||||||||||||||||||||||||
7135 | setAttribute(Qt::WA_PendingMoveEvent); | - | ||||||||||||||||||||||||||||||||||||
7136 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7137 | - | |||||||||||||||||||||||||||||||||||||
7138 | if (d->extra && d->extra->hasWindowContainer)
| 0 | ||||||||||||||||||||||||||||||||||||
7139 | QWindowContainer::parentWasMoved(this); never executed: QWindowContainer::parentWasMoved(this); | 0 | ||||||||||||||||||||||||||||||||||||
7140 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7141 | - | |||||||||||||||||||||||||||||||||||||
7142 | // move() was invoked with Qt::WA_WState_Created not set (frame geometry | - | ||||||||||||||||||||||||||||||||||||
7143 | // unknown), that is, crect has a position including the frame. | - | ||||||||||||||||||||||||||||||||||||
7144 | // If we can determine the frame strut, fix that and clear the flag. | - | ||||||||||||||||||||||||||||||||||||
7145 | void QWidgetPrivate::fixPosIncludesFrame() | - | ||||||||||||||||||||||||||||||||||||
7146 | { | - | ||||||||||||||||||||||||||||||||||||
7147 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7148 | if (QTLWExtra *te = maybeTopData()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7149 | if (te->posIncludesFrame) {
| 0 | ||||||||||||||||||||||||||||||||||||
7150 | // For Qt::WA_DontShowOnScreen, assume a frame of 0 (for | - | ||||||||||||||||||||||||||||||||||||
7151 | // example, in QGraphicsProxyWidget). | - | ||||||||||||||||||||||||||||||||||||
7152 | if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7153 | te->posIncludesFrame = 0; | - | ||||||||||||||||||||||||||||||||||||
7154 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7155 | if (q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7156 | updateFrameStrut(); | - | ||||||||||||||||||||||||||||||||||||
7157 | if (!q->data->fstrut_dirty) {
| 0 | ||||||||||||||||||||||||||||||||||||
7158 | data.crect.translate(te->frameStrut.x(), te->frameStrut.y()); | - | ||||||||||||||||||||||||||||||||||||
7159 | te->posIncludesFrame = 0; | - | ||||||||||||||||||||||||||||||||||||
7160 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7161 | } // windowHandle() never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7162 | } // !WA_DontShowOnScreen never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7163 | } // posIncludesFrame | - | ||||||||||||||||||||||||||||||||||||
7164 | } // QTLWExtra never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7165 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7166 | - | |||||||||||||||||||||||||||||||||||||
7167 | /*! \fn void QWidget::resize(int w, int h) | - | ||||||||||||||||||||||||||||||||||||
7168 | \overload | - | ||||||||||||||||||||||||||||||||||||
7169 | - | |||||||||||||||||||||||||||||||||||||
7170 | This corresponds to resize(QSize(\a w, \a h)). | - | ||||||||||||||||||||||||||||||||||||
7171 | */ | - | ||||||||||||||||||||||||||||||||||||
7172 | - | |||||||||||||||||||||||||||||||||||||
7173 | void QWidget::resize(const QSize &s) | - | ||||||||||||||||||||||||||||||||||||
7174 | { | - | ||||||||||||||||||||||||||||||||||||
7175 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7176 | setAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||||||||||||||
7177 | if (testAttribute(Qt::WA_WState_Created)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7178 | d->fixPosIncludesFrame(); | - | ||||||||||||||||||||||||||||||||||||
7179 | d->setGeometry_sys(geometry().x(), geometry().y(), s.width(), s.height(), false); | - | ||||||||||||||||||||||||||||||||||||
7180 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
7181 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7182 | data->crect.setSize(s.boundedTo(maximumSize()).expandedTo(minimumSize())); | - | ||||||||||||||||||||||||||||||||||||
7183 | setAttribute(Qt::WA_PendingResizeEvent); | - | ||||||||||||||||||||||||||||||||||||
7184 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7185 | } | - | ||||||||||||||||||||||||||||||||||||
7186 | - | |||||||||||||||||||||||||||||||||||||
7187 | void QWidget::setGeometry(const QRect &r) | - | ||||||||||||||||||||||||||||||||||||
7188 | { | - | ||||||||||||||||||||||||||||||||||||
7189 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7190 | setAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||||||||||||||
7191 | setAttribute(Qt::WA_Moved); | - | ||||||||||||||||||||||||||||||||||||
7192 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7193 | d->topData()->posIncludesFrame = 0; never executed: d->topData()->posIncludesFrame = 0; | 0 | ||||||||||||||||||||||||||||||||||||
7194 | if (testAttribute(Qt::WA_WState_Created)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7195 | d->setGeometry_sys(r.x(), r.y(), r.width(), r.height(), true); | - | ||||||||||||||||||||||||||||||||||||
7196 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
7197 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7198 | data->crect.setTopLeft(r.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
7199 | data->crect.setSize(r.size().boundedTo(maximumSize()).expandedTo(minimumSize())); | - | ||||||||||||||||||||||||||||||||||||
7200 | setAttribute(Qt::WA_PendingMoveEvent); | - | ||||||||||||||||||||||||||||||||||||
7201 | setAttribute(Qt::WA_PendingResizeEvent); | - | ||||||||||||||||||||||||||||||||||||
7202 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7203 | - | |||||||||||||||||||||||||||||||||||||
7204 | if (d->extra && d->extra->hasWindowContainer)
| 0 | ||||||||||||||||||||||||||||||||||||
7205 | QWindowContainer::parentWasMoved(this); never executed: QWindowContainer::parentWasMoved(this); | 0 | ||||||||||||||||||||||||||||||||||||
7206 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7207 | - | |||||||||||||||||||||||||||||||||||||
7208 | void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) | - | ||||||||||||||||||||||||||||||||||||
7209 | { | - | ||||||||||||||||||||||||||||||||||||
7210 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7211 | if (extra) { // any size restrictions?
| 0 | ||||||||||||||||||||||||||||||||||||
7212 | w = qMin(w,extra->maxw); | - | ||||||||||||||||||||||||||||||||||||
7213 | h = qMin(h,extra->maxh); | - | ||||||||||||||||||||||||||||||||||||
7214 | w = qMax(w,extra->minw); | - | ||||||||||||||||||||||||||||||||||||
7215 | h = qMax(h,extra->minh); | - | ||||||||||||||||||||||||||||||||||||
7216 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7217 | - | |||||||||||||||||||||||||||||||||||||
7218 | if (q->isWindow() && q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7219 | QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration(); | - | ||||||||||||||||||||||||||||||||||||
7220 | if (!integration->hasCapability(QPlatformIntegration::NonFullScreenWindows)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7221 | x = 0; | - | ||||||||||||||||||||||||||||||||||||
7222 | y = 0; | - | ||||||||||||||||||||||||||||||||||||
7223 | w = q->windowHandle()->width(); | - | ||||||||||||||||||||||||||||||||||||
7224 | h = q->windowHandle()->height(); | - | ||||||||||||||||||||||||||||||||||||
7225 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7226 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7227 | - | |||||||||||||||||||||||||||||||||||||
7228 | QPoint oldp = q->geometry().topLeft(); | - | ||||||||||||||||||||||||||||||||||||
7229 | QSize olds = q->size(); | - | ||||||||||||||||||||||||||||||||||||
7230 | QRect r(x, y, w, h); | - | ||||||||||||||||||||||||||||||||||||
7231 | - | |||||||||||||||||||||||||||||||||||||
7232 | bool isResize = olds != r.size(); | - | ||||||||||||||||||||||||||||||||||||
7233 | isMove = oldp != r.topLeft(); //### why do we have isMove as a parameter? | - | ||||||||||||||||||||||||||||||||||||
7234 | - | |||||||||||||||||||||||||||||||||||||
7235 | - | |||||||||||||||||||||||||||||||||||||
7236 | // We only care about stuff that changes the geometry, or may | - | ||||||||||||||||||||||||||||||||||||
7237 | // cause the window manager to change its state | - | ||||||||||||||||||||||||||||||||||||
7238 | if (r.size() == olds && oldp == r.topLeft())
| 0 | ||||||||||||||||||||||||||||||||||||
7239 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
7240 | - | |||||||||||||||||||||||||||||||||||||
7241 | if (!data.in_set_window_state) {
| 0 | ||||||||||||||||||||||||||||||||||||
7242 | q->data->window_state &= ~Qt::WindowMaximized; | - | ||||||||||||||||||||||||||||||||||||
7243 | q->data->window_state &= ~Qt::WindowFullScreen; | - | ||||||||||||||||||||||||||||||||||||
7244 | if (q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7245 | topData()->normalGeometry = QRect(0, 0, -1, -1); never executed: topData()->normalGeometry = QRect(0, 0, -1, -1); | 0 | ||||||||||||||||||||||||||||||||||||
7246 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7247 | - | |||||||||||||||||||||||||||||||||||||
7248 | QPoint oldPos = q->pos(); | - | ||||||||||||||||||||||||||||||||||||
7249 | data.crect = r; | - | ||||||||||||||||||||||||||||||||||||
7250 | - | |||||||||||||||||||||||||||||||||||||
7251 | bool needsShow = false; | - | ||||||||||||||||||||||||||||||||||||
7252 | - | |||||||||||||||||||||||||||||||||||||
7253 | if (q->isWindow() || q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7254 | if (!(data.window_state & Qt::WindowFullScreen) && (w == 0 || h == 0)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7255 | q->setAttribute(Qt::WA_OutsideWSRange, true); | - | ||||||||||||||||||||||||||||||||||||
7256 | if (q->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
7257 | hide_sys(); never executed: hide_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
7258 | data.crect = QRect(x, y, w, h); | - | ||||||||||||||||||||||||||||||||||||
7259 | } else if (q->testAttribute(Qt::WA_OutsideWSRange)) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
7260 | q->setAttribute(Qt::WA_OutsideWSRange, false); | - | ||||||||||||||||||||||||||||||||||||
7261 | needsShow = true; | - | ||||||||||||||||||||||||||||||||||||
7262 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7263 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7264 | - | |||||||||||||||||||||||||||||||||||||
7265 | if (q->isVisible()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7266 | if (!q->testAttribute(Qt::WA_DontShowOnScreen) && !q->testAttribute(Qt::WA_OutsideWSRange)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7267 | if (q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7268 | if (q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7269 | q->windowHandle()->setGeometry(q->geometry()); | - | ||||||||||||||||||||||||||||||||||||
7270 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7271 | QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint()); | - | ||||||||||||||||||||||||||||||||||||
7272 | q->windowHandle()->setGeometry(QRect(posInNativeParent,r.size())); | - | ||||||||||||||||||||||||||||||||||||
7273 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7274 | - | |||||||||||||||||||||||||||||||||||||
7275 | if (needsShow)
| 0 | ||||||||||||||||||||||||||||||||||||
7276 | show_sys(); never executed: show_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
7277 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7278 | - | |||||||||||||||||||||||||||||||||||||
7279 | if (!q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7280 | if (renderToTexture) {
| 0 | ||||||||||||||||||||||||||||||||||||
7281 | QRegion updateRegion(q->geometry()); | - | ||||||||||||||||||||||||||||||||||||
7282 | updateRegion += QRect(oldPos, olds); | - | ||||||||||||||||||||||||||||||||||||
7283 | q->parentWidget()->d_func()->invalidateBuffer(updateRegion); | - | ||||||||||||||||||||||||||||||||||||
7284 | } else if (isMove && !isResize) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
7285 | moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y()); | - | ||||||||||||||||||||||||||||||||||||
7286 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7287 | invalidateBuffer_resizeHelper(oldPos, olds); | - | ||||||||||||||||||||||||||||||||||||
7288 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7289 | } | - | ||||||||||||||||||||||||||||||||||||
7290 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7291 | - | |||||||||||||||||||||||||||||||||||||
7292 | if (isMove) {
| 0 | ||||||||||||||||||||||||||||||||||||
7293 | QMoveEvent e(q->pos(), oldPos); | - | ||||||||||||||||||||||||||||||||||||
7294 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
7295 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7296 | if (isResize) {
| 0 | ||||||||||||||||||||||||||||||||||||
7297 | QResizeEvent e(r.size(), olds); | - | ||||||||||||||||||||||||||||||||||||
7298 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
7299 | if (q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
7300 | q->update(); never executed: q->update(); | 0 | ||||||||||||||||||||||||||||||||||||
7301 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7302 | } else { // not visible never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7303 | if (isMove && q->pos() != oldPos)
| 0 | ||||||||||||||||||||||||||||||||||||
7304 | q->setAttribute(Qt::WA_PendingMoveEvent, true); never executed: q->setAttribute(Qt::WA_PendingMoveEvent, true); | 0 | ||||||||||||||||||||||||||||||||||||
7305 | if (isResize)
| 0 | ||||||||||||||||||||||||||||||||||||
7306 | q->setAttribute(Qt::WA_PendingResizeEvent, true); never executed: q->setAttribute(Qt::WA_PendingResizeEvent, true); | 0 | ||||||||||||||||||||||||||||||||||||
7307 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7308 | - | |||||||||||||||||||||||||||||||||||||
7309 | } | - | ||||||||||||||||||||||||||||||||||||
7310 | - | |||||||||||||||||||||||||||||||||||||
7311 | /*! | - | ||||||||||||||||||||||||||||||||||||
7312 | \since 4.2 | - | ||||||||||||||||||||||||||||||||||||
7313 | Saves the current geometry and state for top-level widgets. | - | ||||||||||||||||||||||||||||||||||||
7314 | - | |||||||||||||||||||||||||||||||||||||
7315 | To save the geometry when the window closes, you can | - | ||||||||||||||||||||||||||||||||||||
7316 | implement a close event like this: | - | ||||||||||||||||||||||||||||||||||||
7317 | - | |||||||||||||||||||||||||||||||||||||
7318 | \snippet code/src_gui_kernel_qwidget.cpp 11 | - | ||||||||||||||||||||||||||||||||||||
7319 | - | |||||||||||||||||||||||||||||||||||||
7320 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
7321 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
7322 | - | |||||||||||||||||||||||||||||||||||||
7323 | Use QMainWindow::saveState() to save the geometry and the state of | - | ||||||||||||||||||||||||||||||||||||
7324 | toolbars and dock widgets. | - | ||||||||||||||||||||||||||||||||||||
7325 | - | |||||||||||||||||||||||||||||||||||||
7326 | \sa restoreGeometry(), QMainWindow::saveState(), QMainWindow::restoreState() | - | ||||||||||||||||||||||||||||||||||||
7327 | */ | - | ||||||||||||||||||||||||||||||||||||
7328 | QByteArray QWidget::saveGeometry() const | - | ||||||||||||||||||||||||||||||||||||
7329 | { | - | ||||||||||||||||||||||||||||||||||||
7330 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
7331 | // We check if the window was maximized during this invocation. If so, we need to record the | - | ||||||||||||||||||||||||||||||||||||
7332 | // starting position as 0,0. | - | ||||||||||||||||||||||||||||||||||||
7333 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
7334 | QRect newFramePosition = frameGeometry(); | - | ||||||||||||||||||||||||||||||||||||
7335 | QRect newNormalPosition = normalGeometry(); | - | ||||||||||||||||||||||||||||||||||||
7336 | if(d->topData()->wasMaximized && !(windowState() & Qt::WindowMaximized)) { | - | ||||||||||||||||||||||||||||||||||||
7337 | // Change the starting position | - | ||||||||||||||||||||||||||||||||||||
7338 | newFramePosition.moveTo(0, 0); | - | ||||||||||||||||||||||||||||||||||||
7339 | newNormalPosition.moveTo(0, 0); | - | ||||||||||||||||||||||||||||||||||||
7340 | } | - | ||||||||||||||||||||||||||||||||||||
7341 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
7342 | QByteArray array; | - | ||||||||||||||||||||||||||||||||||||
7343 | QDataStream stream(&array, QIODevice::WriteOnly); | - | ||||||||||||||||||||||||||||||||||||
7344 | stream.setVersion(QDataStream::Qt_4_0); | - | ||||||||||||||||||||||||||||||||||||
7345 | const quint32 magicNumber = 0x1D9D0CB; | - | ||||||||||||||||||||||||||||||||||||
7346 | // Version history: | - | ||||||||||||||||||||||||||||||||||||
7347 | // - Qt 4.2 - 4.8.6, 5.0 - 5.3 : Version 1.0 | - | ||||||||||||||||||||||||||||||||||||
7348 | // - Qt 4.8.6 - today, 5.4 - today: Version 2.0, save screen width in addition to check for high DPI scaling. | - | ||||||||||||||||||||||||||||||||||||
7349 | quint16 majorVersion = 2; | - | ||||||||||||||||||||||||||||||||||||
7350 | quint16 minorVersion = 0; | - | ||||||||||||||||||||||||||||||||||||
7351 | const int screenNumber = QApplication::desktop()->screenNumber(this); | - | ||||||||||||||||||||||||||||||||||||
7352 | stream << magicNumber | - | ||||||||||||||||||||||||||||||||||||
7353 | << majorVersion | - | ||||||||||||||||||||||||||||||||||||
7354 | << minorVersion | - | ||||||||||||||||||||||||||||||||||||
7355 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
7356 | << newFramePosition | - | ||||||||||||||||||||||||||||||||||||
7357 | << newNormalPosition | - | ||||||||||||||||||||||||||||||||||||
7358 | #else | - | ||||||||||||||||||||||||||||||||||||
7359 | << frameGeometry() | - | ||||||||||||||||||||||||||||||||||||
7360 | << normalGeometry() | - | ||||||||||||||||||||||||||||||||||||
7361 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
7362 | << qint32(screenNumber) | - | ||||||||||||||||||||||||||||||||||||
7363 | << quint8(windowState() & Qt::WindowMaximized) | - | ||||||||||||||||||||||||||||||||||||
7364 | << quint8(windowState() & Qt::WindowFullScreen) | - | ||||||||||||||||||||||||||||||||||||
7365 | << qint32(QApplication::desktop()->screenGeometry(screenNumber).width()); // 1.1 onwards | - | ||||||||||||||||||||||||||||||||||||
7366 | return array; never executed: return array; | 0 | ||||||||||||||||||||||||||||||||||||
7367 | } | - | ||||||||||||||||||||||||||||||||||||
7368 | - | |||||||||||||||||||||||||||||||||||||
7369 | /*! | - | ||||||||||||||||||||||||||||||||||||
7370 | \since 4.2 | - | ||||||||||||||||||||||||||||||||||||
7371 | - | |||||||||||||||||||||||||||||||||||||
7372 | Restores the geometry and state of top-level widgets stored in the | - | ||||||||||||||||||||||||||||||||||||
7373 | byte array \a geometry. Returns \c true on success; otherwise | - | ||||||||||||||||||||||||||||||||||||
7374 | returns \c false. | - | ||||||||||||||||||||||||||||||||||||
7375 | - | |||||||||||||||||||||||||||||||||||||
7376 | If the restored geometry is off-screen, it will be modified to be | - | ||||||||||||||||||||||||||||||||||||
7377 | inside the available screen geometry. | - | ||||||||||||||||||||||||||||||||||||
7378 | - | |||||||||||||||||||||||||||||||||||||
7379 | To restore geometry saved using QSettings, you can use code like | - | ||||||||||||||||||||||||||||||||||||
7380 | this: | - | ||||||||||||||||||||||||||||||||||||
7381 | - | |||||||||||||||||||||||||||||||||||||
7382 | \snippet code/src_gui_kernel_qwidget.cpp 12 | - | ||||||||||||||||||||||||||||||||||||
7383 | - | |||||||||||||||||||||||||||||||||||||
7384 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
7385 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
7386 | - | |||||||||||||||||||||||||||||||||||||
7387 | Use QMainWindow::restoreState() to restore the geometry and the | - | ||||||||||||||||||||||||||||||||||||
7388 | state of toolbars and dock widgets. | - | ||||||||||||||||||||||||||||||||||||
7389 | - | |||||||||||||||||||||||||||||||||||||
7390 | \sa saveGeometry(), QSettings, QMainWindow::saveState(), QMainWindow::restoreState() | - | ||||||||||||||||||||||||||||||||||||
7391 | */ | - | ||||||||||||||||||||||||||||||||||||
7392 | bool QWidget::restoreGeometry(const QByteArray &geometry) | - | ||||||||||||||||||||||||||||||||||||
7393 | { | - | ||||||||||||||||||||||||||||||||||||
7394 | if (geometry.size() < 4)
| 0 | ||||||||||||||||||||||||||||||||||||
7395 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
7396 | QDataStream stream(geometry); | - | ||||||||||||||||||||||||||||||||||||
7397 | stream.setVersion(QDataStream::Qt_4_0); | - | ||||||||||||||||||||||||||||||||||||
7398 | - | |||||||||||||||||||||||||||||||||||||
7399 | const quint32 magicNumber = 0x1D9D0CB; | - | ||||||||||||||||||||||||||||||||||||
7400 | quint32 storedMagicNumber; | - | ||||||||||||||||||||||||||||||||||||
7401 | stream >> storedMagicNumber; | - | ||||||||||||||||||||||||||||||||||||
7402 | if (storedMagicNumber != magicNumber)
| 0 | ||||||||||||||||||||||||||||||||||||
7403 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
7404 | - | |||||||||||||||||||||||||||||||||||||
7405 | const quint16 currentMajorVersion = 2; | - | ||||||||||||||||||||||||||||||||||||
7406 | quint16 majorVersion = 0; | - | ||||||||||||||||||||||||||||||||||||
7407 | quint16 minorVersion = 0; | - | ||||||||||||||||||||||||||||||||||||
7408 | - | |||||||||||||||||||||||||||||||||||||
7409 | stream >> majorVersion >> minorVersion; | - | ||||||||||||||||||||||||||||||||||||
7410 | - | |||||||||||||||||||||||||||||||||||||
7411 | if (majorVersion > currentMajorVersion)
| 0 | ||||||||||||||||||||||||||||||||||||
7412 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
7413 | // (Allow all minor versions.) | - | ||||||||||||||||||||||||||||||||||||
7414 | - | |||||||||||||||||||||||||||||||||||||
7415 | QRect restoredFrameGeometry; | - | ||||||||||||||||||||||||||||||||||||
7416 | QRect restoredNormalGeometry; | - | ||||||||||||||||||||||||||||||||||||
7417 | qint32 restoredScreenNumber; | - | ||||||||||||||||||||||||||||||||||||
7418 | quint8 maximized; | - | ||||||||||||||||||||||||||||||||||||
7419 | quint8 fullScreen; | - | ||||||||||||||||||||||||||||||||||||
7420 | qint32 restoredScreenWidth = 0; | - | ||||||||||||||||||||||||||||||||||||
7421 | - | |||||||||||||||||||||||||||||||||||||
7422 | stream >> restoredFrameGeometry | - | ||||||||||||||||||||||||||||||||||||
7423 | >> restoredNormalGeometry | - | ||||||||||||||||||||||||||||||||||||
7424 | >> restoredScreenNumber | - | ||||||||||||||||||||||||||||||||||||
7425 | >> maximized | - | ||||||||||||||||||||||||||||||||||||
7426 | >> fullScreen; | - | ||||||||||||||||||||||||||||||||||||
7427 | - | |||||||||||||||||||||||||||||||||||||
7428 | if (majorVersion > 1)
| 0 | ||||||||||||||||||||||||||||||||||||
7429 | stream >> restoredScreenWidth; never executed: stream >> restoredScreenWidth; | 0 | ||||||||||||||||||||||||||||||||||||
7430 | - | |||||||||||||||||||||||||||||||||||||
7431 | const QDesktopWidget * const desktop = QApplication::desktop(); | - | ||||||||||||||||||||||||||||||||||||
7432 | if (restoredScreenNumber >= desktop->numScreens())
| 0 | ||||||||||||||||||||||||||||||||||||
7433 | restoredScreenNumber = desktop->primaryScreen(); never executed: restoredScreenNumber = desktop->primaryScreen(); | 0 | ||||||||||||||||||||||||||||||||||||
7434 | const qreal screenWidthF = qreal(desktop->screenGeometry(restoredScreenNumber).width()); | - | ||||||||||||||||||||||||||||||||||||
7435 | // Sanity check bailing out when large variations of screen sizes occur due to | - | ||||||||||||||||||||||||||||||||||||
7436 | // high DPI scaling or different levels of DPI awareness. | - | ||||||||||||||||||||||||||||||||||||
7437 | if (restoredScreenWidth) {
| 0 | ||||||||||||||||||||||||||||||||||||
7438 | const qreal factor = qreal(restoredScreenWidth) / screenWidthF; | - | ||||||||||||||||||||||||||||||||||||
7439 | if (factor < 0.8 || factor > 1.25)
| 0 | ||||||||||||||||||||||||||||||||||||
7440 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
7441 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7442 | // Saved by Qt 5.3 and earlier, try to prevent too large windows | - | ||||||||||||||||||||||||||||||||||||
7443 | // unless the size will be adapted by maximized or fullscreen. | - | ||||||||||||||||||||||||||||||||||||
7444 | if (!maximized && !fullScreen && qreal(restoredFrameGeometry.width()) / screenWidthF > 1.5)
| 0 | ||||||||||||||||||||||||||||||||||||
7445 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
7446 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7447 | - | |||||||||||||||||||||||||||||||||||||
7448 | const int frameHeight = 20; | - | ||||||||||||||||||||||||||||||||||||
7449 | if (!restoredFrameGeometry.isValid())
| 0 | ||||||||||||||||||||||||||||||||||||
7450 | restoredFrameGeometry = QRect(QPoint(0,0), sizeHint()); never executed: restoredFrameGeometry = QRect(QPoint(0,0), sizeHint()); | 0 | ||||||||||||||||||||||||||||||||||||
7451 | - | |||||||||||||||||||||||||||||||||||||
7452 | if (!restoredNormalGeometry.isValid())
| 0 | ||||||||||||||||||||||||||||||||||||
7453 | restoredNormalGeometry = QRect(QPoint(0, frameHeight), sizeHint()); never executed: restoredNormalGeometry = QRect(QPoint(0, frameHeight), sizeHint()); | 0 | ||||||||||||||||||||||||||||||||||||
7454 | if (!restoredNormalGeometry.isValid()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7455 | // use the widget's adjustedSize if the sizeHint() doesn't help | - | ||||||||||||||||||||||||||||||||||||
7456 | restoredNormalGeometry.setSize(restoredNormalGeometry | - | ||||||||||||||||||||||||||||||||||||
7457 | .size() | - | ||||||||||||||||||||||||||||||||||||
7458 | .expandedTo(d_func()->adjustedSize())); | - | ||||||||||||||||||||||||||||||||||||
7459 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7460 | - | |||||||||||||||||||||||||||||||||||||
7461 | const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber); | - | ||||||||||||||||||||||||||||||||||||
7462 | - | |||||||||||||||||||||||||||||||||||||
7463 | // Modify the restored geometry if we are about to restore to coordinates | - | ||||||||||||||||||||||||||||||||||||
7464 | // that would make the window "lost". This happens if: | - | ||||||||||||||||||||||||||||||||||||
7465 | // - The restored geometry is completely oustside the available geometry | - | ||||||||||||||||||||||||||||||||||||
7466 | // - The title bar is outside the available geometry. | - | ||||||||||||||||||||||||||||||||||||
7467 | // - (Mac only) The window is higher than the available geometry. It must | - | ||||||||||||||||||||||||||||||||||||
7468 | // be possible to bring the size grip on screen by moving the window. | - | ||||||||||||||||||||||||||||||||||||
7469 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
7470 | restoredFrameGeometry.setHeight(qMin(restoredFrameGeometry.height(), availableGeometry.height())); | - | ||||||||||||||||||||||||||||||||||||
7471 | restoredNormalGeometry.setHeight(qMin(restoredNormalGeometry.height(), availableGeometry.height() - frameHeight)); | - | ||||||||||||||||||||||||||||||||||||
7472 | #endif | - | ||||||||||||||||||||||||||||||||||||
7473 | - | |||||||||||||||||||||||||||||||||||||
7474 | if (!restoredFrameGeometry.intersects(availableGeometry)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7475 | restoredFrameGeometry.moveBottom(qMin(restoredFrameGeometry.bottom(), availableGeometry.bottom())); | - | ||||||||||||||||||||||||||||||||||||
7476 | restoredFrameGeometry.moveLeft(qMax(restoredFrameGeometry.left(), availableGeometry.left())); | - | ||||||||||||||||||||||||||||||||||||
7477 | restoredFrameGeometry.moveRight(qMin(restoredFrameGeometry.right(), availableGeometry.right())); | - | ||||||||||||||||||||||||||||||||||||
7478 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7479 | restoredFrameGeometry.moveTop(qMax(restoredFrameGeometry.top(), availableGeometry.top())); | - | ||||||||||||||||||||||||||||||||||||
7480 | - | |||||||||||||||||||||||||||||||||||||
7481 | if (!restoredNormalGeometry.intersects(availableGeometry)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7482 | restoredNormalGeometry.moveBottom(qMin(restoredNormalGeometry.bottom(), availableGeometry.bottom())); | - | ||||||||||||||||||||||||||||||||||||
7483 | restoredNormalGeometry.moveLeft(qMax(restoredNormalGeometry.left(), availableGeometry.left())); | - | ||||||||||||||||||||||||||||||||||||
7484 | restoredNormalGeometry.moveRight(qMin(restoredNormalGeometry.right(), availableGeometry.right())); | - | ||||||||||||||||||||||||||||||||||||
7485 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7486 | restoredNormalGeometry.moveTop(qMax(restoredNormalGeometry.top(), availableGeometry.top() + frameHeight)); | - | ||||||||||||||||||||||||||||||||||||
7487 | - | |||||||||||||||||||||||||||||||||||||
7488 | if (maximized || fullScreen) {
| 0 | ||||||||||||||||||||||||||||||||||||
7489 | // set geometry before setting the window state to make | - | ||||||||||||||||||||||||||||||||||||
7490 | // sure the window is maximized to the right screen. | - | ||||||||||||||||||||||||||||||||||||
7491 | Qt::WindowStates ws = windowState(); | - | ||||||||||||||||||||||||||||||||||||
7492 | #ifndef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
7493 | setGeometry(restoredNormalGeometry); | - | ||||||||||||||||||||||||||||||||||||
7494 | #else | - | ||||||||||||||||||||||||||||||||||||
7495 | if (ws & Qt::WindowFullScreen) { | - | ||||||||||||||||||||||||||||||||||||
7496 | // Full screen is not a real window state on Windows. | - | ||||||||||||||||||||||||||||||||||||
7497 | move(availableGeometry.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
7498 | } else if (ws & Qt::WindowMaximized) { | - | ||||||||||||||||||||||||||||||||||||
7499 | // Setting a geometry on an already maximized window causes this to be | - | ||||||||||||||||||||||||||||||||||||
7500 | // restored into a broken, half-maximized state, non-resizable state (QTBUG-4397). | - | ||||||||||||||||||||||||||||||||||||
7501 | // Move the window in normal state if needed. | - | ||||||||||||||||||||||||||||||||||||
7502 | if (restoredScreenNumber != desktop->screenNumber(this)) { | - | ||||||||||||||||||||||||||||||||||||
7503 | setWindowState(Qt::WindowNoState); | - | ||||||||||||||||||||||||||||||||||||
7504 | setGeometry(restoredNormalGeometry); | - | ||||||||||||||||||||||||||||||||||||
7505 | } | - | ||||||||||||||||||||||||||||||||||||
7506 | } else { | - | ||||||||||||||||||||||||||||||||||||
7507 | setGeometry(restoredNormalGeometry); | - | ||||||||||||||||||||||||||||||||||||
7508 | } | - | ||||||||||||||||||||||||||||||||||||
7509 | #endif // Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
7510 | if (maximized)
| 0 | ||||||||||||||||||||||||||||||||||||
7511 | ws |= Qt::WindowMaximized; never executed: ws |= Qt::WindowMaximized; | 0 | ||||||||||||||||||||||||||||||||||||
7512 | if (fullScreen)
| 0 | ||||||||||||||||||||||||||||||||||||
7513 | ws |= Qt::WindowFullScreen; never executed: ws |= Qt::WindowFullScreen; | 0 | ||||||||||||||||||||||||||||||||||||
7514 | setWindowState(ws); | - | ||||||||||||||||||||||||||||||||||||
7515 | d_func()->topData()->normalGeometry = restoredNormalGeometry; | - | ||||||||||||||||||||||||||||||||||||
7516 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7517 | QPoint offset; | - | ||||||||||||||||||||||||||||||||||||
7518 | #ifdef Q_DEAD_CODE_FROM_QT4_X11 | - | ||||||||||||||||||||||||||||||||||||
7519 | if (isFullScreen()) | - | ||||||||||||||||||||||||||||||||||||
7520 | offset = d_func()->topData()->fullScreenOffset; | - | ||||||||||||||||||||||||||||||||||||
7521 | #endif | - | ||||||||||||||||||||||||||||||||||||
7522 | setWindowState(windowState() & ~(Qt::WindowMaximized | Qt::WindowFullScreen)); | - | ||||||||||||||||||||||||||||||||||||
7523 | move(restoredFrameGeometry.topLeft() + offset); | - | ||||||||||||||||||||||||||||||||||||
7524 | resize(restoredNormalGeometry.size()); | - | ||||||||||||||||||||||||||||||||||||
7525 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7526 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
7527 | } | - | ||||||||||||||||||||||||||||||||||||
7528 | - | |||||||||||||||||||||||||||||||||||||
7529 | /*!\fn void QWidget::setGeometry(int x, int y, int w, int h) | - | ||||||||||||||||||||||||||||||||||||
7530 | \overload | - | ||||||||||||||||||||||||||||||||||||
7531 | - | |||||||||||||||||||||||||||||||||||||
7532 | This corresponds to setGeometry(QRect(\a x, \a y, \a w, \a h)). | - | ||||||||||||||||||||||||||||||||||||
7533 | */ | - | ||||||||||||||||||||||||||||||||||||
7534 | - | |||||||||||||||||||||||||||||||||||||
7535 | /*! | - | ||||||||||||||||||||||||||||||||||||
7536 | Sets the margins around the contents of the widget to have the sizes | - | ||||||||||||||||||||||||||||||||||||
7537 | \a left, \a top, \a right, and \a bottom. The margins are used by | - | ||||||||||||||||||||||||||||||||||||
7538 | the layout system, and may be used by subclasses to specify the area | - | ||||||||||||||||||||||||||||||||||||
7539 | to draw in (e.g. excluding the frame). | - | ||||||||||||||||||||||||||||||||||||
7540 | - | |||||||||||||||||||||||||||||||||||||
7541 | Changing the margins will trigger a resizeEvent(). | - | ||||||||||||||||||||||||||||||||||||
7542 | - | |||||||||||||||||||||||||||||||||||||
7543 | \sa contentsRect(), getContentsMargins() | - | ||||||||||||||||||||||||||||||||||||
7544 | */ | - | ||||||||||||||||||||||||||||||||||||
7545 | void QWidget::setContentsMargins(int left, int top, int right, int bottom) | - | ||||||||||||||||||||||||||||||||||||
7546 | { | - | ||||||||||||||||||||||||||||||||||||
7547 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7548 | if (left == d->leftmargin && top == d->topmargin
| 0 | ||||||||||||||||||||||||||||||||||||
7549 | && right == d->rightmargin && bottom == d->bottommargin)
| 0 | ||||||||||||||||||||||||||||||||||||
7550 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
7551 | d->leftmargin = left; | - | ||||||||||||||||||||||||||||||||||||
7552 | d->topmargin = top; | - | ||||||||||||||||||||||||||||||||||||
7553 | d->rightmargin = right; | - | ||||||||||||||||||||||||||||||||||||
7554 | d->bottommargin = bottom; | - | ||||||||||||||||||||||||||||||||||||
7555 | - | |||||||||||||||||||||||||||||||||||||
7556 | if (QLayout *l=d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
7557 | l->update(); //force activate; will do updateGeometry never executed: l->update(); | 0 | ||||||||||||||||||||||||||||||||||||
7558 | else | - | ||||||||||||||||||||||||||||||||||||
7559 | updateGeometry(); never executed: updateGeometry(); | 0 | ||||||||||||||||||||||||||||||||||||
7560 | - | |||||||||||||||||||||||||||||||||||||
7561 | if (isVisible()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7562 | update(); | - | ||||||||||||||||||||||||||||||||||||
7563 | QResizeEvent e(data->crect.size(), data->crect.size()); | - | ||||||||||||||||||||||||||||||||||||
7564 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
7565 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7566 | setAttribute(Qt::WA_PendingResizeEvent, true); | - | ||||||||||||||||||||||||||||||||||||
7567 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7568 | - | |||||||||||||||||||||||||||||||||||||
7569 | QEvent e(QEvent::ContentsRectChange); | - | ||||||||||||||||||||||||||||||||||||
7570 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
7571 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7572 | - | |||||||||||||||||||||||||||||||||||||
7573 | /*! | - | ||||||||||||||||||||||||||||||||||||
7574 | \overload | - | ||||||||||||||||||||||||||||||||||||
7575 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
7576 | - | |||||||||||||||||||||||||||||||||||||
7577 | \brief The setContentsMargins function sets the margins around the | - | ||||||||||||||||||||||||||||||||||||
7578 | widget's contents. | - | ||||||||||||||||||||||||||||||||||||
7579 | - | |||||||||||||||||||||||||||||||||||||
7580 | Sets the margins around the contents of the widget to have the | - | ||||||||||||||||||||||||||||||||||||
7581 | sizes determined by \a margins. The margins are | - | ||||||||||||||||||||||||||||||||||||
7582 | used by the layout system, and may be used by subclasses to | - | ||||||||||||||||||||||||||||||||||||
7583 | specify the area to draw in (e.g. excluding the frame). | - | ||||||||||||||||||||||||||||||||||||
7584 | - | |||||||||||||||||||||||||||||||||||||
7585 | Changing the margins will trigger a resizeEvent(). | - | ||||||||||||||||||||||||||||||||||||
7586 | - | |||||||||||||||||||||||||||||||||||||
7587 | \sa contentsRect(), getContentsMargins() | - | ||||||||||||||||||||||||||||||||||||
7588 | */ | - | ||||||||||||||||||||||||||||||||||||
7589 | void QWidget::setContentsMargins(const QMargins &margins) | - | ||||||||||||||||||||||||||||||||||||
7590 | { | - | ||||||||||||||||||||||||||||||||||||
7591 | setContentsMargins(margins.left(), margins.top(), | - | ||||||||||||||||||||||||||||||||||||
7592 | margins.right(), margins.bottom()); | - | ||||||||||||||||||||||||||||||||||||
7593 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7594 | - | |||||||||||||||||||||||||||||||||||||
7595 | /*! | - | ||||||||||||||||||||||||||||||||||||
7596 | Returns the widget's contents margins for \a left, \a top, \a | - | ||||||||||||||||||||||||||||||||||||
7597 | right, and \a bottom. | - | ||||||||||||||||||||||||||||||||||||
7598 | - | |||||||||||||||||||||||||||||||||||||
7599 | \sa setContentsMargins(), contentsRect() | - | ||||||||||||||||||||||||||||||||||||
7600 | */ | - | ||||||||||||||||||||||||||||||||||||
7601 | void QWidget::getContentsMargins(int *left, int *top, int *right, int *bottom) const | - | ||||||||||||||||||||||||||||||||||||
7602 | { | - | ||||||||||||||||||||||||||||||||||||
7603 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
7604 | if (left)
| 0 | ||||||||||||||||||||||||||||||||||||
7605 | *left = d->leftmargin; never executed: *left = d->leftmargin; | 0 | ||||||||||||||||||||||||||||||||||||
7606 | if (top)
| 0 | ||||||||||||||||||||||||||||||||||||
7607 | *top = d->topmargin; never executed: *top = d->topmargin; | 0 | ||||||||||||||||||||||||||||||||||||
7608 | if (right)
| 0 | ||||||||||||||||||||||||||||||||||||
7609 | *right = d->rightmargin; never executed: *right = d->rightmargin; | 0 | ||||||||||||||||||||||||||||||||||||
7610 | if (bottom)
| 0 | ||||||||||||||||||||||||||||||||||||
7611 | *bottom = d->bottommargin; never executed: *bottom = d->bottommargin; | 0 | ||||||||||||||||||||||||||||||||||||
7612 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7613 | - | |||||||||||||||||||||||||||||||||||||
7614 | /*! | - | ||||||||||||||||||||||||||||||||||||
7615 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
7616 | - | |||||||||||||||||||||||||||||||||||||
7617 | \brief The contentsMargins function returns the widget's contents margins. | - | ||||||||||||||||||||||||||||||||||||
7618 | - | |||||||||||||||||||||||||||||||||||||
7619 | \sa getContentsMargins(), setContentsMargins(), contentsRect() | - | ||||||||||||||||||||||||||||||||||||
7620 | */ | - | ||||||||||||||||||||||||||||||||||||
7621 | QMargins QWidget::contentsMargins() const | - | ||||||||||||||||||||||||||||||||||||
7622 | { | - | ||||||||||||||||||||||||||||||||||||
7623 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
7624 | return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin); never executed: return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin); | 0 | ||||||||||||||||||||||||||||||||||||
7625 | } | - | ||||||||||||||||||||||||||||||||||||
7626 | - | |||||||||||||||||||||||||||||||||||||
7627 | - | |||||||||||||||||||||||||||||||||||||
7628 | /*! | - | ||||||||||||||||||||||||||||||||||||
7629 | Returns the area inside the widget's margins. | - | ||||||||||||||||||||||||||||||||||||
7630 | - | |||||||||||||||||||||||||||||||||||||
7631 | \sa setContentsMargins(), getContentsMargins() | - | ||||||||||||||||||||||||||||||||||||
7632 | */ | - | ||||||||||||||||||||||||||||||||||||
7633 | QRect QWidget::contentsRect() const | - | ||||||||||||||||||||||||||||||||||||
7634 | { | - | ||||||||||||||||||||||||||||||||||||
7635 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
7636 | return QRect(QPoint(d->leftmargin, d->topmargin), never executed: return QRect(QPoint(d->leftmargin, d->topmargin), QPoint(data->crect.width() - 1 - d->rightmargin, data->crect.height() - 1 - d->bottommargin)); | 0 | ||||||||||||||||||||||||||||||||||||
7637 | QPoint(data->crect.width() - 1 - d->rightmargin, never executed: return QRect(QPoint(d->leftmargin, d->topmargin), QPoint(data->crect.width() - 1 - d->rightmargin, data->crect.height() - 1 - d->bottommargin)); | 0 | ||||||||||||||||||||||||||||||||||||
7638 | data->crect.height() - 1 - d->bottommargin)); never executed: return QRect(QPoint(d->leftmargin, d->topmargin), QPoint(data->crect.width() - 1 - d->rightmargin, data->crect.height() - 1 - d->bottommargin)); | 0 | ||||||||||||||||||||||||||||||||||||
7639 | - | |||||||||||||||||||||||||||||||||||||
7640 | } | - | ||||||||||||||||||||||||||||||||||||
7641 | - | |||||||||||||||||||||||||||||||||||||
7642 | - | |||||||||||||||||||||||||||||||||||||
7643 | - | |||||||||||||||||||||||||||||||||||||
7644 | /*! | - | ||||||||||||||||||||||||||||||||||||
7645 | \fn void QWidget::customContextMenuRequested(const QPoint &pos) | - | ||||||||||||||||||||||||||||||||||||
7646 | - | |||||||||||||||||||||||||||||||||||||
7647 | This signal is emitted when the widget's \l contextMenuPolicy is | - | ||||||||||||||||||||||||||||||||||||
7648 | Qt::CustomContextMenu, and the user has requested a context menu on | - | ||||||||||||||||||||||||||||||||||||
7649 | the widget. The position \a pos is the position of the context menu | - | ||||||||||||||||||||||||||||||||||||
7650 | event that the widget receives. Normally this is in widget | - | ||||||||||||||||||||||||||||||||||||
7651 | coordinates. The exception to this rule is QAbstractScrollArea and | - | ||||||||||||||||||||||||||||||||||||
7652 | its subclasses that map the context menu event to coordinates of the | - | ||||||||||||||||||||||||||||||||||||
7653 | \l{QAbstractScrollArea::viewport()}{viewport()}. | - | ||||||||||||||||||||||||||||||||||||
7654 | - | |||||||||||||||||||||||||||||||||||||
7655 | - | |||||||||||||||||||||||||||||||||||||
7656 | \sa mapToGlobal(), QMenu, contextMenuPolicy | - | ||||||||||||||||||||||||||||||||||||
7657 | */ | - | ||||||||||||||||||||||||||||||||||||
7658 | - | |||||||||||||||||||||||||||||||||||||
7659 | - | |||||||||||||||||||||||||||||||||||||
7660 | /*! | - | ||||||||||||||||||||||||||||||||||||
7661 | \property QWidget::contextMenuPolicy | - | ||||||||||||||||||||||||||||||||||||
7662 | \brief how the widget shows a context menu | - | ||||||||||||||||||||||||||||||||||||
7663 | - | |||||||||||||||||||||||||||||||||||||
7664 | The default value of this property is Qt::DefaultContextMenu, | - | ||||||||||||||||||||||||||||||||||||
7665 | which means the contextMenuEvent() handler is called. Other values | - | ||||||||||||||||||||||||||||||||||||
7666 | are Qt::NoContextMenu, Qt::PreventContextMenu, | - | ||||||||||||||||||||||||||||||||||||
7667 | Qt::ActionsContextMenu, and Qt::CustomContextMenu. With | - | ||||||||||||||||||||||||||||||||||||
7668 | Qt::CustomContextMenu, the signal customContextMenuRequested() is | - | ||||||||||||||||||||||||||||||||||||
7669 | emitted. | - | ||||||||||||||||||||||||||||||||||||
7670 | - | |||||||||||||||||||||||||||||||||||||
7671 | \sa contextMenuEvent(), customContextMenuRequested(), actions() | - | ||||||||||||||||||||||||||||||||||||
7672 | */ | - | ||||||||||||||||||||||||||||||||||||
7673 | - | |||||||||||||||||||||||||||||||||||||
7674 | Qt::ContextMenuPolicy QWidget::contextMenuPolicy() const | - | ||||||||||||||||||||||||||||||||||||
7675 | { | - | ||||||||||||||||||||||||||||||||||||
7676 | return (Qt::ContextMenuPolicy)data->context_menu_policy; never executed: return (Qt::ContextMenuPolicy)data->context_menu_policy; | 0 | ||||||||||||||||||||||||||||||||||||
7677 | } | - | ||||||||||||||||||||||||||||||||||||
7678 | - | |||||||||||||||||||||||||||||||||||||
7679 | void QWidget::setContextMenuPolicy(Qt::ContextMenuPolicy policy) | - | ||||||||||||||||||||||||||||||||||||
7680 | { | - | ||||||||||||||||||||||||||||||||||||
7681 | data->context_menu_policy = (uint) policy; | - | ||||||||||||||||||||||||||||||||||||
7682 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7683 | - | |||||||||||||||||||||||||||||||||||||
7684 | /*! | - | ||||||||||||||||||||||||||||||||||||
7685 | \property QWidget::focusPolicy | - | ||||||||||||||||||||||||||||||||||||
7686 | \brief the way the widget accepts keyboard focus | - | ||||||||||||||||||||||||||||||||||||
7687 | - | |||||||||||||||||||||||||||||||||||||
7688 | The policy is Qt::TabFocus if the widget accepts keyboard | - | ||||||||||||||||||||||||||||||||||||
7689 | focus by tabbing, Qt::ClickFocus if the widget accepts | - | ||||||||||||||||||||||||||||||||||||
7690 | focus by clicking, Qt::StrongFocus if it accepts both, and | - | ||||||||||||||||||||||||||||||||||||
7691 | Qt::NoFocus (the default) if it does not accept focus at | - | ||||||||||||||||||||||||||||||||||||
7692 | all. | - | ||||||||||||||||||||||||||||||||||||
7693 | - | |||||||||||||||||||||||||||||||||||||
7694 | You must enable keyboard focus for a widget if it processes | - | ||||||||||||||||||||||||||||||||||||
7695 | keyboard events. This is normally done from the widget's | - | ||||||||||||||||||||||||||||||||||||
7696 | constructor. For instance, the QLineEdit constructor calls | - | ||||||||||||||||||||||||||||||||||||
7697 | setFocusPolicy(Qt::StrongFocus). | - | ||||||||||||||||||||||||||||||||||||
7698 | - | |||||||||||||||||||||||||||||||||||||
7699 | If the widget has a focus proxy, then the focus policy will | - | ||||||||||||||||||||||||||||||||||||
7700 | be propagated to it. | - | ||||||||||||||||||||||||||||||||||||
7701 | - | |||||||||||||||||||||||||||||||||||||
7702 | \sa focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), enabled | - | ||||||||||||||||||||||||||||||||||||
7703 | */ | - | ||||||||||||||||||||||||||||||||||||
7704 | - | |||||||||||||||||||||||||||||||||||||
7705 | - | |||||||||||||||||||||||||||||||||||||
7706 | Qt::FocusPolicy QWidget::focusPolicy() const | - | ||||||||||||||||||||||||||||||||||||
7707 | { | - | ||||||||||||||||||||||||||||||||||||
7708 | return (Qt::FocusPolicy)data->focus_policy; never executed: return (Qt::FocusPolicy)data->focus_policy; | 0 | ||||||||||||||||||||||||||||||||||||
7709 | } | - | ||||||||||||||||||||||||||||||||||||
7710 | - | |||||||||||||||||||||||||||||||||||||
7711 | void QWidget::setFocusPolicy(Qt::FocusPolicy policy) | - | ||||||||||||||||||||||||||||||||||||
7712 | { | - | ||||||||||||||||||||||||||||||||||||
7713 | data->focus_policy = (uint) policy; | - | ||||||||||||||||||||||||||||||||||||
7714 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7715 | if (d->extra && d->extra->focus_proxy)
| 0 | ||||||||||||||||||||||||||||||||||||
7716 | d->extra->focus_proxy->setFocusPolicy(policy); never executed: d->extra->focus_proxy->setFocusPolicy(policy); | 0 | ||||||||||||||||||||||||||||||||||||
7717 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7718 | - | |||||||||||||||||||||||||||||||||||||
7719 | /*! | - | ||||||||||||||||||||||||||||||||||||
7720 | \property QWidget::updatesEnabled | - | ||||||||||||||||||||||||||||||||||||
7721 | \brief whether updates are enabled | - | ||||||||||||||||||||||||||||||||||||
7722 | - | |||||||||||||||||||||||||||||||||||||
7723 | An updates enabled widget receives paint events and has a system | - | ||||||||||||||||||||||||||||||||||||
7724 | background; a disabled widget does not. This also implies that | - | ||||||||||||||||||||||||||||||||||||
7725 | calling update() and repaint() has no effect if updates are | - | ||||||||||||||||||||||||||||||||||||
7726 | disabled. | - | ||||||||||||||||||||||||||||||||||||
7727 | - | |||||||||||||||||||||||||||||||||||||
7728 | By default, this property is \c true. | - | ||||||||||||||||||||||||||||||||||||
7729 | - | |||||||||||||||||||||||||||||||||||||
7730 | setUpdatesEnabled() is normally used to disable updates for a | - | ||||||||||||||||||||||||||||||||||||
7731 | short period of time, for instance to avoid screen flicker during | - | ||||||||||||||||||||||||||||||||||||
7732 | large changes. In Qt, widgets normally do not generate screen | - | ||||||||||||||||||||||||||||||||||||
7733 | flicker, but on X11 the server might erase regions on the screen | - | ||||||||||||||||||||||||||||||||||||
7734 | when widgets get hidden before they can be replaced by other | - | ||||||||||||||||||||||||||||||||||||
7735 | widgets. Disabling updates solves this. | - | ||||||||||||||||||||||||||||||||||||
7736 | - | |||||||||||||||||||||||||||||||||||||
7737 | Example: | - | ||||||||||||||||||||||||||||||||||||
7738 | \snippet code/src_gui_kernel_qwidget.cpp 13 | - | ||||||||||||||||||||||||||||||||||||
7739 | - | |||||||||||||||||||||||||||||||||||||
7740 | Disabling a widget implicitly disables all its children. Enabling a widget | - | ||||||||||||||||||||||||||||||||||||
7741 | enables all child widgets \e except top-level widgets or those that | - | ||||||||||||||||||||||||||||||||||||
7742 | have been explicitly disabled. Re-enabling updates implicitly calls | - | ||||||||||||||||||||||||||||||||||||
7743 | update() on the widget. | - | ||||||||||||||||||||||||||||||||||||
7744 | - | |||||||||||||||||||||||||||||||||||||
7745 | \sa paintEvent() | - | ||||||||||||||||||||||||||||||||||||
7746 | */ | - | ||||||||||||||||||||||||||||||||||||
7747 | void QWidget::setUpdatesEnabled(bool enable) | - | ||||||||||||||||||||||||||||||||||||
7748 | { | - | ||||||||||||||||||||||||||||||||||||
7749 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7750 | setAttribute(Qt::WA_ForceUpdatesDisabled, !enable); | - | ||||||||||||||||||||||||||||||||||||
7751 | d->setUpdatesEnabled_helper(enable); | - | ||||||||||||||||||||||||||||||||||||
7752 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7753 | - | |||||||||||||||||||||||||||||||||||||
7754 | /*! | - | ||||||||||||||||||||||||||||||||||||
7755 | Shows the widget and its child widgets. | - | ||||||||||||||||||||||||||||||||||||
7756 | - | |||||||||||||||||||||||||||||||||||||
7757 | This is equivalent to calling showFullScreen(), showMaximized(), or setVisible(true), | - | ||||||||||||||||||||||||||||||||||||
7758 | depending on the platform's default behavior for the window flags. | - | ||||||||||||||||||||||||||||||||||||
7759 | - | |||||||||||||||||||||||||||||||||||||
7760 | \sa raise(), showEvent(), hide(), setVisible(), showMinimized(), showMaximized(), | - | ||||||||||||||||||||||||||||||||||||
7761 | showNormal(), isVisible(), windowFlags() | - | ||||||||||||||||||||||||||||||||||||
7762 | */ | - | ||||||||||||||||||||||||||||||||||||
7763 | void QWidget::show() | - | ||||||||||||||||||||||||||||||||||||
7764 | { | - | ||||||||||||||||||||||||||||||||||||
7765 | Qt::WindowState defaultState = QGuiApplicationPrivate::platformIntegration()->defaultWindowState(data->window_flags); | - | ||||||||||||||||||||||||||||||||||||
7766 | if (defaultState == Qt::WindowFullScreen)
| 0 | ||||||||||||||||||||||||||||||||||||
7767 | showFullScreen(); never executed: showFullScreen(); | 0 | ||||||||||||||||||||||||||||||||||||
7768 | else if (defaultState == Qt::WindowMaximized)
| 0 | ||||||||||||||||||||||||||||||||||||
7769 | showMaximized(); never executed: showMaximized(); | 0 | ||||||||||||||||||||||||||||||||||||
7770 | else | - | ||||||||||||||||||||||||||||||||||||
7771 | setVisible(true); // FIXME: Why not showNormal(), like QWindow::show()? never executed: setVisible(true); | 0 | ||||||||||||||||||||||||||||||||||||
7772 | } | - | ||||||||||||||||||||||||||||||||||||
7773 | - | |||||||||||||||||||||||||||||||||||||
7774 | /*! \internal | - | ||||||||||||||||||||||||||||||||||||
7775 | - | |||||||||||||||||||||||||||||||||||||
7776 | Makes the widget visible in the isVisible() meaning of the word. | - | ||||||||||||||||||||||||||||||||||||
7777 | It is only called for toplevels or widgets with visible parents. | - | ||||||||||||||||||||||||||||||||||||
7778 | */ | - | ||||||||||||||||||||||||||||||||||||
7779 | void QWidgetPrivate::show_recursive() | - | ||||||||||||||||||||||||||||||||||||
7780 | { | - | ||||||||||||||||||||||||||||||||||||
7781 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7782 | // polish if necessary | - | ||||||||||||||||||||||||||||||||||||
7783 | - | |||||||||||||||||||||||||||||||||||||
7784 | if (!q->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
7785 | createRecursively(); never executed: createRecursively(); | 0 | ||||||||||||||||||||||||||||||||||||
7786 | q->ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
7787 | - | |||||||||||||||||||||||||||||||||||||
7788 | if (!q->isWindow() && q->parentWidget()->d_func()->layout && !q->parentWidget()->data->in_show)
| 0 | ||||||||||||||||||||||||||||||||||||
7789 | q->parentWidget()->d_func()->layout->activate(); never executed: q->parentWidget()->d_func()->layout->activate(); | 0 | ||||||||||||||||||||||||||||||||||||
7790 | // activate our layout before we and our children become visible | - | ||||||||||||||||||||||||||||||||||||
7791 | if (layout)
| 0 | ||||||||||||||||||||||||||||||||||||
7792 | layout->activate(); never executed: layout->activate(); | 0 | ||||||||||||||||||||||||||||||||||||
7793 | - | |||||||||||||||||||||||||||||||||||||
7794 | show_helper(); | - | ||||||||||||||||||||||||||||||||||||
7795 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7796 | - | |||||||||||||||||||||||||||||||||||||
7797 | void QWidgetPrivate::sendPendingMoveAndResizeEvents(bool recursive, bool disableUpdates) | - | ||||||||||||||||||||||||||||||||||||
7798 | { | - | ||||||||||||||||||||||||||||||||||||
7799 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7800 | - | |||||||||||||||||||||||||||||||||||||
7801 | disableUpdates = disableUpdates && q->updatesEnabled();
| 0 | ||||||||||||||||||||||||||||||||||||
7802 | if (disableUpdates)
| 0 | ||||||||||||||||||||||||||||||||||||
7803 | q->setAttribute(Qt::WA_UpdatesDisabled); never executed: q->setAttribute(Qt::WA_UpdatesDisabled); | 0 | ||||||||||||||||||||||||||||||||||||
7804 | - | |||||||||||||||||||||||||||||||||||||
7805 | if (q->testAttribute(Qt::WA_PendingMoveEvent)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7806 | QMoveEvent e(data.crect.topLeft(), data.crect.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
7807 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
7808 | q->setAttribute(Qt::WA_PendingMoveEvent, false); | - | ||||||||||||||||||||||||||||||||||||
7809 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7810 | - | |||||||||||||||||||||||||||||||||||||
7811 | if (q->testAttribute(Qt::WA_PendingResizeEvent)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7812 | QResizeEvent e(data.crect.size(), QSize()); | - | ||||||||||||||||||||||||||||||||||||
7813 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
7814 | q->setAttribute(Qt::WA_PendingResizeEvent, false); | - | ||||||||||||||||||||||||||||||||||||
7815 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7816 | - | |||||||||||||||||||||||||||||||||||||
7817 | if (disableUpdates)
| 0 | ||||||||||||||||||||||||||||||||||||
7818 | q->setAttribute(Qt::WA_UpdatesDisabled, false); never executed: q->setAttribute(Qt::WA_UpdatesDisabled, false); | 0 | ||||||||||||||||||||||||||||||||||||
7819 | - | |||||||||||||||||||||||||||||||||||||
7820 | if (!recursive)
| 0 | ||||||||||||||||||||||||||||||||||||
7821 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
7822 | - | |||||||||||||||||||||||||||||||||||||
7823 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
7824 | if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
| 0 | ||||||||||||||||||||||||||||||||||||
7825 | child->d_func()->sendPendingMoveAndResizeEvents(recursive, disableUpdates); never executed: child->d_func()->sendPendingMoveAndResizeEvents(recursive, disableUpdates); | 0 | ||||||||||||||||||||||||||||||||||||
7826 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7827 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7828 | - | |||||||||||||||||||||||||||||||||||||
7829 | void QWidgetPrivate::activateChildLayoutsRecursively() | - | ||||||||||||||||||||||||||||||||||||
7830 | { | - | ||||||||||||||||||||||||||||||||||||
7831 | sendPendingMoveAndResizeEvents(false, true); | - | ||||||||||||||||||||||||||||||||||||
7832 | - | |||||||||||||||||||||||||||||||||||||
7833 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
7834 | QWidget *child = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
7835 | if (!child || child->isHidden() || child->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7836 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
7837 | - | |||||||||||||||||||||||||||||||||||||
7838 | child->ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
7839 | - | |||||||||||||||||||||||||||||||||||||
7840 | // Activate child's layout | - | ||||||||||||||||||||||||||||||||||||
7841 | QWidgetPrivate *childPrivate = child->d_func(); | - | ||||||||||||||||||||||||||||||||||||
7842 | if (childPrivate->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
7843 | childPrivate->layout->activate(); never executed: childPrivate->layout->activate(); | 0 | ||||||||||||||||||||||||||||||||||||
7844 | - | |||||||||||||||||||||||||||||||||||||
7845 | // Pretend we're visible. | - | ||||||||||||||||||||||||||||||||||||
7846 | const bool wasVisible = child->isVisible(); | - | ||||||||||||||||||||||||||||||||||||
7847 | if (!wasVisible)
| 0 | ||||||||||||||||||||||||||||||||||||
7848 | child->setAttribute(Qt::WA_WState_Visible); never executed: child->setAttribute(Qt::WA_WState_Visible); | 0 | ||||||||||||||||||||||||||||||||||||
7849 | - | |||||||||||||||||||||||||||||||||||||
7850 | // Do the same for all my children. | - | ||||||||||||||||||||||||||||||||||||
7851 | childPrivate->activateChildLayoutsRecursively(); | - | ||||||||||||||||||||||||||||||||||||
7852 | - | |||||||||||||||||||||||||||||||||||||
7853 | // We're not cheating anymore. | - | ||||||||||||||||||||||||||||||||||||
7854 | if (!wasVisible)
| 0 | ||||||||||||||||||||||||||||||||||||
7855 | child->setAttribute(Qt::WA_WState_Visible, false); never executed: child->setAttribute(Qt::WA_WState_Visible, false); | 0 | ||||||||||||||||||||||||||||||||||||
7856 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7857 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7858 | - | |||||||||||||||||||||||||||||||||||||
7859 | void QWidgetPrivate::show_helper() | - | ||||||||||||||||||||||||||||||||||||
7860 | { | - | ||||||||||||||||||||||||||||||||||||
7861 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7862 | data.in_show = true; // qws optimization | - | ||||||||||||||||||||||||||||||||||||
7863 | // make sure we receive pending move and resize events | - | ||||||||||||||||||||||||||||||||||||
7864 | sendPendingMoveAndResizeEvents(); | - | ||||||||||||||||||||||||||||||||||||
7865 | - | |||||||||||||||||||||||||||||||||||||
7866 | // become visible before showing all children | - | ||||||||||||||||||||||||||||||||||||
7867 | q->setAttribute(Qt::WA_WState_Visible); | - | ||||||||||||||||||||||||||||||||||||
7868 | - | |||||||||||||||||||||||||||||||||||||
7869 | // finally show all children recursively | - | ||||||||||||||||||||||||||||||||||||
7870 | showChildren(false); | - | ||||||||||||||||||||||||||||||||||||
7871 | - | |||||||||||||||||||||||||||||||||||||
7872 | - | |||||||||||||||||||||||||||||||||||||
7873 | - | |||||||||||||||||||||||||||||||||||||
7874 | const bool isWindow = q->isWindow(); | - | ||||||||||||||||||||||||||||||||||||
7875 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
7876 | bool isEmbedded = isWindow && q->graphicsProxyWidget() != Q_NULLPTR;
| 0 | ||||||||||||||||||||||||||||||||||||
7877 | #else | - | ||||||||||||||||||||||||||||||||||||
7878 | bool isEmbedded = false; | - | ||||||||||||||||||||||||||||||||||||
7879 | #endif | - | ||||||||||||||||||||||||||||||||||||
7880 | - | |||||||||||||||||||||||||||||||||||||
7881 | // popup handling: new popups and tools need to be raised, and | - | ||||||||||||||||||||||||||||||||||||
7882 | // existing popups must be closed. Also propagate the current | - | ||||||||||||||||||||||||||||||||||||
7883 | // windows's KeyboardFocusChange status. | - | ||||||||||||||||||||||||||||||||||||
7884 | if (isWindow && !isEmbedded) {
| 0 | ||||||||||||||||||||||||||||||||||||
7885 | if ((q->windowType() == Qt::Tool) || (q->windowType() == Qt::Popup) || q->windowType() == Qt::ToolTip) {
| 0 | ||||||||||||||||||||||||||||||||||||
7886 | q->raise(); | - | ||||||||||||||||||||||||||||||||||||
7887 | if (q->parentWidget() && q->parentWidget()->window()->testAttribute(Qt::WA_KeyboardFocusChange))
| 0 | ||||||||||||||||||||||||||||||||||||
7888 | q->setAttribute(Qt::WA_KeyboardFocusChange); never executed: q->setAttribute(Qt::WA_KeyboardFocusChange); | 0 | ||||||||||||||||||||||||||||||||||||
7889 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7890 | while (QApplication::activePopupWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7891 | if (!QApplication::activePopupWidget()->close())
| 0 | ||||||||||||||||||||||||||||||||||||
7892 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
7893 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7894 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7895 | } | - | ||||||||||||||||||||||||||||||||||||
7896 | - | |||||||||||||||||||||||||||||||||||||
7897 | // Automatic embedding of child windows of widgets already embedded into | - | ||||||||||||||||||||||||||||||||||||
7898 | // QGraphicsProxyWidget when they are shown the first time. | - | ||||||||||||||||||||||||||||||||||||
7899 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
7900 | if (isWindow) {
| 0 | ||||||||||||||||||||||||||||||||||||
7901 | if (!isEmbedded && !bypassGraphicsProxyWidget(q)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7902 | QGraphicsProxyWidget *ancestorProxy = nearestGraphicsProxyWidget(q->parentWidget()); | - | ||||||||||||||||||||||||||||||||||||
7903 | if (ancestorProxy) {
| 0 | ||||||||||||||||||||||||||||||||||||
7904 | isEmbedded = true; | - | ||||||||||||||||||||||||||||||||||||
7905 | ancestorProxy->d_func()->embedSubWindow(q); | - | ||||||||||||||||||||||||||||||||||||
7906 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7907 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7908 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7909 | #else | - | ||||||||||||||||||||||||||||||||||||
7910 | Q_UNUSED(isEmbedded); | - | ||||||||||||||||||||||||||||||||||||
7911 | #endif | - | ||||||||||||||||||||||||||||||||||||
7912 | - | |||||||||||||||||||||||||||||||||||||
7913 | // On Windows, show the popup now so that our own focus handling | - | ||||||||||||||||||||||||||||||||||||
7914 | // stores the correct old focus widget even if it's stolen in the | - | ||||||||||||||||||||||||||||||||||||
7915 | // showevent | - | ||||||||||||||||||||||||||||||||||||
7916 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
7917 | if (!isEmbedded && q->windowType() == Qt::Popup) | - | ||||||||||||||||||||||||||||||||||||
7918 | qApp->d_func()->openPopup(q); | - | ||||||||||||||||||||||||||||||||||||
7919 | #endif | - | ||||||||||||||||||||||||||||||||||||
7920 | - | |||||||||||||||||||||||||||||||||||||
7921 | // send the show event before showing the window | - | ||||||||||||||||||||||||||||||||||||
7922 | QShowEvent showEvent; | - | ||||||||||||||||||||||||||||||||||||
7923 | QApplication::sendEvent(q, &showEvent); | - | ||||||||||||||||||||||||||||||||||||
7924 | - | |||||||||||||||||||||||||||||||||||||
7925 | show_sys(); | - | ||||||||||||||||||||||||||||||||||||
7926 | - | |||||||||||||||||||||||||||||||||||||
7927 | if (!isEmbedded && q->windowType() == Qt::Popup)
| 0 | ||||||||||||||||||||||||||||||||||||
7928 | qApp->d_func()->openPopup(q); never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->openPopup(q); | 0 | ||||||||||||||||||||||||||||||||||||
7929 | - | |||||||||||||||||||||||||||||||||||||
7930 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
7931 | if (q->windowType() != Qt::ToolTip) { // Tooltips are read aloud twice in MS narrator.
| 0 | ||||||||||||||||||||||||||||||||||||
7932 | QAccessibleEvent event(q, QAccessible::ObjectShow); | - | ||||||||||||||||||||||||||||||||||||
7933 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
7934 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7935 | #endif | - | ||||||||||||||||||||||||||||||||||||
7936 | - | |||||||||||||||||||||||||||||||||||||
7937 | if (QApplicationPrivate::hidden_focus_widget == q) {
| 0 | ||||||||||||||||||||||||||||||||||||
7938 | QApplicationPrivate::hidden_focus_widget = 0; | - | ||||||||||||||||||||||||||||||||||||
7939 | q->setFocus(Qt::OtherFocusReason); | - | ||||||||||||||||||||||||||||||||||||
7940 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7941 | - | |||||||||||||||||||||||||||||||||||||
7942 | // Process events when showing a Qt::SplashScreen widget before the event loop | - | ||||||||||||||||||||||||||||||||||||
7943 | // is spinnning; otherwise it might not show up on particular platforms. | - | ||||||||||||||||||||||||||||||||||||
7944 | // This makes QSplashScreen behave the same on all platforms. | - | ||||||||||||||||||||||||||||||||||||
7945 | if (!qApp->d_func()->in_exec && q->windowType() == Qt::SplashScreen)
| 0 | ||||||||||||||||||||||||||||||||||||
7946 | QApplication::processEvents(); never executed: QApplication::processEvents(); | 0 | ||||||||||||||||||||||||||||||||||||
7947 | - | |||||||||||||||||||||||||||||||||||||
7948 | data.in_show = false; // reset qws optimization | - | ||||||||||||||||||||||||||||||||||||
7949 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7950 | - | |||||||||||||||||||||||||||||||||||||
7951 | void QWidgetPrivate::show_sys() | - | ||||||||||||||||||||||||||||||||||||
7952 | { | - | ||||||||||||||||||||||||||||||||||||
7953 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7954 | - | |||||||||||||||||||||||||||||||||||||
7955 | QWindow *window = q->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
7956 | - | |||||||||||||||||||||||||||||||||||||
7957 | if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7958 | invalidateBuffer(q->rect()); | - | ||||||||||||||||||||||||||||||||||||
7959 | q->setAttribute(Qt::WA_Mapped); | - | ||||||||||||||||||||||||||||||||||||
7960 | // add our window the modal window list (native dialogs) | - | ||||||||||||||||||||||||||||||||||||
7961 | if (window && q->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
7962 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
7963 | && (!extra || !extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
7964 | #endif | - | ||||||||||||||||||||||||||||||||||||
7965 | && q->windowModality() != Qt::NonModal) {
| 0 | ||||||||||||||||||||||||||||||||||||
7966 | QGuiApplicationPrivate::showModalWindow(window); | - | ||||||||||||||||||||||||||||||||||||
7967 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7968 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
7969 | } | - | ||||||||||||||||||||||||||||||||||||
7970 | - | |||||||||||||||||||||||||||||||||||||
7971 | if (renderToTexture && !q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7972 | QApplication::postEvent(q->parentWidget(), new QUpdateLaterEvent(q->geometry())); never executed: QApplication::postEvent(q->parentWidget(), new QUpdateLaterEvent(q->geometry())); | 0 | ||||||||||||||||||||||||||||||||||||
7973 | else | - | ||||||||||||||||||||||||||||||||||||
7974 | QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); never executed: QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); | 0 | ||||||||||||||||||||||||||||||||||||
7975 | - | |||||||||||||||||||||||||||||||||||||
7976 | if ((!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow))
| 0 | ||||||||||||||||||||||||||||||||||||
7977 | || q->testAttribute(Qt::WA_OutsideWSRange)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7978 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
7979 | } | - | ||||||||||||||||||||||||||||||||||||
7980 | - | |||||||||||||||||||||||||||||||||||||
7981 | if (window) {
| 0 | ||||||||||||||||||||||||||||||||||||
7982 | if (q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7983 | fixPosIncludesFrame(); never executed: fixPosIncludesFrame(); | 0 | ||||||||||||||||||||||||||||||||||||
7984 | QRect geomRect = q->geometry(); | - | ||||||||||||||||||||||||||||||||||||
7985 | if (!q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7986 | QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),QPoint()); | - | ||||||||||||||||||||||||||||||||||||
7987 | geomRect.moveTopLeft(topLeftOfWindow); | - | ||||||||||||||||||||||||||||||||||||
7988 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7989 | const QRect windowRect = window->geometry(); | - | ||||||||||||||||||||||||||||||||||||
7990 | if (windowRect != geomRect) {
| 0 | ||||||||||||||||||||||||||||||||||||
7991 | if (q->testAttribute(Qt::WA_Moved)
| 0 | ||||||||||||||||||||||||||||||||||||
7992 | || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowManagement))
| 0 | ||||||||||||||||||||||||||||||||||||
7993 | window->setGeometry(geomRect); never executed: window->setGeometry(geomRect); | 0 | ||||||||||||||||||||||||||||||||||||
7994 | else | - | ||||||||||||||||||||||||||||||||||||
7995 | window->resize(geomRect.size()); never executed: window->resize(geomRect.size()); | 0 | ||||||||||||||||||||||||||||||||||||
7996 | } | - | ||||||||||||||||||||||||||||||||||||
7997 | - | |||||||||||||||||||||||||||||||||||||
7998 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
7999 | qt_qpa_set_cursor(q, false); // Needed in case cursor was set before show | - | ||||||||||||||||||||||||||||||||||||
8000 | #endif | - | ||||||||||||||||||||||||||||||||||||
8001 | invalidateBuffer(q->rect()); | - | ||||||||||||||||||||||||||||||||||||
8002 | window->setVisible(true); | - | ||||||||||||||||||||||||||||||||||||
8003 | // Was the window moved by the Window system or QPlatformWindow::initialGeometry() ? | - | ||||||||||||||||||||||||||||||||||||
8004 | if (window->isTopLevel()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8005 | const QPoint crectTopLeft = q->data->crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
8006 | const QPoint windowTopLeft = window->geometry().topLeft(); | - | ||||||||||||||||||||||||||||||||||||
8007 | if (crectTopLeft == QPoint(0, 0) && windowTopLeft != crectTopLeft)
| 0 | ||||||||||||||||||||||||||||||||||||
8008 | q->data->crect.moveTopLeft(windowTopLeft); never executed: q->data->crect.moveTopLeft(windowTopLeft); | 0 | ||||||||||||||||||||||||||||||||||||
8009 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8010 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8011 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8012 | - | |||||||||||||||||||||||||||||||||||||
8013 | /*! | - | ||||||||||||||||||||||||||||||||||||
8014 | Hides the widget. This function is equivalent to | - | ||||||||||||||||||||||||||||||||||||
8015 | setVisible(false). | - | ||||||||||||||||||||||||||||||||||||
8016 | - | |||||||||||||||||||||||||||||||||||||
8017 | - | |||||||||||||||||||||||||||||||||||||
8018 | \note If you are working with QDialog or its subclasses and you invoke | - | ||||||||||||||||||||||||||||||||||||
8019 | the show() function after this function, the dialog will be displayed in | - | ||||||||||||||||||||||||||||||||||||
8020 | its original position. | - | ||||||||||||||||||||||||||||||||||||
8021 | - | |||||||||||||||||||||||||||||||||||||
8022 | \sa hideEvent(), isHidden(), show(), setVisible(), isVisible(), close() | - | ||||||||||||||||||||||||||||||||||||
8023 | */ | - | ||||||||||||||||||||||||||||||||||||
8024 | void QWidget::hide() | - | ||||||||||||||||||||||||||||||||||||
8025 | { | - | ||||||||||||||||||||||||||||||||||||
8026 | setVisible(false); | - | ||||||||||||||||||||||||||||||||||||
8027 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8028 | - | |||||||||||||||||||||||||||||||||||||
8029 | /*!\internal | - | ||||||||||||||||||||||||||||||||||||
8030 | */ | - | ||||||||||||||||||||||||||||||||||||
8031 | void QWidgetPrivate::hide_helper() | - | ||||||||||||||||||||||||||||||||||||
8032 | { | - | ||||||||||||||||||||||||||||||||||||
8033 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8034 | - | |||||||||||||||||||||||||||||||||||||
8035 | bool isEmbedded = false; | - | ||||||||||||||||||||||||||||||||||||
8036 | #if !defined QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
8037 | isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != 0;
| 0 | ||||||||||||||||||||||||||||||||||||
8038 | #else | - | ||||||||||||||||||||||||||||||||||||
8039 | Q_UNUSED(isEmbedded); | - | ||||||||||||||||||||||||||||||||||||
8040 | #endif | - | ||||||||||||||||||||||||||||||||||||
8041 | - | |||||||||||||||||||||||||||||||||||||
8042 | if (!isEmbedded && (q->windowType() == Qt::Popup))
| 0 | ||||||||||||||||||||||||||||||||||||
8043 | qApp->d_func()->closePopup(q); never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->closePopup(q); | 0 | ||||||||||||||||||||||||||||||||||||
8044 | - | |||||||||||||||||||||||||||||||||||||
8045 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
8046 | if (q->isWindow() && !(q->windowType() == Qt::Popup) && q->parentWidget() | - | ||||||||||||||||||||||||||||||||||||
8047 | && !q->parentWidget()->isHidden() && q->isActiveWindow()) | - | ||||||||||||||||||||||||||||||||||||
8048 | q->parentWidget()->activateWindow(); // Activate parent | - | ||||||||||||||||||||||||||||||||||||
8049 | #endif | - | ||||||||||||||||||||||||||||||||||||
8050 | - | |||||||||||||||||||||||||||||||||||||
8051 | q->setAttribute(Qt::WA_Mapped, false); | - | ||||||||||||||||||||||||||||||||||||
8052 | hide_sys(); | - | ||||||||||||||||||||||||||||||||||||
8053 | - | |||||||||||||||||||||||||||||||||||||
8054 | bool wasVisible = q->testAttribute(Qt::WA_WState_Visible); | - | ||||||||||||||||||||||||||||||||||||
8055 | - | |||||||||||||||||||||||||||||||||||||
8056 | if (wasVisible) {
| 0 | ||||||||||||||||||||||||||||||||||||
8057 | q->setAttribute(Qt::WA_WState_Visible, false); | - | ||||||||||||||||||||||||||||||||||||
8058 | - | |||||||||||||||||||||||||||||||||||||
8059 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8060 | - | |||||||||||||||||||||||||||||||||||||
8061 | QHideEvent hideEvent; | - | ||||||||||||||||||||||||||||||||||||
8062 | QApplication::sendEvent(q, &hideEvent); | - | ||||||||||||||||||||||||||||||||||||
8063 | hideChildren(false); | - | ||||||||||||||||||||||||||||||||||||
8064 | - | |||||||||||||||||||||||||||||||||||||
8065 | // next bit tries to move the focus if the focus widget is now | - | ||||||||||||||||||||||||||||||||||||
8066 | // hidden. | - | ||||||||||||||||||||||||||||||||||||
8067 | if (wasVisible) {
| 0 | ||||||||||||||||||||||||||||||||||||
8068 | qApp->d_func()->sendSyntheticEnterLeave(q); | - | ||||||||||||||||||||||||||||||||||||
8069 | QWidget *fw = QApplication::focusWidget(); | - | ||||||||||||||||||||||||||||||||||||
8070 | while (fw && !fw->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8071 | if (fw == q) {
| 0 | ||||||||||||||||||||||||||||||||||||
8072 | q->focusNextPrevChild(true); | - | ||||||||||||||||||||||||||||||||||||
8073 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8074 | } | - | ||||||||||||||||||||||||||||||||||||
8075 | fw = fw->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8076 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8077 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8078 | - | |||||||||||||||||||||||||||||||||||||
8079 | if (QWidgetBackingStore *bs = maybeBackingStore())
| 0 | ||||||||||||||||||||||||||||||||||||
8080 | bs->removeDirtyWidget(q); never executed: bs->removeDirtyWidget(q); | 0 | ||||||||||||||||||||||||||||||||||||
8081 | - | |||||||||||||||||||||||||||||||||||||
8082 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
8083 | if (wasVisible) {
| 0 | ||||||||||||||||||||||||||||||||||||
8084 | QAccessibleEvent event(q, QAccessible::ObjectHide); | - | ||||||||||||||||||||||||||||||||||||
8085 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
8086 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8087 | #endif | - | ||||||||||||||||||||||||||||||||||||
8088 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8089 | - | |||||||||||||||||||||||||||||||||||||
8090 | void QWidgetPrivate::hide_sys() | - | ||||||||||||||||||||||||||||||||||||
8091 | { | - | ||||||||||||||||||||||||||||||||||||
8092 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8093 | - | |||||||||||||||||||||||||||||||||||||
8094 | QWindow *window = q->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
8095 | - | |||||||||||||||||||||||||||||||||||||
8096 | if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
| 0 | ||||||||||||||||||||||||||||||||||||
8097 | q->setAttribute(Qt::WA_Mapped, false); | - | ||||||||||||||||||||||||||||||||||||
8098 | // remove our window from the modal window list (native dialogs) | - | ||||||||||||||||||||||||||||||||||||
8099 | if (window && q->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
8100 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
8101 | && (!extra || !extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
8102 | #endif | - | ||||||||||||||||||||||||||||||||||||
8103 | && q->windowModality() != Qt::NonModal) {
| 0 | ||||||||||||||||||||||||||||||||||||
8104 | QGuiApplicationPrivate::hideModalWindow(window); | - | ||||||||||||||||||||||||||||||||||||
8105 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8106 | // do not return here, if window non-zero, we must hide it | - | ||||||||||||||||||||||||||||||||||||
8107 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8108 | - | |||||||||||||||||||||||||||||||||||||
8109 | deactivateWidgetCleanup(); | - | ||||||||||||||||||||||||||||||||||||
8110 | - | |||||||||||||||||||||||||||||||||||||
8111 | if (!q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8112 | QWidget *p = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8113 | if (p &&p->isVisible()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8114 | if (renderToTexture)
| 0 | ||||||||||||||||||||||||||||||||||||
8115 | p->d_func()->invalidateBuffer(q->geometry()); never executed: p->d_func()->invalidateBuffer(q->geometry()); | 0 | ||||||||||||||||||||||||||||||||||||
8116 | else | - | ||||||||||||||||||||||||||||||||||||
8117 | invalidateBuffer(q->rect()); never executed: invalidateBuffer(q->rect()); | 0 | ||||||||||||||||||||||||||||||||||||
8118 | } | - | ||||||||||||||||||||||||||||||||||||
8119 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8120 | invalidateBuffer(q->rect()); | - | ||||||||||||||||||||||||||||||||||||
8121 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8122 | - | |||||||||||||||||||||||||||||||||||||
8123 | if (window)
| 0 | ||||||||||||||||||||||||||||||||||||
8124 | window->setVisible(false); never executed: window->setVisible(false); | 0 | ||||||||||||||||||||||||||||||||||||
8125 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8126 | - | |||||||||||||||||||||||||||||||||||||
8127 | /*! | - | ||||||||||||||||||||||||||||||||||||
8128 | \fn bool QWidget::isHidden() const | - | ||||||||||||||||||||||||||||||||||||
8129 | - | |||||||||||||||||||||||||||||||||||||
8130 | Returns \c true if the widget is hidden, otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
8131 | - | |||||||||||||||||||||||||||||||||||||
8132 | A hidden widget will only become visible when show() is called on | - | ||||||||||||||||||||||||||||||||||||
8133 | it. It will not be automatically shown when the parent is shown. | - | ||||||||||||||||||||||||||||||||||||
8134 | - | |||||||||||||||||||||||||||||||||||||
8135 | To check visibility, use !isVisible() instead (notice the exclamation mark). | - | ||||||||||||||||||||||||||||||||||||
8136 | - | |||||||||||||||||||||||||||||||||||||
8137 | isHidden() implies !isVisible(), but a widget can be not visible | - | ||||||||||||||||||||||||||||||||||||
8138 | and not hidden at the same time. This is the case for widgets that are children of | - | ||||||||||||||||||||||||||||||||||||
8139 | widgets that are not visible. | - | ||||||||||||||||||||||||||||||||||||
8140 | - | |||||||||||||||||||||||||||||||||||||
8141 | - | |||||||||||||||||||||||||||||||||||||
8142 | Widgets are hidden if: | - | ||||||||||||||||||||||||||||||||||||
8143 | \list | - | ||||||||||||||||||||||||||||||||||||
8144 | \li they were created as independent windows, | - | ||||||||||||||||||||||||||||||||||||
8145 | \li they were created as children of visible widgets, | - | ||||||||||||||||||||||||||||||||||||
8146 | \li hide() or setVisible(false) was called. | - | ||||||||||||||||||||||||||||||||||||
8147 | \endlist | - | ||||||||||||||||||||||||||||||||||||
8148 | */ | - | ||||||||||||||||||||||||||||||||||||
8149 | - | |||||||||||||||||||||||||||||||||||||
8150 | - | |||||||||||||||||||||||||||||||||||||
8151 | void QWidget::setVisible(bool visible) | - | ||||||||||||||||||||||||||||||||||||
8152 | { | - | ||||||||||||||||||||||||||||||||||||
8153 | if (visible) { // show
| 0 | ||||||||||||||||||||||||||||||||||||
8154 | if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
| 0 | ||||||||||||||||||||||||||||||||||||
8155 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
8156 | - | |||||||||||||||||||||||||||||||||||||
8157 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8158 | - | |||||||||||||||||||||||||||||||||||||
8159 | // Designer uses a trick to make grabWidget work without showing | - | ||||||||||||||||||||||||||||||||||||
8160 | if (!isWindow() && parentWidget() && parentWidget()->isVisible()
| 0 | ||||||||||||||||||||||||||||||||||||
8161 | && !parentWidget()->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
8162 | parentWidget()->window()->d_func()->createRecursively(); never executed: parentWidget()->window()->d_func()->createRecursively(); | 0 | ||||||||||||||||||||||||||||||||||||
8163 | - | |||||||||||||||||||||||||||||||||||||
8164 | //create toplevels but not children of non-visible parents | - | ||||||||||||||||||||||||||||||||||||
8165 | QWidget *pw = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8166 | if (!testAttribute(Qt::WA_WState_Created)
| 0 | ||||||||||||||||||||||||||||||||||||
8167 | && (isWindow() || pw->testAttribute(Qt::WA_WState_Created))) {
| 0 | ||||||||||||||||||||||||||||||||||||
8168 | create(); | - | ||||||||||||||||||||||||||||||||||||
8169 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8170 | - | |||||||||||||||||||||||||||||||||||||
8171 | bool wasResized = testAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||||||||||||||
8172 | Qt::WindowStates initialWindowState = windowState(); | - | ||||||||||||||||||||||||||||||||||||
8173 | - | |||||||||||||||||||||||||||||||||||||
8174 | // polish if necessary | - | ||||||||||||||||||||||||||||||||||||
8175 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
8176 | - | |||||||||||||||||||||||||||||||||||||
8177 | // remember that show was called explicitly | - | ||||||||||||||||||||||||||||||||||||
8178 | setAttribute(Qt::WA_WState_ExplicitShowHide); | - | ||||||||||||||||||||||||||||||||||||
8179 | // whether we need to inform the parent widget immediately | - | ||||||||||||||||||||||||||||||||||||
8180 | bool needUpdateGeometry = !isWindow() && testAttribute(Qt::WA_WState_Hidden);
| 0 | ||||||||||||||||||||||||||||||||||||
8181 | // we are no longer hidden | - | ||||||||||||||||||||||||||||||||||||
8182 | setAttribute(Qt::WA_WState_Hidden, false); | - | ||||||||||||||||||||||||||||||||||||
8183 | - | |||||||||||||||||||||||||||||||||||||
8184 | if (needUpdateGeometry)
| 0 | ||||||||||||||||||||||||||||||||||||
8185 | d->updateGeometry_helper(true); never executed: d->updateGeometry_helper(true); | 0 | ||||||||||||||||||||||||||||||||||||
8186 | - | |||||||||||||||||||||||||||||||||||||
8187 | // activate our layout before we and our children become visible | - | ||||||||||||||||||||||||||||||||||||
8188 | if (d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
8189 | d->layout->activate(); never executed: d->layout->activate(); | 0 | ||||||||||||||||||||||||||||||||||||
8190 | - | |||||||||||||||||||||||||||||||||||||
8191 | if (!isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8192 | QWidget *parent = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8193 | while (parent && parent->isVisible() && parent->d_func()->layout && !parent->data->in_show) {
| 0 | ||||||||||||||||||||||||||||||||||||
8194 | parent->d_func()->layout->activate(); | - | ||||||||||||||||||||||||||||||||||||
8195 | if (parent->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
8196 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8197 | parent = parent->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8198 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8199 | if (parent)
| 0 | ||||||||||||||||||||||||||||||||||||
8200 | parent->d_func()->setDirtyOpaqueRegion(); never executed: parent->d_func()->setDirtyOpaqueRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
8201 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8202 | - | |||||||||||||||||||||||||||||||||||||
8203 | // adjust size if necessary | - | ||||||||||||||||||||||||||||||||||||
8204 | if (!wasResized
| 0 | ||||||||||||||||||||||||||||||||||||
8205 | && (isWindow() || !parentWidget()->d_func()->layout)) {
| 0 | ||||||||||||||||||||||||||||||||||||
8206 | if (isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8207 | adjustSize(); | - | ||||||||||||||||||||||||||||||||||||
8208 | if (windowState() != initialWindowState)
| 0 | ||||||||||||||||||||||||||||||||||||
8209 | setWindowState(initialWindowState); never executed: setWindowState(initialWindowState); | 0 | ||||||||||||||||||||||||||||||||||||
8210 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8211 | adjustSize(); | - | ||||||||||||||||||||||||||||||||||||
8212 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8213 | setAttribute(Qt::WA_Resized, false); | - | ||||||||||||||||||||||||||||||||||||
8214 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8215 | - | |||||||||||||||||||||||||||||||||||||
8216 | setAttribute(Qt::WA_KeyboardFocusChange, false); | - | ||||||||||||||||||||||||||||||||||||
8217 | - | |||||||||||||||||||||||||||||||||||||
8218 | if (isWindow() || parentWidget()->isVisible()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8219 | d->show_helper(); | - | ||||||||||||||||||||||||||||||||||||
8220 | - | |||||||||||||||||||||||||||||||||||||
8221 | qApp->d_func()->sendSyntheticEnterLeave(this); | - | ||||||||||||||||||||||||||||||||||||
8222 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8223 | - | |||||||||||||||||||||||||||||||||||||
8224 | QEvent showToParentEvent(QEvent::ShowToParent); | - | ||||||||||||||||||||||||||||||||||||
8225 | QApplication::sendEvent(this, &showToParentEvent); | - | ||||||||||||||||||||||||||||||||||||
8226 | } else { // hide never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8227 | if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
| 0 | ||||||||||||||||||||||||||||||||||||
8228 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
8229 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
8230 | // reset WS_DISABLED style in a Blocked window | - | ||||||||||||||||||||||||||||||||||||
8231 | if(isWindow() && testAttribute(Qt::WA_WState_Created) | - | ||||||||||||||||||||||||||||||||||||
8232 | && QApplicationPrivate::isBlockedByModal(this)) | - | ||||||||||||||||||||||||||||||||||||
8233 | { | - | ||||||||||||||||||||||||||||||||||||
8234 | LONG dwStyle = GetWindowLong(winId(), GWL_STYLE); | - | ||||||||||||||||||||||||||||||||||||
8235 | dwStyle &= ~WS_DISABLED; | - | ||||||||||||||||||||||||||||||||||||
8236 | SetWindowLong(winId(), GWL_STYLE, dwStyle); | - | ||||||||||||||||||||||||||||||||||||
8237 | } | - | ||||||||||||||||||||||||||||||||||||
8238 | #endif | - | ||||||||||||||||||||||||||||||||||||
8239 | if (QApplicationPrivate::hidden_focus_widget == this)
| 0 | ||||||||||||||||||||||||||||||||||||
8240 | QApplicationPrivate::hidden_focus_widget = 0; never executed: QApplicationPrivate::hidden_focus_widget = 0; | 0 | ||||||||||||||||||||||||||||||||||||
8241 | - | |||||||||||||||||||||||||||||||||||||
8242 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8243 | - | |||||||||||||||||||||||||||||||||||||
8244 | // hw: The test on getOpaqueRegion() needs to be more intelligent | - | ||||||||||||||||||||||||||||||||||||
8245 | // currently it doesn't work if the widget is hidden (the region will | - | ||||||||||||||||||||||||||||||||||||
8246 | // be clipped). The real check should be testing the cached region | - | ||||||||||||||||||||||||||||||||||||
8247 | // (and dirty flag) directly. | - | ||||||||||||||||||||||||||||||||||||
8248 | if (!isWindow() && parentWidget()) // && !d->getOpaqueRegion().isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
8249 | parentWidget()->d_func()->setDirtyOpaqueRegion(); never executed: parentWidget()->d_func()->setDirtyOpaqueRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
8250 | - | |||||||||||||||||||||||||||||||||||||
8251 | setAttribute(Qt::WA_WState_Hidden); | - | ||||||||||||||||||||||||||||||||||||
8252 | setAttribute(Qt::WA_WState_ExplicitShowHide); | - | ||||||||||||||||||||||||||||||||||||
8253 | if (testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
8254 | d->hide_helper(); never executed: d->hide_helper(); | 0 | ||||||||||||||||||||||||||||||||||||
8255 | - | |||||||||||||||||||||||||||||||||||||
8256 | // invalidate layout similar to updateGeometry() | - | ||||||||||||||||||||||||||||||||||||
8257 | if (!isWindow() && parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8258 | if (parentWidget()->d_func()->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
8259 | parentWidget()->d_func()->layout->invalidate(); never executed: parentWidget()->d_func()->layout->invalidate(); | 0 | ||||||||||||||||||||||||||||||||||||
8260 | else if (parentWidget()->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
8261 | QApplication::postEvent(parentWidget(), new QEvent(QEvent::LayoutRequest)); never executed: QApplication::postEvent(parentWidget(), new QEvent(QEvent::LayoutRequest)); | 0 | ||||||||||||||||||||||||||||||||||||
8262 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8263 | - | |||||||||||||||||||||||||||||||||||||
8264 | QEvent hideToParentEvent(QEvent::HideToParent); | - | ||||||||||||||||||||||||||||||||||||
8265 | QApplication::sendEvent(this, &hideToParentEvent); | - | ||||||||||||||||||||||||||||||||||||
8266 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8267 | } | - | ||||||||||||||||||||||||||||||||||||
8268 | - | |||||||||||||||||||||||||||||||||||||
8269 | /*! | - | ||||||||||||||||||||||||||||||||||||
8270 | Convenience function, equivalent to setVisible(!\a hidden). | - | ||||||||||||||||||||||||||||||||||||
8271 | */ | - | ||||||||||||||||||||||||||||||||||||
8272 | void QWidget::setHidden(bool hidden) | - | ||||||||||||||||||||||||||||||||||||
8273 | { | - | ||||||||||||||||||||||||||||||||||||
8274 | setVisible(!hidden); | - | ||||||||||||||||||||||||||||||||||||
8275 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8276 | - | |||||||||||||||||||||||||||||||||||||
8277 | void QWidgetPrivate::_q_showIfNotHidden() | - | ||||||||||||||||||||||||||||||||||||
8278 | { | - | ||||||||||||||||||||||||||||||||||||
8279 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8280 | if ( !(q->isHidden() && q->testAttribute(Qt::WA_WState_ExplicitShowHide)) )
| 0 | ||||||||||||||||||||||||||||||||||||
8281 | q->setVisible(true); never executed: q->setVisible(true); | 0 | ||||||||||||||||||||||||||||||||||||
8282 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8283 | - | |||||||||||||||||||||||||||||||||||||
8284 | void QWidgetPrivate::showChildren(bool spontaneous) | - | ||||||||||||||||||||||||||||||||||||
8285 | { | - | ||||||||||||||||||||||||||||||||||||
8286 | QList<QObject*> childList = children; | - | ||||||||||||||||||||||||||||||||||||
8287 | for (int i = 0; i < childList.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
8288 | QWidget *widget = qobject_cast<QWidget*>(childList.at(i)); | - | ||||||||||||||||||||||||||||||||||||
8289 | if (!widget
| 0 | ||||||||||||||||||||||||||||||||||||
8290 | || widget->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
8291 | || widget->testAttribute(Qt::WA_WState_Hidden))
| 0 | ||||||||||||||||||||||||||||||||||||
8292 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
8293 | if (spontaneous) {
| 0 | ||||||||||||||||||||||||||||||||||||
8294 | widget->setAttribute(Qt::WA_Mapped); | - | ||||||||||||||||||||||||||||||||||||
8295 | widget->d_func()->showChildren(true); | - | ||||||||||||||||||||||||||||||||||||
8296 | QShowEvent e; | - | ||||||||||||||||||||||||||||||||||||
8297 | QApplication::sendSpontaneousEvent(widget, &e); | - | ||||||||||||||||||||||||||||||||||||
8298 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8299 | if (widget->testAttribute(Qt::WA_WState_ExplicitShowHide))
| 0 | ||||||||||||||||||||||||||||||||||||
8300 | widget->d_func()->show_recursive(); never executed: widget->d_func()->show_recursive(); | 0 | ||||||||||||||||||||||||||||||||||||
8301 | else | - | ||||||||||||||||||||||||||||||||||||
8302 | widget->show(); never executed: widget->show(); | 0 | ||||||||||||||||||||||||||||||||||||
8303 | } | - | ||||||||||||||||||||||||||||||||||||
8304 | } | - | ||||||||||||||||||||||||||||||||||||
8305 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8306 | - | |||||||||||||||||||||||||||||||||||||
8307 | void QWidgetPrivate::hideChildren(bool spontaneous) | - | ||||||||||||||||||||||||||||||||||||
8308 | { | - | ||||||||||||||||||||||||||||||||||||
8309 | QList<QObject*> childList = children; | - | ||||||||||||||||||||||||||||||||||||
8310 | for (int i = 0; i < childList.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
8311 | QWidget *widget = qobject_cast<QWidget*>(childList.at(i)); | - | ||||||||||||||||||||||||||||||||||||
8312 | if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden))
| 0 | ||||||||||||||||||||||||||||||||||||
8313 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
8314 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
8315 | // Before doing anything we need to make sure that we don't leave anything in a non-consistent state. | - | ||||||||||||||||||||||||||||||||||||
8316 | // When hiding a widget we need to make sure that no mouse_down events are active, because | - | ||||||||||||||||||||||||||||||||||||
8317 | // the mouse_up event will never be received by a hidden widget or one of its descendants. | - | ||||||||||||||||||||||||||||||||||||
8318 | // The solution is simple, before going through with this we check if there are any mouse_down events in | - | ||||||||||||||||||||||||||||||||||||
8319 | // progress, if so we check if it is related to this widget or not. If so, we just reset the mouse_down and | - | ||||||||||||||||||||||||||||||||||||
8320 | // then we continue. | - | ||||||||||||||||||||||||||||||||||||
8321 | // In X11 and Windows we send a mouse_release event, however we don't do that here because we were already | - | ||||||||||||||||||||||||||||||||||||
8322 | // ignoring that from before. I.e. Carbon did not send the mouse release event, so we will not send the | - | ||||||||||||||||||||||||||||||||||||
8323 | // mouse release event. There are two ways to interpret this: | - | ||||||||||||||||||||||||||||||||||||
8324 | // 1. If we don't send the mouse release event, the widget might get into an inconsistent state, i.e. it | - | ||||||||||||||||||||||||||||||||||||
8325 | // might be waiting for a release event that will never arrive. | - | ||||||||||||||||||||||||||||||||||||
8326 | // 2. If we send the mouse release event, then the widget might decide to trigger an action that is not | - | ||||||||||||||||||||||||||||||||||||
8327 | // supposed to trigger because it is not visible. | - | ||||||||||||||||||||||||||||||||||||
8328 | if(widget == qt_button_down) | - | ||||||||||||||||||||||||||||||||||||
8329 | qt_button_down = 0; | - | ||||||||||||||||||||||||||||||||||||
8330 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
8331 | if (spontaneous)
| 0 | ||||||||||||||||||||||||||||||||||||
8332 | widget->setAttribute(Qt::WA_Mapped, false); never executed: widget->setAttribute(Qt::WA_Mapped, false); | 0 | ||||||||||||||||||||||||||||||||||||
8333 | else | - | ||||||||||||||||||||||||||||||||||||
8334 | widget->setAttribute(Qt::WA_WState_Visible, false); never executed: widget->setAttribute(Qt::WA_WState_Visible, false); | 0 | ||||||||||||||||||||||||||||||||||||
8335 | widget->d_func()->hideChildren(spontaneous); | - | ||||||||||||||||||||||||||||||||||||
8336 | QHideEvent e; | - | ||||||||||||||||||||||||||||||||||||
8337 | if (spontaneous) {
| 0 | ||||||||||||||||||||||||||||||||||||
8338 | QApplication::sendSpontaneousEvent(widget, &e); | - | ||||||||||||||||||||||||||||||||||||
8339 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8340 | QApplication::sendEvent(widget, &e); | - | ||||||||||||||||||||||||||||||||||||
8341 | if (widget->internalWinId()
| 0 | ||||||||||||||||||||||||||||||||||||
8342 | && widget->testAttribute(Qt::WA_DontCreateNativeAncestors)) {
| 0 | ||||||||||||||||||||||||||||||||||||
8343 | // hide_sys() on an ancestor won't have any affect on this | - | ||||||||||||||||||||||||||||||||||||
8344 | // widget, so it needs an explicit hide_sys() of its own | - | ||||||||||||||||||||||||||||||||||||
8345 | widget->d_func()->hide_sys(); | - | ||||||||||||||||||||||||||||||||||||
8346 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8347 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8348 | qApp->d_func()->sendSyntheticEnterLeave(widget); | - | ||||||||||||||||||||||||||||||||||||
8349 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
8350 | if (!spontaneous) {
| 0 | ||||||||||||||||||||||||||||||||||||
8351 | QAccessibleEvent event(widget, QAccessible::ObjectHide); | - | ||||||||||||||||||||||||||||||||||||
8352 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
8353 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8354 | #endif | - | ||||||||||||||||||||||||||||||||||||
8355 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8356 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8357 | - | |||||||||||||||||||||||||||||||||||||
8358 | bool QWidgetPrivate::close_helper(CloseMode mode) | - | ||||||||||||||||||||||||||||||||||||
8359 | { | - | ||||||||||||||||||||||||||||||||||||
8360 | if (data.is_closing)
| 0 | ||||||||||||||||||||||||||||||||||||
8361 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
8362 | - | |||||||||||||||||||||||||||||||||||||
8363 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8364 | data.is_closing = 1; | - | ||||||||||||||||||||||||||||||||||||
8365 | - | |||||||||||||||||||||||||||||||||||||
8366 | QPointer<QWidget> that = q; | - | ||||||||||||||||||||||||||||||||||||
8367 | QPointer<QWidget> parentWidget = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8368 | - | |||||||||||||||||||||||||||||||||||||
8369 | bool quitOnClose = q->testAttribute(Qt::WA_QuitOnClose); | - | ||||||||||||||||||||||||||||||||||||
8370 | if (mode != CloseNoEvent) {
| 0 | ||||||||||||||||||||||||||||||||||||
8371 | QCloseEvent e; | - | ||||||||||||||||||||||||||||||||||||
8372 | if (mode == CloseWithSpontaneousEvent)
| 0 | ||||||||||||||||||||||||||||||||||||
8373 | QApplication::sendSpontaneousEvent(q, &e); never executed: QApplication::sendSpontaneousEvent(q, &e); | 0 | ||||||||||||||||||||||||||||||||||||
8374 | else | - | ||||||||||||||||||||||||||||||||||||
8375 | QApplication::sendEvent(q, &e); never executed: QApplication::sendEvent(q, &e); | 0 | ||||||||||||||||||||||||||||||||||||
8376 | if (!that.isNull() && !e.isAccepted()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8377 | data.is_closing = 0; | - | ||||||||||||||||||||||||||||||||||||
8378 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
8379 | } | - | ||||||||||||||||||||||||||||||||||||
8380 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8381 | - | |||||||||||||||||||||||||||||||||||||
8382 | if (!that.isNull() && !q->isHidden())
| 0 | ||||||||||||||||||||||||||||||||||||
8383 | q->hide(); never executed: q->hide(); | 0 | ||||||||||||||||||||||||||||||||||||
8384 | - | |||||||||||||||||||||||||||||||||||||
8385 | // Attempt to close the application only if this has WA_QuitOnClose set and a non-visible parent | - | ||||||||||||||||||||||||||||||||||||
8386 | quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible());
| 0 | ||||||||||||||||||||||||||||||||||||
8387 | - | |||||||||||||||||||||||||||||||||||||
8388 | if (quitOnClose) {
| 0 | ||||||||||||||||||||||||||||||||||||
8389 | /* if there is no non-withdrawn primary window left (except | - | ||||||||||||||||||||||||||||||||||||
8390 | the ones without QuitOnClose), we emit the lastWindowClosed | - | ||||||||||||||||||||||||||||||||||||
8391 | signal */ | - | ||||||||||||||||||||||||||||||||||||
8392 | QWidgetList list = QApplication::topLevelWidgets(); | - | ||||||||||||||||||||||||||||||||||||
8393 | bool lastWindowClosed = true; | - | ||||||||||||||||||||||||||||||||||||
8394 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
8395 | QWidget *w = list.at(i); | - | ||||||||||||||||||||||||||||||||||||
8396 | if (!w->isVisible() || w->parentWidget() || !w->testAttribute(Qt::WA_QuitOnClose))
| 0 | ||||||||||||||||||||||||||||||||||||
8397 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
8398 | lastWindowClosed = false; | - | ||||||||||||||||||||||||||||||||||||
8399 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8400 | } | - | ||||||||||||||||||||||||||||||||||||
8401 | if (lastWindowClosed) {
| 0 | ||||||||||||||||||||||||||||||||||||
8402 | QGuiApplicationPrivate::emitLastWindowClosed(); | - | ||||||||||||||||||||||||||||||||||||
8403 | QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance())); | - | ||||||||||||||||||||||||||||||||||||
8404 | applicationPrivate->maybeQuit(); | - | ||||||||||||||||||||||||||||||||||||
8405 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8406 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8407 | - | |||||||||||||||||||||||||||||||||||||
8408 | - | |||||||||||||||||||||||||||||||||||||
8409 | if (!that.isNull()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8410 | data.is_closing = 0; | - | ||||||||||||||||||||||||||||||||||||
8411 | if (q->testAttribute(Qt::WA_DeleteOnClose)) {
| 0 | ||||||||||||||||||||||||||||||||||||
8412 | q->setAttribute(Qt::WA_DeleteOnClose, false); | - | ||||||||||||||||||||||||||||||||||||
8413 | q->deleteLater(); | - | ||||||||||||||||||||||||||||||||||||
8414 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8415 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8416 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
8417 | } | - | ||||||||||||||||||||||||||||||||||||
8418 | - | |||||||||||||||||||||||||||||||||||||
8419 | - | |||||||||||||||||||||||||||||||||||||
8420 | /*! | - | ||||||||||||||||||||||||||||||||||||
8421 | Closes this widget. Returns \c true if the widget was closed; | - | ||||||||||||||||||||||||||||||||||||
8422 | otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
8423 | - | |||||||||||||||||||||||||||||||||||||
8424 | First it sends the widget a QCloseEvent. The widget is | - | ||||||||||||||||||||||||||||||||||||
8425 | \l{hide()}{hidden} if it \l{QEvent::accept()}{accepts} | - | ||||||||||||||||||||||||||||||||||||
8426 | the close event. If it \l{QEvent::ignore()}{ignores} | - | ||||||||||||||||||||||||||||||||||||
8427 | the event, nothing happens. The default | - | ||||||||||||||||||||||||||||||||||||
8428 | implementation of QWidget::closeEvent() accepts the close event. | - | ||||||||||||||||||||||||||||||||||||
8429 | - | |||||||||||||||||||||||||||||||||||||
8430 | If the widget has the Qt::WA_DeleteOnClose flag, the widget | - | ||||||||||||||||||||||||||||||||||||
8431 | is also deleted. A close events is delivered to the widget no | - | ||||||||||||||||||||||||||||||||||||
8432 | matter if the widget is visible or not. | - | ||||||||||||||||||||||||||||||||||||
8433 | - | |||||||||||||||||||||||||||||||||||||
8434 | The \l QApplication::lastWindowClosed() signal is emitted when the | - | ||||||||||||||||||||||||||||||||||||
8435 | last visible primary window (i.e. window with no parent) with the | - | ||||||||||||||||||||||||||||||||||||
8436 | Qt::WA_QuitOnClose attribute set is closed. By default this | - | ||||||||||||||||||||||||||||||||||||
8437 | attribute is set for all widgets except transient windows such as | - | ||||||||||||||||||||||||||||||||||||
8438 | splash screens, tool windows, and popup menus. | - | ||||||||||||||||||||||||||||||||||||
8439 | - | |||||||||||||||||||||||||||||||||||||
8440 | */ | - | ||||||||||||||||||||||||||||||||||||
8441 | - | |||||||||||||||||||||||||||||||||||||
8442 | bool QWidget::close() | - | ||||||||||||||||||||||||||||||||||||
8443 | { | - | ||||||||||||||||||||||||||||||||||||
8444 | return d_func()->close_helper(QWidgetPrivate::CloseWithEvent); never executed: return d_func()->close_helper(QWidgetPrivate::CloseWithEvent); | 0 | ||||||||||||||||||||||||||||||||||||
8445 | } | - | ||||||||||||||||||||||||||||||||||||
8446 | - | |||||||||||||||||||||||||||||||||||||
8447 | /*! | - | ||||||||||||||||||||||||||||||||||||
8448 | \property QWidget::visible | - | ||||||||||||||||||||||||||||||||||||
8449 | \brief whether the widget is visible | - | ||||||||||||||||||||||||||||||||||||
8450 | - | |||||||||||||||||||||||||||||||||||||
8451 | Calling setVisible(true) or show() sets the widget to visible | - | ||||||||||||||||||||||||||||||||||||
8452 | status if all its parent widgets up to the window are visible. If | - | ||||||||||||||||||||||||||||||||||||
8453 | an ancestor is not visible, the widget won't become visible until | - | ||||||||||||||||||||||||||||||||||||
8454 | all its ancestors are shown. If its size or position has changed, | - | ||||||||||||||||||||||||||||||||||||
8455 | Qt guarantees that a widget gets move and resize events just | - | ||||||||||||||||||||||||||||||||||||
8456 | before it is shown. If the widget has not been resized yet, Qt | - | ||||||||||||||||||||||||||||||||||||
8457 | will adjust the widget's size to a useful default using | - | ||||||||||||||||||||||||||||||||||||
8458 | adjustSize(). | - | ||||||||||||||||||||||||||||||||||||
8459 | - | |||||||||||||||||||||||||||||||||||||
8460 | Calling setVisible(false) or hide() hides a widget explicitly. An | - | ||||||||||||||||||||||||||||||||||||
8461 | explicitly hidden widget will never become visible, even if all | - | ||||||||||||||||||||||||||||||||||||
8462 | its ancestors become visible, unless you show it. | - | ||||||||||||||||||||||||||||||||||||
8463 | - | |||||||||||||||||||||||||||||||||||||
8464 | A widget receives show and hide events when its visibility status | - | ||||||||||||||||||||||||||||||||||||
8465 | changes. Between a hide and a show event, there is no need to | - | ||||||||||||||||||||||||||||||||||||
8466 | waste CPU cycles preparing or displaying information to the user. | - | ||||||||||||||||||||||||||||||||||||
8467 | A video application, for example, might simply stop generating new | - | ||||||||||||||||||||||||||||||||||||
8468 | frames. | - | ||||||||||||||||||||||||||||||||||||
8469 | - | |||||||||||||||||||||||||||||||||||||
8470 | A widget that happens to be obscured by other windows on the | - | ||||||||||||||||||||||||||||||||||||
8471 | screen is considered to be visible. The same applies to iconified | - | ||||||||||||||||||||||||||||||||||||
8472 | windows and windows that exist on another virtual | - | ||||||||||||||||||||||||||||||||||||
8473 | desktop (on platforms that support this concept). A widget | - | ||||||||||||||||||||||||||||||||||||
8474 | receives spontaneous show and hide events when its mapping status | - | ||||||||||||||||||||||||||||||||||||
8475 | is changed by the window system, e.g. a spontaneous hide event | - | ||||||||||||||||||||||||||||||||||||
8476 | when the user minimizes the window, and a spontaneous show event | - | ||||||||||||||||||||||||||||||||||||
8477 | when the window is restored again. | - | ||||||||||||||||||||||||||||||||||||
8478 | - | |||||||||||||||||||||||||||||||||||||
8479 | You almost never have to reimplement the setVisible() function. If | - | ||||||||||||||||||||||||||||||||||||
8480 | you need to change some settings before a widget is shown, use | - | ||||||||||||||||||||||||||||||||||||
8481 | showEvent() instead. If you need to do some delayed initialization | - | ||||||||||||||||||||||||||||||||||||
8482 | use the Polish event delivered to the event() function. | - | ||||||||||||||||||||||||||||||||||||
8483 | - | |||||||||||||||||||||||||||||||||||||
8484 | \sa show(), hide(), isHidden(), isVisibleTo(), isMinimized(), | - | ||||||||||||||||||||||||||||||||||||
8485 | showEvent(), hideEvent() | - | ||||||||||||||||||||||||||||||||||||
8486 | */ | - | ||||||||||||||||||||||||||||||||||||
8487 | - | |||||||||||||||||||||||||||||||||||||
8488 | - | |||||||||||||||||||||||||||||||||||||
8489 | /*! | - | ||||||||||||||||||||||||||||||||||||
8490 | Returns \c true if this widget would become visible if \a ancestor is | - | ||||||||||||||||||||||||||||||||||||
8491 | shown; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
8492 | - | |||||||||||||||||||||||||||||||||||||
8493 | The true case occurs if neither the widget itself nor any parent | - | ||||||||||||||||||||||||||||||||||||
8494 | up to but excluding \a ancestor has been explicitly hidden. | - | ||||||||||||||||||||||||||||||||||||
8495 | - | |||||||||||||||||||||||||||||||||||||
8496 | This function will still return true if the widget is obscured by | - | ||||||||||||||||||||||||||||||||||||
8497 | other windows on the screen, but could be physically visible if it | - | ||||||||||||||||||||||||||||||||||||
8498 | or they were to be moved. | - | ||||||||||||||||||||||||||||||||||||
8499 | - | |||||||||||||||||||||||||||||||||||||
8500 | isVisibleTo(0) is identical to isVisible(). | - | ||||||||||||||||||||||||||||||||||||
8501 | - | |||||||||||||||||||||||||||||||||||||
8502 | \sa show(), hide(), isVisible() | - | ||||||||||||||||||||||||||||||||||||
8503 | */ | - | ||||||||||||||||||||||||||||||||||||
8504 | - | |||||||||||||||||||||||||||||||||||||
8505 | bool QWidget::isVisibleTo(const QWidget *ancestor) const | - | ||||||||||||||||||||||||||||||||||||
8506 | { | - | ||||||||||||||||||||||||||||||||||||
8507 | if (!ancestor)
| 0 | ||||||||||||||||||||||||||||||||||||
8508 | return isVisible(); never executed: return isVisible(); | 0 | ||||||||||||||||||||||||||||||||||||
8509 | const QWidget * w = this; | - | ||||||||||||||||||||||||||||||||||||
8510 | while (!w->isHidden()
| 0 | ||||||||||||||||||||||||||||||||||||
8511 | && !w->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
8512 | && w->parentWidget()
| 0 | ||||||||||||||||||||||||||||||||||||
8513 | && w->parentWidget() != ancestor)
| 0 | ||||||||||||||||||||||||||||||||||||
8514 | w = w->parentWidget(); never executed: w = w->parentWidget(); | 0 | ||||||||||||||||||||||||||||||||||||
8515 | return !w->isHidden(); never executed: return !w->isHidden(); | 0 | ||||||||||||||||||||||||||||||||||||
8516 | } | - | ||||||||||||||||||||||||||||||||||||
8517 | - | |||||||||||||||||||||||||||||||||||||
8518 | - | |||||||||||||||||||||||||||||||||||||
8519 | /*! | - | ||||||||||||||||||||||||||||||||||||
8520 | Returns the unobscured region where paint events can occur. | - | ||||||||||||||||||||||||||||||||||||
8521 | - | |||||||||||||||||||||||||||||||||||||
8522 | For visible widgets, this is an approximation of the area not | - | ||||||||||||||||||||||||||||||||||||
8523 | covered by other widgets; otherwise, this is an empty region. | - | ||||||||||||||||||||||||||||||||||||
8524 | - | |||||||||||||||||||||||||||||||||||||
8525 | The repaint() function calls this function if necessary, so in | - | ||||||||||||||||||||||||||||||||||||
8526 | general you do not need to call it. | - | ||||||||||||||||||||||||||||||||||||
8527 | - | |||||||||||||||||||||||||||||||||||||
8528 | */ | - | ||||||||||||||||||||||||||||||||||||
8529 | QRegion QWidget::visibleRegion() const | - | ||||||||||||||||||||||||||||||||||||
8530 | { | - | ||||||||||||||||||||||||||||||||||||
8531 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
8532 | - | |||||||||||||||||||||||||||||||||||||
8533 | QRect clipRect = d->clipRect(); | - | ||||||||||||||||||||||||||||||||||||
8534 | if (clipRect.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
8535 | return QRegion(); never executed: return QRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
8536 | QRegion r(clipRect); | - | ||||||||||||||||||||||||||||||||||||
8537 | d->subtractOpaqueChildren(r, clipRect); | - | ||||||||||||||||||||||||||||||||||||
8538 | d->subtractOpaqueSiblings(r); | - | ||||||||||||||||||||||||||||||||||||
8539 | return r; never executed: return r; | 0 | ||||||||||||||||||||||||||||||||||||
8540 | } | - | ||||||||||||||||||||||||||||||||||||
8541 | - | |||||||||||||||||||||||||||||||||||||
8542 | - | |||||||||||||||||||||||||||||||||||||
8543 | QSize QWidgetPrivate::adjustedSize() const | - | ||||||||||||||||||||||||||||||||||||
8544 | { | - | ||||||||||||||||||||||||||||||||||||
8545 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
8546 | - | |||||||||||||||||||||||||||||||||||||
8547 | QSize s = q->sizeHint(); | - | ||||||||||||||||||||||||||||||||||||
8548 | - | |||||||||||||||||||||||||||||||||||||
8549 | if (q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8550 | Qt::Orientations exp; | - | ||||||||||||||||||||||||||||||||||||
8551 | if (layout) {
| 0 | ||||||||||||||||||||||||||||||||||||
8552 | if (layout->hasHeightForWidth())
| 0 | ||||||||||||||||||||||||||||||||||||
8553 | s.setHeight(layout->totalHeightForWidth(s.width())); never executed: s.setHeight(layout->totalHeightForWidth(s.width())); | 0 | ||||||||||||||||||||||||||||||||||||
8554 | exp = layout->expandingDirections(); | - | ||||||||||||||||||||||||||||||||||||
8555 | } else never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8556 | { | - | ||||||||||||||||||||||||||||||||||||
8557 | if (q->sizePolicy().hasHeightForWidth())
| 0 | ||||||||||||||||||||||||||||||||||||
8558 | s.setHeight(q->heightForWidth(s.width())); never executed: s.setHeight(q->heightForWidth(s.width())); | 0 | ||||||||||||||||||||||||||||||||||||
8559 | exp = q->sizePolicy().expandingDirections(); | - | ||||||||||||||||||||||||||||||||||||
8560 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8561 | if (exp & Qt::Horizontal)
| 0 | ||||||||||||||||||||||||||||||||||||
8562 | s.setWidth(qMax(s.width(), 200)); never executed: s.setWidth(qMax(s.width(), 200)); | 0 | ||||||||||||||||||||||||||||||||||||
8563 | if (exp & Qt::Vertical)
| 0 | ||||||||||||||||||||||||||||||||||||
8564 | s.setHeight(qMax(s.height(), 100)); never executed: s.setHeight(qMax(s.height(), 100)); | 0 | ||||||||||||||||||||||||||||||||||||
8565 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
8566 | QRect screen = QApplication::desktop()->screenGeometry(q->x11Info().screen()); | - | ||||||||||||||||||||||||||||||||||||
8567 | #else // all others | - | ||||||||||||||||||||||||||||||||||||
8568 | QRect screen = QApplication::desktop()->screenGeometry(q->pos()); | - | ||||||||||||||||||||||||||||||||||||
8569 | #endif | - | ||||||||||||||||||||||||||||||||||||
8570 | #if defined (Q_OS_WINCE) | - | ||||||||||||||||||||||||||||||||||||
8571 | s.setWidth(qMin(s.width(), screen.width())); | - | ||||||||||||||||||||||||||||||||||||
8572 | s.setHeight(qMin(s.height(), screen.height())); | - | ||||||||||||||||||||||||||||||||||||
8573 | #else | - | ||||||||||||||||||||||||||||||||||||
8574 | s.setWidth(qMin(s.width(), screen.width()*2/3)); | - | ||||||||||||||||||||||||||||||||||||
8575 | s.setHeight(qMin(s.height(), screen.height()*2/3)); | - | ||||||||||||||||||||||||||||||||||||
8576 | #endif | - | ||||||||||||||||||||||||||||||||||||
8577 | if (QTLWExtra *extra = maybeTopData())
| 0 | ||||||||||||||||||||||||||||||||||||
8578 | extra->sizeAdjusted = true; never executed: extra->sizeAdjusted = true; | 0 | ||||||||||||||||||||||||||||||||||||
8579 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8580 | - | |||||||||||||||||||||||||||||||||||||
8581 | if (!s.isValid()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8582 | QRect r = q->childrenRect(); // get children rectangle | - | ||||||||||||||||||||||||||||||||||||
8583 | if (r.isNull())
| 0 | ||||||||||||||||||||||||||||||||||||
8584 | return s; never executed: return s; | 0 | ||||||||||||||||||||||||||||||||||||
8585 | s = r.size() + QSize(2 * r.x(), 2 * r.y()); | - | ||||||||||||||||||||||||||||||||||||
8586 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8587 | - | |||||||||||||||||||||||||||||||||||||
8588 | return s; never executed: return s; | 0 | ||||||||||||||||||||||||||||||||||||
8589 | } | - | ||||||||||||||||||||||||||||||||||||
8590 | - | |||||||||||||||||||||||||||||||||||||
8591 | /*! | - | ||||||||||||||||||||||||||||||||||||
8592 | Adjusts the size of the widget to fit its contents. | - | ||||||||||||||||||||||||||||||||||||
8593 | - | |||||||||||||||||||||||||||||||||||||
8594 | This function uses sizeHint() if it is valid, i.e., the size hint's width | - | ||||||||||||||||||||||||||||||||||||
8595 | and height are \>= 0. Otherwise, it sets the size to the children | - | ||||||||||||||||||||||||||||||||||||
8596 | rectangle that covers all child widgets (the union of all child widget | - | ||||||||||||||||||||||||||||||||||||
8597 | rectangles). | - | ||||||||||||||||||||||||||||||||||||
8598 | - | |||||||||||||||||||||||||||||||||||||
8599 | For windows, the screen size is also taken into account. If the sizeHint() | - | ||||||||||||||||||||||||||||||||||||
8600 | is less than (200, 100) and the size policy is \l{QSizePolicy::Expanding} | - | ||||||||||||||||||||||||||||||||||||
8601 | {expanding}, the window will be at least (200, 100). The maximum size of | - | ||||||||||||||||||||||||||||||||||||
8602 | a window is 2/3 of the screen's width and height. | - | ||||||||||||||||||||||||||||||||||||
8603 | - | |||||||||||||||||||||||||||||||||||||
8604 | \sa sizeHint(), childrenRect() | - | ||||||||||||||||||||||||||||||||||||
8605 | */ | - | ||||||||||||||||||||||||||||||||||||
8606 | - | |||||||||||||||||||||||||||||||||||||
8607 | void QWidget::adjustSize() | - | ||||||||||||||||||||||||||||||||||||
8608 | { | - | ||||||||||||||||||||||||||||||||||||
8609 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8610 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
8611 | QSize s = d->adjustedSize(); | - | ||||||||||||||||||||||||||||||||||||
8612 | - | |||||||||||||||||||||||||||||||||||||
8613 | if (d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
8614 | d->layout->activate(); never executed: d->layout->activate(); | 0 | ||||||||||||||||||||||||||||||||||||
8615 | - | |||||||||||||||||||||||||||||||||||||
8616 | if (s.isValid())
| 0 | ||||||||||||||||||||||||||||||||||||
8617 | resize(s); never executed: resize(s); | 0 | ||||||||||||||||||||||||||||||||||||
8618 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8619 | - | |||||||||||||||||||||||||||||||||||||
8620 | - | |||||||||||||||||||||||||||||||||||||
8621 | /*! | - | ||||||||||||||||||||||||||||||||||||
8622 | \property QWidget::sizeHint | - | ||||||||||||||||||||||||||||||||||||
8623 | \brief the recommended size for the widget | - | ||||||||||||||||||||||||||||||||||||
8624 | - | |||||||||||||||||||||||||||||||||||||
8625 | If the value of this property is an invalid size, no size is | - | ||||||||||||||||||||||||||||||||||||
8626 | recommended. | - | ||||||||||||||||||||||||||||||||||||
8627 | - | |||||||||||||||||||||||||||||||||||||
8628 | The default implementation of sizeHint() returns an invalid size | - | ||||||||||||||||||||||||||||||||||||
8629 | if there is no layout for this widget, and returns the layout's | - | ||||||||||||||||||||||||||||||||||||
8630 | preferred size otherwise. | - | ||||||||||||||||||||||||||||||||||||
8631 | - | |||||||||||||||||||||||||||||||||||||
8632 | \sa QSize::isValid(), minimumSizeHint(), sizePolicy(), | - | ||||||||||||||||||||||||||||||||||||
8633 | setMinimumSize(), updateGeometry() | - | ||||||||||||||||||||||||||||||||||||
8634 | */ | - | ||||||||||||||||||||||||||||||||||||
8635 | - | |||||||||||||||||||||||||||||||||||||
8636 | QSize QWidget::sizeHint() const | - | ||||||||||||||||||||||||||||||||||||
8637 | { | - | ||||||||||||||||||||||||||||||||||||
8638 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
8639 | if (d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
8640 | return d->layout->totalSizeHint(); never executed: return d->layout->totalSizeHint(); | 0 | ||||||||||||||||||||||||||||||||||||
8641 | return QSize(-1, -1); never executed: return QSize(-1, -1); | 0 | ||||||||||||||||||||||||||||||||||||
8642 | } | - | ||||||||||||||||||||||||||||||||||||
8643 | - | |||||||||||||||||||||||||||||||||||||
8644 | /*! | - | ||||||||||||||||||||||||||||||||||||
8645 | \property QWidget::minimumSizeHint | - | ||||||||||||||||||||||||||||||||||||
8646 | \brief the recommended minimum size for the widget | - | ||||||||||||||||||||||||||||||||||||
8647 | - | |||||||||||||||||||||||||||||||||||||
8648 | If the value of this property is an invalid size, no minimum size | - | ||||||||||||||||||||||||||||||||||||
8649 | is recommended. | - | ||||||||||||||||||||||||||||||||||||
8650 | - | |||||||||||||||||||||||||||||||||||||
8651 | The default implementation of minimumSizeHint() returns an invalid | - | ||||||||||||||||||||||||||||||||||||
8652 | size if there is no layout for this widget, and returns the | - | ||||||||||||||||||||||||||||||||||||
8653 | layout's minimum size otherwise. Most built-in widgets reimplement | - | ||||||||||||||||||||||||||||||||||||
8654 | minimumSizeHint(). | - | ||||||||||||||||||||||||||||||||||||
8655 | - | |||||||||||||||||||||||||||||||||||||
8656 | \l QLayout will never resize a widget to a size smaller than the | - | ||||||||||||||||||||||||||||||||||||
8657 | minimum size hint unless minimumSize() is set or the size policy is | - | ||||||||||||||||||||||||||||||||||||
8658 | set to QSizePolicy::Ignore. If minimumSize() is set, the minimum | - | ||||||||||||||||||||||||||||||||||||
8659 | size hint will be ignored. | - | ||||||||||||||||||||||||||||||||||||
8660 | - | |||||||||||||||||||||||||||||||||||||
8661 | \sa QSize::isValid(), resize(), setMinimumSize(), sizePolicy() | - | ||||||||||||||||||||||||||||||||||||
8662 | */ | - | ||||||||||||||||||||||||||||||||||||
8663 | QSize QWidget::minimumSizeHint() const | - | ||||||||||||||||||||||||||||||||||||
8664 | { | - | ||||||||||||||||||||||||||||||||||||
8665 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
8666 | if (d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
8667 | return d->layout->totalMinimumSize(); never executed: return d->layout->totalMinimumSize(); | 0 | ||||||||||||||||||||||||||||||||||||
8668 | return QSize(-1, -1); never executed: return QSize(-1, -1); | 0 | ||||||||||||||||||||||||||||||||||||
8669 | } | - | ||||||||||||||||||||||||||||||||||||
8670 | - | |||||||||||||||||||||||||||||||||||||
8671 | - | |||||||||||||||||||||||||||||||||||||
8672 | /*! | - | ||||||||||||||||||||||||||||||||||||
8673 | \fn QWidget *QWidget::parentWidget() const | - | ||||||||||||||||||||||||||||||||||||
8674 | - | |||||||||||||||||||||||||||||||||||||
8675 | Returns the parent of this widget, or 0 if it does not have any | - | ||||||||||||||||||||||||||||||||||||
8676 | parent widget. | - | ||||||||||||||||||||||||||||||||||||
8677 | */ | - | ||||||||||||||||||||||||||||||||||||
8678 | - | |||||||||||||||||||||||||||||||||||||
8679 | - | |||||||||||||||||||||||||||||||||||||
8680 | /*! | - | ||||||||||||||||||||||||||||||||||||
8681 | Returns \c true if this widget is a parent, (or grandparent and so on | - | ||||||||||||||||||||||||||||||||||||
8682 | to any level), of the given \a child, and both widgets are within | - | ||||||||||||||||||||||||||||||||||||
8683 | the same window; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
8684 | */ | - | ||||||||||||||||||||||||||||||||||||
8685 | - | |||||||||||||||||||||||||||||||||||||
8686 | bool QWidget::isAncestorOf(const QWidget *child) const | - | ||||||||||||||||||||||||||||||||||||
8687 | { | - | ||||||||||||||||||||||||||||||||||||
8688 | while (child) {
| 0 | ||||||||||||||||||||||||||||||||||||
8689 | if (child == this)
| 0 | ||||||||||||||||||||||||||||||||||||
8690 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
8691 | if (child->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
8692 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
8693 | child = child->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8694 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8695 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
8696 | } | - | ||||||||||||||||||||||||||||||||||||
8697 | - | |||||||||||||||||||||||||||||||||||||
8698 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
8699 | inline void setDisabledStyle(QWidget *w, bool setStyle) | - | ||||||||||||||||||||||||||||||||||||
8700 | { | - | ||||||||||||||||||||||||||||||||||||
8701 | // set/reset WS_DISABLED style. | - | ||||||||||||||||||||||||||||||||||||
8702 | if(w && w->isWindow() && w->isVisible() && w->isEnabled()) { | - | ||||||||||||||||||||||||||||||||||||
8703 | LONG dwStyle = GetWindowLong(w->winId(), GWL_STYLE); | - | ||||||||||||||||||||||||||||||||||||
8704 | LONG newStyle = dwStyle; | - | ||||||||||||||||||||||||||||||||||||
8705 | if (setStyle) | - | ||||||||||||||||||||||||||||||||||||
8706 | newStyle |= WS_DISABLED; | - | ||||||||||||||||||||||||||||||||||||
8707 | else | - | ||||||||||||||||||||||||||||||||||||
8708 | newStyle &= ~WS_DISABLED; | - | ||||||||||||||||||||||||||||||||||||
8709 | if (newStyle != dwStyle) { | - | ||||||||||||||||||||||||||||||||||||
8710 | SetWindowLong(w->winId(), GWL_STYLE, newStyle); | - | ||||||||||||||||||||||||||||||||||||
8711 | // we might need to repaint in some situations (eg. menu) | - | ||||||||||||||||||||||||||||||||||||
8712 | w->repaint(); | - | ||||||||||||||||||||||||||||||||||||
8713 | } | - | ||||||||||||||||||||||||||||||||||||
8714 | } | - | ||||||||||||||||||||||||||||||||||||
8715 | } | - | ||||||||||||||||||||||||||||||||||||
8716 | #endif | - | ||||||||||||||||||||||||||||||||||||
8717 | - | |||||||||||||||||||||||||||||||||||||
8718 | /***************************************************************************** | - | ||||||||||||||||||||||||||||||||||||
8719 | QWidget event handling | - | ||||||||||||||||||||||||||||||||||||
8720 | *****************************************************************************/ | - | ||||||||||||||||||||||||||||||||||||
8721 | - | |||||||||||||||||||||||||||||||||||||
8722 | /*! | - | ||||||||||||||||||||||||||||||||||||
8723 | This is the main event handler; it handles event \a event. You can | - | ||||||||||||||||||||||||||||||||||||
8724 | reimplement this function in a subclass, but we recommend using | - | ||||||||||||||||||||||||||||||||||||
8725 | one of the specialized event handlers instead. | - | ||||||||||||||||||||||||||||||||||||
8726 | - | |||||||||||||||||||||||||||||||||||||
8727 | Key press and release events are treated differently from other | - | ||||||||||||||||||||||||||||||||||||
8728 | events. event() checks for Tab and Shift+Tab and tries to move the | - | ||||||||||||||||||||||||||||||||||||
8729 | focus appropriately. If there is no widget to move the focus to | - | ||||||||||||||||||||||||||||||||||||
8730 | (or the key press is not Tab or Shift+Tab), event() calls | - | ||||||||||||||||||||||||||||||||||||
8731 | keyPressEvent(). | - | ||||||||||||||||||||||||||||||||||||
8732 | - | |||||||||||||||||||||||||||||||||||||
8733 | Mouse and tablet event handling is also slightly special: only | - | ||||||||||||||||||||||||||||||||||||
8734 | when the widget is \l enabled, event() will call the specialized | - | ||||||||||||||||||||||||||||||||||||
8735 | handlers such as mousePressEvent(); otherwise it will discard the | - | ||||||||||||||||||||||||||||||||||||
8736 | event. | - | ||||||||||||||||||||||||||||||||||||
8737 | - | |||||||||||||||||||||||||||||||||||||
8738 | This function returns \c true if the event was recognized, otherwise | - | ||||||||||||||||||||||||||||||||||||
8739 | it returns \c false. If the recognized event was accepted (see \l | - | ||||||||||||||||||||||||||||||||||||
8740 | QEvent::accepted), any further processing such as event | - | ||||||||||||||||||||||||||||||||||||
8741 | propagation to the parent widget stops. | - | ||||||||||||||||||||||||||||||||||||
8742 | - | |||||||||||||||||||||||||||||||||||||
8743 | \sa closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(), | - | ||||||||||||||||||||||||||||||||||||
8744 | keyPressEvent(), keyReleaseEvent(), leaveEvent(), | - | ||||||||||||||||||||||||||||||||||||
8745 | mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), | - | ||||||||||||||||||||||||||||||||||||
8746 | mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent(), | - | ||||||||||||||||||||||||||||||||||||
8747 | QObject::event(), QObject::timerEvent() | - | ||||||||||||||||||||||||||||||||||||
8748 | */ | - | ||||||||||||||||||||||||||||||||||||
8749 | - | |||||||||||||||||||||||||||||||||||||
8750 | bool QWidget::event(QEvent *event) | - | ||||||||||||||||||||||||||||||||||||
8751 | { | - | ||||||||||||||||||||||||||||||||||||
8752 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8753 | - | |||||||||||||||||||||||||||||||||||||
8754 | // ignore mouse and key events when disabled | - | ||||||||||||||||||||||||||||||||||||
8755 | if (!isEnabled()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8756 | switch(event->type()) { | - | ||||||||||||||||||||||||||||||||||||
8757 | case QEvent::TabletPress: never executed: case QEvent::TabletPress: | 0 | ||||||||||||||||||||||||||||||||||||
8758 | case QEvent::TabletRelease: never executed: case QEvent::TabletRelease: | 0 | ||||||||||||||||||||||||||||||||||||
8759 | case QEvent::TabletMove: never executed: case QEvent::TabletMove: | 0 | ||||||||||||||||||||||||||||||||||||
8760 | case QEvent::MouseButtonPress: never executed: case QEvent::MouseButtonPress: | 0 | ||||||||||||||||||||||||||||||||||||
8761 | case QEvent::MouseButtonRelease: never executed: case QEvent::MouseButtonRelease: | 0 | ||||||||||||||||||||||||||||||||||||
8762 | case QEvent::MouseButtonDblClick: never executed: case QEvent::MouseButtonDblClick: | 0 | ||||||||||||||||||||||||||||||||||||
8763 | case QEvent::MouseMove: never executed: case QEvent::MouseMove: | 0 | ||||||||||||||||||||||||||||||||||||
8764 | case QEvent::TouchBegin: never executed: case QEvent::TouchBegin: | 0 | ||||||||||||||||||||||||||||||||||||
8765 | case QEvent::TouchUpdate: never executed: case QEvent::TouchUpdate: | 0 | ||||||||||||||||||||||||||||||||||||
8766 | case QEvent::TouchEnd: never executed: case QEvent::TouchEnd: | 0 | ||||||||||||||||||||||||||||||||||||
8767 | case QEvent::TouchCancel: never executed: case QEvent::TouchCancel: | 0 | ||||||||||||||||||||||||||||||||||||
8768 | case QEvent::ContextMenu: never executed: case QEvent::ContextMenu: | 0 | ||||||||||||||||||||||||||||||||||||
8769 | case QEvent::KeyPress: never executed: case QEvent::KeyPress: | 0 | ||||||||||||||||||||||||||||||||||||
8770 | case QEvent::KeyRelease: never executed: case QEvent::KeyRelease: | 0 | ||||||||||||||||||||||||||||||||||||
8771 | #ifndef QT_NO_WHEELEVENT | - | ||||||||||||||||||||||||||||||||||||
8772 | case QEvent::Wheel: never executed: case QEvent::Wheel: | 0 | ||||||||||||||||||||||||||||||||||||
8773 | #endif | - | ||||||||||||||||||||||||||||||||||||
8774 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
8775 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
8776 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8777 | } | - | ||||||||||||||||||||||||||||||||||||
8778 | } | - | ||||||||||||||||||||||||||||||||||||
8779 | switch (event->type()) { | - | ||||||||||||||||||||||||||||||||||||
8780 | case QEvent::MouseMove: never executed: case QEvent::MouseMove: | 0 | ||||||||||||||||||||||||||||||||||||
8781 | mouseMoveEvent((QMouseEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8782 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8783 | - | |||||||||||||||||||||||||||||||||||||
8784 | case QEvent::MouseButtonPress: never executed: case QEvent::MouseButtonPress: | 0 | ||||||||||||||||||||||||||||||||||||
8785 | mousePressEvent((QMouseEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8786 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8787 | - | |||||||||||||||||||||||||||||||||||||
8788 | case QEvent::MouseButtonRelease: never executed: case QEvent::MouseButtonRelease: | 0 | ||||||||||||||||||||||||||||||||||||
8789 | mouseReleaseEvent((QMouseEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8790 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8791 | - | |||||||||||||||||||||||||||||||||||||
8792 | case QEvent::MouseButtonDblClick: never executed: case QEvent::MouseButtonDblClick: | 0 | ||||||||||||||||||||||||||||||||||||
8793 | mouseDoubleClickEvent((QMouseEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8794 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8795 | #ifndef QT_NO_WHEELEVENT | - | ||||||||||||||||||||||||||||||||||||
8796 | case QEvent::Wheel: never executed: case QEvent::Wheel: | 0 | ||||||||||||||||||||||||||||||||||||
8797 | wheelEvent((QWheelEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8798 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8799 | #endif | - | ||||||||||||||||||||||||||||||||||||
8800 | #ifndef QT_NO_TABLETEVENT | - | ||||||||||||||||||||||||||||||||||||
8801 | case QEvent::TabletMove: never executed: case QEvent::TabletMove: | 0 | ||||||||||||||||||||||||||||||||||||
8802 | case QEvent::TabletPress: never executed: case QEvent::TabletPress: | 0 | ||||||||||||||||||||||||||||||||||||
8803 | case QEvent::TabletRelease: never executed: case QEvent::TabletRelease: | 0 | ||||||||||||||||||||||||||||||||||||
8804 | tabletEvent((QTabletEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8805 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8806 | #endif | - | ||||||||||||||||||||||||||||||||||||
8807 | case QEvent::KeyPress: { never executed: case QEvent::KeyPress: | 0 | ||||||||||||||||||||||||||||||||||||
8808 | QKeyEvent *k = (QKeyEvent *)event; | - | ||||||||||||||||||||||||||||||||||||
8809 | bool res = false; | - | ||||||||||||||||||||||||||||||||||||
8810 | if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
| 0 | ||||||||||||||||||||||||||||||||||||
8811 | if (k->key() == Qt::Key_Backtab
| 0 | ||||||||||||||||||||||||||||||||||||
8812 | || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier)))
| 0 | ||||||||||||||||||||||||||||||||||||
8813 | res = focusNextPrevChild(false); never executed: res = focusNextPrevChild(false); | 0 | ||||||||||||||||||||||||||||||||||||
8814 | else if (k->key() == Qt::Key_Tab)
| 0 | ||||||||||||||||||||||||||||||||||||
8815 | res = focusNextPrevChild(true); never executed: res = focusNextPrevChild(true); | 0 | ||||||||||||||||||||||||||||||||||||
8816 | if (res)
| 0 | ||||||||||||||||||||||||||||||||||||
8817 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8818 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8819 | keyPressEvent(k); | - | ||||||||||||||||||||||||||||||||||||
8820 | #ifdef QT_KEYPAD_NAVIGATION | - | ||||||||||||||||||||||||||||||||||||
8821 | if (!k->isAccepted() && QApplication::keypadNavigationEnabled() | - | ||||||||||||||||||||||||||||||||||||
8822 | && !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::ShiftModifier))) { | - | ||||||||||||||||||||||||||||||||||||
8823 | if (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder) { | - | ||||||||||||||||||||||||||||||||||||
8824 | if (k->key() == Qt::Key_Up) | - | ||||||||||||||||||||||||||||||||||||
8825 | res = focusNextPrevChild(false); | - | ||||||||||||||||||||||||||||||||||||
8826 | else if (k->key() == Qt::Key_Down) | - | ||||||||||||||||||||||||||||||||||||
8827 | res = focusNextPrevChild(true); | - | ||||||||||||||||||||||||||||||||||||
8828 | } else if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) { | - | ||||||||||||||||||||||||||||||||||||
8829 | if (k->key() == Qt::Key_Up) | - | ||||||||||||||||||||||||||||||||||||
8830 | res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionNorth); | - | ||||||||||||||||||||||||||||||||||||
8831 | else if (k->key() == Qt::Key_Right) | - | ||||||||||||||||||||||||||||||||||||
8832 | res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionEast); | - | ||||||||||||||||||||||||||||||||||||
8833 | else if (k->key() == Qt::Key_Down) | - | ||||||||||||||||||||||||||||||||||||
8834 | res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionSouth); | - | ||||||||||||||||||||||||||||||||||||
8835 | else if (k->key() == Qt::Key_Left) | - | ||||||||||||||||||||||||||||||||||||
8836 | res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionWest); | - | ||||||||||||||||||||||||||||||||||||
8837 | } | - | ||||||||||||||||||||||||||||||||||||
8838 | if (res) { | - | ||||||||||||||||||||||||||||||||||||
8839 | k->accept(); | - | ||||||||||||||||||||||||||||||||||||
8840 | break; | - | ||||||||||||||||||||||||||||||||||||
8841 | } | - | ||||||||||||||||||||||||||||||||||||
8842 | } | - | ||||||||||||||||||||||||||||||||||||
8843 | #endif | - | ||||||||||||||||||||||||||||||||||||
8844 | #ifndef QT_NO_WHATSTHIS | - | ||||||||||||||||||||||||||||||||||||
8845 | if (!k->isAccepted()
| 0 | ||||||||||||||||||||||||||||||||||||
8846 | && k->modifiers() & Qt::ShiftModifier && k->key() == Qt::Key_F1
| 0 | ||||||||||||||||||||||||||||||||||||
8847 | && d->whatsThis.size()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8848 | QWhatsThis::showText(mapToGlobal(inputMethodQuery(Qt::ImCursorRectangle).toRect().center()), d->whatsThis, this); | - | ||||||||||||||||||||||||||||||||||||
8849 | k->accept(); | - | ||||||||||||||||||||||||||||||||||||
8850 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8851 | #endif | - | ||||||||||||||||||||||||||||||||||||
8852 | } | - | ||||||||||||||||||||||||||||||||||||
8853 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8854 | - | |||||||||||||||||||||||||||||||||||||
8855 | case QEvent::KeyRelease: never executed: case QEvent::KeyRelease: | 0 | ||||||||||||||||||||||||||||||||||||
8856 | keyReleaseEvent((QKeyEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8857 | // fall through | - | ||||||||||||||||||||||||||||||||||||
8858 | case QEvent::ShortcutOverride: code before this statement never executed: case QEvent::ShortcutOverride: never executed: case QEvent::ShortcutOverride: | 0 | ||||||||||||||||||||||||||||||||||||
8859 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8860 | - | |||||||||||||||||||||||||||||||||||||
8861 | case QEvent::InputMethod: never executed: case QEvent::InputMethod: | 0 | ||||||||||||||||||||||||||||||||||||
8862 | inputMethodEvent((QInputMethodEvent *) event); | - | ||||||||||||||||||||||||||||||||||||
8863 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8864 | - | |||||||||||||||||||||||||||||||||||||
8865 | case QEvent::InputMethodQuery: never executed: case QEvent::InputMethodQuery: | 0 | ||||||||||||||||||||||||||||||||||||
8866 | if (testAttribute(Qt::WA_InputMethodEnabled)) {
| 0 | ||||||||||||||||||||||||||||||||||||
8867 | QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(event); | - | ||||||||||||||||||||||||||||||||||||
8868 | Qt::InputMethodQueries queries = query->queries(); | - | ||||||||||||||||||||||||||||||||||||
8869 | for (uint i = 0; i < 32; ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
8870 | Qt::InputMethodQuery q = (Qt::InputMethodQuery)(int)(queries & (1<<i)); | - | ||||||||||||||||||||||||||||||||||||
8871 | if (q) {
| 0 | ||||||||||||||||||||||||||||||||||||
8872 | QVariant v = inputMethodQuery(q); | - | ||||||||||||||||||||||||||||||||||||
8873 | if (q == Qt::ImEnabled && !v.isValid() && isEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
8874 | v = QVariant(true); // special case for Qt4 compatibility never executed: v = QVariant(true); | 0 | ||||||||||||||||||||||||||||||||||||
8875 | query->setValue(q, v); | - | ||||||||||||||||||||||||||||||||||||
8876 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8877 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8878 | query->accept(); | - | ||||||||||||||||||||||||||||||||||||
8879 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8880 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8881 | - | |||||||||||||||||||||||||||||||||||||
8882 | case QEvent::PolishRequest: never executed: case QEvent::PolishRequest: | 0 | ||||||||||||||||||||||||||||||||||||
8883 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
8884 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8885 | - | |||||||||||||||||||||||||||||||||||||
8886 | case QEvent::Polish: { never executed: case QEvent::Polish: | 0 | ||||||||||||||||||||||||||||||||||||
8887 | style()->polish(this); | - | ||||||||||||||||||||||||||||||||||||
8888 | setAttribute(Qt::WA_WState_Polished); | - | ||||||||||||||||||||||||||||||||||||
8889 | if (!QApplication::font(this).isCopyOf(QApplication::font()))
| 0 | ||||||||||||||||||||||||||||||||||||
8890 | d->resolveFont(); never executed: d->resolveFont(); | 0 | ||||||||||||||||||||||||||||||||||||
8891 | if (!QApplication::palette(this).isCopyOf(QApplication::palette()))
| 0 | ||||||||||||||||||||||||||||||||||||
8892 | d->resolvePalette(); never executed: d->resolvePalette(); | 0 | ||||||||||||||||||||||||||||||||||||
8893 | } | - | ||||||||||||||||||||||||||||||||||||
8894 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8895 | - | |||||||||||||||||||||||||||||||||||||
8896 | case QEvent::ApplicationWindowIconChange: never executed: case QEvent::ApplicationWindowIconChange: | 0 | ||||||||||||||||||||||||||||||||||||
8897 | if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon)) {
| 0 | ||||||||||||||||||||||||||||||||||||
8898 | d->setWindowIcon_sys(); | - | ||||||||||||||||||||||||||||||||||||
8899 | d->setWindowIcon_helper(); | - | ||||||||||||||||||||||||||||||||||||
8900 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8901 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8902 | case QEvent::FocusIn: never executed: case QEvent::FocusIn: | 0 | ||||||||||||||||||||||||||||||||||||
8903 | focusInEvent((QFocusEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8904 | d->updateWidgetTransform(event); | - | ||||||||||||||||||||||||||||||||||||
8905 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8906 | - | |||||||||||||||||||||||||||||||||||||
8907 | case QEvent::FocusOut: never executed: case QEvent::FocusOut: | 0 | ||||||||||||||||||||||||||||||||||||
8908 | focusOutEvent((QFocusEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8909 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8910 | - | |||||||||||||||||||||||||||||||||||||
8911 | case QEvent::Enter: never executed: case QEvent::Enter: | 0 | ||||||||||||||||||||||||||||||||||||
8912 | #ifndef QT_NO_STATUSTIP | - | ||||||||||||||||||||||||||||||||||||
8913 | if (d->statusTip.size()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8914 | QStatusTipEvent tip(d->statusTip); | - | ||||||||||||||||||||||||||||||||||||
8915 | QApplication::sendEvent(const_cast<QWidget *>(this), &tip); | - | ||||||||||||||||||||||||||||||||||||
8916 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8917 | #endif | - | ||||||||||||||||||||||||||||||||||||
8918 | enterEvent(event); | - | ||||||||||||||||||||||||||||||||||||
8919 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8920 | - | |||||||||||||||||||||||||||||||||||||
8921 | case QEvent::Leave: never executed: case QEvent::Leave: | 0 | ||||||||||||||||||||||||||||||||||||
8922 | #ifndef QT_NO_STATUSTIP | - | ||||||||||||||||||||||||||||||||||||
8923 | if (d->statusTip.size()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8924 | QString empty; | - | ||||||||||||||||||||||||||||||||||||
8925 | QStatusTipEvent tip(empty); | - | ||||||||||||||||||||||||||||||||||||
8926 | QApplication::sendEvent(const_cast<QWidget *>(this), &tip); | - | ||||||||||||||||||||||||||||||||||||
8927 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8928 | #endif | - | ||||||||||||||||||||||||||||||||||||
8929 | leaveEvent(event); | - | ||||||||||||||||||||||||||||||||||||
8930 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8931 | - | |||||||||||||||||||||||||||||||||||||
8932 | case QEvent::HoverEnter: never executed: case QEvent::HoverEnter: | 0 | ||||||||||||||||||||||||||||||||||||
8933 | case QEvent::HoverLeave: never executed: case QEvent::HoverLeave: | 0 | ||||||||||||||||||||||||||||||||||||
8934 | update(); | - | ||||||||||||||||||||||||||||||||||||
8935 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8936 | - | |||||||||||||||||||||||||||||||||||||
8937 | case QEvent::Paint: never executed: case QEvent::Paint: | 0 | ||||||||||||||||||||||||||||||||||||
8938 | // At this point the event has to be delivered, regardless | - | ||||||||||||||||||||||||||||||||||||
8939 | // whether the widget isVisible() or not because it | - | ||||||||||||||||||||||||||||||||||||
8940 | // already went through the filters | - | ||||||||||||||||||||||||||||||||||||
8941 | paintEvent((QPaintEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8942 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8943 | - | |||||||||||||||||||||||||||||||||||||
8944 | case QEvent::Move: never executed: case QEvent::Move: | 0 | ||||||||||||||||||||||||||||||||||||
8945 | moveEvent((QMoveEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8946 | d->updateWidgetTransform(event); | - | ||||||||||||||||||||||||||||||||||||
8947 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8948 | - | |||||||||||||||||||||||||||||||||||||
8949 | case QEvent::Resize: never executed: case QEvent::Resize: | 0 | ||||||||||||||||||||||||||||||||||||
8950 | resizeEvent((QResizeEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8951 | d->updateWidgetTransform(event); | - | ||||||||||||||||||||||||||||||||||||
8952 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8953 | - | |||||||||||||||||||||||||||||||||||||
8954 | case QEvent::Close: never executed: case QEvent::Close: | 0 | ||||||||||||||||||||||||||||||||||||
8955 | closeEvent((QCloseEvent *)event); | - | ||||||||||||||||||||||||||||||||||||
8956 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8957 | - | |||||||||||||||||||||||||||||||||||||
8958 | #ifndef QT_NO_CONTEXTMENU | - | ||||||||||||||||||||||||||||||||||||
8959 | case QEvent::ContextMenu: never executed: case QEvent::ContextMenu: | 0 | ||||||||||||||||||||||||||||||||||||
8960 | switch (data->context_menu_policy) { | - | ||||||||||||||||||||||||||||||||||||
8961 | case Qt::PreventContextMenu: never executed: case Qt::PreventContextMenu: | 0 | ||||||||||||||||||||||||||||||||||||
8962 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8963 | case Qt::DefaultContextMenu: never executed: case Qt::DefaultContextMenu: | 0 | ||||||||||||||||||||||||||||||||||||
8964 | contextMenuEvent(static_cast<QContextMenuEvent *>(event)); | - | ||||||||||||||||||||||||||||||||||||
8965 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8966 | case Qt::CustomContextMenu: never executed: case Qt::CustomContextMenu: | 0 | ||||||||||||||||||||||||||||||||||||
8967 | emit customContextMenuRequested(static_cast<QContextMenuEvent *>(event)->pos()); | - | ||||||||||||||||||||||||||||||||||||
8968 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8969 | #ifndef QT_NO_MENU | - | ||||||||||||||||||||||||||||||||||||
8970 | case Qt::ActionsContextMenu: never executed: case Qt::ActionsContextMenu: | 0 | ||||||||||||||||||||||||||||||||||||
8971 | if (d->actions.count()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8972 | QMenu::exec(d->actions, static_cast<QContextMenuEvent *>(event)->globalPos(), | - | ||||||||||||||||||||||||||||||||||||
8973 | 0, this); | - | ||||||||||||||||||||||||||||||||||||
8974 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8975 | } | - | ||||||||||||||||||||||||||||||||||||
8976 | // fall through | - | ||||||||||||||||||||||||||||||||||||
8977 | #endif | - | ||||||||||||||||||||||||||||||||||||
8978 | default: code before this statement never executed: default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
8979 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
8980 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8981 | } | - | ||||||||||||||||||||||||||||||||||||
8982 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8983 | #endif // QT_NO_CONTEXTMENU | - | ||||||||||||||||||||||||||||||||||||
8984 | - | |||||||||||||||||||||||||||||||||||||
8985 | #ifndef QT_NO_DRAGANDDROP | - | ||||||||||||||||||||||||||||||||||||
8986 | case QEvent::Drop: never executed: case QEvent::Drop: | 0 | ||||||||||||||||||||||||||||||||||||
8987 | dropEvent((QDropEvent*) event); | - | ||||||||||||||||||||||||||||||||||||
8988 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8989 | - | |||||||||||||||||||||||||||||||||||||
8990 | case QEvent::DragEnter: never executed: case QEvent::DragEnter: | 0 | ||||||||||||||||||||||||||||||||||||
8991 | dragEnterEvent((QDragEnterEvent*) event); | - | ||||||||||||||||||||||||||||||||||||
8992 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8993 | - | |||||||||||||||||||||||||||||||||||||
8994 | case QEvent::DragMove: never executed: case QEvent::DragMove: | 0 | ||||||||||||||||||||||||||||||||||||
8995 | dragMoveEvent((QDragMoveEvent*) event); | - | ||||||||||||||||||||||||||||||||||||
8996 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8997 | - | |||||||||||||||||||||||||||||||||||||
8998 | case QEvent::DragLeave: never executed: case QEvent::DragLeave: | 0 | ||||||||||||||||||||||||||||||||||||
8999 | dragLeaveEvent((QDragLeaveEvent*) event); | - | ||||||||||||||||||||||||||||||||||||
9000 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9001 | #endif | - | ||||||||||||||||||||||||||||||||||||
9002 | - | |||||||||||||||||||||||||||||||||||||
9003 | case QEvent::Show: never executed: case QEvent::Show: | 0 | ||||||||||||||||||||||||||||||||||||
9004 | showEvent((QShowEvent*) event); | - | ||||||||||||||||||||||||||||||||||||
9005 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9006 | - | |||||||||||||||||||||||||||||||||||||
9007 | case QEvent::Hide: never executed: case QEvent::Hide: | 0 | ||||||||||||||||||||||||||||||||||||
9008 | hideEvent((QHideEvent*) event); | - | ||||||||||||||||||||||||||||||||||||
9009 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9010 | - | |||||||||||||||||||||||||||||||||||||
9011 | case QEvent::ShowWindowRequest: never executed: case QEvent::ShowWindowRequest: | 0 | ||||||||||||||||||||||||||||||||||||
9012 | if (!isHidden())
| 0 | ||||||||||||||||||||||||||||||||||||
9013 | d->show_sys(); never executed: d->show_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
9014 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9015 | - | |||||||||||||||||||||||||||||||||||||
9016 | case QEvent::ApplicationFontChange: never executed: case QEvent::ApplicationFontChange: | 0 | ||||||||||||||||||||||||||||||||||||
9017 | d->resolveFont(); | - | ||||||||||||||||||||||||||||||||||||
9018 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9019 | case QEvent::ApplicationPaletteChange: never executed: case QEvent::ApplicationPaletteChange: | 0 | ||||||||||||||||||||||||||||||||||||
9020 | if (!(windowType() == Qt::Desktop))
| 0 | ||||||||||||||||||||||||||||||||||||
9021 | d->resolvePalette(); never executed: d->resolvePalette(); | 0 | ||||||||||||||||||||||||||||||||||||
9022 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9023 | - | |||||||||||||||||||||||||||||||||||||
9024 | case QEvent::ToolBarChange: never executed: case QEvent::ToolBarChange: | 0 | ||||||||||||||||||||||||||||||||||||
9025 | case QEvent::ActivationChange: never executed: case QEvent::ActivationChange: | 0 | ||||||||||||||||||||||||||||||||||||
9026 | case QEvent::EnabledChange: never executed: case QEvent::EnabledChange: | 0 | ||||||||||||||||||||||||||||||||||||
9027 | case QEvent::FontChange: never executed: case QEvent::FontChange: | 0 | ||||||||||||||||||||||||||||||||||||
9028 | case QEvent::StyleChange: never executed: case QEvent::StyleChange: | 0 | ||||||||||||||||||||||||||||||||||||
9029 | case QEvent::PaletteChange: never executed: case QEvent::PaletteChange: | 0 | ||||||||||||||||||||||||||||||||||||
9030 | case QEvent::WindowTitleChange: never executed: case QEvent::WindowTitleChange: | 0 | ||||||||||||||||||||||||||||||||||||
9031 | case QEvent::IconTextChange: never executed: case QEvent::IconTextChange: | 0 | ||||||||||||||||||||||||||||||||||||
9032 | case QEvent::ModifiedChange: never executed: case QEvent::ModifiedChange: | 0 | ||||||||||||||||||||||||||||||||||||
9033 | case QEvent::MouseTrackingChange: never executed: case QEvent::MouseTrackingChange: | 0 | ||||||||||||||||||||||||||||||||||||
9034 | case QEvent::ParentChange: never executed: case QEvent::ParentChange: | 0 | ||||||||||||||||||||||||||||||||||||
9035 | case QEvent::LocaleChange: never executed: case QEvent::LocaleChange: | 0 | ||||||||||||||||||||||||||||||||||||
9036 | case QEvent::MacSizeChange: never executed: case QEvent::MacSizeChange: | 0 | ||||||||||||||||||||||||||||||||||||
9037 | case QEvent::ContentsRectChange: never executed: case QEvent::ContentsRectChange: | 0 | ||||||||||||||||||||||||||||||||||||
9038 | case QEvent::ThemeChange: never executed: case QEvent::ThemeChange: | 0 | ||||||||||||||||||||||||||||||||||||
9039 | case QEvent::ReadOnlyChange: never executed: case QEvent::ReadOnlyChange: | 0 | ||||||||||||||||||||||||||||||||||||
9040 | changeEvent(event); | - | ||||||||||||||||||||||||||||||||||||
9041 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9042 | - | |||||||||||||||||||||||||||||||||||||
9043 | case QEvent::WindowStateChange: { never executed: case QEvent::WindowStateChange: | 0 | ||||||||||||||||||||||||||||||||||||
9044 | const bool wasMinimized = static_cast<const QWindowStateChangeEvent *>(event)->oldState() & Qt::WindowMinimized; | - | ||||||||||||||||||||||||||||||||||||
9045 | if (wasMinimized != isMinimized()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9046 | QWidget *widget = const_cast<QWidget *>(this); | - | ||||||||||||||||||||||||||||||||||||
9047 | if (wasMinimized) {
| 0 | ||||||||||||||||||||||||||||||||||||
9048 | // Always send the spontaneous events here, otherwise it can break the application! | - | ||||||||||||||||||||||||||||||||||||
9049 | if (!d->childrenShownByExpose) {
| 0 | ||||||||||||||||||||||||||||||||||||
9050 | // Show widgets only when they are not yet shown by the expose event | - | ||||||||||||||||||||||||||||||||||||
9051 | d->showChildren(true); | - | ||||||||||||||||||||||||||||||||||||
9052 | QShowEvent showEvent; | - | ||||||||||||||||||||||||||||||||||||
9053 | QCoreApplication::sendSpontaneousEvent(widget, &showEvent); | - | ||||||||||||||||||||||||||||||||||||
9054 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9055 | d->childrenHiddenByWState = false; // Set it always to "false" when window is restored | - | ||||||||||||||||||||||||||||||||||||
9056 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9057 | QHideEvent hideEvent; | - | ||||||||||||||||||||||||||||||||||||
9058 | QCoreApplication::sendSpontaneousEvent(widget, &hideEvent); | - | ||||||||||||||||||||||||||||||||||||
9059 | d->hideChildren(true); | - | ||||||||||||||||||||||||||||||||||||
9060 | d->childrenHiddenByWState = true; | - | ||||||||||||||||||||||||||||||||||||
9061 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9062 | d->childrenShownByExpose = false; // Set it always to "false" when window state changes | - | ||||||||||||||||||||||||||||||||||||
9063 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9064 | changeEvent(event); | - | ||||||||||||||||||||||||||||||||||||
9065 | } | - | ||||||||||||||||||||||||||||||||||||
9066 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9067 | - | |||||||||||||||||||||||||||||||||||||
9068 | case QEvent::WindowActivate: never executed: case QEvent::WindowActivate: | 0 | ||||||||||||||||||||||||||||||||||||
9069 | case QEvent::WindowDeactivate: { never executed: case QEvent::WindowDeactivate: | 0 | ||||||||||||||||||||||||||||||||||||
9070 | if (isVisible() && !palette().isEqual(QPalette::Active, QPalette::Inactive))
| 0 | ||||||||||||||||||||||||||||||||||||
9071 | update(); never executed: update(); | 0 | ||||||||||||||||||||||||||||||||||||
9072 | QList<QObject*> childList = d->children; | - | ||||||||||||||||||||||||||||||||||||
9073 | for (int i = 0; i < childList.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
9074 | QWidget *w = qobject_cast<QWidget *>(childList.at(i)); | - | ||||||||||||||||||||||||||||||||||||
9075 | if (w && w->isVisible() && !w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
9076 | QApplication::sendEvent(w, event); never executed: QApplication::sendEvent(w, event); | 0 | ||||||||||||||||||||||||||||||||||||
9077 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9078 | break; } never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9079 | - | |||||||||||||||||||||||||||||||||||||
9080 | case QEvent::LanguageChange: never executed: case QEvent::LanguageChange: | 0 | ||||||||||||||||||||||||||||||||||||
9081 | changeEvent(event); | - | ||||||||||||||||||||||||||||||||||||
9082 | { | - | ||||||||||||||||||||||||||||||||||||
9083 | QList<QObject*> childList = d->children; | - | ||||||||||||||||||||||||||||||||||||
9084 | for (int i = 0; i < childList.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
9085 | QObject *o = childList.at(i); | - | ||||||||||||||||||||||||||||||||||||
9086 | if (o)
| 0 | ||||||||||||||||||||||||||||||||||||
9087 | QApplication::sendEvent(o, event); never executed: QApplication::sendEvent(o, event); | 0 | ||||||||||||||||||||||||||||||||||||
9088 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9089 | } | - | ||||||||||||||||||||||||||||||||||||
9090 | update(); | - | ||||||||||||||||||||||||||||||||||||
9091 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9092 | - | |||||||||||||||||||||||||||||||||||||
9093 | case QEvent::ApplicationLayoutDirectionChange: never executed: case QEvent::ApplicationLayoutDirectionChange: | 0 | ||||||||||||||||||||||||||||||||||||
9094 | d->resolveLayoutDirection(); | - | ||||||||||||||||||||||||||||||||||||
9095 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9096 | - | |||||||||||||||||||||||||||||||||||||
9097 | case QEvent::LayoutDirectionChange: never executed: case QEvent::LayoutDirectionChange: | 0 | ||||||||||||||||||||||||||||||||||||
9098 | if (d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
9099 | d->layout->invalidate(); never executed: d->layout->invalidate(); | 0 | ||||||||||||||||||||||||||||||||||||
9100 | update(); | - | ||||||||||||||||||||||||||||||||||||
9101 | changeEvent(event); | - | ||||||||||||||||||||||||||||||||||||
9102 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9103 | case QEvent::UpdateRequest: never executed: case QEvent::UpdateRequest: | 0 | ||||||||||||||||||||||||||||||||||||
9104 | d->syncBackingStore(); | - | ||||||||||||||||||||||||||||||||||||
9105 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9106 | case QEvent::UpdateLater: never executed: case QEvent::UpdateLater: | 0 | ||||||||||||||||||||||||||||||||||||
9107 | update(static_cast<QUpdateLaterEvent*>(event)->region()); | - | ||||||||||||||||||||||||||||||||||||
9108 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9109 | case QEvent::StyleAnimationUpdate: never executed: case QEvent::StyleAnimationUpdate: | 0 | ||||||||||||||||||||||||||||||||||||
9110 | if (isVisible() && !window()->isMinimized()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9111 | event->accept(); | - | ||||||||||||||||||||||||||||||||||||
9112 | update(); | - | ||||||||||||||||||||||||||||||||||||
9113 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9114 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9115 | - | |||||||||||||||||||||||||||||||||||||
9116 | case QEvent::WindowBlocked: never executed: case QEvent::WindowBlocked: | 0 | ||||||||||||||||||||||||||||||||||||
9117 | case QEvent::WindowUnblocked: never executed: case QEvent::WindowUnblocked: | 0 | ||||||||||||||||||||||||||||||||||||
9118 | if (!d->children.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9119 | QWidget *modalWidget = QApplication::activeModalWidget(); | - | ||||||||||||||||||||||||||||||||||||
9120 | for (int i = 0; i < d->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
9121 | QObject *o = d->children.at(i); | - | ||||||||||||||||||||||||||||||||||||
9122 | if (o && o != modalWidget && o->isWidgetType()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9123 | QWidget *w = static_cast<QWidget *>(o); | - | ||||||||||||||||||||||||||||||||||||
9124 | // do not forward the event to child windows; QApplication does this for us | - | ||||||||||||||||||||||||||||||||||||
9125 | if (!w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
9126 | QApplication::sendEvent(w, event); never executed: QApplication::sendEvent(w, event); | 0 | ||||||||||||||||||||||||||||||||||||
9127 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9128 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9129 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9130 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
9131 | setDisabledStyle(this, (event->type() == QEvent::WindowBlocked)); | - | ||||||||||||||||||||||||||||||||||||
9132 | #endif | - | ||||||||||||||||||||||||||||||||||||
9133 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9134 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||||||||||||||
9135 | case QEvent::ToolTip: never executed: case QEvent::ToolTip: | 0 | ||||||||||||||||||||||||||||||||||||
9136 | if (!d->toolTip.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
9137 | QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip, this, QRect(), d->toolTipDuration); never executed: QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip, this, QRect(), d->toolTipDuration); | 0 | ||||||||||||||||||||||||||||||||||||
9138 | else | - | ||||||||||||||||||||||||||||||||||||
9139 | event->ignore(); never executed: event->ignore(); | 0 | ||||||||||||||||||||||||||||||||||||
9140 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9141 | #endif | - | ||||||||||||||||||||||||||||||||||||
9142 | #ifndef QT_NO_WHATSTHIS | - | ||||||||||||||||||||||||||||||||||||
9143 | case QEvent::WhatsThis: never executed: case QEvent::WhatsThis: | 0 | ||||||||||||||||||||||||||||||||||||
9144 | if (d->whatsThis.size())
| 0 | ||||||||||||||||||||||||||||||||||||
9145 | QWhatsThis::showText(static_cast<QHelpEvent *>(event)->globalPos(), d->whatsThis, this); never executed: QWhatsThis::showText(static_cast<QHelpEvent *>(event)->globalPos(), d->whatsThis, this); | 0 | ||||||||||||||||||||||||||||||||||||
9146 | else | - | ||||||||||||||||||||||||||||||||||||
9147 | event->ignore(); never executed: event->ignore(); | 0 | ||||||||||||||||||||||||||||||||||||
9148 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9149 | case QEvent::QueryWhatsThis: never executed: case QEvent::QueryWhatsThis: | 0 | ||||||||||||||||||||||||||||||||||||
9150 | if (d->whatsThis.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
9151 | event->ignore(); never executed: event->ignore(); | 0 | ||||||||||||||||||||||||||||||||||||
9152 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9153 | #endif | - | ||||||||||||||||||||||||||||||||||||
9154 | case QEvent::EmbeddingControl: never executed: case QEvent::EmbeddingControl: | 0 | ||||||||||||||||||||||||||||||||||||
9155 | d->topData()->frameStrut.setCoords(0 ,0, 0, 0); | - | ||||||||||||||||||||||||||||||||||||
9156 | data->fstrut_dirty = false; | - | ||||||||||||||||||||||||||||||||||||
9157 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
9158 | d->topData()->embedded = 1; | - | ||||||||||||||||||||||||||||||||||||
9159 | #endif | - | ||||||||||||||||||||||||||||||||||||
9160 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9161 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||||||||||||||
9162 | case QEvent::ActionAdded: never executed: case QEvent::ActionAdded: | 0 | ||||||||||||||||||||||||||||||||||||
9163 | case QEvent::ActionRemoved: never executed: case QEvent::ActionRemoved: | 0 | ||||||||||||||||||||||||||||||||||||
9164 | case QEvent::ActionChanged: never executed: case QEvent::ActionChanged: | 0 | ||||||||||||||||||||||||||||||||||||
9165 | actionEvent((QActionEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
9166 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9167 | #endif | - | ||||||||||||||||||||||||||||||||||||
9168 | - | |||||||||||||||||||||||||||||||||||||
9169 | case QEvent::KeyboardLayoutChange: never executed: case QEvent::KeyboardLayoutChange: | 0 | ||||||||||||||||||||||||||||||||||||
9170 | { | - | ||||||||||||||||||||||||||||||||||||
9171 | changeEvent(event); | - | ||||||||||||||||||||||||||||||||||||
9172 | - | |||||||||||||||||||||||||||||||||||||
9173 | // inform children of the change | - | ||||||||||||||||||||||||||||||||||||
9174 | QList<QObject*> childList = d->children; | - | ||||||||||||||||||||||||||||||||||||
9175 | for (int i = 0; i < childList.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
9176 | QWidget *w = qobject_cast<QWidget *>(childList.at(i)); | - | ||||||||||||||||||||||||||||||||||||
9177 | if (w && w->isVisible() && !w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
9178 | QApplication::sendEvent(w, event); never executed: QApplication::sendEvent(w, event); | 0 | ||||||||||||||||||||||||||||||||||||
9179 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9180 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9181 | } | - | ||||||||||||||||||||||||||||||||||||
9182 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
9183 | case QEvent::MacGLWindowChange: | - | ||||||||||||||||||||||||||||||||||||
9184 | d->needWindowChange = false; | - | ||||||||||||||||||||||||||||||||||||
9185 | break; | - | ||||||||||||||||||||||||||||||||||||
9186 | #endif | - | ||||||||||||||||||||||||||||||||||||
9187 | case QEvent::TouchBegin: never executed: case QEvent::TouchBegin: | 0 | ||||||||||||||||||||||||||||||||||||
9188 | case QEvent::TouchUpdate: never executed: case QEvent::TouchUpdate: | 0 | ||||||||||||||||||||||||||||||||||||
9189 | case QEvent::TouchEnd: never executed: case QEvent::TouchEnd: | 0 | ||||||||||||||||||||||||||||||||||||
9190 | case QEvent::TouchCancel: never executed: case QEvent::TouchCancel: | 0 | ||||||||||||||||||||||||||||||||||||
9191 | { | - | ||||||||||||||||||||||||||||||||||||
9192 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9193 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9194 | } | - | ||||||||||||||||||||||||||||||||||||
9195 | #ifndef QT_NO_GESTURES | - | ||||||||||||||||||||||||||||||||||||
9196 | case QEvent::Gesture: never executed: case QEvent::Gesture: | 0 | ||||||||||||||||||||||||||||||||||||
9197 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9198 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9199 | #endif | - | ||||||||||||||||||||||||||||||||||||
9200 | case QEvent::ScreenChangeInternal: never executed: case QEvent::ScreenChangeInternal: | 0 | ||||||||||||||||||||||||||||||||||||
9201 | if (const QTLWExtra *te = d->maybeTopData()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9202 | const QWindow *win = te->window; | - | ||||||||||||||||||||||||||||||||||||
9203 | d->setWinId((win && win->handle()) ? win->handle()->winId() : 0); | - | ||||||||||||||||||||||||||||||||||||
9204 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9205 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
9206 | d->renderToTextureReallyDirty = 1; | - | ||||||||||||||||||||||||||||||||||||
9207 | #endif | - | ||||||||||||||||||||||||||||||||||||
9208 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9209 | #ifndef QT_NO_PROPERTIES | - | ||||||||||||||||||||||||||||||||||||
9210 | case QEvent::DynamicPropertyChange: { never executed: case QEvent::DynamicPropertyChange: | 0 | ||||||||||||||||||||||||||||||||||||
9211 | const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName(); | - | ||||||||||||||||||||||||||||||||||||
9212 | if (propName.length() == 13 && !qstrncmp(propName, "_q_customDpi", 12)) {
| 0 | ||||||||||||||||||||||||||||||||||||
9213 | uint value = property(propName.constData()).toUInt(); | - | ||||||||||||||||||||||||||||||||||||
9214 | if (!d->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
9215 | d->createExtra(); never executed: d->createExtra(); | 0 | ||||||||||||||||||||||||||||||||||||
9216 | const char axis = propName.at(12); | - | ||||||||||||||||||||||||||||||||||||
9217 | if (axis == 'X')
| 0 | ||||||||||||||||||||||||||||||||||||
9218 | d->extra->customDpiX = value; never executed: d->extra->customDpiX = value; | 0 | ||||||||||||||||||||||||||||||||||||
9219 | else if (axis == 'Y')
| 0 | ||||||||||||||||||||||||||||||||||||
9220 | d->extra->customDpiY = value; never executed: d->extra->customDpiY = value; | 0 | ||||||||||||||||||||||||||||||||||||
9221 | d->updateFont(d->data.fnt); | - | ||||||||||||||||||||||||||||||||||||
9222 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9223 | if (windowHandle() && !qstrncmp(propName, "_q_platform_", 12))
| 0 | ||||||||||||||||||||||||||||||||||||
9224 | windowHandle()->setProperty(propName, property(propName)); never executed: windowHandle()->setProperty(propName, property(propName)); | 0 | ||||||||||||||||||||||||||||||||||||
9225 | // fall through | - | ||||||||||||||||||||||||||||||||||||
9226 | } | - | ||||||||||||||||||||||||||||||||||||
9227 | #endif | - | ||||||||||||||||||||||||||||||||||||
9228 | default: code before this statement never executed: default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
9229 | return QObject::event(event); never executed: return QObject::event(event); | 0 | ||||||||||||||||||||||||||||||||||||
9230 | } | - | ||||||||||||||||||||||||||||||||||||
9231 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
9232 | } | - | ||||||||||||||||||||||||||||||||||||
9233 | - | |||||||||||||||||||||||||||||||||||||
9234 | /*! | - | ||||||||||||||||||||||||||||||||||||
9235 | This event handler can be reimplemented to handle state changes. | - | ||||||||||||||||||||||||||||||||||||
9236 | - | |||||||||||||||||||||||||||||||||||||
9237 | The state being changed in this event can be retrieved through the \a event | - | ||||||||||||||||||||||||||||||||||||
9238 | supplied. | - | ||||||||||||||||||||||||||||||||||||
9239 | - | |||||||||||||||||||||||||||||||||||||
9240 | Change events include: QEvent::ToolBarChange, | - | ||||||||||||||||||||||||||||||||||||
9241 | QEvent::ActivationChange, QEvent::EnabledChange, QEvent::FontChange, | - | ||||||||||||||||||||||||||||||||||||
9242 | QEvent::StyleChange, QEvent::PaletteChange, | - | ||||||||||||||||||||||||||||||||||||
9243 | QEvent::WindowTitleChange, QEvent::IconTextChange, | - | ||||||||||||||||||||||||||||||||||||
9244 | QEvent::ModifiedChange, QEvent::MouseTrackingChange, | - | ||||||||||||||||||||||||||||||||||||
9245 | QEvent::ParentChange, QEvent::WindowStateChange, | - | ||||||||||||||||||||||||||||||||||||
9246 | QEvent::LanguageChange, QEvent::LocaleChange, | - | ||||||||||||||||||||||||||||||||||||
9247 | QEvent::LayoutDirectionChange, QEvent::ReadOnlyChange. | - | ||||||||||||||||||||||||||||||||||||
9248 | - | |||||||||||||||||||||||||||||||||||||
9249 | */ | - | ||||||||||||||||||||||||||||||||||||
9250 | void QWidget::changeEvent(QEvent * event) | - | ||||||||||||||||||||||||||||||||||||
9251 | { | - | ||||||||||||||||||||||||||||||||||||
9252 | switch(event->type()) { | - | ||||||||||||||||||||||||||||||||||||
9253 | case QEvent::EnabledChange: { never executed: case QEvent::EnabledChange: | 0 | ||||||||||||||||||||||||||||||||||||
9254 | update(); | - | ||||||||||||||||||||||||||||||||||||
9255 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
9256 | QAccessible::State s; | - | ||||||||||||||||||||||||||||||||||||
9257 | s.disabled = true; | - | ||||||||||||||||||||||||||||||||||||
9258 | QAccessibleStateChangeEvent event(this, s); | - | ||||||||||||||||||||||||||||||||||||
9259 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
9260 | #endif | - | ||||||||||||||||||||||||||||||||||||
9261 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9262 | } | - | ||||||||||||||||||||||||||||||||||||
9263 | - | |||||||||||||||||||||||||||||||||||||
9264 | case QEvent::FontChange: never executed: case QEvent::FontChange: | 0 | ||||||||||||||||||||||||||||||||||||
9265 | case QEvent::StyleChange: { never executed: case QEvent::StyleChange: | 0 | ||||||||||||||||||||||||||||||||||||
9266 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
9267 | update(); | - | ||||||||||||||||||||||||||||||||||||
9268 | updateGeometry(); | - | ||||||||||||||||||||||||||||||||||||
9269 | if (d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
9270 | d->layout->invalidate(); never executed: d->layout->invalidate(); | 0 | ||||||||||||||||||||||||||||||||||||
9271 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9272 | } | - | ||||||||||||||||||||||||||||||||||||
9273 | - | |||||||||||||||||||||||||||||||||||||
9274 | case QEvent::PaletteChange: never executed: case QEvent::PaletteChange: | 0 | ||||||||||||||||||||||||||||||||||||
9275 | update(); | - | ||||||||||||||||||||||||||||||||||||
9276 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9277 | - | |||||||||||||||||||||||||||||||||||||
9278 | case QEvent::ThemeChange: never executed: case QEvent::ThemeChange: | 0 | ||||||||||||||||||||||||||||||||||||
9279 | if (QApplication::desktopSettingsAware() && windowType() != Qt::Desktop
| 0 | ||||||||||||||||||||||||||||||||||||
9280 | && qApp && !QApplication::closingDown()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9281 | if (testAttribute(Qt::WA_WState_Polished))
| 0 | ||||||||||||||||||||||||||||||||||||
9282 | QApplication::style()->unpolish(this); never executed: QApplication::style()->unpolish(this); | 0 | ||||||||||||||||||||||||||||||||||||
9283 | if (testAttribute(Qt::WA_WState_Polished))
| 0 | ||||||||||||||||||||||||||||||||||||
9284 | QApplication::style()->polish(this); never executed: QApplication::style()->polish(this); | 0 | ||||||||||||||||||||||||||||||||||||
9285 | QEvent styleChangedEvent(QEvent::StyleChange); | - | ||||||||||||||||||||||||||||||||||||
9286 | QCoreApplication::sendEvent(this, &styleChangedEvent); | - | ||||||||||||||||||||||||||||||||||||
9287 | if (isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
9288 | update(); never executed: update(); | 0 | ||||||||||||||||||||||||||||||||||||
9289 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9290 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9291 | - | |||||||||||||||||||||||||||||||||||||
9292 | #ifdef Q_OS_MAC | - | ||||||||||||||||||||||||||||||||||||
9293 | case QEvent::MacSizeChange: | - | ||||||||||||||||||||||||||||||||||||
9294 | updateGeometry(); | - | ||||||||||||||||||||||||||||||||||||
9295 | break; | - | ||||||||||||||||||||||||||||||||||||
9296 | #elif defined Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
9297 | case QEvent::ToolTipChange: | - | ||||||||||||||||||||||||||||||||||||
9298 | case QEvent::MouseTrackingChange: | - | ||||||||||||||||||||||||||||||||||||
9299 | qt_mac_update_mouseTracking(this); | - | ||||||||||||||||||||||||||||||||||||
9300 | break; | - | ||||||||||||||||||||||||||||||||||||
9301 | #endif | - | ||||||||||||||||||||||||||||||||||||
9302 | - | |||||||||||||||||||||||||||||||||||||
9303 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
9304 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9305 | } | - | ||||||||||||||||||||||||||||||||||||
9306 | } | - | ||||||||||||||||||||||||||||||||||||
9307 | - | |||||||||||||||||||||||||||||||||||||
9308 | /*! | - | ||||||||||||||||||||||||||||||||||||
9309 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9310 | subclass to receive mouse move events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9311 | - | |||||||||||||||||||||||||||||||||||||
9312 | If mouse tracking is switched off, mouse move events only occur if | - | ||||||||||||||||||||||||||||||||||||
9313 | a mouse button is pressed while the mouse is being moved. If mouse | - | ||||||||||||||||||||||||||||||||||||
9314 | tracking is switched on, mouse move events occur even if no mouse | - | ||||||||||||||||||||||||||||||||||||
9315 | button is pressed. | - | ||||||||||||||||||||||||||||||||||||
9316 | - | |||||||||||||||||||||||||||||||||||||
9317 | QMouseEvent::pos() reports the position of the mouse cursor, | - | ||||||||||||||||||||||||||||||||||||
9318 | relative to this widget. For press and release events, the | - | ||||||||||||||||||||||||||||||||||||
9319 | position is usually the same as the position of the last mouse | - | ||||||||||||||||||||||||||||||||||||
9320 | move event, but it might be different if the user's hand shakes. | - | ||||||||||||||||||||||||||||||||||||
9321 | This is a feature of the underlying window system, not Qt. | - | ||||||||||||||||||||||||||||||||||||
9322 | - | |||||||||||||||||||||||||||||||||||||
9323 | If you want to show a tooltip immediately, while the mouse is | - | ||||||||||||||||||||||||||||||||||||
9324 | moving (e.g., to get the mouse coordinates with QMouseEvent::pos() | - | ||||||||||||||||||||||||||||||||||||
9325 | and show them as a tooltip), you must first enable mouse tracking | - | ||||||||||||||||||||||||||||||||||||
9326 | as described above. Then, to ensure that the tooltip is updated | - | ||||||||||||||||||||||||||||||||||||
9327 | immediately, you must call QToolTip::showText() instead of | - | ||||||||||||||||||||||||||||||||||||
9328 | setToolTip() in your implementation of mouseMoveEvent(). | - | ||||||||||||||||||||||||||||||||||||
9329 | - | |||||||||||||||||||||||||||||||||||||
9330 | \sa setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), | - | ||||||||||||||||||||||||||||||||||||
9331 | mouseDoubleClickEvent(), event(), QMouseEvent, {Scribble Example} | - | ||||||||||||||||||||||||||||||||||||
9332 | */ | - | ||||||||||||||||||||||||||||||||||||
9333 | - | |||||||||||||||||||||||||||||||||||||
9334 | void QWidget::mouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9335 | { | - | ||||||||||||||||||||||||||||||||||||
9336 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9337 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9338 | - | |||||||||||||||||||||||||||||||||||||
9339 | /*! | - | ||||||||||||||||||||||||||||||||||||
9340 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9341 | subclass to receive mouse press events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9342 | - | |||||||||||||||||||||||||||||||||||||
9343 | If you create new widgets in the mousePressEvent() the | - | ||||||||||||||||||||||||||||||||||||
9344 | mouseReleaseEvent() may not end up where you expect, depending on | - | ||||||||||||||||||||||||||||||||||||
9345 | the underlying window system (or X11 window manager), the widgets' | - | ||||||||||||||||||||||||||||||||||||
9346 | location and maybe more. | - | ||||||||||||||||||||||||||||||||||||
9347 | - | |||||||||||||||||||||||||||||||||||||
9348 | The default implementation implements the closing of popup widgets | - | ||||||||||||||||||||||||||||||||||||
9349 | when you click outside the window. For other widget types it does | - | ||||||||||||||||||||||||||||||||||||
9350 | nothing. | - | ||||||||||||||||||||||||||||||||||||
9351 | - | |||||||||||||||||||||||||||||||||||||
9352 | \sa mouseReleaseEvent(), mouseDoubleClickEvent(), | - | ||||||||||||||||||||||||||||||||||||
9353 | mouseMoveEvent(), event(), QMouseEvent, {Scribble Example} | - | ||||||||||||||||||||||||||||||||||||
9354 | */ | - | ||||||||||||||||||||||||||||||||||||
9355 | - | |||||||||||||||||||||||||||||||||||||
9356 | void QWidget::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9357 | { | - | ||||||||||||||||||||||||||||||||||||
9358 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9359 | if ((windowType() == Qt::Popup)) {
| 0 | ||||||||||||||||||||||||||||||||||||
9360 | event->accept(); | - | ||||||||||||||||||||||||||||||||||||
9361 | QWidget* w; | - | ||||||||||||||||||||||||||||||||||||
9362 | while ((w = QApplication::activePopupWidget()) && w != this){
| 0 | ||||||||||||||||||||||||||||||||||||
9363 | w->close(); | - | ||||||||||||||||||||||||||||||||||||
9364 | if (QApplication::activePopupWidget() == w) // widget does not want to disappear
| 0 | ||||||||||||||||||||||||||||||||||||
9365 | w->hide(); // hide at least never executed: w->hide(); | 0 | ||||||||||||||||||||||||||||||||||||
9366 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9367 | if (!rect().contains(event->pos())){
| 0 | ||||||||||||||||||||||||||||||||||||
9368 | close(); | - | ||||||||||||||||||||||||||||||||||||
9369 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9370 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9371 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9372 | - | |||||||||||||||||||||||||||||||||||||
9373 | /*! | - | ||||||||||||||||||||||||||||||||||||
9374 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9375 | subclass to receive mouse release events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9376 | - | |||||||||||||||||||||||||||||||||||||
9377 | \sa mousePressEvent(), mouseDoubleClickEvent(), | - | ||||||||||||||||||||||||||||||||||||
9378 | mouseMoveEvent(), event(), QMouseEvent, {Scribble Example} | - | ||||||||||||||||||||||||||||||||||||
9379 | */ | - | ||||||||||||||||||||||||||||||||||||
9380 | - | |||||||||||||||||||||||||||||||||||||
9381 | void QWidget::mouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9382 | { | - | ||||||||||||||||||||||||||||||||||||
9383 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9384 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9385 | - | |||||||||||||||||||||||||||||||||||||
9386 | /*! | - | ||||||||||||||||||||||||||||||||||||
9387 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9388 | subclass to receive mouse double click events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9389 | - | |||||||||||||||||||||||||||||||||||||
9390 | The default implementation calls mousePressEvent(). | - | ||||||||||||||||||||||||||||||||||||
9391 | - | |||||||||||||||||||||||||||||||||||||
9392 | \note The widget will also receive mouse press and mouse release | - | ||||||||||||||||||||||||||||||||||||
9393 | events in addition to the double click event. It is up to the | - | ||||||||||||||||||||||||||||||||||||
9394 | developer to ensure that the application interprets these events | - | ||||||||||||||||||||||||||||||||||||
9395 | correctly. | - | ||||||||||||||||||||||||||||||||||||
9396 | - | |||||||||||||||||||||||||||||||||||||
9397 | \sa mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), | - | ||||||||||||||||||||||||||||||||||||
9398 | event(), QMouseEvent | - | ||||||||||||||||||||||||||||||||||||
9399 | */ | - | ||||||||||||||||||||||||||||||||||||
9400 | - | |||||||||||||||||||||||||||||||||||||
9401 | void QWidget::mouseDoubleClickEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9402 | { | - | ||||||||||||||||||||||||||||||||||||
9403 | mousePressEvent(event); | - | ||||||||||||||||||||||||||||||||||||
9404 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9405 | - | |||||||||||||||||||||||||||||||||||||
9406 | #ifndef QT_NO_WHEELEVENT | - | ||||||||||||||||||||||||||||||||||||
9407 | /*! | - | ||||||||||||||||||||||||||||||||||||
9408 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9409 | subclass to receive wheel events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9410 | - | |||||||||||||||||||||||||||||||||||||
9411 | If you reimplement this handler, it is very important that you | - | ||||||||||||||||||||||||||||||||||||
9412 | \l{QEvent}{ignore()} the event if you do not handle | - | ||||||||||||||||||||||||||||||||||||
9413 | it, so that the widget's parent can interpret it. | - | ||||||||||||||||||||||||||||||||||||
9414 | - | |||||||||||||||||||||||||||||||||||||
9415 | The default implementation ignores the event. | - | ||||||||||||||||||||||||||||||||||||
9416 | - | |||||||||||||||||||||||||||||||||||||
9417 | \sa QEvent::ignore(), QEvent::accept(), event(), | - | ||||||||||||||||||||||||||||||||||||
9418 | QWheelEvent | - | ||||||||||||||||||||||||||||||||||||
9419 | */ | - | ||||||||||||||||||||||||||||||||||||
9420 | - | |||||||||||||||||||||||||||||||||||||
9421 | void QWidget::wheelEvent(QWheelEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9422 | { | - | ||||||||||||||||||||||||||||||||||||
9423 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9424 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9425 | #endif // QT_NO_WHEELEVENT | - | ||||||||||||||||||||||||||||||||||||
9426 | - | |||||||||||||||||||||||||||||||||||||
9427 | #ifndef QT_NO_TABLETEVENT | - | ||||||||||||||||||||||||||||||||||||
9428 | /*! | - | ||||||||||||||||||||||||||||||||||||
9429 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9430 | subclass to receive tablet events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9431 | - | |||||||||||||||||||||||||||||||||||||
9432 | If you reimplement this handler, it is very important that you | - | ||||||||||||||||||||||||||||||||||||
9433 | \l{QEvent}{ignore()} the event if you do not handle | - | ||||||||||||||||||||||||||||||||||||
9434 | it, so that the widget's parent can interpret it. | - | ||||||||||||||||||||||||||||||||||||
9435 | - | |||||||||||||||||||||||||||||||||||||
9436 | The default implementation ignores the event. | - | ||||||||||||||||||||||||||||||||||||
9437 | - | |||||||||||||||||||||||||||||||||||||
9438 | \sa QEvent::ignore(), QEvent::accept(), event(), | - | ||||||||||||||||||||||||||||||||||||
9439 | QTabletEvent | - | ||||||||||||||||||||||||||||||||||||
9440 | */ | - | ||||||||||||||||||||||||||||||||||||
9441 | - | |||||||||||||||||||||||||||||||||||||
9442 | void QWidget::tabletEvent(QTabletEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9443 | { | - | ||||||||||||||||||||||||||||||||||||
9444 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9445 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9446 | #endif // QT_NO_TABLETEVENT | - | ||||||||||||||||||||||||||||||||||||
9447 | - | |||||||||||||||||||||||||||||||||||||
9448 | /*! | - | ||||||||||||||||||||||||||||||||||||
9449 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9450 | subclass to receive key press events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9451 | - | |||||||||||||||||||||||||||||||||||||
9452 | A widget must call setFocusPolicy() to accept focus initially and | - | ||||||||||||||||||||||||||||||||||||
9453 | have focus in order to receive a key press event. | - | ||||||||||||||||||||||||||||||||||||
9454 | - | |||||||||||||||||||||||||||||||||||||
9455 | If you reimplement this handler, it is very important that you | - | ||||||||||||||||||||||||||||||||||||
9456 | call the base class implementation if you do not act upon the key. | - | ||||||||||||||||||||||||||||||||||||
9457 | - | |||||||||||||||||||||||||||||||||||||
9458 | The default implementation closes popup widgets if the user | - | ||||||||||||||||||||||||||||||||||||
9459 | presses the key sequence for QKeySequence::Cancel (typically the | - | ||||||||||||||||||||||||||||||||||||
9460 | Escape key). Otherwise the event is ignored, so that the widget's | - | ||||||||||||||||||||||||||||||||||||
9461 | parent can interpret it. | - | ||||||||||||||||||||||||||||||||||||
9462 | - | |||||||||||||||||||||||||||||||||||||
9463 | Note that QKeyEvent starts with isAccepted() == true, so you do not | - | ||||||||||||||||||||||||||||||||||||
9464 | need to call QKeyEvent::accept() - just do not call the base class | - | ||||||||||||||||||||||||||||||||||||
9465 | implementation if you act upon the key. | - | ||||||||||||||||||||||||||||||||||||
9466 | - | |||||||||||||||||||||||||||||||||||||
9467 | \sa keyReleaseEvent(), setFocusPolicy(), | - | ||||||||||||||||||||||||||||||||||||
9468 | focusInEvent(), focusOutEvent(), event(), QKeyEvent, {Tetrix Example} | - | ||||||||||||||||||||||||||||||||||||
9469 | */ | - | ||||||||||||||||||||||||||||||||||||
9470 | - | |||||||||||||||||||||||||||||||||||||
9471 | void QWidget::keyPressEvent(QKeyEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9472 | { | - | ||||||||||||||||||||||||||||||||||||
9473 | if ((windowType() == Qt::Popup) && event->matches(QKeySequence::Cancel)) {
| 0 | ||||||||||||||||||||||||||||||||||||
9474 | event->accept(); | - | ||||||||||||||||||||||||||||||||||||
9475 | close(); | - | ||||||||||||||||||||||||||||||||||||
9476 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9477 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9478 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9479 | } | - | ||||||||||||||||||||||||||||||||||||
9480 | - | |||||||||||||||||||||||||||||||||||||
9481 | /*! | - | ||||||||||||||||||||||||||||||||||||
9482 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9483 | subclass to receive key release events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9484 | - | |||||||||||||||||||||||||||||||||||||
9485 | A widget must \l{setFocusPolicy()}{accept focus} | - | ||||||||||||||||||||||||||||||||||||
9486 | initially and \l{hasFocus()}{have focus} in order to | - | ||||||||||||||||||||||||||||||||||||
9487 | receive a key release event. | - | ||||||||||||||||||||||||||||||||||||
9488 | - | |||||||||||||||||||||||||||||||||||||
9489 | If you reimplement this handler, it is very important that you | - | ||||||||||||||||||||||||||||||||||||
9490 | call the base class implementation if you do not act upon the key. | - | ||||||||||||||||||||||||||||||||||||
9491 | - | |||||||||||||||||||||||||||||||||||||
9492 | The default implementation ignores the event, so that the widget's | - | ||||||||||||||||||||||||||||||||||||
9493 | parent can interpret it. | - | ||||||||||||||||||||||||||||||||||||
9494 | - | |||||||||||||||||||||||||||||||||||||
9495 | Note that QKeyEvent starts with isAccepted() == true, so you do not | - | ||||||||||||||||||||||||||||||||||||
9496 | need to call QKeyEvent::accept() - just do not call the base class | - | ||||||||||||||||||||||||||||||||||||
9497 | implementation if you act upon the key. | - | ||||||||||||||||||||||||||||||||||||
9498 | - | |||||||||||||||||||||||||||||||||||||
9499 | \sa keyPressEvent(), QEvent::ignore(), setFocusPolicy(), | - | ||||||||||||||||||||||||||||||||||||
9500 | focusInEvent(), focusOutEvent(), event(), QKeyEvent | - | ||||||||||||||||||||||||||||||||||||
9501 | */ | - | ||||||||||||||||||||||||||||||||||||
9502 | - | |||||||||||||||||||||||||||||||||||||
9503 | void QWidget::keyReleaseEvent(QKeyEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9504 | { | - | ||||||||||||||||||||||||||||||||||||
9505 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9506 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9507 | - | |||||||||||||||||||||||||||||||||||||
9508 | /*! | - | ||||||||||||||||||||||||||||||||||||
9509 | \fn void QWidget::focusInEvent(QFocusEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9510 | - | |||||||||||||||||||||||||||||||||||||
9511 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9512 | keyboard focus events (focus received) for the widget. The event | - | ||||||||||||||||||||||||||||||||||||
9513 | is passed in the \a event parameter | - | ||||||||||||||||||||||||||||||||||||
9514 | - | |||||||||||||||||||||||||||||||||||||
9515 | A widget normally must setFocusPolicy() to something other than | - | ||||||||||||||||||||||||||||||||||||
9516 | Qt::NoFocus in order to receive focus events. (Note that the | - | ||||||||||||||||||||||||||||||||||||
9517 | application programmer can call setFocus() on any widget, even | - | ||||||||||||||||||||||||||||||||||||
9518 | those that do not normally accept focus.) | - | ||||||||||||||||||||||||||||||||||||
9519 | - | |||||||||||||||||||||||||||||||||||||
9520 | The default implementation updates the widget (except for windows | - | ||||||||||||||||||||||||||||||||||||
9521 | that do not specify a focusPolicy()). | - | ||||||||||||||||||||||||||||||||||||
9522 | - | |||||||||||||||||||||||||||||||||||||
9523 | \sa focusOutEvent(), setFocusPolicy(), keyPressEvent(), | - | ||||||||||||||||||||||||||||||||||||
9524 | keyReleaseEvent(), event(), QFocusEvent | - | ||||||||||||||||||||||||||||||||||||
9525 | */ | - | ||||||||||||||||||||||||||||||||||||
9526 | - | |||||||||||||||||||||||||||||||||||||
9527 | void QWidget::focusInEvent(QFocusEvent *) | - | ||||||||||||||||||||||||||||||||||||
9528 | { | - | ||||||||||||||||||||||||||||||||||||
9529 | if (focusPolicy() != Qt::NoFocus || !isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9530 | update(); | - | ||||||||||||||||||||||||||||||||||||
9531 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9532 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9533 | - | |||||||||||||||||||||||||||||||||||||
9534 | /*! | - | ||||||||||||||||||||||||||||||||||||
9535 | \fn void QWidget::focusOutEvent(QFocusEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9536 | - | |||||||||||||||||||||||||||||||||||||
9537 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9538 | keyboard focus events (focus lost) for the widget. The events is | - | ||||||||||||||||||||||||||||||||||||
9539 | passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9540 | - | |||||||||||||||||||||||||||||||||||||
9541 | A widget normally must setFocusPolicy() to something other than | - | ||||||||||||||||||||||||||||||||||||
9542 | Qt::NoFocus in order to receive focus events. (Note that the | - | ||||||||||||||||||||||||||||||||||||
9543 | application programmer can call setFocus() on any widget, even | - | ||||||||||||||||||||||||||||||||||||
9544 | those that do not normally accept focus.) | - | ||||||||||||||||||||||||||||||||||||
9545 | - | |||||||||||||||||||||||||||||||||||||
9546 | The default implementation updates the widget (except for windows | - | ||||||||||||||||||||||||||||||||||||
9547 | that do not specify a focusPolicy()). | - | ||||||||||||||||||||||||||||||||||||
9548 | - | |||||||||||||||||||||||||||||||||||||
9549 | \sa focusInEvent(), setFocusPolicy(), keyPressEvent(), | - | ||||||||||||||||||||||||||||||||||||
9550 | keyReleaseEvent(), event(), QFocusEvent | - | ||||||||||||||||||||||||||||||||||||
9551 | */ | - | ||||||||||||||||||||||||||||||||||||
9552 | - | |||||||||||||||||||||||||||||||||||||
9553 | void QWidget::focusOutEvent(QFocusEvent *) | - | ||||||||||||||||||||||||||||||||||||
9554 | { | - | ||||||||||||||||||||||||||||||||||||
9555 | if (focusPolicy() != Qt::NoFocus || !isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
9556 | update(); never executed: update(); | 0 | ||||||||||||||||||||||||||||||||||||
9557 | - | |||||||||||||||||||||||||||||||||||||
9558 | #ifndef Q_OS_IOS | - | ||||||||||||||||||||||||||||||||||||
9559 | // FIXME: revisit autoSIP logic, QTBUG-42906 | - | ||||||||||||||||||||||||||||||||||||
9560 | if (qApp->autoSipEnabled() && testAttribute(Qt::WA_InputMethodEnabled))
| 0 | ||||||||||||||||||||||||||||||||||||
9561 | QGuiApplication::inputMethod()->hide(); never executed: QGuiApplication::inputMethod()->hide(); | 0 | ||||||||||||||||||||||||||||||||||||
9562 | #endif | - | ||||||||||||||||||||||||||||||||||||
9563 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9564 | - | |||||||||||||||||||||||||||||||||||||
9565 | /*! | - | ||||||||||||||||||||||||||||||||||||
9566 | \fn void QWidget::enterEvent(QEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9567 | - | |||||||||||||||||||||||||||||||||||||
9568 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9569 | widget enter events which are passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9570 | - | |||||||||||||||||||||||||||||||||||||
9571 | An event is sent to the widget when the mouse cursor enters the | - | ||||||||||||||||||||||||||||||||||||
9572 | widget. | - | ||||||||||||||||||||||||||||||||||||
9573 | - | |||||||||||||||||||||||||||||||||||||
9574 | \sa leaveEvent(), mouseMoveEvent(), event() | - | ||||||||||||||||||||||||||||||||||||
9575 | */ | - | ||||||||||||||||||||||||||||||||||||
9576 | - | |||||||||||||||||||||||||||||||||||||
9577 | void QWidget::enterEvent(QEvent *) | - | ||||||||||||||||||||||||||||||||||||
9578 | { | - | ||||||||||||||||||||||||||||||||||||
9579 | } | - | ||||||||||||||||||||||||||||||||||||
9580 | - | |||||||||||||||||||||||||||||||||||||
9581 | // ### Qt 6: void QWidget::enterEvent(QEnterEvent *). | - | ||||||||||||||||||||||||||||||||||||
9582 | - | |||||||||||||||||||||||||||||||||||||
9583 | /*! | - | ||||||||||||||||||||||||||||||||||||
9584 | \fn void QWidget::leaveEvent(QEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9585 | - | |||||||||||||||||||||||||||||||||||||
9586 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9587 | widget leave events which are passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9588 | - | |||||||||||||||||||||||||||||||||||||
9589 | A leave event is sent to the widget when the mouse cursor leaves | - | ||||||||||||||||||||||||||||||||||||
9590 | the widget. | - | ||||||||||||||||||||||||||||||||||||
9591 | - | |||||||||||||||||||||||||||||||||||||
9592 | \sa enterEvent(), mouseMoveEvent(), event() | - | ||||||||||||||||||||||||||||||||||||
9593 | */ | - | ||||||||||||||||||||||||||||||||||||
9594 | - | |||||||||||||||||||||||||||||||||||||
9595 | void QWidget::leaveEvent(QEvent *) | - | ||||||||||||||||||||||||||||||||||||
9596 | { | - | ||||||||||||||||||||||||||||||||||||
9597 | } | - | ||||||||||||||||||||||||||||||||||||
9598 | - | |||||||||||||||||||||||||||||||||||||
9599 | /*! | - | ||||||||||||||||||||||||||||||||||||
9600 | \fn void QWidget::paintEvent(QPaintEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9601 | - | |||||||||||||||||||||||||||||||||||||
9602 | This event handler can be reimplemented in a subclass to receive paint | - | ||||||||||||||||||||||||||||||||||||
9603 | events passed in \a event. | - | ||||||||||||||||||||||||||||||||||||
9604 | - | |||||||||||||||||||||||||||||||||||||
9605 | A paint event is a request to repaint all or part of a widget. It can | - | ||||||||||||||||||||||||||||||||||||
9606 | happen for one of the following reasons: | - | ||||||||||||||||||||||||||||||||||||
9607 | - | |||||||||||||||||||||||||||||||||||||
9608 | \list | - | ||||||||||||||||||||||||||||||||||||
9609 | \li repaint() or update() was invoked, | - | ||||||||||||||||||||||||||||||||||||
9610 | \li the widget was obscured and has now been uncovered, or | - | ||||||||||||||||||||||||||||||||||||
9611 | \li many other reasons. | - | ||||||||||||||||||||||||||||||||||||
9612 | \endlist | - | ||||||||||||||||||||||||||||||||||||
9613 | - | |||||||||||||||||||||||||||||||||||||
9614 | Many widgets can simply repaint their entire surface when asked to, but | - | ||||||||||||||||||||||||||||||||||||
9615 | some slow widgets need to optimize by painting only the requested region: | - | ||||||||||||||||||||||||||||||||||||
9616 | QPaintEvent::region(). This speed optimization does not change the result, | - | ||||||||||||||||||||||||||||||||||||
9617 | as painting is clipped to that region during event processing. QListView | - | ||||||||||||||||||||||||||||||||||||
9618 | and QTableView do this, for example. | - | ||||||||||||||||||||||||||||||||||||
9619 | - | |||||||||||||||||||||||||||||||||||||
9620 | Qt also tries to speed up painting by merging multiple paint events into | - | ||||||||||||||||||||||||||||||||||||
9621 | one. When update() is called several times or the window system sends | - | ||||||||||||||||||||||||||||||||||||
9622 | several paint events, Qt merges these events into one event with a larger | - | ||||||||||||||||||||||||||||||||||||
9623 | region (see QRegion::united()). The repaint() function does not permit this | - | ||||||||||||||||||||||||||||||||||||
9624 | optimization, so we suggest using update() whenever possible. | - | ||||||||||||||||||||||||||||||||||||
9625 | - | |||||||||||||||||||||||||||||||||||||
9626 | When the paint event occurs, the update region has normally been erased, so | - | ||||||||||||||||||||||||||||||||||||
9627 | you are painting on the widget's background. | - | ||||||||||||||||||||||||||||||||||||
9628 | - | |||||||||||||||||||||||||||||||||||||
9629 | The background can be set using setBackgroundRole() and setPalette(). | - | ||||||||||||||||||||||||||||||||||||
9630 | - | |||||||||||||||||||||||||||||||||||||
9631 | Since Qt 4.0, QWidget automatically double-buffers its painting, so there | - | ||||||||||||||||||||||||||||||||||||
9632 | is no need to write double-buffering code in paintEvent() to avoid flicker. | - | ||||||||||||||||||||||||||||||||||||
9633 | - | |||||||||||||||||||||||||||||||||||||
9634 | \note Generally, you should refrain from calling update() or repaint() | - | ||||||||||||||||||||||||||||||||||||
9635 | \b{inside} a paintEvent(). For example, calling update() or repaint() on | - | ||||||||||||||||||||||||||||||||||||
9636 | children inside a paintevent() results in undefined behavior; the child may | - | ||||||||||||||||||||||||||||||||||||
9637 | or may not get a paint event. | - | ||||||||||||||||||||||||||||||||||||
9638 | - | |||||||||||||||||||||||||||||||||||||
9639 | \warning If you are using a custom paint engine without Qt's backingstore, | - | ||||||||||||||||||||||||||||||||||||
9640 | Qt::WA_PaintOnScreen must be set. Otherwise, QWidget::paintEngine() will | - | ||||||||||||||||||||||||||||||||||||
9641 | never be called; the backingstore will be used instead. | - | ||||||||||||||||||||||||||||||||||||
9642 | - | |||||||||||||||||||||||||||||||||||||
9643 | \sa event(), repaint(), update(), QPainter, QPixmap, QPaintEvent, | - | ||||||||||||||||||||||||||||||||||||
9644 | {Analog Clock Example} | - | ||||||||||||||||||||||||||||||||||||
9645 | */ | - | ||||||||||||||||||||||||||||||||||||
9646 | - | |||||||||||||||||||||||||||||||||||||
9647 | void QWidget::paintEvent(QPaintEvent *) | - | ||||||||||||||||||||||||||||||||||||
9648 | { | - | ||||||||||||||||||||||||||||||||||||
9649 | } | - | ||||||||||||||||||||||||||||||||||||
9650 | - | |||||||||||||||||||||||||||||||||||||
9651 | - | |||||||||||||||||||||||||||||||||||||
9652 | /*! | - | ||||||||||||||||||||||||||||||||||||
9653 | \fn void QWidget::moveEvent(QMoveEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9654 | - | |||||||||||||||||||||||||||||||||||||
9655 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9656 | widget move events which are passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9657 | When the widget receives this event, it is already at the new | - | ||||||||||||||||||||||||||||||||||||
9658 | position. | - | ||||||||||||||||||||||||||||||||||||
9659 | - | |||||||||||||||||||||||||||||||||||||
9660 | The old position is accessible through QMoveEvent::oldPos(). | - | ||||||||||||||||||||||||||||||||||||
9661 | - | |||||||||||||||||||||||||||||||||||||
9662 | \sa resizeEvent(), event(), move(), QMoveEvent | - | ||||||||||||||||||||||||||||||||||||
9663 | */ | - | ||||||||||||||||||||||||||||||||||||
9664 | - | |||||||||||||||||||||||||||||||||||||
9665 | void QWidget::moveEvent(QMoveEvent *) | - | ||||||||||||||||||||||||||||||||||||
9666 | { | - | ||||||||||||||||||||||||||||||||||||
9667 | } | - | ||||||||||||||||||||||||||||||||||||
9668 | - | |||||||||||||||||||||||||||||||||||||
9669 | - | |||||||||||||||||||||||||||||||||||||
9670 | /*! | - | ||||||||||||||||||||||||||||||||||||
9671 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9672 | widget resize events which are passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9673 | When resizeEvent() is called, the widget already has its new | - | ||||||||||||||||||||||||||||||||||||
9674 | geometry. The old size is accessible through | - | ||||||||||||||||||||||||||||||||||||
9675 | QResizeEvent::oldSize(). | - | ||||||||||||||||||||||||||||||||||||
9676 | - | |||||||||||||||||||||||||||||||||||||
9677 | The widget will be erased and receive a paint event immediately | - | ||||||||||||||||||||||||||||||||||||
9678 | after processing the resize event. No drawing need be (or should | - | ||||||||||||||||||||||||||||||||||||
9679 | be) done inside this handler. | - | ||||||||||||||||||||||||||||||||||||
9680 | - | |||||||||||||||||||||||||||||||||||||
9681 | - | |||||||||||||||||||||||||||||||||||||
9682 | \sa moveEvent(), event(), resize(), QResizeEvent, paintEvent(), | - | ||||||||||||||||||||||||||||||||||||
9683 | {Scribble Example} | - | ||||||||||||||||||||||||||||||||||||
9684 | */ | - | ||||||||||||||||||||||||||||||||||||
9685 | - | |||||||||||||||||||||||||||||||||||||
9686 | void QWidget::resizeEvent(QResizeEvent * /* event */) | - | ||||||||||||||||||||||||||||||||||||
9687 | { | - | ||||||||||||||||||||||||||||||||||||
9688 | } | - | ||||||||||||||||||||||||||||||||||||
9689 | - | |||||||||||||||||||||||||||||||||||||
9690 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||||||||||||||
9691 | /*! | - | ||||||||||||||||||||||||||||||||||||
9692 | \fn void QWidget::actionEvent(QActionEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9693 | - | |||||||||||||||||||||||||||||||||||||
9694 | This event handler is called with the given \a event whenever the | - | ||||||||||||||||||||||||||||||||||||
9695 | widget's actions are changed. | - | ||||||||||||||||||||||||||||||||||||
9696 | - | |||||||||||||||||||||||||||||||||||||
9697 | \sa addAction(), insertAction(), removeAction(), actions(), QActionEvent | - | ||||||||||||||||||||||||||||||||||||
9698 | */ | - | ||||||||||||||||||||||||||||||||||||
9699 | void QWidget::actionEvent(QActionEvent *) | - | ||||||||||||||||||||||||||||||||||||
9700 | { | - | ||||||||||||||||||||||||||||||||||||
9701 | - | |||||||||||||||||||||||||||||||||||||
9702 | } | - | ||||||||||||||||||||||||||||||||||||
9703 | #endif | - | ||||||||||||||||||||||||||||||||||||
9704 | - | |||||||||||||||||||||||||||||||||||||
9705 | /*! | - | ||||||||||||||||||||||||||||||||||||
9706 | This event handler is called with the given \a event when Qt receives a window | - | ||||||||||||||||||||||||||||||||||||
9707 | close request for a top-level widget from the window system. | - | ||||||||||||||||||||||||||||||||||||
9708 | - | |||||||||||||||||||||||||||||||||||||
9709 | By default, the event is accepted and the widget is closed. You can reimplement | - | ||||||||||||||||||||||||||||||||||||
9710 | this function to change the way the widget responds to window close requests. | - | ||||||||||||||||||||||||||||||||||||
9711 | For example, you can prevent the window from closing by calling \l{QEvent::}{ignore()} | - | ||||||||||||||||||||||||||||||||||||
9712 | on all events. | - | ||||||||||||||||||||||||||||||||||||
9713 | - | |||||||||||||||||||||||||||||||||||||
9714 | Main window applications typically use reimplementations of this function to check | - | ||||||||||||||||||||||||||||||||||||
9715 | whether the user's work has been saved and ask for permission before closing. | - | ||||||||||||||||||||||||||||||||||||
9716 | For example, the \l{Application Example} uses a helper function to determine whether | - | ||||||||||||||||||||||||||||||||||||
9717 | or not to close the window: | - | ||||||||||||||||||||||||||||||||||||
9718 | - | |||||||||||||||||||||||||||||||||||||
9719 | \snippet mainwindows/application/mainwindow.cpp 3 | - | ||||||||||||||||||||||||||||||||||||
9720 | \snippet mainwindows/application/mainwindow.cpp 4 | - | ||||||||||||||||||||||||||||||||||||
9721 | - | |||||||||||||||||||||||||||||||||||||
9722 | \sa event(), hide(), close(), QCloseEvent, {Application Example} | - | ||||||||||||||||||||||||||||||||||||
9723 | */ | - | ||||||||||||||||||||||||||||||||||||
9724 | - | |||||||||||||||||||||||||||||||||||||
9725 | void QWidget::closeEvent(QCloseEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9726 | { | - | ||||||||||||||||||||||||||||||||||||
9727 | event->accept(); | - | ||||||||||||||||||||||||||||||||||||
9728 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9729 | - | |||||||||||||||||||||||||||||||||||||
9730 | #ifndef QT_NO_CONTEXTMENU | - | ||||||||||||||||||||||||||||||||||||
9731 | /*! | - | ||||||||||||||||||||||||||||||||||||
9732 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9733 | subclass to receive widget context menu events. | - | ||||||||||||||||||||||||||||||||||||
9734 | - | |||||||||||||||||||||||||||||||||||||
9735 | The handler is called when the widget's \l contextMenuPolicy is | - | ||||||||||||||||||||||||||||||||||||
9736 | Qt::DefaultContextMenu. | - | ||||||||||||||||||||||||||||||||||||
9737 | - | |||||||||||||||||||||||||||||||||||||
9738 | The default implementation ignores the context event. | - | ||||||||||||||||||||||||||||||||||||
9739 | See the \l QContextMenuEvent documentation for more details. | - | ||||||||||||||||||||||||||||||||||||
9740 | - | |||||||||||||||||||||||||||||||||||||
9741 | \sa event(), QContextMenuEvent, customContextMenuRequested() | - | ||||||||||||||||||||||||||||||||||||
9742 | */ | - | ||||||||||||||||||||||||||||||||||||
9743 | - | |||||||||||||||||||||||||||||||||||||
9744 | void QWidget::contextMenuEvent(QContextMenuEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9745 | { | - | ||||||||||||||||||||||||||||||||||||
9746 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9747 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9748 | #endif // QT_NO_CONTEXTMENU | - | ||||||||||||||||||||||||||||||||||||
9749 | - | |||||||||||||||||||||||||||||||||||||
9750 | - | |||||||||||||||||||||||||||||||||||||
9751 | /*! | - | ||||||||||||||||||||||||||||||||||||
9752 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9753 | subclass to receive Input Method composition events. This handler | - | ||||||||||||||||||||||||||||||||||||
9754 | is called when the state of the input method changes. | - | ||||||||||||||||||||||||||||||||||||
9755 | - | |||||||||||||||||||||||||||||||||||||
9756 | Note that when creating custom text editing widgets, the | - | ||||||||||||||||||||||||||||||||||||
9757 | Qt::WA_InputMethodEnabled window attribute must be set explicitly | - | ||||||||||||||||||||||||||||||||||||
9758 | (using the setAttribute() function) in order to receive input | - | ||||||||||||||||||||||||||||||||||||
9759 | method events. | - | ||||||||||||||||||||||||||||||||||||
9760 | - | |||||||||||||||||||||||||||||||||||||
9761 | The default implementation calls event->ignore(), which rejects the | - | ||||||||||||||||||||||||||||||||||||
9762 | Input Method event. See the \l QInputMethodEvent documentation for more | - | ||||||||||||||||||||||||||||||||||||
9763 | details. | - | ||||||||||||||||||||||||||||||||||||
9764 | - | |||||||||||||||||||||||||||||||||||||
9765 | \sa event(), QInputMethodEvent | - | ||||||||||||||||||||||||||||||||||||
9766 | */ | - | ||||||||||||||||||||||||||||||||||||
9767 | void QWidget::inputMethodEvent(QInputMethodEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9768 | { | - | ||||||||||||||||||||||||||||||||||||
9769 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9770 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9771 | - | |||||||||||||||||||||||||||||||||||||
9772 | /*! | - | ||||||||||||||||||||||||||||||||||||
9773 | This method is only relevant for input widgets. It is used by the | - | ||||||||||||||||||||||||||||||||||||
9774 | input method to query a set of properties of the widget to be | - | ||||||||||||||||||||||||||||||||||||
9775 | able to support complex input method operations as support for | - | ||||||||||||||||||||||||||||||||||||
9776 | surrounding text and reconversions. | - | ||||||||||||||||||||||||||||||||||||
9777 | - | |||||||||||||||||||||||||||||||||||||
9778 | \a query specifies which property is queried. | - | ||||||||||||||||||||||||||||||||||||
9779 | - | |||||||||||||||||||||||||||||||||||||
9780 | \sa inputMethodEvent(), QInputMethodEvent, QInputMethodQueryEvent, inputMethodHints | - | ||||||||||||||||||||||||||||||||||||
9781 | */ | - | ||||||||||||||||||||||||||||||||||||
9782 | QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const | - | ||||||||||||||||||||||||||||||||||||
9783 | { | - | ||||||||||||||||||||||||||||||||||||
9784 | switch(query) { | - | ||||||||||||||||||||||||||||||||||||
9785 | case Qt::ImCursorRectangle: never executed: case Qt::ImCursorRectangle: | 0 | ||||||||||||||||||||||||||||||||||||
9786 | return QRect(width()/2, 0, 1, height()); never executed: return QRect(width()/2, 0, 1, height()); | 0 | ||||||||||||||||||||||||||||||||||||
9787 | case Qt::ImFont: never executed: case Qt::ImFont: | 0 | ||||||||||||||||||||||||||||||||||||
9788 | return font(); never executed: return font(); | 0 | ||||||||||||||||||||||||||||||||||||
9789 | case Qt::ImAnchorPosition: never executed: case Qt::ImAnchorPosition: | 0 | ||||||||||||||||||||||||||||||||||||
9790 | // Fallback. | - | ||||||||||||||||||||||||||||||||||||
9791 | return inputMethodQuery(Qt::ImCursorPosition); never executed: return inputMethodQuery(Qt::ImCursorPosition); | 0 | ||||||||||||||||||||||||||||||||||||
9792 | case Qt::ImHints: never executed: case Qt::ImHints: | 0 | ||||||||||||||||||||||||||||||||||||
9793 | return (int)inputMethodHints(); never executed: return (int)inputMethodHints(); | 0 | ||||||||||||||||||||||||||||||||||||
9794 | case Qt::ImInputItemClipRectangle: never executed: case Qt::ImInputItemClipRectangle: | 0 | ||||||||||||||||||||||||||||||||||||
9795 | return d_func()->clipRect(); never executed: return d_func()->clipRect(); | 0 | ||||||||||||||||||||||||||||||||||||
9796 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
9797 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||||||||||||||||||||
9798 | } | - | ||||||||||||||||||||||||||||||||||||
9799 | } | - | ||||||||||||||||||||||||||||||||||||
9800 | - | |||||||||||||||||||||||||||||||||||||
9801 | /*! | - | ||||||||||||||||||||||||||||||||||||
9802 | \property QWidget::inputMethodHints | - | ||||||||||||||||||||||||||||||||||||
9803 | \brief What input method specific hints the widget has. | - | ||||||||||||||||||||||||||||||||||||
9804 | - | |||||||||||||||||||||||||||||||||||||
9805 | This is only relevant for input widgets. It is used by | - | ||||||||||||||||||||||||||||||||||||
9806 | the input method to retrieve hints as to how the input method | - | ||||||||||||||||||||||||||||||||||||
9807 | should operate. For example, if the Qt::ImhFormattedNumbersOnly flag | - | ||||||||||||||||||||||||||||||||||||
9808 | is set, the input method may change its visual components to reflect | - | ||||||||||||||||||||||||||||||||||||
9809 | that only numbers can be entered. | - | ||||||||||||||||||||||||||||||||||||
9810 | - | |||||||||||||||||||||||||||||||||||||
9811 | \warning Some widgets require certain flags in order to work as | - | ||||||||||||||||||||||||||||||||||||
9812 | intended. To set a flag, do \c{w->setInputMethodHints(w->inputMethodHints()|f)} | - | ||||||||||||||||||||||||||||||||||||
9813 | instead of \c{w->setInputMethodHints(f)}. | - | ||||||||||||||||||||||||||||||||||||
9814 | - | |||||||||||||||||||||||||||||||||||||
9815 | \note The flags are only hints, so the particular input method | - | ||||||||||||||||||||||||||||||||||||
9816 | implementation is free to ignore them. If you want to be | - | ||||||||||||||||||||||||||||||||||||
9817 | sure that a certain type of characters are entered, | - | ||||||||||||||||||||||||||||||||||||
9818 | you should also set a QValidator on the widget. | - | ||||||||||||||||||||||||||||||||||||
9819 | - | |||||||||||||||||||||||||||||||||||||
9820 | The default value is Qt::ImhNone. | - | ||||||||||||||||||||||||||||||||||||
9821 | - | |||||||||||||||||||||||||||||||||||||
9822 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
9823 | - | |||||||||||||||||||||||||||||||||||||
9824 | \sa inputMethodQuery() | - | ||||||||||||||||||||||||||||||||||||
9825 | */ | - | ||||||||||||||||||||||||||||||||||||
9826 | Qt::InputMethodHints QWidget::inputMethodHints() const | - | ||||||||||||||||||||||||||||||||||||
9827 | { | - | ||||||||||||||||||||||||||||||||||||
9828 | #ifndef QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
9829 | const QWidgetPrivate *priv = d_func(); | - | ||||||||||||||||||||||||||||||||||||
9830 | while (priv->inheritsInputMethodHints) {
| 0 | ||||||||||||||||||||||||||||||||||||
9831 | priv = priv->q_func()->parentWidget()->d_func(); | - | ||||||||||||||||||||||||||||||||||||
9832 | Q_ASSERT(priv); | - | ||||||||||||||||||||||||||||||||||||
9833 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9834 | return priv->imHints; never executed: return priv->imHints; | 0 | ||||||||||||||||||||||||||||||||||||
9835 | #else //QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
9836 | return 0; | - | ||||||||||||||||||||||||||||||||||||
9837 | #endif //QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
9838 | } | - | ||||||||||||||||||||||||||||||||||||
9839 | - | |||||||||||||||||||||||||||||||||||||
9840 | void QWidget::setInputMethodHints(Qt::InputMethodHints hints) | - | ||||||||||||||||||||||||||||||||||||
9841 | { | - | ||||||||||||||||||||||||||||||||||||
9842 | #ifndef QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
9843 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
9844 | if (d->imHints == hints)
| 0 | ||||||||||||||||||||||||||||||||||||
9845 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
9846 | d->imHints = hints; | - | ||||||||||||||||||||||||||||||||||||
9847 | if (this == QGuiApplication::focusObject())
| 0 | ||||||||||||||||||||||||||||||||||||
9848 | QGuiApplication::inputMethod()->update(Qt::ImHints); never executed: QGuiApplication::inputMethod()->update(Qt::ImHints); | 0 | ||||||||||||||||||||||||||||||||||||
9849 | #else | - | ||||||||||||||||||||||||||||||||||||
9850 | Q_UNUSED(hints); | - | ||||||||||||||||||||||||||||||||||||
9851 | #endif //QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
9852 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9853 | - | |||||||||||||||||||||||||||||||||||||
9854 | - | |||||||||||||||||||||||||||||||||||||
9855 | #ifndef QT_NO_DRAGANDDROP | - | ||||||||||||||||||||||||||||||||||||
9856 | - | |||||||||||||||||||||||||||||||||||||
9857 | /*! | - | ||||||||||||||||||||||||||||||||||||
9858 | \fn void QWidget::dragEnterEvent(QDragEnterEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9859 | - | |||||||||||||||||||||||||||||||||||||
9860 | This event handler is called when a drag is in progress and the | - | ||||||||||||||||||||||||||||||||||||
9861 | mouse enters this widget. The event is passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9862 | - | |||||||||||||||||||||||||||||||||||||
9863 | If the event is ignored, the widget won't receive any \l{dragMoveEvent()}{drag | - | ||||||||||||||||||||||||||||||||||||
9864 | move events}. | - | ||||||||||||||||||||||||||||||||||||
9865 | - | |||||||||||||||||||||||||||||||||||||
9866 | See the \l{dnd.html}{Drag-and-drop documentation} for an | - | ||||||||||||||||||||||||||||||||||||
9867 | overview of how to provide drag-and-drop in your application. | - | ||||||||||||||||||||||||||||||||||||
9868 | - | |||||||||||||||||||||||||||||||||||||
9869 | \sa QDrag, QDragEnterEvent | - | ||||||||||||||||||||||||||||||||||||
9870 | */ | - | ||||||||||||||||||||||||||||||||||||
9871 | void QWidget::dragEnterEvent(QDragEnterEvent *) | - | ||||||||||||||||||||||||||||||||||||
9872 | { | - | ||||||||||||||||||||||||||||||||||||
9873 | } | - | ||||||||||||||||||||||||||||||||||||
9874 | - | |||||||||||||||||||||||||||||||||||||
9875 | /*! | - | ||||||||||||||||||||||||||||||||||||
9876 | \fn void QWidget::dragMoveEvent(QDragMoveEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9877 | - | |||||||||||||||||||||||||||||||||||||
9878 | This event handler is called if a drag is in progress, and when | - | ||||||||||||||||||||||||||||||||||||
9879 | any of the following conditions occur: the cursor enters this widget, | - | ||||||||||||||||||||||||||||||||||||
9880 | the cursor moves within this widget, or a modifier key is pressed on | - | ||||||||||||||||||||||||||||||||||||
9881 | the keyboard while this widget has the focus. The event is passed | - | ||||||||||||||||||||||||||||||||||||
9882 | in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9883 | - | |||||||||||||||||||||||||||||||||||||
9884 | See the \l{dnd.html}{Drag-and-drop documentation} for an | - | ||||||||||||||||||||||||||||||||||||
9885 | overview of how to provide drag-and-drop in your application. | - | ||||||||||||||||||||||||||||||||||||
9886 | - | |||||||||||||||||||||||||||||||||||||
9887 | \sa QDrag, QDragMoveEvent | - | ||||||||||||||||||||||||||||||||||||
9888 | */ | - | ||||||||||||||||||||||||||||||||||||
9889 | void QWidget::dragMoveEvent(QDragMoveEvent *) | - | ||||||||||||||||||||||||||||||||||||
9890 | { | - | ||||||||||||||||||||||||||||||||||||
9891 | } | - | ||||||||||||||||||||||||||||||||||||
9892 | - | |||||||||||||||||||||||||||||||||||||
9893 | /*! | - | ||||||||||||||||||||||||||||||||||||
9894 | \fn void QWidget::dragLeaveEvent(QDragLeaveEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9895 | - | |||||||||||||||||||||||||||||||||||||
9896 | This event handler is called when a drag is in progress and the | - | ||||||||||||||||||||||||||||||||||||
9897 | mouse leaves this widget. The event is passed in the \a event | - | ||||||||||||||||||||||||||||||||||||
9898 | parameter. | - | ||||||||||||||||||||||||||||||||||||
9899 | - | |||||||||||||||||||||||||||||||||||||
9900 | See the \l{dnd.html}{Drag-and-drop documentation} for an | - | ||||||||||||||||||||||||||||||||||||
9901 | overview of how to provide drag-and-drop in your application. | - | ||||||||||||||||||||||||||||||||||||
9902 | - | |||||||||||||||||||||||||||||||||||||
9903 | \sa QDrag, QDragLeaveEvent | - | ||||||||||||||||||||||||||||||||||||
9904 | */ | - | ||||||||||||||||||||||||||||||||||||
9905 | void QWidget::dragLeaveEvent(QDragLeaveEvent *) | - | ||||||||||||||||||||||||||||||||||||
9906 | { | - | ||||||||||||||||||||||||||||||||||||
9907 | } | - | ||||||||||||||||||||||||||||||||||||
9908 | - | |||||||||||||||||||||||||||||||||||||
9909 | /*! | - | ||||||||||||||||||||||||||||||||||||
9910 | \fn void QWidget::dropEvent(QDropEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9911 | - | |||||||||||||||||||||||||||||||||||||
9912 | This event handler is called when the drag is dropped on this | - | ||||||||||||||||||||||||||||||||||||
9913 | widget. The event is passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9914 | - | |||||||||||||||||||||||||||||||||||||
9915 | See the \l{dnd.html}{Drag-and-drop documentation} for an | - | ||||||||||||||||||||||||||||||||||||
9916 | overview of how to provide drag-and-drop in your application. | - | ||||||||||||||||||||||||||||||||||||
9917 | - | |||||||||||||||||||||||||||||||||||||
9918 | \sa QDrag, QDropEvent | - | ||||||||||||||||||||||||||||||||||||
9919 | */ | - | ||||||||||||||||||||||||||||||||||||
9920 | void QWidget::dropEvent(QDropEvent *) | - | ||||||||||||||||||||||||||||||||||||
9921 | { | - | ||||||||||||||||||||||||||||||||||||
9922 | } | - | ||||||||||||||||||||||||||||||||||||
9923 | - | |||||||||||||||||||||||||||||||||||||
9924 | #endif // QT_NO_DRAGANDDROP | - | ||||||||||||||||||||||||||||||||||||
9925 | - | |||||||||||||||||||||||||||||||||||||
9926 | /*! | - | ||||||||||||||||||||||||||||||||||||
9927 | \fn void QWidget::showEvent(QShowEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9928 | - | |||||||||||||||||||||||||||||||||||||
9929 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9930 | widget show events which are passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9931 | - | |||||||||||||||||||||||||||||||||||||
9932 | Non-spontaneous show events are sent to widgets immediately | - | ||||||||||||||||||||||||||||||||||||
9933 | before they are shown. The spontaneous show events of windows are | - | ||||||||||||||||||||||||||||||||||||
9934 | delivered afterwards. | - | ||||||||||||||||||||||||||||||||||||
9935 | - | |||||||||||||||||||||||||||||||||||||
9936 | Note: A widget receives spontaneous show and hide events when its | - | ||||||||||||||||||||||||||||||||||||
9937 | mapping status is changed by the window system, e.g. a spontaneous | - | ||||||||||||||||||||||||||||||||||||
9938 | hide event when the user minimizes the window, and a spontaneous | - | ||||||||||||||||||||||||||||||||||||
9939 | show event when the window is restored again. After receiving a | - | ||||||||||||||||||||||||||||||||||||
9940 | spontaneous hide event, a widget is still considered visible in | - | ||||||||||||||||||||||||||||||||||||
9941 | the sense of isVisible(). | - | ||||||||||||||||||||||||||||||||||||
9942 | - | |||||||||||||||||||||||||||||||||||||
9943 | \sa visible, event(), QShowEvent | - | ||||||||||||||||||||||||||||||||||||
9944 | */ | - | ||||||||||||||||||||||||||||||||||||
9945 | void QWidget::showEvent(QShowEvent *) | - | ||||||||||||||||||||||||||||||||||||
9946 | { | - | ||||||||||||||||||||||||||||||||||||
9947 | } | - | ||||||||||||||||||||||||||||||||||||
9948 | - | |||||||||||||||||||||||||||||||||||||
9949 | /*! | - | ||||||||||||||||||||||||||||||||||||
9950 | \fn void QWidget::hideEvent(QHideEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9951 | - | |||||||||||||||||||||||||||||||||||||
9952 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9953 | widget hide events. The event is passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9954 | - | |||||||||||||||||||||||||||||||||||||
9955 | Hide events are sent to widgets immediately after they have been | - | ||||||||||||||||||||||||||||||||||||
9956 | hidden. | - | ||||||||||||||||||||||||||||||||||||
9957 | - | |||||||||||||||||||||||||||||||||||||
9958 | Note: A widget receives spontaneous show and hide events when its | - | ||||||||||||||||||||||||||||||||||||
9959 | mapping status is changed by the window system, e.g. a spontaneous | - | ||||||||||||||||||||||||||||||||||||
9960 | hide event when the user minimizes the window, and a spontaneous | - | ||||||||||||||||||||||||||||||||||||
9961 | show event when the window is restored again. After receiving a | - | ||||||||||||||||||||||||||||||||||||
9962 | spontaneous hide event, a widget is still considered visible in | - | ||||||||||||||||||||||||||||||||||||
9963 | the sense of isVisible(). | - | ||||||||||||||||||||||||||||||||||||
9964 | - | |||||||||||||||||||||||||||||||||||||
9965 | \sa visible, event(), QHideEvent | - | ||||||||||||||||||||||||||||||||||||
9966 | */ | - | ||||||||||||||||||||||||||||||||||||
9967 | void QWidget::hideEvent(QHideEvent *) | - | ||||||||||||||||||||||||||||||||||||
9968 | { | - | ||||||||||||||||||||||||||||||||||||
9969 | } | - | ||||||||||||||||||||||||||||||||||||
9970 | - | |||||||||||||||||||||||||||||||||||||
9971 | /*! | - | ||||||||||||||||||||||||||||||||||||
9972 | This special event handler can be reimplemented in a subclass to | - | ||||||||||||||||||||||||||||||||||||
9973 | receive native platform events identified by \a eventType | - | ||||||||||||||||||||||||||||||||||||
9974 | which are passed in the \a message parameter. | - | ||||||||||||||||||||||||||||||||||||
9975 | - | |||||||||||||||||||||||||||||||||||||
9976 | In your reimplementation of this function, if you want to stop the | - | ||||||||||||||||||||||||||||||||||||
9977 | event being handled by Qt, return true and set \a result. | - | ||||||||||||||||||||||||||||||||||||
9978 | If you return false, this native event is passed back to Qt, | - | ||||||||||||||||||||||||||||||||||||
9979 | which translates the event into a Qt event and sends it to the widget. | - | ||||||||||||||||||||||||||||||||||||
9980 | - | |||||||||||||||||||||||||||||||||||||
9981 | \note Events are only delivered to this event handler if the widget is | - | ||||||||||||||||||||||||||||||||||||
9982 | has a native Window handle. | - | ||||||||||||||||||||||||||||||||||||
9983 | - | |||||||||||||||||||||||||||||||||||||
9984 | \note This function superseedes the event filter functions | - | ||||||||||||||||||||||||||||||||||||
9985 | x11Event(), winEvent() and macEvent() of Qt 4. | - | ||||||||||||||||||||||||||||||||||||
9986 | - | |||||||||||||||||||||||||||||||||||||
9987 | \table | - | ||||||||||||||||||||||||||||||||||||
9988 | \header \li Platform \li Event Type Identifier \li Message Type \li Result Type | - | ||||||||||||||||||||||||||||||||||||
9989 | \row \li Windows \li "windows_generic_MSG" \li MSG * \li LRESULT | - | ||||||||||||||||||||||||||||||||||||
9990 | \endtable | - | ||||||||||||||||||||||||||||||||||||
9991 | */ | - | ||||||||||||||||||||||||||||||||||||
9992 | - | |||||||||||||||||||||||||||||||||||||
9993 | bool QWidget::nativeEvent(const QByteArray &eventType, void *message, long *result) | - | ||||||||||||||||||||||||||||||||||||
9994 | { | - | ||||||||||||||||||||||||||||||||||||
9995 | Q_UNUSED(eventType); | - | ||||||||||||||||||||||||||||||||||||
9996 | Q_UNUSED(message); | - | ||||||||||||||||||||||||||||||||||||
9997 | Q_UNUSED(result); | - | ||||||||||||||||||||||||||||||||||||
9998 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
9999 | } | - | ||||||||||||||||||||||||||||||||||||
10000 | - | |||||||||||||||||||||||||||||||||||||
10001 | /*! | - | ||||||||||||||||||||||||||||||||||||
10002 | Ensures that the widget has been polished by QStyle (i.e., has a | - | ||||||||||||||||||||||||||||||||||||
10003 | proper font and palette). | - | ||||||||||||||||||||||||||||||||||||
10004 | - | |||||||||||||||||||||||||||||||||||||
10005 | QWidget calls this function after it has been fully constructed | - | ||||||||||||||||||||||||||||||||||||
10006 | but before it is shown the very first time. You can call this | - | ||||||||||||||||||||||||||||||||||||
10007 | function if you want to ensure that the widget is polished before | - | ||||||||||||||||||||||||||||||||||||
10008 | doing an operation, e.g., the correct font size might be needed in | - | ||||||||||||||||||||||||||||||||||||
10009 | the widget's sizeHint() reimplementation. Note that this function | - | ||||||||||||||||||||||||||||||||||||
10010 | \e is called from the default implementation of sizeHint(). | - | ||||||||||||||||||||||||||||||||||||
10011 | - | |||||||||||||||||||||||||||||||||||||
10012 | Polishing is useful for final initialization that must happen after | - | ||||||||||||||||||||||||||||||||||||
10013 | all constructors (from base classes as well as from subclasses) | - | ||||||||||||||||||||||||||||||||||||
10014 | have been called. | - | ||||||||||||||||||||||||||||||||||||
10015 | - | |||||||||||||||||||||||||||||||||||||
10016 | If you need to change some settings when a widget is polished, | - | ||||||||||||||||||||||||||||||||||||
10017 | reimplement event() and handle the QEvent::Polish event type. | - | ||||||||||||||||||||||||||||||||||||
10018 | - | |||||||||||||||||||||||||||||||||||||
10019 | \b{Note:} The function is declared const so that it can be called from | - | ||||||||||||||||||||||||||||||||||||
10020 | other const functions (e.g., sizeHint()). | - | ||||||||||||||||||||||||||||||||||||
10021 | - | |||||||||||||||||||||||||||||||||||||
10022 | \sa event() | - | ||||||||||||||||||||||||||||||||||||
10023 | */ | - | ||||||||||||||||||||||||||||||||||||
10024 | void QWidget::ensurePolished() const | - | ||||||||||||||||||||||||||||||||||||
10025 | { | - | ||||||||||||||||||||||||||||||||||||
10026 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
10027 | - | |||||||||||||||||||||||||||||||||||||
10028 | const QMetaObject *m = metaObject(); | - | ||||||||||||||||||||||||||||||||||||
10029 | if (m == d->polished)
| 0 | ||||||||||||||||||||||||||||||||||||
10030 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10031 | d->polished = m; | - | ||||||||||||||||||||||||||||||||||||
10032 | - | |||||||||||||||||||||||||||||||||||||
10033 | QEvent e(QEvent::Polish); | - | ||||||||||||||||||||||||||||||||||||
10034 | QCoreApplication::sendEvent(const_cast<QWidget *>(this), &e); | - | ||||||||||||||||||||||||||||||||||||
10035 | - | |||||||||||||||||||||||||||||||||||||
10036 | // polish children after 'this' | - | ||||||||||||||||||||||||||||||||||||
10037 | QList<QObject*> children = d->children; | - | ||||||||||||||||||||||||||||||||||||
10038 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
10039 | QObject *o = children.at(i); | - | ||||||||||||||||||||||||||||||||||||
10040 | if(!o->isWidgetType())
| 0 | ||||||||||||||||||||||||||||||||||||
10041 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
10042 | if (QWidget *w = qobject_cast<QWidget *>(o))
| 0 | ||||||||||||||||||||||||||||||||||||
10043 | w->ensurePolished(); never executed: w->ensurePolished(); | 0 | ||||||||||||||||||||||||||||||||||||
10044 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10045 | - | |||||||||||||||||||||||||||||||||||||
10046 | if (d->parent && d->sendChildEvents) {
| 0 | ||||||||||||||||||||||||||||||||||||
10047 | QChildEvent e(QEvent::ChildPolished, const_cast<QWidget *>(this)); | - | ||||||||||||||||||||||||||||||||||||
10048 | QCoreApplication::sendEvent(d->parent, &e); | - | ||||||||||||||||||||||||||||||||||||
10049 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10050 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10051 | - | |||||||||||||||||||||||||||||||||||||
10052 | /*! | - | ||||||||||||||||||||||||||||||||||||
10053 | Returns the mask currently set on a widget. If no mask is set the | - | ||||||||||||||||||||||||||||||||||||
10054 | return value will be an empty region. | - | ||||||||||||||||||||||||||||||||||||
10055 | - | |||||||||||||||||||||||||||||||||||||
10056 | \sa setMask(), clearMask(), QRegion::isEmpty(), {Shaped Clock Example} | - | ||||||||||||||||||||||||||||||||||||
10057 | */ | - | ||||||||||||||||||||||||||||||||||||
10058 | QRegion QWidget::mask() const | - | ||||||||||||||||||||||||||||||||||||
10059 | { | - | ||||||||||||||||||||||||||||||||||||
10060 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
10061 | return d->extra ? d->extra->mask : QRegion(); never executed: return d->extra ? d->extra->mask : QRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
10062 | } | - | ||||||||||||||||||||||||||||||||||||
10063 | - | |||||||||||||||||||||||||||||||||||||
10064 | /*! | - | ||||||||||||||||||||||||||||||||||||
10065 | Returns the layout manager that is installed on this widget, or 0 | - | ||||||||||||||||||||||||||||||||||||
10066 | if no layout manager is installed. | - | ||||||||||||||||||||||||||||||||||||
10067 | - | |||||||||||||||||||||||||||||||||||||
10068 | The layout manager sets the geometry of the widget's children | - | ||||||||||||||||||||||||||||||||||||
10069 | that have been added to the layout. | - | ||||||||||||||||||||||||||||||||||||
10070 | - | |||||||||||||||||||||||||||||||||||||
10071 | \sa setLayout(), sizePolicy(), {Layout Management} | - | ||||||||||||||||||||||||||||||||||||
10072 | */ | - | ||||||||||||||||||||||||||||||||||||
10073 | QLayout *QWidget::layout() const | - | ||||||||||||||||||||||||||||||||||||
10074 | { | - | ||||||||||||||||||||||||||||||||||||
10075 | return d_func()->layout; never executed: return d_func()->layout; | 0 | ||||||||||||||||||||||||||||||||||||
10076 | } | - | ||||||||||||||||||||||||||||||||||||
10077 | - | |||||||||||||||||||||||||||||||||||||
10078 | - | |||||||||||||||||||||||||||||||||||||
10079 | /*! | - | ||||||||||||||||||||||||||||||||||||
10080 | \fn void QWidget::setLayout(QLayout *layout) | - | ||||||||||||||||||||||||||||||||||||
10081 | - | |||||||||||||||||||||||||||||||||||||
10082 | Sets the layout manager for this widget to \a layout. | - | ||||||||||||||||||||||||||||||||||||
10083 | - | |||||||||||||||||||||||||||||||||||||
10084 | If there already is a layout manager installed on this widget, | - | ||||||||||||||||||||||||||||||||||||
10085 | QWidget won't let you install another. You must first delete the | - | ||||||||||||||||||||||||||||||||||||
10086 | existing layout manager (returned by layout()) before you can | - | ||||||||||||||||||||||||||||||||||||
10087 | call setLayout() with the new layout. | - | ||||||||||||||||||||||||||||||||||||
10088 | - | |||||||||||||||||||||||||||||||||||||
10089 | If \a layout is the layout manager on a different widget, setLayout() | - | ||||||||||||||||||||||||||||||||||||
10090 | will reparent the layout and make it the layout manager for this widget. | - | ||||||||||||||||||||||||||||||||||||
10091 | - | |||||||||||||||||||||||||||||||||||||
10092 | Example: | - | ||||||||||||||||||||||||||||||||||||
10093 | - | |||||||||||||||||||||||||||||||||||||
10094 | \snippet layouts/layouts.cpp 24 | - | ||||||||||||||||||||||||||||||||||||
10095 | - | |||||||||||||||||||||||||||||||||||||
10096 | An alternative to calling this function is to pass this widget to | - | ||||||||||||||||||||||||||||||||||||
10097 | the layout's constructor. | - | ||||||||||||||||||||||||||||||||||||
10098 | - | |||||||||||||||||||||||||||||||||||||
10099 | The QWidget will take ownership of \a layout. | - | ||||||||||||||||||||||||||||||||||||
10100 | - | |||||||||||||||||||||||||||||||||||||
10101 | \sa layout(), {Layout Management} | - | ||||||||||||||||||||||||||||||||||||
10102 | */ | - | ||||||||||||||||||||||||||||||||||||
10103 | - | |||||||||||||||||||||||||||||||||||||
10104 | void QWidget::setLayout(QLayout *l) | - | ||||||||||||||||||||||||||||||||||||
10105 | { | - | ||||||||||||||||||||||||||||||||||||
10106 | if (Q_UNLIKELY(!l)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10107 | qWarning("QWidget::setLayout: Cannot set layout to 0"); | - | ||||||||||||||||||||||||||||||||||||
10108 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10109 | } | - | ||||||||||||||||||||||||||||||||||||
10110 | if (layout()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10111 | if (Q_UNLIKELY(layout() != l))
| 0 | ||||||||||||||||||||||||||||||||||||
10112 | qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a" never executed: QMessageLogger(__FILE__, 10112, __PRETTY_FUNCTION__).warning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a" " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(), objectName().toLocal8Bit().data()); | 0 | ||||||||||||||||||||||||||||||||||||
10113 | " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(), never executed: QMessageLogger(__FILE__, 10112, __PRETTY_FUNCTION__).warning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a" " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(), objectName().toLocal8Bit().data()); | 0 | ||||||||||||||||||||||||||||||||||||
10114 | objectName().toLocal8Bit().data()); never executed: QMessageLogger(__FILE__, 10112, __PRETTY_FUNCTION__).warning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a" " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(), objectName().toLocal8Bit().data()); | 0 | ||||||||||||||||||||||||||||||||||||
10115 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10116 | } | - | ||||||||||||||||||||||||||||||||||||
10117 | - | |||||||||||||||||||||||||||||||||||||
10118 | QObject *oldParent = l->parent(); | - | ||||||||||||||||||||||||||||||||||||
10119 | if (oldParent && oldParent != this) {
| 0 | ||||||||||||||||||||||||||||||||||||
10120 | if (oldParent->isWidgetType()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10121 | // Steal the layout off a widget parent. Takes effect when | - | ||||||||||||||||||||||||||||||||||||
10122 | // morphing laid-out container widgets in Designer. | - | ||||||||||||||||||||||||||||||||||||
10123 | QWidget *oldParentWidget = static_cast<QWidget *>(oldParent); | - | ||||||||||||||||||||||||||||||||||||
10124 | oldParentWidget->takeLayout(); | - | ||||||||||||||||||||||||||||||||||||
10125 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10126 | qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent", | - | ||||||||||||||||||||||||||||||||||||
10127 | l->objectName().toLocal8Bit().data(), metaObject()->className(), | - | ||||||||||||||||||||||||||||||||||||
10128 | objectName().toLocal8Bit().data()); | - | ||||||||||||||||||||||||||||||||||||
10129 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10130 | } | - | ||||||||||||||||||||||||||||||||||||
10131 | } | - | ||||||||||||||||||||||||||||||||||||
10132 | - | |||||||||||||||||||||||||||||||||||||
10133 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10134 | l->d_func()->topLevel = true; | - | ||||||||||||||||||||||||||||||||||||
10135 | d->layout = l; | - | ||||||||||||||||||||||||||||||||||||
10136 | if (oldParent != this) {
| 0 | ||||||||||||||||||||||||||||||||||||
10137 | l->setParent(this); | - | ||||||||||||||||||||||||||||||||||||
10138 | l->d_func()->reparentChildWidgets(this); | - | ||||||||||||||||||||||||||||||||||||
10139 | l->invalidate(); | - | ||||||||||||||||||||||||||||||||||||
10140 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10141 | - | |||||||||||||||||||||||||||||||||||||
10142 | if (isWindow() && d->maybeTopData())
| 0 | ||||||||||||||||||||||||||||||||||||
10143 | d->topData()->sizeAdjusted = false; never executed: d->topData()->sizeAdjusted = false; | 0 | ||||||||||||||||||||||||||||||||||||
10144 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10145 | - | |||||||||||||||||||||||||||||||||||||
10146 | /*! | - | ||||||||||||||||||||||||||||||||||||
10147 | \fn QLayout *QWidget::takeLayout() | - | ||||||||||||||||||||||||||||||||||||
10148 | - | |||||||||||||||||||||||||||||||||||||
10149 | Remove the layout from the widget. | - | ||||||||||||||||||||||||||||||||||||
10150 | \since 4.5 | - | ||||||||||||||||||||||||||||||||||||
10151 | */ | - | ||||||||||||||||||||||||||||||||||||
10152 | - | |||||||||||||||||||||||||||||||||||||
10153 | QLayout *QWidget::takeLayout() | - | ||||||||||||||||||||||||||||||||||||
10154 | { | - | ||||||||||||||||||||||||||||||||||||
10155 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10156 | QLayout *l = layout(); | - | ||||||||||||||||||||||||||||||||||||
10157 | if (!l)
| 0 | ||||||||||||||||||||||||||||||||||||
10158 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
10159 | d->layout = 0; | - | ||||||||||||||||||||||||||||||||||||
10160 | l->setParent(0); | - | ||||||||||||||||||||||||||||||||||||
10161 | return l; never executed: return l; | 0 | ||||||||||||||||||||||||||||||||||||
10162 | } | - | ||||||||||||||||||||||||||||||||||||
10163 | - | |||||||||||||||||||||||||||||||||||||
10164 | /*! | - | ||||||||||||||||||||||||||||||||||||
10165 | \property QWidget::sizePolicy | - | ||||||||||||||||||||||||||||||||||||
10166 | \brief the default layout behavior of the widget | - | ||||||||||||||||||||||||||||||||||||
10167 | - | |||||||||||||||||||||||||||||||||||||
10168 | If there is a QLayout that manages this widget's children, the | - | ||||||||||||||||||||||||||||||||||||
10169 | size policy specified by that layout is used. If there is no such | - | ||||||||||||||||||||||||||||||||||||
10170 | QLayout, the result of this function is used. | - | ||||||||||||||||||||||||||||||||||||
10171 | - | |||||||||||||||||||||||||||||||||||||
10172 | The default policy is Preferred/Preferred, which means that the | - | ||||||||||||||||||||||||||||||||||||
10173 | widget can be freely resized, but prefers to be the size | - | ||||||||||||||||||||||||||||||||||||
10174 | sizeHint() returns. Button-like widgets set the size policy to | - | ||||||||||||||||||||||||||||||||||||
10175 | specify that they may stretch horizontally, but are fixed | - | ||||||||||||||||||||||||||||||||||||
10176 | vertically. The same applies to lineedit controls (such as | - | ||||||||||||||||||||||||||||||||||||
10177 | QLineEdit, QSpinBox or an editable QComboBox) and other | - | ||||||||||||||||||||||||||||||||||||
10178 | horizontally orientated widgets (such as QProgressBar). | - | ||||||||||||||||||||||||||||||||||||
10179 | QToolButton's are normally square, so they allow growth in both | - | ||||||||||||||||||||||||||||||||||||
10180 | directions. Widgets that support different directions (such as | - | ||||||||||||||||||||||||||||||||||||
10181 | QSlider, QScrollBar or QHeader) specify stretching in the | - | ||||||||||||||||||||||||||||||||||||
10182 | respective direction only. Widgets that can provide scroll bars | - | ||||||||||||||||||||||||||||||||||||
10183 | (usually subclasses of QScrollArea) tend to specify that they can | - | ||||||||||||||||||||||||||||||||||||
10184 | use additional space, and that they can make do with less than | - | ||||||||||||||||||||||||||||||||||||
10185 | sizeHint(). | - | ||||||||||||||||||||||||||||||||||||
10186 | - | |||||||||||||||||||||||||||||||||||||
10187 | \sa sizeHint(), QLayout, QSizePolicy, updateGeometry() | - | ||||||||||||||||||||||||||||||||||||
10188 | */ | - | ||||||||||||||||||||||||||||||||||||
10189 | QSizePolicy QWidget::sizePolicy() const | - | ||||||||||||||||||||||||||||||||||||
10190 | { | - | ||||||||||||||||||||||||||||||||||||
10191 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
10192 | return d->size_policy; never executed: return d->size_policy; | 0 | ||||||||||||||||||||||||||||||||||||
10193 | } | - | ||||||||||||||||||||||||||||||||||||
10194 | - | |||||||||||||||||||||||||||||||||||||
10195 | void QWidget::setSizePolicy(QSizePolicy policy) | - | ||||||||||||||||||||||||||||||||||||
10196 | { | - | ||||||||||||||||||||||||||||||||||||
10197 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10198 | setAttribute(Qt::WA_WState_OwnSizePolicy); | - | ||||||||||||||||||||||||||||||||||||
10199 | if (policy == d->size_policy)
| 0 | ||||||||||||||||||||||||||||||||||||
10200 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10201 | - | |||||||||||||||||||||||||||||||||||||
10202 | if (d->size_policy.retainSizeWhenHidden() != policy.retainSizeWhenHidden())
| 0 | ||||||||||||||||||||||||||||||||||||
10203 | d->retainSizeWhenHiddenChanged = 1; never executed: d->retainSizeWhenHiddenChanged = 1; | 0 | ||||||||||||||||||||||||||||||||||||
10204 | - | |||||||||||||||||||||||||||||||||||||
10205 | d->size_policy = policy; | - | ||||||||||||||||||||||||||||||||||||
10206 | - | |||||||||||||||||||||||||||||||||||||
10207 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
10208 | if (QWExtra *extra = d->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
10209 | if (extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
10210 | extra->proxyWidget->setSizePolicy(policy); never executed: extra->proxyWidget->setSizePolicy(policy); | 0 | ||||||||||||||||||||||||||||||||||||
10211 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10212 | #endif | - | ||||||||||||||||||||||||||||||||||||
10213 | - | |||||||||||||||||||||||||||||||||||||
10214 | updateGeometry(); | - | ||||||||||||||||||||||||||||||||||||
10215 | d->retainSizeWhenHiddenChanged = 0; | - | ||||||||||||||||||||||||||||||||||||
10216 | - | |||||||||||||||||||||||||||||||||||||
10217 | if (isWindow() && d->maybeTopData())
| 0 | ||||||||||||||||||||||||||||||||||||
10218 | d->topData()->sizeAdjusted = false; never executed: d->topData()->sizeAdjusted = false; | 0 | ||||||||||||||||||||||||||||||||||||
10219 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10220 | - | |||||||||||||||||||||||||||||||||||||
10221 | /*! | - | ||||||||||||||||||||||||||||||||||||
10222 | \fn void QWidget::setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical) | - | ||||||||||||||||||||||||||||||||||||
10223 | \overload | - | ||||||||||||||||||||||||||||||||||||
10224 | - | |||||||||||||||||||||||||||||||||||||
10225 | Sets the size policy of the widget to \a horizontal and \a | - | ||||||||||||||||||||||||||||||||||||
10226 | vertical, with standard stretch and no height-for-width. | - | ||||||||||||||||||||||||||||||||||||
10227 | - | |||||||||||||||||||||||||||||||||||||
10228 | \sa QSizePolicy::QSizePolicy() | - | ||||||||||||||||||||||||||||||||||||
10229 | */ | - | ||||||||||||||||||||||||||||||||||||
10230 | - | |||||||||||||||||||||||||||||||||||||
10231 | /*! | - | ||||||||||||||||||||||||||||||||||||
10232 | Returns the preferred height for this widget, given the width \a w. | - | ||||||||||||||||||||||||||||||||||||
10233 | - | |||||||||||||||||||||||||||||||||||||
10234 | If this widget has a layout, the default implementation returns | - | ||||||||||||||||||||||||||||||||||||
10235 | the layout's preferred height. if there is no layout, the default | - | ||||||||||||||||||||||||||||||||||||
10236 | implementation returns -1 indicating that the preferred height | - | ||||||||||||||||||||||||||||||||||||
10237 | does not depend on the width. | - | ||||||||||||||||||||||||||||||||||||
10238 | */ | - | ||||||||||||||||||||||||||||||||||||
10239 | - | |||||||||||||||||||||||||||||||||||||
10240 | int QWidget::heightForWidth(int w) const | - | ||||||||||||||||||||||||||||||||||||
10241 | { | - | ||||||||||||||||||||||||||||||||||||
10242 | if (layout() && layout()->hasHeightForWidth())
| 0 | ||||||||||||||||||||||||||||||||||||
10243 | return layout()->totalHeightForWidth(w); never executed: return layout()->totalHeightForWidth(w); | 0 | ||||||||||||||||||||||||||||||||||||
10244 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||
10245 | } | - | ||||||||||||||||||||||||||||||||||||
10246 | - | |||||||||||||||||||||||||||||||||||||
10247 | - | |||||||||||||||||||||||||||||||||||||
10248 | /*! | - | ||||||||||||||||||||||||||||||||||||
10249 | \since 5.0 | - | ||||||||||||||||||||||||||||||||||||
10250 | - | |||||||||||||||||||||||||||||||||||||
10251 | Returns \c true if the widget's preferred height depends on its width; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
10252 | */ | - | ||||||||||||||||||||||||||||||||||||
10253 | bool QWidget::hasHeightForWidth() const | - | ||||||||||||||||||||||||||||||||||||
10254 | { | - | ||||||||||||||||||||||||||||||||||||
10255 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
10256 | return d->layout ? d->layout->hasHeightForWidth() : d->size_policy.hasHeightForWidth(); never executed: return d->layout ? d->layout->hasHeightForWidth() : d->size_policy.hasHeightForWidth(); | 0 | ||||||||||||||||||||||||||||||||||||
10257 | } | - | ||||||||||||||||||||||||||||||||||||
10258 | - | |||||||||||||||||||||||||||||||||||||
10259 | /*! | - | ||||||||||||||||||||||||||||||||||||
10260 | \fn QWidget *QWidget::childAt(int x, int y) const | - | ||||||||||||||||||||||||||||||||||||
10261 | - | |||||||||||||||||||||||||||||||||||||
10262 | Returns the visible child widget at the position (\a{x}, \a{y}) | - | ||||||||||||||||||||||||||||||||||||
10263 | in the widget's coordinate system. If there is no visible child | - | ||||||||||||||||||||||||||||||||||||
10264 | widget at the specified position, the function returns 0. | - | ||||||||||||||||||||||||||||||||||||
10265 | */ | - | ||||||||||||||||||||||||||||||||||||
10266 | - | |||||||||||||||||||||||||||||||||||||
10267 | /*! | - | ||||||||||||||||||||||||||||||||||||
10268 | \overload | - | ||||||||||||||||||||||||||||||||||||
10269 | - | |||||||||||||||||||||||||||||||||||||
10270 | Returns the visible child widget at point \a p in the widget's own | - | ||||||||||||||||||||||||||||||||||||
10271 | coordinate system. | - | ||||||||||||||||||||||||||||||||||||
10272 | */ | - | ||||||||||||||||||||||||||||||||||||
10273 | - | |||||||||||||||||||||||||||||||||||||
10274 | QWidget *QWidget::childAt(const QPoint &p) const | - | ||||||||||||||||||||||||||||||||||||
10275 | { | - | ||||||||||||||||||||||||||||||||||||
10276 | return d_func()->childAt_helper(p, false); never executed: return d_func()->childAt_helper(p, false); | 0 | ||||||||||||||||||||||||||||||||||||
10277 | } | - | ||||||||||||||||||||||||||||||||||||
10278 | - | |||||||||||||||||||||||||||||||||||||
10279 | QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const | - | ||||||||||||||||||||||||||||||||||||
10280 | { | - | ||||||||||||||||||||||||||||||||||||
10281 | if (children.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
10282 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
10283 | - | |||||||||||||||||||||||||||||||||||||
10284 | if (!pointInsideRectAndMask(p))
| 0 | ||||||||||||||||||||||||||||||||||||
10285 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
10286 | return childAtRecursiveHelper(p, ignoreChildrenInDestructor); never executed: return childAtRecursiveHelper(p, ignoreChildrenInDestructor); | 0 | ||||||||||||||||||||||||||||||||||||
10287 | } | - | ||||||||||||||||||||||||||||||||||||
10288 | - | |||||||||||||||||||||||||||||||||||||
10289 | QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor) const | - | ||||||||||||||||||||||||||||||||||||
10290 | { | - | ||||||||||||||||||||||||||||||||||||
10291 | for (int i = children.size() - 1; i >= 0; --i) {
| 0 | ||||||||||||||||||||||||||||||||||||
10292 | QWidget *child = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
10293 | if (!child || child->isWindow() || child->isHidden() || child->testAttribute(Qt::WA_TransparentForMouseEvents)
| 0 | ||||||||||||||||||||||||||||||||||||
10294 | || (ignoreChildrenInDestructor && child->data->in_destructor)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10295 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
10296 | } | - | ||||||||||||||||||||||||||||||||||||
10297 | - | |||||||||||||||||||||||||||||||||||||
10298 | // Map the point 'p' from parent coordinates to child coordinates. | - | ||||||||||||||||||||||||||||||||||||
10299 | QPoint childPoint = p; | - | ||||||||||||||||||||||||||||||||||||
10300 | childPoint -= child->data->crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
10301 | - | |||||||||||||||||||||||||||||||||||||
10302 | // Check if the point hits the child. | - | ||||||||||||||||||||||||||||||||||||
10303 | if (!child->d_func()->pointInsideRectAndMask(childPoint))
| 0 | ||||||||||||||||||||||||||||||||||||
10304 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
10305 | - | |||||||||||||||||||||||||||||||||||||
10306 | // Do the same for the child's descendants. | - | ||||||||||||||||||||||||||||||||||||
10307 | if (QWidget *w = child->d_func()->childAtRecursiveHelper(childPoint, ignoreChildrenInDestructor))
| 0 | ||||||||||||||||||||||||||||||||||||
10308 | return w; never executed: return w; | 0 | ||||||||||||||||||||||||||||||||||||
10309 | - | |||||||||||||||||||||||||||||||||||||
10310 | // We have found our target; namely the child at position 'p'. | - | ||||||||||||||||||||||||||||||||||||
10311 | return child; never executed: return child; | 0 | ||||||||||||||||||||||||||||||||||||
10312 | } | - | ||||||||||||||||||||||||||||||||||||
10313 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
10314 | } | - | ||||||||||||||||||||||||||||||||||||
10315 | - | |||||||||||||||||||||||||||||||||||||
10316 | void QWidgetPrivate::updateGeometry_helper(bool forceUpdate) | - | ||||||||||||||||||||||||||||||||||||
10317 | { | - | ||||||||||||||||||||||||||||||||||||
10318 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10319 | if (widgetItem)
| 0 | ||||||||||||||||||||||||||||||||||||
10320 | widgetItem->invalidateSizeCache(); never executed: widgetItem->invalidateSizeCache(); | 0 | ||||||||||||||||||||||||||||||||||||
10321 | QWidget *parent; | - | ||||||||||||||||||||||||||||||||||||
10322 | if (forceUpdate || !extra || extra->minw != extra->maxw || extra->minh != extra->maxh) {
| 0 | ||||||||||||||||||||||||||||||||||||
10323 | const int isHidden = q->isHidden() && !size_policy.retainSizeWhenHidden() && !retainSizeWhenHiddenChanged;
| 0 | ||||||||||||||||||||||||||||||||||||
10324 | - | |||||||||||||||||||||||||||||||||||||
10325 | if (!q->isWindow() && !isHidden && (parent = q->parentWidget())) {
| 0 | ||||||||||||||||||||||||||||||||||||
10326 | if (parent->d_func()->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
10327 | parent->d_func()->layout->invalidate(); never executed: parent->d_func()->layout->invalidate(); | 0 | ||||||||||||||||||||||||||||||||||||
10328 | else if (parent->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
10329 | QApplication::postEvent(parent, new QEvent(QEvent::LayoutRequest)); never executed: QApplication::postEvent(parent, new QEvent(QEvent::LayoutRequest)); | 0 | ||||||||||||||||||||||||||||||||||||
10330 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10331 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10332 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10333 | - | |||||||||||||||||||||||||||||||||||||
10334 | /*! | - | ||||||||||||||||||||||||||||||||||||
10335 | Notifies the layout system that this widget has changed and may | - | ||||||||||||||||||||||||||||||||||||
10336 | need to change geometry. | - | ||||||||||||||||||||||||||||||||||||
10337 | - | |||||||||||||||||||||||||||||||||||||
10338 | Call this function if the sizeHint() or sizePolicy() have changed. | - | ||||||||||||||||||||||||||||||||||||
10339 | - | |||||||||||||||||||||||||||||||||||||
10340 | For explicitly hidden widgets, updateGeometry() is a no-op. The | - | ||||||||||||||||||||||||||||||||||||
10341 | layout system will be notified as soon as the widget is shown. | - | ||||||||||||||||||||||||||||||||||||
10342 | */ | - | ||||||||||||||||||||||||||||||||||||
10343 | - | |||||||||||||||||||||||||||||||||||||
10344 | void QWidget::updateGeometry() | - | ||||||||||||||||||||||||||||||||||||
10345 | { | - | ||||||||||||||||||||||||||||||||||||
10346 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10347 | d->updateGeometry_helper(false); | - | ||||||||||||||||||||||||||||||||||||
10348 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10349 | - | |||||||||||||||||||||||||||||||||||||
10350 | /*! \property QWidget::windowFlags | - | ||||||||||||||||||||||||||||||||||||
10351 | - | |||||||||||||||||||||||||||||||||||||
10352 | Window flags are a combination of a type (e.g. Qt::Dialog) and | - | ||||||||||||||||||||||||||||||||||||
10353 | zero or more hints to the window system (e.g. | - | ||||||||||||||||||||||||||||||||||||
10354 | Qt::FramelessWindowHint). | - | ||||||||||||||||||||||||||||||||||||
10355 | - | |||||||||||||||||||||||||||||||||||||
10356 | If the widget had type Qt::Widget or Qt::SubWindow and becomes a | - | ||||||||||||||||||||||||||||||||||||
10357 | window (Qt::Window, Qt::Dialog, etc.), it is put at position (0, | - | ||||||||||||||||||||||||||||||||||||
10358 | 0) on the desktop. If the widget is a window and becomes a | - | ||||||||||||||||||||||||||||||||||||
10359 | Qt::Widget or Qt::SubWindow, it is put at position (0, 0) | - | ||||||||||||||||||||||||||||||||||||
10360 | relative to its parent widget. | - | ||||||||||||||||||||||||||||||||||||
10361 | - | |||||||||||||||||||||||||||||||||||||
10362 | \note This function calls setParent() when changing the flags for | - | ||||||||||||||||||||||||||||||||||||
10363 | a window, causing the widget to be hidden. You must call show() to make | - | ||||||||||||||||||||||||||||||||||||
10364 | the widget visible again.. | - | ||||||||||||||||||||||||||||||||||||
10365 | - | |||||||||||||||||||||||||||||||||||||
10366 | \sa windowType(), {Window Flags Example} | - | ||||||||||||||||||||||||||||||||||||
10367 | */ | - | ||||||||||||||||||||||||||||||||||||
10368 | void QWidget::setWindowFlags(Qt::WindowFlags flags) | - | ||||||||||||||||||||||||||||||||||||
10369 | { | - | ||||||||||||||||||||||||||||||||||||
10370 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10371 | d->setWindowFlags(flags); | - | ||||||||||||||||||||||||||||||||||||
10372 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10373 | - | |||||||||||||||||||||||||||||||||||||
10374 | /*! \internal | - | ||||||||||||||||||||||||||||||||||||
10375 | - | |||||||||||||||||||||||||||||||||||||
10376 | Implemented in QWidgetPrivate so that QMdiSubWindowPrivate can reimplement it. | - | ||||||||||||||||||||||||||||||||||||
10377 | */ | - | ||||||||||||||||||||||||||||||||||||
10378 | void QWidgetPrivate::setWindowFlags(Qt::WindowFlags flags) | - | ||||||||||||||||||||||||||||||||||||
10379 | { | - | ||||||||||||||||||||||||||||||||||||
10380 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10381 | if (q->data->window_flags == flags)
| 0 | ||||||||||||||||||||||||||||||||||||
10382 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10383 | - | |||||||||||||||||||||||||||||||||||||
10384 | if ((q->data->window_flags | flags) & Qt::Window) {
| 0 | ||||||||||||||||||||||||||||||||||||
10385 | // the old type was a window and/or the new type is a window | - | ||||||||||||||||||||||||||||||||||||
10386 | QPoint oldPos = q->pos(); | - | ||||||||||||||||||||||||||||||||||||
10387 | bool visible = q->isVisible(); | - | ||||||||||||||||||||||||||||||||||||
10388 | const bool windowFlagChanged = (q->data->window_flags ^ flags) & Qt::Window; | - | ||||||||||||||||||||||||||||||||||||
10389 | q->setParent(q->parentWidget(), flags); | - | ||||||||||||||||||||||||||||||||||||
10390 | - | |||||||||||||||||||||||||||||||||||||
10391 | // if both types are windows or neither of them are, we restore | - | ||||||||||||||||||||||||||||||||||||
10392 | // the old position | - | ||||||||||||||||||||||||||||||||||||
10393 | if (!windowFlagChanged && (visible || q->testAttribute(Qt::WA_Moved)))
| 0 | ||||||||||||||||||||||||||||||||||||
10394 | q->move(oldPos); never executed: q->move(oldPos); | 0 | ||||||||||||||||||||||||||||||||||||
10395 | // for backward-compatibility we change Qt::WA_QuitOnClose attribute value only when the window was recreated. | - | ||||||||||||||||||||||||||||||||||||
10396 | adjustQuitOnCloseAttribute(); | - | ||||||||||||||||||||||||||||||||||||
10397 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10398 | q->data->window_flags = flags; | - | ||||||||||||||||||||||||||||||||||||
10399 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10400 | } | - | ||||||||||||||||||||||||||||||||||||
10401 | - | |||||||||||||||||||||||||||||||||||||
10402 | /*! | - | ||||||||||||||||||||||||||||||||||||
10403 | Sets the window flags for the widget to \a flags, | - | ||||||||||||||||||||||||||||||||||||
10404 | \e without telling the window system. | - | ||||||||||||||||||||||||||||||||||||
10405 | - | |||||||||||||||||||||||||||||||||||||
10406 | \warning Do not call this function unless you really know what | - | ||||||||||||||||||||||||||||||||||||
10407 | you're doing. | - | ||||||||||||||||||||||||||||||||||||
10408 | - | |||||||||||||||||||||||||||||||||||||
10409 | \sa setWindowFlags() | - | ||||||||||||||||||||||||||||||||||||
10410 | */ | - | ||||||||||||||||||||||||||||||||||||
10411 | void QWidget::overrideWindowFlags(Qt::WindowFlags flags) | - | ||||||||||||||||||||||||||||||||||||
10412 | { | - | ||||||||||||||||||||||||||||||||||||
10413 | data->window_flags = flags; | - | ||||||||||||||||||||||||||||||||||||
10414 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10415 | - | |||||||||||||||||||||||||||||||||||||
10416 | /*! | - | ||||||||||||||||||||||||||||||||||||
10417 | \fn Qt::WindowType QWidget::windowType() const | - | ||||||||||||||||||||||||||||||||||||
10418 | - | |||||||||||||||||||||||||||||||||||||
10419 | Returns the window type of this widget. This is identical to | - | ||||||||||||||||||||||||||||||||||||
10420 | windowFlags() & Qt::WindowType_Mask. | - | ||||||||||||||||||||||||||||||||||||
10421 | - | |||||||||||||||||||||||||||||||||||||
10422 | \sa windowFlags | - | ||||||||||||||||||||||||||||||||||||
10423 | */ | - | ||||||||||||||||||||||||||||||||||||
10424 | - | |||||||||||||||||||||||||||||||||||||
10425 | /*! | - | ||||||||||||||||||||||||||||||||||||
10426 | Sets the parent of the widget to \a parent, and resets the window | - | ||||||||||||||||||||||||||||||||||||
10427 | flags. The widget is moved to position (0, 0) in its new parent. | - | ||||||||||||||||||||||||||||||||||||
10428 | - | |||||||||||||||||||||||||||||||||||||
10429 | If the new parent widget is in a different window, the | - | ||||||||||||||||||||||||||||||||||||
10430 | reparented widget and its children are appended to the end of the | - | ||||||||||||||||||||||||||||||||||||
10431 | \l{setFocusPolicy()}{tab chain} of the new parent | - | ||||||||||||||||||||||||||||||||||||
10432 | widget, in the same internal order as before. If one of the moved | - | ||||||||||||||||||||||||||||||||||||
10433 | widgets had keyboard focus, setParent() calls clearFocus() for that | - | ||||||||||||||||||||||||||||||||||||
10434 | widget. | - | ||||||||||||||||||||||||||||||||||||
10435 | - | |||||||||||||||||||||||||||||||||||||
10436 | If the new parent widget is in the same window as the | - | ||||||||||||||||||||||||||||||||||||
10437 | old parent, setting the parent doesn't change the tab order or | - | ||||||||||||||||||||||||||||||||||||
10438 | keyboard focus. | - | ||||||||||||||||||||||||||||||||||||
10439 | - | |||||||||||||||||||||||||||||||||||||
10440 | If the "new" parent widget is the old parent widget, this function | - | ||||||||||||||||||||||||||||||||||||
10441 | does nothing. | - | ||||||||||||||||||||||||||||||||||||
10442 | - | |||||||||||||||||||||||||||||||||||||
10443 | \note The widget becomes invisible as part of changing its parent, | - | ||||||||||||||||||||||||||||||||||||
10444 | even if it was previously visible. You must call show() to make the | - | ||||||||||||||||||||||||||||||||||||
10445 | widget visible again. | - | ||||||||||||||||||||||||||||||||||||
10446 | - | |||||||||||||||||||||||||||||||||||||
10447 | \warning It is very unlikely that you will ever need this | - | ||||||||||||||||||||||||||||||||||||
10448 | function. If you have a widget that changes its content | - | ||||||||||||||||||||||||||||||||||||
10449 | dynamically, it is far easier to use \l QStackedWidget. | - | ||||||||||||||||||||||||||||||||||||
10450 | - | |||||||||||||||||||||||||||||||||||||
10451 | \sa setWindowFlags() | - | ||||||||||||||||||||||||||||||||||||
10452 | */ | - | ||||||||||||||||||||||||||||||||||||
10453 | void QWidget::setParent(QWidget *parent) | - | ||||||||||||||||||||||||||||||||||||
10454 | { | - | ||||||||||||||||||||||||||||||||||||
10455 | if (parent == parentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
10456 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10457 | setParent((QWidget*)parent, windowFlags() & ~Qt::WindowType_Mask); | - | ||||||||||||||||||||||||||||||||||||
10458 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10459 | - | |||||||||||||||||||||||||||||||||||||
10460 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
10461 | static void sendWindowChangeToTextureChildrenRecursively(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
10462 | { | - | ||||||||||||||||||||||||||||||||||||
10463 | QWidgetPrivate *d = QWidgetPrivate::get(widget); | - | ||||||||||||||||||||||||||||||||||||
10464 | if (d->renderToTexture) {
| 0 | ||||||||||||||||||||||||||||||||||||
10465 | QEvent e(QEvent::WindowChangeInternal); | - | ||||||||||||||||||||||||||||||||||||
10466 | QApplication::sendEvent(widget, &e); | - | ||||||||||||||||||||||||||||||||||||
10467 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10468 | - | |||||||||||||||||||||||||||||||||||||
10469 | for (int i = 0; i < d->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
10470 | QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
10471 | if (w && !w->isWindow() && !w->isHidden() && QWidgetPrivate::get(w)->textureChildSeen)
| 0 | ||||||||||||||||||||||||||||||||||||
10472 | sendWindowChangeToTextureChildrenRecursively(w); never executed: sendWindowChangeToTextureChildrenRecursively(w); | 0 | ||||||||||||||||||||||||||||||||||||
10473 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10474 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10475 | #endif | - | ||||||||||||||||||||||||||||||||||||
10476 | - | |||||||||||||||||||||||||||||||||||||
10477 | /*! | - | ||||||||||||||||||||||||||||||||||||
10478 | \overload | - | ||||||||||||||||||||||||||||||||||||
10479 | - | |||||||||||||||||||||||||||||||||||||
10480 | This function also takes widget flags, \a f as an argument. | - | ||||||||||||||||||||||||||||||||||||
10481 | */ | - | ||||||||||||||||||||||||||||||||||||
10482 | - | |||||||||||||||||||||||||||||||||||||
10483 | void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) | - | ||||||||||||||||||||||||||||||||||||
10484 | { | - | ||||||||||||||||||||||||||||||||||||
10485 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10486 | bool resized = testAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||||||||||||||
10487 | bool wasCreated = testAttribute(Qt::WA_WState_Created); | - | ||||||||||||||||||||||||||||||||||||
10488 | QWidget *oldtlw = window(); | - | ||||||||||||||||||||||||||||||||||||
10489 | - | |||||||||||||||||||||||||||||||||||||
10490 | if (f & Qt::Window) // Frame geometry likely changes, refresh.
| 0 | ||||||||||||||||||||||||||||||||||||
10491 | d->data.fstrut_dirty = true; never executed: d->data.fstrut_dirty = true; | 0 | ||||||||||||||||||||||||||||||||||||
10492 | - | |||||||||||||||||||||||||||||||||||||
10493 | QWidget *desktopWidget = 0; | - | ||||||||||||||||||||||||||||||||||||
10494 | if (parent && parent->windowType() == Qt::Desktop)
| 0 | ||||||||||||||||||||||||||||||||||||
10495 | desktopWidget = parent; never executed: desktopWidget = parent; | 0 | ||||||||||||||||||||||||||||||||||||
10496 | bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget;
| 0 | ||||||||||||||||||||||||||||||||||||
10497 | - | |||||||||||||||||||||||||||||||||||||
10498 | if (newParent && parent && !desktopWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
10499 | if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings))
| 0 | ||||||||||||||||||||||||||||||||||||
10500 | parent->d_func()->enforceNativeChildren(); never executed: parent->d_func()->enforceNativeChildren(); | 0 | ||||||||||||||||||||||||||||||||||||
10501 | else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))
| 0 | ||||||||||||||||||||||||||||||||||||
10502 | setAttribute(Qt::WA_NativeWindow); never executed: setAttribute(Qt::WA_NativeWindow); | 0 | ||||||||||||||||||||||||||||||||||||
10503 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10504 | - | |||||||||||||||||||||||||||||||||||||
10505 | if (wasCreated) {
| 0 | ||||||||||||||||||||||||||||||||||||
10506 | if (!testAttribute(Qt::WA_WState_Hidden)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10507 | hide(); | - | ||||||||||||||||||||||||||||||||||||
10508 | setAttribute(Qt::WA_WState_ExplicitShowHide, false); | - | ||||||||||||||||||||||||||||||||||||
10509 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10510 | if (newParent) {
| 0 | ||||||||||||||||||||||||||||||||||||
10511 | QEvent e(QEvent::ParentAboutToChange); | - | ||||||||||||||||||||||||||||||||||||
10512 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
10513 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10514 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10515 | if (newParent && isAncestorOf(focusWidget()))
| 0 | ||||||||||||||||||||||||||||||||||||
10516 | focusWidget()->clearFocus(); never executed: focusWidget()->clearFocus(); | 0 | ||||||||||||||||||||||||||||||||||||
10517 | - | |||||||||||||||||||||||||||||||||||||
10518 | QTLWExtra *oldTopExtra = window()->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
10519 | QWidgetBackingStoreTracker *oldBsTracker = oldTopExtra ? &oldTopExtra->backingStoreTracker : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
10520 | - | |||||||||||||||||||||||||||||||||||||
10521 | d->setParent_sys(parent, f); | - | ||||||||||||||||||||||||||||||||||||
10522 | - | |||||||||||||||||||||||||||||||||||||
10523 | QTLWExtra *topExtra = window()->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
10524 | QWidgetBackingStoreTracker *bsTracker = topExtra ? &topExtra->backingStoreTracker : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
10525 | if (oldBsTracker && oldBsTracker != bsTracker)
| 0 | ||||||||||||||||||||||||||||||||||||
10526 | oldBsTracker->unregisterWidgetSubtree(this); never executed: oldBsTracker->unregisterWidgetSubtree(this); | 0 | ||||||||||||||||||||||||||||||||||||
10527 | - | |||||||||||||||||||||||||||||||||||||
10528 | if (desktopWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
10529 | parent = 0; never executed: parent = 0; | 0 | ||||||||||||||||||||||||||||||||||||
10530 | - | |||||||||||||||||||||||||||||||||||||
10531 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
10532 | if (d->textureChildSeen && parent) {
| 0 | ||||||||||||||||||||||||||||||||||||
10533 | // set the textureChildSeen flag up the whole parent chain | - | ||||||||||||||||||||||||||||||||||||
10534 | QWidgetPrivate::get(parent)->setTextureChildSeen(); | - | ||||||||||||||||||||||||||||||||||||
10535 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10536 | #endif | - | ||||||||||||||||||||||||||||||||||||
10537 | - | |||||||||||||||||||||||||||||||||||||
10538 | if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10539 | if (newParent)
| 0 | ||||||||||||||||||||||||||||||||||||
10540 | oldBs->removeDirtyWidget(this); never executed: oldBs->removeDirtyWidget(this); | 0 | ||||||||||||||||||||||||||||||||||||
10541 | // Move the widget and all its static children from | - | ||||||||||||||||||||||||||||||||||||
10542 | // the old backing store to the new one. | - | ||||||||||||||||||||||||||||||||||||
10543 | oldBs->moveStaticWidgets(this); | - | ||||||||||||||||||||||||||||||||||||
10544 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10545 | - | |||||||||||||||||||||||||||||||||||||
10546 | // ### fixme: Qt 6: Remove AA_ImmediateWidgetCreation. | - | ||||||||||||||||||||||||||||||||||||
10547 | if (QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation) && !testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
10548 | create(); never executed: create(); | 0 | ||||||||||||||||||||||||||||||||||||
10549 | - | |||||||||||||||||||||||||||||||||||||
10550 | d->reparentFocusWidgets(oldtlw); | - | ||||||||||||||||||||||||||||||||||||
10551 | setAttribute(Qt::WA_Resized, resized); | - | ||||||||||||||||||||||||||||||||||||
10552 | - | |||||||||||||||||||||||||||||||||||||
10553 | const bool useStyleSheetPropagationInWidgetStyles = | - | ||||||||||||||||||||||||||||||||||||
10554 | QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); | - | ||||||||||||||||||||||||||||||||||||
10555 | - | |||||||||||||||||||||||||||||||||||||
10556 | if (!useStyleSheetPropagationInWidgetStyles && !testAttribute(Qt::WA_StyleSheet)
| 0 | ||||||||||||||||||||||||||||||||||||
10557 | && (!parent || !parent->testAttribute(Qt::WA_StyleSheet))) {
| 0 | ||||||||||||||||||||||||||||||||||||
10558 | d->resolveFont(); | - | ||||||||||||||||||||||||||||||||||||
10559 | d->resolvePalette(); | - | ||||||||||||||||||||||||||||||||||||
10560 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10561 | d->resolveLayoutDirection(); | - | ||||||||||||||||||||||||||||||||||||
10562 | d->resolveLocale(); | - | ||||||||||||||||||||||||||||||||||||
10563 | - | |||||||||||||||||||||||||||||||||||||
10564 | // Note: GL widgets under WGL or EGL will always need a ParentChange | - | ||||||||||||||||||||||||||||||||||||
10565 | // event to handle recreation/rebinding of the GL context, hence the | - | ||||||||||||||||||||||||||||||||||||
10566 | // (f & Qt::MSWindowsOwnDC) clause (which is set on QGLWidgets on all | - | ||||||||||||||||||||||||||||||||||||
10567 | // platforms). | - | ||||||||||||||||||||||||||||||||||||
10568 | if (newParent
| 0 | ||||||||||||||||||||||||||||||||||||
10569 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(QT_OPENGL_ES) | - | ||||||||||||||||||||||||||||||||||||
10570 | || (f & Qt::MSWindowsOwnDC) | - | ||||||||||||||||||||||||||||||||||||
10571 | #endif | - | ||||||||||||||||||||||||||||||||||||
10572 | ) { | - | ||||||||||||||||||||||||||||||||||||
10573 | // propagate enabled updates enabled state to non-windows | - | ||||||||||||||||||||||||||||||||||||
10574 | if (!isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10575 | if (!testAttribute(Qt::WA_ForceDisabled))
| 0 | ||||||||||||||||||||||||||||||||||||
10576 | d->setEnabled_helper(parent ? parent->isEnabled() : true); never executed: d->setEnabled_helper(parent ? parent->isEnabled() : true); | 0 | ||||||||||||||||||||||||||||||||||||
10577 | if (!testAttribute(Qt::WA_ForceUpdatesDisabled))
| 0 | ||||||||||||||||||||||||||||||||||||
10578 | d->setUpdatesEnabled_helper(parent ? parent->updatesEnabled() : true); never executed: d->setUpdatesEnabled_helper(parent ? parent->updatesEnabled() : true); | 0 | ||||||||||||||||||||||||||||||||||||
10579 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10580 | d->inheritStyle(); | - | ||||||||||||||||||||||||||||||||||||
10581 | - | |||||||||||||||||||||||||||||||||||||
10582 | // send and post remaining QObject events | - | ||||||||||||||||||||||||||||||||||||
10583 | if (parent && d->sendChildEvents) {
| 0 | ||||||||||||||||||||||||||||||||||||
10584 | QChildEvent e(QEvent::ChildAdded, this); | - | ||||||||||||||||||||||||||||||||||||
10585 | QApplication::sendEvent(parent, &e); | - | ||||||||||||||||||||||||||||||||||||
10586 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10587 | - | |||||||||||||||||||||||||||||||||||||
10588 | //### already hidden above ---> must probably do something smart on the mac | - | ||||||||||||||||||||||||||||||||||||
10589 | // #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
10590 | // extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp | - | ||||||||||||||||||||||||||||||||||||
10591 | // if(!qt_mac_is_macdrawer(q)) //special case | - | ||||||||||||||||||||||||||||||||||||
10592 | // q->setAttribute(Qt::WA_WState_Hidden); | - | ||||||||||||||||||||||||||||||||||||
10593 | // #else | - | ||||||||||||||||||||||||||||||||||||
10594 | // q->setAttribute(Qt::WA_WState_Hidden); | - | ||||||||||||||||||||||||||||||||||||
10595 | //#endif | - | ||||||||||||||||||||||||||||||||||||
10596 | - | |||||||||||||||||||||||||||||||||||||
10597 | if (parent && d->sendChildEvents && d->polished) {
| 0 | ||||||||||||||||||||||||||||||||||||
10598 | QChildEvent e(QEvent::ChildPolished, this); | - | ||||||||||||||||||||||||||||||||||||
10599 | QCoreApplication::sendEvent(parent, &e); | - | ||||||||||||||||||||||||||||||||||||
10600 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10601 | - | |||||||||||||||||||||||||||||||||||||
10602 | QEvent e(QEvent::ParentChange); | - | ||||||||||||||||||||||||||||||||||||
10603 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
10604 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10605 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
10606 | //renderToTexture widgets also need to know when their top-level window changes | - | ||||||||||||||||||||||||||||||||||||
10607 | if (d->textureChildSeen && oldtlw != window()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10608 | sendWindowChangeToTextureChildrenRecursively(this); | - | ||||||||||||||||||||||||||||||||||||
10609 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10610 | #endif | - | ||||||||||||||||||||||||||||||||||||
10611 | - | |||||||||||||||||||||||||||||||||||||
10612 | if (!wasCreated) {
| 0 | ||||||||||||||||||||||||||||||||||||
10613 | if (isWindow() || parentWidget()->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
10614 | setAttribute(Qt::WA_WState_Hidden, true); never executed: setAttribute(Qt::WA_WState_Hidden, true); | 0 | ||||||||||||||||||||||||||||||||||||
10615 | else if (!testAttribute(Qt::WA_WState_ExplicitShowHide))
| 0 | ||||||||||||||||||||||||||||||||||||
10616 | setAttribute(Qt::WA_WState_Hidden, false); never executed: setAttribute(Qt::WA_WState_Hidden, false); | 0 | ||||||||||||||||||||||||||||||||||||
10617 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10618 | - | |||||||||||||||||||||||||||||||||||||
10619 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
10620 | - | |||||||||||||||||||||||||||||||||||||
10621 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
10622 | // Embed the widget into a proxy if the parent is embedded. | - | ||||||||||||||||||||||||||||||||||||
10623 | // ### Doesn't handle reparenting out of an embedded widget. | - | ||||||||||||||||||||||||||||||||||||
10624 | if (oldtlw->graphicsProxyWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10625 | if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(oldtlw))
| 0 | ||||||||||||||||||||||||||||||||||||
10626 | ancestorProxy->d_func()->unembedSubWindow(this); never executed: ancestorProxy->d_func()->unembedSubWindow(this); | 0 | ||||||||||||||||||||||||||||||||||||
10627 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10628 | if (isWindow() && parent && !graphicsProxyWidget() && !bypassGraphicsProxyWidget(this)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10629 | if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(parent))
| 0 | ||||||||||||||||||||||||||||||||||||
10630 | ancestorProxy->d_func()->embedSubWindow(this); never executed: ancestorProxy->d_func()->embedSubWindow(this); | 0 | ||||||||||||||||||||||||||||||||||||
10631 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10632 | #endif | - | ||||||||||||||||||||||||||||||||||||
10633 | - | |||||||||||||||||||||||||||||||||||||
10634 | if (d->extra && d->extra->hasWindowContainer)
| 0 | ||||||||||||||||||||||||||||||||||||
10635 | QWindowContainer::parentWasChanged(this); never executed: QWindowContainer::parentWasChanged(this); | 0 | ||||||||||||||||||||||||||||||||||||
10636 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10637 | - | |||||||||||||||||||||||||||||||||||||
10638 | void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) | - | ||||||||||||||||||||||||||||||||||||
10639 | { | - | ||||||||||||||||||||||||||||||||||||
10640 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10641 | - | |||||||||||||||||||||||||||||||||||||
10642 | Qt::WindowFlags oldFlags = data.window_flags; | - | ||||||||||||||||||||||||||||||||||||
10643 | bool wasCreated = q->testAttribute(Qt::WA_WState_Created); | - | ||||||||||||||||||||||||||||||||||||
10644 | - | |||||||||||||||||||||||||||||||||||||
10645 | int targetScreen = -1; | - | ||||||||||||||||||||||||||||||||||||
10646 | // Handle a request to move the widget to a particular screen | - | ||||||||||||||||||||||||||||||||||||
10647 | if (newparent && newparent->windowType() == Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
10648 | // make sure the widget is created on the same screen as the | - | ||||||||||||||||||||||||||||||||||||
10649 | // programmer specified desktop widget | - | ||||||||||||||||||||||||||||||||||||
10650 | const QDesktopScreenWidget *sw = qobject_cast<const QDesktopScreenWidget *>(newparent); | - | ||||||||||||||||||||||||||||||||||||
10651 | targetScreen = sw ? sw->screenNumber() : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
10652 | newparent = 0; | - | ||||||||||||||||||||||||||||||||||||
10653 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10654 | - | |||||||||||||||||||||||||||||||||||||
10655 | setWinId(0); | - | ||||||||||||||||||||||||||||||||||||
10656 | - | |||||||||||||||||||||||||||||||||||||
10657 | if (parent != newparent) {
| 0 | ||||||||||||||||||||||||||||||||||||
10658 | QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function??? | - | ||||||||||||||||||||||||||||||||||||
10659 | if (q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10660 | q->windowHandle()->setFlags(f); | - | ||||||||||||||||||||||||||||||||||||
10661 | QWidget *parentWithWindow = | - | ||||||||||||||||||||||||||||||||||||
10662 | newparent ? (newparent->windowHandle() ? newparent : newparent->nativeParentWidget()) : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
10663 | if (parentWithWindow) {
| 0 | ||||||||||||||||||||||||||||||||||||
10664 | QWidget *topLevel = parentWithWindow->window(); | - | ||||||||||||||||||||||||||||||||||||
10665 | if ((f & Qt::Window) && topLevel && topLevel->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10666 | q->windowHandle()->setTransientParent(topLevel->windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
10667 | q->windowHandle()->setParent(0); | - | ||||||||||||||||||||||||||||||||||||
10668 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10669 | q->windowHandle()->setTransientParent(0); | - | ||||||||||||||||||||||||||||||||||||
10670 | q->windowHandle()->setParent(parentWithWindow->windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
10671 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10672 | } else { | - | ||||||||||||||||||||||||||||||||||||
10673 | q->windowHandle()->setTransientParent(0); | - | ||||||||||||||||||||||||||||||||||||
10674 | q->windowHandle()->setParent(0); | - | ||||||||||||||||||||||||||||||||||||
10675 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10676 | } | - | ||||||||||||||||||||||||||||||||||||
10677 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10678 | - | |||||||||||||||||||||||||||||||||||||
10679 | if (!newparent) {
| 0 | ||||||||||||||||||||||||||||||||||||
10680 | f |= Qt::Window; | - | ||||||||||||||||||||||||||||||||||||
10681 | if (targetScreen == -1) {
| 0 | ||||||||||||||||||||||||||||||||||||
10682 | if (parent)
| 0 | ||||||||||||||||||||||||||||||||||||
10683 | targetScreen = QApplication::desktop()->screenNumber(q->parentWidget()->window()); never executed: targetScreen = QApplication::desktop()->screenNumber(q->parentWidget()->window()); | 0 | ||||||||||||||||||||||||||||||||||||
10684 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10685 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10686 | - | |||||||||||||||||||||||||||||||||||||
10687 | bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
| 0 | ||||||||||||||||||||||||||||||||||||
10688 | - | |||||||||||||||||||||||||||||||||||||
10689 | // Reparenting toplevel to child | - | ||||||||||||||||||||||||||||||||||||
10690 | if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10691 | if (extra && extra->hasWindowContainer)
| 0 | ||||||||||||||||||||||||||||||||||||
10692 | QWindowContainer::toplevelAboutToBeDestroyed(q); never executed: QWindowContainer::toplevelAboutToBeDestroyed(q); | 0 | ||||||||||||||||||||||||||||||||||||
10693 | - | |||||||||||||||||||||||||||||||||||||
10694 | QWindow *newParentWindow = newparent->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
10695 | if (!newParentWindow)
| 0 | ||||||||||||||||||||||||||||||||||||
10696 | if (QWidget *npw = newparent->nativeParentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
10697 | newParentWindow = npw->windowHandle(); never executed: newParentWindow = npw->windowHandle(); | 0 | ||||||||||||||||||||||||||||||||||||
10698 | - | |||||||||||||||||||||||||||||||||||||
10699 | Q_FOREACH (QObject *child, q->windowHandle()->children()) { | - | ||||||||||||||||||||||||||||||||||||
10700 | QWindow *childWindow = qobject_cast<QWindow *>(child); | - | ||||||||||||||||||||||||||||||||||||
10701 | if (!childWindow)
| 0 | ||||||||||||||||||||||||||||||||||||
10702 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
10703 | - | |||||||||||||||||||||||||||||||||||||
10704 | QWidgetWindow *childWW = qobject_cast<QWidgetWindow *>(childWindow); | - | ||||||||||||||||||||||||||||||||||||
10705 | QWidget *childWidget = childWW ? childWW->widget() : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
10706 | if (!childWW || (childWidget && childWidget->testAttribute(Qt::WA_NativeWindow)))
| 0 | ||||||||||||||||||||||||||||||||||||
10707 | childWindow->setParent(newParentWindow); never executed: childWindow->setParent(newParentWindow); | 0 | ||||||||||||||||||||||||||||||||||||
10708 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10709 | q->destroy(); | - | ||||||||||||||||||||||||||||||||||||
10710 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10711 | - | |||||||||||||||||||||||||||||||||||||
10712 | adjustFlags(f, q); | - | ||||||||||||||||||||||||||||||||||||
10713 | data.window_flags = f; | - | ||||||||||||||||||||||||||||||||||||
10714 | q->setAttribute(Qt::WA_WState_Created, false); | - | ||||||||||||||||||||||||||||||||||||
10715 | q->setAttribute(Qt::WA_WState_Visible, false); | - | ||||||||||||||||||||||||||||||||||||
10716 | q->setAttribute(Qt::WA_WState_Hidden, false); | - | ||||||||||||||||||||||||||||||||||||
10717 | - | |||||||||||||||||||||||||||||||||||||
10718 | if (newparent && wasCreated && (q->testAttribute(Qt::WA_NativeWindow) || (f & Qt::Window)))
| 0 | ||||||||||||||||||||||||||||||||||||
10719 | q->createWinId(); never executed: q->createWinId(); | 0 | ||||||||||||||||||||||||||||||||||||
10720 | - | |||||||||||||||||||||||||||||||||||||
10721 | if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
| 0 | ||||||||||||||||||||||||||||||||||||
10722 | q->setAttribute(Qt::WA_WState_Hidden); never executed: q->setAttribute(Qt::WA_WState_Hidden); | 0 | ||||||||||||||||||||||||||||||||||||
10723 | q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); | - | ||||||||||||||||||||||||||||||||||||
10724 | - | |||||||||||||||||||||||||||||||||||||
10725 | // move the window to the selected screen | - | ||||||||||||||||||||||||||||||||||||
10726 | if (!newparent && targetScreen != -1) {
| 0 | ||||||||||||||||||||||||||||||||||||
10727 | // only if it is already created | - | ||||||||||||||||||||||||||||||||||||
10728 | if (q->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
10729 | q->windowHandle()->setScreen(QGuiApplication::screens().value(targetScreen, 0)); never executed: q->windowHandle()->setScreen(QGuiApplication::screens().value(targetScreen, 0)); | 0 | ||||||||||||||||||||||||||||||||||||
10730 | else | - | ||||||||||||||||||||||||||||||||||||
10731 | topData()->initialScreenIndex = targetScreen; never executed: topData()->initialScreenIndex = targetScreen; | 0 | ||||||||||||||||||||||||||||||||||||
10732 | } | - | ||||||||||||||||||||||||||||||||||||
10733 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10734 | - | |||||||||||||||||||||||||||||||||||||
10735 | /*! | - | ||||||||||||||||||||||||||||||||||||
10736 | Scrolls the widget including its children \a dx pixels to the | - | ||||||||||||||||||||||||||||||||||||
10737 | right and \a dy downward. Both \a dx and \a dy may be negative. | - | ||||||||||||||||||||||||||||||||||||
10738 | - | |||||||||||||||||||||||||||||||||||||
10739 | After scrolling, the widgets will receive paint events for | - | ||||||||||||||||||||||||||||||||||||
10740 | the areas that need to be repainted. For widgets that Qt knows to | - | ||||||||||||||||||||||||||||||||||||
10741 | be opaque, this is only the newly exposed parts. | - | ||||||||||||||||||||||||||||||||||||
10742 | For example, if an opaque widget is scrolled 8 pixels to the left, | - | ||||||||||||||||||||||||||||||||||||
10743 | only an 8-pixel wide stripe at the right edge needs updating. | - | ||||||||||||||||||||||||||||||||||||
10744 | - | |||||||||||||||||||||||||||||||||||||
10745 | Since widgets propagate the contents of their parents by default, | - | ||||||||||||||||||||||||||||||||||||
10746 | you need to set the \l autoFillBackground property, or use | - | ||||||||||||||||||||||||||||||||||||
10747 | setAttribute() to set the Qt::WA_OpaquePaintEvent attribute, to make | - | ||||||||||||||||||||||||||||||||||||
10748 | a widget opaque. | - | ||||||||||||||||||||||||||||||||||||
10749 | - | |||||||||||||||||||||||||||||||||||||
10750 | For widgets that use contents propagation, a scroll will cause an | - | ||||||||||||||||||||||||||||||||||||
10751 | update of the entire scroll area. | - | ||||||||||||||||||||||||||||||||||||
10752 | - | |||||||||||||||||||||||||||||||||||||
10753 | \sa {Transparency and Double Buffering} | - | ||||||||||||||||||||||||||||||||||||
10754 | */ | - | ||||||||||||||||||||||||||||||||||||
10755 | - | |||||||||||||||||||||||||||||||||||||
10756 | void QWidget::scroll(int dx, int dy) | - | ||||||||||||||||||||||||||||||||||||
10757 | { | - | ||||||||||||||||||||||||||||||||||||
10758 | if ((!updatesEnabled() && children().size() == 0) || !isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
10759 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10760 | if (dx == 0 && dy == 0)
| 0 | ||||||||||||||||||||||||||||||||||||
10761 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10762 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10763 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
10764 | if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10765 | // Graphics View maintains its own dirty region as a list of rects; | - | ||||||||||||||||||||||||||||||||||||
10766 | // until we can connect item updates directly to the view, we must | - | ||||||||||||||||||||||||||||||||||||
10767 | // separately add a translated dirty region. | - | ||||||||||||||||||||||||||||||||||||
10768 | if (!d->dirty.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10769 | foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects()) | - | ||||||||||||||||||||||||||||||||||||
10770 | proxy->update(rect); never executed: proxy->update(rect); | 0 | ||||||||||||||||||||||||||||||||||||
10771 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10772 | proxy->scroll(dx, dy, proxy->subWidgetRect(this)); | - | ||||||||||||||||||||||||||||||||||||
10773 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10774 | } | - | ||||||||||||||||||||||||||||||||||||
10775 | #endif | - | ||||||||||||||||||||||||||||||||||||
10776 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
10777 | d->scroll_sys(dx, dy); | - | ||||||||||||||||||||||||||||||||||||
10778 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10779 | - | |||||||||||||||||||||||||||||||||||||
10780 | void QWidgetPrivate::scroll_sys(int dx, int dy) | - | ||||||||||||||||||||||||||||||||||||
10781 | { | - | ||||||||||||||||||||||||||||||||||||
10782 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10783 | scrollChildren(dx, dy); | - | ||||||||||||||||||||||||||||||||||||
10784 | scrollRect(q->rect(), dx, dy); | - | ||||||||||||||||||||||||||||||||||||
10785 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10786 | - | |||||||||||||||||||||||||||||||||||||
10787 | /*! | - | ||||||||||||||||||||||||||||||||||||
10788 | \overload | - | ||||||||||||||||||||||||||||||||||||
10789 | - | |||||||||||||||||||||||||||||||||||||
10790 | This version only scrolls \a r and does not move the children of | - | ||||||||||||||||||||||||||||||||||||
10791 | the widget. | - | ||||||||||||||||||||||||||||||||||||
10792 | - | |||||||||||||||||||||||||||||||||||||
10793 | If \a r is empty or invalid, the result is undefined. | - | ||||||||||||||||||||||||||||||||||||
10794 | - | |||||||||||||||||||||||||||||||||||||
10795 | \sa QScrollArea | - | ||||||||||||||||||||||||||||||||||||
10796 | */ | - | ||||||||||||||||||||||||||||||||||||
10797 | void QWidget::scroll(int dx, int dy, const QRect &r) | - | ||||||||||||||||||||||||||||||||||||
10798 | { | - | ||||||||||||||||||||||||||||||||||||
10799 | - | |||||||||||||||||||||||||||||||||||||
10800 | if ((!updatesEnabled() && children().size() == 0) || !isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
10801 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10802 | if (dx == 0 && dy == 0)
| 0 | ||||||||||||||||||||||||||||||||||||
10803 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10804 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10805 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
10806 | if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10807 | // Graphics View maintains its own dirty region as a list of rects; | - | ||||||||||||||||||||||||||||||||||||
10808 | // until we can connect item updates directly to the view, we must | - | ||||||||||||||||||||||||||||||||||||
10809 | // separately add a translated dirty region. | - | ||||||||||||||||||||||||||||||||||||
10810 | if (!d->dirty.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10811 | foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects()) | - | ||||||||||||||||||||||||||||||||||||
10812 | proxy->update(rect); never executed: proxy->update(rect); | 0 | ||||||||||||||||||||||||||||||||||||
10813 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10814 | proxy->scroll(dx, dy, r.translated(proxy->subWidgetRect(this).topLeft().toPoint())); | - | ||||||||||||||||||||||||||||||||||||
10815 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10816 | } | - | ||||||||||||||||||||||||||||||||||||
10817 | #endif | - | ||||||||||||||||||||||||||||||||||||
10818 | d->scroll_sys(dx, dy, r); | - | ||||||||||||||||||||||||||||||||||||
10819 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10820 | - | |||||||||||||||||||||||||||||||||||||
10821 | void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) | - | ||||||||||||||||||||||||||||||||||||
10822 | { | - | ||||||||||||||||||||||||||||||||||||
10823 | scrollRect(r, dx, dy); | - | ||||||||||||||||||||||||||||||||||||
10824 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10825 | - | |||||||||||||||||||||||||||||||||||||
10826 | /*! | - | ||||||||||||||||||||||||||||||||||||
10827 | Repaints the widget directly by calling paintEvent() immediately, | - | ||||||||||||||||||||||||||||||||||||
10828 | unless updates are disabled or the widget is hidden. | - | ||||||||||||||||||||||||||||||||||||
10829 | - | |||||||||||||||||||||||||||||||||||||
10830 | We suggest only using repaint() if you need an immediate repaint, | - | ||||||||||||||||||||||||||||||||||||
10831 | for example during animation. In almost all circumstances update() | - | ||||||||||||||||||||||||||||||||||||
10832 | is better, as it permits Qt to optimize for speed and minimize | - | ||||||||||||||||||||||||||||||||||||
10833 | flicker. | - | ||||||||||||||||||||||||||||||||||||
10834 | - | |||||||||||||||||||||||||||||||||||||
10835 | \warning If you call repaint() in a function which may itself be | - | ||||||||||||||||||||||||||||||||||||
10836 | called from paintEvent(), you may get infinite recursion. The | - | ||||||||||||||||||||||||||||||||||||
10837 | update() function never causes recursion. | - | ||||||||||||||||||||||||||||||||||||
10838 | - | |||||||||||||||||||||||||||||||||||||
10839 | \sa update(), paintEvent(), setUpdatesEnabled() | - | ||||||||||||||||||||||||||||||||||||
10840 | */ | - | ||||||||||||||||||||||||||||||||||||
10841 | - | |||||||||||||||||||||||||||||||||||||
10842 | void QWidget::repaint() | - | ||||||||||||||||||||||||||||||||||||
10843 | { | - | ||||||||||||||||||||||||||||||||||||
10844 | repaint(rect()); | - | ||||||||||||||||||||||||||||||||||||
10845 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10846 | - | |||||||||||||||||||||||||||||||||||||
10847 | /*! \overload | - | ||||||||||||||||||||||||||||||||||||
10848 | - | |||||||||||||||||||||||||||||||||||||
10849 | This version repaints a rectangle (\a x, \a y, \a w, \a h) inside | - | ||||||||||||||||||||||||||||||||||||
10850 | the widget. | - | ||||||||||||||||||||||||||||||||||||
10851 | - | |||||||||||||||||||||||||||||||||||||
10852 | If \a w is negative, it is replaced with \c{width() - x}, and if | - | ||||||||||||||||||||||||||||||||||||
10853 | \a h is negative, it is replaced width \c{height() - y}. | - | ||||||||||||||||||||||||||||||||||||
10854 | */ | - | ||||||||||||||||||||||||||||||||||||
10855 | void QWidget::repaint(int x, int y, int w, int h) | - | ||||||||||||||||||||||||||||||||||||
10856 | { | - | ||||||||||||||||||||||||||||||||||||
10857 | if (x > data->crect.width() || y > data->crect.height())
| 0 | ||||||||||||||||||||||||||||||||||||
10858 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10859 | - | |||||||||||||||||||||||||||||||||||||
10860 | if (w < 0)
| 0 | ||||||||||||||||||||||||||||||||||||
10861 | w = data->crect.width() - x; never executed: w = data->crect.width() - x; | 0 | ||||||||||||||||||||||||||||||||||||
10862 | if (h < 0)
| 0 | ||||||||||||||||||||||||||||||||||||
10863 | h = data->crect.height() - y; never executed: h = data->crect.height() - y; | 0 | ||||||||||||||||||||||||||||||||||||
10864 | - | |||||||||||||||||||||||||||||||||||||
10865 | repaint(QRect(x, y, w, h)); | - | ||||||||||||||||||||||||||||||||||||
10866 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10867 | - | |||||||||||||||||||||||||||||||||||||
10868 | /*! \overload | - | ||||||||||||||||||||||||||||||||||||
10869 | - | |||||||||||||||||||||||||||||||||||||
10870 | This version repaints a rectangle \a rect inside the widget. | - | ||||||||||||||||||||||||||||||||||||
10871 | */ | - | ||||||||||||||||||||||||||||||||||||
10872 | void QWidget::repaint(const QRect &rect) | - | ||||||||||||||||||||||||||||||||||||
10873 | { | - | ||||||||||||||||||||||||||||||||||||
10874 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10875 | - | |||||||||||||||||||||||||||||||||||||
10876 | if (testAttribute(Qt::WA_WState_ConfigPending)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10877 | update(rect); | - | ||||||||||||||||||||||||||||||||||||
10878 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10879 | } | - | ||||||||||||||||||||||||||||||||||||
10880 | - | |||||||||||||||||||||||||||||||||||||
10881 | if (!isVisible() || !updatesEnabled() || rect.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
10882 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10883 | - | |||||||||||||||||||||||||||||||||||||
10884 | if (hasBackingStoreSupport()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10885 | QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
10886 | if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
| 0 | ||||||||||||||||||||||||||||||||||||
10887 | tlwExtra->inRepaint = true; | - | ||||||||||||||||||||||||||||||||||||
10888 | tlwExtra->backingStoreTracker->markDirty(rect, this, QWidgetBackingStore::UpdateNow); | - | ||||||||||||||||||||||||||||||||||||
10889 | tlwExtra->inRepaint = false; | - | ||||||||||||||||||||||||||||||||||||
10890 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10891 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10892 | d->repaint_sys(rect); | - | ||||||||||||||||||||||||||||||||||||
10893 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10894 | } | - | ||||||||||||||||||||||||||||||||||||
10895 | - | |||||||||||||||||||||||||||||||||||||
10896 | /*! | - | ||||||||||||||||||||||||||||||||||||
10897 | \overload | - | ||||||||||||||||||||||||||||||||||||
10898 | - | |||||||||||||||||||||||||||||||||||||
10899 | This version repaints a region \a rgn inside the widget. | - | ||||||||||||||||||||||||||||||||||||
10900 | */ | - | ||||||||||||||||||||||||||||||||||||
10901 | void QWidget::repaint(const QRegion &rgn) | - | ||||||||||||||||||||||||||||||||||||
10902 | { | - | ||||||||||||||||||||||||||||||||||||
10903 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10904 | - | |||||||||||||||||||||||||||||||||||||
10905 | if (testAttribute(Qt::WA_WState_ConfigPending)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10906 | update(rgn); | - | ||||||||||||||||||||||||||||||||||||
10907 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10908 | } | - | ||||||||||||||||||||||||||||||||||||
10909 | - | |||||||||||||||||||||||||||||||||||||
10910 | if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
10911 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10912 | - | |||||||||||||||||||||||||||||||||||||
10913 | if (hasBackingStoreSupport()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10914 | QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
10915 | if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
| 0 | ||||||||||||||||||||||||||||||||||||
10916 | tlwExtra->inRepaint = true; | - | ||||||||||||||||||||||||||||||||||||
10917 | tlwExtra->backingStoreTracker->markDirty(rgn, this, QWidgetBackingStore::UpdateNow); | - | ||||||||||||||||||||||||||||||||||||
10918 | tlwExtra->inRepaint = false; | - | ||||||||||||||||||||||||||||||||||||
10919 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10920 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10921 | d->repaint_sys(rgn); | - | ||||||||||||||||||||||||||||||||||||
10922 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10923 | } | - | ||||||||||||||||||||||||||||||||||||
10924 | - | |||||||||||||||||||||||||||||||||||||
10925 | /*! | - | ||||||||||||||||||||||||||||||||||||
10926 | Updates the widget unless updates are disabled or the widget is | - | ||||||||||||||||||||||||||||||||||||
10927 | hidden. | - | ||||||||||||||||||||||||||||||||||||
10928 | - | |||||||||||||||||||||||||||||||||||||
10929 | This function does not cause an immediate repaint; instead it | - | ||||||||||||||||||||||||||||||||||||
10930 | schedules a paint event for processing when Qt returns to the main | - | ||||||||||||||||||||||||||||||||||||
10931 | event loop. This permits Qt to optimize for more speed and less | - | ||||||||||||||||||||||||||||||||||||
10932 | flicker than a call to repaint() does. | - | ||||||||||||||||||||||||||||||||||||
10933 | - | |||||||||||||||||||||||||||||||||||||
10934 | Calling update() several times normally results in just one | - | ||||||||||||||||||||||||||||||||||||
10935 | paintEvent() call. | - | ||||||||||||||||||||||||||||||||||||
10936 | - | |||||||||||||||||||||||||||||||||||||
10937 | Qt normally erases the widget's area before the paintEvent() call. | - | ||||||||||||||||||||||||||||||||||||
10938 | If the Qt::WA_OpaquePaintEvent widget attribute is set, the widget is | - | ||||||||||||||||||||||||||||||||||||
10939 | responsible for painting all its pixels with an opaque color. | - | ||||||||||||||||||||||||||||||||||||
10940 | - | |||||||||||||||||||||||||||||||||||||
10941 | \sa repaint(), paintEvent(), setUpdatesEnabled(), {Analog Clock Example} | - | ||||||||||||||||||||||||||||||||||||
10942 | */ | - | ||||||||||||||||||||||||||||||||||||
10943 | void QWidget::update() | - | ||||||||||||||||||||||||||||||||||||
10944 | { | - | ||||||||||||||||||||||||||||||||||||
10945 | update(rect()); | - | ||||||||||||||||||||||||||||||||||||
10946 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10947 | - | |||||||||||||||||||||||||||||||||||||
10948 | /*! \fn void QWidget::update(int x, int y, int w, int h) | - | ||||||||||||||||||||||||||||||||||||
10949 | \overload | - | ||||||||||||||||||||||||||||||||||||
10950 | - | |||||||||||||||||||||||||||||||||||||
10951 | This version updates a rectangle (\a x, \a y, \a w, \a h) inside | - | ||||||||||||||||||||||||||||||||||||
10952 | the widget. | - | ||||||||||||||||||||||||||||||||||||
10953 | */ | - | ||||||||||||||||||||||||||||||||||||
10954 | - | |||||||||||||||||||||||||||||||||||||
10955 | /*! | - | ||||||||||||||||||||||||||||||||||||
10956 | \overload | - | ||||||||||||||||||||||||||||||||||||
10957 | - | |||||||||||||||||||||||||||||||||||||
10958 | This version updates a rectangle \a rect inside the widget. | - | ||||||||||||||||||||||||||||||||||||
10959 | */ | - | ||||||||||||||||||||||||||||||||||||
10960 | void QWidget::update(const QRect &rect) | - | ||||||||||||||||||||||||||||||||||||
10961 | { | - | ||||||||||||||||||||||||||||||||||||
10962 | if (!isVisible() || !updatesEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
10963 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10964 | - | |||||||||||||||||||||||||||||||||||||
10965 | QRect r = rect & QWidget::rect(); | - | ||||||||||||||||||||||||||||||||||||
10966 | - | |||||||||||||||||||||||||||||||||||||
10967 | if (r.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
10968 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10969 | - | |||||||||||||||||||||||||||||||||||||
10970 | if (testAttribute(Qt::WA_WState_InPaintEvent)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10971 | QApplication::postEvent(this, new QUpdateLaterEvent(r)); | - | ||||||||||||||||||||||||||||||||||||
10972 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10973 | } | - | ||||||||||||||||||||||||||||||||||||
10974 | - | |||||||||||||||||||||||||||||||||||||
10975 | if (hasBackingStoreSupport()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10976 | QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
10977 | if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
| 0 | ||||||||||||||||||||||||||||||||||||
10978 | tlwExtra->backingStoreTracker->markDirty(r, this); never executed: tlwExtra->backingStoreTracker->markDirty(r, this); | 0 | ||||||||||||||||||||||||||||||||||||
10979 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10980 | d_func()->repaint_sys(r); | - | ||||||||||||||||||||||||||||||||||||
10981 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10982 | } | - | ||||||||||||||||||||||||||||||||||||
10983 | - | |||||||||||||||||||||||||||||||||||||
10984 | /*! | - | ||||||||||||||||||||||||||||||||||||
10985 | \overload | - | ||||||||||||||||||||||||||||||||||||
10986 | - | |||||||||||||||||||||||||||||||||||||
10987 | This version repaints a region \a rgn inside the widget. | - | ||||||||||||||||||||||||||||||||||||
10988 | */ | - | ||||||||||||||||||||||||||||||||||||
10989 | void QWidget::update(const QRegion &rgn) | - | ||||||||||||||||||||||||||||||||||||
10990 | { | - | ||||||||||||||||||||||||||||||||||||
10991 | if (!isVisible() || !updatesEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
10992 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10993 | - | |||||||||||||||||||||||||||||||||||||
10994 | QRegion r = rgn & QWidget::rect(); | - | ||||||||||||||||||||||||||||||||||||
10995 | - | |||||||||||||||||||||||||||||||||||||
10996 | if (r.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
10997 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10998 | - | |||||||||||||||||||||||||||||||||||||
10999 | if (testAttribute(Qt::WA_WState_InPaintEvent)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11000 | QApplication::postEvent(this, new QUpdateLaterEvent(r)); | - | ||||||||||||||||||||||||||||||||||||
11001 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11002 | } | - | ||||||||||||||||||||||||||||||||||||
11003 | - | |||||||||||||||||||||||||||||||||||||
11004 | if (hasBackingStoreSupport()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11005 | QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
11006 | if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
| 0 | ||||||||||||||||||||||||||||||||||||
11007 | tlwExtra->backingStoreTracker->markDirty(r, this); never executed: tlwExtra->backingStoreTracker->markDirty(r, this); | 0 | ||||||||||||||||||||||||||||||||||||
11008 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11009 | d_func()->repaint_sys(r); | - | ||||||||||||||||||||||||||||||||||||
11010 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11011 | } | - | ||||||||||||||||||||||||||||||||||||
11012 | - | |||||||||||||||||||||||||||||||||||||
11013 | - | |||||||||||||||||||||||||||||||||||||
11014 | /*! | - | ||||||||||||||||||||||||||||||||||||
11015 | \internal | - | ||||||||||||||||||||||||||||||||||||
11016 | - | |||||||||||||||||||||||||||||||||||||
11017 | This just sets the corresponding attribute bit to 1 or 0 | - | ||||||||||||||||||||||||||||||||||||
11018 | */ | - | ||||||||||||||||||||||||||||||||||||
11019 | static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidgetData *data, | - | ||||||||||||||||||||||||||||||||||||
11020 | QWidgetPrivate *d) | - | ||||||||||||||||||||||||||||||||||||
11021 | { | - | ||||||||||||||||||||||||||||||||||||
11022 | if (attribute < int(8*sizeof(uint))) {
| 0 | ||||||||||||||||||||||||||||||||||||
11023 | if (on)
| 0 | ||||||||||||||||||||||||||||||||||||
11024 | data->widget_attributes |= (1<<attribute); never executed: data->widget_attributes |= (1<<attribute); | 0 | ||||||||||||||||||||||||||||||||||||
11025 | else | - | ||||||||||||||||||||||||||||||||||||
11026 | data->widget_attributes &= ~(1<<attribute); never executed: data->widget_attributes &= ~(1<<attribute); | 0 | ||||||||||||||||||||||||||||||||||||
11027 | } else { | - | ||||||||||||||||||||||||||||||||||||
11028 | const int x = attribute - 8*sizeof(uint); | - | ||||||||||||||||||||||||||||||||||||
11029 | const int int_off = x / (8*sizeof(uint)); | - | ||||||||||||||||||||||||||||||||||||
11030 | if (on)
| 0 | ||||||||||||||||||||||||||||||||||||
11031 | d->high_attributes[int_off] |= (1<<(x-(int_off*8*sizeof(uint)))); never executed: d->high_attributes[int_off] |= (1<<(x-(int_off*8*sizeof(uint)))); | 0 | ||||||||||||||||||||||||||||||||||||
11032 | else | - | ||||||||||||||||||||||||||||||||||||
11033 | d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint)))); never executed: d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint)))); | 0 | ||||||||||||||||||||||||||||||||||||
11034 | } | - | ||||||||||||||||||||||||||||||||||||
11035 | } | - | ||||||||||||||||||||||||||||||||||||
11036 | - | |||||||||||||||||||||||||||||||||||||
11037 | #ifdef Q_OS_MAC | - | ||||||||||||||||||||||||||||||||||||
11038 | void QWidgetPrivate::macUpdateSizeAttribute() | - | ||||||||||||||||||||||||||||||||||||
11039 | { | - | ||||||||||||||||||||||||||||||||||||
11040 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11041 | QEvent event(QEvent::MacSizeChange); | - | ||||||||||||||||||||||||||||||||||||
11042 | QApplication::sendEvent(q, &event); | - | ||||||||||||||||||||||||||||||||||||
11043 | for (int i = 0; i < children.size(); ++i) { | - | ||||||||||||||||||||||||||||||||||||
11044 | QWidget *w = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
11045 | if (w && (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation)) | - | ||||||||||||||||||||||||||||||||||||
11046 | && !q->testAttribute(Qt::WA_MacMiniSize) // no attribute set? inherit from parent | - | ||||||||||||||||||||||||||||||||||||
11047 | && !w->testAttribute(Qt::WA_MacSmallSize) | - | ||||||||||||||||||||||||||||||||||||
11048 | && !w->testAttribute(Qt::WA_MacNormalSize)) | - | ||||||||||||||||||||||||||||||||||||
11049 | w->d_func()->macUpdateSizeAttribute(); | - | ||||||||||||||||||||||||||||||||||||
11050 | } | - | ||||||||||||||||||||||||||||||||||||
11051 | resolveFont(); | - | ||||||||||||||||||||||||||||||||||||
11052 | } | - | ||||||||||||||||||||||||||||||||||||
11053 | #endif | - | ||||||||||||||||||||||||||||||||||||
11054 | - | |||||||||||||||||||||||||||||||||||||
11055 | /*! | - | ||||||||||||||||||||||||||||||||||||
11056 | Sets the attribute \a attribute on this widget if \a on is true; | - | ||||||||||||||||||||||||||||||||||||
11057 | otherwise clears the attribute. | - | ||||||||||||||||||||||||||||||||||||
11058 | - | |||||||||||||||||||||||||||||||||||||
11059 | \sa testAttribute() | - | ||||||||||||||||||||||||||||||||||||
11060 | */ | - | ||||||||||||||||||||||||||||||||||||
11061 | void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) | - | ||||||||||||||||||||||||||||||||||||
11062 | { | - | ||||||||||||||||||||||||||||||||||||
11063 | if (testAttribute(attribute) == on)
| 0 | ||||||||||||||||||||||||||||||||||||
11064 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11065 | - | |||||||||||||||||||||||||||||||||||||
11066 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11067 | Q_STATIC_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8), | - | ||||||||||||||||||||||||||||||||||||
11068 | "QWidget::setAttribute(WidgetAttribute, bool): " | - | ||||||||||||||||||||||||||||||||||||
11069 | "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute"); | - | ||||||||||||||||||||||||||||||||||||
11070 | #ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
11071 | // ### Don't use PaintOnScreen+paintEngine() to do native painting in some future release | - | ||||||||||||||||||||||||||||||||||||
11072 | if (attribute == Qt::WA_PaintOnScreen && on && windowType() != Qt::Desktop && !inherits("QGLWidget")) { | - | ||||||||||||||||||||||||||||||||||||
11073 | // see ::paintEngine for details | - | ||||||||||||||||||||||||||||||||||||
11074 | paintEngine(); | - | ||||||||||||||||||||||||||||||||||||
11075 | if (d->noPaintOnScreen) | - | ||||||||||||||||||||||||||||||||||||
11076 | return; | - | ||||||||||||||||||||||||||||||||||||
11077 | } | - | ||||||||||||||||||||||||||||||||||||
11078 | #endif | - | ||||||||||||||||||||||||||||||||||||
11079 | - | |||||||||||||||||||||||||||||||||||||
11080 | // Don't set WA_NativeWindow on platforms that don't support it -- except for QGLWidget, which depends on it | - | ||||||||||||||||||||||||||||||||||||
11081 | if (attribute == Qt::WA_NativeWindow && !d->mustHaveWindowHandle) {
| 0 | ||||||||||||||||||||||||||||||||||||
11082 | QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); | - | ||||||||||||||||||||||||||||||||||||
11083 | if (!platformIntegration->hasCapability(QPlatformIntegration::NativeWidgets))
| 0 | ||||||||||||||||||||||||||||||||||||
11084 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11085 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11086 | - | |||||||||||||||||||||||||||||||||||||
11087 | setAttribute_internal(attribute, on, data, d); | - | ||||||||||||||||||||||||||||||||||||
11088 | - | |||||||||||||||||||||||||||||||||||||
11089 | switch (attribute) { | - | ||||||||||||||||||||||||||||||||||||
11090 | - | |||||||||||||||||||||||||||||||||||||
11091 | #ifndef QT_NO_DRAGANDDROP | - | ||||||||||||||||||||||||||||||||||||
11092 | case Qt::WA_AcceptDrops: { never executed: case Qt::WA_AcceptDrops: | 0 | ||||||||||||||||||||||||||||||||||||
11093 | if (on && !testAttribute(Qt::WA_DropSiteRegistered))
| 0 | ||||||||||||||||||||||||||||||||||||
11094 | setAttribute(Qt::WA_DropSiteRegistered, true); never executed: setAttribute(Qt::WA_DropSiteRegistered, true); | 0 | ||||||||||||||||||||||||||||||||||||
11095 | else if (!on && (isWindow() || !parentWidget() || !parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)))
| 0 | ||||||||||||||||||||||||||||||||||||
11096 | setAttribute(Qt::WA_DropSiteRegistered, false); never executed: setAttribute(Qt::WA_DropSiteRegistered, false); | 0 | ||||||||||||||||||||||||||||||||||||
11097 | QEvent e(QEvent::AcceptDropsChange); | - | ||||||||||||||||||||||||||||||||||||
11098 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
11099 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11100 | } | - | ||||||||||||||||||||||||||||||||||||
11101 | case Qt::WA_DropSiteRegistered: { never executed: case Qt::WA_DropSiteRegistered: | 0 | ||||||||||||||||||||||||||||||||||||
11102 | d->registerDropSite(on); | - | ||||||||||||||||||||||||||||||||||||
11103 | for (int i = 0; i < d->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
11104 | QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
11105 | if (w && !w->isWindow() && !w->testAttribute(Qt::WA_AcceptDrops) && w->testAttribute(Qt::WA_DropSiteRegistered) != on)
| 0 | ||||||||||||||||||||||||||||||||||||
11106 | w->setAttribute(Qt::WA_DropSiteRegistered, on); never executed: w->setAttribute(Qt::WA_DropSiteRegistered, on); | 0 | ||||||||||||||||||||||||||||||||||||
11107 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11108 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11109 | } | - | ||||||||||||||||||||||||||||||||||||
11110 | #endif | - | ||||||||||||||||||||||||||||||||||||
11111 | - | |||||||||||||||||||||||||||||||||||||
11112 | case Qt::WA_NoChildEventsForParent: never executed: case Qt::WA_NoChildEventsForParent: | 0 | ||||||||||||||||||||||||||||||||||||
11113 | d->sendChildEvents = !on; | - | ||||||||||||||||||||||||||||||||||||
11114 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11115 | case Qt::WA_NoChildEventsFromChildren: never executed: case Qt::WA_NoChildEventsFromChildren: | 0 | ||||||||||||||||||||||||||||||||||||
11116 | d->receiveChildEvents = !on; | - | ||||||||||||||||||||||||||||||||||||
11117 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11118 | case Qt::WA_MacBrushedMetal: never executed: case Qt::WA_MacBrushedMetal: | 0 | ||||||||||||||||||||||||||||||||||||
11119 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
11120 | d->setStyle_helper(style(), false, true); // Make sure things get unpolished/polished correctly. | - | ||||||||||||||||||||||||||||||||||||
11121 | // fall through since changing the metal attribute affects the opaque size grip. | - | ||||||||||||||||||||||||||||||||||||
11122 | case Qt::WA_MacOpaqueSizeGrip: | - | ||||||||||||||||||||||||||||||||||||
11123 | d->macUpdateOpaqueSizeGrip(); | - | ||||||||||||||||||||||||||||||||||||
11124 | break; | - | ||||||||||||||||||||||||||||||||||||
11125 | case Qt::WA_MacShowFocusRect: | - | ||||||||||||||||||||||||||||||||||||
11126 | if (hasFocus()) { | - | ||||||||||||||||||||||||||||||||||||
11127 | clearFocus(); | - | ||||||||||||||||||||||||||||||||||||
11128 | setFocus(); | - | ||||||||||||||||||||||||||||||||||||
11129 | } | - | ||||||||||||||||||||||||||||||||||||
11130 | break; | - | ||||||||||||||||||||||||||||||||||||
11131 | case Qt::WA_Hover: | - | ||||||||||||||||||||||||||||||||||||
11132 | qt_mac_update_mouseTracking(this); | - | ||||||||||||||||||||||||||||||||||||
11133 | break; | - | ||||||||||||||||||||||||||||||||||||
11134 | #endif | - | ||||||||||||||||||||||||||||||||||||
11135 | case Qt::WA_MacAlwaysShowToolWindow: never executed: case Qt::WA_MacAlwaysShowToolWindow: | 0 | ||||||||||||||||||||||||||||||||||||
11136 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
11137 | d->macUpdateHideOnSuspend(); | - | ||||||||||||||||||||||||||||||||||||
11138 | #endif | - | ||||||||||||||||||||||||||||||||||||
11139 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11140 | case Qt::WA_MacNormalSize: never executed: case Qt::WA_MacNormalSize: | 0 | ||||||||||||||||||||||||||||||||||||
11141 | case Qt::WA_MacSmallSize: never executed: case Qt::WA_MacSmallSize: | 0 | ||||||||||||||||||||||||||||||||||||
11142 | case Qt::WA_MacMiniSize: never executed: case Qt::WA_MacMiniSize: | 0 | ||||||||||||||||||||||||||||||||||||
11143 | #ifdef Q_OS_MAC | - | ||||||||||||||||||||||||||||||||||||
11144 | { | - | ||||||||||||||||||||||||||||||||||||
11145 | // We can only have one of these set at a time | - | ||||||||||||||||||||||||||||||||||||
11146 | const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize, | - | ||||||||||||||||||||||||||||||||||||
11147 | Qt::WA_MacMiniSize }; | - | ||||||||||||||||||||||||||||||||||||
11148 | for (int i = 0; i < 3; ++i) { | - | ||||||||||||||||||||||||||||||||||||
11149 | if (MacSizes[i] != attribute) | - | ||||||||||||||||||||||||||||||||||||
11150 | setAttribute_internal(MacSizes[i], false, data, d); | - | ||||||||||||||||||||||||||||||||||||
11151 | } | - | ||||||||||||||||||||||||||||||||||||
11152 | d->macUpdateSizeAttribute(); | - | ||||||||||||||||||||||||||||||||||||
11153 | } | - | ||||||||||||||||||||||||||||||||||||
11154 | #endif | - | ||||||||||||||||||||||||||||||||||||
11155 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11156 | case Qt::WA_ShowModal: never executed: case Qt::WA_ShowModal: | 0 | ||||||||||||||||||||||||||||||||||||
11157 | if (!on) {
| 0 | ||||||||||||||||||||||||||||||||||||
11158 | // reset modality type to NonModal when clearing WA_ShowModal | - | ||||||||||||||||||||||||||||||||||||
11159 | data->window_modality = Qt::NonModal; | - | ||||||||||||||||||||||||||||||||||||
11160 | } else if (data->window_modality == Qt::NonModal) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
11161 | // determine the modality type if it hasn't been set prior | - | ||||||||||||||||||||||||||||||||||||
11162 | // to setting WA_ShowModal. set the default to WindowModal | - | ||||||||||||||||||||||||||||||||||||
11163 | // if we are the child of a group leader; otherwise use | - | ||||||||||||||||||||||||||||||||||||
11164 | // ApplicationModal. | - | ||||||||||||||||||||||||||||||||||||
11165 | QWidget *w = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
11166 | if (w)
| 0 | ||||||||||||||||||||||||||||||||||||
11167 | w = w->window(); never executed: w = w->window(); | 0 | ||||||||||||||||||||||||||||||||||||
11168 | while (w && !w->testAttribute(Qt::WA_GroupLeader)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11169 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
11170 | if (w)
| 0 | ||||||||||||||||||||||||||||||||||||
11171 | w = w->window(); never executed: w = w->window(); | 0 | ||||||||||||||||||||||||||||||||||||
11172 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11173 | data->window_modality = (w && w->testAttribute(Qt::WA_GroupLeader))
| 0 | ||||||||||||||||||||||||||||||||||||
11174 | ? Qt::WindowModal | - | ||||||||||||||||||||||||||||||||||||
11175 | : Qt::ApplicationModal; | - | ||||||||||||||||||||||||||||||||||||
11176 | // Some window managers do not allow us to enter modality after the | - | ||||||||||||||||||||||||||||||||||||
11177 | // window is visible.The window must be hidden before changing the | - | ||||||||||||||||||||||||||||||||||||
11178 | // windowModality property and then reshown. | - | ||||||||||||||||||||||||||||||||||||
11179 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11180 | if (testAttribute(Qt::WA_WState_Created)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11181 | // don't call setModal_sys() before create_sys() | - | ||||||||||||||||||||||||||||||||||||
11182 | d->setModal_sys(); | - | ||||||||||||||||||||||||||||||||||||
11183 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11184 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11185 | case Qt::WA_MouseTracking: { never executed: case Qt::WA_MouseTracking: | 0 | ||||||||||||||||||||||||||||||||||||
11186 | QEvent e(QEvent::MouseTrackingChange); | - | ||||||||||||||||||||||||||||||||||||
11187 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
11188 | break; } never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11189 | case Qt::WA_NativeWindow: { never executed: case Qt::WA_NativeWindow: | 0 | ||||||||||||||||||||||||||||||||||||
11190 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
11191 | if (on)
| 0 | ||||||||||||||||||||||||||||||||||||
11192 | d->createTLSysExtra(); never executed: d->createTLSysExtra(); | 0 | ||||||||||||||||||||||||||||||||||||
11193 | #ifndef QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
11194 | QWidget *focusWidget = d->effectiveFocusWidget(); | - | ||||||||||||||||||||||||||||||||||||
11195 | if (on && !internalWinId() && this == QGuiApplication::focusObject()
| 0 | ||||||||||||||||||||||||||||||||||||
11196 | && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11197 | QGuiApplication::inputMethod()->commit(); | - | ||||||||||||||||||||||||||||||||||||
11198 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); | - | ||||||||||||||||||||||||||||||||||||
11199 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11200 | if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
11201 | parentWidget()->d_func()->enforceNativeChildren(); never executed: parentWidget()->d_func()->enforceNativeChildren(); | 0 | ||||||||||||||||||||||||||||||||||||
11202 | if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11203 | d->createWinId(); never executed: d->createWinId(); | 0 | ||||||||||||||||||||||||||||||||||||
11204 | if (isEnabled() && focusWidget->isEnabled() && this == QGuiApplication::focusObject()
| 0 | ||||||||||||||||||||||||||||||||||||
11205 | && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11206 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); | - | ||||||||||||||||||||||||||||||||||||
11207 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11208 | #endif //QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
11209 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11210 | } | - | ||||||||||||||||||||||||||||||||||||
11211 | case Qt::WA_PaintOnScreen: never executed: case Qt::WA_PaintOnScreen: | 0 | ||||||||||||||||||||||||||||||||||||
11212 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
11213 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_X11) || defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
11214 | // Recreate the widget if it's already created as an alien widget and | - | ||||||||||||||||||||||||||||||||||||
11215 | // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id. | - | ||||||||||||||||||||||||||||||||||||
11216 | // So must their children. | - | ||||||||||||||||||||||||||||||||||||
11217 | if (on) { | - | ||||||||||||||||||||||||||||||||||||
11218 | setAttribute(Qt::WA_NativeWindow); | - | ||||||||||||||||||||||||||||||||||||
11219 | d->enforceNativeChildren(); | - | ||||||||||||||||||||||||||||||||||||
11220 | } | - | ||||||||||||||||||||||||||||||||||||
11221 | #endif | - | ||||||||||||||||||||||||||||||||||||
11222 | // fall through | - | ||||||||||||||||||||||||||||||||||||
11223 | case Qt::WA_OpaquePaintEvent: code before this statement never executed: case Qt::WA_OpaquePaintEvent: never executed: case Qt::WA_OpaquePaintEvent: | 0 | ||||||||||||||||||||||||||||||||||||
11224 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
11225 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11226 | case Qt::WA_NoSystemBackground: never executed: case Qt::WA_NoSystemBackground: | 0 | ||||||||||||||||||||||||||||||||||||
11227 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
11228 | // fall through... | - | ||||||||||||||||||||||||||||||||||||
11229 | case Qt::WA_UpdatesDisabled: code before this statement never executed: case Qt::WA_UpdatesDisabled: never executed: case Qt::WA_UpdatesDisabled: | 0 | ||||||||||||||||||||||||||||||||||||
11230 | d->updateSystemBackground(); | - | ||||||||||||||||||||||||||||||||||||
11231 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11232 | case Qt::WA_TransparentForMouseEvents: never executed: case Qt::WA_TransparentForMouseEvents: | 0 | ||||||||||||||||||||||||||||||||||||
11233 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
11234 | d->macUpdateIgnoreMouseEvents(); | - | ||||||||||||||||||||||||||||||||||||
11235 | #endif | - | ||||||||||||||||||||||||||||||||||||
11236 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11237 | case Qt::WA_InputMethodEnabled: { never executed: case Qt::WA_InputMethodEnabled: | 0 | ||||||||||||||||||||||||||||||||||||
11238 | #ifndef QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
11239 | if (QGuiApplication::focusObject() == this) {
| 0 | ||||||||||||||||||||||||||||||||||||
11240 | if (!on)
| 0 | ||||||||||||||||||||||||||||||||||||
11241 | QGuiApplication::inputMethod()->commit(); never executed: QGuiApplication::inputMethod()->commit(); | 0 | ||||||||||||||||||||||||||||||||||||
11242 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); | - | ||||||||||||||||||||||||||||||||||||
11243 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11244 | #endif //QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
11245 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11246 | } | - | ||||||||||||||||||||||||||||||||||||
11247 | case Qt::WA_WindowPropagation: never executed: case Qt::WA_WindowPropagation: | 0 | ||||||||||||||||||||||||||||||||||||
11248 | d->resolvePalette(); | - | ||||||||||||||||||||||||||||||||||||
11249 | d->resolveFont(); | - | ||||||||||||||||||||||||||||||||||||
11250 | d->resolveLocale(); | - | ||||||||||||||||||||||||||||||||||||
11251 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11252 | #ifdef Q_DEAD_CODE_FROM_QT4_X11 | - | ||||||||||||||||||||||||||||||||||||
11253 | case Qt::WA_NoX11EventCompression: | - | ||||||||||||||||||||||||||||||||||||
11254 | if (!d->extra) | - | ||||||||||||||||||||||||||||||||||||
11255 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
11256 | d->extra->compress_events = on; | - | ||||||||||||||||||||||||||||||||||||
11257 | break; | - | ||||||||||||||||||||||||||||||||||||
11258 | case Qt::WA_X11OpenGLOverlay: | - | ||||||||||||||||||||||||||||||||||||
11259 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
11260 | break; | - | ||||||||||||||||||||||||||||||||||||
11261 | case Qt::WA_X11DoNotAcceptFocus: | - | ||||||||||||||||||||||||||||||||||||
11262 | if (testAttribute(Qt::WA_WState_Created)) | - | ||||||||||||||||||||||||||||||||||||
11263 | d->updateX11AcceptFocus(); | - | ||||||||||||||||||||||||||||||||||||
11264 | break; | - | ||||||||||||||||||||||||||||||||||||
11265 | #endif | - | ||||||||||||||||||||||||||||||||||||
11266 | case Qt::WA_DontShowOnScreen: { never executed: case Qt::WA_DontShowOnScreen: | 0 | ||||||||||||||||||||||||||||||||||||
11267 | if (on && isVisible()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11268 | // Make sure we keep the current state and only hide the widget | - | ||||||||||||||||||||||||||||||||||||
11269 | // from the desktop. show_sys will only update platform specific | - | ||||||||||||||||||||||||||||||||||||
11270 | // attributes at this point. | - | ||||||||||||||||||||||||||||||||||||
11271 | d->hide_sys(); | - | ||||||||||||||||||||||||||||||||||||
11272 | d->show_sys(); | - | ||||||||||||||||||||||||||||||||||||
11273 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11274 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11275 | } | - | ||||||||||||||||||||||||||||||||||||
11276 | - | |||||||||||||||||||||||||||||||||||||
11277 | case Qt::WA_X11NetWmWindowTypeDesktop: never executed: case Qt::WA_X11NetWmWindowTypeDesktop: | 0 | ||||||||||||||||||||||||||||||||||||
11278 | case Qt::WA_X11NetWmWindowTypeDock: never executed: case Qt::WA_X11NetWmWindowTypeDock: | 0 | ||||||||||||||||||||||||||||||||||||
11279 | case Qt::WA_X11NetWmWindowTypeToolBar: never executed: case Qt::WA_X11NetWmWindowTypeToolBar: | 0 | ||||||||||||||||||||||||||||||||||||
11280 | case Qt::WA_X11NetWmWindowTypeMenu: never executed: case Qt::WA_X11NetWmWindowTypeMenu: | 0 | ||||||||||||||||||||||||||||||||||||
11281 | case Qt::WA_X11NetWmWindowTypeUtility: never executed: case Qt::WA_X11NetWmWindowTypeUtility: | 0 | ||||||||||||||||||||||||||||||||||||
11282 | case Qt::WA_X11NetWmWindowTypeSplash: never executed: case Qt::WA_X11NetWmWindowTypeSplash: | 0 | ||||||||||||||||||||||||||||||||||||
11283 | case Qt::WA_X11NetWmWindowTypeDialog: never executed: case Qt::WA_X11NetWmWindowTypeDialog: | 0 | ||||||||||||||||||||||||||||||||||||
11284 | case Qt::WA_X11NetWmWindowTypeDropDownMenu: never executed: case Qt::WA_X11NetWmWindowTypeDropDownMenu: | 0 | ||||||||||||||||||||||||||||||||||||
11285 | case Qt::WA_X11NetWmWindowTypePopupMenu: never executed: case Qt::WA_X11NetWmWindowTypePopupMenu: | 0 | ||||||||||||||||||||||||||||||||||||
11286 | case Qt::WA_X11NetWmWindowTypeToolTip: never executed: case Qt::WA_X11NetWmWindowTypeToolTip: | 0 | ||||||||||||||||||||||||||||||||||||
11287 | case Qt::WA_X11NetWmWindowTypeNotification: never executed: case Qt::WA_X11NetWmWindowTypeNotification: | 0 | ||||||||||||||||||||||||||||||||||||
11288 | case Qt::WA_X11NetWmWindowTypeCombo: never executed: case Qt::WA_X11NetWmWindowTypeCombo: | 0 | ||||||||||||||||||||||||||||||||||||
11289 | case Qt::WA_X11NetWmWindowTypeDND: never executed: case Qt::WA_X11NetWmWindowTypeDND: | 0 | ||||||||||||||||||||||||||||||||||||
11290 | d->setNetWmWindowTypes(); | - | ||||||||||||||||||||||||||||||||||||
11291 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11292 | - | |||||||||||||||||||||||||||||||||||||
11293 | case Qt::WA_StaticContents: never executed: case Qt::WA_StaticContents: | 0 | ||||||||||||||||||||||||||||||||||||
11294 | if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11295 | if (on)
| 0 | ||||||||||||||||||||||||||||||||||||
11296 | bs->addStaticWidget(this); never executed: bs->addStaticWidget(this); | 0 | ||||||||||||||||||||||||||||||||||||
11297 | else | - | ||||||||||||||||||||||||||||||||||||
11298 | bs->removeStaticWidget(this); never executed: bs->removeStaticWidget(this); | 0 | ||||||||||||||||||||||||||||||||||||
11299 | } | - | ||||||||||||||||||||||||||||||||||||
11300 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11301 | case Qt::WA_TranslucentBackground: never executed: case Qt::WA_TranslucentBackground: | 0 | ||||||||||||||||||||||||||||||||||||
11302 | if (on) {
| 0 | ||||||||||||||||||||||||||||||||||||
11303 | setAttribute(Qt::WA_NoSystemBackground); | - | ||||||||||||||||||||||||||||||||||||
11304 | d->updateIsTranslucent(); | - | ||||||||||||||||||||||||||||||||||||
11305 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11306 | - | |||||||||||||||||||||||||||||||||||||
11307 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11308 | case Qt::WA_AcceptTouchEvents: never executed: case Qt::WA_AcceptTouchEvents: | 0 | ||||||||||||||||||||||||||||||||||||
11309 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
11310 | if (on) | - | ||||||||||||||||||||||||||||||||||||
11311 | d->registerTouchWindow(); | - | ||||||||||||||||||||||||||||||||||||
11312 | #endif | - | ||||||||||||||||||||||||||||||||||||
11313 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11314 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
11315 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11316 | } | - | ||||||||||||||||||||||||||||||||||||
11317 | } | - | ||||||||||||||||||||||||||||||||||||
11318 | - | |||||||||||||||||||||||||||||||||||||
11319 | /*! \fn bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const | - | ||||||||||||||||||||||||||||||||||||
11320 | - | |||||||||||||||||||||||||||||||||||||
11321 | Returns \c true if attribute \a attribute is set on this widget; | - | ||||||||||||||||||||||||||||||||||||
11322 | otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
11323 | - | |||||||||||||||||||||||||||||||||||||
11324 | \sa setAttribute() | - | ||||||||||||||||||||||||||||||||||||
11325 | */ | - | ||||||||||||||||||||||||||||||||||||
11326 | bool QWidget::testAttribute_helper(Qt::WidgetAttribute attribute) const | - | ||||||||||||||||||||||||||||||||||||
11327 | { | - | ||||||||||||||||||||||||||||||||||||
11328 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11329 | const int x = attribute - 8*sizeof(uint); | - | ||||||||||||||||||||||||||||||||||||
11330 | const int int_off = x / (8*sizeof(uint)); | - | ||||||||||||||||||||||||||||||||||||
11331 | return (d->high_attributes[int_off] & (1<<(x-(int_off*8*sizeof(uint))))); never executed: return (d->high_attributes[int_off] & (1<<(x-(int_off*8*sizeof(uint))))); | 0 | ||||||||||||||||||||||||||||||||||||
11332 | } | - | ||||||||||||||||||||||||||||||||||||
11333 | - | |||||||||||||||||||||||||||||||||||||
11334 | /*! | - | ||||||||||||||||||||||||||||||||||||
11335 | \property QWidget::windowOpacity | - | ||||||||||||||||||||||||||||||||||||
11336 | - | |||||||||||||||||||||||||||||||||||||
11337 | \brief The level of opacity for the window. | - | ||||||||||||||||||||||||||||||||||||
11338 | - | |||||||||||||||||||||||||||||||||||||
11339 | The valid range of opacity is from 1.0 (completely opaque) to | - | ||||||||||||||||||||||||||||||||||||
11340 | 0.0 (completely transparent). | - | ||||||||||||||||||||||||||||||||||||
11341 | - | |||||||||||||||||||||||||||||||||||||
11342 | By default the value of this property is 1.0. | - | ||||||||||||||||||||||||||||||||||||
11343 | - | |||||||||||||||||||||||||||||||||||||
11344 | This feature is available on Embedded Linux, \macos, Windows, | - | ||||||||||||||||||||||||||||||||||||
11345 | and X11 platforms that support the Composite extension. | - | ||||||||||||||||||||||||||||||||||||
11346 | - | |||||||||||||||||||||||||||||||||||||
11347 | \note On X11 you need to have a composite manager running, | - | ||||||||||||||||||||||||||||||||||||
11348 | and the X11 specific _NET_WM_WINDOW_OPACITY atom needs to be | - | ||||||||||||||||||||||||||||||||||||
11349 | supported by the window manager you are using. | - | ||||||||||||||||||||||||||||||||||||
11350 | - | |||||||||||||||||||||||||||||||||||||
11351 | \warning Changing this property from opaque to transparent might issue a | - | ||||||||||||||||||||||||||||||||||||
11352 | paint event that needs to be processed before the window is displayed | - | ||||||||||||||||||||||||||||||||||||
11353 | correctly. This affects mainly the use of QPixmap::grabWindow(). Also note | - | ||||||||||||||||||||||||||||||||||||
11354 | that semi-transparent windows update and resize significantly slower than | - | ||||||||||||||||||||||||||||||||||||
11355 | opaque windows. | - | ||||||||||||||||||||||||||||||||||||
11356 | - | |||||||||||||||||||||||||||||||||||||
11357 | \sa setMask() | - | ||||||||||||||||||||||||||||||||||||
11358 | */ | - | ||||||||||||||||||||||||||||||||||||
11359 | qreal QWidget::windowOpacity() const | - | ||||||||||||||||||||||||||||||||||||
11360 | { | - | ||||||||||||||||||||||||||||||||||||
11361 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11362 | return (isWindow() && d->maybeTopData()) ? d->maybeTopData()->opacity / 255. : 1.0; never executed: return (isWindow() && d->maybeTopData()) ? d->maybeTopData()->opacity / 255. : 1.0; | 0 | ||||||||||||||||||||||||||||||||||||
11363 | } | - | ||||||||||||||||||||||||||||||||||||
11364 | - | |||||||||||||||||||||||||||||||||||||
11365 | void QWidget::setWindowOpacity(qreal opacity) | - | ||||||||||||||||||||||||||||||||||||
11366 | { | - | ||||||||||||||||||||||||||||||||||||
11367 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11368 | if (!isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
11369 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11370 | - | |||||||||||||||||||||||||||||||||||||
11371 | opacity = qBound(qreal(0.0), opacity, qreal(1.0)); | - | ||||||||||||||||||||||||||||||||||||
11372 | QTLWExtra *extra = d->topData(); | - | ||||||||||||||||||||||||||||||||||||
11373 | extra->opacity = uint(opacity * 255); | - | ||||||||||||||||||||||||||||||||||||
11374 | setAttribute(Qt::WA_WState_WindowOpacitySet); | - | ||||||||||||||||||||||||||||||||||||
11375 | d->setWindowOpacity_sys(opacity); | - | ||||||||||||||||||||||||||||||||||||
11376 | - | |||||||||||||||||||||||||||||||||||||
11377 | if (!testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11378 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11379 | - | |||||||||||||||||||||||||||||||||||||
11380 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
11381 | if (QGraphicsProxyWidget *proxy = graphicsProxyWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11382 | // Avoid invalidating the cache if set. | - | ||||||||||||||||||||||||||||||||||||
11383 | if (proxy->cacheMode() == QGraphicsItem::NoCache)
| 0 | ||||||||||||||||||||||||||||||||||||
11384 | proxy->update(); never executed: proxy->update(); | 0 | ||||||||||||||||||||||||||||||||||||
11385 | else if (QGraphicsScene *scene = proxy->scene())
| 0 | ||||||||||||||||||||||||||||||||||||
11386 | scene->update(proxy->sceneBoundingRect()); never executed: scene->update(proxy->sceneBoundingRect()); | 0 | ||||||||||||||||||||||||||||||||||||
11387 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11388 | } | - | ||||||||||||||||||||||||||||||||||||
11389 | #endif | - | ||||||||||||||||||||||||||||||||||||
11390 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11391 | - | |||||||||||||||||||||||||||||||||||||
11392 | void QWidgetPrivate::setWindowOpacity_sys(qreal level) | - | ||||||||||||||||||||||||||||||||||||
11393 | { | - | ||||||||||||||||||||||||||||||||||||
11394 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11395 | if (q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
11396 | q->windowHandle()->setOpacity(level); never executed: q->windowHandle()->setOpacity(level); | 0 | ||||||||||||||||||||||||||||||||||||
11397 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11398 | - | |||||||||||||||||||||||||||||||||||||
11399 | /*! | - | ||||||||||||||||||||||||||||||||||||
11400 | \property QWidget::windowModified | - | ||||||||||||||||||||||||||||||||||||
11401 | \brief whether the document shown in the window has unsaved changes | - | ||||||||||||||||||||||||||||||||||||
11402 | - | |||||||||||||||||||||||||||||||||||||
11403 | A modified window is a window whose content has changed but has | - | ||||||||||||||||||||||||||||||||||||
11404 | not been saved to disk. This flag will have different effects | - | ||||||||||||||||||||||||||||||||||||
11405 | varied by the platform. On \macos the close button will have a | - | ||||||||||||||||||||||||||||||||||||
11406 | modified look; on other platforms, the window title will have an | - | ||||||||||||||||||||||||||||||||||||
11407 | '*' (asterisk). | - | ||||||||||||||||||||||||||||||||||||
11408 | - | |||||||||||||||||||||||||||||||||||||
11409 | The window title must contain a "[*]" placeholder, which | - | ||||||||||||||||||||||||||||||||||||
11410 | indicates where the '*' should appear. Normally, it should appear | - | ||||||||||||||||||||||||||||||||||||
11411 | right after the file name (e.g., "document1.txt[*] - Text | - | ||||||||||||||||||||||||||||||||||||
11412 | Editor"). If the window isn't modified, the placeholder is simply | - | ||||||||||||||||||||||||||||||||||||
11413 | removed. | - | ||||||||||||||||||||||||||||||||||||
11414 | - | |||||||||||||||||||||||||||||||||||||
11415 | Note that if a widget is set as modified, all its ancestors will | - | ||||||||||||||||||||||||||||||||||||
11416 | also be set as modified. However, if you call \c | - | ||||||||||||||||||||||||||||||||||||
11417 | {setWindowModified(false)} on a widget, this will not propagate to | - | ||||||||||||||||||||||||||||||||||||
11418 | its parent because other children of the parent might have been | - | ||||||||||||||||||||||||||||||||||||
11419 | modified. | - | ||||||||||||||||||||||||||||||||||||
11420 | - | |||||||||||||||||||||||||||||||||||||
11421 | \sa windowTitle, {Application Example}, {SDI Example}, {MDI Example} | - | ||||||||||||||||||||||||||||||||||||
11422 | */ | - | ||||||||||||||||||||||||||||||||||||
11423 | bool QWidget::isWindowModified() const | - | ||||||||||||||||||||||||||||||||||||
11424 | { | - | ||||||||||||||||||||||||||||||||||||
11425 | return testAttribute(Qt::WA_WindowModified); never executed: return testAttribute(Qt::WA_WindowModified); | 0 | ||||||||||||||||||||||||||||||||||||
11426 | } | - | ||||||||||||||||||||||||||||||||||||
11427 | - | |||||||||||||||||||||||||||||||||||||
11428 | void QWidget::setWindowModified(bool mod) | - | ||||||||||||||||||||||||||||||||||||
11429 | { | - | ||||||||||||||||||||||||||||||||||||
11430 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11431 | setAttribute(Qt::WA_WindowModified, mod); | - | ||||||||||||||||||||||||||||||||||||
11432 | - | |||||||||||||||||||||||||||||||||||||
11433 | d->setWindowModified_helper(); | - | ||||||||||||||||||||||||||||||||||||
11434 | - | |||||||||||||||||||||||||||||||||||||
11435 | QEvent e(QEvent::ModifiedChange); | - | ||||||||||||||||||||||||||||||||||||
11436 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
11437 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11438 | - | |||||||||||||||||||||||||||||||||||||
11439 | void QWidgetPrivate::setWindowModified_helper() | - | ||||||||||||||||||||||||||||||||||||
11440 | { | - | ||||||||||||||||||||||||||||||||||||
11441 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11442 | QWindow *window = q->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
11443 | if (!window)
| 0 | ||||||||||||||||||||||||||||||||||||
11444 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11445 | QPlatformWindow *platformWindow = window->handle(); | - | ||||||||||||||||||||||||||||||||||||
11446 | if (!platformWindow)
| 0 | ||||||||||||||||||||||||||||||||||||
11447 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11448 | bool on = q->testAttribute(Qt::WA_WindowModified); | - | ||||||||||||||||||||||||||||||||||||
11449 | if (!platformWindow->setWindowModified(on)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11450 | if (Q_UNLIKELY(on && !q->windowTitle().contains(QLatin1String("[*]"))))
| 0 | ||||||||||||||||||||||||||||||||||||
11451 | qWarning("QWidget::setWindowModified: The window title does not contain a '[*]' placeholder"); never executed: QMessageLogger(__FILE__, 11451, __PRETTY_FUNCTION__).warning("QWidget::setWindowModified: The window title does not contain a '[*]' placeholder"); | 0 | ||||||||||||||||||||||||||||||||||||
11452 | setWindowTitle_helper(q->windowTitle()); | - | ||||||||||||||||||||||||||||||||||||
11453 | setWindowIconText_helper(q->windowIconText()); | - | ||||||||||||||||||||||||||||||||||||
11454 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11455 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11456 | - | |||||||||||||||||||||||||||||||||||||
11457 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||||||||||||||
11458 | /*! | - | ||||||||||||||||||||||||||||||||||||
11459 | \property QWidget::toolTip | - | ||||||||||||||||||||||||||||||||||||
11460 | - | |||||||||||||||||||||||||||||||||||||
11461 | \brief the widget's tooltip | - | ||||||||||||||||||||||||||||||||||||
11462 | - | |||||||||||||||||||||||||||||||||||||
11463 | Note that by default tooltips are only shown for widgets that are | - | ||||||||||||||||||||||||||||||||||||
11464 | children of the active window. You can change this behavior by | - | ||||||||||||||||||||||||||||||||||||
11465 | setting the attribute Qt::WA_AlwaysShowToolTips on the \e window, | - | ||||||||||||||||||||||||||||||||||||
11466 | not on the widget with the tooltip. | - | ||||||||||||||||||||||||||||||||||||
11467 | - | |||||||||||||||||||||||||||||||||||||
11468 | If you want to control a tooltip's behavior, you can intercept the | - | ||||||||||||||||||||||||||||||||||||
11469 | event() function and catch the QEvent::ToolTip event (e.g., if you | - | ||||||||||||||||||||||||||||||||||||
11470 | want to customize the area for which the tooltip should be shown). | - | ||||||||||||||||||||||||||||||||||||
11471 | - | |||||||||||||||||||||||||||||||||||||
11472 | By default, this property contains an empty string. | - | ||||||||||||||||||||||||||||||||||||
11473 | - | |||||||||||||||||||||||||||||||||||||
11474 | \sa QToolTip, statusTip, whatsThis | - | ||||||||||||||||||||||||||||||||||||
11475 | */ | - | ||||||||||||||||||||||||||||||||||||
11476 | void QWidget::setToolTip(const QString &s) | - | ||||||||||||||||||||||||||||||||||||
11477 | { | - | ||||||||||||||||||||||||||||||||||||
11478 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11479 | d->toolTip = s; | - | ||||||||||||||||||||||||||||||||||||
11480 | - | |||||||||||||||||||||||||||||||||||||
11481 | QEvent event(QEvent::ToolTipChange); | - | ||||||||||||||||||||||||||||||||||||
11482 | QApplication::sendEvent(this, &event); | - | ||||||||||||||||||||||||||||||||||||
11483 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11484 | - | |||||||||||||||||||||||||||||||||||||
11485 | QString QWidget::toolTip() const | - | ||||||||||||||||||||||||||||||||||||
11486 | { | - | ||||||||||||||||||||||||||||||||||||
11487 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11488 | return d->toolTip; never executed: return d->toolTip; | 0 | ||||||||||||||||||||||||||||||||||||
11489 | } | - | ||||||||||||||||||||||||||||||||||||
11490 | - | |||||||||||||||||||||||||||||||||||||
11491 | /*! | - | ||||||||||||||||||||||||||||||||||||
11492 | \property QWidget::toolTipDuration | - | ||||||||||||||||||||||||||||||||||||
11493 | \brief the widget's tooltip duration | - | ||||||||||||||||||||||||||||||||||||
11494 | \since 5.2 | - | ||||||||||||||||||||||||||||||||||||
11495 | - | |||||||||||||||||||||||||||||||||||||
11496 | Specifies how long time the tooltip will be displayed, in milliseconds. | - | ||||||||||||||||||||||||||||||||||||
11497 | If the value is -1 (default) the duration is calculated depending on the length of the tooltip. | - | ||||||||||||||||||||||||||||||||||||
11498 | - | |||||||||||||||||||||||||||||||||||||
11499 | \sa toolTip | - | ||||||||||||||||||||||||||||||||||||
11500 | */ | - | ||||||||||||||||||||||||||||||||||||
11501 | - | |||||||||||||||||||||||||||||||||||||
11502 | void QWidget::setToolTipDuration(int msec) | - | ||||||||||||||||||||||||||||||||||||
11503 | { | - | ||||||||||||||||||||||||||||||||||||
11504 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11505 | d->toolTipDuration = msec; | - | ||||||||||||||||||||||||||||||||||||
11506 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11507 | - | |||||||||||||||||||||||||||||||||||||
11508 | int QWidget::toolTipDuration() const | - | ||||||||||||||||||||||||||||||||||||
11509 | { | - | ||||||||||||||||||||||||||||||||||||
11510 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11511 | return d->toolTipDuration; never executed: return d->toolTipDuration; | 0 | ||||||||||||||||||||||||||||||||||||
11512 | } | - | ||||||||||||||||||||||||||||||||||||
11513 | - | |||||||||||||||||||||||||||||||||||||
11514 | #endif // QT_NO_TOOLTIP | - | ||||||||||||||||||||||||||||||||||||
11515 | - | |||||||||||||||||||||||||||||||||||||
11516 | - | |||||||||||||||||||||||||||||||||||||
11517 | #ifndef QT_NO_STATUSTIP | - | ||||||||||||||||||||||||||||||||||||
11518 | /*! | - | ||||||||||||||||||||||||||||||||||||
11519 | \property QWidget::statusTip | - | ||||||||||||||||||||||||||||||||||||
11520 | \brief the widget's status tip | - | ||||||||||||||||||||||||||||||||||||
11521 | - | |||||||||||||||||||||||||||||||||||||
11522 | By default, this property contains an empty string. | - | ||||||||||||||||||||||||||||||||||||
11523 | - | |||||||||||||||||||||||||||||||||||||
11524 | \sa toolTip, whatsThis | - | ||||||||||||||||||||||||||||||||||||
11525 | */ | - | ||||||||||||||||||||||||||||||||||||
11526 | void QWidget::setStatusTip(const QString &s) | - | ||||||||||||||||||||||||||||||||||||
11527 | { | - | ||||||||||||||||||||||||||||||||||||
11528 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11529 | d->statusTip = s; | - | ||||||||||||||||||||||||||||||||||||
11530 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11531 | - | |||||||||||||||||||||||||||||||||||||
11532 | QString QWidget::statusTip() const | - | ||||||||||||||||||||||||||||||||||||
11533 | { | - | ||||||||||||||||||||||||||||||||||||
11534 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11535 | return d->statusTip; never executed: return d->statusTip; | 0 | ||||||||||||||||||||||||||||||||||||
11536 | } | - | ||||||||||||||||||||||||||||||||||||
11537 | #endif // QT_NO_STATUSTIP | - | ||||||||||||||||||||||||||||||||||||
11538 | - | |||||||||||||||||||||||||||||||||||||
11539 | #ifndef QT_NO_WHATSTHIS | - | ||||||||||||||||||||||||||||||||||||
11540 | /*! | - | ||||||||||||||||||||||||||||||||||||
11541 | \property QWidget::whatsThis | - | ||||||||||||||||||||||||||||||||||||
11542 | - | |||||||||||||||||||||||||||||||||||||
11543 | \brief the widget's What's This help text. | - | ||||||||||||||||||||||||||||||||||||
11544 | - | |||||||||||||||||||||||||||||||||||||
11545 | By default, this property contains an empty string. | - | ||||||||||||||||||||||||||||||||||||
11546 | - | |||||||||||||||||||||||||||||||||||||
11547 | \sa QWhatsThis, QWidget::toolTip, QWidget::statusTip | - | ||||||||||||||||||||||||||||||||||||
11548 | */ | - | ||||||||||||||||||||||||||||||||||||
11549 | void QWidget::setWhatsThis(const QString &s) | - | ||||||||||||||||||||||||||||||||||||
11550 | { | - | ||||||||||||||||||||||||||||||||||||
11551 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11552 | d->whatsThis = s; | - | ||||||||||||||||||||||||||||||||||||
11553 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11554 | - | |||||||||||||||||||||||||||||||||||||
11555 | QString QWidget::whatsThis() const | - | ||||||||||||||||||||||||||||||||||||
11556 | { | - | ||||||||||||||||||||||||||||||||||||
11557 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11558 | return d->whatsThis; never executed: return d->whatsThis; | 0 | ||||||||||||||||||||||||||||||||||||
11559 | } | - | ||||||||||||||||||||||||||||||||||||
11560 | #endif // QT_NO_WHATSTHIS | - | ||||||||||||||||||||||||||||||||||||
11561 | - | |||||||||||||||||||||||||||||||||||||
11562 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
11563 | /*! | - | ||||||||||||||||||||||||||||||||||||
11564 | \property QWidget::accessibleName | - | ||||||||||||||||||||||||||||||||||||
11565 | - | |||||||||||||||||||||||||||||||||||||
11566 | \brief the widget's name as seen by assistive technologies | - | ||||||||||||||||||||||||||||||||||||
11567 | - | |||||||||||||||||||||||||||||||||||||
11568 | This is the primary name by which assistive technology such as screen readers | - | ||||||||||||||||||||||||||||||||||||
11569 | announce this widget. For most widgets setting this property is not required. | - | ||||||||||||||||||||||||||||||||||||
11570 | For example for QPushButton the button's text will be used. | - | ||||||||||||||||||||||||||||||||||||
11571 | - | |||||||||||||||||||||||||||||||||||||
11572 | It is important to set this property when the widget does not provide any | - | ||||||||||||||||||||||||||||||||||||
11573 | text. For example a button that only contains an icon needs to set this | - | ||||||||||||||||||||||||||||||||||||
11574 | property to work with screen readers. | - | ||||||||||||||||||||||||||||||||||||
11575 | The name should be short and equivalent to the visual information conveyed | - | ||||||||||||||||||||||||||||||||||||
11576 | by the widget. | - | ||||||||||||||||||||||||||||||||||||
11577 | - | |||||||||||||||||||||||||||||||||||||
11578 | This property has to be \l{Internationalization with Qt}{localized}. | - | ||||||||||||||||||||||||||||||||||||
11579 | - | |||||||||||||||||||||||||||||||||||||
11580 | By default, this property contains an empty string. | - | ||||||||||||||||||||||||||||||||||||
11581 | - | |||||||||||||||||||||||||||||||||||||
11582 | \sa QWidget::accessibleDescription, QAccessibleInterface::text() | - | ||||||||||||||||||||||||||||||||||||
11583 | */ | - | ||||||||||||||||||||||||||||||||||||
11584 | void QWidget::setAccessibleName(const QString &name) | - | ||||||||||||||||||||||||||||||||||||
11585 | { | - | ||||||||||||||||||||||||||||||||||||
11586 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11587 | d->accessibleName = name; | - | ||||||||||||||||||||||||||||||||||||
11588 | QAccessibleEvent event(this, QAccessible::NameChanged); | - | ||||||||||||||||||||||||||||||||||||
11589 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
11590 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11591 | - | |||||||||||||||||||||||||||||||||||||
11592 | QString QWidget::accessibleName() const | - | ||||||||||||||||||||||||||||||||||||
11593 | { | - | ||||||||||||||||||||||||||||||||||||
11594 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11595 | return d->accessibleName; never executed: return d->accessibleName; | 0 | ||||||||||||||||||||||||||||||||||||
11596 | } | - | ||||||||||||||||||||||||||||||||||||
11597 | - | |||||||||||||||||||||||||||||||||||||
11598 | /*! | - | ||||||||||||||||||||||||||||||||||||
11599 | \property QWidget::accessibleDescription | - | ||||||||||||||||||||||||||||||||||||
11600 | - | |||||||||||||||||||||||||||||||||||||
11601 | \brief the widget's description as seen by assistive technologies | - | ||||||||||||||||||||||||||||||||||||
11602 | - | |||||||||||||||||||||||||||||||||||||
11603 | The accessible description of a widget should convey what a widget does. | - | ||||||||||||||||||||||||||||||||||||
11604 | While the \l accessibleName should be a short and consise string (e.g. \gui{Save}), | - | ||||||||||||||||||||||||||||||||||||
11605 | the description should give more context, such as \gui{Saves the current document}. | - | ||||||||||||||||||||||||||||||||||||
11606 | - | |||||||||||||||||||||||||||||||||||||
11607 | This property has to be \l{Internationalization with Qt}{localized}. | - | ||||||||||||||||||||||||||||||||||||
11608 | - | |||||||||||||||||||||||||||||||||||||
11609 | By default, this property contains an empty string and Qt falls back | - | ||||||||||||||||||||||||||||||||||||
11610 | to using the tool tip to provide this information. | - | ||||||||||||||||||||||||||||||||||||
11611 | - | |||||||||||||||||||||||||||||||||||||
11612 | \sa QWidget::accessibleName, QAccessibleInterface::text() | - | ||||||||||||||||||||||||||||||||||||
11613 | */ | - | ||||||||||||||||||||||||||||||||||||
11614 | void QWidget::setAccessibleDescription(const QString &description) | - | ||||||||||||||||||||||||||||||||||||
11615 | { | - | ||||||||||||||||||||||||||||||||||||
11616 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11617 | d->accessibleDescription = description; | - | ||||||||||||||||||||||||||||||||||||
11618 | QAccessibleEvent event(this, QAccessible::DescriptionChanged); | - | ||||||||||||||||||||||||||||||||||||
11619 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
11620 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11621 | - | |||||||||||||||||||||||||||||||||||||
11622 | QString QWidget::accessibleDescription() const | - | ||||||||||||||||||||||||||||||||||||
11623 | { | - | ||||||||||||||||||||||||||||||||||||
11624 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11625 | return d->accessibleDescription; never executed: return d->accessibleDescription; | 0 | ||||||||||||||||||||||||||||||||||||
11626 | } | - | ||||||||||||||||||||||||||||||||||||
11627 | #endif // QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
11628 | - | |||||||||||||||||||||||||||||||||||||
11629 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||||||||||||||||||||
11630 | /*! | - | ||||||||||||||||||||||||||||||||||||
11631 | Adds a shortcut to Qt's shortcut system that watches for the given | - | ||||||||||||||||||||||||||||||||||||
11632 | \a key sequence in the given \a context. If the \a context is | - | ||||||||||||||||||||||||||||||||||||
11633 | Qt::ApplicationShortcut, the shortcut applies to the application as a | - | ||||||||||||||||||||||||||||||||||||
11634 | whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut, | - | ||||||||||||||||||||||||||||||||||||
11635 | or to the window itself, Qt::WindowShortcut. | - | ||||||||||||||||||||||||||||||||||||
11636 | - | |||||||||||||||||||||||||||||||||||||
11637 | If the same \a key sequence has been grabbed by several widgets, | - | ||||||||||||||||||||||||||||||||||||
11638 | when the \a key sequence occurs a QEvent::Shortcut event is sent | - | ||||||||||||||||||||||||||||||||||||
11639 | to all the widgets to which it applies in a non-deterministic | - | ||||||||||||||||||||||||||||||||||||
11640 | order, but with the ``ambiguous'' flag set to true. | - | ||||||||||||||||||||||||||||||||||||
11641 | - | |||||||||||||||||||||||||||||||||||||
11642 | \warning You should not normally need to use this function; | - | ||||||||||||||||||||||||||||||||||||
11643 | instead create \l{QAction}s with the shortcut key sequences you | - | ||||||||||||||||||||||||||||||||||||
11644 | require (if you also want equivalent menu options and toolbar | - | ||||||||||||||||||||||||||||||||||||
11645 | buttons), or create \l{QShortcut}s if you just need key sequences. | - | ||||||||||||||||||||||||||||||||||||
11646 | Both QAction and QShortcut handle all the event filtering for you, | - | ||||||||||||||||||||||||||||||||||||
11647 | and provide signals which are triggered when the user triggers the | - | ||||||||||||||||||||||||||||||||||||
11648 | key sequence, so are much easier to use than this low-level | - | ||||||||||||||||||||||||||||||||||||
11649 | function. | - | ||||||||||||||||||||||||||||||||||||
11650 | - | |||||||||||||||||||||||||||||||||||||
11651 | \sa releaseShortcut(), setShortcutEnabled() | - | ||||||||||||||||||||||||||||||||||||
11652 | */ | - | ||||||||||||||||||||||||||||||||||||
11653 | int QWidget::grabShortcut(const QKeySequence &key, Qt::ShortcutContext context) | - | ||||||||||||||||||||||||||||||||||||
11654 | { | - | ||||||||||||||||||||||||||||||||||||
11655 | Q_ASSERT(qApp); | - | ||||||||||||||||||||||||||||||||||||
11656 | if (key.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
11657 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
11658 | setAttribute(Qt::WA_GrabbedShortcut); | - | ||||||||||||||||||||||||||||||||||||
11659 | return qApp->d_func()->shortcutMap.addShortcut(this, key, context, qWidgetShortcutContextMatcher); never executed: return (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.addShortcut(this, key, context, qWidgetShortcutContextMatcher); | 0 | ||||||||||||||||||||||||||||||||||||
11660 | } | - | ||||||||||||||||||||||||||||||||||||
11661 | - | |||||||||||||||||||||||||||||||||||||
11662 | /*! | - | ||||||||||||||||||||||||||||||||||||
11663 | Removes the shortcut with the given \a id from Qt's shortcut | - | ||||||||||||||||||||||||||||||||||||
11664 | system. The widget will no longer receive QEvent::Shortcut events | - | ||||||||||||||||||||||||||||||||||||
11665 | for the shortcut's key sequence (unless it has other shortcuts | - | ||||||||||||||||||||||||||||||||||||
11666 | with the same key sequence). | - | ||||||||||||||||||||||||||||||||||||
11667 | - | |||||||||||||||||||||||||||||||||||||
11668 | \warning You should not normally need to use this function since | - | ||||||||||||||||||||||||||||||||||||
11669 | Qt's shortcut system removes shortcuts automatically when their | - | ||||||||||||||||||||||||||||||||||||
11670 | parent widget is destroyed. It is best to use QAction or | - | ||||||||||||||||||||||||||||||||||||
11671 | QShortcut to handle shortcuts, since they are easier to use than | - | ||||||||||||||||||||||||||||||||||||
11672 | this low-level function. Note also that this is an expensive | - | ||||||||||||||||||||||||||||||||||||
11673 | operation. | - | ||||||||||||||||||||||||||||||||||||
11674 | - | |||||||||||||||||||||||||||||||||||||
11675 | \sa grabShortcut(), setShortcutEnabled() | - | ||||||||||||||||||||||||||||||||||||
11676 | */ | - | ||||||||||||||||||||||||||||||||||||
11677 | void QWidget::releaseShortcut(int id) | - | ||||||||||||||||||||||||||||||||||||
11678 | { | - | ||||||||||||||||||||||||||||||||||||
11679 | Q_ASSERT(qApp); | - | ||||||||||||||||||||||||||||||||||||
11680 | if (id)
| 0 | ||||||||||||||||||||||||||||||||||||
11681 | qApp->d_func()->shortcutMap.removeShortcut(id, this, 0); never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(id, this, 0); | 0 | ||||||||||||||||||||||||||||||||||||
11682 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11683 | - | |||||||||||||||||||||||||||||||||||||
11684 | /*! | - | ||||||||||||||||||||||||||||||||||||
11685 | If \a enable is true, the shortcut with the given \a id is | - | ||||||||||||||||||||||||||||||||||||
11686 | enabled; otherwise the shortcut is disabled. | - | ||||||||||||||||||||||||||||||||||||
11687 | - | |||||||||||||||||||||||||||||||||||||
11688 | \warning You should not normally need to use this function since | - | ||||||||||||||||||||||||||||||||||||
11689 | Qt's shortcut system enables/disables shortcuts automatically as | - | ||||||||||||||||||||||||||||||||||||
11690 | widgets become hidden/visible and gain or lose focus. It is best | - | ||||||||||||||||||||||||||||||||||||
11691 | to use QAction or QShortcut to handle shortcuts, since they are | - | ||||||||||||||||||||||||||||||||||||
11692 | easier to use than this low-level function. | - | ||||||||||||||||||||||||||||||||||||
11693 | - | |||||||||||||||||||||||||||||||||||||
11694 | \sa grabShortcut(), releaseShortcut() | - | ||||||||||||||||||||||||||||||||||||
11695 | */ | - | ||||||||||||||||||||||||||||||||||||
11696 | void QWidget::setShortcutEnabled(int id, bool enable) | - | ||||||||||||||||||||||||||||||||||||
11697 | { | - | ||||||||||||||||||||||||||||||||||||
11698 | Q_ASSERT(qApp); | - | ||||||||||||||||||||||||||||||||||||
11699 | if (id)
| 0 | ||||||||||||||||||||||||||||||||||||
11700 | qApp->d_func()->shortcutMap.setShortcutEnabled(enable, id, this, 0); never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.setShortcutEnabled(enable, id, this, 0); | 0 | ||||||||||||||||||||||||||||||||||||
11701 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11702 | - | |||||||||||||||||||||||||||||||||||||
11703 | /*! | - | ||||||||||||||||||||||||||||||||||||
11704 | \since 4.2 | - | ||||||||||||||||||||||||||||||||||||
11705 | - | |||||||||||||||||||||||||||||||||||||
11706 | If \a enable is true, auto repeat of the shortcut with the | - | ||||||||||||||||||||||||||||||||||||
11707 | given \a id is enabled; otherwise it is disabled. | - | ||||||||||||||||||||||||||||||||||||
11708 | - | |||||||||||||||||||||||||||||||||||||
11709 | \sa grabShortcut(), releaseShortcut() | - | ||||||||||||||||||||||||||||||||||||
11710 | */ | - | ||||||||||||||||||||||||||||||||||||
11711 | void QWidget::setShortcutAutoRepeat(int id, bool enable) | - | ||||||||||||||||||||||||||||||||||||
11712 | { | - | ||||||||||||||||||||||||||||||||||||
11713 | Q_ASSERT(qApp); | - | ||||||||||||||||||||||||||||||||||||
11714 | if (id)
| 0 | ||||||||||||||||||||||||||||||||||||
11715 | qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enable, id, this, 0); never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.setShortcutAutoRepeat(enable, id, this, 0); | 0 | ||||||||||||||||||||||||||||||||||||
11716 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11717 | #endif // QT_NO_SHORTCUT | - | ||||||||||||||||||||||||||||||||||||
11718 | - | |||||||||||||||||||||||||||||||||||||
11719 | /*! | - | ||||||||||||||||||||||||||||||||||||
11720 | Updates the widget's micro focus. | - | ||||||||||||||||||||||||||||||||||||
11721 | */ | - | ||||||||||||||||||||||||||||||||||||
11722 | void QWidget::updateMicroFocus() | - | ||||||||||||||||||||||||||||||||||||
11723 | { | - | ||||||||||||||||||||||||||||||||||||
11724 | // updating everything since this is currently called for any kind of state change | - | ||||||||||||||||||||||||||||||||||||
11725 | if (this == QGuiApplication::focusObject())
| 0 | ||||||||||||||||||||||||||||||||||||
11726 | QGuiApplication::inputMethod()->update(Qt::ImQueryAll); never executed: QGuiApplication::inputMethod()->update(Qt::ImQueryAll); | 0 | ||||||||||||||||||||||||||||||||||||
11727 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11728 | - | |||||||||||||||||||||||||||||||||||||
11729 | /*! | - | ||||||||||||||||||||||||||||||||||||
11730 | Raises this widget to the top of the parent widget's stack. | - | ||||||||||||||||||||||||||||||||||||
11731 | - | |||||||||||||||||||||||||||||||||||||
11732 | After this call the widget will be visually in front of any | - | ||||||||||||||||||||||||||||||||||||
11733 | overlapping sibling widgets. | - | ||||||||||||||||||||||||||||||||||||
11734 | - | |||||||||||||||||||||||||||||||||||||
11735 | \note When using activateWindow(), you can call this function to | - | ||||||||||||||||||||||||||||||||||||
11736 | ensure that the window is stacked on top. | - | ||||||||||||||||||||||||||||||||||||
11737 | - | |||||||||||||||||||||||||||||||||||||
11738 | \sa lower(), stackUnder() | - | ||||||||||||||||||||||||||||||||||||
11739 | */ | - | ||||||||||||||||||||||||||||||||||||
11740 | - | |||||||||||||||||||||||||||||||||||||
11741 | void QWidget::raise() | - | ||||||||||||||||||||||||||||||||||||
11742 | { | - | ||||||||||||||||||||||||||||||||||||
11743 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11744 | if (!isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11745 | QWidget *p = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
11746 | const int parentChildCount = p->d_func()->children.size(); | - | ||||||||||||||||||||||||||||||||||||
11747 | if (parentChildCount < 2)
| 0 | ||||||||||||||||||||||||||||||||||||
11748 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11749 | const int from = p->d_func()->children.indexOf(this); | - | ||||||||||||||||||||||||||||||||||||
11750 | Q_ASSERT(from >= 0); | - | ||||||||||||||||||||||||||||||||||||
11751 | // Do nothing if the widget is already in correct stacking order _and_ created. | - | ||||||||||||||||||||||||||||||||||||
11752 | if (from != parentChildCount -1)
| 0 | ||||||||||||||||||||||||||||||||||||
11753 | p->d_func()->children.move(from, parentChildCount - 1); never executed: p->d_func()->children.move(from, parentChildCount - 1); | 0 | ||||||||||||||||||||||||||||||||||||
11754 | if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11755 | create(); never executed: create(); | 0 | ||||||||||||||||||||||||||||||||||||
11756 | else if (from == parentChildCount - 1)
| 0 | ||||||||||||||||||||||||||||||||||||
11757 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11758 | - | |||||||||||||||||||||||||||||||||||||
11759 | QRegion region(rect()); | - | ||||||||||||||||||||||||||||||||||||
11760 | d->subtractOpaqueSiblings(region); | - | ||||||||||||||||||||||||||||||||||||
11761 | d->invalidateBuffer(region); | - | ||||||||||||||||||||||||||||||||||||
11762 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11763 | if (testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11764 | d->raise_sys(); never executed: d->raise_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
11765 | - | |||||||||||||||||||||||||||||||||||||
11766 | if (d->extra && d->extra->hasWindowContainer)
| 0 | ||||||||||||||||||||||||||||||||||||
11767 | QWindowContainer::parentWasRaised(this); never executed: QWindowContainer::parentWasRaised(this); | 0 | ||||||||||||||||||||||||||||||||||||
11768 | - | |||||||||||||||||||||||||||||||||||||
11769 | QEvent e(QEvent::ZOrderChange); | - | ||||||||||||||||||||||||||||||||||||
11770 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
11771 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11772 | - | |||||||||||||||||||||||||||||||||||||
11773 | void QWidgetPrivate::raise_sys() | - | ||||||||||||||||||||||||||||||||||||
11774 | { | - | ||||||||||||||||||||||||||||||||||||
11775 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11776 | if (q->isWindow() || q->testAttribute(Qt::WA_NativeWindow)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11777 | q->windowHandle()->raise(); | - | ||||||||||||||||||||||||||||||||||||
11778 | } else if (renderToTexture) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
11779 | if (QWidget *p = q->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11780 | setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
11781 | p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); | - | ||||||||||||||||||||||||||||||||||||
11782 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11783 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11784 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11785 | - | |||||||||||||||||||||||||||||||||||||
11786 | /*! | - | ||||||||||||||||||||||||||||||||||||
11787 | Lowers the widget to the bottom of the parent widget's stack. | - | ||||||||||||||||||||||||||||||||||||
11788 | - | |||||||||||||||||||||||||||||||||||||
11789 | After this call the widget will be visually behind (and therefore | - | ||||||||||||||||||||||||||||||||||||
11790 | obscured by) any overlapping sibling widgets. | - | ||||||||||||||||||||||||||||||||||||
11791 | - | |||||||||||||||||||||||||||||||||||||
11792 | \sa raise(), stackUnder() | - | ||||||||||||||||||||||||||||||||||||
11793 | */ | - | ||||||||||||||||||||||||||||||||||||
11794 | - | |||||||||||||||||||||||||||||||||||||
11795 | void QWidget::lower() | - | ||||||||||||||||||||||||||||||||||||
11796 | { | - | ||||||||||||||||||||||||||||||||||||
11797 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11798 | if (!isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11799 | QWidget *p = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
11800 | const int parentChildCount = p->d_func()->children.size(); | - | ||||||||||||||||||||||||||||||||||||
11801 | if (parentChildCount < 2)
| 0 | ||||||||||||||||||||||||||||||||||||
11802 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11803 | const int from = p->d_func()->children.indexOf(this); | - | ||||||||||||||||||||||||||||||||||||
11804 | Q_ASSERT(from >= 0); | - | ||||||||||||||||||||||||||||||||||||
11805 | // Do nothing if the widget is already in correct stacking order _and_ created. | - | ||||||||||||||||||||||||||||||||||||
11806 | if (from != 0)
| 0 | ||||||||||||||||||||||||||||||||||||
11807 | p->d_func()->children.move(from, 0); never executed: p->d_func()->children.move(from, 0); | 0 | ||||||||||||||||||||||||||||||||||||
11808 | if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11809 | create(); never executed: create(); | 0 | ||||||||||||||||||||||||||||||||||||
11810 | else if (from == 0)
| 0 | ||||||||||||||||||||||||||||||||||||
11811 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11812 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11813 | if (testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11814 | d->lower_sys(); never executed: d->lower_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
11815 | - | |||||||||||||||||||||||||||||||||||||
11816 | if (d->extra && d->extra->hasWindowContainer)
| 0 | ||||||||||||||||||||||||||||||||||||
11817 | QWindowContainer::parentWasLowered(this); never executed: QWindowContainer::parentWasLowered(this); | 0 | ||||||||||||||||||||||||||||||||||||
11818 | - | |||||||||||||||||||||||||||||||||||||
11819 | QEvent e(QEvent::ZOrderChange); | - | ||||||||||||||||||||||||||||||||||||
11820 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
11821 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11822 | - | |||||||||||||||||||||||||||||||||||||
11823 | void QWidgetPrivate::lower_sys() | - | ||||||||||||||||||||||||||||||||||||
11824 | { | - | ||||||||||||||||||||||||||||||||||||
11825 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11826 | if (q->isWindow() || q->testAttribute(Qt::WA_NativeWindow)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11827 | Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); | - | ||||||||||||||||||||||||||||||||||||
11828 | q->windowHandle()->lower(); | - | ||||||||||||||||||||||||||||||||||||
11829 | } else if (QWidget *p = q->parentWidget()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
11830 | setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
11831 | p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); | - | ||||||||||||||||||||||||||||||||||||
11832 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11833 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11834 | - | |||||||||||||||||||||||||||||||||||||
11835 | /*! | - | ||||||||||||||||||||||||||||||||||||
11836 | Places the widget under \a w in the parent widget's stack. | - | ||||||||||||||||||||||||||||||||||||
11837 | - | |||||||||||||||||||||||||||||||||||||
11838 | To make this work, the widget itself and \a w must be siblings. | - | ||||||||||||||||||||||||||||||||||||
11839 | - | |||||||||||||||||||||||||||||||||||||
11840 | \sa raise(), lower() | - | ||||||||||||||||||||||||||||||||||||
11841 | */ | - | ||||||||||||||||||||||||||||||||||||
11842 | void QWidget::stackUnder(QWidget* w) | - | ||||||||||||||||||||||||||||||||||||
11843 | { | - | ||||||||||||||||||||||||||||||||||||
11844 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11845 | QWidget *p = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
11846 | if (!w || isWindow() || p != w->parentWidget() || this == w)
| 0 | ||||||||||||||||||||||||||||||||||||
11847 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11848 | if (p) {
| 0 | ||||||||||||||||||||||||||||||||||||
11849 | int from = p->d_func()->children.indexOf(this); | - | ||||||||||||||||||||||||||||||||||||
11850 | int to = p->d_func()->children.indexOf(w); | - | ||||||||||||||||||||||||||||||||||||
11851 | Q_ASSERT(from >= 0); | - | ||||||||||||||||||||||||||||||||||||
11852 | Q_ASSERT(to >= 0); | - | ||||||||||||||||||||||||||||||||||||
11853 | if (from < to)
| 0 | ||||||||||||||||||||||||||||||||||||
11854 | --to; never executed: --to; | 0 | ||||||||||||||||||||||||||||||||||||
11855 | // Do nothing if the widget is already in correct stacking order _and_ created. | - | ||||||||||||||||||||||||||||||||||||
11856 | if (from != to)
| 0 | ||||||||||||||||||||||||||||||||||||
11857 | p->d_func()->children.move(from, to); never executed: p->d_func()->children.move(from, to); | 0 | ||||||||||||||||||||||||||||||||||||
11858 | if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11859 | create(); never executed: create(); | 0 | ||||||||||||||||||||||||||||||||||||
11860 | else if (from == to)
| 0 | ||||||||||||||||||||||||||||||||||||
11861 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11862 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11863 | if (testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11864 | d->stackUnder_sys(w); never executed: d->stackUnder_sys(w); | 0 | ||||||||||||||||||||||||||||||||||||
11865 | - | |||||||||||||||||||||||||||||||||||||
11866 | QEvent e(QEvent::ZOrderChange); | - | ||||||||||||||||||||||||||||||||||||
11867 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
11868 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11869 | - | |||||||||||||||||||||||||||||||||||||
11870 | void QWidgetPrivate::stackUnder_sys(QWidget*) | - | ||||||||||||||||||||||||||||||||||||
11871 | { | - | ||||||||||||||||||||||||||||||||||||
11872 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11873 | if (QWidget *p = q->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11874 | setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
11875 | p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); | - | ||||||||||||||||||||||||||||||||||||
11876 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11877 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11878 | - | |||||||||||||||||||||||||||||||||||||
11879 | /*! | - | ||||||||||||||||||||||||||||||||||||
11880 | \fn bool QWidget::isTopLevel() const | - | ||||||||||||||||||||||||||||||||||||
11881 | \obsolete | - | ||||||||||||||||||||||||||||||||||||
11882 | - | |||||||||||||||||||||||||||||||||||||
11883 | Use isWindow() instead. | - | ||||||||||||||||||||||||||||||||||||
11884 | */ | - | ||||||||||||||||||||||||||||||||||||
11885 | - | |||||||||||||||||||||||||||||||||||||
11886 | /*! | - | ||||||||||||||||||||||||||||||||||||
11887 | \fn bool QWidget::isRightToLeft() const | - | ||||||||||||||||||||||||||||||||||||
11888 | \internal | - | ||||||||||||||||||||||||||||||||||||
11889 | */ | - | ||||||||||||||||||||||||||||||||||||
11890 | - | |||||||||||||||||||||||||||||||||||||
11891 | /*! | - | ||||||||||||||||||||||||||||||||||||
11892 | \fn bool QWidget::isLeftToRight() const | - | ||||||||||||||||||||||||||||||||||||
11893 | \internal | - | ||||||||||||||||||||||||||||||||||||
11894 | */ | - | ||||||||||||||||||||||||||||||||||||
11895 | - | |||||||||||||||||||||||||||||||||||||
11896 | /*! | - | ||||||||||||||||||||||||||||||||||||
11897 | \macro QWIDGETSIZE_MAX | - | ||||||||||||||||||||||||||||||||||||
11898 | \relates QWidget | - | ||||||||||||||||||||||||||||||||||||
11899 | - | |||||||||||||||||||||||||||||||||||||
11900 | Defines the maximum size for a QWidget object. | - | ||||||||||||||||||||||||||||||||||||
11901 | - | |||||||||||||||||||||||||||||||||||||
11902 | The largest allowed size for a widget is QSize(QWIDGETSIZE_MAX, | - | ||||||||||||||||||||||||||||||||||||
11903 | QWIDGETSIZE_MAX), i.e. QSize (16777215,16777215). | - | ||||||||||||||||||||||||||||||||||||
11904 | - | |||||||||||||||||||||||||||||||||||||
11905 | \sa QWidget::setMaximumSize() | - | ||||||||||||||||||||||||||||||||||||
11906 | */ | - | ||||||||||||||||||||||||||||||||||||
11907 | - | |||||||||||||||||||||||||||||||||||||
11908 | /*! | - | ||||||||||||||||||||||||||||||||||||
11909 | \fn QWidget::setupUi(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
11910 | - | |||||||||||||||||||||||||||||||||||||
11911 | Sets up the user interface for the specified \a widget. | - | ||||||||||||||||||||||||||||||||||||
11912 | - | |||||||||||||||||||||||||||||||||||||
11913 | \note This function is available with widgets that derive from user | - | ||||||||||||||||||||||||||||||||||||
11914 | interface descriptions created using \l{uic}. | - | ||||||||||||||||||||||||||||||||||||
11915 | - | |||||||||||||||||||||||||||||||||||||
11916 | \sa {Using a Designer UI File in Your Application} | - | ||||||||||||||||||||||||||||||||||||
11917 | */ | - | ||||||||||||||||||||||||||||||||||||
11918 | - | |||||||||||||||||||||||||||||||||||||
11919 | QRect QWidgetPrivate::frameStrut() const | - | ||||||||||||||||||||||||||||||||||||
11920 | { | - | ||||||||||||||||||||||||||||||||||||
11921 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11922 | if (!q->isWindow() || (q->windowType() == Qt::Desktop) || q->testAttribute(Qt::WA_DontShowOnScreen)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11923 | // x2 = x1 + w - 1, so w/h = 1 | - | ||||||||||||||||||||||||||||||||||||
11924 | return QRect(0, 0, 1, 1); never executed: return QRect(0, 0, 1, 1); | 0 | ||||||||||||||||||||||||||||||||||||
11925 | } | - | ||||||||||||||||||||||||||||||||||||
11926 | - | |||||||||||||||||||||||||||||||||||||
11927 | if (data.fstrut_dirty
| 0 | ||||||||||||||||||||||||||||||||||||
11928 | #ifndef Q_DEAD_CODE_FROM_QT4_WIN | - | ||||||||||||||||||||||||||||||||||||
11929 | // ### Fix properly for 4.3 | - | ||||||||||||||||||||||||||||||||||||
11930 | && q->isVisible()
| 0 | ||||||||||||||||||||||||||||||||||||
11931 | #endif | - | ||||||||||||||||||||||||||||||||||||
11932 | && q->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11933 | const_cast<QWidgetPrivate *>(this)->updateFrameStrut(); never executed: const_cast<QWidgetPrivate *>(this)->updateFrameStrut(); | 0 | ||||||||||||||||||||||||||||||||||||
11934 | - | |||||||||||||||||||||||||||||||||||||
11935 | return maybeTopData() ? maybeTopData()->frameStrut : QRect(); never executed: return maybeTopData() ? maybeTopData()->frameStrut : QRect(); | 0 | ||||||||||||||||||||||||||||||||||||
11936 | } | - | ||||||||||||||||||||||||||||||||||||
11937 | - | |||||||||||||||||||||||||||||||||||||
11938 | void QWidgetPrivate::updateFrameStrut() | - | ||||||||||||||||||||||||||||||||||||
11939 | { | - | ||||||||||||||||||||||||||||||||||||
11940 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11941 | if (q->data->fstrut_dirty) {
| 0 | ||||||||||||||||||||||||||||||||||||
11942 | if (QTLWExtra *te = maybeTopData()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11943 | if (te->window && te->window->handle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11944 | const QMargins margins = te->window->frameMargins(); | - | ||||||||||||||||||||||||||||||||||||
11945 | if (!margins.isNull()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11946 | te->frameStrut.setCoords(margins.left(), margins.top(), margins.right(), margins.bottom()); | - | ||||||||||||||||||||||||||||||||||||
11947 | q->data->fstrut_dirty = false; | - | ||||||||||||||||||||||||||||||||||||
11948 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11949 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11950 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11951 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11952 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11953 | - | |||||||||||||||||||||||||||||||||||||
11954 | #ifdef QT_KEYPAD_NAVIGATION | - | ||||||||||||||||||||||||||||||||||||
11955 | /*! | - | ||||||||||||||||||||||||||||||||||||
11956 | \internal | - | ||||||||||||||||||||||||||||||||||||
11957 | - | |||||||||||||||||||||||||||||||||||||
11958 | Changes the focus from the current focusWidget to a widget in | - | ||||||||||||||||||||||||||||||||||||
11959 | the \a direction. | - | ||||||||||||||||||||||||||||||||||||
11960 | - | |||||||||||||||||||||||||||||||||||||
11961 | Returns \c true, if there was a widget in that direction | - | ||||||||||||||||||||||||||||||||||||
11962 | */ | - | ||||||||||||||||||||||||||||||||||||
11963 | bool QWidgetPrivate::navigateToDirection(Direction direction) | - | ||||||||||||||||||||||||||||||||||||
11964 | { | - | ||||||||||||||||||||||||||||||||||||
11965 | QWidget *targetWidget = widgetInNavigationDirection(direction); | - | ||||||||||||||||||||||||||||||||||||
11966 | if (targetWidget) | - | ||||||||||||||||||||||||||||||||||||
11967 | targetWidget->setFocus(); | - | ||||||||||||||||||||||||||||||||||||
11968 | return (targetWidget != 0); | - | ||||||||||||||||||||||||||||||||||||
11969 | } | - | ||||||||||||||||||||||||||||||||||||
11970 | - | |||||||||||||||||||||||||||||||||||||
11971 | /*! | - | ||||||||||||||||||||||||||||||||||||
11972 | \internal | - | ||||||||||||||||||||||||||||||||||||
11973 | - | |||||||||||||||||||||||||||||||||||||
11974 | Searches for a widget that is positioned in the \a direction, starting | - | ||||||||||||||||||||||||||||||||||||
11975 | from the current focusWidget. | - | ||||||||||||||||||||||||||||||||||||
11976 | - | |||||||||||||||||||||||||||||||||||||
11977 | Returns the pointer to a found widget or 0, if there was no widget in | - | ||||||||||||||||||||||||||||||||||||
11978 | that direction. | - | ||||||||||||||||||||||||||||||||||||
11979 | */ | - | ||||||||||||||||||||||||||||||||||||
11980 | QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction) | - | ||||||||||||||||||||||||||||||||||||
11981 | { | - | ||||||||||||||||||||||||||||||||||||
11982 | const QWidget *sourceWidget = QApplication::focusWidget(); | - | ||||||||||||||||||||||||||||||||||||
11983 | if (!sourceWidget) | - | ||||||||||||||||||||||||||||||||||||
11984 | return 0; | - | ||||||||||||||||||||||||||||||||||||
11985 | const QRect sourceRect = sourceWidget->rect().translated(sourceWidget->mapToGlobal(QPoint())); | - | ||||||||||||||||||||||||||||||||||||
11986 | const int sourceX = | - | ||||||||||||||||||||||||||||||||||||
11987 | (direction == DirectionNorth || direction == DirectionSouth) ? | - | ||||||||||||||||||||||||||||||||||||
11988 | (sourceRect.left() + (sourceRect.right() - sourceRect.left()) / 2) | - | ||||||||||||||||||||||||||||||||||||
11989 | :(direction == DirectionEast ? sourceRect.right() : sourceRect.left()); | - | ||||||||||||||||||||||||||||||||||||
11990 | const int sourceY = | - | ||||||||||||||||||||||||||||||||||||
11991 | (direction == DirectionEast || direction == DirectionWest) ? | - | ||||||||||||||||||||||||||||||||||||
11992 | (sourceRect.top() + (sourceRect.bottom() - sourceRect.top()) / 2) | - | ||||||||||||||||||||||||||||||||||||
11993 | :(direction == DirectionSouth ? sourceRect.bottom() : sourceRect.top()); | - | ||||||||||||||||||||||||||||||||||||
11994 | const QPoint sourcePoint(sourceX, sourceY); | - | ||||||||||||||||||||||||||||||||||||
11995 | const QPoint sourceCenter = sourceRect.center(); | - | ||||||||||||||||||||||||||||||||||||
11996 | const QWidget *sourceWindow = sourceWidget->window(); | - | ||||||||||||||||||||||||||||||||||||
11997 | - | |||||||||||||||||||||||||||||||||||||
11998 | QWidget *targetWidget = 0; | - | ||||||||||||||||||||||||||||||||||||
11999 | int shortestDistance = INT_MAX; | - | ||||||||||||||||||||||||||||||||||||
12000 | - | |||||||||||||||||||||||||||||||||||||
12001 | const auto targetCandidates = QApplication::allWidgets(); | - | ||||||||||||||||||||||||||||||||||||
12002 | for (QWidget *targetCandidate : targetCandidates) { | - | ||||||||||||||||||||||||||||||||||||
12003 | - | |||||||||||||||||||||||||||||||||||||
12004 | const QRect targetCandidateRect = targetCandidate->rect().translated(targetCandidate->mapToGlobal(QPoint())); | - | ||||||||||||||||||||||||||||||||||||
12005 | - | |||||||||||||||||||||||||||||||||||||
12006 | // For focus proxies, the child widget handling the focus can have keypad navigation focus, | - | ||||||||||||||||||||||||||||||||||||
12007 | // but the owner of the proxy cannot. | - | ||||||||||||||||||||||||||||||||||||
12008 | // Additionally, empty widgets should be ignored. | - | ||||||||||||||||||||||||||||||||||||
12009 | if (targetCandidate->focusProxy() || targetCandidateRect.isEmpty()) | - | ||||||||||||||||||||||||||||||||||||
12010 | continue; | - | ||||||||||||||||||||||||||||||||||||
12011 | - | |||||||||||||||||||||||||||||||||||||
12012 | // Only navigate to a target widget that... | - | ||||||||||||||||||||||||||||||||||||
12013 | if ( targetCandidate != sourceWidget | - | ||||||||||||||||||||||||||||||||||||
12014 | // ...takes the focus, | - | ||||||||||||||||||||||||||||||||||||
12015 | && targetCandidate->focusPolicy() & Qt::TabFocus | - | ||||||||||||||||||||||||||||||||||||
12016 | // ...is above if DirectionNorth, | - | ||||||||||||||||||||||||||||||||||||
12017 | && !(direction == DirectionNorth && targetCandidateRect.bottom() > sourceRect.top()) | - | ||||||||||||||||||||||||||||||||||||
12018 | // ...is on the right if DirectionEast, | - | ||||||||||||||||||||||||||||||||||||
12019 | && !(direction == DirectionEast && targetCandidateRect.left() < sourceRect.right()) | - | ||||||||||||||||||||||||||||||||||||
12020 | // ...is below if DirectionSouth, | - | ||||||||||||||||||||||||||||||||||||
12021 | && !(direction == DirectionSouth && targetCandidateRect.top() < sourceRect.bottom()) | - | ||||||||||||||||||||||||||||||||||||
12022 | // ...is on the left if DirectionWest, | - | ||||||||||||||||||||||||||||||||||||
12023 | && !(direction == DirectionWest && targetCandidateRect.right() > sourceRect.left()) | - | ||||||||||||||||||||||||||||||||||||
12024 | // ...is enabled, | - | ||||||||||||||||||||||||||||||||||||
12025 | && targetCandidate->isEnabled() | - | ||||||||||||||||||||||||||||||||||||
12026 | // ...is visible, | - | ||||||||||||||||||||||||||||||||||||
12027 | && targetCandidate->isVisible() | - | ||||||||||||||||||||||||||||||||||||
12028 | // ...is in the same window, | - | ||||||||||||||||||||||||||||||||||||
12029 | && targetCandidate->window() == sourceWindow) { | - | ||||||||||||||||||||||||||||||||||||
12030 | const int targetCandidateDistance = pointToRect(sourcePoint, targetCandidateRect); | - | ||||||||||||||||||||||||||||||||||||
12031 | if (targetCandidateDistance < shortestDistance) { | - | ||||||||||||||||||||||||||||||||||||
12032 | shortestDistance = targetCandidateDistance; | - | ||||||||||||||||||||||||||||||||||||
12033 | targetWidget = targetCandidate; | - | ||||||||||||||||||||||||||||||||||||
12034 | } | - | ||||||||||||||||||||||||||||||||||||
12035 | } | - | ||||||||||||||||||||||||||||||||||||
12036 | } | - | ||||||||||||||||||||||||||||||||||||
12037 | return targetWidget; | - | ||||||||||||||||||||||||||||||||||||
12038 | } | - | ||||||||||||||||||||||||||||||||||||
12039 | - | |||||||||||||||||||||||||||||||||||||
12040 | /*! | - | ||||||||||||||||||||||||||||||||||||
12041 | \internal | - | ||||||||||||||||||||||||||||||||||||
12042 | - | |||||||||||||||||||||||||||||||||||||
12043 | Tells us if it there is currently a reachable widget by keypad navigation in | - | ||||||||||||||||||||||||||||||||||||
12044 | a certain \a orientation. | - | ||||||||||||||||||||||||||||||||||||
12045 | If no navigation is possible, occurring key events in that \a orientation may | - | ||||||||||||||||||||||||||||||||||||
12046 | be used to interact with the value in the focused widget, even though it | - | ||||||||||||||||||||||||||||||||||||
12047 | currently has not the editFocus. | - | ||||||||||||||||||||||||||||||||||||
12048 | - | |||||||||||||||||||||||||||||||||||||
12049 | \sa QWidgetPrivate::widgetInNavigationDirection(), QWidget::hasEditFocus() | - | ||||||||||||||||||||||||||||||||||||
12050 | */ | - | ||||||||||||||||||||||||||||||||||||
12051 | bool QWidgetPrivate::canKeypadNavigate(Qt::Orientation orientation) | - | ||||||||||||||||||||||||||||||||||||
12052 | { | - | ||||||||||||||||||||||||||||||||||||
12053 | return orientation == Qt::Horizontal? | - | ||||||||||||||||||||||||||||||||||||
12054 | (QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionEast) | - | ||||||||||||||||||||||||||||||||||||
12055 | || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionWest)) | - | ||||||||||||||||||||||||||||||||||||
12056 | :(QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionNorth) | - | ||||||||||||||||||||||||||||||||||||
12057 | || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionSouth)); | - | ||||||||||||||||||||||||||||||||||||
12058 | } | - | ||||||||||||||||||||||||||||||||||||
12059 | /*! | - | ||||||||||||||||||||||||||||||||||||
12060 | \internal | - | ||||||||||||||||||||||||||||||||||||
12061 | - | |||||||||||||||||||||||||||||||||||||
12062 | Checks, if the \a widget is inside a QTabWidget. If is is inside | - | ||||||||||||||||||||||||||||||||||||
12063 | one, left/right key events will be used to switch between tabs in keypad | - | ||||||||||||||||||||||||||||||||||||
12064 | navigation. If there is no QTabWidget, the horizontal key events can be used | - | ||||||||||||||||||||||||||||||||||||
12065 | to | - | ||||||||||||||||||||||||||||||||||||
12066 | interact with the value in the focused widget, even though it currently has | - | ||||||||||||||||||||||||||||||||||||
12067 | not the editFocus. | - | ||||||||||||||||||||||||||||||||||||
12068 | - | |||||||||||||||||||||||||||||||||||||
12069 | \sa QWidget::hasEditFocus() | - | ||||||||||||||||||||||||||||||||||||
12070 | */ | - | ||||||||||||||||||||||||||||||||||||
12071 | bool QWidgetPrivate::inTabWidget(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
12072 | { | - | ||||||||||||||||||||||||||||||||||||
12073 | for (QWidget *tabWidget = widget; tabWidget; tabWidget = tabWidget->parentWidget()) | - | ||||||||||||||||||||||||||||||||||||
12074 | if (qobject_cast<const QTabWidget*>(tabWidget)) | - | ||||||||||||||||||||||||||||||||||||
12075 | return true; | - | ||||||||||||||||||||||||||||||||||||
12076 | return false; | - | ||||||||||||||||||||||||||||||||||||
12077 | } | - | ||||||||||||||||||||||||||||||||||||
12078 | #endif | - | ||||||||||||||||||||||||||||||||||||
12079 | - | |||||||||||||||||||||||||||||||||||||
12080 | /*! | - | ||||||||||||||||||||||||||||||||||||
12081 | \since 5.0 | - | ||||||||||||||||||||||||||||||||||||
12082 | \internal | - | ||||||||||||||||||||||||||||||||||||
12083 | - | |||||||||||||||||||||||||||||||||||||
12084 | Sets the backing store to be the \a store specified. | - | ||||||||||||||||||||||||||||||||||||
12085 | The QWidget will take ownership of the \a store. | - | ||||||||||||||||||||||||||||||||||||
12086 | */ | - | ||||||||||||||||||||||||||||||||||||
12087 | void QWidget::setBackingStore(QBackingStore *store) | - | ||||||||||||||||||||||||||||||||||||
12088 | { | - | ||||||||||||||||||||||||||||||||||||
12089 | // ### createWinId() ?? | - | ||||||||||||||||||||||||||||||||||||
12090 | - | |||||||||||||||||||||||||||||||||||||
12091 | if (!isTopLevel())
| 0 | ||||||||||||||||||||||||||||||||||||
12092 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12093 | - | |||||||||||||||||||||||||||||||||||||
12094 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12095 | - | |||||||||||||||||||||||||||||||||||||
12096 | QTLWExtra *topData = d->topData(); | - | ||||||||||||||||||||||||||||||||||||
12097 | if (topData->backingStore == store)
| 0 | ||||||||||||||||||||||||||||||||||||
12098 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12099 | - | |||||||||||||||||||||||||||||||||||||
12100 | QBackingStore *oldStore = topData->backingStore; | - | ||||||||||||||||||||||||||||||||||||
12101 | deleteBackingStore(d); | - | ||||||||||||||||||||||||||||||||||||
12102 | topData->backingStore = store; | - | ||||||||||||||||||||||||||||||||||||
12103 | - | |||||||||||||||||||||||||||||||||||||
12104 | QWidgetBackingStore *bs = d->maybeBackingStore(); | - | ||||||||||||||||||||||||||||||||||||
12105 | if (!bs)
| 0 | ||||||||||||||||||||||||||||||||||||
12106 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12107 | - | |||||||||||||||||||||||||||||||||||||
12108 | if (isTopLevel()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12109 | if (bs->store != oldStore && bs->store != store)
| 0 | ||||||||||||||||||||||||||||||||||||
12110 | delete bs->store; never executed: delete bs->store; | 0 | ||||||||||||||||||||||||||||||||||||
12111 | bs->store = store; | - | ||||||||||||||||||||||||||||||||||||
12112 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12113 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12114 | - | |||||||||||||||||||||||||||||||||||||
12115 | /*! | - | ||||||||||||||||||||||||||||||||||||
12116 | \since 5.0 | - | ||||||||||||||||||||||||||||||||||||
12117 | - | |||||||||||||||||||||||||||||||||||||
12118 | Returns the QBackingStore this widget will be drawn into. | - | ||||||||||||||||||||||||||||||||||||
12119 | */ | - | ||||||||||||||||||||||||||||||||||||
12120 | QBackingStore *QWidget::backingStore() const | - | ||||||||||||||||||||||||||||||||||||
12121 | { | - | ||||||||||||||||||||||||||||||||||||
12122 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
12123 | QTLWExtra *extra = d->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
12124 | if (extra && extra->backingStore)
| 0 | ||||||||||||||||||||||||||||||||||||
12125 | return extra->backingStore; never executed: return extra->backingStore; | 0 | ||||||||||||||||||||||||||||||||||||
12126 | - | |||||||||||||||||||||||||||||||||||||
12127 | QWidgetBackingStore *bs = d->maybeBackingStore(); | - | ||||||||||||||||||||||||||||||||||||
12128 | - | |||||||||||||||||||||||||||||||||||||
12129 | return bs ? bs->store : 0; never executed: return bs ? bs->store : 0; | 0 | ||||||||||||||||||||||||||||||||||||
12130 | } | - | ||||||||||||||||||||||||||||||||||||
12131 | - | |||||||||||||||||||||||||||||||||||||
12132 | void QWidgetPrivate::getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const | - | ||||||||||||||||||||||||||||||||||||
12133 | { | - | ||||||||||||||||||||||||||||||||||||
12134 | if (left)
| 0 | ||||||||||||||||||||||||||||||||||||
12135 | *left = (int)leftLayoutItemMargin; never executed: *left = (int)leftLayoutItemMargin; | 0 | ||||||||||||||||||||||||||||||||||||
12136 | if (top)
| 0 | ||||||||||||||||||||||||||||||||||||
12137 | *top = (int)topLayoutItemMargin; never executed: *top = (int)topLayoutItemMargin; | 0 | ||||||||||||||||||||||||||||||||||||
12138 | if (right)
| 0 | ||||||||||||||||||||||||||||||||||||
12139 | *right = (int)rightLayoutItemMargin; never executed: *right = (int)rightLayoutItemMargin; | 0 | ||||||||||||||||||||||||||||||||||||
12140 | if (bottom)
| 0 | ||||||||||||||||||||||||||||||||||||
12141 | *bottom = (int)bottomLayoutItemMargin; never executed: *bottom = (int)bottomLayoutItemMargin; | 0 | ||||||||||||||||||||||||||||||||||||
12142 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12143 | - | |||||||||||||||||||||||||||||||||||||
12144 | void QWidgetPrivate::setLayoutItemMargins(int left, int top, int right, int bottom) | - | ||||||||||||||||||||||||||||||||||||
12145 | { | - | ||||||||||||||||||||||||||||||||||||
12146 | if (leftLayoutItemMargin == left
| 0 | ||||||||||||||||||||||||||||||||||||
12147 | && topLayoutItemMargin == top
| 0 | ||||||||||||||||||||||||||||||||||||
12148 | && rightLayoutItemMargin == right
| 0 | ||||||||||||||||||||||||||||||||||||
12149 | && bottomLayoutItemMargin == bottom)
| 0 | ||||||||||||||||||||||||||||||||||||
12150 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12151 | - | |||||||||||||||||||||||||||||||||||||
12152 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12153 | leftLayoutItemMargin = (signed char)left; | - | ||||||||||||||||||||||||||||||||||||
12154 | topLayoutItemMargin = (signed char)top; | - | ||||||||||||||||||||||||||||||||||||
12155 | rightLayoutItemMargin = (signed char)right; | - | ||||||||||||||||||||||||||||||||||||
12156 | bottomLayoutItemMargin = (signed char)bottom; | - | ||||||||||||||||||||||||||||||||||||
12157 | q->updateGeometry(); | - | ||||||||||||||||||||||||||||||||||||
12158 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12159 | - | |||||||||||||||||||||||||||||||||||||
12160 | void QWidgetPrivate::setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt) | - | ||||||||||||||||||||||||||||||||||||
12161 | { | - | ||||||||||||||||||||||||||||||||||||
12162 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12163 | QStyleOption myOpt; | - | ||||||||||||||||||||||||||||||||||||
12164 | if (!opt) {
| 0 | ||||||||||||||||||||||||||||||||||||
12165 | myOpt.initFrom(q); | - | ||||||||||||||||||||||||||||||||||||
12166 | myOpt.rect.setRect(0, 0, 32768, 32768); // arbitrary | - | ||||||||||||||||||||||||||||||||||||
12167 | opt = &myOpt; | - | ||||||||||||||||||||||||||||||||||||
12168 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12169 | - | |||||||||||||||||||||||||||||||||||||
12170 | QRect liRect = q->style()->subElementRect(element, opt, q); | - | ||||||||||||||||||||||||||||||||||||
12171 | if (liRect.isValid()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12172 | leftLayoutItemMargin = (signed char)(opt->rect.left() - liRect.left()); | - | ||||||||||||||||||||||||||||||||||||
12173 | topLayoutItemMargin = (signed char)(opt->rect.top() - liRect.top()); | - | ||||||||||||||||||||||||||||||||||||
12174 | rightLayoutItemMargin = (signed char)(liRect.right() - opt->rect.right()); | - | ||||||||||||||||||||||||||||||||||||
12175 | bottomLayoutItemMargin = (signed char)(liRect.bottom() - opt->rect.bottom()); | - | ||||||||||||||||||||||||||||||||||||
12176 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12177 | leftLayoutItemMargin = 0; | - | ||||||||||||||||||||||||||||||||||||
12178 | topLayoutItemMargin = 0; | - | ||||||||||||||||||||||||||||||||||||
12179 | rightLayoutItemMargin = 0; | - | ||||||||||||||||||||||||||||||||||||
12180 | bottomLayoutItemMargin = 0; | - | ||||||||||||||||||||||||||||||||||||
12181 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12182 | } | - | ||||||||||||||||||||||||||||||||||||
12183 | // resets the Qt::WA_QuitOnClose attribute to the default value for transient widgets. | - | ||||||||||||||||||||||||||||||||||||
12184 | void QWidgetPrivate::adjustQuitOnCloseAttribute() | - | ||||||||||||||||||||||||||||||||||||
12185 | { | - | ||||||||||||||||||||||||||||||||||||
12186 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12187 | - | |||||||||||||||||||||||||||||||||||||
12188 | if (!q->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12189 | Qt::WindowType type = q->windowType(); | - | ||||||||||||||||||||||||||||||||||||
12190 | if (type == Qt::Widget || type == Qt::SubWindow)
| 0 | ||||||||||||||||||||||||||||||||||||
12191 | type = Qt::Window; never executed: type = Qt::Window; | 0 | ||||||||||||||||||||||||||||||||||||
12192 | if (type != Qt::Widget && type != Qt::Window && type != Qt::Dialog)
| 0 | ||||||||||||||||||||||||||||||||||||
12193 | q->setAttribute(Qt::WA_QuitOnClose, false); never executed: q->setAttribute(Qt::WA_QuitOnClose, false); | 0 | ||||||||||||||||||||||||||||||||||||
12194 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12195 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12196 | - | |||||||||||||||||||||||||||||||||||||
12197 | QOpenGLContext *QWidgetPrivate::shareContext() const | - | ||||||||||||||||||||||||||||||||||||
12198 | { | - | ||||||||||||||||||||||||||||||||||||
12199 | #ifdef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
12200 | return 0; | - | ||||||||||||||||||||||||||||||||||||
12201 | #else | - | ||||||||||||||||||||||||||||||||||||
12202 | if (Q_UNLIKELY(!extra || !extra->topextra || !extra->topextra->window)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12203 | qWarning("Asking for share context for widget that does not have a window handle"); | - | ||||||||||||||||||||||||||||||||||||
12204 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
12205 | } | - | ||||||||||||||||||||||||||||||||||||
12206 | QWidgetPrivate *that = const_cast<QWidgetPrivate *>(this); | - | ||||||||||||||||||||||||||||||||||||
12207 | if (!extra->topextra->shareContext) {
| 0 | ||||||||||||||||||||||||||||||||||||
12208 | QOpenGLContext *ctx = new QOpenGLContext; | - | ||||||||||||||||||||||||||||||||||||
12209 | ctx->setShareContext(qt_gl_global_share_context()); | - | ||||||||||||||||||||||||||||||||||||
12210 | ctx->setFormat(extra->topextra->window->format()); | - | ||||||||||||||||||||||||||||||||||||
12211 | ctx->setScreen(extra->topextra->window->screen()); | - | ||||||||||||||||||||||||||||||||||||
12212 | ctx->create(); | - | ||||||||||||||||||||||||||||||||||||
12213 | that->extra->topextra->shareContext = ctx; | - | ||||||||||||||||||||||||||||||||||||
12214 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12215 | return that->extra->topextra->shareContext; never executed: return that->extra->topextra->shareContext; | 0 | ||||||||||||||||||||||||||||||||||||
12216 | #endif // QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
12217 | } | - | ||||||||||||||||||||||||||||||||||||
12218 | - | |||||||||||||||||||||||||||||||||||||
12219 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
12220 | void QWidgetPrivate::sendComposeStatus(QWidget *w, bool end) | - | ||||||||||||||||||||||||||||||||||||
12221 | { | - | ||||||||||||||||||||||||||||||||||||
12222 | QWidgetPrivate *wd = QWidgetPrivate::get(w); | - | ||||||||||||||||||||||||||||||||||||
12223 | if (!wd->textureChildSeen)
| 0 | ||||||||||||||||||||||||||||||||||||
12224 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12225 | if (end)
| 0 | ||||||||||||||||||||||||||||||||||||
12226 | wd->endCompose(); never executed: wd->endCompose(); | 0 | ||||||||||||||||||||||||||||||||||||
12227 | else | - | ||||||||||||||||||||||||||||||||||||
12228 | wd->beginCompose(); never executed: wd->beginCompose(); | 0 | ||||||||||||||||||||||||||||||||||||
12229 | for (int i = 0; i < wd->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
12230 | w = qobject_cast<QWidget *>(wd->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
12231 | if (w && !w->isWindow() && !w->isHidden() && QWidgetPrivate::get(w)->textureChildSeen)
| 0 | ||||||||||||||||||||||||||||||||||||
12232 | sendComposeStatus(w, end); never executed: sendComposeStatus(w, end); | 0 | ||||||||||||||||||||||||||||||||||||
12233 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12234 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12235 | #endif // QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
12236 | - | |||||||||||||||||||||||||||||||||||||
12237 | Q_WIDGETS_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
12238 | { | - | ||||||||||||||||||||||||||||||||||||
12239 | return widget->data; never executed: return widget->data; | 0 | ||||||||||||||||||||||||||||||||||||
12240 | } | - | ||||||||||||||||||||||||||||||||||||
12241 | - | |||||||||||||||||||||||||||||||||||||
12242 | Q_WIDGETS_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
12243 | { | - | ||||||||||||||||||||||||||||||||||||
12244 | return widget->d_func(); never executed: return widget->d_func(); | 0 | ||||||||||||||||||||||||||||||||||||
12245 | } | - | ||||||||||||||||||||||||||||||||||||
12246 | - | |||||||||||||||||||||||||||||||||||||
12247 | - | |||||||||||||||||||||||||||||||||||||
12248 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
12249 | /*! | - | ||||||||||||||||||||||||||||||||||||
12250 | \since 4.5 | - | ||||||||||||||||||||||||||||||||||||
12251 | - | |||||||||||||||||||||||||||||||||||||
12252 | Returns the proxy widget for the corresponding embedded widget in a graphics | - | ||||||||||||||||||||||||||||||||||||
12253 | view; otherwise returns 0. | - | ||||||||||||||||||||||||||||||||||||
12254 | - | |||||||||||||||||||||||||||||||||||||
12255 | \sa QGraphicsProxyWidget::createProxyForChildWidget(), | - | ||||||||||||||||||||||||||||||||||||
12256 | QGraphicsScene::addWidget() | - | ||||||||||||||||||||||||||||||||||||
12257 | */ | - | ||||||||||||||||||||||||||||||||||||
12258 | QGraphicsProxyWidget *QWidget::graphicsProxyWidget() const | - | ||||||||||||||||||||||||||||||||||||
12259 | { | - | ||||||||||||||||||||||||||||||||||||
12260 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
12261 | if (d->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
12262 | return d->extra->proxyWidget; never executed: return d->extra->proxyWidget; | 0 | ||||||||||||||||||||||||||||||||||||
12263 | } | - | ||||||||||||||||||||||||||||||||||||
12264 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
12265 | } | - | ||||||||||||||||||||||||||||||||||||
12266 | #endif | - | ||||||||||||||||||||||||||||||||||||
12267 | - | |||||||||||||||||||||||||||||||||||||
12268 | #ifndef QT_NO_GESTURES | - | ||||||||||||||||||||||||||||||||||||
12269 | /*! | - | ||||||||||||||||||||||||||||||||||||
12270 | Subscribes the widget to a given \a gesture with specific \a flags. | - | ||||||||||||||||||||||||||||||||||||
12271 | - | |||||||||||||||||||||||||||||||||||||
12272 | \sa ungrabGesture(), QGestureEvent | - | ||||||||||||||||||||||||||||||||||||
12273 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
12274 | */ | - | ||||||||||||||||||||||||||||||||||||
12275 | void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags) | - | ||||||||||||||||||||||||||||||||||||
12276 | { | - | ||||||||||||||||||||||||||||||||||||
12277 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12278 | d->gestureContext.insert(gesture, flags); | - | ||||||||||||||||||||||||||||||||||||
12279 | (void)QGestureManager::instance(); // create a gesture manager | - | ||||||||||||||||||||||||||||||||||||
12280 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12281 | - | |||||||||||||||||||||||||||||||||||||
12282 | /*! | - | ||||||||||||||||||||||||||||||||||||
12283 | Unsubscribes the widget from a given \a gesture type | - | ||||||||||||||||||||||||||||||||||||
12284 | - | |||||||||||||||||||||||||||||||||||||
12285 | \sa grabGesture(), QGestureEvent | - | ||||||||||||||||||||||||||||||||||||
12286 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
12287 | */ | - | ||||||||||||||||||||||||||||||||||||
12288 | void QWidget::ungrabGesture(Qt::GestureType gesture) | - | ||||||||||||||||||||||||||||||||||||
12289 | { | - | ||||||||||||||||||||||||||||||||||||
12290 | // if you modify this function, check the inlined version in ~QWidget, too | - | ||||||||||||||||||||||||||||||||||||
12291 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12292 | if (d->gestureContext.remove(gesture)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12293 | if (QGestureManager *manager = QGestureManager::instance())
| 0 | ||||||||||||||||||||||||||||||||||||
12294 | manager->cleanupCachedGestures(this, gesture); never executed: manager->cleanupCachedGestures(this, gesture); | 0 | ||||||||||||||||||||||||||||||||||||
12295 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12296 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12297 | #endif // QT_NO_GESTURES | - | ||||||||||||||||||||||||||||||||||||
12298 | - | |||||||||||||||||||||||||||||||||||||
12299 | /*! | - | ||||||||||||||||||||||||||||||||||||
12300 | \fn void QWidget::destroy(bool destroyWindow, bool destroySubWindows) | - | ||||||||||||||||||||||||||||||||||||
12301 | - | |||||||||||||||||||||||||||||||||||||
12302 | Frees up window system resources. Destroys the widget window if \a | - | ||||||||||||||||||||||||||||||||||||
12303 | destroyWindow is true. | - | ||||||||||||||||||||||||||||||||||||
12304 | - | |||||||||||||||||||||||||||||||||||||
12305 | destroy() calls itself recursively for all the child widgets, | - | ||||||||||||||||||||||||||||||||||||
12306 | passing \a destroySubWindows for the \a destroyWindow parameter. | - | ||||||||||||||||||||||||||||||||||||
12307 | To have more control over destruction of subwidgets, destroy | - | ||||||||||||||||||||||||||||||||||||
12308 | subwidgets selectively first. | - | ||||||||||||||||||||||||||||||||||||
12309 | - | |||||||||||||||||||||||||||||||||||||
12310 | This function is usually called from the QWidget destructor. | - | ||||||||||||||||||||||||||||||||||||
12311 | */ | - | ||||||||||||||||||||||||||||||||||||
12312 | void QWidget::destroy(bool destroyWindow, bool destroySubWindows) | - | ||||||||||||||||||||||||||||||||||||
12313 | { | - | ||||||||||||||||||||||||||||||||||||
12314 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12315 | - | |||||||||||||||||||||||||||||||||||||
12316 | d->aboutToDestroy(); | - | ||||||||||||||||||||||||||||||||||||
12317 | if (!isWindow() && parentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
12318 | parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry())); never executed: parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry())); | 0 | ||||||||||||||||||||||||||||||||||||
12319 | d->deactivateWidgetCleanup(); | - | ||||||||||||||||||||||||||||||||||||
12320 | - | |||||||||||||||||||||||||||||||||||||
12321 | if ((windowType() == Qt::Popup) && qApp)
| 0 | ||||||||||||||||||||||||||||||||||||
12322 | qApp->d_func()->closePopup(this); never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->closePopup(this); | 0 | ||||||||||||||||||||||||||||||||||||
12323 | - | |||||||||||||||||||||||||||||||||||||
12324 | if (this == QApplicationPrivate::active_window)
| 0 | ||||||||||||||||||||||||||||||||||||
12325 | QApplication::setActiveWindow(0); never executed: QApplication::setActiveWindow(0); | 0 | ||||||||||||||||||||||||||||||||||||
12326 | if (QWidget::mouseGrabber() == this)
| 0 | ||||||||||||||||||||||||||||||||||||
12327 | releaseMouse(); never executed: releaseMouse(); | 0 | ||||||||||||||||||||||||||||||||||||
12328 | if (QWidget::keyboardGrabber() == this)
| 0 | ||||||||||||||||||||||||||||||||||||
12329 | releaseKeyboard(); never executed: releaseKeyboard(); | 0 | ||||||||||||||||||||||||||||||||||||
12330 | - | |||||||||||||||||||||||||||||||||||||
12331 | setAttribute(Qt::WA_WState_Created, false); | - | ||||||||||||||||||||||||||||||||||||
12332 | - | |||||||||||||||||||||||||||||||||||||
12333 | if (windowType() != Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
12334 | if (destroySubWindows) {
| 0 | ||||||||||||||||||||||||||||||||||||
12335 | QObjectList childList(children()); | - | ||||||||||||||||||||||||||||||||||||
12336 | for (int i = 0; i < childList.size(); i++) {
| 0 | ||||||||||||||||||||||||||||||||||||
12337 | QWidget *widget = qobject_cast<QWidget *>(childList.at(i)); | - | ||||||||||||||||||||||||||||||||||||
12338 | if (widget && widget->testAttribute(Qt::WA_NativeWindow)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12339 | if (widget->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12340 | widget->destroy(); | - | ||||||||||||||||||||||||||||||||||||
12341 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12342 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12343 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12344 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12345 | if (destroyWindow) {
| 0 | ||||||||||||||||||||||||||||||||||||
12346 | d->deleteTLSysExtra(); | - | ||||||||||||||||||||||||||||||||||||
12347 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12348 | if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12349 | d->hide_sys(); | - | ||||||||||||||||||||||||||||||||||||
12350 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12351 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12352 | - | |||||||||||||||||||||||||||||||||||||
12353 | d->setWinId(0); | - | ||||||||||||||||||||||||||||||||||||
12354 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12355 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12356 | - | |||||||||||||||||||||||||||||||||||||
12357 | /*! | - | ||||||||||||||||||||||||||||||||||||
12358 | \fn QPaintEngine *QWidget::paintEngine() const | - | ||||||||||||||||||||||||||||||||||||
12359 | - | |||||||||||||||||||||||||||||||||||||
12360 | Returns the widget's paint engine. | - | ||||||||||||||||||||||||||||||||||||
12361 | - | |||||||||||||||||||||||||||||||||||||
12362 | Note that this function should not be called explicitly by the | - | ||||||||||||||||||||||||||||||||||||
12363 | user, since it's meant for reimplementation purposes only. The | - | ||||||||||||||||||||||||||||||||||||
12364 | function is called by Qt internally, and the default | - | ||||||||||||||||||||||||||||||||||||
12365 | implementation may not always return a valid pointer. | - | ||||||||||||||||||||||||||||||||||||
12366 | */ | - | ||||||||||||||||||||||||||||||||||||
12367 | QPaintEngine *QWidget::paintEngine() const | - | ||||||||||||||||||||||||||||||||||||
12368 | { | - | ||||||||||||||||||||||||||||||||||||
12369 | qWarning("QWidget::paintEngine: Should no longer be called"); | - | ||||||||||||||||||||||||||||||||||||
12370 | - | |||||||||||||||||||||||||||||||||||||
12371 | #ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
12372 | // We set this bit which is checked in setAttribute for | - | ||||||||||||||||||||||||||||||||||||
12373 | // Qt::WA_PaintOnScreen. We do this to allow these two scenarios: | - | ||||||||||||||||||||||||||||||||||||
12374 | // | - | ||||||||||||||||||||||||||||||||||||
12375 | // 1. Users accidentally set Qt::WA_PaintOnScreen on X and port to | - | ||||||||||||||||||||||||||||||||||||
12376 | // Windows which would mean suddenly their widgets stop working. | - | ||||||||||||||||||||||||||||||||||||
12377 | // | - | ||||||||||||||||||||||||||||||||||||
12378 | // 2. Users set paint on screen and subclass paintEngine() to | - | ||||||||||||||||||||||||||||||||||||
12379 | // return 0, in which case we have a "hole" in the backingstore | - | ||||||||||||||||||||||||||||||||||||
12380 | // allowing use of GDI or DirectX directly. | - | ||||||||||||||||||||||||||||||||||||
12381 | // | - | ||||||||||||||||||||||||||||||||||||
12382 | // 1 is WRONG, but to minimize silent failures, we have set this | - | ||||||||||||||||||||||||||||||||||||
12383 | // bit to ignore the setAttribute call. 2. needs to be | - | ||||||||||||||||||||||||||||||||||||
12384 | // supported because its our only means of embedding native | - | ||||||||||||||||||||||||||||||||||||
12385 | // graphics stuff. | - | ||||||||||||||||||||||||||||||||||||
12386 | const_cast<QWidgetPrivate *>(d_func())->noPaintOnScreen = 1; | - | ||||||||||||||||||||||||||||||||||||
12387 | #endif | - | ||||||||||||||||||||||||||||||||||||
12388 | - | |||||||||||||||||||||||||||||||||||||
12389 | return 0; //##### @@@ never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
12390 | } | - | ||||||||||||||||||||||||||||||||||||
12391 | - | |||||||||||||||||||||||||||||||||||||
12392 | // Do not call QWindow::mapToGlobal() until QPlatformWindow is properly showing. | - | ||||||||||||||||||||||||||||||||||||
12393 | static inline bool canMapPosition(QWindow *window) | - | ||||||||||||||||||||||||||||||||||||
12394 | { | - | ||||||||||||||||||||||||||||||||||||
12395 | return window->handle() && !qt_window_private(window)->resizeEventPending; never executed: return window->handle() && !qt_window_private(window)->resizeEventPending; | 0 | ||||||||||||||||||||||||||||||||||||
12396 | } | - | ||||||||||||||||||||||||||||||||||||
12397 | - | |||||||||||||||||||||||||||||||||||||
12398 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
12399 | static inline QGraphicsProxyWidget *graphicsProxyWidget(const QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
12400 | { | - | ||||||||||||||||||||||||||||||||||||
12401 | QGraphicsProxyWidget *result = Q_NULLPTR; | - | ||||||||||||||||||||||||||||||||||||
12402 | const QWidgetPrivate *d = qt_widget_private(const_cast<QWidget *>(w)); | - | ||||||||||||||||||||||||||||||||||||
12403 | if (d->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
12404 | result = d->extra->proxyWidget; never executed: result = d->extra->proxyWidget; | 0 | ||||||||||||||||||||||||||||||||||||
12405 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||||||||||||||
12406 | } | - | ||||||||||||||||||||||||||||||||||||
12407 | #endif // !QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
12408 | - | |||||||||||||||||||||||||||||||||||||
12409 | struct MapToGlobalTransformResult { | - | ||||||||||||||||||||||||||||||||||||
12410 | QTransform transform; | - | ||||||||||||||||||||||||||||||||||||
12411 | QWindow *window; | - | ||||||||||||||||||||||||||||||||||||
12412 | }; | - | ||||||||||||||||||||||||||||||||||||
12413 | - | |||||||||||||||||||||||||||||||||||||
12414 | static MapToGlobalTransformResult mapToGlobalTransform(const QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
12415 | { | - | ||||||||||||||||||||||||||||||||||||
12416 | MapToGlobalTransformResult result; | - | ||||||||||||||||||||||||||||||||||||
12417 | result.window = Q_NULLPTR; | - | ||||||||||||||||||||||||||||||||||||
12418 | for ( ; w ; w = w->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12419 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
12420 | if (QGraphicsProxyWidget *qgpw = graphicsProxyWidget(w)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12421 | if (const QGraphicsScene *scene = qgpw->scene()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12422 | const QList <QGraphicsView *> views = scene->views(); | - | ||||||||||||||||||||||||||||||||||||
12423 | if (!views.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12424 | result.transform *= qgpw->sceneTransform(); | - | ||||||||||||||||||||||||||||||||||||
12425 | result.transform *= views.first()->viewportTransform(); | - | ||||||||||||||||||||||||||||||||||||
12426 | w = views.first()->viewport(); | - | ||||||||||||||||||||||||||||||||||||
12427 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12428 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12429 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12430 | #endif // !QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
12431 | QWindow *window = w->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
12432 | if (window && canMapPosition(window)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12433 | result.window = window; | - | ||||||||||||||||||||||||||||||||||||
12434 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
12435 | } | - | ||||||||||||||||||||||||||||||||||||
12436 | - | |||||||||||||||||||||||||||||||||||||
12437 | const QPoint topLeft = w->geometry().topLeft(); | - | ||||||||||||||||||||||||||||||||||||
12438 | result.transform.translate(topLeft.x(), topLeft.y()); | - | ||||||||||||||||||||||||||||||||||||
12439 | if (w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
12440 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
12441 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12442 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||||||||||||||
12443 | } | - | ||||||||||||||||||||||||||||||||||||
12444 | - | |||||||||||||||||||||||||||||||||||||
12445 | /*! | - | ||||||||||||||||||||||||||||||||||||
12446 | \fn QPoint QWidget::mapToGlobal(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
12447 | - | |||||||||||||||||||||||||||||||||||||
12448 | Translates the widget coordinate \a pos to global screen | - | ||||||||||||||||||||||||||||||||||||
12449 | coordinates. For example, \c{mapToGlobal(QPoint(0,0))} would give | - | ||||||||||||||||||||||||||||||||||||
12450 | the global coordinates of the top-left pixel of the widget. | - | ||||||||||||||||||||||||||||||||||||
12451 | - | |||||||||||||||||||||||||||||||||||||
12452 | \sa mapFromGlobal(), mapTo(), mapToParent() | - | ||||||||||||||||||||||||||||||||||||
12453 | */ | - | ||||||||||||||||||||||||||||||||||||
12454 | QPoint QWidget::mapToGlobal(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
12455 | { | - | ||||||||||||||||||||||||||||||||||||
12456 | const MapToGlobalTransformResult t = mapToGlobalTransform(this); | - | ||||||||||||||||||||||||||||||||||||
12457 | const QPoint g = t.transform.map(pos); | - | ||||||||||||||||||||||||||||||||||||
12458 | return t.window ? t.window->mapToGlobal(g) : g; never executed: return t.window ? t.window->mapToGlobal(g) : g; | 0 | ||||||||||||||||||||||||||||||||||||
12459 | } | - | ||||||||||||||||||||||||||||||||||||
12460 | - | |||||||||||||||||||||||||||||||||||||
12461 | /*! | - | ||||||||||||||||||||||||||||||||||||
12462 | \fn QPoint QWidget::mapFromGlobal(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
12463 | - | |||||||||||||||||||||||||||||||||||||
12464 | Translates the global screen coordinate \a pos to widget | - | ||||||||||||||||||||||||||||||||||||
12465 | coordinates. | - | ||||||||||||||||||||||||||||||||||||
12466 | - | |||||||||||||||||||||||||||||||||||||
12467 | \sa mapToGlobal(), mapFrom(), mapFromParent() | - | ||||||||||||||||||||||||||||||||||||
12468 | */ | - | ||||||||||||||||||||||||||||||||||||
12469 | QPoint QWidget::mapFromGlobal(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
12470 | { | - | ||||||||||||||||||||||||||||||||||||
12471 | const MapToGlobalTransformResult t = mapToGlobalTransform(this); | - | ||||||||||||||||||||||||||||||||||||
12472 | const QPoint windowLocal = t.window ? t.window->mapFromGlobal(pos) : pos;
| 0 | ||||||||||||||||||||||||||||||||||||
12473 | return t.transform.inverted().map(windowLocal); never executed: return t.transform.inverted().map(windowLocal); | 0 | ||||||||||||||||||||||||||||||||||||
12474 | } | - | ||||||||||||||||||||||||||||||||||||
12475 | - | |||||||||||||||||||||||||||||||||||||
12476 | QWidget *qt_pressGrab = 0; | - | ||||||||||||||||||||||||||||||||||||
12477 | QWidget *qt_mouseGrb = 0; | - | ||||||||||||||||||||||||||||||||||||
12478 | static bool mouseGrabWithCursor = false; | - | ||||||||||||||||||||||||||||||||||||
12479 | static QWidget *keyboardGrb = 0; | - | ||||||||||||||||||||||||||||||||||||
12480 | - | |||||||||||||||||||||||||||||||||||||
12481 | static inline QWindow *grabberWindow(const QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
12482 | { | - | ||||||||||||||||||||||||||||||||||||
12483 | QWindow *window = w->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
12484 | if (!window)
| 0 | ||||||||||||||||||||||||||||||||||||
12485 | if (const QWidget *nativeParent = w->nativeParentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
12486 | window = nativeParent->windowHandle(); never executed: window = nativeParent->windowHandle(); | 0 | ||||||||||||||||||||||||||||||||||||
12487 | return window; never executed: return window; | 0 | ||||||||||||||||||||||||||||||||||||
12488 | } | - | ||||||||||||||||||||||||||||||||||||
12489 | - | |||||||||||||||||||||||||||||||||||||
12490 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
12491 | static void grabMouseForWidget(QWidget *widget, const QCursor *cursor = 0) | - | ||||||||||||||||||||||||||||||||||||
12492 | #else | - | ||||||||||||||||||||||||||||||||||||
12493 | static void grabMouseForWidget(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
12494 | #endif | - | ||||||||||||||||||||||||||||||||||||
12495 | { | - | ||||||||||||||||||||||||||||||||||||
12496 | if (qt_mouseGrb)
| 0 | ||||||||||||||||||||||||||||||||||||
12497 | qt_mouseGrb->releaseMouse(); never executed: qt_mouseGrb->releaseMouse(); | 0 | ||||||||||||||||||||||||||||||||||||
12498 | - | |||||||||||||||||||||||||||||||||||||
12499 | mouseGrabWithCursor = false; | - | ||||||||||||||||||||||||||||||||||||
12500 | if (QWindow *window = grabberWindow(widget)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12501 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
12502 | if (cursor) {
| 0 | ||||||||||||||||||||||||||||||||||||
12503 | mouseGrabWithCursor = true; | - | ||||||||||||||||||||||||||||||||||||
12504 | QGuiApplication::setOverrideCursor(*cursor); | - | ||||||||||||||||||||||||||||||||||||
12505 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12506 | #endif // !QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
12507 | window->setMouseGrabEnabled(true); | - | ||||||||||||||||||||||||||||||||||||
12508 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12509 | - | |||||||||||||||||||||||||||||||||||||
12510 | qt_mouseGrb = widget; | - | ||||||||||||||||||||||||||||||||||||
12511 | qt_pressGrab = 0; | - | ||||||||||||||||||||||||||||||||||||
12512 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12513 | - | |||||||||||||||||||||||||||||||||||||
12514 | static void releaseMouseGrabOfWidget(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
12515 | { | - | ||||||||||||||||||||||||||||||||||||
12516 | if (qt_mouseGrb == widget) {
| 0 | ||||||||||||||||||||||||||||||||||||
12517 | if (QWindow *window = grabberWindow(widget)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12518 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
12519 | if (mouseGrabWithCursor) {
| 0 | ||||||||||||||||||||||||||||||||||||
12520 | QGuiApplication::restoreOverrideCursor(); | - | ||||||||||||||||||||||||||||||||||||
12521 | mouseGrabWithCursor = false; | - | ||||||||||||||||||||||||||||||||||||
12522 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12523 | #endif // !QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
12524 | window->setMouseGrabEnabled(false); | - | ||||||||||||||||||||||||||||||||||||
12525 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12526 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12527 | qt_mouseGrb = 0; | - | ||||||||||||||||||||||||||||||||||||
12528 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12529 | - | |||||||||||||||||||||||||||||||||||||
12530 | /*! | - | ||||||||||||||||||||||||||||||||||||
12531 | \fn void QWidget::grabMouse() | - | ||||||||||||||||||||||||||||||||||||
12532 | - | |||||||||||||||||||||||||||||||||||||
12533 | Grabs the mouse input. | - | ||||||||||||||||||||||||||||||||||||
12534 | - | |||||||||||||||||||||||||||||||||||||
12535 | This widget receives all mouse events until releaseMouse() is | - | ||||||||||||||||||||||||||||||||||||
12536 | called; other widgets get no mouse events at all. Keyboard | - | ||||||||||||||||||||||||||||||||||||
12537 | events are not affected. Use grabKeyboard() if you want to grab | - | ||||||||||||||||||||||||||||||||||||
12538 | that. | - | ||||||||||||||||||||||||||||||||||||
12539 | - | |||||||||||||||||||||||||||||||||||||
12540 | \warning Bugs in mouse-grabbing applications very often lock the | - | ||||||||||||||||||||||||||||||||||||
12541 | terminal. Use this function with extreme caution, and consider | - | ||||||||||||||||||||||||||||||||||||
12542 | using the \c -nograb command line option while debugging. | - | ||||||||||||||||||||||||||||||||||||
12543 | - | |||||||||||||||||||||||||||||||||||||
12544 | It is almost never necessary to grab the mouse when using Qt, as | - | ||||||||||||||||||||||||||||||||||||
12545 | Qt grabs and releases it sensibly. In particular, Qt grabs the | - | ||||||||||||||||||||||||||||||||||||
12546 | mouse when a mouse button is pressed and keeps it until the last | - | ||||||||||||||||||||||||||||||||||||
12547 | button is released. | - | ||||||||||||||||||||||||||||||||||||
12548 | - | |||||||||||||||||||||||||||||||||||||
12549 | \note Only visible widgets can grab mouse input. If isVisible() | - | ||||||||||||||||||||||||||||||||||||
12550 | returns \c false for a widget, that widget cannot call grabMouse(). | - | ||||||||||||||||||||||||||||||||||||
12551 | - | |||||||||||||||||||||||||||||||||||||
12552 | \note On Windows, grabMouse() only works when the mouse is inside a window | - | ||||||||||||||||||||||||||||||||||||
12553 | owned by the process. | - | ||||||||||||||||||||||||||||||||||||
12554 | On \macos, grabMouse() only works when the mouse is inside the frame of that widget. | - | ||||||||||||||||||||||||||||||||||||
12555 | - | |||||||||||||||||||||||||||||||||||||
12556 | \sa releaseMouse(), grabKeyboard(), releaseKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12557 | */ | - | ||||||||||||||||||||||||||||||||||||
12558 | void QWidget::grabMouse() | - | ||||||||||||||||||||||||||||||||||||
12559 | { | - | ||||||||||||||||||||||||||||||||||||
12560 | grabMouseForWidget(this); | - | ||||||||||||||||||||||||||||||||||||
12561 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12562 | - | |||||||||||||||||||||||||||||||||||||
12563 | /*! | - | ||||||||||||||||||||||||||||||||||||
12564 | \fn void QWidget::grabMouse(const QCursor &cursor) | - | ||||||||||||||||||||||||||||||||||||
12565 | \overload grabMouse() | - | ||||||||||||||||||||||||||||||||||||
12566 | - | |||||||||||||||||||||||||||||||||||||
12567 | Grabs the mouse input and changes the cursor shape. | - | ||||||||||||||||||||||||||||||||||||
12568 | - | |||||||||||||||||||||||||||||||||||||
12569 | The cursor will assume shape \a cursor (for as long as the mouse | - | ||||||||||||||||||||||||||||||||||||
12570 | focus is grabbed) and this widget will be the only one to receive | - | ||||||||||||||||||||||||||||||||||||
12571 | mouse events until releaseMouse() is called(). | - | ||||||||||||||||||||||||||||||||||||
12572 | - | |||||||||||||||||||||||||||||||||||||
12573 | \warning Grabbing the mouse might lock the terminal. | - | ||||||||||||||||||||||||||||||||||||
12574 | - | |||||||||||||||||||||||||||||||||||||
12575 | \note See the note in QWidget::grabMouse(). | - | ||||||||||||||||||||||||||||||||||||
12576 | - | |||||||||||||||||||||||||||||||||||||
12577 | \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor() | - | ||||||||||||||||||||||||||||||||||||
12578 | */ | - | ||||||||||||||||||||||||||||||||||||
12579 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
12580 | void QWidget::grabMouse(const QCursor &cursor) | - | ||||||||||||||||||||||||||||||||||||
12581 | { | - | ||||||||||||||||||||||||||||||||||||
12582 | grabMouseForWidget(this, &cursor); | - | ||||||||||||||||||||||||||||||||||||
12583 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12584 | #endif | - | ||||||||||||||||||||||||||||||||||||
12585 | - | |||||||||||||||||||||||||||||||||||||
12586 | bool QWidgetPrivate::stealMouseGrab(bool grab) | - | ||||||||||||||||||||||||||||||||||||
12587 | { | - | ||||||||||||||||||||||||||||||||||||
12588 | // This is like a combination of grab/releaseMouse() but with error checking | - | ||||||||||||||||||||||||||||||||||||
12589 | // and it has no effect on the result of mouseGrabber(). | - | ||||||||||||||||||||||||||||||||||||
12590 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12591 | QWindow *window = grabberWindow(q); | - | ||||||||||||||||||||||||||||||||||||
12592 | return window ? window->setMouseGrabEnabled(grab) : false; never executed: return window ? window->setMouseGrabEnabled(grab) : false; | 0 | ||||||||||||||||||||||||||||||||||||
12593 | } | - | ||||||||||||||||||||||||||||||||||||
12594 | - | |||||||||||||||||||||||||||||||||||||
12595 | /*! | - | ||||||||||||||||||||||||||||||||||||
12596 | \fn void QWidget::releaseMouse() | - | ||||||||||||||||||||||||||||||||||||
12597 | - | |||||||||||||||||||||||||||||||||||||
12598 | Releases the mouse grab. | - | ||||||||||||||||||||||||||||||||||||
12599 | - | |||||||||||||||||||||||||||||||||||||
12600 | \sa grabMouse(), grabKeyboard(), releaseKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12601 | */ | - | ||||||||||||||||||||||||||||||||||||
12602 | void QWidget::releaseMouse() | - | ||||||||||||||||||||||||||||||||||||
12603 | { | - | ||||||||||||||||||||||||||||||||||||
12604 | releaseMouseGrabOfWidget(this); | - | ||||||||||||||||||||||||||||||||||||
12605 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12606 | - | |||||||||||||||||||||||||||||||||||||
12607 | /*! | - | ||||||||||||||||||||||||||||||||||||
12608 | \fn void QWidget::grabKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12609 | - | |||||||||||||||||||||||||||||||||||||
12610 | Grabs the keyboard input. | - | ||||||||||||||||||||||||||||||||||||
12611 | - | |||||||||||||||||||||||||||||||||||||
12612 | This widget receives all keyboard events until releaseKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12613 | is called; other widgets get no keyboard events at all. Mouse | - | ||||||||||||||||||||||||||||||||||||
12614 | events are not affected. Use grabMouse() if you want to grab that. | - | ||||||||||||||||||||||||||||||||||||
12615 | - | |||||||||||||||||||||||||||||||||||||
12616 | The focus widget is not affected, except that it doesn't receive | - | ||||||||||||||||||||||||||||||||||||
12617 | any keyboard events. setFocus() moves the focus as usual, but the | - | ||||||||||||||||||||||||||||||||||||
12618 | new focus widget receives keyboard events only after | - | ||||||||||||||||||||||||||||||||||||
12619 | releaseKeyboard() is called. | - | ||||||||||||||||||||||||||||||||||||
12620 | - | |||||||||||||||||||||||||||||||||||||
12621 | If a different widget is currently grabbing keyboard input, that | - | ||||||||||||||||||||||||||||||||||||
12622 | widget's grab is released first. | - | ||||||||||||||||||||||||||||||||||||
12623 | - | |||||||||||||||||||||||||||||||||||||
12624 | \sa releaseKeyboard(), grabMouse(), releaseMouse(), focusWidget() | - | ||||||||||||||||||||||||||||||||||||
12625 | */ | - | ||||||||||||||||||||||||||||||||||||
12626 | void QWidget::grabKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12627 | { | - | ||||||||||||||||||||||||||||||||||||
12628 | if (keyboardGrb)
| 0 | ||||||||||||||||||||||||||||||||||||
12629 | keyboardGrb->releaseKeyboard(); never executed: keyboardGrb->releaseKeyboard(); | 0 | ||||||||||||||||||||||||||||||||||||
12630 | if (QWindow *window = grabberWindow(this))
| 0 | ||||||||||||||||||||||||||||||||||||
12631 | window->setKeyboardGrabEnabled(true); never executed: window->setKeyboardGrabEnabled(true); | 0 | ||||||||||||||||||||||||||||||||||||
12632 | keyboardGrb = this; | - | ||||||||||||||||||||||||||||||||||||
12633 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12634 | - | |||||||||||||||||||||||||||||||||||||
12635 | bool QWidgetPrivate::stealKeyboardGrab(bool grab) | - | ||||||||||||||||||||||||||||||||||||
12636 | { | - | ||||||||||||||||||||||||||||||||||||
12637 | // This is like a combination of grab/releaseKeyboard() but with error | - | ||||||||||||||||||||||||||||||||||||
12638 | // checking and it has no effect on the result of keyboardGrabber(). | - | ||||||||||||||||||||||||||||||||||||
12639 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12640 | QWindow *window = grabberWindow(q); | - | ||||||||||||||||||||||||||||||||||||
12641 | return window ? window->setKeyboardGrabEnabled(grab) : false; never executed: return window ? window->setKeyboardGrabEnabled(grab) : false; | 0 | ||||||||||||||||||||||||||||||||||||
12642 | } | - | ||||||||||||||||||||||||||||||||||||
12643 | - | |||||||||||||||||||||||||||||||||||||
12644 | /*! | - | ||||||||||||||||||||||||||||||||||||
12645 | \fn void QWidget::releaseKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12646 | - | |||||||||||||||||||||||||||||||||||||
12647 | Releases the keyboard grab. | - | ||||||||||||||||||||||||||||||||||||
12648 | - | |||||||||||||||||||||||||||||||||||||
12649 | \sa grabKeyboard(), grabMouse(), releaseMouse() | - | ||||||||||||||||||||||||||||||||||||
12650 | */ | - | ||||||||||||||||||||||||||||||||||||
12651 | void QWidget::releaseKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12652 | { | - | ||||||||||||||||||||||||||||||||||||
12653 | if (keyboardGrb == this) {
| 0 | ||||||||||||||||||||||||||||||||||||
12654 | if (QWindow *window = grabberWindow(this))
| 0 | ||||||||||||||||||||||||||||||||||||
12655 | window->setKeyboardGrabEnabled(false); never executed: window->setKeyboardGrabEnabled(false); | 0 | ||||||||||||||||||||||||||||||||||||
12656 | keyboardGrb = 0; | - | ||||||||||||||||||||||||||||||||||||
12657 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12658 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12659 | - | |||||||||||||||||||||||||||||||||||||
12660 | /*! | - | ||||||||||||||||||||||||||||||||||||
12661 | \fn QWidget *QWidget::mouseGrabber() | - | ||||||||||||||||||||||||||||||||||||
12662 | - | |||||||||||||||||||||||||||||||||||||
12663 | Returns the widget that is currently grabbing the mouse input. | - | ||||||||||||||||||||||||||||||||||||
12664 | - | |||||||||||||||||||||||||||||||||||||
12665 | If no widget in this application is currently grabbing the mouse, | - | ||||||||||||||||||||||||||||||||||||
12666 | 0 is returned. | - | ||||||||||||||||||||||||||||||||||||
12667 | - | |||||||||||||||||||||||||||||||||||||
12668 | \sa grabMouse(), keyboardGrabber() | - | ||||||||||||||||||||||||||||||||||||
12669 | */ | - | ||||||||||||||||||||||||||||||||||||
12670 | QWidget *QWidget::mouseGrabber() | - | ||||||||||||||||||||||||||||||||||||
12671 | { | - | ||||||||||||||||||||||||||||||||||||
12672 | if (qt_mouseGrb)
| 0 | ||||||||||||||||||||||||||||||||||||
12673 | return qt_mouseGrb; never executed: return qt_mouseGrb; | 0 | ||||||||||||||||||||||||||||||||||||
12674 | return qt_pressGrab; never executed: return qt_pressGrab; | 0 | ||||||||||||||||||||||||||||||||||||
12675 | } | - | ||||||||||||||||||||||||||||||||||||
12676 | - | |||||||||||||||||||||||||||||||||||||
12677 | /*! | - | ||||||||||||||||||||||||||||||||||||
12678 | \fn QWidget *QWidget::keyboardGrabber() | - | ||||||||||||||||||||||||||||||||||||
12679 | - | |||||||||||||||||||||||||||||||||||||
12680 | Returns the widget that is currently grabbing the keyboard input. | - | ||||||||||||||||||||||||||||||||||||
12681 | - | |||||||||||||||||||||||||||||||||||||
12682 | If no widget in this application is currently grabbing the | - | ||||||||||||||||||||||||||||||||||||
12683 | keyboard, 0 is returned. | - | ||||||||||||||||||||||||||||||||||||
12684 | - | |||||||||||||||||||||||||||||||||||||
12685 | \sa grabMouse(), mouseGrabber() | - | ||||||||||||||||||||||||||||||||||||
12686 | */ | - | ||||||||||||||||||||||||||||||||||||
12687 | QWidget *QWidget::keyboardGrabber() | - | ||||||||||||||||||||||||||||||||||||
12688 | { | - | ||||||||||||||||||||||||||||||||||||
12689 | return keyboardGrb; never executed: return keyboardGrb; | 0 | ||||||||||||||||||||||||||||||||||||
12690 | } | - | ||||||||||||||||||||||||||||||||||||
12691 | - | |||||||||||||||||||||||||||||||||||||
12692 | /*! | - | ||||||||||||||||||||||||||||||||||||
12693 | \fn void QWidget::activateWindow() | - | ||||||||||||||||||||||||||||||||||||
12694 | - | |||||||||||||||||||||||||||||||||||||
12695 | Sets the top-level widget containing this widget to be the active | - | ||||||||||||||||||||||||||||||||||||
12696 | window. | - | ||||||||||||||||||||||||||||||||||||
12697 | - | |||||||||||||||||||||||||||||||||||||
12698 | An active window is a visible top-level window that has the | - | ||||||||||||||||||||||||||||||||||||
12699 | keyboard input focus. | - | ||||||||||||||||||||||||||||||||||||
12700 | - | |||||||||||||||||||||||||||||||||||||
12701 | This function performs the same operation as clicking the mouse on | - | ||||||||||||||||||||||||||||||||||||
12702 | the title bar of a top-level window. On X11, the result depends on | - | ||||||||||||||||||||||||||||||||||||
12703 | the Window Manager. If you want to ensure that the window is | - | ||||||||||||||||||||||||||||||||||||
12704 | stacked on top as well you should also call raise(). Note that the | - | ||||||||||||||||||||||||||||||||||||
12705 | window must be visible, otherwise activateWindow() has no effect. | - | ||||||||||||||||||||||||||||||||||||
12706 | - | |||||||||||||||||||||||||||||||||||||
12707 | On Windows, if you are calling this when the application is not | - | ||||||||||||||||||||||||||||||||||||
12708 | currently the active one then it will not make it the active | - | ||||||||||||||||||||||||||||||||||||
12709 | window. It will change the color of the taskbar entry to indicate | - | ||||||||||||||||||||||||||||||||||||
12710 | that the window has changed in some way. This is because Microsoft | - | ||||||||||||||||||||||||||||||||||||
12711 | does not allow an application to interrupt what the user is currently | - | ||||||||||||||||||||||||||||||||||||
12712 | doing in another application. | - | ||||||||||||||||||||||||||||||||||||
12713 | - | |||||||||||||||||||||||||||||||||||||
12714 | \sa isActiveWindow(), window(), show(), QWindowsWindowFunctions::setWindowActivationBehavior() | - | ||||||||||||||||||||||||||||||||||||
12715 | */ | - | ||||||||||||||||||||||||||||||||||||
12716 | void QWidget::activateWindow() | - | ||||||||||||||||||||||||||||||||||||
12717 | { | - | ||||||||||||||||||||||||||||||||||||
12718 | QWindow *const wnd = window()->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
12719 | - | |||||||||||||||||||||||||||||||||||||
12720 | if (wnd)
| 0 | ||||||||||||||||||||||||||||||||||||
12721 | wnd->requestActivate(); never executed: wnd->requestActivate(); | 0 | ||||||||||||||||||||||||||||||||||||
12722 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12723 | - | |||||||||||||||||||||||||||||||||||||
12724 | /*! | - | ||||||||||||||||||||||||||||||||||||
12725 | \fn int QWidget::metric(PaintDeviceMetric m) const | - | ||||||||||||||||||||||||||||||||||||
12726 | - | |||||||||||||||||||||||||||||||||||||
12727 | Internal implementation of the virtual QPaintDevice::metric() | - | ||||||||||||||||||||||||||||||||||||
12728 | function. | - | ||||||||||||||||||||||||||||||||||||
12729 | - | |||||||||||||||||||||||||||||||||||||
12730 | \a m is the metric to get. | - | ||||||||||||||||||||||||||||||||||||
12731 | */ | - | ||||||||||||||||||||||||||||||||||||
12732 | int QWidget::metric(PaintDeviceMetric m) const | - | ||||||||||||||||||||||||||||||||||||
12733 | { | - | ||||||||||||||||||||||||||||||||||||
12734 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
12735 | - | |||||||||||||||||||||||||||||||||||||
12736 | QWindow *topLevelWindow = 0; | - | ||||||||||||||||||||||||||||||||||||
12737 | QScreen *screen = 0; | - | ||||||||||||||||||||||||||||||||||||
12738 | if (QWidget *topLevel = window()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12739 | topLevelWindow = topLevel->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
12740 | if (topLevelWindow)
| 0 | ||||||||||||||||||||||||||||||||||||
12741 | screen = topLevelWindow->screen(); never executed: screen = topLevelWindow->screen(); | 0 | ||||||||||||||||||||||||||||||||||||
12742 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12743 | if (!screen && QGuiApplication::primaryScreen())
| 0 | ||||||||||||||||||||||||||||||||||||
12744 | screen = QGuiApplication::primaryScreen(); never executed: screen = QGuiApplication::primaryScreen(); | 0 | ||||||||||||||||||||||||||||||||||||
12745 | - | |||||||||||||||||||||||||||||||||||||
12746 | if (!screen) {
| 0 | ||||||||||||||||||||||||||||||||||||
12747 | if (m == PdmDpiX || m == PdmDpiY)
| 0 | ||||||||||||||||||||||||||||||||||||
12748 | return 72; never executed: return 72; | 0 | ||||||||||||||||||||||||||||||||||||
12749 | return QPaintDevice::metric(m); never executed: return QPaintDevice::metric(m); | 0 | ||||||||||||||||||||||||||||||||||||
12750 | } | - | ||||||||||||||||||||||||||||||||||||
12751 | int val; | - | ||||||||||||||||||||||||||||||||||||
12752 | if (m == PdmWidth) {
| 0 | ||||||||||||||||||||||||||||||||||||
12753 | val = data->crect.width(); | - | ||||||||||||||||||||||||||||||||||||
12754 | } else if (m == PdmWidthMM) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
12755 | val = data->crect.width() * screen->physicalSize().width() / screen->geometry().width(); | - | ||||||||||||||||||||||||||||||||||||
12756 | } else if (m == PdmHeight) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
12757 | val = data->crect.height(); | - | ||||||||||||||||||||||||||||||||||||
12758 | } else if (m == PdmHeightMM) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
12759 | val = data->crect.height() * screen->physicalSize().height() / screen->geometry().height(); | - | ||||||||||||||||||||||||||||||||||||
12760 | } else if (m == PdmDepth) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
12761 | return screen->depth(); never executed: return screen->depth(); | 0 | ||||||||||||||||||||||||||||||||||||
12762 | } else if (m == PdmDpiX) {
| 0 | ||||||||||||||||||||||||||||||||||||
12763 | if (d->extra && d->extra->customDpiX)
| 0 | ||||||||||||||||||||||||||||||||||||
12764 | return d->extra->customDpiX; never executed: return d->extra->customDpiX; | 0 | ||||||||||||||||||||||||||||||||||||
12765 | else if (d->parent)
| 0 | ||||||||||||||||||||||||||||||||||||
12766 | return static_cast<QWidget *>(d->parent)->metric(m); never executed: return static_cast<QWidget *>(d->parent)->metric(m); | 0 | ||||||||||||||||||||||||||||||||||||
12767 | return qRound(screen->logicalDotsPerInchX()); never executed: return qRound(screen->logicalDotsPerInchX()); | 0 | ||||||||||||||||||||||||||||||||||||
12768 | } else if (m == PdmDpiY) {
| 0 | ||||||||||||||||||||||||||||||||||||
12769 | if (d->extra && d->extra->customDpiY)
| 0 | ||||||||||||||||||||||||||||||||||||
12770 | return d->extra->customDpiY; never executed: return d->extra->customDpiY; | 0 | ||||||||||||||||||||||||||||||||||||
12771 | else if (d->parent)
| 0 | ||||||||||||||||||||||||||||||||||||
12772 | return static_cast<QWidget *>(d->parent)->metric(m); never executed: return static_cast<QWidget *>(d->parent)->metric(m); | 0 | ||||||||||||||||||||||||||||||||||||
12773 | return qRound(screen->logicalDotsPerInchY()); never executed: return qRound(screen->logicalDotsPerInchY()); | 0 | ||||||||||||||||||||||||||||||||||||
12774 | } else if (m == PdmPhysicalDpiX) {
| 0 | ||||||||||||||||||||||||||||||||||||
12775 | return qRound(screen->physicalDotsPerInchX()); never executed: return qRound(screen->physicalDotsPerInchX()); | 0 | ||||||||||||||||||||||||||||||||||||
12776 | } else if (m == PdmPhysicalDpiY) {
| 0 | ||||||||||||||||||||||||||||||||||||
12777 | return qRound(screen->physicalDotsPerInchY()); never executed: return qRound(screen->physicalDotsPerInchY()); | 0 | ||||||||||||||||||||||||||||||||||||
12778 | } else if (m == PdmDevicePixelRatio) {
| 0 | ||||||||||||||||||||||||||||||||||||
12779 | return topLevelWindow ? topLevelWindow->devicePixelRatio() : qApp->devicePixelRatio(); never executed: return topLevelWindow ? topLevelWindow->devicePixelRatio() : (static_cast<QApplication *>(QCoreApplication::instance()))->devicePixelRatio(); | 0 | ||||||||||||||||||||||||||||||||||||
12780 | } else if (m == PdmDevicePixelRatioScaled) {
| 0 | ||||||||||||||||||||||||||||||||||||
12781 | return (QPaintDevice::devicePixelRatioFScale() * never executed: return (QPaintDevice::devicePixelRatioFScale() * (topLevelWindow ? topLevelWindow->devicePixelRatio() : (static_cast<QApplication *>(QCoreApplication::instance()))->devicePixelRatio())); | 0 | ||||||||||||||||||||||||||||||||||||
12782 | (topLevelWindow ? topLevelWindow->devicePixelRatio() : qApp->devicePixelRatio())); never executed: return (QPaintDevice::devicePixelRatioFScale() * (topLevelWindow ? topLevelWindow->devicePixelRatio() : (static_cast<QApplication *>(QCoreApplication::instance()))->devicePixelRatio())); | 0 | ||||||||||||||||||||||||||||||||||||
12783 | } else { | - | ||||||||||||||||||||||||||||||||||||
12784 | val = QPaintDevice::metric(m);// XXX | - | ||||||||||||||||||||||||||||||||||||
12785 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12786 | return val; never executed: return val; | 0 | ||||||||||||||||||||||||||||||||||||
12787 | } | - | ||||||||||||||||||||||||||||||||||||
12788 | - | |||||||||||||||||||||||||||||||||||||
12789 | /*! | - | ||||||||||||||||||||||||||||||||||||
12790 | Initializes the \a painter pen, background and font to the same as | - | ||||||||||||||||||||||||||||||||||||
12791 | the given widget's. This function is called automatically when the | - | ||||||||||||||||||||||||||||||||||||
12792 | painter is opened on a QWidget. | - | ||||||||||||||||||||||||||||||||||||
12793 | */ | - | ||||||||||||||||||||||||||||||||||||
12794 | void QWidget::initPainter(QPainter *painter) const | - | ||||||||||||||||||||||||||||||||||||
12795 | { | - | ||||||||||||||||||||||||||||||||||||
12796 | const QPalette &pal = palette(); | - | ||||||||||||||||||||||||||||||||||||
12797 | painter->d_func()->state->pen = QPen(pal.brush(foregroundRole()), 1); | - | ||||||||||||||||||||||||||||||||||||
12798 | painter->d_func()->state->bgBrush = pal.brush(backgroundRole()); | - | ||||||||||||||||||||||||||||||||||||
12799 | QFont f(font(), const_cast<QWidget *>(this)); | - | ||||||||||||||||||||||||||||||||||||
12800 | painter->d_func()->state->deviceFont = f; | - | ||||||||||||||||||||||||||||||||||||
12801 | painter->d_func()->state->font = f; | - | ||||||||||||||||||||||||||||||||||||
12802 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12803 | - | |||||||||||||||||||||||||||||||||||||
12804 | /*! | - | ||||||||||||||||||||||||||||||||||||
12805 | \internal | - | ||||||||||||||||||||||||||||||||||||
12806 | - | |||||||||||||||||||||||||||||||||||||
12807 | Do PaintDevice rendering with the specified \a offset. | - | ||||||||||||||||||||||||||||||||||||
12808 | */ | - | ||||||||||||||||||||||||||||||||||||
12809 | QPaintDevice *QWidget::redirected(QPoint *offset) const | - | ||||||||||||||||||||||||||||||||||||
12810 | { | - | ||||||||||||||||||||||||||||||||||||
12811 | return d_func()->redirected(offset); never executed: return d_func()->redirected(offset); | 0 | ||||||||||||||||||||||||||||||||||||
12812 | } | - | ||||||||||||||||||||||||||||||||||||
12813 | - | |||||||||||||||||||||||||||||||||||||
12814 | /*! | - | ||||||||||||||||||||||||||||||||||||
12815 | \internal | - | ||||||||||||||||||||||||||||||||||||
12816 | - | |||||||||||||||||||||||||||||||||||||
12817 | A painter that is shared among other instances of QPainter. | - | ||||||||||||||||||||||||||||||||||||
12818 | */ | - | ||||||||||||||||||||||||||||||||||||
12819 | QPainter *QWidget::sharedPainter() const | - | ||||||||||||||||||||||||||||||||||||
12820 | { | - | ||||||||||||||||||||||||||||||||||||
12821 | // Someone sent a paint event directly to the widget | - | ||||||||||||||||||||||||||||||||||||
12822 | if (!d_func()->redirectDev)
| 0 | ||||||||||||||||||||||||||||||||||||
12823 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
12824 | - | |||||||||||||||||||||||||||||||||||||
12825 | QPainter *sp = d_func()->sharedPainter(); | - | ||||||||||||||||||||||||||||||||||||
12826 | if (!sp || !sp->isActive())
| 0 | ||||||||||||||||||||||||||||||||||||
12827 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
12828 | - | |||||||||||||||||||||||||||||||||||||
12829 | if (sp->paintEngine()->paintDevice() != d_func()->redirectDev)
| 0 | ||||||||||||||||||||||||||||||||||||
12830 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
12831 | - | |||||||||||||||||||||||||||||||||||||
12832 | return sp; never executed: return sp; | 0 | ||||||||||||||||||||||||||||||||||||
12833 | } | - | ||||||||||||||||||||||||||||||||||||
12834 | - | |||||||||||||||||||||||||||||||||||||
12835 | /*! | - | ||||||||||||||||||||||||||||||||||||
12836 | \fn void QWidget::setMask(const QRegion ®ion) | - | ||||||||||||||||||||||||||||||||||||
12837 | \overload | - | ||||||||||||||||||||||||||||||||||||
12838 | - | |||||||||||||||||||||||||||||||||||||
12839 | Causes only the parts of the widget which overlap \a region to be | - | ||||||||||||||||||||||||||||||||||||
12840 | visible. If the region includes pixels outside the rect() of the | - | ||||||||||||||||||||||||||||||||||||
12841 | widget, window system controls in that area may or may not be | - | ||||||||||||||||||||||||||||||||||||
12842 | visible, depending on the platform. | - | ||||||||||||||||||||||||||||||||||||
12843 | - | |||||||||||||||||||||||||||||||||||||
12844 | Note that this effect can be slow if the region is particularly | - | ||||||||||||||||||||||||||||||||||||
12845 | complex. | - | ||||||||||||||||||||||||||||||||||||
12846 | - | |||||||||||||||||||||||||||||||||||||
12847 | \sa windowOpacity | - | ||||||||||||||||||||||||||||||||||||
12848 | */ | - | ||||||||||||||||||||||||||||||||||||
12849 | void QWidget::setMask(const QRegion &newMask) | - | ||||||||||||||||||||||||||||||||||||
12850 | { | - | ||||||||||||||||||||||||||||||||||||
12851 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12852 | - | |||||||||||||||||||||||||||||||||||||
12853 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
12854 | if (newMask == d->extra->mask)
| 0 | ||||||||||||||||||||||||||||||||||||
12855 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12856 | - | |||||||||||||||||||||||||||||||||||||
12857 | #ifndef QT_NO_BACKINGSTORE | - | ||||||||||||||||||||||||||||||||||||
12858 | const QRegion oldMask(d->extra->mask); | - | ||||||||||||||||||||||||||||||||||||
12859 | #endif | - | ||||||||||||||||||||||||||||||||||||
12860 | - | |||||||||||||||||||||||||||||||||||||
12861 | d->extra->mask = newMask; | - | ||||||||||||||||||||||||||||||||||||
12862 | d->extra->hasMask = !newMask.isEmpty(); | - | ||||||||||||||||||||||||||||||||||||
12863 | - | |||||||||||||||||||||||||||||||||||||
12864 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
12865 | if (!testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
12866 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12867 | #endif | - | ||||||||||||||||||||||||||||||||||||
12868 | - | |||||||||||||||||||||||||||||||||||||
12869 | d->setMask_sys(newMask); | - | ||||||||||||||||||||||||||||||||||||
12870 | - | |||||||||||||||||||||||||||||||||||||
12871 | #ifndef QT_NO_BACKINGSTORE | - | ||||||||||||||||||||||||||||||||||||
12872 | if (!isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
12873 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12874 | - | |||||||||||||||||||||||||||||||||||||
12875 | if (!d->extra->hasMask) {
| 0 | ||||||||||||||||||||||||||||||||||||
12876 | // Mask was cleared; update newly exposed area. | - | ||||||||||||||||||||||||||||||||||||
12877 | QRegion expose(rect()); | - | ||||||||||||||||||||||||||||||||||||
12878 | expose -= oldMask; | - | ||||||||||||||||||||||||||||||||||||
12879 | if (!expose.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12880 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
12881 | update(expose); | - | ||||||||||||||||||||||||||||||||||||
12882 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12883 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12884 | } | - | ||||||||||||||||||||||||||||||||||||
12885 | - | |||||||||||||||||||||||||||||||||||||
12886 | if (!isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12887 | // Update newly exposed area on the parent widget. | - | ||||||||||||||||||||||||||||||||||||
12888 | QRegion parentExpose(rect()); | - | ||||||||||||||||||||||||||||||||||||
12889 | parentExpose -= newMask; | - | ||||||||||||||||||||||||||||||||||||
12890 | if (!parentExpose.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12891 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
12892 | parentExpose.translate(data->crect.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
12893 | parentWidget()->update(parentExpose); | - | ||||||||||||||||||||||||||||||||||||
12894 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12895 | - | |||||||||||||||||||||||||||||||||||||
12896 | // Update newly exposed area on this widget | - | ||||||||||||||||||||||||||||||||||||
12897 | if (!oldMask.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
12898 | update(newMask - oldMask); never executed: update(newMask - oldMask); | 0 | ||||||||||||||||||||||||||||||||||||
12899 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12900 | #endif | - | ||||||||||||||||||||||||||||||||||||
12901 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12902 | - | |||||||||||||||||||||||||||||||||||||
12903 | void QWidgetPrivate::setMask_sys(const QRegion ®ion) | - | ||||||||||||||||||||||||||||||||||||
12904 | { | - | ||||||||||||||||||||||||||||||||||||
12905 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12906 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
12907 | window->setMask(region); never executed: window->setMask(region); | 0 | ||||||||||||||||||||||||||||||||||||
12908 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12909 | - | |||||||||||||||||||||||||||||||||||||
12910 | /*! | - | ||||||||||||||||||||||||||||||||||||
12911 | \fn void QWidget::setMask(const QBitmap &bitmap) | - | ||||||||||||||||||||||||||||||||||||
12912 | - | |||||||||||||||||||||||||||||||||||||
12913 | Causes only the pixels of the widget for which \a bitmap has a | - | ||||||||||||||||||||||||||||||||||||
12914 | corresponding 1 bit to be visible. If the region includes pixels | - | ||||||||||||||||||||||||||||||||||||
12915 | outside the rect() of the widget, window system controls in that | - | ||||||||||||||||||||||||||||||||||||
12916 | area may or may not be visible, depending on the platform. | - | ||||||||||||||||||||||||||||||||||||
12917 | - | |||||||||||||||||||||||||||||||||||||
12918 | Note that this effect can be slow if the region is particularly | - | ||||||||||||||||||||||||||||||||||||
12919 | complex. | - | ||||||||||||||||||||||||||||||||||||
12920 | - | |||||||||||||||||||||||||||||||||||||
12921 | The following code shows how an image with an alpha channel can be | - | ||||||||||||||||||||||||||||||||||||
12922 | used to generate a mask for a widget: | - | ||||||||||||||||||||||||||||||||||||
12923 | - | |||||||||||||||||||||||||||||||||||||
12924 | \snippet widget-mask/main.cpp 0 | - | ||||||||||||||||||||||||||||||||||||
12925 | - | |||||||||||||||||||||||||||||||||||||
12926 | The label shown by this code is masked using the image it contains, | - | ||||||||||||||||||||||||||||||||||||
12927 | giving the appearance that an irregularly-shaped image is being drawn | - | ||||||||||||||||||||||||||||||||||||
12928 | directly onto the screen. | - | ||||||||||||||||||||||||||||||||||||
12929 | - | |||||||||||||||||||||||||||||||||||||
12930 | Masked widgets receive mouse events only on their visible | - | ||||||||||||||||||||||||||||||||||||
12931 | portions. | - | ||||||||||||||||||||||||||||||||||||
12932 | - | |||||||||||||||||||||||||||||||||||||
12933 | \sa clearMask(), windowOpacity(), {Shaped Clock Example} | - | ||||||||||||||||||||||||||||||||||||
12934 | */ | - | ||||||||||||||||||||||||||||||||||||
12935 | void QWidget::setMask(const QBitmap &bitmap) | - | ||||||||||||||||||||||||||||||||||||
12936 | { | - | ||||||||||||||||||||||||||||||||||||
12937 | setMask(QRegion(bitmap)); | - | ||||||||||||||||||||||||||||||||||||
12938 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12939 | - | |||||||||||||||||||||||||||||||||||||
12940 | /*! | - | ||||||||||||||||||||||||||||||||||||
12941 | \fn void QWidget::clearMask() | - | ||||||||||||||||||||||||||||||||||||
12942 | - | |||||||||||||||||||||||||||||||||||||
12943 | Removes any mask set by setMask(). | - | ||||||||||||||||||||||||||||||||||||
12944 | - | |||||||||||||||||||||||||||||||||||||
12945 | \sa setMask() | - | ||||||||||||||||||||||||||||||||||||
12946 | */ | - | ||||||||||||||||||||||||||||||||||||
12947 | void QWidget::clearMask() | - | ||||||||||||||||||||||||||||||||||||
12948 | { | - | ||||||||||||||||||||||||||||||||||||
12949 | setMask(QRegion()); | - | ||||||||||||||||||||||||||||||||||||
12950 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12951 | - | |||||||||||||||||||||||||||||||||||||
12952 | void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *newParent) | - | ||||||||||||||||||||||||||||||||||||
12953 | { | - | ||||||||||||||||||||||||||||||||||||
12954 | Q_ASSERT(widgetAsObject->isWidgetType()); | - | ||||||||||||||||||||||||||||||||||||
12955 | Q_ASSERT(!newParent || newParent->isWidgetType()); | - | ||||||||||||||||||||||||||||||||||||
12956 | QWidget *widget = static_cast<QWidget*>(widgetAsObject); | - | ||||||||||||||||||||||||||||||||||||
12957 | widget->setParent(static_cast<QWidget*>(newParent)); | - | ||||||||||||||||||||||||||||||||||||
12958 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12959 | - | |||||||||||||||||||||||||||||||||||||
12960 | void QWidgetPrivate::setNetWmWindowTypes(bool skipIfMissing) | - | ||||||||||||||||||||||||||||||||||||
12961 | { | - | ||||||||||||||||||||||||||||||||||||
12962 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12963 | - | |||||||||||||||||||||||||||||||||||||
12964 | if (!q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
12965 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12966 | - | |||||||||||||||||||||||||||||||||||||
12967 | int wmWindowType = 0; | - | ||||||||||||||||||||||||||||||||||||
12968 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDesktop))
| 0 | ||||||||||||||||||||||||||||||||||||
12969 | wmWindowType |= QXcbWindowFunctions::Desktop; never executed: wmWindowType |= QXcbWindowFunctions::Desktop; | 0 | ||||||||||||||||||||||||||||||||||||
12970 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDock))
| 0 | ||||||||||||||||||||||||||||||||||||
12971 | wmWindowType |= QXcbWindowFunctions::Dock; never executed: wmWindowType |= QXcbWindowFunctions::Dock; | 0 | ||||||||||||||||||||||||||||||||||||
12972 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolBar))
| 0 | ||||||||||||||||||||||||||||||||||||
12973 | wmWindowType |= QXcbWindowFunctions::Toolbar; never executed: wmWindowType |= QXcbWindowFunctions::Toolbar; | 0 | ||||||||||||||||||||||||||||||||||||
12974 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeMenu))
| 0 | ||||||||||||||||||||||||||||||||||||
12975 | wmWindowType |= QXcbWindowFunctions::Menu; never executed: wmWindowType |= QXcbWindowFunctions::Menu; | 0 | ||||||||||||||||||||||||||||||||||||
12976 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeUtility))
| 0 | ||||||||||||||||||||||||||||||||||||
12977 | wmWindowType |= QXcbWindowFunctions::Utility; never executed: wmWindowType |= QXcbWindowFunctions::Utility; | 0 | ||||||||||||||||||||||||||||||||||||
12978 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeSplash))
| 0 | ||||||||||||||||||||||||||||||||||||
12979 | wmWindowType |= QXcbWindowFunctions::Splash; never executed: wmWindowType |= QXcbWindowFunctions::Splash; | 0 | ||||||||||||||||||||||||||||||||||||
12980 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDialog))
| 0 | ||||||||||||||||||||||||||||||||||||
12981 | wmWindowType |= QXcbWindowFunctions::Dialog; never executed: wmWindowType |= QXcbWindowFunctions::Dialog; | 0 | ||||||||||||||||||||||||||||||||||||
12982 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu))
| 0 | ||||||||||||||||||||||||||||||||||||
12983 | wmWindowType |= QXcbWindowFunctions::DropDownMenu; never executed: wmWindowType |= QXcbWindowFunctions::DropDownMenu; | 0 | ||||||||||||||||||||||||||||||||||||
12984 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypePopupMenu))
| 0 | ||||||||||||||||||||||||||||||||||||
12985 | wmWindowType |= QXcbWindowFunctions::PopupMenu; never executed: wmWindowType |= QXcbWindowFunctions::PopupMenu; | 0 | ||||||||||||||||||||||||||||||||||||
12986 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolTip))
| 0 | ||||||||||||||||||||||||||||||||||||
12987 | wmWindowType |= QXcbWindowFunctions::Tooltip; never executed: wmWindowType |= QXcbWindowFunctions::Tooltip; | 0 | ||||||||||||||||||||||||||||||||||||
12988 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeNotification))
| 0 | ||||||||||||||||||||||||||||||||||||
12989 | wmWindowType |= QXcbWindowFunctions::Notification; never executed: wmWindowType |= QXcbWindowFunctions::Notification; | 0 | ||||||||||||||||||||||||||||||||||||
12990 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeCombo))
| 0 | ||||||||||||||||||||||||||||||||||||
12991 | wmWindowType |= QXcbWindowFunctions::Combo; never executed: wmWindowType |= QXcbWindowFunctions::Combo; | 0 | ||||||||||||||||||||||||||||||||||||
12992 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDND))
| 0 | ||||||||||||||||||||||||||||||||||||
12993 | wmWindowType |= QXcbWindowFunctions::Dnd; never executed: wmWindowType |= QXcbWindowFunctions::Dnd; | 0 | ||||||||||||||||||||||||||||||||||||
12994 | - | |||||||||||||||||||||||||||||||||||||
12995 | if (wmWindowType == 0 && skipIfMissing)
| 0 | ||||||||||||||||||||||||||||||||||||
12996 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12997 | - | |||||||||||||||||||||||||||||||||||||
12998 | QXcbWindowFunctions::setWmWindowType(q->windowHandle(), static_cast<QXcbWindowFunctions::WmWindowType>(wmWindowType)); | - | ||||||||||||||||||||||||||||||||||||
12999 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
13000 | - | |||||||||||||||||||||||||||||||||||||
13001 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||||||||||||||
13002 | - | |||||||||||||||||||||||||||||||||||||
13003 | static inline void formatWidgetAttributes(QDebug debug, const QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
13004 | { | - | ||||||||||||||||||||||||||||||||||||
13005 | const QMetaObject *qtMo = qt_getEnumMetaObject(Qt::WA_AttributeCount); | - | ||||||||||||||||||||||||||||||||||||
13006 | const QMetaEnum me = qtMo->enumerator(qtMo->indexOfEnumerator("WidgetAttribute")); | - | ||||||||||||||||||||||||||||||||||||
13007 | debug << ", attributes=["; | - | ||||||||||||||||||||||||||||||||||||
13008 | int count = 0; | - | ||||||||||||||||||||||||||||||||||||
13009 | for (int a = 0; a < Qt::WA_AttributeCount; ++a) {
| 0 | ||||||||||||||||||||||||||||||||||||
13010 | if (widget->testAttribute(static_cast<Qt::WidgetAttribute>(a))) {
| 0 | ||||||||||||||||||||||||||||||||||||
13011 | if (count++)
| 0 | ||||||||||||||||||||||||||||||||||||
13012 | debug << ','; never executed: debug << ','; | 0 | ||||||||||||||||||||||||||||||||||||
13013 | debug << me.valueToKey(a); | - | ||||||||||||||||||||||||||||||||||||
13014 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
13015 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
13016 | debug << ']'; | - | ||||||||||||||||||||||||||||||||||||
13017 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
13018 | - | |||||||||||||||||||||||||||||||||||||
13019 | QDebug operator<<(QDebug debug, const QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
13020 | { | - | ||||||||||||||||||||||||||||||||||||
13021 | const QDebugStateSaver saver(debug); | - | ||||||||||||||||||||||||||||||||||||
13022 | debug.nospace(); | - | ||||||||||||||||||||||||||||||||||||
13023 | if (widget) {
| 0 | ||||||||||||||||||||||||||||||||||||
13024 | debug << widget->metaObject()->className() << '(' << (const void *)widget; | - | ||||||||||||||||||||||||||||||||||||
13025 | if (!widget->objectName().isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
13026 | debug << ", name=" << widget->objectName(); never executed: debug << ", name=" << widget->objectName(); | 0 | ||||||||||||||||||||||||||||||||||||
13027 | if (debug.verbosity() > 2) {
| 0 | ||||||||||||||||||||||||||||||||||||
13028 | const QRect geometry = widget->geometry(); | - | ||||||||||||||||||||||||||||||||||||
13029 | const QRect frameGeometry = widget->frameGeometry(); | - | ||||||||||||||||||||||||||||||||||||
13030 | if (widget->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
13031 | debug << ", visible"; never executed: debug << ", visible"; | 0 | ||||||||||||||||||||||||||||||||||||
13032 | if (!widget->isEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
13033 | debug << ", disabled"; never executed: debug << ", disabled"; | 0 | ||||||||||||||||||||||||||||||||||||
13034 | debug << ", states=" << widget->windowState() | - | ||||||||||||||||||||||||||||||||||||
13035 | << ", type=" << widget->windowType() << ", flags=" << widget->windowFlags(); | - | ||||||||||||||||||||||||||||||||||||
13036 | formatWidgetAttributes(debug, widget); | - | ||||||||||||||||||||||||||||||||||||
13037 | if (widget->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
13038 | debug << ", window"; never executed: debug << ", window"; | 0 | ||||||||||||||||||||||||||||||||||||
13039 | debug << ", " << geometry.width() << 'x' << geometry.height() | - | ||||||||||||||||||||||||||||||||||||
13040 | << forcesign << geometry.x() << geometry.y() << noforcesign; | - | ||||||||||||||||||||||||||||||||||||
13041 | if (frameGeometry != geometry) {
| 0 | ||||||||||||||||||||||||||||||||||||
13042 | const QMargins margins(geometry.x() - frameGeometry.x(), | - | ||||||||||||||||||||||||||||||||||||
13043 | geometry.y() - frameGeometry.y(), | - | ||||||||||||||||||||||||||||||||||||
13044 | frameGeometry.right() - geometry.right(), | - | ||||||||||||||||||||||||||||||||||||
13045 | frameGeometry.bottom() - geometry.bottom()); | - | ||||||||||||||||||||||||||||||||||||
13046 | debug << ", margins=" << margins; | - | ||||||||||||||||||||||||||||||||||||
13047 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
13048 | debug << ", devicePixelRatio=" << widget->devicePixelRatioF(); | - | ||||||||||||||||||||||||||||||||||||
13049 | if (const WId wid = widget->internalWinId())
| 0 | ||||||||||||||||||||||||||||||||||||
13050 | debug << ", winId=0x" << hex << wid << dec; never executed: debug << ", winId=0x" << hex << wid << dec; | 0 | ||||||||||||||||||||||||||||||||||||
13051 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
13052 | debug << ')'; | - | ||||||||||||||||||||||||||||||||||||
13053 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
13054 | debug << "QWidget(0x0)"; | - | ||||||||||||||||||||||||||||||||||||
13055 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
13056 | return debug; never executed: return debug; | 0 | ||||||||||||||||||||||||||||||||||||
13057 | } | - | ||||||||||||||||||||||||||||||||||||
13058 | #endif // !QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||||||||||||||
13059 | - | |||||||||||||||||||||||||||||||||||||
13060 | /*! \fn Qt::HANDLE QWidget::macCGHandle() const | - | ||||||||||||||||||||||||||||||||||||
13061 | \internal | - | ||||||||||||||||||||||||||||||||||||
13062 | - | |||||||||||||||||||||||||||||||||||||
13063 | Returns the CoreGraphics handle of the widget. Use of this function is not portable. | - | ||||||||||||||||||||||||||||||||||||
13064 | This function will return 0 if no painter context can be established, or if the handle | - | ||||||||||||||||||||||||||||||||||||
13065 | could not be created. | - | ||||||||||||||||||||||||||||||||||||
13066 | - | |||||||||||||||||||||||||||||||||||||
13067 | \warning This function is only available on \macos. | - | ||||||||||||||||||||||||||||||||||||
13068 | */ | - | ||||||||||||||||||||||||||||||||||||
13069 | /*! \fn Qt::HANDLE QWidget::macQDHandle() const | - | ||||||||||||||||||||||||||||||||||||
13070 | \internal | - | ||||||||||||||||||||||||||||||||||||
13071 | - | |||||||||||||||||||||||||||||||||||||
13072 | Returns the QuickDraw handle of the widget. Use of this function is not portable. | - | ||||||||||||||||||||||||||||||||||||
13073 | This function will return 0 if QuickDraw is not supported, or if the handle could | - | ||||||||||||||||||||||||||||||||||||
13074 | not be created. | - | ||||||||||||||||||||||||||||||||||||
13075 | - | |||||||||||||||||||||||||||||||||||||
13076 | \warning This function is only available on \macos. | - | ||||||||||||||||||||||||||||||||||||
13077 | */ | - | ||||||||||||||||||||||||||||||||||||
13078 | /*! \fn const QX11Info &QWidget::x11Info() const | - | ||||||||||||||||||||||||||||||||||||
13079 | \internal | - | ||||||||||||||||||||||||||||||||||||
13080 | - | |||||||||||||||||||||||||||||||||||||
13081 | Returns information about the configuration of the X display used to display | - | ||||||||||||||||||||||||||||||||||||
13082 | the widget. | - | ||||||||||||||||||||||||||||||||||||
13083 | - | |||||||||||||||||||||||||||||||||||||
13084 | \warning This function is only available on X11. | - | ||||||||||||||||||||||||||||||||||||
13085 | */ | - | ||||||||||||||||||||||||||||||||||||
13086 | - | |||||||||||||||||||||||||||||||||||||
13087 | /*! \fn Qt::HANDLE QWidget::x11PictureHandle() const | - | ||||||||||||||||||||||||||||||||||||
13088 | \internal | - | ||||||||||||||||||||||||||||||||||||
13089 | - | |||||||||||||||||||||||||||||||||||||
13090 | Returns the X11 picture handle of the widget for XRender | - | ||||||||||||||||||||||||||||||||||||
13091 | support. Use of this function is not portable. This function will | - | ||||||||||||||||||||||||||||||||||||
13092 | return 0 if XRender support is not compiled into Qt, if the | - | ||||||||||||||||||||||||||||||||||||
13093 | XRender extension is not supported on the X11 display, or if the | - | ||||||||||||||||||||||||||||||||||||
13094 | handle could not be created. | - | ||||||||||||||||||||||||||||||||||||
13095 | - | |||||||||||||||||||||||||||||||||||||
13096 | \warning This function is only available on X11. | - | ||||||||||||||||||||||||||||||||||||
13097 | - | |||||||||||||||||||||||||||||||||||||
13098 | */ | - | ||||||||||||||||||||||||||||||||||||
13099 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||||||||||||||
13100 | - | |||||||||||||||||||||||||||||||||||||
13101 | #include "moc_qwidget.cpp" | - | ||||||||||||||||||||||||||||||||||||
13102 | - | |||||||||||||||||||||||||||||||||||||
Source code | Switch to Preprocessed file |