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) 2015 The Qt Company Ltd. | - | ||||||||||||||||||||||||||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||||||||||||||
6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||||||||||||||||||||||||||
7 | ** | - | ||||||||||||||||||||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||||||||||||||||||||
16 | ** | - | ||||||||||||||||||||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||||||||||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||||||||||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||||||||||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||||||||||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||||||||||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||||||||||||||||||||
25 | ** | - | ||||||||||||||||||||||||||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||||||||||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||||||||||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||||||||||||||||||||
29 | ** | - | ||||||||||||||||||||||||||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||||||||||||||
31 | ** | - | ||||||||||||||||||||||||||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||||||||||||||
34 | #include "qapplication.h" | - | ||||||||||||||||||||||||||||||||||||
35 | #include "qapplication_p.h" | - | ||||||||||||||||||||||||||||||||||||
36 | #include "qbrush.h" | - | ||||||||||||||||||||||||||||||||||||
37 | #include "qcursor.h" | - | ||||||||||||||||||||||||||||||||||||
38 | #include "qdesktopwidget_p.h" | - | ||||||||||||||||||||||||||||||||||||
39 | #include "qevent.h" | - | ||||||||||||||||||||||||||||||||||||
40 | #include "qlayout.h" | - | ||||||||||||||||||||||||||||||||||||
41 | #include "qmenu.h" | - | ||||||||||||||||||||||||||||||||||||
42 | #include "qmetaobject.h" | - | ||||||||||||||||||||||||||||||||||||
43 | #include "qpixmap.h" | - | ||||||||||||||||||||||||||||||||||||
44 | #include "qpointer.h" | - | ||||||||||||||||||||||||||||||||||||
45 | #include "qstack.h" | - | ||||||||||||||||||||||||||||||||||||
46 | #include "qstyle.h" | - | ||||||||||||||||||||||||||||||||||||
47 | #include "qstylefactory.h" | - | ||||||||||||||||||||||||||||||||||||
48 | #include "qvariant.h" | - | ||||||||||||||||||||||||||||||||||||
49 | #include "qwidget.h" | - | ||||||||||||||||||||||||||||||||||||
50 | #include "qstyleoption.h" | - | ||||||||||||||||||||||||||||||||||||
51 | #include "qstylehints.h" | - | ||||||||||||||||||||||||||||||||||||
52 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
53 | # include "qaccessible.h" | - | ||||||||||||||||||||||||||||||||||||
54 | #endif | - | ||||||||||||||||||||||||||||||||||||
55 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
56 | # include "qt_mac_p.h" | - | ||||||||||||||||||||||||||||||||||||
57 | # include "qt_cocoa_helpers_mac_p.h" | - | ||||||||||||||||||||||||||||||||||||
58 | # include "qmainwindow.h" | - | ||||||||||||||||||||||||||||||||||||
59 | # include "qtoolbar.h" | - | ||||||||||||||||||||||||||||||||||||
60 | # include <private/qmainwindowlayout_p.h> | - | ||||||||||||||||||||||||||||||||||||
61 | #endif | - | ||||||||||||||||||||||||||||||||||||
62 | #include <qpa/qplatformwindow.h> | - | ||||||||||||||||||||||||||||||||||||
63 | #include <qpa/qplatformbackingstore.h> | - | ||||||||||||||||||||||||||||||||||||
64 | #include "private/qwidgetwindow_p.h" | - | ||||||||||||||||||||||||||||||||||||
65 | #include "qpainter.h" | - | ||||||||||||||||||||||||||||||||||||
66 | #include "qtooltip.h" | - | ||||||||||||||||||||||||||||||||||||
67 | #include "qwhatsthis.h" | - | ||||||||||||||||||||||||||||||||||||
68 | #include "qdebug.h" | - | ||||||||||||||||||||||||||||||||||||
69 | #include "private/qstylesheetstyle_p.h" | - | ||||||||||||||||||||||||||||||||||||
70 | #include "private/qstyle_p.h" | - | ||||||||||||||||||||||||||||||||||||
71 | #include "qfileinfo.h" | - | ||||||||||||||||||||||||||||||||||||
72 | #include <QtGui/private/qhighdpiscaling_p.h> | - | ||||||||||||||||||||||||||||||||||||
73 | #include <QtGui/qinputmethod.h> | - | ||||||||||||||||||||||||||||||||||||
74 | #include <QtGui/qopenglcontext.h> | - | ||||||||||||||||||||||||||||||||||||
75 | #include <QtGui/private/qopenglcontext_p.h> | - | ||||||||||||||||||||||||||||||||||||
76 | #include <QtGui/qoffscreensurface.h> | - | ||||||||||||||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||||||||||||||
78 | #include <private/qgraphicseffect_p.h> | - | ||||||||||||||||||||||||||||||||||||
79 | #include <qbackingstore.h> | - | ||||||||||||||||||||||||||||||||||||
80 | #include <private/qwidgetbackingstore_p.h> | - | ||||||||||||||||||||||||||||||||||||
81 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
82 | # include <private/qpaintengine_mac_p.h> | - | ||||||||||||||||||||||||||||||||||||
83 | #endif | - | ||||||||||||||||||||||||||||||||||||
84 | #include <private/qpaintengine_raster_p.h> | - | ||||||||||||||||||||||||||||||||||||
85 | - | |||||||||||||||||||||||||||||||||||||
86 | #include "qwidget_p.h" | - | ||||||||||||||||||||||||||||||||||||
87 | #include <QtGui/private/qwindow_p.h> | - | ||||||||||||||||||||||||||||||||||||
88 | #include "qaction_p.h" | - | ||||||||||||||||||||||||||||||||||||
89 | #include "qlayout_p.h" | - | ||||||||||||||||||||||||||||||||||||
90 | #include "QtWidgets/qgraphicsproxywidget.h" | - | ||||||||||||||||||||||||||||||||||||
91 | #include "QtWidgets/qgraphicsscene.h" | - | ||||||||||||||||||||||||||||||||||||
92 | #include "private/qgraphicsproxywidget_p.h" | - | ||||||||||||||||||||||||||||||||||||
93 | #include "QtWidgets/qabstractscrollarea.h" | - | ||||||||||||||||||||||||||||||||||||
94 | #include "private/qabstractscrollarea_p.h" | - | ||||||||||||||||||||||||||||||||||||
95 | #include "private/qevent_p.h" | - | ||||||||||||||||||||||||||||||||||||
96 | - | |||||||||||||||||||||||||||||||||||||
97 | #include "private/qgesturemanager_p.h" | - | ||||||||||||||||||||||||||||||||||||
98 | - | |||||||||||||||||||||||||||||||||||||
99 | #ifdef QT_KEYPAD_NAVIGATION | - | ||||||||||||||||||||||||||||||||||||
100 | #include "qtabwidget.h" // Needed in inTabWidget() | - | ||||||||||||||||||||||||||||||||||||
101 | #endif // QT_KEYPAD_NAVIGATION | - | ||||||||||||||||||||||||||||||||||||
102 | - | |||||||||||||||||||||||||||||||||||||
103 | #include "qwindowcontainer_p.h" | - | ||||||||||||||||||||||||||||||||||||
104 | - | |||||||||||||||||||||||||||||||||||||
105 | #include <QtPlatformHeaders/qxcbwindowfunctions.h> | - | ||||||||||||||||||||||||||||||||||||
106 | - | |||||||||||||||||||||||||||||||||||||
107 | // widget/widget data creation count | - | ||||||||||||||||||||||||||||||||||||
108 | //#define QWIDGET_EXTRA_DEBUG | - | ||||||||||||||||||||||||||||||||||||
109 | //#define ALIEN_DEBUG | - | ||||||||||||||||||||||||||||||||||||
110 | - | |||||||||||||||||||||||||||||||||||||
111 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||||||||||||||
112 | - | |||||||||||||||||||||||||||||||||||||
113 | static bool qt_enable_backingstore = true; | - | ||||||||||||||||||||||||||||||||||||
114 | #ifdef Q_DEAD_CODE_FROM_QT4_X11 | - | ||||||||||||||||||||||||||||||||||||
115 | // for compatibility with Qt 4.0 | - | ||||||||||||||||||||||||||||||||||||
116 | Q_WIDGETS_EXPORT void qt_x11_set_global_double_buffer(bool enable) | - | ||||||||||||||||||||||||||||||||||||
117 | { | - | ||||||||||||||||||||||||||||||||||||
118 | qt_enable_backingstore = enable; | - | ||||||||||||||||||||||||||||||||||||
119 | } | - | ||||||||||||||||||||||||||||||||||||
120 | #endif | - | ||||||||||||||||||||||||||||||||||||
121 | - | |||||||||||||||||||||||||||||||||||||
122 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
123 | bool qt_mac_clearDirtyOnWidgetInsideDrawWidget = false; | - | ||||||||||||||||||||||||||||||||||||
124 | #endif | - | ||||||||||||||||||||||||||||||||||||
125 | - | |||||||||||||||||||||||||||||||||||||
126 | static inline bool qRectIntersects(const QRect &r1, const QRect &r2) | - | ||||||||||||||||||||||||||||||||||||
127 | { | - | ||||||||||||||||||||||||||||||||||||
128 | 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 | ||||||||||||||||||||||||||||||||||||
129 | 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 | ||||||||||||||||||||||||||||||||||||
130 | } | - | ||||||||||||||||||||||||||||||||||||
131 | - | |||||||||||||||||||||||||||||||||||||
132 | static inline bool hasBackingStoreSupport() | - | ||||||||||||||||||||||||||||||||||||
133 | { | - | ||||||||||||||||||||||||||||||||||||
134 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
135 | } | - | ||||||||||||||||||||||||||||||||||||
136 | - | |||||||||||||||||||||||||||||||||||||
137 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
138 | # define QT_NO_PAINT_DEBUG | - | ||||||||||||||||||||||||||||||||||||
139 | #endif | - | ||||||||||||||||||||||||||||||||||||
140 | - | |||||||||||||||||||||||||||||||||||||
141 | extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp | - | ||||||||||||||||||||||||||||||||||||
142 | extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp | - | ||||||||||||||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||||||||||||||
144 | /*! | - | ||||||||||||||||||||||||||||||||||||
145 | \internal | - | ||||||||||||||||||||||||||||||||||||
146 | \class QWidgetBackingStoreTracker | - | ||||||||||||||||||||||||||||||||||||
147 | \brief Class which allows tracking of which widgets are using a given backing store | - | ||||||||||||||||||||||||||||||||||||
148 | - | |||||||||||||||||||||||||||||||||||||
149 | QWidgetBackingStoreTracker is a thin wrapper around a QWidgetBackingStore pointer, | - | ||||||||||||||||||||||||||||||||||||
150 | which maintains a list of the QWidgets which are currently using the backing | - | ||||||||||||||||||||||||||||||||||||
151 | store. This list is modified via the registerWidget and unregisterWidget functions. | - | ||||||||||||||||||||||||||||||||||||
152 | */ | - | ||||||||||||||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||||||||||||||
154 | QWidgetBackingStoreTracker::QWidgetBackingStoreTracker() | - | ||||||||||||||||||||||||||||||||||||
155 | : m_ptr(0) | - | ||||||||||||||||||||||||||||||||||||
156 | { | - | ||||||||||||||||||||||||||||||||||||
157 | - | |||||||||||||||||||||||||||||||||||||
158 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||||||||||||||
160 | QWidgetBackingStoreTracker::~QWidgetBackingStoreTracker() | - | ||||||||||||||||||||||||||||||||||||
161 | { | - | ||||||||||||||||||||||||||||||||||||
162 | delete m_ptr; | - | ||||||||||||||||||||||||||||||||||||
163 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
164 | - | |||||||||||||||||||||||||||||||||||||
165 | /*! | - | ||||||||||||||||||||||||||||||||||||
166 | \internal | - | ||||||||||||||||||||||||||||||||||||
167 | Destroy the contained QWidgetBackingStore, if not null, and clear the list of | - | ||||||||||||||||||||||||||||||||||||
168 | widgets using the backing store, then create a new QWidgetBackingStore, providing | - | ||||||||||||||||||||||||||||||||||||
169 | the QWidget. | - | ||||||||||||||||||||||||||||||||||||
170 | */ | - | ||||||||||||||||||||||||||||||||||||
171 | void QWidgetBackingStoreTracker::create(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
172 | { | - | ||||||||||||||||||||||||||||||||||||
173 | destroy(); | - | ||||||||||||||||||||||||||||||||||||
174 | m_ptr = new QWidgetBackingStore(widget); | - | ||||||||||||||||||||||||||||||||||||
175 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
176 | - | |||||||||||||||||||||||||||||||||||||
177 | /*! | - | ||||||||||||||||||||||||||||||||||||
178 | \internal | - | ||||||||||||||||||||||||||||||||||||
179 | Destroy the contained QWidgetBackingStore, if not null, and clear the list of | - | ||||||||||||||||||||||||||||||||||||
180 | widgets using the backing store. | - | ||||||||||||||||||||||||||||||||||||
181 | */ | - | ||||||||||||||||||||||||||||||||||||
182 | void QWidgetBackingStoreTracker::destroy() | - | ||||||||||||||||||||||||||||||||||||
183 | { | - | ||||||||||||||||||||||||||||||||||||
184 | delete m_ptr; | - | ||||||||||||||||||||||||||||||||||||
185 | m_ptr = 0; | - | ||||||||||||||||||||||||||||||||||||
186 | m_widgets.clear(); | - | ||||||||||||||||||||||||||||||||||||
187 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||||||||||||||
189 | /*! | - | ||||||||||||||||||||||||||||||||||||
190 | \internal | - | ||||||||||||||||||||||||||||||||||||
191 | Add the widget to the list of widgets currently using the backing store. | - | ||||||||||||||||||||||||||||||||||||
192 | If the widget was already in the list, this function is a no-op. | - | ||||||||||||||||||||||||||||||||||||
193 | */ | - | ||||||||||||||||||||||||||||||||||||
194 | void QWidgetBackingStoreTracker::registerWidget(QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
195 | { | - | ||||||||||||||||||||||||||||||||||||
196 | Q_ASSERT(m_ptr); | - | ||||||||||||||||||||||||||||||||||||
197 | Q_ASSERT(w->internalWinId()); | - | ||||||||||||||||||||||||||||||||||||
198 | Q_ASSERT(qt_widget_private(w)->maybeBackingStore() == m_ptr); | - | ||||||||||||||||||||||||||||||||||||
199 | m_widgets.insert(w); | - | ||||||||||||||||||||||||||||||||||||
200 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
201 | - | |||||||||||||||||||||||||||||||||||||
202 | /*! | - | ||||||||||||||||||||||||||||||||||||
203 | \internal | - | ||||||||||||||||||||||||||||||||||||
204 | Remove the widget from the list of widgets currently using the backing store. | - | ||||||||||||||||||||||||||||||||||||
205 | If the widget was in the list, and removing it causes the list to be empty, | - | ||||||||||||||||||||||||||||||||||||
206 | the backing store is deleted. | - | ||||||||||||||||||||||||||||||||||||
207 | If the widget was not in the list, this function is a no-op. | - | ||||||||||||||||||||||||||||||||||||
208 | */ | - | ||||||||||||||||||||||||||||||||||||
209 | void QWidgetBackingStoreTracker::unregisterWidget(QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
210 | { | - | ||||||||||||||||||||||||||||||||||||
211 | if (m_widgets.remove(w) && m_widgets.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
212 | delete m_ptr; | - | ||||||||||||||||||||||||||||||||||||
213 | m_ptr = 0; | - | ||||||||||||||||||||||||||||||||||||
214 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
215 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
216 | - | |||||||||||||||||||||||||||||||||||||
217 | /*! | - | ||||||||||||||||||||||||||||||||||||
218 | \internal | - | ||||||||||||||||||||||||||||||||||||
219 | Recursively remove widget and all of its descendents. | - | ||||||||||||||||||||||||||||||||||||
220 | */ | - | ||||||||||||||||||||||||||||||||||||
221 | void QWidgetBackingStoreTracker::unregisterWidgetSubtree(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
222 | { | - | ||||||||||||||||||||||||||||||||||||
223 | unregisterWidget(widget); | - | ||||||||||||||||||||||||||||||||||||
224 | foreach (QObject *child, widget->children()) | - | ||||||||||||||||||||||||||||||||||||
225 | if (QWidget *childWidget = qobject_cast<QWidget *>(child))
| 0 | ||||||||||||||||||||||||||||||||||||
226 | unregisterWidgetSubtree(childWidget); never executed: unregisterWidgetSubtree(childWidget); | 0 | ||||||||||||||||||||||||||||||||||||
227 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
228 | - | |||||||||||||||||||||||||||||||||||||
229 | QWidgetPrivate::QWidgetPrivate(int version) | - | ||||||||||||||||||||||||||||||||||||
230 | : QObjectPrivate(version) | - | ||||||||||||||||||||||||||||||||||||
231 | , extra(0) | - | ||||||||||||||||||||||||||||||||||||
232 | , focus_next(0) | - | ||||||||||||||||||||||||||||||||||||
233 | , focus_prev(0) | - | ||||||||||||||||||||||||||||||||||||
234 | , focus_child(0) | - | ||||||||||||||||||||||||||||||||||||
235 | , layout(0) | - | ||||||||||||||||||||||||||||||||||||
236 | , needsFlush(0) | - | ||||||||||||||||||||||||||||||||||||
237 | , redirectDev(0) | - | ||||||||||||||||||||||||||||||||||||
238 | , widgetItem(0) | - | ||||||||||||||||||||||||||||||||||||
239 | , extraPaintEngine(0) | - | ||||||||||||||||||||||||||||||||||||
240 | , polished(0) | - | ||||||||||||||||||||||||||||||||||||
241 | , graphicsEffect(0) | - | ||||||||||||||||||||||||||||||||||||
242 | #if !defined(QT_NO_IM) | - | ||||||||||||||||||||||||||||||||||||
243 | , imHints(Qt::ImhNone) | - | ||||||||||||||||||||||||||||||||||||
244 | #endif | - | ||||||||||||||||||||||||||||||||||||
245 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||||||||||||||
246 | , toolTipDuration(-1) | - | ||||||||||||||||||||||||||||||||||||
247 | #endif | - | ||||||||||||||||||||||||||||||||||||
248 | , inheritedFontResolveMask(0) | - | ||||||||||||||||||||||||||||||||||||
249 | , inheritedPaletteResolveMask(0) | - | ||||||||||||||||||||||||||||||||||||
250 | , leftmargin(0) | - | ||||||||||||||||||||||||||||||||||||
251 | , topmargin(0) | - | ||||||||||||||||||||||||||||||||||||
252 | , rightmargin(0) | - | ||||||||||||||||||||||||||||||||||||
253 | , bottommargin(0) | - | ||||||||||||||||||||||||||||||||||||
254 | , leftLayoutItemMargin(0) | - | ||||||||||||||||||||||||||||||||||||
255 | , topLayoutItemMargin(0) | - | ||||||||||||||||||||||||||||||||||||
256 | , rightLayoutItemMargin(0) | - | ||||||||||||||||||||||||||||||||||||
257 | , bottomLayoutItemMargin(0) | - | ||||||||||||||||||||||||||||||||||||
258 | , hd(0) | - | ||||||||||||||||||||||||||||||||||||
259 | , size_policy(QSizePolicy::Preferred, QSizePolicy::Preferred) | - | ||||||||||||||||||||||||||||||||||||
260 | , fg_role(QPalette::NoRole) | - | ||||||||||||||||||||||||||||||||||||
261 | , bg_role(QPalette::NoRole) | - | ||||||||||||||||||||||||||||||||||||
262 | , dirtyOpaqueChildren(1) | - | ||||||||||||||||||||||||||||||||||||
263 | , isOpaque(0) | - | ||||||||||||||||||||||||||||||||||||
264 | , retainSizeWhenHiddenChanged(0) | - | ||||||||||||||||||||||||||||||||||||
265 | , inDirtyList(0) | - | ||||||||||||||||||||||||||||||||||||
266 | , isScrolled(0) | - | ||||||||||||||||||||||||||||||||||||
267 | , isMoved(0) | - | ||||||||||||||||||||||||||||||||||||
268 | , usesDoubleBufferedGLContext(0) | - | ||||||||||||||||||||||||||||||||||||
269 | , mustHaveWindowHandle(0) | - | ||||||||||||||||||||||||||||||||||||
270 | , renderToTexture(0) | - | ||||||||||||||||||||||||||||||||||||
271 | , textureChildSeen(0) | - | ||||||||||||||||||||||||||||||||||||
272 | #ifndef QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
273 | , inheritsInputMethodHints(0) | - | ||||||||||||||||||||||||||||||||||||
274 | #endif | - | ||||||||||||||||||||||||||||||||||||
275 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
276 | , renderToTextureReallyDirty(1) | - | ||||||||||||||||||||||||||||||||||||
277 | , renderToTextureComposeActive(0) | - | ||||||||||||||||||||||||||||||||||||
278 | #endif | - | ||||||||||||||||||||||||||||||||||||
279 | , childrenHiddenByWState(0) | - | ||||||||||||||||||||||||||||||||||||
280 | , childrenShownByExpose(0) | - | ||||||||||||||||||||||||||||||||||||
281 | #if defined(Q_OS_WIN) | - | ||||||||||||||||||||||||||||||||||||
282 | , noPaintOnScreen(0) | - | ||||||||||||||||||||||||||||||||||||
283 | #endif | - | ||||||||||||||||||||||||||||||||||||
284 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
285 | , picture(0) | - | ||||||||||||||||||||||||||||||||||||
286 | #elif defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
287 | #ifndef QT_NO_GESTURES | - | ||||||||||||||||||||||||||||||||||||
288 | , nativeGesturePanEnabled(0) | - | ||||||||||||||||||||||||||||||||||||
289 | #endif | - | ||||||||||||||||||||||||||||||||||||
290 | #elif defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
291 | , needWindowChange(0) | - | ||||||||||||||||||||||||||||||||||||
292 | , window_event(0) | - | ||||||||||||||||||||||||||||||||||||
293 | , qd_hd(0) | - | ||||||||||||||||||||||||||||||||||||
294 | #endif | - | ||||||||||||||||||||||||||||||||||||
295 | { | - | ||||||||||||||||||||||||||||||||||||
296 | if (!qApp) {
| 0 | ||||||||||||||||||||||||||||||||||||
297 | qFatal("QWidget: Must construct a QApplication before a QWidget"); | - | ||||||||||||||||||||||||||||||||||||
298 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
299 | } | - | ||||||||||||||||||||||||||||||||||||
300 | - | |||||||||||||||||||||||||||||||||||||
301 | #ifdef QT_BUILD_INTERNAL | - | ||||||||||||||||||||||||||||||||||||
302 | // Don't check the version parameter in internal builds. | - | ||||||||||||||||||||||||||||||||||||
303 | // This allows incompatible versions to be loaded, possibly for testing. | - | ||||||||||||||||||||||||||||||||||||
304 | Q_UNUSED(version); | - | ||||||||||||||||||||||||||||||||||||
305 | #else | - | ||||||||||||||||||||||||||||||||||||
306 | if (version != QObjectPrivateVersion) | - | ||||||||||||||||||||||||||||||||||||
307 | qFatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)", | - | ||||||||||||||||||||||||||||||||||||
308 | version, QObjectPrivateVersion); | - | ||||||||||||||||||||||||||||||||||||
309 | #endif | - | ||||||||||||||||||||||||||||||||||||
310 | - | |||||||||||||||||||||||||||||||||||||
311 | isWidget = true; | - | ||||||||||||||||||||||||||||||||||||
312 | memset(high_attributes, 0, sizeof(high_attributes)); | - | ||||||||||||||||||||||||||||||||||||
313 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
314 | drawRectOriginalAdded = false; | - | ||||||||||||||||||||||||||||||||||||
315 | originalDrawMethod = true; | - | ||||||||||||||||||||||||||||||||||||
316 | changeMethods = false; | - | ||||||||||||||||||||||||||||||||||||
317 | isInUnifiedToolbar = false; | - | ||||||||||||||||||||||||||||||||||||
318 | unifiedSurface = 0; | - | ||||||||||||||||||||||||||||||||||||
319 | toolbar_ancestor = 0; | - | ||||||||||||||||||||||||||||||||||||
320 | flushRequested = false; | - | ||||||||||||||||||||||||||||||||||||
321 | touchEventsEnabled = false; | - | ||||||||||||||||||||||||||||||||||||
322 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
323 | #ifdef QWIDGET_EXTRA_DEBUG | - | ||||||||||||||||||||||||||||||||||||
324 | static int count = 0; | - | ||||||||||||||||||||||||||||||||||||
325 | qDebug() << "widgets" << ++count; | - | ||||||||||||||||||||||||||||||||||||
326 | #endif | - | ||||||||||||||||||||||||||||||||||||
327 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
328 | - | |||||||||||||||||||||||||||||||||||||
329 | - | |||||||||||||||||||||||||||||||||||||
330 | QWidgetPrivate::~QWidgetPrivate() | - | ||||||||||||||||||||||||||||||||||||
331 | { | - | ||||||||||||||||||||||||||||||||||||
332 | if (widgetItem)
| 0 | ||||||||||||||||||||||||||||||||||||
333 | widgetItem->wid = 0; never executed: widgetItem->wid = 0; | 0 | ||||||||||||||||||||||||||||||||||||
334 | - | |||||||||||||||||||||||||||||||||||||
335 | if (extra)
| 0 | ||||||||||||||||||||||||||||||||||||
336 | deleteExtra(); never executed: deleteExtra(); | 0 | ||||||||||||||||||||||||||||||||||||
337 | - | |||||||||||||||||||||||||||||||||||||
338 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
339 | delete graphicsEffect; | - | ||||||||||||||||||||||||||||||||||||
340 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
341 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
342 | - | |||||||||||||||||||||||||||||||||||||
343 | /*! | - | ||||||||||||||||||||||||||||||||||||
344 | \internal | - | ||||||||||||||||||||||||||||||||||||
345 | */ | - | ||||||||||||||||||||||||||||||||||||
346 | void QWidgetPrivate::scrollChildren(int dx, int dy) | - | ||||||||||||||||||||||||||||||||||||
347 | { | - | ||||||||||||||||||||||||||||||||||||
348 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
349 | if (q->children().size() > 0) { // scroll children
| 0 | ||||||||||||||||||||||||||||||||||||
350 | QPoint pd(dx, dy); | - | ||||||||||||||||||||||||||||||||||||
351 | QObjectList childObjects = q->children(); | - | ||||||||||||||||||||||||||||||||||||
352 | for (int i = 0; i < childObjects.size(); ++i) { // move all children
| 0 | ||||||||||||||||||||||||||||||||||||
353 | QWidget *w = qobject_cast<QWidget*>(childObjects.at(i)); | - | ||||||||||||||||||||||||||||||||||||
354 | if (w && !w->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
355 | QPoint oldp = w->pos(); | - | ||||||||||||||||||||||||||||||||||||
356 | QRect r(w->pos() + pd, w->size()); | - | ||||||||||||||||||||||||||||||||||||
357 | w->data->crect = r; | - | ||||||||||||||||||||||||||||||||||||
358 | if (w->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
359 | w->d_func()->setWSGeometry(); never executed: w->d_func()->setWSGeometry(); | 0 | ||||||||||||||||||||||||||||||||||||
360 | w->d_func()->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
361 | QMoveEvent e(r.topLeft(), oldp); | - | ||||||||||||||||||||||||||||||||||||
362 | QApplication::sendEvent(w, &e); | - | ||||||||||||||||||||||||||||||||||||
363 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
364 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
365 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
366 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
367 | - | |||||||||||||||||||||||||||||||||||||
368 | void QWidgetPrivate::setWSGeometry() | - | ||||||||||||||||||||||||||||||||||||
369 | { | - | ||||||||||||||||||||||||||||||||||||
370 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
371 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
372 | window->setGeometry(data.crect); never executed: window->setGeometry(data.crect); | 0 | ||||||||||||||||||||||||||||||||||||
373 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
374 | - | |||||||||||||||||||||||||||||||||||||
375 | void QWidgetPrivate::updateWidgetTransform(QEvent *event) | - | ||||||||||||||||||||||||||||||||||||
376 | { | - | ||||||||||||||||||||||||||||||||||||
377 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
378 | if (q == QGuiApplication::focusObject() || event->type() == QEvent::FocusIn) {
| 0 | ||||||||||||||||||||||||||||||||||||
379 | QTransform t; | - | ||||||||||||||||||||||||||||||||||||
380 | QPoint p = q->mapTo(q->topLevelWidget(), QPoint(0,0)); | - | ||||||||||||||||||||||||||||||||||||
381 | t.translate(p.x(), p.y()); | - | ||||||||||||||||||||||||||||||||||||
382 | QGuiApplication::inputMethod()->setInputItemTransform(t); | - | ||||||||||||||||||||||||||||||||||||
383 | QGuiApplication::inputMethod()->setInputItemRectangle(q->rect()); | - | ||||||||||||||||||||||||||||||||||||
384 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
385 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
386 | - | |||||||||||||||||||||||||||||||||||||
387 | #ifdef QT_KEYPAD_NAVIGATION | - | ||||||||||||||||||||||||||||||||||||
388 | QPointer<QWidget> QWidgetPrivate::editingWidget; | - | ||||||||||||||||||||||||||||||||||||
389 | - | |||||||||||||||||||||||||||||||||||||
390 | /*! | - | ||||||||||||||||||||||||||||||||||||
391 | Returns \c true if this widget currently has edit focus; otherwise false. | - | ||||||||||||||||||||||||||||||||||||
392 | - | |||||||||||||||||||||||||||||||||||||
393 | This feature is only available in Qt for Embedded Linux. | - | ||||||||||||||||||||||||||||||||||||
394 | - | |||||||||||||||||||||||||||||||||||||
395 | \sa setEditFocus(), QApplication::keypadNavigationEnabled() | - | ||||||||||||||||||||||||||||||||||||
396 | */ | - | ||||||||||||||||||||||||||||||||||||
397 | bool QWidget::hasEditFocus() const | - | ||||||||||||||||||||||||||||||||||||
398 | { | - | ||||||||||||||||||||||||||||||||||||
399 | const QWidget* w = this; | - | ||||||||||||||||||||||||||||||||||||
400 | while (w->d_func()->extra && w->d_func()->extra->focus_proxy) | - | ||||||||||||||||||||||||||||||||||||
401 | w = w->d_func()->extra->focus_proxy; | - | ||||||||||||||||||||||||||||||||||||
402 | return QWidgetPrivate::editingWidget == w; | - | ||||||||||||||||||||||||||||||||||||
403 | } | - | ||||||||||||||||||||||||||||||||||||
404 | - | |||||||||||||||||||||||||||||||||||||
405 | /*! | - | ||||||||||||||||||||||||||||||||||||
406 | \fn void QWidget::setEditFocus(bool enable) | - | ||||||||||||||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||||||||||||||
408 | If \a enable is true, make this widget have edit focus, in which | - | ||||||||||||||||||||||||||||||||||||
409 | case Qt::Key_Up and Qt::Key_Down will be delivered to the widget | - | ||||||||||||||||||||||||||||||||||||
410 | normally; otherwise, Qt::Key_Up and Qt::Key_Down are used to | - | ||||||||||||||||||||||||||||||||||||
411 | change focus. | - | ||||||||||||||||||||||||||||||||||||
412 | - | |||||||||||||||||||||||||||||||||||||
413 | This feature is only available in Qt for Embedded Linux. | - | ||||||||||||||||||||||||||||||||||||
414 | - | |||||||||||||||||||||||||||||||||||||
415 | \sa hasEditFocus(), QApplication::keypadNavigationEnabled() | - | ||||||||||||||||||||||||||||||||||||
416 | */ | - | ||||||||||||||||||||||||||||||||||||
417 | void QWidget::setEditFocus(bool on) | - | ||||||||||||||||||||||||||||||||||||
418 | { | - | ||||||||||||||||||||||||||||||||||||
419 | QWidget *f = this; | - | ||||||||||||||||||||||||||||||||||||
420 | while (f->d_func()->extra && f->d_func()->extra->focus_proxy) | - | ||||||||||||||||||||||||||||||||||||
421 | f = f->d_func()->extra->focus_proxy; | - | ||||||||||||||||||||||||||||||||||||
422 | - | |||||||||||||||||||||||||||||||||||||
423 | if (QWidgetPrivate::editingWidget && QWidgetPrivate::editingWidget != f) | - | ||||||||||||||||||||||||||||||||||||
424 | QWidgetPrivate::editingWidget->setEditFocus(false); | - | ||||||||||||||||||||||||||||||||||||
425 | - | |||||||||||||||||||||||||||||||||||||
426 | if (on && !f->hasFocus()) | - | ||||||||||||||||||||||||||||||||||||
427 | f->setFocus(); | - | ||||||||||||||||||||||||||||||||||||
428 | - | |||||||||||||||||||||||||||||||||||||
429 | if ((!on && !QWidgetPrivate::editingWidget) | - | ||||||||||||||||||||||||||||||||||||
430 | || (on && QWidgetPrivate::editingWidget == f)) { | - | ||||||||||||||||||||||||||||||||||||
431 | return; | - | ||||||||||||||||||||||||||||||||||||
432 | } | - | ||||||||||||||||||||||||||||||||||||
433 | - | |||||||||||||||||||||||||||||||||||||
434 | if (!on && QWidgetPrivate::editingWidget == f) { | - | ||||||||||||||||||||||||||||||||||||
435 | QWidgetPrivate::editingWidget = 0; | - | ||||||||||||||||||||||||||||||||||||
436 | QEvent event(QEvent::LeaveEditFocus); | - | ||||||||||||||||||||||||||||||||||||
437 | QApplication::sendEvent(f, &event); | - | ||||||||||||||||||||||||||||||||||||
438 | QApplication::sendEvent(f->style(), &event); | - | ||||||||||||||||||||||||||||||||||||
439 | } else if (on) { | - | ||||||||||||||||||||||||||||||||||||
440 | QWidgetPrivate::editingWidget = f; | - | ||||||||||||||||||||||||||||||||||||
441 | QEvent event(QEvent::EnterEditFocus); | - | ||||||||||||||||||||||||||||||||||||
442 | QApplication::sendEvent(f, &event); | - | ||||||||||||||||||||||||||||||||||||
443 | QApplication::sendEvent(f->style(), &event); | - | ||||||||||||||||||||||||||||||||||||
444 | } | - | ||||||||||||||||||||||||||||||||||||
445 | } | - | ||||||||||||||||||||||||||||||||||||
446 | #endif | - | ||||||||||||||||||||||||||||||||||||
447 | - | |||||||||||||||||||||||||||||||||||||
448 | /*! | - | ||||||||||||||||||||||||||||||||||||
449 | \property QWidget::autoFillBackground | - | ||||||||||||||||||||||||||||||||||||
450 | \brief whether the widget background is filled automatically | - | ||||||||||||||||||||||||||||||||||||
451 | \since 4.1 | - | ||||||||||||||||||||||||||||||||||||
452 | - | |||||||||||||||||||||||||||||||||||||
453 | If enabled, this property will cause Qt to fill the background of the | - | ||||||||||||||||||||||||||||||||||||
454 | widget before invoking the paint event. The color used is defined by the | - | ||||||||||||||||||||||||||||||||||||
455 | QPalette::Window color role from the widget's \l{QPalette}{palette}. | - | ||||||||||||||||||||||||||||||||||||
456 | - | |||||||||||||||||||||||||||||||||||||
457 | In addition, Windows are always filled with QPalette::Window, unless the | - | ||||||||||||||||||||||||||||||||||||
458 | WA_OpaquePaintEvent or WA_NoSystemBackground attributes are set. | - | ||||||||||||||||||||||||||||||||||||
459 | - | |||||||||||||||||||||||||||||||||||||
460 | This property cannot be turned off (i.e., set to false) if a widget's | - | ||||||||||||||||||||||||||||||||||||
461 | parent has a static gradient for its background. | - | ||||||||||||||||||||||||||||||||||||
462 | - | |||||||||||||||||||||||||||||||||||||
463 | \warning Use this property with caution in conjunction with | - | ||||||||||||||||||||||||||||||||||||
464 | \l{Qt Style Sheets}. When a widget has a style sheet with a valid | - | ||||||||||||||||||||||||||||||||||||
465 | background or a border-image, this property is automatically disabled. | - | ||||||||||||||||||||||||||||||||||||
466 | - | |||||||||||||||||||||||||||||||||||||
467 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
468 | - | |||||||||||||||||||||||||||||||||||||
469 | \sa Qt::WA_OpaquePaintEvent, Qt::WA_NoSystemBackground, | - | ||||||||||||||||||||||||||||||||||||
470 | {QWidget#Transparency and Double Buffering}{Transparency and Double Buffering} | - | ||||||||||||||||||||||||||||||||||||
471 | */ | - | ||||||||||||||||||||||||||||||||||||
472 | bool QWidget::autoFillBackground() const | - | ||||||||||||||||||||||||||||||||||||
473 | { | - | ||||||||||||||||||||||||||||||||||||
474 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
475 | return d->extra && d->extra->autoFillBackground; never executed: return d->extra && d->extra->autoFillBackground;
| 0 | ||||||||||||||||||||||||||||||||||||
476 | } | - | ||||||||||||||||||||||||||||||||||||
477 | - | |||||||||||||||||||||||||||||||||||||
478 | void QWidget::setAutoFillBackground(bool enabled) | - | ||||||||||||||||||||||||||||||||||||
479 | { | - | ||||||||||||||||||||||||||||||||||||
480 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
481 | if (!d->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
482 | d->createExtra(); never executed: d->createExtra(); | 0 | ||||||||||||||||||||||||||||||||||||
483 | if (d->extra->autoFillBackground == enabled)
| 0 | ||||||||||||||||||||||||||||||||||||
484 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
485 | - | |||||||||||||||||||||||||||||||||||||
486 | d->extra->autoFillBackground = enabled; | - | ||||||||||||||||||||||||||||||||||||
487 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
488 | update(); | - | ||||||||||||||||||||||||||||||||||||
489 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
490 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
491 | - | |||||||||||||||||||||||||||||||||||||
492 | /*! | - | ||||||||||||||||||||||||||||||||||||
493 | \class QWidget | - | ||||||||||||||||||||||||||||||||||||
494 | \brief The QWidget class is the base class of all user interface objects. | - | ||||||||||||||||||||||||||||||||||||
495 | - | |||||||||||||||||||||||||||||||||||||
496 | \ingroup basicwidgets | - | ||||||||||||||||||||||||||||||||||||
497 | \inmodule QtWidgets | - | ||||||||||||||||||||||||||||||||||||
498 | - | |||||||||||||||||||||||||||||||||||||
499 | The widget is the atom of the user interface: it receives mouse, keyboard | - | ||||||||||||||||||||||||||||||||||||
500 | and other events from the window system, and paints a representation of | - | ||||||||||||||||||||||||||||||||||||
501 | itself on the screen. Every widget is rectangular, and they are sorted in a | - | ||||||||||||||||||||||||||||||||||||
502 | Z-order. A widget is clipped by its parent and by the widgets in front of | - | ||||||||||||||||||||||||||||||||||||
503 | it. | - | ||||||||||||||||||||||||||||||||||||
504 | - | |||||||||||||||||||||||||||||||||||||
505 | A widget that is not embedded in a parent widget is called a window. | - | ||||||||||||||||||||||||||||||||||||
506 | Usually, windows have a frame and a title bar, although it is also possible | - | ||||||||||||||||||||||||||||||||||||
507 | to create windows without such decoration using suitable | - | ||||||||||||||||||||||||||||||||||||
508 | \l{Qt::WindowFlags}{window flags}). In Qt, QMainWindow and the various | - | ||||||||||||||||||||||||||||||||||||
509 | subclasses of QDialog are the most common window types. | - | ||||||||||||||||||||||||||||||||||||
510 | - | |||||||||||||||||||||||||||||||||||||
511 | Every widget's constructor accepts one or two standard arguments: | - | ||||||||||||||||||||||||||||||||||||
512 | - | |||||||||||||||||||||||||||||||||||||
513 | \list 1 | - | ||||||||||||||||||||||||||||||||||||
514 | \li \c{QWidget *parent = 0} is the parent of the new widget. If it is 0 | - | ||||||||||||||||||||||||||||||||||||
515 | (the default), the new widget will be a window. If not, it will be | - | ||||||||||||||||||||||||||||||||||||
516 | a child of \e parent, and be constrained by \e parent's geometry | - | ||||||||||||||||||||||||||||||||||||
517 | (unless you specify Qt::Window as window flag). | - | ||||||||||||||||||||||||||||||||||||
518 | \li \c{Qt::WindowFlags f = 0} (where available) sets the window flags; | - | ||||||||||||||||||||||||||||||||||||
519 | the default is suitable for almost all widgets, but to get, for | - | ||||||||||||||||||||||||||||||||||||
520 | example, a window without a window system frame, you must use | - | ||||||||||||||||||||||||||||||||||||
521 | special flags. | - | ||||||||||||||||||||||||||||||||||||
522 | \endlist | - | ||||||||||||||||||||||||||||||||||||
523 | - | |||||||||||||||||||||||||||||||||||||
524 | QWidget has many member functions, but some of them have little direct | - | ||||||||||||||||||||||||||||||||||||
525 | functionality; for example, QWidget has a font property, but never uses | - | ||||||||||||||||||||||||||||||||||||
526 | this itself. There are many subclasses which provide real functionality, | - | ||||||||||||||||||||||||||||||||||||
527 | such as QLabel, QPushButton, QListWidget, and QTabWidget. | - | ||||||||||||||||||||||||||||||||||||
528 | - | |||||||||||||||||||||||||||||||||||||
529 | - | |||||||||||||||||||||||||||||||||||||
530 | \section1 Top-Level and Child Widgets | - | ||||||||||||||||||||||||||||||||||||
531 | - | |||||||||||||||||||||||||||||||||||||
532 | A widget without a parent widget is always an independent window (top-level | - | ||||||||||||||||||||||||||||||||||||
533 | widget). For these widgets, setWindowTitle() and setWindowIcon() set the | - | ||||||||||||||||||||||||||||||||||||
534 | title bar and icon respectively. | - | ||||||||||||||||||||||||||||||||||||
535 | - | |||||||||||||||||||||||||||||||||||||
536 | Non-window widgets are child widgets, displayed within their parent | - | ||||||||||||||||||||||||||||||||||||
537 | widgets. Most widgets in Qt are mainly useful as child widgets. For | - | ||||||||||||||||||||||||||||||||||||
538 | example, it is possible to display a button as a top-level window, but most | - | ||||||||||||||||||||||||||||||||||||
539 | people prefer to put their buttons inside other widgets, such as QDialog. | - | ||||||||||||||||||||||||||||||||||||
540 | - | |||||||||||||||||||||||||||||||||||||
541 | \image parent-child-widgets.png A parent widget containing various child widgets. | - | ||||||||||||||||||||||||||||||||||||
542 | - | |||||||||||||||||||||||||||||||||||||
543 | The diagram above shows a QGroupBox widget being used to hold various child | - | ||||||||||||||||||||||||||||||||||||
544 | widgets in a layout provided by QGridLayout. The QLabel child widgets have | - | ||||||||||||||||||||||||||||||||||||
545 | been outlined to indicate their full sizes. | - | ||||||||||||||||||||||||||||||||||||
546 | - | |||||||||||||||||||||||||||||||||||||
547 | If you want to use a QWidget to hold child widgets you will usually want to | - | ||||||||||||||||||||||||||||||||||||
548 | add a layout to the parent QWidget. See \l{Layout Management} for more | - | ||||||||||||||||||||||||||||||||||||
549 | information. | - | ||||||||||||||||||||||||||||||||||||
550 | - | |||||||||||||||||||||||||||||||||||||
551 | - | |||||||||||||||||||||||||||||||||||||
552 | \section1 Composite Widgets | - | ||||||||||||||||||||||||||||||||||||
553 | - | |||||||||||||||||||||||||||||||||||||
554 | When a widget is used as a container to group a number of child widgets, it | - | ||||||||||||||||||||||||||||||||||||
555 | is known as a composite widget. These can be created by constructing a | - | ||||||||||||||||||||||||||||||||||||
556 | widget with the required visual properties - a QFrame, for example - and | - | ||||||||||||||||||||||||||||||||||||
557 | adding child widgets to it, usually managed by a layout. The above diagram | - | ||||||||||||||||||||||||||||||||||||
558 | shows such a composite widget that was created using Qt Designer. | - | ||||||||||||||||||||||||||||||||||||
559 | - | |||||||||||||||||||||||||||||||||||||
560 | Composite widgets can also be created by subclassing a standard widget, | - | ||||||||||||||||||||||||||||||||||||
561 | such as QWidget or QFrame, and adding the necessary layout and child | - | ||||||||||||||||||||||||||||||||||||
562 | widgets in the constructor of the subclass. Many of the \l{Qt Examples} | - | ||||||||||||||||||||||||||||||||||||
563 | {examples provided with Qt} use this approach, and it is also covered in | - | ||||||||||||||||||||||||||||||||||||
564 | the Qt \l{Tutorials}. | - | ||||||||||||||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||||||||||||||
566 | - | |||||||||||||||||||||||||||||||||||||
567 | \section1 Custom Widgets and Painting | - | ||||||||||||||||||||||||||||||||||||
568 | - | |||||||||||||||||||||||||||||||||||||
569 | Since QWidget is a subclass of QPaintDevice, subclasses can be used to | - | ||||||||||||||||||||||||||||||||||||
570 | display custom content that is composed using a series of painting | - | ||||||||||||||||||||||||||||||||||||
571 | operations with an instance of the QPainter class. This approach contrasts | - | ||||||||||||||||||||||||||||||||||||
572 | with the canvas-style approach used by the \l{Graphics View} | - | ||||||||||||||||||||||||||||||||||||
573 | {Graphics View Framework} where items are added to a scene by the | - | ||||||||||||||||||||||||||||||||||||
574 | application and are rendered by the framework itself. | - | ||||||||||||||||||||||||||||||||||||
575 | - | |||||||||||||||||||||||||||||||||||||
576 | Each widget performs all painting operations from within its paintEvent() | - | ||||||||||||||||||||||||||||||||||||
577 | function. This is called whenever the widget needs to be redrawn, either | - | ||||||||||||||||||||||||||||||||||||
578 | as a result of some external change or when requested by the application. | - | ||||||||||||||||||||||||||||||||||||
579 | - | |||||||||||||||||||||||||||||||||||||
580 | The \l{widgets/analogclock}{Analog Clock example} shows how a simple widget | - | ||||||||||||||||||||||||||||||||||||
581 | can handle paint events. | - | ||||||||||||||||||||||||||||||||||||
582 | - | |||||||||||||||||||||||||||||||||||||
583 | - | |||||||||||||||||||||||||||||||||||||
584 | \section1 Size Hints and Size Policies | - | ||||||||||||||||||||||||||||||||||||
585 | - | |||||||||||||||||||||||||||||||||||||
586 | When implementing a new widget, it is almost always useful to reimplement | - | ||||||||||||||||||||||||||||||||||||
587 | sizeHint() to provide a reasonable default size for the widget and to set | - | ||||||||||||||||||||||||||||||||||||
588 | the correct size policy with setSizePolicy(). | - | ||||||||||||||||||||||||||||||||||||
589 | - | |||||||||||||||||||||||||||||||||||||
590 | By default, composite widgets which do not provide a size hint will be | - | ||||||||||||||||||||||||||||||||||||
591 | sized according to the space requirements of their child widgets. | - | ||||||||||||||||||||||||||||||||||||
592 | - | |||||||||||||||||||||||||||||||||||||
593 | The size policy lets you supply good default behavior for the layout | - | ||||||||||||||||||||||||||||||||||||
594 | management system, so that other widgets can contain and manage yours | - | ||||||||||||||||||||||||||||||||||||
595 | easily. The default size policy indicates that the size hint represents | - | ||||||||||||||||||||||||||||||||||||
596 | the preferred size of the widget, and this is often good enough for many | - | ||||||||||||||||||||||||||||||||||||
597 | widgets. | - | ||||||||||||||||||||||||||||||||||||
598 | - | |||||||||||||||||||||||||||||||||||||
599 | \note The size of top-level widgets are constrained to 2/3 of the desktop's | - | ||||||||||||||||||||||||||||||||||||
600 | height and width. You can resize() the widget manually if these bounds are | - | ||||||||||||||||||||||||||||||||||||
601 | inadequate. | - | ||||||||||||||||||||||||||||||||||||
602 | - | |||||||||||||||||||||||||||||||||||||
603 | - | |||||||||||||||||||||||||||||||||||||
604 | \section1 Events | - | ||||||||||||||||||||||||||||||||||||
605 | - | |||||||||||||||||||||||||||||||||||||
606 | Widgets respond to events that are typically caused by user actions. Qt | - | ||||||||||||||||||||||||||||||||||||
607 | delivers events to widgets by calling specific event handler functions with | - | ||||||||||||||||||||||||||||||||||||
608 | instances of QEvent subclasses containing information about each event. | - | ||||||||||||||||||||||||||||||||||||
609 | - | |||||||||||||||||||||||||||||||||||||
610 | If your widget only contains child widgets, you probably do not need to | - | ||||||||||||||||||||||||||||||||||||
611 | implement any event handlers. If you want to detect a mouse click in a | - | ||||||||||||||||||||||||||||||||||||
612 | child widget call the child's underMouse() function inside the widget's | - | ||||||||||||||||||||||||||||||||||||
613 | mousePressEvent(). | - | ||||||||||||||||||||||||||||||||||||
614 | - | |||||||||||||||||||||||||||||||||||||
615 | The \l{widgets/scribble}{Scribble example} implements a wider set of | - | ||||||||||||||||||||||||||||||||||||
616 | events to handle mouse movement, button presses, and window resizing. | - | ||||||||||||||||||||||||||||||||||||
617 | - | |||||||||||||||||||||||||||||||||||||
618 | You will need to supply the behavior and content for your own widgets, but | - | ||||||||||||||||||||||||||||||||||||
619 | here is a brief overview of the events that are relevant to QWidget, | - | ||||||||||||||||||||||||||||||||||||
620 | starting with the most common ones: | - | ||||||||||||||||||||||||||||||||||||
621 | - | |||||||||||||||||||||||||||||||||||||
622 | \list | - | ||||||||||||||||||||||||||||||||||||
623 | \li paintEvent() is called whenever the widget needs to be repainted. | - | ||||||||||||||||||||||||||||||||||||
624 | Every widget displaying custom content must implement it. Painting | - | ||||||||||||||||||||||||||||||||||||
625 | using a QPainter can only take place in a paintEvent() or a | - | ||||||||||||||||||||||||||||||||||||
626 | function called by a paintEvent(). | - | ||||||||||||||||||||||||||||||||||||
627 | \li resizeEvent() is called when the widget has been resized. | - | ||||||||||||||||||||||||||||||||||||
628 | \li mousePressEvent() is called when a mouse button is pressed while | - | ||||||||||||||||||||||||||||||||||||
629 | the mouse cursor is inside the widget, or when the widget has | - | ||||||||||||||||||||||||||||||||||||
630 | grabbed the mouse using grabMouse(). Pressing the mouse without | - | ||||||||||||||||||||||||||||||||||||
631 | releasing it is effectively the same as calling grabMouse(). | - | ||||||||||||||||||||||||||||||||||||
632 | \li mouseReleaseEvent() is called when a mouse button is released. A | - | ||||||||||||||||||||||||||||||||||||
633 | widget receives mouse release events when it has received the | - | ||||||||||||||||||||||||||||||||||||
634 | corresponding mouse press event. This means that if the user | - | ||||||||||||||||||||||||||||||||||||
635 | presses the mouse inside \e your widget, then drags the mouse | - | ||||||||||||||||||||||||||||||||||||
636 | somewhere else before releasing the mouse button, \e your widget | - | ||||||||||||||||||||||||||||||||||||
637 | receives the release event. There is one exception: if a popup menu | - | ||||||||||||||||||||||||||||||||||||
638 | appears while the mouse button is held down, this popup immediately | - | ||||||||||||||||||||||||||||||||||||
639 | steals the mouse events. | - | ||||||||||||||||||||||||||||||||||||
640 | \li mouseDoubleClickEvent() is called when the user double-clicks in | - | ||||||||||||||||||||||||||||||||||||
641 | the widget. If the user double-clicks, the widget receives a mouse | - | ||||||||||||||||||||||||||||||||||||
642 | press event, a mouse release event, (a mouse click event,) a second | - | ||||||||||||||||||||||||||||||||||||
643 | mouse press, this event and finally a second mouse release event. | - | ||||||||||||||||||||||||||||||||||||
644 | (Some mouse move events may also be | - | ||||||||||||||||||||||||||||||||||||
645 | received if the mouse is not held steady during this operation.) It | - | ||||||||||||||||||||||||||||||||||||
646 | is \e{not possible} to distinguish a click from a double-click | - | ||||||||||||||||||||||||||||||||||||
647 | until the second click arrives. (This is one reason why most GUI | - | ||||||||||||||||||||||||||||||||||||
648 | books recommend that double-clicks be an extension of | - | ||||||||||||||||||||||||||||||||||||
649 | single-clicks, rather than trigger a different action.) | - | ||||||||||||||||||||||||||||||||||||
650 | \endlist | - | ||||||||||||||||||||||||||||||||||||
651 | - | |||||||||||||||||||||||||||||||||||||
652 | Widgets that accept keyboard input need to reimplement a few more event | - | ||||||||||||||||||||||||||||||||||||
653 | handlers: | - | ||||||||||||||||||||||||||||||||||||
654 | - | |||||||||||||||||||||||||||||||||||||
655 | \list | - | ||||||||||||||||||||||||||||||||||||
656 | \li keyPressEvent() is called whenever a key is pressed, and again when | - | ||||||||||||||||||||||||||||||||||||
657 | a key has been held down long enough for it to auto-repeat. The | - | ||||||||||||||||||||||||||||||||||||
658 | \uicontrol Tab and \uicontrol Shift+Tab keys are only passed to the widget if | - | ||||||||||||||||||||||||||||||||||||
659 | they are not used by the focus-change mechanisms. To force those | - | ||||||||||||||||||||||||||||||||||||
660 | keys to be processed by your widget, you must reimplement | - | ||||||||||||||||||||||||||||||||||||
661 | QWidget::event(). | - | ||||||||||||||||||||||||||||||||||||
662 | \li focusInEvent() is called when the widget gains keyboard focus | - | ||||||||||||||||||||||||||||||||||||
663 | (assuming you have called setFocusPolicy()). Well-behaved widgets | - | ||||||||||||||||||||||||||||||||||||
664 | indicate that they own the keyboard focus in a clear but discreet | - | ||||||||||||||||||||||||||||||||||||
665 | way. | - | ||||||||||||||||||||||||||||||||||||
666 | \li focusOutEvent() is called when the widget loses keyboard focus. | - | ||||||||||||||||||||||||||||||||||||
667 | \endlist | - | ||||||||||||||||||||||||||||||||||||
668 | - | |||||||||||||||||||||||||||||||||||||
669 | You may be required to also reimplement some of the less common event | - | ||||||||||||||||||||||||||||||||||||
670 | handlers: | - | ||||||||||||||||||||||||||||||||||||
671 | - | |||||||||||||||||||||||||||||||||||||
672 | \list | - | ||||||||||||||||||||||||||||||||||||
673 | \li mouseMoveEvent() is called whenever the mouse moves while a mouse | - | ||||||||||||||||||||||||||||||||||||
674 | button is held down. This can be useful during drag and drop | - | ||||||||||||||||||||||||||||||||||||
675 | operations. If you call \l{setMouseTracking()}{setMouseTracking}(true), | - | ||||||||||||||||||||||||||||||||||||
676 | you get mouse move events even when no buttons are held down. | - | ||||||||||||||||||||||||||||||||||||
677 | (See also the \l{Drag and Drop} guide.) | - | ||||||||||||||||||||||||||||||||||||
678 | \li keyReleaseEvent() is called whenever a key is released and while it | - | ||||||||||||||||||||||||||||||||||||
679 | is held down (if the key is auto-repeating). In that case, the | - | ||||||||||||||||||||||||||||||||||||
680 | widget will receive a pair of key release and key press event for | - | ||||||||||||||||||||||||||||||||||||
681 | every repeat. The \uicontrol Tab and \uicontrol Shift+Tab keys are only passed | - | ||||||||||||||||||||||||||||||||||||
682 | to the widget if they are not used by the focus-change mechanisms. | - | ||||||||||||||||||||||||||||||||||||
683 | To force those keys to be processed by your widget, you must | - | ||||||||||||||||||||||||||||||||||||
684 | reimplement QWidget::event(). | - | ||||||||||||||||||||||||||||||||||||
685 | \li wheelEvent() is called whenever the user turns the mouse wheel | - | ||||||||||||||||||||||||||||||||||||
686 | while the widget has the focus. | - | ||||||||||||||||||||||||||||||||||||
687 | \li enterEvent() is called when the mouse enters the widget's screen | - | ||||||||||||||||||||||||||||||||||||
688 | space. (This excludes screen space owned by any of the widget's | - | ||||||||||||||||||||||||||||||||||||
689 | children.) | - | ||||||||||||||||||||||||||||||||||||
690 | \li leaveEvent() is called when the mouse leaves the widget's screen | - | ||||||||||||||||||||||||||||||||||||
691 | space. If the mouse enters a child widget it will not cause a | - | ||||||||||||||||||||||||||||||||||||
692 | leaveEvent(). | - | ||||||||||||||||||||||||||||||||||||
693 | \li moveEvent() is called when the widget has been moved relative to | - | ||||||||||||||||||||||||||||||||||||
694 | its parent. | - | ||||||||||||||||||||||||||||||||||||
695 | \li closeEvent() is called when the user closes the widget (or when | - | ||||||||||||||||||||||||||||||||||||
696 | close() is called). | - | ||||||||||||||||||||||||||||||||||||
697 | \endlist | - | ||||||||||||||||||||||||||||||||||||
698 | - | |||||||||||||||||||||||||||||||||||||
699 | There are also some rather obscure events described in the documentation | - | ||||||||||||||||||||||||||||||||||||
700 | for QEvent::Type. To handle these events, you need to reimplement event() | - | ||||||||||||||||||||||||||||||||||||
701 | directly. | - | ||||||||||||||||||||||||||||||||||||
702 | - | |||||||||||||||||||||||||||||||||||||
703 | The default implementation of event() handles \uicontrol Tab and \uicontrol Shift+Tab | - | ||||||||||||||||||||||||||||||||||||
704 | (to move the keyboard focus), and passes on most of the other events to | - | ||||||||||||||||||||||||||||||||||||
705 | one of the more specialized handlers above. | - | ||||||||||||||||||||||||||||||||||||
706 | - | |||||||||||||||||||||||||||||||||||||
707 | Events and the mechanism used to deliver them are covered in | - | ||||||||||||||||||||||||||||||||||||
708 | \l{The Event System}. | - | ||||||||||||||||||||||||||||||||||||
709 | - | |||||||||||||||||||||||||||||||||||||
710 | \section1 Groups of Functions and Properties | - | ||||||||||||||||||||||||||||||||||||
711 | - | |||||||||||||||||||||||||||||||||||||
712 | \table | - | ||||||||||||||||||||||||||||||||||||
713 | \header \li Context \li Functions and Properties | - | ||||||||||||||||||||||||||||||||||||
714 | - | |||||||||||||||||||||||||||||||||||||
715 | \row \li Window functions \li | - | ||||||||||||||||||||||||||||||||||||
716 | show(), | - | ||||||||||||||||||||||||||||||||||||
717 | hide(), | - | ||||||||||||||||||||||||||||||||||||
718 | raise(), | - | ||||||||||||||||||||||||||||||||||||
719 | lower(), | - | ||||||||||||||||||||||||||||||||||||
720 | close(). | - | ||||||||||||||||||||||||||||||||||||
721 | - | |||||||||||||||||||||||||||||||||||||
722 | \row \li Top-level windows \li | - | ||||||||||||||||||||||||||||||||||||
723 | \l windowModified, \l windowTitle, \l windowIcon, | - | ||||||||||||||||||||||||||||||||||||
724 | \l isActiveWindow, activateWindow(), \l minimized, showMinimized(), | - | ||||||||||||||||||||||||||||||||||||
725 | \l maximized, showMaximized(), \l fullScreen, showFullScreen(), | - | ||||||||||||||||||||||||||||||||||||
726 | showNormal(). | - | ||||||||||||||||||||||||||||||||||||
727 | - | |||||||||||||||||||||||||||||||||||||
728 | \row \li Window contents \li | - | ||||||||||||||||||||||||||||||||||||
729 | update(), | - | ||||||||||||||||||||||||||||||||||||
730 | repaint(), | - | ||||||||||||||||||||||||||||||||||||
731 | scroll(). | - | ||||||||||||||||||||||||||||||||||||
732 | - | |||||||||||||||||||||||||||||||||||||
733 | \row \li Geometry \li | - | ||||||||||||||||||||||||||||||||||||
734 | \l pos, x(), y(), \l rect, \l size, width(), height(), move(), resize(), | - | ||||||||||||||||||||||||||||||||||||
735 | \l sizePolicy, sizeHint(), minimumSizeHint(), | - | ||||||||||||||||||||||||||||||||||||
736 | updateGeometry(), layout(), | - | ||||||||||||||||||||||||||||||||||||
737 | \l frameGeometry, \l geometry, \l childrenRect, \l childrenRegion, | - | ||||||||||||||||||||||||||||||||||||
738 | adjustSize(), | - | ||||||||||||||||||||||||||||||||||||
739 | mapFromGlobal(), mapToGlobal(), | - | ||||||||||||||||||||||||||||||||||||
740 | mapFromParent(), mapToParent(), | - | ||||||||||||||||||||||||||||||||||||
741 | \l maximumSize, \l minimumSize, \l sizeIncrement, | - | ||||||||||||||||||||||||||||||||||||
742 | \l baseSize, setFixedSize() | - | ||||||||||||||||||||||||||||||||||||
743 | - | |||||||||||||||||||||||||||||||||||||
744 | \row \li Mode \li | - | ||||||||||||||||||||||||||||||||||||
745 | \l visible, isVisibleTo(), | - | ||||||||||||||||||||||||||||||||||||
746 | \l enabled, isEnabledTo(), | - | ||||||||||||||||||||||||||||||||||||
747 | \l modal, | - | ||||||||||||||||||||||||||||||||||||
748 | isWindow(), | - | ||||||||||||||||||||||||||||||||||||
749 | \l mouseTracking, | - | ||||||||||||||||||||||||||||||||||||
750 | \l updatesEnabled, | - | ||||||||||||||||||||||||||||||||||||
751 | visibleRegion(). | - | ||||||||||||||||||||||||||||||||||||
752 | - | |||||||||||||||||||||||||||||||||||||
753 | \row \li Look and feel \li | - | ||||||||||||||||||||||||||||||||||||
754 | style(), | - | ||||||||||||||||||||||||||||||||||||
755 | setStyle(), | - | ||||||||||||||||||||||||||||||||||||
756 | \l styleSheet, | - | ||||||||||||||||||||||||||||||||||||
757 | \l cursor, | - | ||||||||||||||||||||||||||||||||||||
758 | \l font, | - | ||||||||||||||||||||||||||||||||||||
759 | \l palette, | - | ||||||||||||||||||||||||||||||||||||
760 | backgroundRole(), setBackgroundRole(), | - | ||||||||||||||||||||||||||||||||||||
761 | fontInfo(), fontMetrics(). | - | ||||||||||||||||||||||||||||||||||||
762 | - | |||||||||||||||||||||||||||||||||||||
763 | \row \li Keyboard focus functions \li | - | ||||||||||||||||||||||||||||||||||||
764 | \l focus, \l focusPolicy, | - | ||||||||||||||||||||||||||||||||||||
765 | setFocus(), clearFocus(), setTabOrder(), setFocusProxy(), | - | ||||||||||||||||||||||||||||||||||||
766 | focusNextChild(), focusPreviousChild(). | - | ||||||||||||||||||||||||||||||||||||
767 | - | |||||||||||||||||||||||||||||||||||||
768 | \row \li Mouse and keyboard grabbing \li | - | ||||||||||||||||||||||||||||||||||||
769 | grabMouse(), releaseMouse(), | - | ||||||||||||||||||||||||||||||||||||
770 | grabKeyboard(), releaseKeyboard(), | - | ||||||||||||||||||||||||||||||||||||
771 | mouseGrabber(), keyboardGrabber(). | - | ||||||||||||||||||||||||||||||||||||
772 | - | |||||||||||||||||||||||||||||||||||||
773 | \row \li Event handlers \li | - | ||||||||||||||||||||||||||||||||||||
774 | event(), | - | ||||||||||||||||||||||||||||||||||||
775 | mousePressEvent(), | - | ||||||||||||||||||||||||||||||||||||
776 | mouseReleaseEvent(), | - | ||||||||||||||||||||||||||||||||||||
777 | mouseDoubleClickEvent(), | - | ||||||||||||||||||||||||||||||||||||
778 | mouseMoveEvent(), | - | ||||||||||||||||||||||||||||||||||||
779 | keyPressEvent(), | - | ||||||||||||||||||||||||||||||||||||
780 | keyReleaseEvent(), | - | ||||||||||||||||||||||||||||||||||||
781 | focusInEvent(), | - | ||||||||||||||||||||||||||||||||||||
782 | focusOutEvent(), | - | ||||||||||||||||||||||||||||||||||||
783 | wheelEvent(), | - | ||||||||||||||||||||||||||||||||||||
784 | enterEvent(), | - | ||||||||||||||||||||||||||||||||||||
785 | leaveEvent(), | - | ||||||||||||||||||||||||||||||||||||
786 | paintEvent(), | - | ||||||||||||||||||||||||||||||||||||
787 | moveEvent(), | - | ||||||||||||||||||||||||||||||||||||
788 | resizeEvent(), | - | ||||||||||||||||||||||||||||||||||||
789 | closeEvent(), | - | ||||||||||||||||||||||||||||||||||||
790 | dragEnterEvent(), | - | ||||||||||||||||||||||||||||||||||||
791 | dragMoveEvent(), | - | ||||||||||||||||||||||||||||||||||||
792 | dragLeaveEvent(), | - | ||||||||||||||||||||||||||||||||||||
793 | dropEvent(), | - | ||||||||||||||||||||||||||||||||||||
794 | childEvent(), | - | ||||||||||||||||||||||||||||||||||||
795 | showEvent(), | - | ||||||||||||||||||||||||||||||||||||
796 | hideEvent(), | - | ||||||||||||||||||||||||||||||||||||
797 | customEvent(). | - | ||||||||||||||||||||||||||||||||||||
798 | changeEvent(), | - | ||||||||||||||||||||||||||||||||||||
799 | - | |||||||||||||||||||||||||||||||||||||
800 | \row \li System functions \li | - | ||||||||||||||||||||||||||||||||||||
801 | parentWidget(), window(), setParent(), winId(), | - | ||||||||||||||||||||||||||||||||||||
802 | find(), metric(). | - | ||||||||||||||||||||||||||||||||||||
803 | - | |||||||||||||||||||||||||||||||||||||
804 | \row \li Interactive help \li | - | ||||||||||||||||||||||||||||||||||||
805 | setToolTip(), setWhatsThis() | - | ||||||||||||||||||||||||||||||||||||
806 | - | |||||||||||||||||||||||||||||||||||||
807 | \endtable | - | ||||||||||||||||||||||||||||||||||||
808 | - | |||||||||||||||||||||||||||||||||||||
809 | - | |||||||||||||||||||||||||||||||||||||
810 | \section1 Widget Style Sheets | - | ||||||||||||||||||||||||||||||||||||
811 | - | |||||||||||||||||||||||||||||||||||||
812 | In addition to the standard widget styles for each platform, widgets can | - | ||||||||||||||||||||||||||||||||||||
813 | also be styled according to rules specified in a \l{styleSheet} | - | ||||||||||||||||||||||||||||||||||||
814 | {style sheet}. This feature enables you to customize the appearance of | - | ||||||||||||||||||||||||||||||||||||
815 | specific widgets to provide visual cues to users about their purpose. For | - | ||||||||||||||||||||||||||||||||||||
816 | example, a button could be styled in a particular way to indicate that it | - | ||||||||||||||||||||||||||||||||||||
817 | performs a destructive action. | - | ||||||||||||||||||||||||||||||||||||
818 | - | |||||||||||||||||||||||||||||||||||||
819 | The use of widget style sheets is described in more detail in the | - | ||||||||||||||||||||||||||||||||||||
820 | \l{Qt Style Sheets} document. | - | ||||||||||||||||||||||||||||||||||||
821 | - | |||||||||||||||||||||||||||||||||||||
822 | - | |||||||||||||||||||||||||||||||||||||
823 | \section1 Transparency and Double Buffering | - | ||||||||||||||||||||||||||||||||||||
824 | - | |||||||||||||||||||||||||||||||||||||
825 | Since Qt 4.0, QWidget automatically double-buffers its painting, so there | - | ||||||||||||||||||||||||||||||||||||
826 | is no need to write double-buffering code in paintEvent() to avoid | - | ||||||||||||||||||||||||||||||||||||
827 | flicker. | - | ||||||||||||||||||||||||||||||||||||
828 | - | |||||||||||||||||||||||||||||||||||||
829 | Since Qt 4.1, the Qt::WA_ContentsPropagated widget attribute has been | - | ||||||||||||||||||||||||||||||||||||
830 | deprecated. Instead, the contents of parent widgets are propagated by | - | ||||||||||||||||||||||||||||||||||||
831 | default to each of their children as long as Qt::WA_PaintOnScreen is not | - | ||||||||||||||||||||||||||||||||||||
832 | set. Custom widgets can be written to take advantage of this feature by | - | ||||||||||||||||||||||||||||||||||||
833 | updating irregular regions (to create non-rectangular child widgets), or | - | ||||||||||||||||||||||||||||||||||||
834 | painting with colors that have less than full alpha component. The | - | ||||||||||||||||||||||||||||||||||||
835 | following diagram shows how attributes and properties of a custom widget | - | ||||||||||||||||||||||||||||||||||||
836 | can be fine-tuned to achieve different effects. | - | ||||||||||||||||||||||||||||||||||||
837 | - | |||||||||||||||||||||||||||||||||||||
838 | \image propagation-custom.png | - | ||||||||||||||||||||||||||||||||||||
839 | - | |||||||||||||||||||||||||||||||||||||
840 | In the above diagram, a semi-transparent rectangular child widget with an | - | ||||||||||||||||||||||||||||||||||||
841 | area removed is constructed and added to a parent widget (a QLabel showing | - | ||||||||||||||||||||||||||||||||||||
842 | a pixmap). Then, different properties and widget attributes are set to | - | ||||||||||||||||||||||||||||||||||||
843 | achieve different effects: | - | ||||||||||||||||||||||||||||||||||||
844 | - | |||||||||||||||||||||||||||||||||||||
845 | \list | - | ||||||||||||||||||||||||||||||||||||
846 | \li The left widget has no additional properties or widget attributes | - | ||||||||||||||||||||||||||||||||||||
847 | set. This default state suits most custom widgets using | - | ||||||||||||||||||||||||||||||||||||
848 | transparency, are irregularly-shaped, or do not paint over their | - | ||||||||||||||||||||||||||||||||||||
849 | entire area with an opaque brush. | - | ||||||||||||||||||||||||||||||||||||
850 | \li The center widget has the \l autoFillBackground property set. This | - | ||||||||||||||||||||||||||||||||||||
851 | property is used with custom widgets that rely on the widget to | - | ||||||||||||||||||||||||||||||||||||
852 | supply a default background, and do not paint over their entire | - | ||||||||||||||||||||||||||||||||||||
853 | area with an opaque brush. | - | ||||||||||||||||||||||||||||||||||||
854 | \li The right widget has the Qt::WA_OpaquePaintEvent widget attribute | - | ||||||||||||||||||||||||||||||||||||
855 | set. This indicates that the widget will paint over its entire area | - | ||||||||||||||||||||||||||||||||||||
856 | with opaque colors. The widget's area will initially be | - | ||||||||||||||||||||||||||||||||||||
857 | \e{uninitialized}, represented in the diagram with a red diagonal | - | ||||||||||||||||||||||||||||||||||||
858 | grid pattern that shines through the overpainted area. The | - | ||||||||||||||||||||||||||||||||||||
859 | Qt::WA_OpaquePaintArea attribute is useful for widgets that need to | - | ||||||||||||||||||||||||||||||||||||
860 | paint their own specialized contents quickly and do not need a | - | ||||||||||||||||||||||||||||||||||||
861 | default filled background. | - | ||||||||||||||||||||||||||||||||||||
862 | \endlist | - | ||||||||||||||||||||||||||||||||||||
863 | - | |||||||||||||||||||||||||||||||||||||
864 | To rapidly update custom widgets with simple background colors, such as | - | ||||||||||||||||||||||||||||||||||||
865 | real-time plotting or graphing widgets, it is better to define a suitable | - | ||||||||||||||||||||||||||||||||||||
866 | background color (using setBackgroundRole() with the | - | ||||||||||||||||||||||||||||||||||||
867 | QPalette::Window role), set the \l autoFillBackground property, and only | - | ||||||||||||||||||||||||||||||||||||
868 | implement the necessary drawing functionality in the widget's paintEvent(). | - | ||||||||||||||||||||||||||||||||||||
869 | - | |||||||||||||||||||||||||||||||||||||
870 | To rapidly update custom widgets that constantly paint over their entire | - | ||||||||||||||||||||||||||||||||||||
871 | areas with opaque content, e.g., video streaming widgets, it is better to | - | ||||||||||||||||||||||||||||||||||||
872 | set the widget's Qt::WA_OpaquePaintEvent, avoiding any unnecessary overhead | - | ||||||||||||||||||||||||||||||||||||
873 | associated with repainting the widget's background. | - | ||||||||||||||||||||||||||||||||||||
874 | - | |||||||||||||||||||||||||||||||||||||
875 | If a widget has both the Qt::WA_OpaquePaintEvent widget attribute \e{and} | - | ||||||||||||||||||||||||||||||||||||
876 | the \l autoFillBackground property set, the Qt::WA_OpaquePaintEvent | - | ||||||||||||||||||||||||||||||||||||
877 | attribute takes precedence. Depending on your requirements, you should | - | ||||||||||||||||||||||||||||||||||||
878 | choose either one of them. | - | ||||||||||||||||||||||||||||||||||||
879 | - | |||||||||||||||||||||||||||||||||||||
880 | Since Qt 4.1, the contents of parent widgets are also propagated to | - | ||||||||||||||||||||||||||||||||||||
881 | standard Qt widgets. This can lead to some unexpected results if the | - | ||||||||||||||||||||||||||||||||||||
882 | parent widget is decorated in a non-standard way, as shown in the diagram | - | ||||||||||||||||||||||||||||||||||||
883 | below. | - | ||||||||||||||||||||||||||||||||||||
884 | - | |||||||||||||||||||||||||||||||||||||
885 | \image propagation-standard.png | - | ||||||||||||||||||||||||||||||||||||
886 | - | |||||||||||||||||||||||||||||||||||||
887 | The scope for customizing the painting behavior of standard Qt widgets, | - | ||||||||||||||||||||||||||||||||||||
888 | without resorting to subclassing, is slightly less than that possible for | - | ||||||||||||||||||||||||||||||||||||
889 | custom widgets. Usually, the desired appearance of a standard widget can be | - | ||||||||||||||||||||||||||||||||||||
890 | achieved by setting its \l autoFillBackground property. | - | ||||||||||||||||||||||||||||||||||||
891 | - | |||||||||||||||||||||||||||||||||||||
892 | - | |||||||||||||||||||||||||||||||||||||
893 | \section1 Creating Translucent Windows | - | ||||||||||||||||||||||||||||||||||||
894 | - | |||||||||||||||||||||||||||||||||||||
895 | Since Qt 4.5, it has been possible to create windows with translucent regions | - | ||||||||||||||||||||||||||||||||||||
896 | on window systems that support compositing. | - | ||||||||||||||||||||||||||||||||||||
897 | - | |||||||||||||||||||||||||||||||||||||
898 | To enable this feature in a top-level widget, set its Qt::WA_TranslucentBackground | - | ||||||||||||||||||||||||||||||||||||
899 | attribute with setAttribute() and ensure that its background is painted with | - | ||||||||||||||||||||||||||||||||||||
900 | non-opaque colors in the regions you want to be partially transparent. | - | ||||||||||||||||||||||||||||||||||||
901 | - | |||||||||||||||||||||||||||||||||||||
902 | Platform notes: | - | ||||||||||||||||||||||||||||||||||||
903 | - | |||||||||||||||||||||||||||||||||||||
904 | \list | - | ||||||||||||||||||||||||||||||||||||
905 | \li X11: This feature relies on the use of an X server that supports ARGB visuals | - | ||||||||||||||||||||||||||||||||||||
906 | and a compositing window manager. | - | ||||||||||||||||||||||||||||||||||||
907 | \li Windows: The widget needs to have the Qt::FramelessWindowHint window flag set | - | ||||||||||||||||||||||||||||||||||||
908 | for the translucency to work. | - | ||||||||||||||||||||||||||||||||||||
909 | \endlist | - | ||||||||||||||||||||||||||||||||||||
910 | - | |||||||||||||||||||||||||||||||||||||
911 | - | |||||||||||||||||||||||||||||||||||||
912 | \section1 Native Widgets vs Alien Widgets | - | ||||||||||||||||||||||||||||||||||||
913 | - | |||||||||||||||||||||||||||||||||||||
914 | Introduced in Qt 4.4, alien widgets are widgets unknown to the windowing | - | ||||||||||||||||||||||||||||||||||||
915 | system. They do not have a native window handle associated with them. This | - | ||||||||||||||||||||||||||||||||||||
916 | feature significantly speeds up widget painting, resizing, and removes flicker. | - | ||||||||||||||||||||||||||||||||||||
917 | - | |||||||||||||||||||||||||||||||||||||
918 | Should you require the old behavior with native windows, you can choose | - | ||||||||||||||||||||||||||||||||||||
919 | one of the following options: | - | ||||||||||||||||||||||||||||||||||||
920 | - | |||||||||||||||||||||||||||||||||||||
921 | \list 1 | - | ||||||||||||||||||||||||||||||||||||
922 | \li Use the \c{QT_USE_NATIVE_WINDOWS=1} in your environment. | - | ||||||||||||||||||||||||||||||||||||
923 | \li Set the Qt::AA_NativeWindows attribute on your application. All | - | ||||||||||||||||||||||||||||||||||||
924 | widgets will be native widgets. | - | ||||||||||||||||||||||||||||||||||||
925 | \li Set the Qt::WA_NativeWindow attribute on widgets: The widget itself | - | ||||||||||||||||||||||||||||||||||||
926 | and all of its ancestors will become native (unless | - | ||||||||||||||||||||||||||||||||||||
927 | Qt::WA_DontCreateNativeAncestors is set). | - | ||||||||||||||||||||||||||||||||||||
928 | \li Call QWidget::winId to enforce a native window (this implies 3). | - | ||||||||||||||||||||||||||||||||||||
929 | \li Set the Qt::WA_PaintOnScreen attribute to enforce a native window | - | ||||||||||||||||||||||||||||||||||||
930 | (this implies 3). | - | ||||||||||||||||||||||||||||||||||||
931 | \endlist | - | ||||||||||||||||||||||||||||||||||||
932 | - | |||||||||||||||||||||||||||||||||||||
933 | \sa QEvent, QPainter, QGridLayout, QBoxLayout | - | ||||||||||||||||||||||||||||||||||||
934 | - | |||||||||||||||||||||||||||||||||||||
935 | */ | - | ||||||||||||||||||||||||||||||||||||
936 | - | |||||||||||||||||||||||||||||||||||||
937 | QWidgetMapper *QWidgetPrivate::mapper = 0; // widget with wid | - | ||||||||||||||||||||||||||||||||||||
938 | QWidgetSet *QWidgetPrivate::allWidgets = 0; // widgets with no wid | - | ||||||||||||||||||||||||||||||||||||
939 | - | |||||||||||||||||||||||||||||||||||||
940 | - | |||||||||||||||||||||||||||||||||||||
941 | /***************************************************************************** | - | ||||||||||||||||||||||||||||||||||||
942 | QWidget utility functions | - | ||||||||||||||||||||||||||||||||||||
943 | *****************************************************************************/ | - | ||||||||||||||||||||||||||||||||||||
944 | - | |||||||||||||||||||||||||||||||||||||
945 | QRegion qt_dirtyRegion(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
946 | { | - | ||||||||||||||||||||||||||||||||||||
947 | if (!widget)
| 0 | ||||||||||||||||||||||||||||||||||||
948 | return QRegion(); never executed: return QRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
949 | - | |||||||||||||||||||||||||||||||||||||
950 | QWidgetBackingStore *bs = qt_widget_private(widget)->maybeBackingStore(); | - | ||||||||||||||||||||||||||||||||||||
951 | if (!bs)
| 0 | ||||||||||||||||||||||||||||||||||||
952 | return QRegion(); never executed: return QRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
953 | - | |||||||||||||||||||||||||||||||||||||
954 | return bs->dirtyRegion(widget); never executed: return bs->dirtyRegion(widget); | 0 | ||||||||||||||||||||||||||||||||||||
955 | } | - | ||||||||||||||||||||||||||||||||||||
956 | - | |||||||||||||||||||||||||||||||||||||
957 | /***************************************************************************** | - | ||||||||||||||||||||||||||||||||||||
958 | QWidget member functions | - | ||||||||||||||||||||||||||||||||||||
959 | *****************************************************************************/ | - | ||||||||||||||||||||||||||||||||||||
960 | - | |||||||||||||||||||||||||||||||||||||
961 | /* | - | ||||||||||||||||||||||||||||||||||||
962 | Widget state flags: | - | ||||||||||||||||||||||||||||||||||||
963 | \list | - | ||||||||||||||||||||||||||||||||||||
964 | \li Qt::WA_WState_Created The widget has a valid winId(). | - | ||||||||||||||||||||||||||||||||||||
965 | \li Qt::WA_WState_Visible The widget is currently visible. | - | ||||||||||||||||||||||||||||||||||||
966 | \li Qt::WA_WState_Hidden The widget is hidden, i.e. it won't | - | ||||||||||||||||||||||||||||||||||||
967 | become visible unless you call show() on it. Qt::WA_WState_Hidden | - | ||||||||||||||||||||||||||||||||||||
968 | implies !Qt::WA_WState_Visible. | - | ||||||||||||||||||||||||||||||||||||
969 | \li Qt::WA_WState_CompressKeys Compress keyboard events. | - | ||||||||||||||||||||||||||||||||||||
970 | \li Qt::WA_WState_BlockUpdates Repaints and updates are disabled. | - | ||||||||||||||||||||||||||||||||||||
971 | \li Qt::WA_WState_InPaintEvent Currently processing a paint event. | - | ||||||||||||||||||||||||||||||||||||
972 | \li Qt::WA_WState_Reparented The widget has been reparented. | - | ||||||||||||||||||||||||||||||||||||
973 | \li Qt::WA_WState_ConfigPending A configuration (resize/move) event is pending. | - | ||||||||||||||||||||||||||||||||||||
974 | \li Qt::WA_WState_DND (Deprecated) The widget supports drag and drop, see setAcceptDrops(). | - | ||||||||||||||||||||||||||||||||||||
975 | \endlist | - | ||||||||||||||||||||||||||||||||||||
976 | */ | - | ||||||||||||||||||||||||||||||||||||
977 | - | |||||||||||||||||||||||||||||||||||||
978 | struct QWidgetExceptionCleaner | - | ||||||||||||||||||||||||||||||||||||
979 | { | - | ||||||||||||||||||||||||||||||||||||
980 | /* this cleans up when the constructor throws an exception */ | - | ||||||||||||||||||||||||||||||||||||
981 | static inline void cleanup(QWidget *that, QWidgetPrivate *d) | - | ||||||||||||||||||||||||||||||||||||
982 | { | - | ||||||||||||||||||||||||||||||||||||
983 | #ifdef QT_NO_EXCEPTIONS | - | ||||||||||||||||||||||||||||||||||||
984 | Q_UNUSED(that); | - | ||||||||||||||||||||||||||||||||||||
985 | Q_UNUSED(d); | - | ||||||||||||||||||||||||||||||||||||
986 | #else | - | ||||||||||||||||||||||||||||||||||||
987 | QWidgetPrivate::allWidgets->remove(that); | - | ||||||||||||||||||||||||||||||||||||
988 | if (d->focus_next != that) { | - | ||||||||||||||||||||||||||||||||||||
989 | if (d->focus_next) | - | ||||||||||||||||||||||||||||||||||||
990 | d->focus_next->d_func()->focus_prev = d->focus_prev; | - | ||||||||||||||||||||||||||||||||||||
991 | if (d->focus_prev) | - | ||||||||||||||||||||||||||||||||||||
992 | d->focus_prev->d_func()->focus_next = d->focus_next; | - | ||||||||||||||||||||||||||||||||||||
993 | } | - | ||||||||||||||||||||||||||||||||||||
994 | #endif | - | ||||||||||||||||||||||||||||||||||||
995 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
996 | }; | - | ||||||||||||||||||||||||||||||||||||
997 | - | |||||||||||||||||||||||||||||||||||||
998 | /*! | - | ||||||||||||||||||||||||||||||||||||
999 | Constructs a widget which is a child of \a parent, with widget | - | ||||||||||||||||||||||||||||||||||||
1000 | flags set to \a f. | - | ||||||||||||||||||||||||||||||||||||
1001 | - | |||||||||||||||||||||||||||||||||||||
1002 | If \a parent is 0, the new widget becomes a window. If | - | ||||||||||||||||||||||||||||||||||||
1003 | \a parent is another widget, this widget becomes a child window | - | ||||||||||||||||||||||||||||||||||||
1004 | inside \a parent. The new widget is deleted when its \a parent is | - | ||||||||||||||||||||||||||||||||||||
1005 | deleted. | - | ||||||||||||||||||||||||||||||||||||
1006 | - | |||||||||||||||||||||||||||||||||||||
1007 | The widget flags argument, \a f, is normally 0, but it can be set | - | ||||||||||||||||||||||||||||||||||||
1008 | to customize the frame of a window (i.e. \a | - | ||||||||||||||||||||||||||||||||||||
1009 | parent must be 0). To customize the frame, use a value composed | - | ||||||||||||||||||||||||||||||||||||
1010 | from the bitwise OR of any of the \l{Qt::WindowFlags}{window flags}. | - | ||||||||||||||||||||||||||||||||||||
1011 | - | |||||||||||||||||||||||||||||||||||||
1012 | If you add a child widget to an already visible widget you must | - | ||||||||||||||||||||||||||||||||||||
1013 | explicitly show the child to make it visible. | - | ||||||||||||||||||||||||||||||||||||
1014 | - | |||||||||||||||||||||||||||||||||||||
1015 | Note that the X11 version of Qt may not be able to deliver all | - | ||||||||||||||||||||||||||||||||||||
1016 | combinations of style flags on all systems. This is because on | - | ||||||||||||||||||||||||||||||||||||
1017 | X11, Qt can only ask the window manager, and the window manager | - | ||||||||||||||||||||||||||||||||||||
1018 | can override the application's settings. On Windows, Qt can set | - | ||||||||||||||||||||||||||||||||||||
1019 | whatever flags you want. | - | ||||||||||||||||||||||||||||||||||||
1020 | - | |||||||||||||||||||||||||||||||||||||
1021 | \sa windowFlags | - | ||||||||||||||||||||||||||||||||||||
1022 | */ | - | ||||||||||||||||||||||||||||||||||||
1023 | QWidget::QWidget(QWidget *parent, Qt::WindowFlags f) | - | ||||||||||||||||||||||||||||||||||||
1024 | : QObject(*new QWidgetPrivate, 0), QPaintDevice() | - | ||||||||||||||||||||||||||||||||||||
1025 | { | - | ||||||||||||||||||||||||||||||||||||
1026 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1027 | d_func()->init(parent, f); | - | ||||||||||||||||||||||||||||||||||||
1028 | } QT_CATCH(...) { never executed: end of block dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1029 | QWidgetExceptionCleaner::cleanup(this, d_func()); dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1030 | QT_RETHROW; dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1031 | } dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1032 | } | - | ||||||||||||||||||||||||||||||||||||
1033 | - | |||||||||||||||||||||||||||||||||||||
1034 | - | |||||||||||||||||||||||||||||||||||||
1035 | /*! \internal | - | ||||||||||||||||||||||||||||||||||||
1036 | */ | - | ||||||||||||||||||||||||||||||||||||
1037 | QWidget::QWidget(QWidgetPrivate &dd, QWidget* parent, Qt::WindowFlags f) | - | ||||||||||||||||||||||||||||||||||||
1038 | : QObject(dd, 0), QPaintDevice() | - | ||||||||||||||||||||||||||||||||||||
1039 | { | - | ||||||||||||||||||||||||||||||||||||
1040 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1041 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1042 | d->init(parent, f); | - | ||||||||||||||||||||||||||||||||||||
1043 | } QT_CATCH(...) { never executed: end of block dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1044 | QWidgetExceptionCleaner::cleanup(this, d_func()); dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1045 | QT_RETHROW; dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1046 | } dead code: { QWidgetExceptionCleaner::cleanup(this, d_func()); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1047 | } | - | ||||||||||||||||||||||||||||||||||||
1048 | - | |||||||||||||||||||||||||||||||||||||
1049 | /*! | - | ||||||||||||||||||||||||||||||||||||
1050 | \internal | - | ||||||||||||||||||||||||||||||||||||
1051 | */ | - | ||||||||||||||||||||||||||||||||||||
1052 | int QWidget::devType() const | - | ||||||||||||||||||||||||||||||||||||
1053 | { | - | ||||||||||||||||||||||||||||||||||||
1054 | return QInternal::Widget; never executed: return QInternal::Widget; | 0 | ||||||||||||||||||||||||||||||||||||
1055 | } | - | ||||||||||||||||||||||||||||||||||||
1056 | - | |||||||||||||||||||||||||||||||||||||
1057 | - | |||||||||||||||||||||||||||||||||||||
1058 | //### w is a "this" ptr, passed as a param because QWorkspace needs special logic | - | ||||||||||||||||||||||||||||||||||||
1059 | void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
1060 | { | - | ||||||||||||||||||||||||||||||||||||
1061 | bool customize = (flags & (Qt::CustomizeWindowHint | - | ||||||||||||||||||||||||||||||||||||
1062 | | Qt::FramelessWindowHint | - | ||||||||||||||||||||||||||||||||||||
1063 | | Qt::WindowTitleHint | - | ||||||||||||||||||||||||||||||||||||
1064 | | Qt::WindowSystemMenuHint | - | ||||||||||||||||||||||||||||||||||||
1065 | | Qt::WindowMinimizeButtonHint | - | ||||||||||||||||||||||||||||||||||||
1066 | | Qt::WindowMaximizeButtonHint | - | ||||||||||||||||||||||||||||||||||||
1067 | | Qt::WindowCloseButtonHint | - | ||||||||||||||||||||||||||||||||||||
1068 | | Qt::WindowContextHelpButtonHint)); | - | ||||||||||||||||||||||||||||||||||||
1069 | - | |||||||||||||||||||||||||||||||||||||
1070 | uint type = (flags & Qt::WindowType_Mask); | - | ||||||||||||||||||||||||||||||||||||
1071 | - | |||||||||||||||||||||||||||||||||||||
1072 | if ((type == Qt::Widget || type == Qt::SubWindow) && w && !w->parent()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1073 | type = Qt::Window; | - | ||||||||||||||||||||||||||||||||||||
1074 | flags |= Qt::Window; | - | ||||||||||||||||||||||||||||||||||||
1075 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1076 | - | |||||||||||||||||||||||||||||||||||||
1077 | if (flags & Qt::CustomizeWindowHint) {
| 0 | ||||||||||||||||||||||||||||||||||||
1078 | // modify window flags to make them consistent. | - | ||||||||||||||||||||||||||||||||||||
1079 | // Only enable this on non-Mac platforms. Since the old way of doing this would | - | ||||||||||||||||||||||||||||||||||||
1080 | // interpret WindowSystemMenuHint as a close button and we can't change that behavior | - | ||||||||||||||||||||||||||||||||||||
1081 | // we can't just add this in. | - | ||||||||||||||||||||||||||||||||||||
1082 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1083 | if ((flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowContextHelpButtonHint))
| 0 | ||||||||||||||||||||||||||||||||||||
1084 | # ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
1085 | && type != Qt::Dialog // QTBUG-2027, allow for menu-less dialogs. | - | ||||||||||||||||||||||||||||||||||||
1086 | # endif | - | ||||||||||||||||||||||||||||||||||||
1087 | ) { | - | ||||||||||||||||||||||||||||||||||||
1088 | flags |= Qt::WindowSystemMenuHint; | - | ||||||||||||||||||||||||||||||||||||
1089 | #else | - | ||||||||||||||||||||||||||||||||||||
1090 | if (flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | - | ||||||||||||||||||||||||||||||||||||
1091 | | Qt::WindowSystemMenuHint)) { | - | ||||||||||||||||||||||||||||||||||||
1092 | #endif | - | ||||||||||||||||||||||||||||||||||||
1093 | flags |= Qt::WindowTitleHint; | - | ||||||||||||||||||||||||||||||||||||
1094 | flags &= ~Qt::FramelessWindowHint; | - | ||||||||||||||||||||||||||||||||||||
1095 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1096 | } else if (customize && !(flags & Qt::FramelessWindowHint)) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
1097 | // if any of the window hints that affect the titlebar are set | - | ||||||||||||||||||||||||||||||||||||
1098 | // and the window is supposed to have frame, we add a titlebar | - | ||||||||||||||||||||||||||||||||||||
1099 | // and system menu by default. | - | ||||||||||||||||||||||||||||||||||||
1100 | flags |= Qt::WindowSystemMenuHint; | - | ||||||||||||||||||||||||||||||||||||
1101 | flags |= Qt::WindowTitleHint; | - | ||||||||||||||||||||||||||||||||||||
1102 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1103 | if (customize)
| 0 | ||||||||||||||||||||||||||||||||||||
1104 | ; // don't modify window flags if the user explicitly set them. never executed: ; | 0 | ||||||||||||||||||||||||||||||||||||
1105 | else if (type == Qt::Dialog || type == Qt::Sheet)
| 0 | ||||||||||||||||||||||||||||||||||||
1106 | #ifndef Q_OS_WINCE | - | ||||||||||||||||||||||||||||||||||||
1107 | flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint; never executed: flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint; | 0 | ||||||||||||||||||||||||||||||||||||
1108 | #else | - | ||||||||||||||||||||||||||||||||||||
1109 | flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; | - | ||||||||||||||||||||||||||||||||||||
1110 | #endif | - | ||||||||||||||||||||||||||||||||||||
1111 | else if (type == Qt::Tool)
| 0 | ||||||||||||||||||||||||||||||||||||
1112 | flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; never executed: flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; | 0 | ||||||||||||||||||||||||||||||||||||
1113 | else | - | ||||||||||||||||||||||||||||||||||||
1114 | flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | never executed: flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint; | 0 | ||||||||||||||||||||||||||||||||||||
1115 | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint; never executed: flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint; | 0 | ||||||||||||||||||||||||||||||||||||
1116 | if (w->testAttribute(Qt::WA_TransparentForMouseEvents))
| 0 | ||||||||||||||||||||||||||||||||||||
1117 | flags |= Qt::WindowTransparentForInput; never executed: flags |= Qt::WindowTransparentForInput; | 0 | ||||||||||||||||||||||||||||||||||||
1118 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1119 | - | |||||||||||||||||||||||||||||||||||||
1120 | void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) | - | ||||||||||||||||||||||||||||||||||||
1121 | { | - | ||||||||||||||||||||||||||||||||||||
1122 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1123 | if (!qobject_cast<QApplication *>(QCoreApplication::instance()))
| 0 | ||||||||||||||||||||||||||||||||||||
1124 | qFatal("QWidget: Cannot create a QWidget without QApplication"); never executed: QMessageLogger(__FILE__, 1124, __PRETTY_FUNCTION__).fatal("QWidget: Cannot create a QWidget without QApplication"); | 0 | ||||||||||||||||||||||||||||||||||||
1125 | - | |||||||||||||||||||||||||||||||||||||
1126 | Q_ASSERT(allWidgets); | - | ||||||||||||||||||||||||||||||||||||
1127 | if (allWidgets)
| 0 | ||||||||||||||||||||||||||||||||||||
1128 | allWidgets->insert(q); never executed: allWidgets->insert(q); | 0 | ||||||||||||||||||||||||||||||||||||
1129 | - | |||||||||||||||||||||||||||||||||||||
1130 | int targetScreen = -1; | - | ||||||||||||||||||||||||||||||||||||
1131 | if (parentWidget && parentWidget->windowType() == Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
1132 | const QDesktopScreenWidget *sw = qobject_cast<const QDesktopScreenWidget *>(parentWidget); | - | ||||||||||||||||||||||||||||||||||||
1133 | targetScreen = sw ? sw->screenNumber() : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
1134 | parentWidget = 0; | - | ||||||||||||||||||||||||||||||||||||
1135 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1136 | - | |||||||||||||||||||||||||||||||||||||
1137 | q->data = &data; | - | ||||||||||||||||||||||||||||||||||||
1138 | - | |||||||||||||||||||||||||||||||||||||
1139 | #ifndef QT_NO_THREAD | - | ||||||||||||||||||||||||||||||||||||
1140 | if (!parent) {
| 0 | ||||||||||||||||||||||||||||||||||||
1141 | Q_ASSERT_X(q->thread() == qApp->thread(), "QWidget", | - | ||||||||||||||||||||||||||||||||||||
1142 | "Widgets must be created in the GUI thread."); | - | ||||||||||||||||||||||||||||||||||||
1143 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1144 | #endif | - | ||||||||||||||||||||||||||||||||||||
1145 | - | |||||||||||||||||||||||||||||||||||||
1146 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
1147 | if (desktopWidget) { | - | ||||||||||||||||||||||||||||||||||||
1148 | // make sure the widget is created on the same screen as the | - | ||||||||||||||||||||||||||||||||||||
1149 | // programmer specified desktop widget | - | ||||||||||||||||||||||||||||||||||||
1150 | xinfo = desktopWidget->d_func()->xinfo; | - | ||||||||||||||||||||||||||||||||||||
1151 | } | - | ||||||||||||||||||||||||||||||||||||
1152 | #endif | - | ||||||||||||||||||||||||||||||||||||
1153 | if (targetScreen >= 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
1154 | topData()->initialScreenIndex = targetScreen; | - | ||||||||||||||||||||||||||||||||||||
1155 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
1156 | window->setScreen(QGuiApplication::screens().value(targetScreen, Q_NULLPTR)); never executed: window->setScreen(QGuiApplication::screens().value(targetScreen, nullptr)); | 0 | ||||||||||||||||||||||||||||||||||||
1157 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1158 | - | |||||||||||||||||||||||||||||||||||||
1159 | data.fstrut_dirty = true; | - | ||||||||||||||||||||||||||||||||||||
1160 | - | |||||||||||||||||||||||||||||||||||||
1161 | data.winid = 0; | - | ||||||||||||||||||||||||||||||||||||
1162 | data.widget_attributes = 0; | - | ||||||||||||||||||||||||||||||||||||
1163 | data.window_flags = f; | - | ||||||||||||||||||||||||||||||||||||
1164 | data.window_state = 0; | - | ||||||||||||||||||||||||||||||||||||
1165 | data.focus_policy = 0; | - | ||||||||||||||||||||||||||||||||||||
1166 | data.context_menu_policy = Qt::DefaultContextMenu; | - | ||||||||||||||||||||||||||||||||||||
1167 | data.window_modality = Qt::NonModal; | - | ||||||||||||||||||||||||||||||||||||
1168 | - | |||||||||||||||||||||||||||||||||||||
1169 | data.sizehint_forced = 0; | - | ||||||||||||||||||||||||||||||||||||
1170 | data.is_closing = 0; | - | ||||||||||||||||||||||||||||||||||||
1171 | data.in_show = 0; | - | ||||||||||||||||||||||||||||||||||||
1172 | data.in_set_window_state = 0; | - | ||||||||||||||||||||||||||||||||||||
1173 | data.in_destructor = false; | - | ||||||||||||||||||||||||||||||||||||
1174 | - | |||||||||||||||||||||||||||||||||||||
1175 | // Widgets with Qt::MSWindowsOwnDC (typically QGLWidget) must have a window handle. | - | ||||||||||||||||||||||||||||||||||||
1176 | if (f & Qt::MSWindowsOwnDC) {
| 0 | ||||||||||||||||||||||||||||||||||||
1177 | mustHaveWindowHandle = 1; | - | ||||||||||||||||||||||||||||||||||||
1178 | q->setAttribute(Qt::WA_NativeWindow); | - | ||||||||||||||||||||||||||||||||||||
1179 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1180 | //#ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1181 | // q->setAttribute(Qt::WA_NativeWindow); | - | ||||||||||||||||||||||||||||||||||||
1182 | //#endif | - | ||||||||||||||||||||||||||||||||||||
1183 | - | |||||||||||||||||||||||||||||||||||||
1184 | q->setAttribute(Qt::WA_QuitOnClose); // might be cleared in adjustQuitOnCloseAttribute() | - | ||||||||||||||||||||||||||||||||||||
1185 | adjustQuitOnCloseAttribute(); | - | ||||||||||||||||||||||||||||||||||||
1186 | - | |||||||||||||||||||||||||||||||||||||
1187 | q->setAttribute(Qt::WA_WState_Hidden); | - | ||||||||||||||||||||||||||||||||||||
1188 | - | |||||||||||||||||||||||||||||||||||||
1189 | //give potential windows a bigger "pre-initial" size; create_sys() will give them a new size later | - | ||||||||||||||||||||||||||||||||||||
1190 | data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480);
| 0 | ||||||||||||||||||||||||||||||||||||
1191 | focus_next = focus_prev = q; | - | ||||||||||||||||||||||||||||||||||||
1192 | - | |||||||||||||||||||||||||||||||||||||
1193 | if ((f & Qt::WindowType_Mask) == Qt::Desktop)
| 0 | ||||||||||||||||||||||||||||||||||||
1194 | q->create(); never executed: q->create(); | 0 | ||||||||||||||||||||||||||||||||||||
1195 | else if (parentWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
1196 | q->setParent(parentWidget, data.window_flags); never executed: q->setParent(parentWidget, data.window_flags); | 0 | ||||||||||||||||||||||||||||||||||||
1197 | else { | - | ||||||||||||||||||||||||||||||||||||
1198 | adjustFlags(data.window_flags, q); | - | ||||||||||||||||||||||||||||||||||||
1199 | resolveLayoutDirection(); | - | ||||||||||||||||||||||||||||||||||||
1200 | // opaque system background? | - | ||||||||||||||||||||||||||||||||||||
1201 | const QBrush &background = q->palette().brush(QPalette::Window); | - | ||||||||||||||||||||||||||||||||||||
1202 | setOpaque(q->isWindow() && background.style() != Qt::NoBrush && background.isOpaque()); | - | ||||||||||||||||||||||||||||||||||||
1203 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1204 | data.fnt = QFont(data.fnt, q); | - | ||||||||||||||||||||||||||||||||||||
1205 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
1206 | data.fnt.x11SetScreen(xinfo.screen()); | - | ||||||||||||||||||||||||||||||||||||
1207 | #endif // Q_DEAD_CODE_FROM_QT4_X11 | - | ||||||||||||||||||||||||||||||||||||
1208 | - | |||||||||||||||||||||||||||||||||||||
1209 | q->setAttribute(Qt::WA_PendingMoveEvent); | - | ||||||||||||||||||||||||||||||||||||
1210 | q->setAttribute(Qt::WA_PendingResizeEvent); | - | ||||||||||||||||||||||||||||||||||||
1211 | - | |||||||||||||||||||||||||||||||||||||
1212 | if (++QWidgetPrivate::instanceCounter > QWidgetPrivate::maxInstances)
| 0 | ||||||||||||||||||||||||||||||||||||
1213 | QWidgetPrivate::maxInstances = QWidgetPrivate::instanceCounter; never executed: QWidgetPrivate::maxInstances = QWidgetPrivate::instanceCounter; | 0 | ||||||||||||||||||||||||||||||||||||
1214 | - | |||||||||||||||||||||||||||||||||||||
1215 | if (QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation)) // ### fixme: Qt 6: Remove AA_ImmediateWidgetCreation.
| 0 | ||||||||||||||||||||||||||||||||||||
1216 | q->create(); never executed: q->create(); | 0 | ||||||||||||||||||||||||||||||||||||
1217 | - | |||||||||||||||||||||||||||||||||||||
1218 | QEvent e(QEvent::Create); | - | ||||||||||||||||||||||||||||||||||||
1219 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
1220 | QApplication::postEvent(q, new QEvent(QEvent::PolishRequest)); | - | ||||||||||||||||||||||||||||||||||||
1221 | - | |||||||||||||||||||||||||||||||||||||
1222 | extraPaintEngine = 0; | - | ||||||||||||||||||||||||||||||||||||
1223 | - | |||||||||||||||||||||||||||||||||||||
1224 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1225 | // If we add a child to the unified toolbar, we have to redirect the painting. | - | ||||||||||||||||||||||||||||||||||||
1226 | if (parentWidget && parentWidget->d_func() && parentWidget->d_func()->isInUnifiedToolbar) { | - | ||||||||||||||||||||||||||||||||||||
1227 | if (parentWidget->d_func()->unifiedSurface) { | - | ||||||||||||||||||||||||||||||||||||
1228 | QWidget *toolbar = parentWidget->d_func()->toolbar_ancestor; | - | ||||||||||||||||||||||||||||||||||||
1229 | parentWidget->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset); | - | ||||||||||||||||||||||||||||||||||||
1230 | } | - | ||||||||||||||||||||||||||||||||||||
1231 | } | - | ||||||||||||||||||||||||||||||||||||
1232 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1233 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1234 | - | |||||||||||||||||||||||||||||||||||||
1235 | - | |||||||||||||||||||||||||||||||||||||
1236 | - | |||||||||||||||||||||||||||||||||||||
1237 | void QWidgetPrivate::createRecursively() | - | ||||||||||||||||||||||||||||||||||||
1238 | { | - | ||||||||||||||||||||||||||||||||||||
1239 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1240 | q->create(0, true, true); | - | ||||||||||||||||||||||||||||||||||||
1241 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
1242 | QWidget *child = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
1243 | if (child && !child->isHidden() && !child->isWindow() && !child->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
1244 | child->d_func()->createRecursively(); never executed: child->d_func()->createRecursively(); | 0 | ||||||||||||||||||||||||||||||||||||
1245 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1246 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1247 | - | |||||||||||||||||||||||||||||||||||||
1248 | - | |||||||||||||||||||||||||||||||||||||
1249 | // ### fixme: Qt 6: Remove parameter window from QWidget::create() | - | ||||||||||||||||||||||||||||||||||||
1250 | - | |||||||||||||||||||||||||||||||||||||
1251 | /*! | - | ||||||||||||||||||||||||||||||||||||
1252 | Creates a new widget window. | - | ||||||||||||||||||||||||||||||||||||
1253 | - | |||||||||||||||||||||||||||||||||||||
1254 | The parameter \a window is ignored in Qt 5. Please use | - | ||||||||||||||||||||||||||||||||||||
1255 | QWindow::fromWinId() to create a QWindow wrapping a foreign | - | ||||||||||||||||||||||||||||||||||||
1256 | window and pass it to QWidget::createWindowContainer() instead. | - | ||||||||||||||||||||||||||||||||||||
1257 | - | |||||||||||||||||||||||||||||||||||||
1258 | Initializes the window (sets the geometry etc.) if \a | - | ||||||||||||||||||||||||||||||||||||
1259 | initializeWindow is true. If \a initializeWindow is false, no | - | ||||||||||||||||||||||||||||||||||||
1260 | initialization is performed. This parameter only makes sense if \a | - | ||||||||||||||||||||||||||||||||||||
1261 | window is a valid window. | - | ||||||||||||||||||||||||||||||||||||
1262 | - | |||||||||||||||||||||||||||||||||||||
1263 | Destroys the old window if \a destroyOldWindow is true. If \a | - | ||||||||||||||||||||||||||||||||||||
1264 | destroyOldWindow is false, you are responsible for destroying the | - | ||||||||||||||||||||||||||||||||||||
1265 | window yourself (using platform native code). | - | ||||||||||||||||||||||||||||||||||||
1266 | - | |||||||||||||||||||||||||||||||||||||
1267 | The QWidget constructor calls create(0,true,true) to create a | - | ||||||||||||||||||||||||||||||||||||
1268 | window for this widget. | - | ||||||||||||||||||||||||||||||||||||
1269 | - | |||||||||||||||||||||||||||||||||||||
1270 | \sa createWindowContainer(), QWindow::fromWinId() | - | ||||||||||||||||||||||||||||||||||||
1271 | */ | - | ||||||||||||||||||||||||||||||||||||
1272 | - | |||||||||||||||||||||||||||||||||||||
1273 | void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) | - | ||||||||||||||||||||||||||||||||||||
1274 | { | - | ||||||||||||||||||||||||||||||||||||
1275 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1276 | if (Q_UNLIKELY(window))
| 0 | ||||||||||||||||||||||||||||||||||||
1277 | qWarning("QWidget::create(): Parameter 'window' does not have any effect."); never executed: QMessageLogger(__FILE__, 1277, __PRETTY_FUNCTION__).warning("QWidget::create(): Parameter 'window' does not have any effect."); | 0 | ||||||||||||||||||||||||||||||||||||
1278 | if (testAttribute(Qt::WA_WState_Created) && window == 0 && internalWinId())
| 0 | ||||||||||||||||||||||||||||||||||||
1279 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
1280 | - | |||||||||||||||||||||||||||||||||||||
1281 | if (d->data.in_destructor)
| 0 | ||||||||||||||||||||||||||||||||||||
1282 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
1283 | - | |||||||||||||||||||||||||||||||||||||
1284 | Qt::WindowType type = windowType(); | - | ||||||||||||||||||||||||||||||||||||
1285 | Qt::WindowFlags &flags = data->window_flags; | - | ||||||||||||||||||||||||||||||||||||
1286 | - | |||||||||||||||||||||||||||||||||||||
1287 | if ((type == Qt::Widget || type == Qt::SubWindow) && !parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1288 | type = Qt::Window; | - | ||||||||||||||||||||||||||||||||||||
1289 | flags |= Qt::Window; | - | ||||||||||||||||||||||||||||||||||||
1290 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1291 | - | |||||||||||||||||||||||||||||||||||||
1292 | if (QWidget *parent = parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1293 | if (type & Qt::Window) {
| 0 | ||||||||||||||||||||||||||||||||||||
1294 | if (!parent->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
1295 | parent->createWinId(); never executed: parent->createWinId(); | 0 | ||||||||||||||||||||||||||||||||||||
1296 | } else if (testAttribute(Qt::WA_NativeWindow) && !parent->internalWinId() never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
1297 | && !testAttribute(Qt::WA_DontCreateNativeAncestors)) {
| 0 | ||||||||||||||||||||||||||||||||||||
1298 | // We're about to create a native child widget that doesn't have a native parent; | - | ||||||||||||||||||||||||||||||||||||
1299 | // enforce a native handle for the parent unless the Qt::WA_DontCreateNativeAncestors | - | ||||||||||||||||||||||||||||||||||||
1300 | // attribute is set. | - | ||||||||||||||||||||||||||||||||||||
1301 | d->createWinId(); | - | ||||||||||||||||||||||||||||||||||||
1302 | // Nothing more to do. | - | ||||||||||||||||||||||||||||||||||||
1303 | Q_ASSERT(testAttribute(Qt::WA_WState_Created)); | - | ||||||||||||||||||||||||||||||||||||
1304 | Q_ASSERT(internalWinId()); | - | ||||||||||||||||||||||||||||||||||||
1305 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
1306 | } | - | ||||||||||||||||||||||||||||||||||||
1307 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1308 | - | |||||||||||||||||||||||||||||||||||||
1309 | - | |||||||||||||||||||||||||||||||||||||
1310 | static const bool paintOnScreenEnv = qEnvironmentVariableIntValue("QT_ONSCREEN_PAINT") > 0; | - | ||||||||||||||||||||||||||||||||||||
1311 | if (paintOnScreenEnv)
| 0 | ||||||||||||||||||||||||||||||||||||
1312 | setAttribute(Qt::WA_PaintOnScreen); never executed: setAttribute(Qt::WA_PaintOnScreen); | 0 | ||||||||||||||||||||||||||||||||||||
1313 | - | |||||||||||||||||||||||||||||||||||||
1314 | if (QApplicationPrivate::testAttribute(Qt::AA_NativeWindows))
| 0 | ||||||||||||||||||||||||||||||||||||
1315 | setAttribute(Qt::WA_NativeWindow); never executed: setAttribute(Qt::WA_NativeWindow); | 0 | ||||||||||||||||||||||||||||||||||||
1316 | - | |||||||||||||||||||||||||||||||||||||
1317 | #ifdef ALIEN_DEBUG | - | ||||||||||||||||||||||||||||||||||||
1318 | qDebug() << "QWidget::create:" << this << "parent:" << parentWidget() | - | ||||||||||||||||||||||||||||||||||||
1319 | << "Alien?" << !testAttribute(Qt::WA_NativeWindow); | - | ||||||||||||||||||||||||||||||||||||
1320 | #endif | - | ||||||||||||||||||||||||||||||||||||
1321 | - | |||||||||||||||||||||||||||||||||||||
1322 | #if defined (Q_DEAD_CODE_FROM_QT4_WIN) && !defined(QT_NO_DRAGANDDROP) | - | ||||||||||||||||||||||||||||||||||||
1323 | // Unregister the dropsite (if already registered) before we | - | ||||||||||||||||||||||||||||||||||||
1324 | // re-create the widget with a native window. | - | ||||||||||||||||||||||||||||||||||||
1325 | if (testAttribute(Qt::WA_WState_Created) && !internalWinId() && testAttribute(Qt::WA_NativeWindow) | - | ||||||||||||||||||||||||||||||||||||
1326 | && d->extra && d->extra->dropTarget) { | - | ||||||||||||||||||||||||||||||||||||
1327 | d->registerDropSite(false); | - | ||||||||||||||||||||||||||||||||||||
1328 | } | - | ||||||||||||||||||||||||||||||||||||
1329 | #endif // defined (Q_DEAD_CODE_FROM_QT4_WIN) && !defined(QT_NO_DRAGANDDROP) | - | ||||||||||||||||||||||||||||||||||||
1330 | - | |||||||||||||||||||||||||||||||||||||
1331 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
1332 | - | |||||||||||||||||||||||||||||||||||||
1333 | setAttribute(Qt::WA_WState_Created); // set created flag | - | ||||||||||||||||||||||||||||||||||||
1334 | d->create_sys(window, initializeWindow, destroyOldWindow); | - | ||||||||||||||||||||||||||||||||||||
1335 | - | |||||||||||||||||||||||||||||||||||||
1336 | // a real toplevel window needs a backing store | - | ||||||||||||||||||||||||||||||||||||
1337 | if (isWindow() && windowType() != Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
1338 | d->topData()->backingStoreTracker.destroy(); | - | ||||||||||||||||||||||||||||||||||||
1339 | if (hasBackingStoreSupport())
| 0 | ||||||||||||||||||||||||||||||||||||
1340 | d->topData()->backingStoreTracker.create(this); never executed: d->topData()->backingStoreTracker.create(this); | 0 | ||||||||||||||||||||||||||||||||||||
1341 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1342 | - | |||||||||||||||||||||||||||||||||||||
1343 | d->setModal_sys(); | - | ||||||||||||||||||||||||||||||||||||
1344 | - | |||||||||||||||||||||||||||||||||||||
1345 | if (!isWindow() && parentWidget() && parentWidget()->testAttribute(Qt::WA_DropSiteRegistered))
| 0 | ||||||||||||||||||||||||||||||||||||
1346 | setAttribute(Qt::WA_DropSiteRegistered, true); never executed: setAttribute(Qt::WA_DropSiteRegistered, true); | 0 | ||||||||||||||||||||||||||||||||||||
1347 | - | |||||||||||||||||||||||||||||||||||||
1348 | #ifdef QT_EVAL | - | ||||||||||||||||||||||||||||||||||||
1349 | extern void qt_eval_init_widget(QWidget *w); | - | ||||||||||||||||||||||||||||||||||||
1350 | qt_eval_init_widget(this); | - | ||||||||||||||||||||||||||||||||||||
1351 | #endif | - | ||||||||||||||||||||||||||||||||||||
1352 | - | |||||||||||||||||||||||||||||||||||||
1353 | // need to force the resting of the icon after changing parents | - | ||||||||||||||||||||||||||||||||||||
1354 | if (testAttribute(Qt::WA_SetWindowIcon))
| 0 | ||||||||||||||||||||||||||||||||||||
1355 | d->setWindowIcon_sys(); never executed: d->setWindowIcon_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
1356 | - | |||||||||||||||||||||||||||||||||||||
1357 | if (isWindow() && !d->topData()->iconText.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
1358 | d->setWindowIconText_helper(d->topData()->iconText); never executed: d->setWindowIconText_helper(d->topData()->iconText); | 0 | ||||||||||||||||||||||||||||||||||||
1359 | if (isWindow() && !d->topData()->caption.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
1360 | d->setWindowTitle_helper(d->topData()->caption); never executed: d->setWindowTitle_helper(d->topData()->caption); | 0 | ||||||||||||||||||||||||||||||||||||
1361 | if (windowType() != Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
1362 | d->updateSystemBackground(); | - | ||||||||||||||||||||||||||||||||||||
1363 | - | |||||||||||||||||||||||||||||||||||||
1364 | if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon))
| 0 | ||||||||||||||||||||||||||||||||||||
1365 | d->setWindowIcon_sys(); never executed: d->setWindowIcon_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
1366 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1367 | - | |||||||||||||||||||||||||||||||||||||
1368 | // Frame strut update needed in cases where there are native widgets such as QGLWidget, | - | ||||||||||||||||||||||||||||||||||||
1369 | // as those force native window creation on their ancestors before they are shown. | - | ||||||||||||||||||||||||||||||||||||
1370 | // If the strut is not updated, any subsequent move of the top level window before show | - | ||||||||||||||||||||||||||||||||||||
1371 | // will cause window frame to be ignored when positioning the window. | - | ||||||||||||||||||||||||||||||||||||
1372 | // Note that this only helps on platforms that handle window creation synchronously. | - | ||||||||||||||||||||||||||||||||||||
1373 | d->updateFrameStrut(); | - | ||||||||||||||||||||||||||||||||||||
1374 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1375 | - | |||||||||||||||||||||||||||||||||||||
1376 | void q_createNativeChildrenAndSetParent(const QWidget *parentWidget) | - | ||||||||||||||||||||||||||||||||||||
1377 | { | - | ||||||||||||||||||||||||||||||||||||
1378 | QObjectList children = parentWidget->children(); | - | ||||||||||||||||||||||||||||||||||||
1379 | for (int i = 0; i < children.size(); i++) {
| 0 | ||||||||||||||||||||||||||||||||||||
1380 | if (children.at(i)->isWidgetType()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1381 | const QWidget *childWidget = qobject_cast<const QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
1382 | if (childWidget) { // should not be necessary
| 0 | ||||||||||||||||||||||||||||||||||||
1383 | if (childWidget->testAttribute(Qt::WA_NativeWindow)) {
| 0 | ||||||||||||||||||||||||||||||||||||
1384 | if (!childWidget->internalWinId())
| 0 | ||||||||||||||||||||||||||||||||||||
1385 | childWidget->winId(); never executed: childWidget->winId(); | 0 | ||||||||||||||||||||||||||||||||||||
1386 | if (childWidget->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1387 | if (childWidget->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1388 | childWidget->windowHandle()->setTransientParent(parentWidget->window()->windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
1389 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1390 | childWidget->windowHandle()->setParent(childWidget->nativeParentWidget()->windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
1391 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1392 | } | - | ||||||||||||||||||||||||||||||||||||
1393 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1394 | q_createNativeChildrenAndSetParent(childWidget); | - | ||||||||||||||||||||||||||||||||||||
1395 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1396 | } | - | ||||||||||||||||||||||||||||||||||||
1397 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1398 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1399 | - | |||||||||||||||||||||||||||||||||||||
1400 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1401 | - | |||||||||||||||||||||||||||||||||||||
1402 | void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow) | - | ||||||||||||||||||||||||||||||||||||
1403 | { | - | ||||||||||||||||||||||||||||||||||||
1404 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1405 | - | |||||||||||||||||||||||||||||||||||||
1406 | Q_UNUSED(window); | - | ||||||||||||||||||||||||||||||||||||
1407 | Q_UNUSED(initializeWindow); | - | ||||||||||||||||||||||||||||||||||||
1408 | Q_UNUSED(destroyOldWindow); | - | ||||||||||||||||||||||||||||||||||||
1409 | - | |||||||||||||||||||||||||||||||||||||
1410 | Qt::WindowFlags flags = data.window_flags; | - | ||||||||||||||||||||||||||||||||||||
1411 | - | |||||||||||||||||||||||||||||||||||||
1412 | if (!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
1413 | return; // we only care about real toplevels never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
1414 | - | |||||||||||||||||||||||||||||||||||||
1415 | QWindow *win = topData()->window; | - | ||||||||||||||||||||||||||||||||||||
1416 | // topData() ensures the extra is created but does not ensure 'window' is non-null | - | ||||||||||||||||||||||||||||||||||||
1417 | // in case the extra was already valid. | - | ||||||||||||||||||||||||||||||||||||
1418 | if (!win) {
| 0 | ||||||||||||||||||||||||||||||||||||
1419 | createTLSysExtra(); | - | ||||||||||||||||||||||||||||||||||||
1420 | win = topData()->window; | - | ||||||||||||||||||||||||||||||||||||
1421 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1422 | - | |||||||||||||||||||||||||||||||||||||
1423 | foreach (const QByteArray &propertyName, q->dynamicPropertyNames()) { | - | ||||||||||||||||||||||||||||||||||||
1424 | if (!qstrncmp(propertyName, "_q_platform_", 12))
| 0 | ||||||||||||||||||||||||||||||||||||
1425 | win->setProperty(propertyName, q->property(propertyName)); never executed: win->setProperty(propertyName, q->property(propertyName)); | 0 | ||||||||||||||||||||||||||||||||||||
1426 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1427 | - | |||||||||||||||||||||||||||||||||||||
1428 | if (q->testAttribute(Qt::WA_ShowWithoutActivating))
| 0 | ||||||||||||||||||||||||||||||||||||
1429 | win->setProperty("_q_showWithoutActivating", QVariant(true)); never executed: win->setProperty("_q_showWithoutActivating", QVariant(true)); | 0 | ||||||||||||||||||||||||||||||||||||
1430 | if (q->testAttribute(Qt::WA_MacAlwaysShowToolWindow))
| 0 | ||||||||||||||||||||||||||||||||||||
1431 | win->setProperty("_q_macAlwaysShowToolWindow", QVariant::fromValue(QVariant(true))); never executed: win->setProperty("_q_macAlwaysShowToolWindow", QVariant::fromValue(QVariant(true))); | 0 | ||||||||||||||||||||||||||||||||||||
1432 | setNetWmWindowTypes(true); // do nothing if none of WA_X11NetWmWindowType* is set | - | ||||||||||||||||||||||||||||||||||||
1433 | win->setFlags(data.window_flags); | - | ||||||||||||||||||||||||||||||||||||
1434 | fixPosIncludesFrame(); | - | ||||||||||||||||||||||||||||||||||||
1435 | if (q->testAttribute(Qt::WA_Moved)
| 0 | ||||||||||||||||||||||||||||||||||||
1436 | || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowManagement))
| 0 | ||||||||||||||||||||||||||||||||||||
1437 | win->setGeometry(q->geometry()); never executed: win->setGeometry(q->geometry()); | 0 | ||||||||||||||||||||||||||||||||||||
1438 | else | - | ||||||||||||||||||||||||||||||||||||
1439 | win->resize(q->size()); never executed: win->resize(q->size()); | 0 | ||||||||||||||||||||||||||||||||||||
1440 | if (win->isTopLevel()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1441 | int screenNumber = topData()->initialScreenIndex; | - | ||||||||||||||||||||||||||||||||||||
1442 | topData()->initialScreenIndex = -1; | - | ||||||||||||||||||||||||||||||||||||
1443 | if (screenNumber < 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
1444 | screenNumber = q->windowType() != Qt::Desktop
| 0 | ||||||||||||||||||||||||||||||||||||
1445 | ? QApplication::desktop()->screenNumber(q) : 0; | - | ||||||||||||||||||||||||||||||||||||
1446 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1447 | win->setScreen(QGuiApplication::screens().value(screenNumber, Q_NULLPTR)); | - | ||||||||||||||||||||||||||||||||||||
1448 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1449 | - | |||||||||||||||||||||||||||||||||||||
1450 | QSurfaceFormat format = win->requestedFormat(); | - | ||||||||||||||||||||||||||||||||||||
1451 | if ((flags & Qt::Window) && win->surfaceType() != QSurface::OpenGLSurface
| 0 | ||||||||||||||||||||||||||||||||||||
1452 | && q->testAttribute(Qt::WA_TranslucentBackground)) {
| 0 | ||||||||||||||||||||||||||||||||||||
1453 | format.setAlphaBufferSize(8); | - | ||||||||||||||||||||||||||||||||||||
1454 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1455 | win->setFormat(format); | - | ||||||||||||||||||||||||||||||||||||
1456 | - | |||||||||||||||||||||||||||||||||||||
1457 | if (QWidget *nativeParent = q->nativeParentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1458 | if (nativeParent->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1459 | if (flags & Qt::Window) {
| 0 | ||||||||||||||||||||||||||||||||||||
1460 | win->setTransientParent(nativeParent->window()->windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
1461 | win->setParent(0); | - | ||||||||||||||||||||||||||||||||||||
1462 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1463 | win->setTransientParent(0); | - | ||||||||||||||||||||||||||||||||||||
1464 | win->setParent(nativeParent->windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
1465 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1466 | } | - | ||||||||||||||||||||||||||||||||||||
1467 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1468 | - | |||||||||||||||||||||||||||||||||||||
1469 | qt_window_private(win)->positionPolicy = topData()->posIncludesFrame ?
| 0 | ||||||||||||||||||||||||||||||||||||
1470 | QWindowPrivate::WindowFrameInclusive : QWindowPrivate::WindowFrameExclusive; | - | ||||||||||||||||||||||||||||||||||||
1471 | win->create(); | - | ||||||||||||||||||||||||||||||||||||
1472 | // Enable nonclient-area events for QDockWidget and other NonClientArea-mouse event processing. | - | ||||||||||||||||||||||||||||||||||||
1473 | if ((flags & Qt::Desktop) == Qt::Window) {
| 0 | ||||||||||||||||||||||||||||||||||||
1474 | if (QPlatformWindow *platformWindow = win->handle())
| 0 | ||||||||||||||||||||||||||||||||||||
1475 | platformWindow->setFrameStrutEventsEnabled(true); never executed: platformWindow->setFrameStrutEventsEnabled(true); | 0 | ||||||||||||||||||||||||||||||||||||
1476 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1477 | - | |||||||||||||||||||||||||||||||||||||
1478 | data.window_flags = win->flags(); | - | ||||||||||||||||||||||||||||||||||||
1479 | - | |||||||||||||||||||||||||||||||||||||
1480 | if (!topData()->role.isNull())
| 0 | ||||||||||||||||||||||||||||||||||||
1481 | QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1()); never executed: QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1()); | 0 | ||||||||||||||||||||||||||||||||||||
1482 | - | |||||||||||||||||||||||||||||||||||||
1483 | QBackingStore *store = q->backingStore(); | - | ||||||||||||||||||||||||||||||||||||
1484 | - | |||||||||||||||||||||||||||||||||||||
1485 | if (!store) {
| 0 | ||||||||||||||||||||||||||||||||||||
1486 | if (win && q->windowType() != Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
1487 | if (q->isTopLevel())
| 0 | ||||||||||||||||||||||||||||||||||||
1488 | q->setBackingStore(new QBackingStore(win)); never executed: q->setBackingStore(new QBackingStore(win)); | 0 | ||||||||||||||||||||||||||||||||||||
1489 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1490 | q->setAttribute(Qt::WA_PaintOnScreen, true); | - | ||||||||||||||||||||||||||||||||||||
1491 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1492 | } | - | ||||||||||||||||||||||||||||||||||||
1493 | - | |||||||||||||||||||||||||||||||||||||
1494 | setWindowModified_helper(); | - | ||||||||||||||||||||||||||||||||||||
1495 | WId id = win->winId(); | - | ||||||||||||||||||||||||||||||||||||
1496 | // See the QPlatformWindow::winId() documentation | - | ||||||||||||||||||||||||||||||||||||
1497 | Q_ASSERT(id != WId(0)); | - | ||||||||||||||||||||||||||||||||||||
1498 | setWinId(id); | - | ||||||||||||||||||||||||||||||||||||
1499 | - | |||||||||||||||||||||||||||||||||||||
1500 | // Check children and create windows for them if necessary | - | ||||||||||||||||||||||||||||||||||||
1501 | q_createNativeChildrenAndSetParent(q); | - | ||||||||||||||||||||||||||||||||||||
1502 | - | |||||||||||||||||||||||||||||||||||||
1503 | if (extra && !extra->mask.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
1504 | setMask_sys(extra->mask); never executed: setMask_sys(extra->mask); | 0 | ||||||||||||||||||||||||||||||||||||
1505 | - | |||||||||||||||||||||||||||||||||||||
1506 | if (data.crect.width() == 0 || data.crect.height() == 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
1507 | q->setAttribute(Qt::WA_OutsideWSRange, true); | - | ||||||||||||||||||||||||||||||||||||
1508 | } else if (q->isVisible()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
1509 | // If widget is already shown, set window visible, too | - | ||||||||||||||||||||||||||||||||||||
1510 | win->setVisible(true); | - | ||||||||||||||||||||||||||||||||||||
1511 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1512 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1513 | - | |||||||||||||||||||||||||||||||||||||
1514 | #ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
1515 | static const char activeXNativeParentHandleProperty[] = "_q_embedded_native_parent_handle"; | - | ||||||||||||||||||||||||||||||||||||
1516 | #endif | - | ||||||||||||||||||||||||||||||||||||
1517 | - | |||||||||||||||||||||||||||||||||||||
1518 | void QWidgetPrivate::createTLSysExtra() | - | ||||||||||||||||||||||||||||||||||||
1519 | { | - | ||||||||||||||||||||||||||||||||||||
1520 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1521 | if (!extra->topextra->window && (q->testAttribute(Qt::WA_NativeWindow) || q->isWindow())) {
| 0 | ||||||||||||||||||||||||||||||||||||
1522 | extra->topextra->window = new QWidgetWindow(q); | - | ||||||||||||||||||||||||||||||||||||
1523 | if (extra->minw || extra->minh)
| 0 | ||||||||||||||||||||||||||||||||||||
1524 | extra->topextra->window->setMinimumSize(QSize(extra->minw, extra->minh)); never executed: extra->topextra->window->setMinimumSize(QSize(extra->minw, extra->minh)); | 0 | ||||||||||||||||||||||||||||||||||||
1525 | if (extra->maxw != QWIDGETSIZE_MAX || extra->maxh != QWIDGETSIZE_MAX)
| 0 | ||||||||||||||||||||||||||||||||||||
1526 | extra->topextra->window->setMaximumSize(QSize(extra->maxw, extra->maxh)); never executed: extra->topextra->window->setMaximumSize(QSize(extra->maxw, extra->maxh)); | 0 | ||||||||||||||||||||||||||||||||||||
1527 | if (extra->topextra->opacity != 255 && q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
1528 | extra->topextra->window->setOpacity(qreal(extra->topextra->opacity) / qreal(255)); never executed: extra->topextra->window->setOpacity(qreal(extra->topextra->opacity) / qreal(255)); | 0 | ||||||||||||||||||||||||||||||||||||
1529 | #ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
1530 | // Pass on native parent handle for Widget embedded into Active X. | - | ||||||||||||||||||||||||||||||||||||
1531 | const QVariant activeXNativeParentHandle = q->property(activeXNativeParentHandleProperty); | - | ||||||||||||||||||||||||||||||||||||
1532 | if (activeXNativeParentHandle.isValid()) | - | ||||||||||||||||||||||||||||||||||||
1533 | extra->topextra->window->setProperty(activeXNativeParentHandleProperty, activeXNativeParentHandle); | - | ||||||||||||||||||||||||||||||||||||
1534 | if (q->inherits("QTipLabel") || q->inherits("QAlphaWidget")) | - | ||||||||||||||||||||||||||||||||||||
1535 | extra->topextra->window->setProperty("_q_windowsDropShadow", QVariant(true)); | - | ||||||||||||||||||||||||||||||||||||
1536 | #endif | - | ||||||||||||||||||||||||||||||||||||
1537 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1538 | - | |||||||||||||||||||||||||||||||||||||
1539 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1540 | - | |||||||||||||||||||||||||||||||||||||
1541 | /*! | - | ||||||||||||||||||||||||||||||||||||
1542 | Destroys the widget. | - | ||||||||||||||||||||||||||||||||||||
1543 | - | |||||||||||||||||||||||||||||||||||||
1544 | All this widget's children are deleted first. The application | - | ||||||||||||||||||||||||||||||||||||
1545 | exits if this widget is the main widget. | - | ||||||||||||||||||||||||||||||||||||
1546 | */ | - | ||||||||||||||||||||||||||||||||||||
1547 | - | |||||||||||||||||||||||||||||||||||||
1548 | QWidget::~QWidget() | - | ||||||||||||||||||||||||||||||||||||
1549 | { | - | ||||||||||||||||||||||||||||||||||||
1550 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1551 | d->data.in_destructor = true; | - | ||||||||||||||||||||||||||||||||||||
1552 | - | |||||||||||||||||||||||||||||||||||||
1553 | #if defined (QT_CHECK_STATE) | - | ||||||||||||||||||||||||||||||||||||
1554 | if (paintingActive()) | - | ||||||||||||||||||||||||||||||||||||
1555 | qWarning("QWidget: %s (%s) deleted while being painted", className(), name()); | - | ||||||||||||||||||||||||||||||||||||
1556 | #endif | - | ||||||||||||||||||||||||||||||||||||
1557 | - | |||||||||||||||||||||||||||||||||||||
1558 | #ifndef QT_NO_GESTURES | - | ||||||||||||||||||||||||||||||||||||
1559 | foreach (Qt::GestureType type, d->gestureContext.keys()) | - | ||||||||||||||||||||||||||||||||||||
1560 | ungrabGesture(type); never executed: ungrabGesture(type); | 0 | ||||||||||||||||||||||||||||||||||||
1561 | #endif | - | ||||||||||||||||||||||||||||||||||||
1562 | - | |||||||||||||||||||||||||||||||||||||
1563 | // force acceptDrops false before winId is destroyed. | - | ||||||||||||||||||||||||||||||||||||
1564 | d->registerDropSite(false); | - | ||||||||||||||||||||||||||||||||||||
1565 | - | |||||||||||||||||||||||||||||||||||||
1566 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||||||||||||||
1567 | // remove all actions from this widget | - | ||||||||||||||||||||||||||||||||||||
1568 | for (int i = 0; i < d->actions.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
1569 | QActionPrivate *apriv = d->actions.at(i)->d_func(); | - | ||||||||||||||||||||||||||||||||||||
1570 | apriv->widgets.removeAll(this); | - | ||||||||||||||||||||||||||||||||||||
1571 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1572 | d->actions.clear(); | - | ||||||||||||||||||||||||||||||||||||
1573 | #endif | - | ||||||||||||||||||||||||||||||||||||
1574 | - | |||||||||||||||||||||||||||||||||||||
1575 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||||||||||||||||||||
1576 | // Remove all shortcuts grabbed by this | - | ||||||||||||||||||||||||||||||||||||
1577 | // widget, unless application is closing | - | ||||||||||||||||||||||||||||||||||||
1578 | if (!QApplicationPrivate::is_app_closing && testAttribute(Qt::WA_GrabbedShortcut))
| 0 | ||||||||||||||||||||||||||||||||||||
1579 | qApp->d_func()->shortcutMap.removeShortcut(0, this, QKeySequence()); never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(0, this, QKeySequence()); | 0 | ||||||||||||||||||||||||||||||||||||
1580 | #endif | - | ||||||||||||||||||||||||||||||||||||
1581 | - | |||||||||||||||||||||||||||||||||||||
1582 | // delete layout while we still are a valid widget | - | ||||||||||||||||||||||||||||||||||||
1583 | delete d->layout; | - | ||||||||||||||||||||||||||||||||||||
1584 | d->layout = 0; | - | ||||||||||||||||||||||||||||||||||||
1585 | // Remove myself from focus list | - | ||||||||||||||||||||||||||||||||||||
1586 | - | |||||||||||||||||||||||||||||||||||||
1587 | Q_ASSERT(d->focus_next->d_func()->focus_prev == this); | - | ||||||||||||||||||||||||||||||||||||
1588 | Q_ASSERT(d->focus_prev->d_func()->focus_next == this); | - | ||||||||||||||||||||||||||||||||||||
1589 | - | |||||||||||||||||||||||||||||||||||||
1590 | if (d->focus_next != this) {
| 0 | ||||||||||||||||||||||||||||||||||||
1591 | d->focus_next->d_func()->focus_prev = d->focus_prev; | - | ||||||||||||||||||||||||||||||||||||
1592 | d->focus_prev->d_func()->focus_next = d->focus_next; | - | ||||||||||||||||||||||||||||||||||||
1593 | d->focus_next = d->focus_prev = 0; | - | ||||||||||||||||||||||||||||||||||||
1594 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1595 | - | |||||||||||||||||||||||||||||||||||||
1596 | - | |||||||||||||||||||||||||||||||||||||
1597 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1598 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
1599 | const QWidget* w = this; | - | ||||||||||||||||||||||||||||||||||||
1600 | while (w->d_func()->extra && w->d_func()->extra->focus_proxy)
| 0 | ||||||||||||||||||||||||||||||||||||
1601 | w = w->d_func()->extra->focus_proxy; never executed: w = w->d_func()->extra->focus_proxy; | 0 | ||||||||||||||||||||||||||||||||||||
1602 | QWidget *window = w->window(); | - | ||||||||||||||||||||||||||||||||||||
1603 | QWExtra *e = window ? window->d_func()->extra : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
1604 | if (!e || !e->proxyWidget || (w->parentWidget() && w->parentWidget()->d_func()->focus_child == this))
| 0 | ||||||||||||||||||||||||||||||||||||
1605 | #endif | - | ||||||||||||||||||||||||||||||||||||
1606 | clearFocus(); never executed: clearFocus(); | 0 | ||||||||||||||||||||||||||||||||||||
1607 | } QT_CATCH(...) { never executed: end of block dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1608 | // swallow this problem because we are in a destructor dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1609 | } dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1610 | - | |||||||||||||||||||||||||||||||||||||
1611 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
1612 | - | |||||||||||||||||||||||||||||||||||||
1613 | if (isWindow() && isVisible() && internalWinId()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1614 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1615 | d->close_helper(QWidgetPrivate::CloseNoEvent); | - | ||||||||||||||||||||||||||||||||||||
1616 | } QT_CATCH(...) { never executed: end of block dead code: { if (true) { hide(); } else { } } | - | ||||||||||||||||||||||||||||||||||||
1617 | // if we're out of memory, at least hide the window. dead code: { if (true) { hide(); } else { } } | - | ||||||||||||||||||||||||||||||||||||
1618 | QT_TRY { dead code: { if (true) { hide(); } else { } } | - | ||||||||||||||||||||||||||||||||||||
1619 | hide(); dead code: { if (true) { hide(); } else { } } | - | ||||||||||||||||||||||||||||||||||||
1620 | } QT_CATCH(...) { dead code: { if (true) { hide(); } else { } } dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1621 | // and if that also doesn't work, then give up dead code: { if (true) { hide(); } else { } } dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1622 | } dead code: { if (true) { hide(); } else { } } dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1623 | } dead code: { if (true) { hide(); } else { } } | - | ||||||||||||||||||||||||||||||||||||
1624 | } | - | ||||||||||||||||||||||||||||||||||||
1625 | - | |||||||||||||||||||||||||||||||||||||
1626 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_X11)|| defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
1627 | else if (!internalWinId() && isVisible()) { | - | ||||||||||||||||||||||||||||||||||||
1628 | qApp->d_func()->sendSyntheticEnterLeave(this); | - | ||||||||||||||||||||||||||||||||||||
1629 | } | - | ||||||||||||||||||||||||||||||||||||
1630 | #endif | - | ||||||||||||||||||||||||||||||||||||
1631 | else if (isVisible()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1632 | qApp->d_func()->sendSyntheticEnterLeave(this); | - | ||||||||||||||||||||||||||||||||||||
1633 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1634 | - | |||||||||||||||||||||||||||||||||||||
1635 | if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1636 | bs->removeDirtyWidget(this); | - | ||||||||||||||||||||||||||||||||||||
1637 | if (testAttribute(Qt::WA_StaticContents))
| 0 | ||||||||||||||||||||||||||||||||||||
1638 | bs->removeStaticWidget(this); never executed: bs->removeStaticWidget(this); | 0 | ||||||||||||||||||||||||||||||||||||
1639 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1640 | - | |||||||||||||||||||||||||||||||||||||
1641 | delete d->needsFlush; | - | ||||||||||||||||||||||||||||||||||||
1642 | d->needsFlush = 0; | - | ||||||||||||||||||||||||||||||||||||
1643 | - | |||||||||||||||||||||||||||||||||||||
1644 | // The next 20 lines are duplicated from QObject, but required here | - | ||||||||||||||||||||||||||||||||||||
1645 | // since QWidget deletes is children itself | - | ||||||||||||||||||||||||||||||||||||
1646 | bool blocked = d->blockSig; | - | ||||||||||||||||||||||||||||||||||||
1647 | d->blockSig = 0; // unblock signals so we always emit destroyed() | - | ||||||||||||||||||||||||||||||||||||
1648 | - | |||||||||||||||||||||||||||||||||||||
1649 | if (d->isSignalConnected(0)) {
| 0 | ||||||||||||||||||||||||||||||||||||
1650 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1651 | emit destroyed(this); | - | ||||||||||||||||||||||||||||||||||||
1652 | } QT_CATCH(...) { never executed: end of block dead code: { QMessageLogger(__FILE__, 1655, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1653 | // all the signal/slots connections are still in place - if we don't dead code: { QMessageLogger(__FILE__, 1655, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1654 | // quit now, we will crash pretty soon. dead code: { QMessageLogger(__FILE__, 1655, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1655 | qWarning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); dead code: { QMessageLogger(__FILE__, 1655, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1656 | QT_RETHROW; dead code: { QMessageLogger(__FILE__, 1655, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1657 | } dead code: { QMessageLogger(__FILE__, 1655, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QWidget while emitting destroyed()."); qt_noop(); } | - | ||||||||||||||||||||||||||||||||||||
1658 | } | - | ||||||||||||||||||||||||||||||||||||
1659 | - | |||||||||||||||||||||||||||||||||||||
1660 | if (d->declarativeData) {
| 0 | ||||||||||||||||||||||||||||||||||||
1661 | if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
| 0 | ||||||||||||||||||||||||||||||||||||
1662 | if (QAbstractDeclarativeData::destroyed_qml1)
| 0 | ||||||||||||||||||||||||||||||||||||
1663 | QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this); never executed: QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this); | 0 | ||||||||||||||||||||||||||||||||||||
1664 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1665 | if (QAbstractDeclarativeData::destroyed)
| 0 | ||||||||||||||||||||||||||||||||||||
1666 | QAbstractDeclarativeData::destroyed(d->declarativeData, this); never executed: QAbstractDeclarativeData::destroyed(d->declarativeData, this); | 0 | ||||||||||||||||||||||||||||||||||||
1667 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1668 | d->declarativeData = 0; // don't activate again in ~QObject | - | ||||||||||||||||||||||||||||||||||||
1669 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1670 | - | |||||||||||||||||||||||||||||||||||||
1671 | d->blockSig = blocked; | - | ||||||||||||||||||||||||||||||||||||
1672 | - | |||||||||||||||||||||||||||||||||||||
1673 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1674 | // QCocoaView holds a pointer back to this widget. Clear it now | - | ||||||||||||||||||||||||||||||||||||
1675 | // to make sure it's not followed later on. The lifetime of the | - | ||||||||||||||||||||||||||||||||||||
1676 | // QCocoaView might exceed the lifetime of this widget in cases | - | ||||||||||||||||||||||||||||||||||||
1677 | // where Cocoa itself holds references to it. | - | ||||||||||||||||||||||||||||||||||||
1678 | extern void qt_mac_clearCocoaViewQWidgetPointers(QWidget *); | - | ||||||||||||||||||||||||||||||||||||
1679 | qt_mac_clearCocoaViewQWidgetPointers(this); | - | ||||||||||||||||||||||||||||||||||||
1680 | #endif | - | ||||||||||||||||||||||||||||||||||||
1681 | - | |||||||||||||||||||||||||||||||||||||
1682 | if (!d->children.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
1683 | d->deleteChildren(); never executed: d->deleteChildren(); | 0 | ||||||||||||||||||||||||||||||||||||
1684 | - | |||||||||||||||||||||||||||||||||||||
1685 | QApplication::removePostedEvents(this); | - | ||||||||||||||||||||||||||||||||||||
1686 | - | |||||||||||||||||||||||||||||||||||||
1687 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1688 | destroy(); // platform-dependent cleanup | - | ||||||||||||||||||||||||||||||||||||
1689 | } QT_CATCH(...) { never executed: end of block dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1690 | // if this fails we can't do anything about it but at least we are not allowed to throw. dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1691 | } dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1692 | --QWidgetPrivate::instanceCounter; | - | ||||||||||||||||||||||||||||||||||||
1693 | - | |||||||||||||||||||||||||||||||||||||
1694 | if (QWidgetPrivate::allWidgets) // might have been deleted by ~QApplication
| 0 | ||||||||||||||||||||||||||||||||||||
1695 | QWidgetPrivate::allWidgets->remove(this); never executed: QWidgetPrivate::allWidgets->remove(this); | 0 | ||||||||||||||||||||||||||||||||||||
1696 | - | |||||||||||||||||||||||||||||||||||||
1697 | QT_TRY { | - | ||||||||||||||||||||||||||||||||||||
1698 | QEvent e(QEvent::Destroy); | - | ||||||||||||||||||||||||||||||||||||
1699 | QCoreApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
1700 | } QT_CATCH(const std::exception&) { never executed: end of block dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1701 | // if this fails we can't do anything about it but at least we are not allowed to throw. dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1702 | } dead code: { } | - | ||||||||||||||||||||||||||||||||||||
1703 | } | - | ||||||||||||||||||||||||||||||||||||
1704 | - | |||||||||||||||||||||||||||||||||||||
1705 | int QWidgetPrivate::instanceCounter = 0; // Current number of widget instances | - | ||||||||||||||||||||||||||||||||||||
1706 | int QWidgetPrivate::maxInstances = 0; // Maximum number of widget instances | - | ||||||||||||||||||||||||||||||||||||
1707 | - | |||||||||||||||||||||||||||||||||||||
1708 | void QWidgetPrivate::setWinId(WId id) // set widget identifier | - | ||||||||||||||||||||||||||||||||||||
1709 | { | - | ||||||||||||||||||||||||||||||||||||
1710 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1711 | // the user might create a widget with Qt::Desktop window | - | ||||||||||||||||||||||||||||||||||||
1712 | // attribute (or create another QDesktopWidget instance), which | - | ||||||||||||||||||||||||||||||||||||
1713 | // will have the same windowid (the root window id) as the | - | ||||||||||||||||||||||||||||||||||||
1714 | // qt_desktopWidget. We should not add the second desktop widget | - | ||||||||||||||||||||||||||||||||||||
1715 | // to the mapper. | - | ||||||||||||||||||||||||||||||||||||
1716 | bool userDesktopWidget = qt_desktopWidget != 0 && qt_desktopWidget != q && q->windowType() == Qt::Desktop;
| 0 | ||||||||||||||||||||||||||||||||||||
1717 | if (mapper && data.winid && !userDesktopWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
1718 | mapper->remove(data.winid); | - | ||||||||||||||||||||||||||||||||||||
1719 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1720 | - | |||||||||||||||||||||||||||||||||||||
1721 | const WId oldWinId = data.winid; | - | ||||||||||||||||||||||||||||||||||||
1722 | - | |||||||||||||||||||||||||||||||||||||
1723 | data.winid = id; | - | ||||||||||||||||||||||||||||||||||||
1724 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
1725 | hd = id; // X11: hd == ident | - | ||||||||||||||||||||||||||||||||||||
1726 | #endif | - | ||||||||||||||||||||||||||||||||||||
1727 | if (mapper && id && !userDesktopWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
1728 | mapper->insert(data.winid, q); | - | ||||||||||||||||||||||||||||||||||||
1729 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1730 | - | |||||||||||||||||||||||||||||||||||||
1731 | if(oldWinId != id) {
| 0 | ||||||||||||||||||||||||||||||||||||
1732 | QEvent e(QEvent::WinIdChange); | - | ||||||||||||||||||||||||||||||||||||
1733 | QCoreApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
1734 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1735 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1736 | - | |||||||||||||||||||||||||||||||||||||
1737 | void QWidgetPrivate::createTLExtra() | - | ||||||||||||||||||||||||||||||||||||
1738 | { | - | ||||||||||||||||||||||||||||||||||||
1739 | if (!extra)
| 0 | ||||||||||||||||||||||||||||||||||||
1740 | createExtra(); never executed: createExtra(); | 0 | ||||||||||||||||||||||||||||||||||||
1741 | if (!extra->topextra) {
| 0 | ||||||||||||||||||||||||||||||||||||
1742 | QTLWExtra* x = extra->topextra = new QTLWExtra; | - | ||||||||||||||||||||||||||||||||||||
1743 | x->icon = 0; | - | ||||||||||||||||||||||||||||||||||||
1744 | x->backingStore = 0; | - | ||||||||||||||||||||||||||||||||||||
1745 | x->sharedPainter = 0; | - | ||||||||||||||||||||||||||||||||||||
1746 | x->incw = x->inch = 0; | - | ||||||||||||||||||||||||||||||||||||
1747 | x->basew = x->baseh = 0; | - | ||||||||||||||||||||||||||||||||||||
1748 | x->frameStrut.setCoords(0, 0, 0, 0); | - | ||||||||||||||||||||||||||||||||||||
1749 | x->normalGeometry = QRect(0,0,-1,-1); | - | ||||||||||||||||||||||||||||||||||||
1750 | x->savedFlags = 0; | - | ||||||||||||||||||||||||||||||||||||
1751 | x->opacity = 255; | - | ||||||||||||||||||||||||||||||||||||
1752 | x->posIncludesFrame = 0; | - | ||||||||||||||||||||||||||||||||||||
1753 | x->sizeAdjusted = false; | - | ||||||||||||||||||||||||||||||||||||
1754 | x->inTopLevelResize = false; | - | ||||||||||||||||||||||||||||||||||||
1755 | x->inRepaint = false; | - | ||||||||||||||||||||||||||||||||||||
1756 | x->embedded = 0; | - | ||||||||||||||||||||||||||||||||||||
1757 | x->window = 0; | - | ||||||||||||||||||||||||||||||||||||
1758 | x->shareContext = 0; | - | ||||||||||||||||||||||||||||||||||||
1759 | x->initialScreenIndex = -1; | - | ||||||||||||||||||||||||||||||||||||
1760 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1761 | x->wasMaximized = false; | - | ||||||||||||||||||||||||||||||||||||
1762 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
1763 | #ifdef QWIDGET_EXTRA_DEBUG | - | ||||||||||||||||||||||||||||||||||||
1764 | static int count = 0; | - | ||||||||||||||||||||||||||||||||||||
1765 | qDebug() << "tlextra" << ++count; | - | ||||||||||||||||||||||||||||||||||||
1766 | #endif | - | ||||||||||||||||||||||||||||||||||||
1767 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1768 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1769 | - | |||||||||||||||||||||||||||||||||||||
1770 | /*! | - | ||||||||||||||||||||||||||||||||||||
1771 | \internal | - | ||||||||||||||||||||||||||||||||||||
1772 | Creates the widget extra data. | - | ||||||||||||||||||||||||||||||||||||
1773 | */ | - | ||||||||||||||||||||||||||||||||||||
1774 | - | |||||||||||||||||||||||||||||||||||||
1775 | void QWidgetPrivate::createExtra() | - | ||||||||||||||||||||||||||||||||||||
1776 | { | - | ||||||||||||||||||||||||||||||||||||
1777 | if (!extra) { // if not exists
| 0 | ||||||||||||||||||||||||||||||||||||
1778 | extra = new QWExtra; | - | ||||||||||||||||||||||||||||||||||||
1779 | extra->glContext = 0; | - | ||||||||||||||||||||||||||||||||||||
1780 | extra->topextra = 0; | - | ||||||||||||||||||||||||||||||||||||
1781 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
1782 | extra->proxyWidget = 0; | - | ||||||||||||||||||||||||||||||||||||
1783 | #endif | - | ||||||||||||||||||||||||||||||||||||
1784 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
1785 | extra->curs = 0; | - | ||||||||||||||||||||||||||||||||||||
1786 | #endif | - | ||||||||||||||||||||||||||||||||||||
1787 | extra->minw = 0; | - | ||||||||||||||||||||||||||||||||||||
1788 | extra->minh = 0; | - | ||||||||||||||||||||||||||||||||||||
1789 | extra->maxw = QWIDGETSIZE_MAX; | - | ||||||||||||||||||||||||||||||||||||
1790 | extra->maxh = QWIDGETSIZE_MAX; | - | ||||||||||||||||||||||||||||||||||||
1791 | extra->customDpiX = 0; | - | ||||||||||||||||||||||||||||||||||||
1792 | extra->customDpiY = 0; | - | ||||||||||||||||||||||||||||||||||||
1793 | extra->explicitMinSize = 0; | - | ||||||||||||||||||||||||||||||||||||
1794 | extra->explicitMaxSize = 0; | - | ||||||||||||||||||||||||||||||||||||
1795 | extra->autoFillBackground = 0; | - | ||||||||||||||||||||||||||||||||||||
1796 | extra->nativeChildrenForced = 0; | - | ||||||||||||||||||||||||||||||||||||
1797 | extra->inRenderWithPainter = 0; | - | ||||||||||||||||||||||||||||||||||||
1798 | extra->hasWindowContainer = false; | - | ||||||||||||||||||||||||||||||||||||
1799 | extra->hasMask = 0; | - | ||||||||||||||||||||||||||||||||||||
1800 | createSysExtra(); | - | ||||||||||||||||||||||||||||||||||||
1801 | #ifdef QWIDGET_EXTRA_DEBUG | - | ||||||||||||||||||||||||||||||||||||
1802 | static int count = 0; | - | ||||||||||||||||||||||||||||||||||||
1803 | qDebug() << "extra" << ++count; | - | ||||||||||||||||||||||||||||||||||||
1804 | #endif | - | ||||||||||||||||||||||||||||||||||||
1805 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1806 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1807 | - | |||||||||||||||||||||||||||||||||||||
1808 | void QWidgetPrivate::createSysExtra() | - | ||||||||||||||||||||||||||||||||||||
1809 | { | - | ||||||||||||||||||||||||||||||||||||
1810 | } | - | ||||||||||||||||||||||||||||||||||||
1811 | - | |||||||||||||||||||||||||||||||||||||
1812 | /*! | - | ||||||||||||||||||||||||||||||||||||
1813 | \internal | - | ||||||||||||||||||||||||||||||||||||
1814 | Deletes the widget extra data. | - | ||||||||||||||||||||||||||||||||||||
1815 | */ | - | ||||||||||||||||||||||||||||||||||||
1816 | - | |||||||||||||||||||||||||||||||||||||
1817 | void QWidgetPrivate::deleteExtra() | - | ||||||||||||||||||||||||||||||||||||
1818 | { | - | ||||||||||||||||||||||||||||||||||||
1819 | if (extra) { // if exists
| 0 | ||||||||||||||||||||||||||||||||||||
1820 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
1821 | delete extra->curs; | - | ||||||||||||||||||||||||||||||||||||
1822 | #endif | - | ||||||||||||||||||||||||||||||||||||
1823 | deleteSysExtra(); | - | ||||||||||||||||||||||||||||||||||||
1824 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
1825 | // dereference the stylesheet style | - | ||||||||||||||||||||||||||||||||||||
1826 | if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(extra->style))
| 0 | ||||||||||||||||||||||||||||||||||||
1827 | proxy->deref(); never executed: proxy->deref(); | 0 | ||||||||||||||||||||||||||||||||||||
1828 | #endif | - | ||||||||||||||||||||||||||||||||||||
1829 | if (extra->topextra) {
| 0 | ||||||||||||||||||||||||||||||||||||
1830 | deleteTLSysExtra(); | - | ||||||||||||||||||||||||||||||||||||
1831 | // extra->topextra->backingStore destroyed in QWidgetPrivate::deleteTLSysExtra() | - | ||||||||||||||||||||||||||||||||||||
1832 | delete extra->topextra->icon; | - | ||||||||||||||||||||||||||||||||||||
1833 | delete extra->topextra; | - | ||||||||||||||||||||||||||||||||||||
1834 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1835 | delete extra; | - | ||||||||||||||||||||||||||||||||||||
1836 | // extra->xic destroyed in QWidget::destroy() | - | ||||||||||||||||||||||||||||||||||||
1837 | extra = 0; | - | ||||||||||||||||||||||||||||||||||||
1838 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1839 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1840 | - | |||||||||||||||||||||||||||||||||||||
1841 | void QWidgetPrivate::deleteSysExtra() | - | ||||||||||||||||||||||||||||||||||||
1842 | { | - | ||||||||||||||||||||||||||||||||||||
1843 | } | - | ||||||||||||||||||||||||||||||||||||
1844 | - | |||||||||||||||||||||||||||||||||||||
1845 | static void deleteBackingStore(QWidgetPrivate *d) | - | ||||||||||||||||||||||||||||||||||||
1846 | { | - | ||||||||||||||||||||||||||||||||||||
1847 | QTLWExtra *topData = d->topData(); | - | ||||||||||||||||||||||||||||||||||||
1848 | - | |||||||||||||||||||||||||||||||||||||
1849 | // The context must be current when destroying the backing store as it may attempt to | - | ||||||||||||||||||||||||||||||||||||
1850 | // release resources like textures and shader programs. The window may not be suitable | - | ||||||||||||||||||||||||||||||||||||
1851 | // anymore as there will often not be a platform window underneath at this stage. Fall | - | ||||||||||||||||||||||||||||||||||||
1852 | // back to a QOffscreenSurface in this case. | - | ||||||||||||||||||||||||||||||||||||
1853 | QScopedPointer<QOffscreenSurface> tempSurface; | - | ||||||||||||||||||||||||||||||||||||
1854 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
1855 | if (d->textureChildSeen && topData->shareContext) {
| 0 | ||||||||||||||||||||||||||||||||||||
1856 | if (topData->window->handle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1857 | topData->shareContext->makeCurrent(topData->window); | - | ||||||||||||||||||||||||||||||||||||
1858 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1859 | tempSurface.reset(new QOffscreenSurface); | - | ||||||||||||||||||||||||||||||||||||
1860 | tempSurface->setFormat(topData->shareContext->format()); | - | ||||||||||||||||||||||||||||||||||||
1861 | tempSurface->create(); | - | ||||||||||||||||||||||||||||||||||||
1862 | topData->shareContext->makeCurrent(tempSurface.data()); | - | ||||||||||||||||||||||||||||||||||||
1863 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1864 | } | - | ||||||||||||||||||||||||||||||||||||
1865 | #endif | - | ||||||||||||||||||||||||||||||||||||
1866 | - | |||||||||||||||||||||||||||||||||||||
1867 | delete topData->backingStore; | - | ||||||||||||||||||||||||||||||||||||
1868 | topData->backingStore = 0; | - | ||||||||||||||||||||||||||||||||||||
1869 | - | |||||||||||||||||||||||||||||||||||||
1870 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
1871 | if (d->textureChildSeen && topData->shareContext)
| 0 | ||||||||||||||||||||||||||||||||||||
1872 | topData->shareContext->doneCurrent(); never executed: topData->shareContext->doneCurrent(); | 0 | ||||||||||||||||||||||||||||||||||||
1873 | #endif | - | ||||||||||||||||||||||||||||||||||||
1874 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1875 | - | |||||||||||||||||||||||||||||||||||||
1876 | void QWidgetPrivate::deleteTLSysExtra() | - | ||||||||||||||||||||||||||||||||||||
1877 | { | - | ||||||||||||||||||||||||||||||||||||
1878 | if (extra && extra->topextra) {
| 0 | ||||||||||||||||||||||||||||||||||||
1879 | //the qplatformbackingstore may hold a reference to the window, so the backingstore | - | ||||||||||||||||||||||||||||||||||||
1880 | //needs to be deleted first. If the backingstore holds GL resources, we need to | - | ||||||||||||||||||||||||||||||||||||
1881 | // make the context current here. This is taken care of by deleteBackingStore(). | - | ||||||||||||||||||||||||||||||||||||
1882 | - | |||||||||||||||||||||||||||||||||||||
1883 | extra->topextra->backingStoreTracker.destroy(); | - | ||||||||||||||||||||||||||||||||||||
1884 | deleteBackingStore(this); | - | ||||||||||||||||||||||||||||||||||||
1885 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
1886 | qDeleteAll(extra->topextra->widgetTextures); | - | ||||||||||||||||||||||||||||||||||||
1887 | extra->topextra->widgetTextures.clear(); | - | ||||||||||||||||||||||||||||||||||||
1888 | delete extra->topextra->shareContext; | - | ||||||||||||||||||||||||||||||||||||
1889 | extra->topextra->shareContext = 0; | - | ||||||||||||||||||||||||||||||||||||
1890 | #endif | - | ||||||||||||||||||||||||||||||||||||
1891 | - | |||||||||||||||||||||||||||||||||||||
1892 | //the toplevel might have a context with a "qglcontext associated with it. We need to | - | ||||||||||||||||||||||||||||||||||||
1893 | //delete the qglcontext before we delete the qplatformopenglcontext. | - | ||||||||||||||||||||||||||||||||||||
1894 | //One unfortunate thing about this is that we potentially create a glContext just to | - | ||||||||||||||||||||||||||||||||||||
1895 | //delete it straight afterwards. | - | ||||||||||||||||||||||||||||||||||||
1896 | if (extra->topextra->window) {
| 0 | ||||||||||||||||||||||||||||||||||||
1897 | extra->topextra->window->destroy(); | - | ||||||||||||||||||||||||||||||||||||
1898 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1899 | delete extra->topextra->window; | - | ||||||||||||||||||||||||||||||||||||
1900 | extra->topextra->window = 0; | - | ||||||||||||||||||||||||||||||||||||
1901 | - | |||||||||||||||||||||||||||||||||||||
1902 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1903 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1904 | - | |||||||||||||||||||||||||||||||||||||
1905 | /* | - | ||||||||||||||||||||||||||||||||||||
1906 | Returns \c true if there are widgets above this which overlap with | - | ||||||||||||||||||||||||||||||||||||
1907 | \a rect, which is in parent's coordinate system (same as crect). | - | ||||||||||||||||||||||||||||||||||||
1908 | */ | - | ||||||||||||||||||||||||||||||||||||
1909 | - | |||||||||||||||||||||||||||||||||||||
1910 | bool QWidgetPrivate::isOverlapped(const QRect &rect) const | - | ||||||||||||||||||||||||||||||||||||
1911 | { | - | ||||||||||||||||||||||||||||||||||||
1912 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
1913 | - | |||||||||||||||||||||||||||||||||||||
1914 | const QWidget *w = q; | - | ||||||||||||||||||||||||||||||||||||
1915 | QRect r = rect; | - | ||||||||||||||||||||||||||||||||||||
1916 | while (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
1917 | if (w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
1918 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
1919 | QWidgetPrivate *pd = w->parentWidget()->d_func(); | - | ||||||||||||||||||||||||||||||||||||
1920 | bool above = false; | - | ||||||||||||||||||||||||||||||||||||
1921 | for (int i = 0; i < pd->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
1922 | QWidget *sibling = qobject_cast<QWidget *>(pd->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
1923 | if (!sibling || !sibling->isVisible() || sibling->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
1924 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
1925 | if (!above) {
| 0 | ||||||||||||||||||||||||||||||||||||
1926 | above = (sibling == w); | - | ||||||||||||||||||||||||||||||||||||
1927 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
1928 | } | - | ||||||||||||||||||||||||||||||||||||
1929 | - | |||||||||||||||||||||||||||||||||||||
1930 | if (qRectIntersects(sibling->d_func()->effectiveRectFor(sibling->data->crect), r)) {
| 0 | ||||||||||||||||||||||||||||||||||||
1931 | const QWExtra *siblingExtra = sibling->d_func()->extra; | - | ||||||||||||||||||||||||||||||||||||
1932 | if (siblingExtra && siblingExtra->hasMask && !sibling->d_func()->graphicsEffect
| 0 | ||||||||||||||||||||||||||||||||||||
1933 | && !siblingExtra->mask.translated(sibling->data->crect.topLeft()).intersects(r)) {
| 0 | ||||||||||||||||||||||||||||||||||||
1934 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
1935 | } | - | ||||||||||||||||||||||||||||||||||||
1936 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
1937 | } | - | ||||||||||||||||||||||||||||||||||||
1938 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1939 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
1940 | r.translate(pd->data.crect.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
1941 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1942 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
1943 | } | - | ||||||||||||||||||||||||||||||||||||
1944 | - | |||||||||||||||||||||||||||||||||||||
1945 | void QWidgetPrivate::syncBackingStore() | - | ||||||||||||||||||||||||||||||||||||
1946 | { | - | ||||||||||||||||||||||||||||||||||||
1947 | if (paintOnScreen()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1948 | repaint_sys(dirty); | - | ||||||||||||||||||||||||||||||||||||
1949 | dirty = QRegion(); | - | ||||||||||||||||||||||||||||||||||||
1950 | } else if (QWidgetBackingStore *bs = maybeBackingStore()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
1951 | bs->sync(); | - | ||||||||||||||||||||||||||||||||||||
1952 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1953 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1954 | - | |||||||||||||||||||||||||||||||||||||
1955 | void QWidgetPrivate::syncBackingStore(const QRegion ®ion) | - | ||||||||||||||||||||||||||||||||||||
1956 | { | - | ||||||||||||||||||||||||||||||||||||
1957 | if (paintOnScreen())
| 0 | ||||||||||||||||||||||||||||||||||||
1958 | repaint_sys(region); never executed: repaint_sys(region); | 0 | ||||||||||||||||||||||||||||||||||||
1959 | else if (QWidgetBackingStore *bs = maybeBackingStore()) {
| 0 | ||||||||||||||||||||||||||||||||||||
1960 | bs->sync(q_func(), region); | - | ||||||||||||||||||||||||||||||||||||
1961 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1962 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1963 | - | |||||||||||||||||||||||||||||||||||||
1964 | void QWidgetPrivate::setUpdatesEnabled_helper(bool enable) | - | ||||||||||||||||||||||||||||||||||||
1965 | { | - | ||||||||||||||||||||||||||||||||||||
1966 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1967 | - | |||||||||||||||||||||||||||||||||||||
1968 | if (enable && !q->isWindow() && q->parentWidget() && !q->parentWidget()->updatesEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
1969 | return; // nothing we can do never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
1970 | - | |||||||||||||||||||||||||||||||||||||
1971 | if (enable != q->testAttribute(Qt::WA_UpdatesDisabled))
| 0 | ||||||||||||||||||||||||||||||||||||
1972 | return; // nothing to do never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
1973 | - | |||||||||||||||||||||||||||||||||||||
1974 | q->setAttribute(Qt::WA_UpdatesDisabled, !enable); | - | ||||||||||||||||||||||||||||||||||||
1975 | if (enable)
| 0 | ||||||||||||||||||||||||||||||||||||
1976 | q->update(); never executed: q->update(); | 0 | ||||||||||||||||||||||||||||||||||||
1977 | - | |||||||||||||||||||||||||||||||||||||
1978 | Qt::WidgetAttribute attribute = enable ? Qt::WA_ForceUpdatesDisabled : Qt::WA_UpdatesDisabled;
| 0 | ||||||||||||||||||||||||||||||||||||
1979 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
1980 | QWidget *w = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
1981 | if (w && !w->isWindow() && !w->testAttribute(attribute))
| 0 | ||||||||||||||||||||||||||||||||||||
1982 | w->d_func()->setUpdatesEnabled_helper(enable); never executed: w->d_func()->setUpdatesEnabled_helper(enable); | 0 | ||||||||||||||||||||||||||||||||||||
1983 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1984 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
1985 | - | |||||||||||||||||||||||||||||||||||||
1986 | /*! | - | ||||||||||||||||||||||||||||||||||||
1987 | \internal | - | ||||||||||||||||||||||||||||||||||||
1988 | - | |||||||||||||||||||||||||||||||||||||
1989 | Propagate this widget's palette to all children, except style sheet | - | ||||||||||||||||||||||||||||||||||||
1990 | widgets, and windows that don't enable window propagation (palettes don't | - | ||||||||||||||||||||||||||||||||||||
1991 | normally propagate to windows). | - | ||||||||||||||||||||||||||||||||||||
1992 | */ | - | ||||||||||||||||||||||||||||||||||||
1993 | void QWidgetPrivate::propagatePaletteChange() | - | ||||||||||||||||||||||||||||||||||||
1994 | { | - | ||||||||||||||||||||||||||||||||||||
1995 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
1996 | // Propagate a new inherited mask to all children. | - | ||||||||||||||||||||||||||||||||||||
1997 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
1998 | if (!q->parentWidget() && extra && extra->proxyWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
1999 | QGraphicsProxyWidget *p = extra->proxyWidget; | - | ||||||||||||||||||||||||||||||||||||
2000 | inheritedPaletteResolveMask = p->d_func()->inheritedPaletteResolveMask | p->palette().resolve(); | - | ||||||||||||||||||||||||||||||||||||
2001 | } else never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2002 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
2003 | if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2004 | inheritedPaletteResolveMask = 0; | - | ||||||||||||||||||||||||||||||||||||
2005 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2006 | int mask = data.pal.resolve() | inheritedPaletteResolveMask; | - | ||||||||||||||||||||||||||||||||||||
2007 | - | |||||||||||||||||||||||||||||||||||||
2008 | QEvent pc(QEvent::PaletteChange); | - | ||||||||||||||||||||||||||||||||||||
2009 | QApplication::sendEvent(q, &pc); | - | ||||||||||||||||||||||||||||||||||||
2010 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
2011 | QWidget *w = qobject_cast<QWidget*>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
2012 | if (w && !w->testAttribute(Qt::WA_StyleSheet)
| 0 | ||||||||||||||||||||||||||||||||||||
2013 | && (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) {
| 0 | ||||||||||||||||||||||||||||||||||||
2014 | QWidgetPrivate *wd = w->d_func(); | - | ||||||||||||||||||||||||||||||||||||
2015 | wd->inheritedPaletteResolveMask = mask; | - | ||||||||||||||||||||||||||||||||||||
2016 | wd->resolvePalette(); | - | ||||||||||||||||||||||||||||||||||||
2017 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2018 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2019 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2020 | - | |||||||||||||||||||||||||||||||||||||
2021 | /* | - | ||||||||||||||||||||||||||||||||||||
2022 | Returns the widget's clipping rectangle. | - | ||||||||||||||||||||||||||||||||||||
2023 | */ | - | ||||||||||||||||||||||||||||||||||||
2024 | QRect QWidgetPrivate::clipRect() const | - | ||||||||||||||||||||||||||||||||||||
2025 | { | - | ||||||||||||||||||||||||||||||||||||
2026 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2027 | const QWidget * w = q; | - | ||||||||||||||||||||||||||||||||||||
2028 | if (!w->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
2029 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||||||||||||||
2030 | QRect r = effectiveRectFor(q->rect()); | - | ||||||||||||||||||||||||||||||||||||
2031 | int ox = 0; | - | ||||||||||||||||||||||||||||||||||||
2032 | int oy = 0; | - | ||||||||||||||||||||||||||||||||||||
2033 | while (w
| 0 | ||||||||||||||||||||||||||||||||||||
2034 | && w->isVisible()
| 0 | ||||||||||||||||||||||||||||||||||||
2035 | && !w->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
2036 | && w->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2037 | ox -= w->x(); | - | ||||||||||||||||||||||||||||||||||||
2038 | oy -= w->y(); | - | ||||||||||||||||||||||||||||||||||||
2039 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2040 | r &= QRect(ox, oy, w->width(), w->height()); | - | ||||||||||||||||||||||||||||||||||||
2041 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2042 | return r; never executed: return r; | 0 | ||||||||||||||||||||||||||||||||||||
2043 | } | - | ||||||||||||||||||||||||||||||||||||
2044 | - | |||||||||||||||||||||||||||||||||||||
2045 | /* | - | ||||||||||||||||||||||||||||||||||||
2046 | Returns the widget's clipping region (without siblings). | - | ||||||||||||||||||||||||||||||||||||
2047 | */ | - | ||||||||||||||||||||||||||||||||||||
2048 | QRegion QWidgetPrivate::clipRegion() const | - | ||||||||||||||||||||||||||||||||||||
2049 | { | - | ||||||||||||||||||||||||||||||||||||
2050 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2051 | if (!q->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
2052 | return QRegion(); never executed: return QRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
2053 | QRegion r(q->rect()); | - | ||||||||||||||||||||||||||||||||||||
2054 | const QWidget * w = q; | - | ||||||||||||||||||||||||||||||||||||
2055 | const QWidget *ignoreUpTo; | - | ||||||||||||||||||||||||||||||||||||
2056 | int ox = 0; | - | ||||||||||||||||||||||||||||||||||||
2057 | int oy = 0; | - | ||||||||||||||||||||||||||||||||||||
2058 | while (w
| 0 | ||||||||||||||||||||||||||||||||||||
2059 | && w->isVisible()
| 0 | ||||||||||||||||||||||||||||||||||||
2060 | && !w->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
2061 | && w->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2062 | ox -= w->x(); | - | ||||||||||||||||||||||||||||||||||||
2063 | oy -= w->y(); | - | ||||||||||||||||||||||||||||||||||||
2064 | ignoreUpTo = w; | - | ||||||||||||||||||||||||||||||||||||
2065 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2066 | r &= QRegion(ox, oy, w->width(), w->height()); | - | ||||||||||||||||||||||||||||||||||||
2067 | - | |||||||||||||||||||||||||||||||||||||
2068 | int i = 0; | - | ||||||||||||||||||||||||||||||||||||
2069 | while(w->d_func()->children.at(i++) != static_cast<const QObject *>(ignoreUpTo))
| 0 | ||||||||||||||||||||||||||||||||||||
2070 | ; never executed: ; | 0 | ||||||||||||||||||||||||||||||||||||
2071 | for ( ; i < w->d_func()->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
2072 | if(QWidget *sibling = qobject_cast<QWidget *>(w->d_func()->children.at(i))) {
| 0 | ||||||||||||||||||||||||||||||||||||
2073 | if(sibling->isVisible() && !sibling->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2074 | QRect siblingRect(ox+sibling->x(), oy+sibling->y(), | - | ||||||||||||||||||||||||||||||||||||
2075 | sibling->width(), sibling->height()); | - | ||||||||||||||||||||||||||||||||||||
2076 | if (qRectIntersects(siblingRect, q->rect()))
| 0 | ||||||||||||||||||||||||||||||||||||
2077 | r -= QRegion(siblingRect); never executed: r -= QRegion(siblingRect); | 0 | ||||||||||||||||||||||||||||||||||||
2078 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2079 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2080 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2081 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2082 | return r; never executed: return r; | 0 | ||||||||||||||||||||||||||||||||||||
2083 | } | - | ||||||||||||||||||||||||||||||||||||
2084 | - | |||||||||||||||||||||||||||||||||||||
2085 | void QWidgetPrivate::setSystemClip(QPaintDevice *paintDevice, const QRegion ®ion) | - | ||||||||||||||||||||||||||||||||||||
2086 | { | - | ||||||||||||||||||||||||||||||||||||
2087 | // Transform the system clip region from device-independent pixels to device pixels | - | ||||||||||||||||||||||||||||||||||||
2088 | QPaintEngine *paintEngine = paintDevice->paintEngine(); | - | ||||||||||||||||||||||||||||||||||||
2089 | QTransform scaleTransform; | - | ||||||||||||||||||||||||||||||||||||
2090 | const qreal devicePixelRatio = paintDevice->devicePixelRatioF(); | - | ||||||||||||||||||||||||||||||||||||
2091 | scaleTransform.scale(devicePixelRatio, devicePixelRatio); | - | ||||||||||||||||||||||||||||||||||||
2092 | paintEngine->d_func()->systemClip = scaleTransform.map(region); | - | ||||||||||||||||||||||||||||||||||||
2093 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2094 | - | |||||||||||||||||||||||||||||||||||||
2095 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2096 | void QWidgetPrivate::invalidateGraphicsEffectsRecursively() | - | ||||||||||||||||||||||||||||||||||||
2097 | { | - | ||||||||||||||||||||||||||||||||||||
2098 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2099 | QWidget *w = q; | - | ||||||||||||||||||||||||||||||||||||
2100 | do { | - | ||||||||||||||||||||||||||||||||||||
2101 | if (w->graphicsEffect()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2102 | QWidgetEffectSourcePrivate *sourced = | - | ||||||||||||||||||||||||||||||||||||
2103 | static_cast<QWidgetEffectSourcePrivate *>(w->graphicsEffect()->source()->d_func()); | - | ||||||||||||||||||||||||||||||||||||
2104 | if (!sourced->updateDueToGraphicsEffect)
| 0 | ||||||||||||||||||||||||||||||||||||
2105 | w->graphicsEffect()->source()->d_func()->invalidateCache(); never executed: w->graphicsEffect()->source()->d_func()->invalidateCache(); | 0 | ||||||||||||||||||||||||||||||||||||
2106 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2107 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2108 | } while (w); never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
2109 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2110 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2111 | - | |||||||||||||||||||||||||||||||||||||
2112 | void QWidgetPrivate::setDirtyOpaqueRegion() | - | ||||||||||||||||||||||||||||||||||||
2113 | { | - | ||||||||||||||||||||||||||||||||||||
2114 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2115 | - | |||||||||||||||||||||||||||||||||||||
2116 | dirtyOpaqueChildren = true; | - | ||||||||||||||||||||||||||||||||||||
2117 | - | |||||||||||||||||||||||||||||||||||||
2118 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2119 | invalidateGraphicsEffectsRecursively(); | - | ||||||||||||||||||||||||||||||||||||
2120 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2121 | - | |||||||||||||||||||||||||||||||||||||
2122 | if (q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
2123 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2124 | - | |||||||||||||||||||||||||||||||||||||
2125 | QWidget *parent = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2126 | if (!parent)
| 0 | ||||||||||||||||||||||||||||||||||||
2127 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2128 | - | |||||||||||||||||||||||||||||||||||||
2129 | // TODO: instead of setting dirtyflag, manipulate the dirtyregion directly? | - | ||||||||||||||||||||||||||||||||||||
2130 | QWidgetPrivate *pd = parent->d_func(); | - | ||||||||||||||||||||||||||||||||||||
2131 | if (!pd->dirtyOpaqueChildren)
| 0 | ||||||||||||||||||||||||||||||||||||
2132 | pd->setDirtyOpaqueRegion(); never executed: pd->setDirtyOpaqueRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
2133 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2134 | - | |||||||||||||||||||||||||||||||||||||
2135 | const QRegion &QWidgetPrivate::getOpaqueChildren() const | - | ||||||||||||||||||||||||||||||||||||
2136 | { | - | ||||||||||||||||||||||||||||||||||||
2137 | if (!dirtyOpaqueChildren)
| 0 | ||||||||||||||||||||||||||||||||||||
2138 | return opaqueChildren; never executed: return opaqueChildren; | 0 | ||||||||||||||||||||||||||||||||||||
2139 | - | |||||||||||||||||||||||||||||||||||||
2140 | QWidgetPrivate *that = const_cast<QWidgetPrivate*>(this); | - | ||||||||||||||||||||||||||||||||||||
2141 | that->opaqueChildren = QRegion(); | - | ||||||||||||||||||||||||||||||||||||
2142 | - | |||||||||||||||||||||||||||||||||||||
2143 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
2144 | QWidget *child = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
2145 | if (!child || !child->isVisible() || child->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
2146 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2147 | - | |||||||||||||||||||||||||||||||||||||
2148 | const QPoint offset = child->geometry().topLeft(); | - | ||||||||||||||||||||||||||||||||||||
2149 | QWidgetPrivate *childd = child->d_func(); | - | ||||||||||||||||||||||||||||||||||||
2150 | QRegion r = childd->isOpaque ? child->rect() : childd->getOpaqueChildren();
| 0 | ||||||||||||||||||||||||||||||||||||
2151 | if (childd->extra && childd->extra->hasMask)
| 0 | ||||||||||||||||||||||||||||||||||||
2152 | r &= childd->extra->mask; never executed: r &= childd->extra->mask; | 0 | ||||||||||||||||||||||||||||||||||||
2153 | if (r.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
2154 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2155 | r.translate(offset); | - | ||||||||||||||||||||||||||||||||||||
2156 | that->opaqueChildren += r; | - | ||||||||||||||||||||||||||||||||||||
2157 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2158 | - | |||||||||||||||||||||||||||||||||||||
2159 | that->opaqueChildren &= q_func()->rect(); | - | ||||||||||||||||||||||||||||||||||||
2160 | that->dirtyOpaqueChildren = false; | - | ||||||||||||||||||||||||||||||||||||
2161 | - | |||||||||||||||||||||||||||||||||||||
2162 | return that->opaqueChildren; never executed: return that->opaqueChildren; | 0 | ||||||||||||||||||||||||||||||||||||
2163 | } | - | ||||||||||||||||||||||||||||||||||||
2164 | - | |||||||||||||||||||||||||||||||||||||
2165 | void QWidgetPrivate::subtractOpaqueChildren(QRegion &source, const QRect &clipRect) const | - | ||||||||||||||||||||||||||||||||||||
2166 | { | - | ||||||||||||||||||||||||||||||||||||
2167 | if (children.isEmpty() || clipRect.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
2168 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2169 | - | |||||||||||||||||||||||||||||||||||||
2170 | const QRegion &r = getOpaqueChildren(); | - | ||||||||||||||||||||||||||||||||||||
2171 | if (!r.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
2172 | source -= (r & clipRect); never executed: source -= (r & clipRect); | 0 | ||||||||||||||||||||||||||||||||||||
2173 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2174 | - | |||||||||||||||||||||||||||||||||||||
2175 | //subtract any relatives that are higher up than me --- this is too expensive !!! | - | ||||||||||||||||||||||||||||||||||||
2176 | void QWidgetPrivate::subtractOpaqueSiblings(QRegion &sourceRegion, bool *hasDirtySiblingsAbove, | - | ||||||||||||||||||||||||||||||||||||
2177 | bool alsoNonOpaque) const | - | ||||||||||||||||||||||||||||||||||||
2178 | { | - | ||||||||||||||||||||||||||||||||||||
2179 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2180 | static int disableSubtractOpaqueSiblings = qEnvironmentVariableIntValue("QT_NO_SUBTRACTOPAQUESIBLINGS"); | - | ||||||||||||||||||||||||||||||||||||
2181 | if (disableSubtractOpaqueSiblings || q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
2182 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2183 | - | |||||||||||||||||||||||||||||||||||||
2184 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2185 | if (q->d_func()->isInUnifiedToolbar) | - | ||||||||||||||||||||||||||||||||||||
2186 | return; | - | ||||||||||||||||||||||||||||||||||||
2187 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2188 | - | |||||||||||||||||||||||||||||||||||||
2189 | QRect clipBoundingRect; | - | ||||||||||||||||||||||||||||||||||||
2190 | bool dirtyClipBoundingRect = true; | - | ||||||||||||||||||||||||||||||||||||
2191 | - | |||||||||||||||||||||||||||||||||||||
2192 | QRegion parentClip; | - | ||||||||||||||||||||||||||||||||||||
2193 | bool dirtyParentClip = true; | - | ||||||||||||||||||||||||||||||||||||
2194 | - | |||||||||||||||||||||||||||||||||||||
2195 | QPoint parentOffset = data.crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
2196 | - | |||||||||||||||||||||||||||||||||||||
2197 | const QWidget *w = q; | - | ||||||||||||||||||||||||||||||||||||
2198 | - | |||||||||||||||||||||||||||||||||||||
2199 | while (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
2200 | if (w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
2201 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
2202 | QWidgetPrivate *pd = w->parentWidget()->d_func(); | - | ||||||||||||||||||||||||||||||||||||
2203 | const int myIndex = pd->children.indexOf(const_cast<QWidget *>(w)); | - | ||||||||||||||||||||||||||||||||||||
2204 | const QRect widgetGeometry = w->d_func()->effectiveRectFor(w->data->crect); | - | ||||||||||||||||||||||||||||||||||||
2205 | for (int i = myIndex + 1; i < pd->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
2206 | QWidget *sibling = qobject_cast<QWidget *>(pd->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
2207 | if (!sibling || !sibling->isVisible() || sibling->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
2208 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2209 | - | |||||||||||||||||||||||||||||||||||||
2210 | const QRect siblingGeometry = sibling->d_func()->effectiveRectFor(sibling->data->crect); | - | ||||||||||||||||||||||||||||||||||||
2211 | if (!qRectIntersects(siblingGeometry, widgetGeometry))
| 0 | ||||||||||||||||||||||||||||||||||||
2212 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2213 | - | |||||||||||||||||||||||||||||||||||||
2214 | if (dirtyClipBoundingRect) {
| 0 | ||||||||||||||||||||||||||||||||||||
2215 | clipBoundingRect = sourceRegion.boundingRect(); | - | ||||||||||||||||||||||||||||||||||||
2216 | dirtyClipBoundingRect = false; | - | ||||||||||||||||||||||||||||||||||||
2217 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2218 | - | |||||||||||||||||||||||||||||||||||||
2219 | if (!qRectIntersects(siblingGeometry, clipBoundingRect.translated(parentOffset)))
| 0 | ||||||||||||||||||||||||||||||||||||
2220 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2221 | - | |||||||||||||||||||||||||||||||||||||
2222 | if (dirtyParentClip) {
| 0 | ||||||||||||||||||||||||||||||||||||
2223 | parentClip = sourceRegion.translated(parentOffset); | - | ||||||||||||||||||||||||||||||||||||
2224 | dirtyParentClip = false; | - | ||||||||||||||||||||||||||||||||||||
2225 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2226 | - | |||||||||||||||||||||||||||||||||||||
2227 | const QPoint siblingPos(sibling->data->crect.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
2228 | const QRect siblingClipRect(sibling->d_func()->clipRect()); | - | ||||||||||||||||||||||||||||||||||||
2229 | QRegion siblingDirty(parentClip); | - | ||||||||||||||||||||||||||||||||||||
2230 | siblingDirty &= (siblingClipRect.translated(siblingPos)); | - | ||||||||||||||||||||||||||||||||||||
2231 | const bool hasMask = sibling->d_func()->extra && sibling->d_func()->extra->hasMask
| 0 | ||||||||||||||||||||||||||||||||||||
2232 | && !sibling->d_func()->graphicsEffect;
| 0 | ||||||||||||||||||||||||||||||||||||
2233 | if (hasMask)
| 0 | ||||||||||||||||||||||||||||||||||||
2234 | siblingDirty &= sibling->d_func()->extra->mask.translated(siblingPos); never executed: siblingDirty &= sibling->d_func()->extra->mask.translated(siblingPos); | 0 | ||||||||||||||||||||||||||||||||||||
2235 | if (siblingDirty.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
2236 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2237 | - | |||||||||||||||||||||||||||||||||||||
2238 | if (sibling->d_func()->isOpaque || alsoNonOpaque) {
| 0 | ||||||||||||||||||||||||||||||||||||
2239 | if (hasMask) {
| 0 | ||||||||||||||||||||||||||||||||||||
2240 | siblingDirty.translate(-parentOffset); | - | ||||||||||||||||||||||||||||||||||||
2241 | sourceRegion -= siblingDirty; | - | ||||||||||||||||||||||||||||||||||||
2242 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2243 | sourceRegion -= siblingGeometry.translated(-parentOffset); | - | ||||||||||||||||||||||||||||||||||||
2244 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2245 | } else { | - | ||||||||||||||||||||||||||||||||||||
2246 | if (hasDirtySiblingsAbove)
| 0 | ||||||||||||||||||||||||||||||||||||
2247 | *hasDirtySiblingsAbove = true; never executed: *hasDirtySiblingsAbove = true; | 0 | ||||||||||||||||||||||||||||||||||||
2248 | if (sibling->d_func()->children.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
2249 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
2250 | QRegion opaqueSiblingChildren(sibling->d_func()->getOpaqueChildren()); | - | ||||||||||||||||||||||||||||||||||||
2251 | opaqueSiblingChildren.translate(-parentOffset + siblingPos); | - | ||||||||||||||||||||||||||||||||||||
2252 | sourceRegion -= opaqueSiblingChildren; | - | ||||||||||||||||||||||||||||||||||||
2253 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2254 | if (sourceRegion.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
2255 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2256 | - | |||||||||||||||||||||||||||||||||||||
2257 | dirtyClipBoundingRect = true; | - | ||||||||||||||||||||||||||||||||||||
2258 | dirtyParentClip = true; | - | ||||||||||||||||||||||||||||||||||||
2259 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2260 | - | |||||||||||||||||||||||||||||||||||||
2261 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2262 | parentOffset += pd->data.crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
2263 | dirtyParentClip = true; | - | ||||||||||||||||||||||||||||||||||||
2264 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2265 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2266 | - | |||||||||||||||||||||||||||||||||||||
2267 | void QWidgetPrivate::clipToEffectiveMask(QRegion ®ion) const | - | ||||||||||||||||||||||||||||||||||||
2268 | { | - | ||||||||||||||||||||||||||||||||||||
2269 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2270 | - | |||||||||||||||||||||||||||||||||||||
2271 | const QWidget *w = q; | - | ||||||||||||||||||||||||||||||||||||
2272 | QPoint offset; | - | ||||||||||||||||||||||||||||||||||||
2273 | - | |||||||||||||||||||||||||||||||||||||
2274 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2275 | if (graphicsEffect) {
| 0 | ||||||||||||||||||||||||||||||||||||
2276 | w = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2277 | offset -= data.crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
2278 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2279 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2280 | - | |||||||||||||||||||||||||||||||||||||
2281 | while (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
2282 | const QWidgetPrivate *wd = w->d_func(); | - | ||||||||||||||||||||||||||||||||||||
2283 | if (wd->extra && wd->extra->hasMask)
| 0 | ||||||||||||||||||||||||||||||||||||
2284 | 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 | ||||||||||||||||||||||||||||||||||||
2285 | if (w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
2286 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2287 | offset -= wd->data.crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
2288 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2289 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2290 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2291 | - | |||||||||||||||||||||||||||||||||||||
2292 | bool QWidgetPrivate::paintOnScreen() const | - | ||||||||||||||||||||||||||||||||||||
2293 | { | - | ||||||||||||||||||||||||||||||||||||
2294 | #if defined(QT_NO_BACKINGSTORE) | - | ||||||||||||||||||||||||||||||||||||
2295 | return true; | - | ||||||||||||||||||||||||||||||||||||
2296 | #else | - | ||||||||||||||||||||||||||||||||||||
2297 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2298 | if (q->testAttribute(Qt::WA_PaintOnScreen)
| 0 | ||||||||||||||||||||||||||||||||||||
2299 | || (!q->isWindow() && q->window()->testAttribute(Qt::WA_PaintOnScreen))) {
| 0 | ||||||||||||||||||||||||||||||||||||
2300 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
2301 | } | - | ||||||||||||||||||||||||||||||||||||
2302 | - | |||||||||||||||||||||||||||||||||||||
2303 | return !qt_enable_backingstore; never executed: return !qt_enable_backingstore; | 0 | ||||||||||||||||||||||||||||||||||||
2304 | #endif | - | ||||||||||||||||||||||||||||||||||||
2305 | } | - | ||||||||||||||||||||||||||||||||||||
2306 | - | |||||||||||||||||||||||||||||||||||||
2307 | void QWidgetPrivate::updateIsOpaque() | - | ||||||||||||||||||||||||||||||||||||
2308 | { | - | ||||||||||||||||||||||||||||||||||||
2309 | // hw: todo: only needed if opacity actually changed | - | ||||||||||||||||||||||||||||||||||||
2310 | setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
2311 | - | |||||||||||||||||||||||||||||||||||||
2312 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2313 | if (graphicsEffect) {
| 0 | ||||||||||||||||||||||||||||||||||||
2314 | // ### We should probably add QGraphicsEffect::isOpaque at some point. | - | ||||||||||||||||||||||||||||||||||||
2315 | setOpaque(false); | - | ||||||||||||||||||||||||||||||||||||
2316 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2317 | } | - | ||||||||||||||||||||||||||||||||||||
2318 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
2319 | - | |||||||||||||||||||||||||||||||||||||
2320 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2321 | #ifdef Q_DEAD_CODE_FROM_QT4_X11 | - | ||||||||||||||||||||||||||||||||||||
2322 | if (q->testAttribute(Qt::WA_X11OpenGLOverlay)) { | - | ||||||||||||||||||||||||||||||||||||
2323 | setOpaque(false); | - | ||||||||||||||||||||||||||||||||||||
2324 | return; | - | ||||||||||||||||||||||||||||||||||||
2325 | } | - | ||||||||||||||||||||||||||||||||||||
2326 | #endif | - | ||||||||||||||||||||||||||||||||||||
2327 | - | |||||||||||||||||||||||||||||||||||||
2328 | if (q->testAttribute(Qt::WA_OpaquePaintEvent) || q->testAttribute(Qt::WA_PaintOnScreen)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2329 | setOpaque(true); | - | ||||||||||||||||||||||||||||||||||||
2330 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2331 | } | - | ||||||||||||||||||||||||||||||||||||
2332 | - | |||||||||||||||||||||||||||||||||||||
2333 | const QPalette &pal = q->palette(); | - | ||||||||||||||||||||||||||||||||||||
2334 | - | |||||||||||||||||||||||||||||||||||||
2335 | if (q->autoFillBackground()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2336 | const QBrush &autoFillBrush = pal.brush(q->backgroundRole()); | - | ||||||||||||||||||||||||||||||||||||
2337 | if (autoFillBrush.style() != Qt::NoBrush && autoFillBrush.isOpaque()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2338 | setOpaque(true); | - | ||||||||||||||||||||||||||||||||||||
2339 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2340 | } | - | ||||||||||||||||||||||||||||||||||||
2341 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2342 | - | |||||||||||||||||||||||||||||||||||||
2343 | if (q->isWindow() && !q->testAttribute(Qt::WA_NoSystemBackground)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2344 | const QBrush &windowBrush = q->palette().brush(QPalette::Window); | - | ||||||||||||||||||||||||||||||||||||
2345 | if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2346 | setOpaque(true); | - | ||||||||||||||||||||||||||||||||||||
2347 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2348 | } | - | ||||||||||||||||||||||||||||||||||||
2349 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2350 | setOpaque(false); | - | ||||||||||||||||||||||||||||||||||||
2351 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2352 | - | |||||||||||||||||||||||||||||||||||||
2353 | void QWidgetPrivate::setOpaque(bool opaque) | - | ||||||||||||||||||||||||||||||||||||
2354 | { | - | ||||||||||||||||||||||||||||||||||||
2355 | if (isOpaque != opaque) {
| 0 | ||||||||||||||||||||||||||||||||||||
2356 | isOpaque = opaque; | - | ||||||||||||||||||||||||||||||||||||
2357 | updateIsTranslucent(); | - | ||||||||||||||||||||||||||||||||||||
2358 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2359 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2360 | - | |||||||||||||||||||||||||||||||||||||
2361 | void QWidgetPrivate::updateIsTranslucent() | - | ||||||||||||||||||||||||||||||||||||
2362 | { | - | ||||||||||||||||||||||||||||||||||||
2363 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2364 | if (QWindow *window = q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2365 | QSurfaceFormat format = window->format(); | - | ||||||||||||||||||||||||||||||||||||
2366 | const int oldAlpha = format.alphaBufferSize(); | - | ||||||||||||||||||||||||||||||||||||
2367 | const int newAlpha = q->testAttribute(Qt::WA_TranslucentBackground)? 8 : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
2368 | if (oldAlpha != newAlpha) {
| 0 | ||||||||||||||||||||||||||||||||||||
2369 | format.setAlphaBufferSize(newAlpha); | - | ||||||||||||||||||||||||||||||||||||
2370 | window->setFormat(format); | - | ||||||||||||||||||||||||||||||||||||
2371 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2372 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2373 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2374 | - | |||||||||||||||||||||||||||||||||||||
2375 | static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrush &brush) | - | ||||||||||||||||||||||||||||||||||||
2376 | { | - | ||||||||||||||||||||||||||||||||||||
2377 | Q_ASSERT(painter); | - | ||||||||||||||||||||||||||||||||||||
2378 | - | |||||||||||||||||||||||||||||||||||||
2379 | if (brush.style() == Qt::TexturePattern) {
| 0 | ||||||||||||||||||||||||||||||||||||
2380 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2381 | // Optimize pattern filling on mac by using HITheme directly | - | ||||||||||||||||||||||||||||||||||||
2382 | // when filling with the standard widget background. | - | ||||||||||||||||||||||||||||||||||||
2383 | // Defined in qmacstyle_mac.cpp | - | ||||||||||||||||||||||||||||||||||||
2384 | extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush); | - | ||||||||||||||||||||||||||||||||||||
2385 | qt_mac_fill_background(painter, rgn, brush); | - | ||||||||||||||||||||||||||||||||||||
2386 | #else | - | ||||||||||||||||||||||||||||||||||||
2387 | { | - | ||||||||||||||||||||||||||||||||||||
2388 | const QRect rect(rgn.boundingRect()); | - | ||||||||||||||||||||||||||||||||||||
2389 | painter->setClipRegion(rgn); | - | ||||||||||||||||||||||||||||||||||||
2390 | painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
2391 | } | - | ||||||||||||||||||||||||||||||||||||
2392 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2393 | - | |||||||||||||||||||||||||||||||||||||
2394 | } else if (brush.gradient() never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
2395 | && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode) {
| 0 | ||||||||||||||||||||||||||||||||||||
2396 | painter->save(); | - | ||||||||||||||||||||||||||||||||||||
2397 | painter->setClipRegion(rgn); | - | ||||||||||||||||||||||||||||||||||||
2398 | painter->fillRect(0, 0, painter->device()->width(), painter->device()->height(), brush); | - | ||||||||||||||||||||||||||||||||||||
2399 | painter->restore(); | - | ||||||||||||||||||||||||||||||||||||
2400 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2401 | const QVector<QRect> &rects = rgn.rects(); | - | ||||||||||||||||||||||||||||||||||||
2402 | for (int i = 0; i < rects.size(); ++i)
| 0 | ||||||||||||||||||||||||||||||||||||
2403 | painter->fillRect(rects.at(i), brush); never executed: painter->fillRect(rects.at(i), brush); | 0 | ||||||||||||||||||||||||||||||||||||
2404 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2405 | } | - | ||||||||||||||||||||||||||||||||||||
2406 | - | |||||||||||||||||||||||||||||||||||||
2407 | void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int flags) const | - | ||||||||||||||||||||||||||||||||||||
2408 | { | - | ||||||||||||||||||||||||||||||||||||
2409 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2410 | - | |||||||||||||||||||||||||||||||||||||
2411 | #ifndef QT_NO_SCROLLAREA | - | ||||||||||||||||||||||||||||||||||||
2412 | bool resetBrushOrigin = false; | - | ||||||||||||||||||||||||||||||||||||
2413 | QPointF oldBrushOrigin; | - | ||||||||||||||||||||||||||||||||||||
2414 | //If we are painting the viewport of a scrollarea, we must apply an offset to the brush in case we are drawing a texture | - | ||||||||||||||||||||||||||||||||||||
2415 | QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent); | - | ||||||||||||||||||||||||||||||||||||
2416 | if (scrollArea && scrollArea->viewport() == q) {
| 0 | ||||||||||||||||||||||||||||||||||||
2417 | QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr.data(); | - | ||||||||||||||||||||||||||||||||||||
2418 | QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate); | - | ||||||||||||||||||||||||||||||||||||
2419 | oldBrushOrigin = painter->brushOrigin(); | - | ||||||||||||||||||||||||||||||||||||
2420 | resetBrushOrigin = true; | - | ||||||||||||||||||||||||||||||||||||
2421 | painter->setBrushOrigin(-priv->contentsOffset()); | - | ||||||||||||||||||||||||||||||||||||
2422 | - | |||||||||||||||||||||||||||||||||||||
2423 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2424 | #endif // QT_NO_SCROLLAREA | - | ||||||||||||||||||||||||||||||||||||
2425 | - | |||||||||||||||||||||||||||||||||||||
2426 | const QBrush autoFillBrush = q->palette().brush(q->backgroundRole()); | - | ||||||||||||||||||||||||||||||||||||
2427 | - | |||||||||||||||||||||||||||||||||||||
2428 | if ((flags & DrawAsRoot) && !(q->autoFillBackground() && autoFillBrush.isOpaque())) {
| 0 | ||||||||||||||||||||||||||||||||||||
2429 | const QBrush bg = q->palette().brush(QPalette::Window); | - | ||||||||||||||||||||||||||||||||||||
2430 | if (!(flags & DontSetCompositionMode)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2431 | //copy alpha straight in | - | ||||||||||||||||||||||||||||||||||||
2432 | QPainter::CompositionMode oldMode = painter->compositionMode(); | - | ||||||||||||||||||||||||||||||||||||
2433 | painter->setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||||||||||||||||||||||||||||||||
2434 | fillRegion(painter, rgn, bg); | - | ||||||||||||||||||||||||||||||||||||
2435 | painter->setCompositionMode(oldMode); | - | ||||||||||||||||||||||||||||||||||||
2436 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2437 | fillRegion(painter, rgn, bg); | - | ||||||||||||||||||||||||||||||||||||
2438 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2439 | } | - | ||||||||||||||||||||||||||||||||||||
2440 | - | |||||||||||||||||||||||||||||||||||||
2441 | if (q->autoFillBackground())
| 0 | ||||||||||||||||||||||||||||||||||||
2442 | fillRegion(painter, rgn, autoFillBrush); never executed: fillRegion(painter, rgn, autoFillBrush); | 0 | ||||||||||||||||||||||||||||||||||||
2443 | - | |||||||||||||||||||||||||||||||||||||
2444 | if (q->testAttribute(Qt::WA_StyledBackground)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2445 | painter->setClipRegion(rgn); | - | ||||||||||||||||||||||||||||||||||||
2446 | QStyleOption opt; | - | ||||||||||||||||||||||||||||||||||||
2447 | opt.initFrom(q); | - | ||||||||||||||||||||||||||||||||||||
2448 | q->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, q); | - | ||||||||||||||||||||||||||||||||||||
2449 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2450 | - | |||||||||||||||||||||||||||||||||||||
2451 | #ifndef QT_NO_SCROLLAREA | - | ||||||||||||||||||||||||||||||||||||
2452 | if (resetBrushOrigin)
| 0 | ||||||||||||||||||||||||||||||||||||
2453 | painter->setBrushOrigin(oldBrushOrigin); never executed: painter->setBrushOrigin(oldBrushOrigin); | 0 | ||||||||||||||||||||||||||||||||||||
2454 | #endif // QT_NO_SCROLLAREA | - | ||||||||||||||||||||||||||||||||||||
2455 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2456 | - | |||||||||||||||||||||||||||||||||||||
2457 | /* | - | ||||||||||||||||||||||||||||||||||||
2458 | \internal | - | ||||||||||||||||||||||||||||||||||||
2459 | This function is called when a widget is hidden or destroyed. | - | ||||||||||||||||||||||||||||||||||||
2460 | It resets some application global pointers that should only refer active, | - | ||||||||||||||||||||||||||||||||||||
2461 | visible widgets. | - | ||||||||||||||||||||||||||||||||||||
2462 | */ | - | ||||||||||||||||||||||||||||||||||||
2463 | - | |||||||||||||||||||||||||||||||||||||
2464 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2465 | extern QPointer<QWidget> qt_button_down; | - | ||||||||||||||||||||||||||||||||||||
2466 | #else | - | ||||||||||||||||||||||||||||||||||||
2467 | extern QWidget *qt_button_down; | - | ||||||||||||||||||||||||||||||||||||
2468 | #endif | - | ||||||||||||||||||||||||||||||||||||
2469 | - | |||||||||||||||||||||||||||||||||||||
2470 | void QWidgetPrivate::deactivateWidgetCleanup() | - | ||||||||||||||||||||||||||||||||||||
2471 | { | - | ||||||||||||||||||||||||||||||||||||
2472 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2473 | // If this was the active application window, reset it | - | ||||||||||||||||||||||||||||||||||||
2474 | if (QApplication::activeWindow() == q)
| 0 | ||||||||||||||||||||||||||||||||||||
2475 | QApplication::setActiveWindow(0); never executed: QApplication::setActiveWindow(0); | 0 | ||||||||||||||||||||||||||||||||||||
2476 | // If the is the active mouse press widget, reset it | - | ||||||||||||||||||||||||||||||||||||
2477 | if (q == qt_button_down)
| 0 | ||||||||||||||||||||||||||||||||||||
2478 | qt_button_down = 0; never executed: qt_button_down = 0; | 0 | ||||||||||||||||||||||||||||||||||||
2479 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2480 | - | |||||||||||||||||||||||||||||||||||||
2481 | - | |||||||||||||||||||||||||||||||||||||
2482 | /*! | - | ||||||||||||||||||||||||||||||||||||
2483 | Returns a pointer to the widget with window identifer/handle \a | - | ||||||||||||||||||||||||||||||||||||
2484 | id. | - | ||||||||||||||||||||||||||||||||||||
2485 | - | |||||||||||||||||||||||||||||||||||||
2486 | The window identifier type depends on the underlying window | - | ||||||||||||||||||||||||||||||||||||
2487 | system, see \c qwindowdefs.h for the actual definition. If there | - | ||||||||||||||||||||||||||||||||||||
2488 | is no widget with this identifier, 0 is returned. | - | ||||||||||||||||||||||||||||||||||||
2489 | */ | - | ||||||||||||||||||||||||||||||||||||
2490 | - | |||||||||||||||||||||||||||||||||||||
2491 | QWidget *QWidget::find(WId id) | - | ||||||||||||||||||||||||||||||||||||
2492 | { | - | ||||||||||||||||||||||||||||||||||||
2493 | return QWidgetPrivate::mapper ? QWidgetPrivate::mapper->value(id, 0) : 0; never executed: return QWidgetPrivate::mapper ? QWidgetPrivate::mapper->value(id, 0) : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
2494 | } | - | ||||||||||||||||||||||||||||||||||||
2495 | - | |||||||||||||||||||||||||||||||||||||
2496 | - | |||||||||||||||||||||||||||||||||||||
2497 | - | |||||||||||||||||||||||||||||||||||||
2498 | /*! | - | ||||||||||||||||||||||||||||||||||||
2499 | \fn WId QWidget::internalWinId() const | - | ||||||||||||||||||||||||||||||||||||
2500 | \internal | - | ||||||||||||||||||||||||||||||||||||
2501 | Returns the window system identifier of the widget, or 0 if the widget is not created yet. | - | ||||||||||||||||||||||||||||||||||||
2502 | - | |||||||||||||||||||||||||||||||||||||
2503 | */ | - | ||||||||||||||||||||||||||||||||||||
2504 | - | |||||||||||||||||||||||||||||||||||||
2505 | /*! | - | ||||||||||||||||||||||||||||||||||||
2506 | \fn WId QWidget::winId() const | - | ||||||||||||||||||||||||||||||||||||
2507 | - | |||||||||||||||||||||||||||||||||||||
2508 | Returns the window system identifier of the widget. | - | ||||||||||||||||||||||||||||||||||||
2509 | - | |||||||||||||||||||||||||||||||||||||
2510 | Portable in principle, but if you use it you are probably about to | - | ||||||||||||||||||||||||||||||||||||
2511 | do something non-portable. Be careful. | - | ||||||||||||||||||||||||||||||||||||
2512 | - | |||||||||||||||||||||||||||||||||||||
2513 | If a widget is non-native (alien) and winId() is invoked on it, that widget | - | ||||||||||||||||||||||||||||||||||||
2514 | will be provided a native handle. | - | ||||||||||||||||||||||||||||||||||||
2515 | - | |||||||||||||||||||||||||||||||||||||
2516 | On \macos, the type returned depends on which framework Qt was linked | - | ||||||||||||||||||||||||||||||||||||
2517 | against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt | - | ||||||||||||||||||||||||||||||||||||
2518 | is using Cocoa, {WId} is a pointer to an NSView. | - | ||||||||||||||||||||||||||||||||||||
2519 | - | |||||||||||||||||||||||||||||||||||||
2520 | This value may change at run-time. An event with type QEvent::WinIdChange | - | ||||||||||||||||||||||||||||||||||||
2521 | will be sent to the widget following a change in window system identifier. | - | ||||||||||||||||||||||||||||||||||||
2522 | - | |||||||||||||||||||||||||||||||||||||
2523 | \sa find() | - | ||||||||||||||||||||||||||||||||||||
2524 | */ | - | ||||||||||||||||||||||||||||||||||||
2525 | WId QWidget::winId() const | - | ||||||||||||||||||||||||||||||||||||
2526 | { | - | ||||||||||||||||||||||||||||||||||||
2527 | if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2528 | #ifdef ALIEN_DEBUG | - | ||||||||||||||||||||||||||||||||||||
2529 | qDebug() << "QWidget::winId: creating native window for" << this; | - | ||||||||||||||||||||||||||||||||||||
2530 | #endif | - | ||||||||||||||||||||||||||||||||||||
2531 | QWidget *that = const_cast<QWidget*>(this); | - | ||||||||||||||||||||||||||||||||||||
2532 | that->setAttribute(Qt::WA_NativeWindow); | - | ||||||||||||||||||||||||||||||||||||
2533 | that->d_func()->createWinId(); | - | ||||||||||||||||||||||||||||||||||||
2534 | return that->data->winid; never executed: return that->data->winid; | 0 | ||||||||||||||||||||||||||||||||||||
2535 | } | - | ||||||||||||||||||||||||||||||||||||
2536 | return data->winid; never executed: return data->winid; | 0 | ||||||||||||||||||||||||||||||||||||
2537 | } | - | ||||||||||||||||||||||||||||||||||||
2538 | - | |||||||||||||||||||||||||||||||||||||
2539 | void QWidgetPrivate::createWinId() | - | ||||||||||||||||||||||||||||||||||||
2540 | { | - | ||||||||||||||||||||||||||||||||||||
2541 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2542 | - | |||||||||||||||||||||||||||||||||||||
2543 | #ifdef ALIEN_DEBUG | - | ||||||||||||||||||||||||||||||||||||
2544 | qDebug() << "QWidgetPrivate::createWinId for" << q; | - | ||||||||||||||||||||||||||||||||||||
2545 | #endif | - | ||||||||||||||||||||||||||||||||||||
2546 | const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow); | - | ||||||||||||||||||||||||||||||||||||
2547 | if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) {
| 0 | ||||||||||||||||||||||||||||||||||||
2548 | if (!q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2549 | QWidget *parent = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2550 | QWidgetPrivate *pd = parent->d_func(); | - | ||||||||||||||||||||||||||||||||||||
2551 | if (forceNativeWindow && !q->testAttribute(Qt::WA_DontCreateNativeAncestors))
| 0 | ||||||||||||||||||||||||||||||||||||
2552 | parent->setAttribute(Qt::WA_NativeWindow); never executed: parent->setAttribute(Qt::WA_NativeWindow); | 0 | ||||||||||||||||||||||||||||||||||||
2553 | if (!parent->internalWinId()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2554 | pd->createWinId(); | - | ||||||||||||||||||||||||||||||||||||
2555 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2556 | - | |||||||||||||||||||||||||||||||||||||
2557 | for (int i = 0; i < pd->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
2558 | QWidget *w = qobject_cast<QWidget *>(pd->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
2559 | if (w && !w->isWindow() && (!w->testAttribute(Qt::WA_WState_Created)
| 0 | ||||||||||||||||||||||||||||||||||||
2560 | || (!w->internalWinId() && w->testAttribute(Qt::WA_NativeWindow)))) {
| 0 | ||||||||||||||||||||||||||||||||||||
2561 | w->create(); | - | ||||||||||||||||||||||||||||||||||||
2562 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2563 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2564 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2565 | q->create(); | - | ||||||||||||||||||||||||||||||||||||
2566 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2567 | } | - | ||||||||||||||||||||||||||||||||||||
2568 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2569 | - | |||||||||||||||||||||||||||||||||||||
2570 | - | |||||||||||||||||||||||||||||||||||||
2571 | /*! | - | ||||||||||||||||||||||||||||||||||||
2572 | \internal | - | ||||||||||||||||||||||||||||||||||||
2573 | Ensures that the widget has a window system identifier, i.e. that it is known to the windowing system. | - | ||||||||||||||||||||||||||||||||||||
2574 | - | |||||||||||||||||||||||||||||||||||||
2575 | */ | - | ||||||||||||||||||||||||||||||||||||
2576 | - | |||||||||||||||||||||||||||||||||||||
2577 | void QWidget::createWinId() | - | ||||||||||||||||||||||||||||||||||||
2578 | { | - | ||||||||||||||||||||||||||||||||||||
2579 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2580 | #ifdef ALIEN_DEBUG | - | ||||||||||||||||||||||||||||||||||||
2581 | qDebug() << "QWidget::createWinId" << this; | - | ||||||||||||||||||||||||||||||||||||
2582 | #endif | - | ||||||||||||||||||||||||||||||||||||
2583 | // qWarning("QWidget::createWinId is obsolete, please fix your code."); | - | ||||||||||||||||||||||||||||||||||||
2584 | d->createWinId(); | - | ||||||||||||||||||||||||||||||||||||
2585 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2586 | - | |||||||||||||||||||||||||||||||||||||
2587 | /*! | - | ||||||||||||||||||||||||||||||||||||
2588 | \since 4.4 | - | ||||||||||||||||||||||||||||||||||||
2589 | - | |||||||||||||||||||||||||||||||||||||
2590 | Returns the effective window system identifier of the widget, i.e. the | - | ||||||||||||||||||||||||||||||||||||
2591 | native parent's window system identifier. | - | ||||||||||||||||||||||||||||||||||||
2592 | - | |||||||||||||||||||||||||||||||||||||
2593 | If the widget is native, this function returns the native widget ID. | - | ||||||||||||||||||||||||||||||||||||
2594 | Otherwise, the window ID of the first native parent widget, i.e., the | - | ||||||||||||||||||||||||||||||||||||
2595 | top-level widget that contains this widget, is returned. | - | ||||||||||||||||||||||||||||||||||||
2596 | - | |||||||||||||||||||||||||||||||||||||
2597 | \note We recommend that you do not store this value as it is likely to | - | ||||||||||||||||||||||||||||||||||||
2598 | change at run-time. | - | ||||||||||||||||||||||||||||||||||||
2599 | - | |||||||||||||||||||||||||||||||||||||
2600 | \sa nativeParentWidget() | - | ||||||||||||||||||||||||||||||||||||
2601 | */ | - | ||||||||||||||||||||||||||||||||||||
2602 | WId QWidget::effectiveWinId() const | - | ||||||||||||||||||||||||||||||||||||
2603 | { | - | ||||||||||||||||||||||||||||||||||||
2604 | const WId id = internalWinId(); | - | ||||||||||||||||||||||||||||||||||||
2605 | if (id || !testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
2606 | return id; never executed: return id; | 0 | ||||||||||||||||||||||||||||||||||||
2607 | if (const QWidget *realParent = nativeParentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
2608 | return realParent->internalWinId(); never executed: return realParent->internalWinId(); | 0 | ||||||||||||||||||||||||||||||||||||
2609 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
2610 | } | - | ||||||||||||||||||||||||||||||||||||
2611 | - | |||||||||||||||||||||||||||||||||||||
2612 | /*! | - | ||||||||||||||||||||||||||||||||||||
2613 | If this is a native widget, return the associated QWindow. | - | ||||||||||||||||||||||||||||||||||||
2614 | Otherwise return null. | - | ||||||||||||||||||||||||||||||||||||
2615 | - | |||||||||||||||||||||||||||||||||||||
2616 | Native widgets include toplevel widgets, QGLWidget, and child widgets | - | ||||||||||||||||||||||||||||||||||||
2617 | on which winId() was called. | - | ||||||||||||||||||||||||||||||||||||
2618 | - | |||||||||||||||||||||||||||||||||||||
2619 | \since 5.0 | - | ||||||||||||||||||||||||||||||||||||
2620 | - | |||||||||||||||||||||||||||||||||||||
2621 | \sa winId() | - | ||||||||||||||||||||||||||||||||||||
2622 | */ | - | ||||||||||||||||||||||||||||||||||||
2623 | QWindow *QWidget::windowHandle() const | - | ||||||||||||||||||||||||||||||||||||
2624 | { | - | ||||||||||||||||||||||||||||||||||||
2625 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2626 | QTLWExtra *extra = d->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
2627 | if (extra)
| 0 | ||||||||||||||||||||||||||||||||||||
2628 | return extra->window; never executed: return extra->window; | 0 | ||||||||||||||||||||||||||||||||||||
2629 | - | |||||||||||||||||||||||||||||||||||||
2630 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
2631 | } | - | ||||||||||||||||||||||||||||||||||||
2632 | - | |||||||||||||||||||||||||||||||||||||
2633 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2634 | - | |||||||||||||||||||||||||||||||||||||
2635 | /*! | - | ||||||||||||||||||||||||||||||||||||
2636 | \property QWidget::styleSheet | - | ||||||||||||||||||||||||||||||||||||
2637 | \brief the widget's style sheet | - | ||||||||||||||||||||||||||||||||||||
2638 | \since 4.2 | - | ||||||||||||||||||||||||||||||||||||
2639 | - | |||||||||||||||||||||||||||||||||||||
2640 | The style sheet contains a textual description of customizations to the | - | ||||||||||||||||||||||||||||||||||||
2641 | widget's style, as described in the \l{Qt Style Sheets} document. | - | ||||||||||||||||||||||||||||||||||||
2642 | - | |||||||||||||||||||||||||||||||||||||
2643 | Since Qt 4.5, Qt style sheets fully supports \macos. | - | ||||||||||||||||||||||||||||||||||||
2644 | - | |||||||||||||||||||||||||||||||||||||
2645 | \warning Qt style sheets are currently not supported for custom QStyle | - | ||||||||||||||||||||||||||||||||||||
2646 | subclasses. We plan to address this in some future release. | - | ||||||||||||||||||||||||||||||||||||
2647 | - | |||||||||||||||||||||||||||||||||||||
2648 | \sa setStyle(), QApplication::styleSheet, {Qt Style Sheets} | - | ||||||||||||||||||||||||||||||||||||
2649 | */ | - | ||||||||||||||||||||||||||||||||||||
2650 | QString QWidget::styleSheet() const | - | ||||||||||||||||||||||||||||||||||||
2651 | { | - | ||||||||||||||||||||||||||||||||||||
2652 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2653 | if (!d->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
2654 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||||||||
2655 | return d->extra->styleSheet; never executed: return d->extra->styleSheet; | 0 | ||||||||||||||||||||||||||||||||||||
2656 | } | - | ||||||||||||||||||||||||||||||||||||
2657 | - | |||||||||||||||||||||||||||||||||||||
2658 | void QWidget::setStyleSheet(const QString& styleSheet) | - | ||||||||||||||||||||||||||||||||||||
2659 | { | - | ||||||||||||||||||||||||||||||||||||
2660 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2661 | if (data->in_destructor)
| 0 | ||||||||||||||||||||||||||||||||||||
2662 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2663 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
2664 | - | |||||||||||||||||||||||||||||||||||||
2665 | QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(d->extra->style); | - | ||||||||||||||||||||||||||||||||||||
2666 | d->extra->styleSheet = styleSheet; | - | ||||||||||||||||||||||||||||||||||||
2667 | if (styleSheet.isEmpty()) { // stylesheet removed
| 0 | ||||||||||||||||||||||||||||||||||||
2668 | if (!proxy)
| 0 | ||||||||||||||||||||||||||||||||||||
2669 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2670 | - | |||||||||||||||||||||||||||||||||||||
2671 | d->inheritStyle(); | - | ||||||||||||||||||||||||||||||||||||
2672 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2673 | } | - | ||||||||||||||||||||||||||||||||||||
2674 | - | |||||||||||||||||||||||||||||||||||||
2675 | if (proxy) { // style sheet update
| 0 | ||||||||||||||||||||||||||||||||||||
2676 | if (d->polished)
| 0 | ||||||||||||||||||||||||||||||||||||
2677 | proxy->repolish(this); never executed: proxy->repolish(this); | 0 | ||||||||||||||||||||||||||||||||||||
2678 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2679 | } | - | ||||||||||||||||||||||||||||||||||||
2680 | - | |||||||||||||||||||||||||||||||||||||
2681 | if (testAttribute(Qt::WA_SetStyle)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2682 | d->setStyle_helper(new QStyleSheetStyle(d->extra->style), true); | - | ||||||||||||||||||||||||||||||||||||
2683 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2684 | d->setStyle_helper(new QStyleSheetStyle(0), true); | - | ||||||||||||||||||||||||||||||||||||
2685 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2686 | } | - | ||||||||||||||||||||||||||||||||||||
2687 | - | |||||||||||||||||||||||||||||||||||||
2688 | #endif // QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2689 | - | |||||||||||||||||||||||||||||||||||||
2690 | /*! | - | ||||||||||||||||||||||||||||||||||||
2691 | \sa QWidget::setStyle(), QApplication::setStyle(), QApplication::style() | - | ||||||||||||||||||||||||||||||||||||
2692 | */ | - | ||||||||||||||||||||||||||||||||||||
2693 | - | |||||||||||||||||||||||||||||||||||||
2694 | QStyle *QWidget::style() const | - | ||||||||||||||||||||||||||||||||||||
2695 | { | - | ||||||||||||||||||||||||||||||||||||
2696 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
2697 | - | |||||||||||||||||||||||||||||||||||||
2698 | if (d->extra && d->extra->style)
| 0 | ||||||||||||||||||||||||||||||||||||
2699 | return d->extra->style; never executed: return d->extra->style; | 0 | ||||||||||||||||||||||||||||||||||||
2700 | return QApplication::style(); never executed: return QApplication::style(); | 0 | ||||||||||||||||||||||||||||||||||||
2701 | } | - | ||||||||||||||||||||||||||||||||||||
2702 | - | |||||||||||||||||||||||||||||||||||||
2703 | /*! | - | ||||||||||||||||||||||||||||||||||||
2704 | Sets the widget's GUI style to \a style. The ownership of the style | - | ||||||||||||||||||||||||||||||||||||
2705 | object is not transferred. | - | ||||||||||||||||||||||||||||||||||||
2706 | - | |||||||||||||||||||||||||||||||||||||
2707 | If no style is set, the widget uses the application's style, | - | ||||||||||||||||||||||||||||||||||||
2708 | QApplication::style() instead. | - | ||||||||||||||||||||||||||||||||||||
2709 | - | |||||||||||||||||||||||||||||||||||||
2710 | Setting a widget's style has no effect on existing or future child | - | ||||||||||||||||||||||||||||||||||||
2711 | widgets. | - | ||||||||||||||||||||||||||||||||||||
2712 | - | |||||||||||||||||||||||||||||||||||||
2713 | \warning This function is particularly useful for demonstration | - | ||||||||||||||||||||||||||||||||||||
2714 | purposes, where you want to show Qt's styling capabilities. Real | - | ||||||||||||||||||||||||||||||||||||
2715 | applications should avoid it and use one consistent GUI style | - | ||||||||||||||||||||||||||||||||||||
2716 | instead. | - | ||||||||||||||||||||||||||||||||||||
2717 | - | |||||||||||||||||||||||||||||||||||||
2718 | \warning Qt style sheets are currently not supported for custom QStyle | - | ||||||||||||||||||||||||||||||||||||
2719 | subclasses. We plan to address this in some future release. | - | ||||||||||||||||||||||||||||||||||||
2720 | - | |||||||||||||||||||||||||||||||||||||
2721 | \sa style(), QStyle, QApplication::style(), QApplication::setStyle() | - | ||||||||||||||||||||||||||||||||||||
2722 | */ | - | ||||||||||||||||||||||||||||||||||||
2723 | - | |||||||||||||||||||||||||||||||||||||
2724 | void QWidget::setStyle(QStyle *style) | - | ||||||||||||||||||||||||||||||||||||
2725 | { | - | ||||||||||||||||||||||||||||||||||||
2726 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2727 | setAttribute(Qt::WA_SetStyle, style != 0); | - | ||||||||||||||||||||||||||||||||||||
2728 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
2729 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2730 | if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(style)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2731 | //if for some reason someone try to set a QStyleSheetStyle, ref it | - | ||||||||||||||||||||||||||||||||||||
2732 | //(this may happen for exemple in QButtonDialogBox which propagates its style) | - | ||||||||||||||||||||||||||||||||||||
2733 | proxy->ref(); | - | ||||||||||||||||||||||||||||||||||||
2734 | d->setStyle_helper(style, false); | - | ||||||||||||||||||||||||||||||||||||
2735 | } else if (qobject_cast<QStyleSheetStyle *>(d->extra->style) || !qApp->styleSheet().isEmpty()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
2736 | // if we have an application stylesheet or have a proxy already, propagate | - | ||||||||||||||||||||||||||||||||||||
2737 | d->setStyle_helper(new QStyleSheetStyle(style), true); | - | ||||||||||||||||||||||||||||||||||||
2738 | } else never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2739 | #endif | - | ||||||||||||||||||||||||||||||||||||
2740 | d->setStyle_helper(style, false); never executed: d->setStyle_helper(style, false); | 0 | ||||||||||||||||||||||||||||||||||||
2741 | } | - | ||||||||||||||||||||||||||||||||||||
2742 | - | |||||||||||||||||||||||||||||||||||||
2743 | void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool | - | ||||||||||||||||||||||||||||||||||||
2744 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2745 | metalHack | - | ||||||||||||||||||||||||||||||||||||
2746 | #endif | - | ||||||||||||||||||||||||||||||||||||
2747 | ) | - | ||||||||||||||||||||||||||||||||||||
2748 | { | - | ||||||||||||||||||||||||||||||||||||
2749 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2750 | QStyle *oldStyle = q->style(); | - | ||||||||||||||||||||||||||||||||||||
2751 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2752 | QPointer<QStyle> origStyle; | - | ||||||||||||||||||||||||||||||||||||
2753 | #endif | - | ||||||||||||||||||||||||||||||||||||
2754 | - | |||||||||||||||||||||||||||||||||||||
2755 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2756 | // the metalhack boolean allows Qt/Mac to do a proper re-polish depending | - | ||||||||||||||||||||||||||||||||||||
2757 | // on how the Qt::WA_MacBrushedMetal attribute is set. It is only ever | - | ||||||||||||||||||||||||||||||||||||
2758 | // set when changing that attribute and passes the widget's CURRENT style. | - | ||||||||||||||||||||||||||||||||||||
2759 | // therefore no need to do a reassignment. | - | ||||||||||||||||||||||||||||||||||||
2760 | if (!metalHack) | - | ||||||||||||||||||||||||||||||||||||
2761 | #endif | - | ||||||||||||||||||||||||||||||||||||
2762 | { | - | ||||||||||||||||||||||||||||||||||||
2763 | createExtra(); | - | ||||||||||||||||||||||||||||||||||||
2764 | - | |||||||||||||||||||||||||||||||||||||
2765 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2766 | origStyle = extra->style.data(); | - | ||||||||||||||||||||||||||||||||||||
2767 | #endif | - | ||||||||||||||||||||||||||||||||||||
2768 | extra->style = newStyle; | - | ||||||||||||||||||||||||||||||||||||
2769 | } | - | ||||||||||||||||||||||||||||||||||||
2770 | - | |||||||||||||||||||||||||||||||||||||
2771 | // repolish | - | ||||||||||||||||||||||||||||||||||||
2772 | if (q->windowType() != Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
2773 | if (polished) {
| 0 | ||||||||||||||||||||||||||||||||||||
2774 | oldStyle->unpolish(q); | - | ||||||||||||||||||||||||||||||||||||
2775 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2776 | if (metalHack) | - | ||||||||||||||||||||||||||||||||||||
2777 | macUpdateMetalAttribute(); | - | ||||||||||||||||||||||||||||||||||||
2778 | #endif | - | ||||||||||||||||||||||||||||||||||||
2779 | q->style()->polish(q); | - | ||||||||||||||||||||||||||||||||||||
2780 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
2781 | } else if (metalHack) { | - | ||||||||||||||||||||||||||||||||||||
2782 | macUpdateMetalAttribute(); | - | ||||||||||||||||||||||||||||||||||||
2783 | #endif | - | ||||||||||||||||||||||||||||||||||||
2784 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2785 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2786 | - | |||||||||||||||||||||||||||||||||||||
2787 | if (propagate) {
| 0 | ||||||||||||||||||||||||||||||||||||
2788 | // We copy the list because the order may be modified | - | ||||||||||||||||||||||||||||||||||||
2789 | const QObjectList childrenList = children; | - | ||||||||||||||||||||||||||||||||||||
2790 | for (int i = 0; i < childrenList.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
2791 | QWidget *c = qobject_cast<QWidget*>(childrenList.at(i)); | - | ||||||||||||||||||||||||||||||||||||
2792 | if (c)
| 0 | ||||||||||||||||||||||||||||||||||||
2793 | c->d_func()->inheritStyle(); never executed: c->d_func()->inheritStyle(); | 0 | ||||||||||||||||||||||||||||||||||||
2794 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2795 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2796 | - | |||||||||||||||||||||||||||||||||||||
2797 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2798 | if (!qobject_cast<QStyleSheetStyle*>(newStyle)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2799 | if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle.data())) {
| 0 | ||||||||||||||||||||||||||||||||||||
2800 | cssStyle->clearWidgetFont(q); | - | ||||||||||||||||||||||||||||||||||||
2801 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2802 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2803 | #endif | - | ||||||||||||||||||||||||||||||||||||
2804 | - | |||||||||||||||||||||||||||||||||||||
2805 | QEvent e(QEvent::StyleChange); | - | ||||||||||||||||||||||||||||||||||||
2806 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
2807 | - | |||||||||||||||||||||||||||||||||||||
2808 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2809 | // dereference the old stylesheet style | - | ||||||||||||||||||||||||||||||||||||
2810 | if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle.data()))
| 0 | ||||||||||||||||||||||||||||||||||||
2811 | proxy->deref(); never executed: proxy->deref(); | 0 | ||||||||||||||||||||||||||||||||||||
2812 | #endif | - | ||||||||||||||||||||||||||||||||||||
2813 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2814 | - | |||||||||||||||||||||||||||||||||||||
2815 | // Inherits style from the current parent and propagates it as necessary | - | ||||||||||||||||||||||||||||||||||||
2816 | void QWidgetPrivate::inheritStyle() | - | ||||||||||||||||||||||||||||||||||||
2817 | { | - | ||||||||||||||||||||||||||||||||||||
2818 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2819 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2820 | - | |||||||||||||||||||||||||||||||||||||
2821 | QStyleSheetStyle *proxy = extra ? qobject_cast<QStyleSheetStyle *>(extra->style) : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
2822 | - | |||||||||||||||||||||||||||||||||||||
2823 | if (!q->styleSheet().isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
2824 | Q_ASSERT(proxy); | - | ||||||||||||||||||||||||||||||||||||
2825 | proxy->repolish(q); | - | ||||||||||||||||||||||||||||||||||||
2826 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2827 | } | - | ||||||||||||||||||||||||||||||||||||
2828 | - | |||||||||||||||||||||||||||||||||||||
2829 | QStyle *origStyle = proxy ? proxy->base : (extra ? (QStyle*)extra->style : 0);
| 0 | ||||||||||||||||||||||||||||||||||||
2830 | QWidget *parent = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
2831 | QStyle *parentStyle = (parent && parent->d_func()->extra) ? (QStyle*)parent->d_func()->extra->style : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
2832 | // If we have stylesheet on app or parent has stylesheet style, we need | - | ||||||||||||||||||||||||||||||||||||
2833 | // to be running a proxy | - | ||||||||||||||||||||||||||||||||||||
2834 | if (!qApp->styleSheet().isEmpty() || qobject_cast<QStyleSheetStyle *>(parentStyle)) {
| 0 | ||||||||||||||||||||||||||||||||||||
2835 | QStyle *newStyle = parentStyle; | - | ||||||||||||||||||||||||||||||||||||
2836 | if (q->testAttribute(Qt::WA_SetStyle))
| 0 | ||||||||||||||||||||||||||||||||||||
2837 | newStyle = new QStyleSheetStyle(origStyle); never executed: newStyle = new QStyleSheetStyle(origStyle); | 0 | ||||||||||||||||||||||||||||||||||||
2838 | else if (QStyleSheetStyle *newProxy = qobject_cast<QStyleSheetStyle *>(parentStyle))
| 0 | ||||||||||||||||||||||||||||||||||||
2839 | newProxy->ref(); never executed: newProxy->ref(); | 0 | ||||||||||||||||||||||||||||||||||||
2840 | - | |||||||||||||||||||||||||||||||||||||
2841 | setStyle_helper(newStyle, true); | - | ||||||||||||||||||||||||||||||||||||
2842 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2843 | } | - | ||||||||||||||||||||||||||||||||||||
2844 | - | |||||||||||||||||||||||||||||||||||||
2845 | // So, we have no stylesheet on parent/app and we have an empty stylesheet | - | ||||||||||||||||||||||||||||||||||||
2846 | // we just need our original style back | - | ||||||||||||||||||||||||||||||||||||
2847 | if (origStyle == (extra ? (QStyle*)extra->style : 0)) // is it any different?
| 0 | ||||||||||||||||||||||||||||||||||||
2848 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2849 | - | |||||||||||||||||||||||||||||||||||||
2850 | // We could have inherited the proxy from our parent (which has a custom style) | - | ||||||||||||||||||||||||||||||||||||
2851 | // In such a case we need to start following the application style (i.e revert | - | ||||||||||||||||||||||||||||||||||||
2852 | // the propagation behavior of QStyleSheetStyle) | - | ||||||||||||||||||||||||||||||||||||
2853 | if (!q->testAttribute(Qt::WA_SetStyle))
| 0 | ||||||||||||||||||||||||||||||||||||
2854 | origStyle = 0; never executed: origStyle = 0; | 0 | ||||||||||||||||||||||||||||||||||||
2855 | - | |||||||||||||||||||||||||||||||||||||
2856 | setStyle_helper(origStyle, true); | - | ||||||||||||||||||||||||||||||||||||
2857 | #endif // QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
2858 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2859 | - | |||||||||||||||||||||||||||||||||||||
2860 | - | |||||||||||||||||||||||||||||||||||||
2861 | /*! | - | ||||||||||||||||||||||||||||||||||||
2862 | \fn bool QWidget::isWindow() const | - | ||||||||||||||||||||||||||||||||||||
2863 | - | |||||||||||||||||||||||||||||||||||||
2864 | Returns \c true if the widget is an independent window, otherwise | - | ||||||||||||||||||||||||||||||||||||
2865 | returns \c false. | - | ||||||||||||||||||||||||||||||||||||
2866 | - | |||||||||||||||||||||||||||||||||||||
2867 | A window is a widget that isn't visually the child of any other | - | ||||||||||||||||||||||||||||||||||||
2868 | widget and that usually has a frame and a | - | ||||||||||||||||||||||||||||||||||||
2869 | \l{QWidget::setWindowTitle()}{window title}. | - | ||||||||||||||||||||||||||||||||||||
2870 | - | |||||||||||||||||||||||||||||||||||||
2871 | A window can have a \l{QWidget::parentWidget()}{parent widget}. | - | ||||||||||||||||||||||||||||||||||||
2872 | It will then be grouped with its parent and deleted when the | - | ||||||||||||||||||||||||||||||||||||
2873 | parent is deleted, minimized when the parent is minimized etc. If | - | ||||||||||||||||||||||||||||||||||||
2874 | supported by the window manager, it will also have a common | - | ||||||||||||||||||||||||||||||||||||
2875 | taskbar entry with its parent. | - | ||||||||||||||||||||||||||||||||||||
2876 | - | |||||||||||||||||||||||||||||||||||||
2877 | QDialog and QMainWindow widgets are by default windows, even if a | - | ||||||||||||||||||||||||||||||||||||
2878 | parent widget is specified in the constructor. This behavior is | - | ||||||||||||||||||||||||||||||||||||
2879 | specified by the Qt::Window flag. | - | ||||||||||||||||||||||||||||||||||||
2880 | - | |||||||||||||||||||||||||||||||||||||
2881 | \sa window(), isModal(), parentWidget() | - | ||||||||||||||||||||||||||||||||||||
2882 | */ | - | ||||||||||||||||||||||||||||||||||||
2883 | - | |||||||||||||||||||||||||||||||||||||
2884 | /*! | - | ||||||||||||||||||||||||||||||||||||
2885 | \property QWidget::modal | - | ||||||||||||||||||||||||||||||||||||
2886 | \brief whether the widget is a modal widget | - | ||||||||||||||||||||||||||||||||||||
2887 | - | |||||||||||||||||||||||||||||||||||||
2888 | This property only makes sense for windows. A modal widget | - | ||||||||||||||||||||||||||||||||||||
2889 | prevents widgets in all other windows from getting any input. | - | ||||||||||||||||||||||||||||||||||||
2890 | - | |||||||||||||||||||||||||||||||||||||
2891 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
2892 | - | |||||||||||||||||||||||||||||||||||||
2893 | \sa isWindow(), windowModality, QDialog | - | ||||||||||||||||||||||||||||||||||||
2894 | */ | - | ||||||||||||||||||||||||||||||||||||
2895 | - | |||||||||||||||||||||||||||||||||||||
2896 | /*! | - | ||||||||||||||||||||||||||||||||||||
2897 | \property QWidget::windowModality | - | ||||||||||||||||||||||||||||||||||||
2898 | \brief which windows are blocked by the modal widget | - | ||||||||||||||||||||||||||||||||||||
2899 | \since 4.1 | - | ||||||||||||||||||||||||||||||||||||
2900 | - | |||||||||||||||||||||||||||||||||||||
2901 | This property only makes sense for windows. A modal widget | - | ||||||||||||||||||||||||||||||||||||
2902 | prevents widgets in other windows from getting input. The value of | - | ||||||||||||||||||||||||||||||||||||
2903 | this property controls which windows are blocked when the widget | - | ||||||||||||||||||||||||||||||||||||
2904 | is visible. Changing this property while the window is visible has | - | ||||||||||||||||||||||||||||||||||||
2905 | no effect; you must hide() the widget first, then show() it again. | - | ||||||||||||||||||||||||||||||||||||
2906 | - | |||||||||||||||||||||||||||||||||||||
2907 | By default, this property is Qt::NonModal. | - | ||||||||||||||||||||||||||||||||||||
2908 | - | |||||||||||||||||||||||||||||||||||||
2909 | \sa isWindow(), QWidget::modal, QDialog | - | ||||||||||||||||||||||||||||||||||||
2910 | */ | - | ||||||||||||||||||||||||||||||||||||
2911 | - | |||||||||||||||||||||||||||||||||||||
2912 | Qt::WindowModality QWidget::windowModality() const | - | ||||||||||||||||||||||||||||||||||||
2913 | { | - | ||||||||||||||||||||||||||||||||||||
2914 | return static_cast<Qt::WindowModality>(data->window_modality); never executed: return static_cast<Qt::WindowModality>(data->window_modality); | 0 | ||||||||||||||||||||||||||||||||||||
2915 | } | - | ||||||||||||||||||||||||||||||||||||
2916 | - | |||||||||||||||||||||||||||||||||||||
2917 | void QWidget::setWindowModality(Qt::WindowModality windowModality) | - | ||||||||||||||||||||||||||||||||||||
2918 | { | - | ||||||||||||||||||||||||||||||||||||
2919 | data->window_modality = windowModality; | - | ||||||||||||||||||||||||||||||||||||
2920 | // setModal_sys() will be called by setAttribute() | - | ||||||||||||||||||||||||||||||||||||
2921 | setAttribute(Qt::WA_ShowModal, (data->window_modality != Qt::NonModal)); | - | ||||||||||||||||||||||||||||||||||||
2922 | setAttribute(Qt::WA_SetWindowModality, true); | - | ||||||||||||||||||||||||||||||||||||
2923 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2924 | - | |||||||||||||||||||||||||||||||||||||
2925 | void QWidgetPrivate::setModal_sys() | - | ||||||||||||||||||||||||||||||||||||
2926 | { | - | ||||||||||||||||||||||||||||||||||||
2927 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
2928 | if (q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
2929 | q->windowHandle()->setModality(q->windowModality()); never executed: q->windowHandle()->setModality(q->windowModality()); | 0 | ||||||||||||||||||||||||||||||||||||
2930 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2931 | - | |||||||||||||||||||||||||||||||||||||
2932 | /*! | - | ||||||||||||||||||||||||||||||||||||
2933 | \fn bool QWidget::underMouse() const | - | ||||||||||||||||||||||||||||||||||||
2934 | - | |||||||||||||||||||||||||||||||||||||
2935 | Returns \c true if the widget is under the mouse cursor; otherwise | - | ||||||||||||||||||||||||||||||||||||
2936 | returns \c false. | - | ||||||||||||||||||||||||||||||||||||
2937 | - | |||||||||||||||||||||||||||||||||||||
2938 | This value is not updated properly during drag and drop | - | ||||||||||||||||||||||||||||||||||||
2939 | operations. | - | ||||||||||||||||||||||||||||||||||||
2940 | - | |||||||||||||||||||||||||||||||||||||
2941 | \sa enterEvent(), leaveEvent() | - | ||||||||||||||||||||||||||||||||||||
2942 | */ | - | ||||||||||||||||||||||||||||||||||||
2943 | - | |||||||||||||||||||||||||||||||||||||
2944 | /*! | - | ||||||||||||||||||||||||||||||||||||
2945 | \property QWidget::minimized | - | ||||||||||||||||||||||||||||||||||||
2946 | \brief whether this widget is minimized (iconified) | - | ||||||||||||||||||||||||||||||||||||
2947 | - | |||||||||||||||||||||||||||||||||||||
2948 | This property is only relevant for windows. | - | ||||||||||||||||||||||||||||||||||||
2949 | - | |||||||||||||||||||||||||||||||||||||
2950 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
2951 | - | |||||||||||||||||||||||||||||||||||||
2952 | \sa showMinimized(), visible, show(), hide(), showNormal(), maximized | - | ||||||||||||||||||||||||||||||||||||
2953 | */ | - | ||||||||||||||||||||||||||||||||||||
2954 | bool QWidget::isMinimized() const | - | ||||||||||||||||||||||||||||||||||||
2955 | { never executed: return data->window_state & Qt::WindowMinimized; }return data->window_state & Qt::WindowMinimized; never executed: return data->window_state & Qt::WindowMinimized; | 0 | ||||||||||||||||||||||||||||||||||||
2956 | - | |||||||||||||||||||||||||||||||||||||
2957 | /*! | - | ||||||||||||||||||||||||||||||||||||
2958 | Shows the widget minimized, as an icon. | - | ||||||||||||||||||||||||||||||||||||
2959 | - | |||||||||||||||||||||||||||||||||||||
2960 | Calling this function only affects \l{isWindow()}{windows}. | - | ||||||||||||||||||||||||||||||||||||
2961 | - | |||||||||||||||||||||||||||||||||||||
2962 | \sa showNormal(), showMaximized(), show(), hide(), isVisible(), | - | ||||||||||||||||||||||||||||||||||||
2963 | isMinimized() | - | ||||||||||||||||||||||||||||||||||||
2964 | */ | - | ||||||||||||||||||||||||||||||||||||
2965 | void QWidget::showMinimized() | - | ||||||||||||||||||||||||||||||||||||
2966 | { | - | ||||||||||||||||||||||||||||||||||||
2967 | bool isMin = isMinimized(); | - | ||||||||||||||||||||||||||||||||||||
2968 | if (isMin && isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
2969 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2970 | - | |||||||||||||||||||||||||||||||||||||
2971 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
2972 | - | |||||||||||||||||||||||||||||||||||||
2973 | if (!isMin)
| 0 | ||||||||||||||||||||||||||||||||||||
2974 | setWindowState((windowState() & ~Qt::WindowActive) | Qt::WindowMinimized); never executed: setWindowState((windowState() & ~Qt::WindowActive) | Qt::WindowMinimized); | 0 | ||||||||||||||||||||||||||||||||||||
2975 | setVisible(true); | - | ||||||||||||||||||||||||||||||||||||
2976 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
2977 | - | |||||||||||||||||||||||||||||||||||||
2978 | /*! | - | ||||||||||||||||||||||||||||||||||||
2979 | \property QWidget::maximized | - | ||||||||||||||||||||||||||||||||||||
2980 | \brief whether this widget is maximized | - | ||||||||||||||||||||||||||||||||||||
2981 | - | |||||||||||||||||||||||||||||||||||||
2982 | This property is only relevant for windows. | - | ||||||||||||||||||||||||||||||||||||
2983 | - | |||||||||||||||||||||||||||||||||||||
2984 | \note Due to limitations on some window systems, this does not always | - | ||||||||||||||||||||||||||||||||||||
2985 | report the expected results (e.g., if the user on X11 maximizes the | - | ||||||||||||||||||||||||||||||||||||
2986 | window via the window manager, Qt has no way of distinguishing this | - | ||||||||||||||||||||||||||||||||||||
2987 | from any other resize). This is expected to improve as window manager | - | ||||||||||||||||||||||||||||||||||||
2988 | protocols evolve. | - | ||||||||||||||||||||||||||||||||||||
2989 | - | |||||||||||||||||||||||||||||||||||||
2990 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
2991 | - | |||||||||||||||||||||||||||||||||||||
2992 | \sa windowState(), showMaximized(), visible, show(), hide(), showNormal(), minimized | - | ||||||||||||||||||||||||||||||||||||
2993 | */ | - | ||||||||||||||||||||||||||||||||||||
2994 | bool QWidget::isMaximized() const | - | ||||||||||||||||||||||||||||||||||||
2995 | { never executed: return data->window_state & Qt::WindowMaximized; }return data->window_state & Qt::WindowMaximized; never executed: return data->window_state & Qt::WindowMaximized; | 0 | ||||||||||||||||||||||||||||||||||||
2996 | - | |||||||||||||||||||||||||||||||||||||
2997 | - | |||||||||||||||||||||||||||||||||||||
2998 | - | |||||||||||||||||||||||||||||||||||||
2999 | /*! | - | ||||||||||||||||||||||||||||||||||||
3000 | Returns the current window state. The window state is a OR'ed | - | ||||||||||||||||||||||||||||||||||||
3001 | combination of Qt::WindowState: Qt::WindowMinimized, | - | ||||||||||||||||||||||||||||||||||||
3002 | Qt::WindowMaximized, Qt::WindowFullScreen, and Qt::WindowActive. | - | ||||||||||||||||||||||||||||||||||||
3003 | - | |||||||||||||||||||||||||||||||||||||
3004 | \sa Qt::WindowState, setWindowState() | - | ||||||||||||||||||||||||||||||||||||
3005 | */ | - | ||||||||||||||||||||||||||||||||||||
3006 | Qt::WindowStates QWidget::windowState() const | - | ||||||||||||||||||||||||||||||||||||
3007 | { | - | ||||||||||||||||||||||||||||||||||||
3008 | return Qt::WindowStates(data->window_state); never executed: return Qt::WindowStates(data->window_state); | 0 | ||||||||||||||||||||||||||||||||||||
3009 | } | - | ||||||||||||||||||||||||||||||||||||
3010 | - | |||||||||||||||||||||||||||||||||||||
3011 | /*!\internal | - | ||||||||||||||||||||||||||||||||||||
3012 | - | |||||||||||||||||||||||||||||||||||||
3013 | The function sets the window state on child widgets similar to | - | ||||||||||||||||||||||||||||||||||||
3014 | setWindowState(). The difference is that the window state changed | - | ||||||||||||||||||||||||||||||||||||
3015 | event has the isOverride() flag set. It exists mainly to keep | - | ||||||||||||||||||||||||||||||||||||
3016 | QWorkspace working. | - | ||||||||||||||||||||||||||||||||||||
3017 | */ | - | ||||||||||||||||||||||||||||||||||||
3018 | void QWidget::overrideWindowState(Qt::WindowStates newstate) | - | ||||||||||||||||||||||||||||||||||||
3019 | { | - | ||||||||||||||||||||||||||||||||||||
3020 | QWindowStateChangeEvent e(Qt::WindowStates(data->window_state), true); | - | ||||||||||||||||||||||||||||||||||||
3021 | data->window_state = newstate; | - | ||||||||||||||||||||||||||||||||||||
3022 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
3023 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3024 | - | |||||||||||||||||||||||||||||||||||||
3025 | Qt::WindowState effectiveState(Qt::WindowStates state) | - | ||||||||||||||||||||||||||||||||||||
3026 | { | - | ||||||||||||||||||||||||||||||||||||
3027 | if (state & Qt::WindowMinimized)
| 0 | ||||||||||||||||||||||||||||||||||||
3028 | return Qt::WindowMinimized; never executed: return Qt::WindowMinimized; | 0 | ||||||||||||||||||||||||||||||||||||
3029 | else if (state & Qt::WindowFullScreen)
| 0 | ||||||||||||||||||||||||||||||||||||
3030 | return Qt::WindowFullScreen; never executed: return Qt::WindowFullScreen; | 0 | ||||||||||||||||||||||||||||||||||||
3031 | else if (state & Qt::WindowMaximized)
| 0 | ||||||||||||||||||||||||||||||||||||
3032 | return Qt::WindowMaximized; never executed: return Qt::WindowMaximized; | 0 | ||||||||||||||||||||||||||||||||||||
3033 | return Qt::WindowNoState; never executed: return Qt::WindowNoState; | 0 | ||||||||||||||||||||||||||||||||||||
3034 | } | - | ||||||||||||||||||||||||||||||||||||
3035 | - | |||||||||||||||||||||||||||||||||||||
3036 | /*! | - | ||||||||||||||||||||||||||||||||||||
3037 | \fn void QWidget::setWindowState(Qt::WindowStates windowState) | - | ||||||||||||||||||||||||||||||||||||
3038 | - | |||||||||||||||||||||||||||||||||||||
3039 | Sets the window state to \a windowState. The window state is a OR'ed | - | ||||||||||||||||||||||||||||||||||||
3040 | combination of Qt::WindowState: Qt::WindowMinimized, | - | ||||||||||||||||||||||||||||||||||||
3041 | Qt::WindowMaximized, Qt::WindowFullScreen, and Qt::WindowActive. | - | ||||||||||||||||||||||||||||||||||||
3042 | - | |||||||||||||||||||||||||||||||||||||
3043 | If the window is not visible (i.e. isVisible() returns \c false), the | - | ||||||||||||||||||||||||||||||||||||
3044 | window state will take effect when show() is called. For visible | - | ||||||||||||||||||||||||||||||||||||
3045 | windows, the change is immediate. For example, to toggle between | - | ||||||||||||||||||||||||||||||||||||
3046 | full-screen and normal mode, use the following code: | - | ||||||||||||||||||||||||||||||||||||
3047 | - | |||||||||||||||||||||||||||||||||||||
3048 | \snippet code/src_gui_kernel_qwidget.cpp 0 | - | ||||||||||||||||||||||||||||||||||||
3049 | - | |||||||||||||||||||||||||||||||||||||
3050 | In order to restore and activate a minimized window (while | - | ||||||||||||||||||||||||||||||||||||
3051 | preserving its maximized and/or full-screen state), use the following: | - | ||||||||||||||||||||||||||||||||||||
3052 | - | |||||||||||||||||||||||||||||||||||||
3053 | \snippet code/src_gui_kernel_qwidget.cpp 1 | - | ||||||||||||||||||||||||||||||||||||
3054 | - | |||||||||||||||||||||||||||||||||||||
3055 | Calling this function will hide the widget. You must call show() to make | - | ||||||||||||||||||||||||||||||||||||
3056 | the widget visible again. | - | ||||||||||||||||||||||||||||||||||||
3057 | - | |||||||||||||||||||||||||||||||||||||
3058 | \note On some window systems Qt::WindowActive is not immediate, and may be | - | ||||||||||||||||||||||||||||||||||||
3059 | ignored in certain cases. | - | ||||||||||||||||||||||||||||||||||||
3060 | - | |||||||||||||||||||||||||||||||||||||
3061 | When the window state changes, the widget receives a changeEvent() | - | ||||||||||||||||||||||||||||||||||||
3062 | of type QEvent::WindowStateChange. | - | ||||||||||||||||||||||||||||||||||||
3063 | - | |||||||||||||||||||||||||||||||||||||
3064 | \sa Qt::WindowState, windowState() | - | ||||||||||||||||||||||||||||||||||||
3065 | */ | - | ||||||||||||||||||||||||||||||||||||
3066 | void QWidget::setWindowState(Qt::WindowStates newstate) | - | ||||||||||||||||||||||||||||||||||||
3067 | { | - | ||||||||||||||||||||||||||||||||||||
3068 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3069 | Qt::WindowStates oldstate = windowState(); | - | ||||||||||||||||||||||||||||||||||||
3070 | if (oldstate == newstate)
| 0 | ||||||||||||||||||||||||||||||||||||
3071 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
3072 | if (isWindow() && !testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
3073 | create(); never executed: create(); | 0 | ||||||||||||||||||||||||||||||||||||
3074 | - | |||||||||||||||||||||||||||||||||||||
3075 | data->window_state = newstate; | - | ||||||||||||||||||||||||||||||||||||
3076 | data->in_set_window_state = 1; | - | ||||||||||||||||||||||||||||||||||||
3077 | Qt::WindowState newEffectiveState = effectiveState(newstate); | - | ||||||||||||||||||||||||||||||||||||
3078 | Qt::WindowState oldEffectiveState = effectiveState(oldstate); | - | ||||||||||||||||||||||||||||||||||||
3079 | if (isWindow() && newEffectiveState != oldEffectiveState) {
| 0 | ||||||||||||||||||||||||||||||||||||
3080 | // Ensure the initial size is valid, since we store it as normalGeometry below. | - | ||||||||||||||||||||||||||||||||||||
3081 | if (!testAttribute(Qt::WA_Resized) && !isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
3082 | adjustSize(); never executed: adjustSize(); | 0 | ||||||||||||||||||||||||||||||||||||
3083 | - | |||||||||||||||||||||||||||||||||||||
3084 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
3085 | if (oldEffectiveState == Qt::WindowNoState)
| 0 | ||||||||||||||||||||||||||||||||||||
3086 | d->topData()->normalGeometry = geometry(); never executed: d->topData()->normalGeometry = geometry(); | 0 | ||||||||||||||||||||||||||||||||||||
3087 | - | |||||||||||||||||||||||||||||||||||||
3088 | Q_ASSERT(windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
3089 | windowHandle()->setWindowState(newEffectiveState); | - | ||||||||||||||||||||||||||||||||||||
3090 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3091 | data->in_set_window_state = 0; | - | ||||||||||||||||||||||||||||||||||||
3092 | - | |||||||||||||||||||||||||||||||||||||
3093 | if (newstate & Qt::WindowActive)
| 0 | ||||||||||||||||||||||||||||||||||||
3094 | activateWindow(); never executed: activateWindow(); | 0 | ||||||||||||||||||||||||||||||||||||
3095 | - | |||||||||||||||||||||||||||||||||||||
3096 | QWindowStateChangeEvent e(oldstate); | - | ||||||||||||||||||||||||||||||||||||
3097 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
3098 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3099 | - | |||||||||||||||||||||||||||||||||||||
3100 | /*! | - | ||||||||||||||||||||||||||||||||||||
3101 | \property QWidget::fullScreen | - | ||||||||||||||||||||||||||||||||||||
3102 | \brief whether the widget is shown in full screen mode | - | ||||||||||||||||||||||||||||||||||||
3103 | - | |||||||||||||||||||||||||||||||||||||
3104 | A widget in full screen mode occupies the whole screen area and does not | - | ||||||||||||||||||||||||||||||||||||
3105 | display window decorations, such as a title bar. | - | ||||||||||||||||||||||||||||||||||||
3106 | - | |||||||||||||||||||||||||||||||||||||
3107 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
3108 | - | |||||||||||||||||||||||||||||||||||||
3109 | \sa windowState(), minimized, maximized | - | ||||||||||||||||||||||||||||||||||||
3110 | */ | - | ||||||||||||||||||||||||||||||||||||
3111 | bool QWidget::isFullScreen() const | - | ||||||||||||||||||||||||||||||||||||
3112 | { never executed: return data->window_state & Qt::WindowFullScreen; }return data->window_state & Qt::WindowFullScreen; never executed: return data->window_state & Qt::WindowFullScreen; | 0 | ||||||||||||||||||||||||||||||||||||
3113 | - | |||||||||||||||||||||||||||||||||||||
3114 | /*! | - | ||||||||||||||||||||||||||||||||||||
3115 | Shows the widget in full-screen mode. | - | ||||||||||||||||||||||||||||||||||||
3116 | - | |||||||||||||||||||||||||||||||||||||
3117 | Calling this function only affects \l{isWindow()}{windows}. | - | ||||||||||||||||||||||||||||||||||||
3118 | - | |||||||||||||||||||||||||||||||||||||
3119 | To return from full-screen mode, call showNormal(). | - | ||||||||||||||||||||||||||||||||||||
3120 | - | |||||||||||||||||||||||||||||||||||||
3121 | Full-screen mode works fine under Windows, but has certain | - | ||||||||||||||||||||||||||||||||||||
3122 | problems under X. These problems are due to limitations of the | - | ||||||||||||||||||||||||||||||||||||
3123 | ICCCM protocol that specifies the communication between X11 | - | ||||||||||||||||||||||||||||||||||||
3124 | clients and the window manager. ICCCM simply does not understand | - | ||||||||||||||||||||||||||||||||||||
3125 | the concept of non-decorated full-screen windows. Therefore, the | - | ||||||||||||||||||||||||||||||||||||
3126 | best we can do is to request a borderless window and place and | - | ||||||||||||||||||||||||||||||||||||
3127 | resize it to fill the entire screen. Depending on the window | - | ||||||||||||||||||||||||||||||||||||
3128 | manager, this may or may not work. The borderless window is | - | ||||||||||||||||||||||||||||||||||||
3129 | requested using MOTIF hints, which are at least partially | - | ||||||||||||||||||||||||||||||||||||
3130 | supported by virtually all modern window managers. | - | ||||||||||||||||||||||||||||||||||||
3131 | - | |||||||||||||||||||||||||||||||||||||
3132 | An alternative would be to bypass the window manager entirely and | - | ||||||||||||||||||||||||||||||||||||
3133 | create a window with the Qt::X11BypassWindowManagerHint flag. This | - | ||||||||||||||||||||||||||||||||||||
3134 | has other severe problems though, like totally broken keyboard focus | - | ||||||||||||||||||||||||||||||||||||
3135 | and very strange effects on desktop changes or when the user raises | - | ||||||||||||||||||||||||||||||||||||
3136 | other windows. | - | ||||||||||||||||||||||||||||||||||||
3137 | - | |||||||||||||||||||||||||||||||||||||
3138 | X11 window managers that follow modern post-ICCCM specifications | - | ||||||||||||||||||||||||||||||||||||
3139 | support full-screen mode properly. | - | ||||||||||||||||||||||||||||||||||||
3140 | - | |||||||||||||||||||||||||||||||||||||
3141 | \sa showNormal(), showMaximized(), show(), hide(), isVisible() | - | ||||||||||||||||||||||||||||||||||||
3142 | */ | - | ||||||||||||||||||||||||||||||||||||
3143 | void QWidget::showFullScreen() | - | ||||||||||||||||||||||||||||||||||||
3144 | { | - | ||||||||||||||||||||||||||||||||||||
3145 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
3146 | // If the unified toolbar is enabled, we have to disable it before going fullscreen. | - | ||||||||||||||||||||||||||||||||||||
3147 | QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); | - | ||||||||||||||||||||||||||||||||||||
3148 | if (mainWindow && mainWindow->unifiedTitleAndToolBarOnMac()) { | - | ||||||||||||||||||||||||||||||||||||
3149 | mainWindow->setUnifiedTitleAndToolBarOnMac(false); | - | ||||||||||||||||||||||||||||||||||||
3150 | QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); | - | ||||||||||||||||||||||||||||||||||||
3151 | mainLayout->activateUnifiedToolbarAfterFullScreen = true; | - | ||||||||||||||||||||||||||||||||||||
3152 | } | - | ||||||||||||||||||||||||||||||||||||
3153 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
3154 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
3155 | - | |||||||||||||||||||||||||||||||||||||
3156 | setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowMaximized)) | - | ||||||||||||||||||||||||||||||||||||
3157 | | Qt::WindowFullScreen); | - | ||||||||||||||||||||||||||||||||||||
3158 | setVisible(true); | - | ||||||||||||||||||||||||||||||||||||
3159 | #if !defined Q_OS_QNX // On QNX this window will be activated anyway from libscreen | - | ||||||||||||||||||||||||||||||||||||
3160 | // activating it here before libscreen activates it causes problems | - | ||||||||||||||||||||||||||||||||||||
3161 | activateWindow(); | - | ||||||||||||||||||||||||||||||||||||
3162 | #endif | - | ||||||||||||||||||||||||||||||||||||
3163 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3164 | - | |||||||||||||||||||||||||||||||||||||
3165 | /*! | - | ||||||||||||||||||||||||||||||||||||
3166 | Shows the widget maximized. | - | ||||||||||||||||||||||||||||||||||||
3167 | - | |||||||||||||||||||||||||||||||||||||
3168 | Calling this function only affects \l{isWindow()}{windows}. | - | ||||||||||||||||||||||||||||||||||||
3169 | - | |||||||||||||||||||||||||||||||||||||
3170 | On X11, this function may not work properly with certain window | - | ||||||||||||||||||||||||||||||||||||
3171 | managers. See the \l{Window Geometry} documentation for an explanation. | - | ||||||||||||||||||||||||||||||||||||
3172 | - | |||||||||||||||||||||||||||||||||||||
3173 | \sa setWindowState(), showNormal(), showMinimized(), show(), hide(), isVisible() | - | ||||||||||||||||||||||||||||||||||||
3174 | */ | - | ||||||||||||||||||||||||||||||||||||
3175 | void QWidget::showMaximized() | - | ||||||||||||||||||||||||||||||||||||
3176 | { | - | ||||||||||||||||||||||||||||||||||||
3177 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
3178 | - | |||||||||||||||||||||||||||||||||||||
3179 | setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen)) | - | ||||||||||||||||||||||||||||||||||||
3180 | | Qt::WindowMaximized); | - | ||||||||||||||||||||||||||||||||||||
3181 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
3182 | // If the unified toolbar was enabled before going fullscreen, we have to enable it back. | - | ||||||||||||||||||||||||||||||||||||
3183 | QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); | - | ||||||||||||||||||||||||||||||||||||
3184 | if (mainWindow) | - | ||||||||||||||||||||||||||||||||||||
3185 | { | - | ||||||||||||||||||||||||||||||||||||
3186 | QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); | - | ||||||||||||||||||||||||||||||||||||
3187 | if (mainLayout->activateUnifiedToolbarAfterFullScreen) { | - | ||||||||||||||||||||||||||||||||||||
3188 | mainWindow->setUnifiedTitleAndToolBarOnMac(true); | - | ||||||||||||||||||||||||||||||||||||
3189 | mainLayout->activateUnifiedToolbarAfterFullScreen = false; | - | ||||||||||||||||||||||||||||||||||||
3190 | } | - | ||||||||||||||||||||||||||||||||||||
3191 | } | - | ||||||||||||||||||||||||||||||||||||
3192 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
3193 | setVisible(true); | - | ||||||||||||||||||||||||||||||||||||
3194 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3195 | - | |||||||||||||||||||||||||||||||||||||
3196 | /*! | - | ||||||||||||||||||||||||||||||||||||
3197 | Restores the widget after it has been maximized or minimized. | - | ||||||||||||||||||||||||||||||||||||
3198 | - | |||||||||||||||||||||||||||||||||||||
3199 | Calling this function only affects \l{isWindow()}{windows}. | - | ||||||||||||||||||||||||||||||||||||
3200 | - | |||||||||||||||||||||||||||||||||||||
3201 | \sa setWindowState(), showMinimized(), showMaximized(), show(), hide(), isVisible() | - | ||||||||||||||||||||||||||||||||||||
3202 | */ | - | ||||||||||||||||||||||||||||||||||||
3203 | void QWidget::showNormal() | - | ||||||||||||||||||||||||||||||||||||
3204 | { | - | ||||||||||||||||||||||||||||||||||||
3205 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
3206 | - | |||||||||||||||||||||||||||||||||||||
3207 | setWindowState(windowState() & ~(Qt::WindowMinimized | - | ||||||||||||||||||||||||||||||||||||
3208 | | Qt::WindowMaximized | - | ||||||||||||||||||||||||||||||||||||
3209 | | Qt::WindowFullScreen)); | - | ||||||||||||||||||||||||||||||||||||
3210 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
3211 | // If the unified toolbar was enabled before going fullscreen, we have to enable it back. | - | ||||||||||||||||||||||||||||||||||||
3212 | QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); | - | ||||||||||||||||||||||||||||||||||||
3213 | if (mainWindow) | - | ||||||||||||||||||||||||||||||||||||
3214 | { | - | ||||||||||||||||||||||||||||||||||||
3215 | QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); | - | ||||||||||||||||||||||||||||||||||||
3216 | if (mainLayout->activateUnifiedToolbarAfterFullScreen) { | - | ||||||||||||||||||||||||||||||||||||
3217 | mainWindow->setUnifiedTitleAndToolBarOnMac(true); | - | ||||||||||||||||||||||||||||||||||||
3218 | mainLayout->activateUnifiedToolbarAfterFullScreen = false; | - | ||||||||||||||||||||||||||||||||||||
3219 | } | - | ||||||||||||||||||||||||||||||||||||
3220 | } | - | ||||||||||||||||||||||||||||||||||||
3221 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
3222 | setVisible(true); | - | ||||||||||||||||||||||||||||||||||||
3223 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3224 | - | |||||||||||||||||||||||||||||||||||||
3225 | /*! | - | ||||||||||||||||||||||||||||||||||||
3226 | Returns \c true if this widget would become enabled if \a ancestor is | - | ||||||||||||||||||||||||||||||||||||
3227 | enabled; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
3228 | - | |||||||||||||||||||||||||||||||||||||
3229 | - | |||||||||||||||||||||||||||||||||||||
3230 | - | |||||||||||||||||||||||||||||||||||||
3231 | This is the case if neither the widget itself nor every parent up | - | ||||||||||||||||||||||||||||||||||||
3232 | to but excluding \a ancestor has been explicitly disabled. | - | ||||||||||||||||||||||||||||||||||||
3233 | - | |||||||||||||||||||||||||||||||||||||
3234 | isEnabledTo(0) returns false if this widget or any if its ancestors | - | ||||||||||||||||||||||||||||||||||||
3235 | was explicitly disabled. | - | ||||||||||||||||||||||||||||||||||||
3236 | - | |||||||||||||||||||||||||||||||||||||
3237 | The word ancestor here means a parent widget within the same window. | - | ||||||||||||||||||||||||||||||||||||
3238 | - | |||||||||||||||||||||||||||||||||||||
3239 | Therefore isEnabledTo(0) stops at this widget's window, unlike | - | ||||||||||||||||||||||||||||||||||||
3240 | isEnabled() which also takes parent windows into considerations. | - | ||||||||||||||||||||||||||||||||||||
3241 | - | |||||||||||||||||||||||||||||||||||||
3242 | \sa setEnabled(), enabled | - | ||||||||||||||||||||||||||||||||||||
3243 | */ | - | ||||||||||||||||||||||||||||||||||||
3244 | - | |||||||||||||||||||||||||||||||||||||
3245 | bool QWidget::isEnabledTo(const QWidget *ancestor) const | - | ||||||||||||||||||||||||||||||||||||
3246 | { | - | ||||||||||||||||||||||||||||||||||||
3247 | const QWidget * w = this; | - | ||||||||||||||||||||||||||||||||||||
3248 | while (!w->testAttribute(Qt::WA_ForceDisabled)
| 0 | ||||||||||||||||||||||||||||||||||||
3249 | && !w->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
3250 | && w->parentWidget()
| 0 | ||||||||||||||||||||||||||||||||||||
3251 | && w->parentWidget() != ancestor)
| 0 | ||||||||||||||||||||||||||||||||||||
3252 | w = w->parentWidget(); never executed: w = w->parentWidget(); | 0 | ||||||||||||||||||||||||||||||||||||
3253 | return !w->testAttribute(Qt::WA_ForceDisabled); never executed: return !w->testAttribute(Qt::WA_ForceDisabled); | 0 | ||||||||||||||||||||||||||||||||||||
3254 | } | - | ||||||||||||||||||||||||||||||||||||
3255 | - | |||||||||||||||||||||||||||||||||||||
3256 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||||||||||||||
3257 | /*! | - | ||||||||||||||||||||||||||||||||||||
3258 | Appends the action \a action to this widget's list of actions. | - | ||||||||||||||||||||||||||||||||||||
3259 | - | |||||||||||||||||||||||||||||||||||||
3260 | All QWidgets have a list of \l{QAction}s, however they can be | - | ||||||||||||||||||||||||||||||||||||
3261 | represented graphically in many different ways. The default use of | - | ||||||||||||||||||||||||||||||||||||
3262 | the QAction list (as returned by actions()) is to create a context | - | ||||||||||||||||||||||||||||||||||||
3263 | QMenu. | - | ||||||||||||||||||||||||||||||||||||
3264 | - | |||||||||||||||||||||||||||||||||||||
3265 | A QWidget should only have one of each action and adding an action | - | ||||||||||||||||||||||||||||||||||||
3266 | it already has will not cause the same action to be in the widget twice. | - | ||||||||||||||||||||||||||||||||||||
3267 | - | |||||||||||||||||||||||||||||||||||||
3268 | The ownership of \a action is not transferred to this QWidget. | - | ||||||||||||||||||||||||||||||||||||
3269 | - | |||||||||||||||||||||||||||||||||||||
3270 | \sa removeAction(), insertAction(), actions(), QMenu | - | ||||||||||||||||||||||||||||||||||||
3271 | */ | - | ||||||||||||||||||||||||||||||||||||
3272 | void QWidget::addAction(QAction *action) | - | ||||||||||||||||||||||||||||||||||||
3273 | { | - | ||||||||||||||||||||||||||||||||||||
3274 | insertAction(0, action); | - | ||||||||||||||||||||||||||||||||||||
3275 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3276 | - | |||||||||||||||||||||||||||||||||||||
3277 | /*! | - | ||||||||||||||||||||||||||||||||||||
3278 | Appends the actions \a actions to this widget's list of actions. | - | ||||||||||||||||||||||||||||||||||||
3279 | - | |||||||||||||||||||||||||||||||||||||
3280 | \sa removeAction(), QMenu, addAction() | - | ||||||||||||||||||||||||||||||||||||
3281 | */ | - | ||||||||||||||||||||||||||||||||||||
3282 | #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) | - | ||||||||||||||||||||||||||||||||||||
3283 | void QWidget::addActions(const QList<QAction *> &actions) | - | ||||||||||||||||||||||||||||||||||||
3284 | #else | - | ||||||||||||||||||||||||||||||||||||
3285 | void QWidget::addActions(QList<QAction*> actions) | - | ||||||||||||||||||||||||||||||||||||
3286 | #endif | - | ||||||||||||||||||||||||||||||||||||
3287 | { | - | ||||||||||||||||||||||||||||||||||||
3288 | for(int i = 0; i < actions.count(); i++)
| 0 | ||||||||||||||||||||||||||||||||||||
3289 | insertAction(0, actions.at(i)); never executed: insertAction(0, actions.at(i)); | 0 | ||||||||||||||||||||||||||||||||||||
3290 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3291 | - | |||||||||||||||||||||||||||||||||||||
3292 | /*! | - | ||||||||||||||||||||||||||||||||||||
3293 | Inserts the action \a action to this widget's list of actions, | - | ||||||||||||||||||||||||||||||||||||
3294 | before the action \a before. It appends the action if \a before is 0 or | - | ||||||||||||||||||||||||||||||||||||
3295 | \a before is not a valid action for this widget. | - | ||||||||||||||||||||||||||||||||||||
3296 | - | |||||||||||||||||||||||||||||||||||||
3297 | A QWidget should only have one of each action. | - | ||||||||||||||||||||||||||||||||||||
3298 | - | |||||||||||||||||||||||||||||||||||||
3299 | \sa removeAction(), addAction(), QMenu, contextMenuPolicy, actions() | - | ||||||||||||||||||||||||||||||||||||
3300 | */ | - | ||||||||||||||||||||||||||||||||||||
3301 | void QWidget::insertAction(QAction *before, QAction *action) | - | ||||||||||||||||||||||||||||||||||||
3302 | { | - | ||||||||||||||||||||||||||||||||||||
3303 | if(!action) {
| 0 | ||||||||||||||||||||||||||||||||||||
3304 | qWarning("QWidget::insertAction: Attempt to insert null action"); | - | ||||||||||||||||||||||||||||||||||||
3305 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
3306 | } | - | ||||||||||||||||||||||||||||||||||||
3307 | - | |||||||||||||||||||||||||||||||||||||
3308 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3309 | if(d->actions.contains(action))
| 0 | ||||||||||||||||||||||||||||||||||||
3310 | removeAction(action); never executed: removeAction(action); | 0 | ||||||||||||||||||||||||||||||||||||
3311 | - | |||||||||||||||||||||||||||||||||||||
3312 | int pos = d->actions.indexOf(before); | - | ||||||||||||||||||||||||||||||||||||
3313 | if (pos < 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
3314 | before = 0; | - | ||||||||||||||||||||||||||||||||||||
3315 | pos = d->actions.size(); | - | ||||||||||||||||||||||||||||||||||||
3316 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3317 | d->actions.insert(pos, action); | - | ||||||||||||||||||||||||||||||||||||
3318 | - | |||||||||||||||||||||||||||||||||||||
3319 | QActionPrivate *apriv = action->d_func(); | - | ||||||||||||||||||||||||||||||||||||
3320 | apriv->widgets.append(this); | - | ||||||||||||||||||||||||||||||||||||
3321 | - | |||||||||||||||||||||||||||||||||||||
3322 | QActionEvent e(QEvent::ActionAdded, action, before); | - | ||||||||||||||||||||||||||||||||||||
3323 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
3324 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3325 | - | |||||||||||||||||||||||||||||||||||||
3326 | /*! | - | ||||||||||||||||||||||||||||||||||||
3327 | Inserts the actions \a actions to this widget's list of actions, | - | ||||||||||||||||||||||||||||||||||||
3328 | before the action \a before. It appends the action if \a before is 0 or | - | ||||||||||||||||||||||||||||||||||||
3329 | \a before is not a valid action for this widget. | - | ||||||||||||||||||||||||||||||||||||
3330 | - | |||||||||||||||||||||||||||||||||||||
3331 | A QWidget can have at most one of each action. | - | ||||||||||||||||||||||||||||||||||||
3332 | - | |||||||||||||||||||||||||||||||||||||
3333 | \sa removeAction(), QMenu, insertAction(), contextMenuPolicy | - | ||||||||||||||||||||||||||||||||||||
3334 | */ | - | ||||||||||||||||||||||||||||||||||||
3335 | void QWidget::insertActions(QAction *before, QList<QAction*> actions) | - | ||||||||||||||||||||||||||||||||||||
3336 | { | - | ||||||||||||||||||||||||||||||||||||
3337 | for(int i = 0; i < actions.count(); ++i)
| 0 | ||||||||||||||||||||||||||||||||||||
3338 | insertAction(before, actions.at(i)); never executed: insertAction(before, actions.at(i)); | 0 | ||||||||||||||||||||||||||||||||||||
3339 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3340 | - | |||||||||||||||||||||||||||||||||||||
3341 | /*! | - | ||||||||||||||||||||||||||||||||||||
3342 | Removes the action \a action from this widget's list of actions. | - | ||||||||||||||||||||||||||||||||||||
3343 | \sa insertAction(), actions(), insertAction() | - | ||||||||||||||||||||||||||||||||||||
3344 | */ | - | ||||||||||||||||||||||||||||||||||||
3345 | void QWidget::removeAction(QAction *action) | - | ||||||||||||||||||||||||||||||||||||
3346 | { | - | ||||||||||||||||||||||||||||||||||||
3347 | if (!action)
| 0 | ||||||||||||||||||||||||||||||||||||
3348 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
3349 | - | |||||||||||||||||||||||||||||||||||||
3350 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3351 | - | |||||||||||||||||||||||||||||||||||||
3352 | QActionPrivate *apriv = action->d_func(); | - | ||||||||||||||||||||||||||||||||||||
3353 | apriv->widgets.removeAll(this); | - | ||||||||||||||||||||||||||||||||||||
3354 | - | |||||||||||||||||||||||||||||||||||||
3355 | if (d->actions.removeAll(action)) {
| 0 | ||||||||||||||||||||||||||||||||||||
3356 | QActionEvent e(QEvent::ActionRemoved, action); | - | ||||||||||||||||||||||||||||||||||||
3357 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
3358 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3359 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3360 | - | |||||||||||||||||||||||||||||||||||||
3361 | /*! | - | ||||||||||||||||||||||||||||||||||||
3362 | Returns the (possibly empty) list of this widget's actions. | - | ||||||||||||||||||||||||||||||||||||
3363 | - | |||||||||||||||||||||||||||||||||||||
3364 | \sa contextMenuPolicy, insertAction(), removeAction() | - | ||||||||||||||||||||||||||||||||||||
3365 | */ | - | ||||||||||||||||||||||||||||||||||||
3366 | QList<QAction*> QWidget::actions() const | - | ||||||||||||||||||||||||||||||||||||
3367 | { | - | ||||||||||||||||||||||||||||||||||||
3368 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3369 | return d->actions; never executed: return d->actions; | 0 | ||||||||||||||||||||||||||||||||||||
3370 | } | - | ||||||||||||||||||||||||||||||||||||
3371 | #endif // QT_NO_ACTION | - | ||||||||||||||||||||||||||||||||||||
3372 | - | |||||||||||||||||||||||||||||||||||||
3373 | /*! | - | ||||||||||||||||||||||||||||||||||||
3374 | \fn bool QWidget::isEnabledToTLW() const | - | ||||||||||||||||||||||||||||||||||||
3375 | \obsolete | - | ||||||||||||||||||||||||||||||||||||
3376 | - | |||||||||||||||||||||||||||||||||||||
3377 | This function is deprecated. It is equivalent to isEnabled() | - | ||||||||||||||||||||||||||||||||||||
3378 | */ | - | ||||||||||||||||||||||||||||||||||||
3379 | - | |||||||||||||||||||||||||||||||||||||
3380 | /*! | - | ||||||||||||||||||||||||||||||||||||
3381 | \property QWidget::enabled | - | ||||||||||||||||||||||||||||||||||||
3382 | \brief whether the widget is enabled | - | ||||||||||||||||||||||||||||||||||||
3383 | - | |||||||||||||||||||||||||||||||||||||
3384 | In general an enabled widget handles keyboard and mouse events; a disabled | - | ||||||||||||||||||||||||||||||||||||
3385 | widget does not. An exception is made with \l{QAbstractButton}. | - | ||||||||||||||||||||||||||||||||||||
3386 | - | |||||||||||||||||||||||||||||||||||||
3387 | Some widgets display themselves differently when they are | - | ||||||||||||||||||||||||||||||||||||
3388 | disabled. For example a button might draw its label grayed out. If | - | ||||||||||||||||||||||||||||||||||||
3389 | your widget needs to know when it becomes enabled or disabled, you | - | ||||||||||||||||||||||||||||||||||||
3390 | can use the changeEvent() with type QEvent::EnabledChange. | - | ||||||||||||||||||||||||||||||||||||
3391 | - | |||||||||||||||||||||||||||||||||||||
3392 | Disabling a widget implicitly disables all its children. Enabling | - | ||||||||||||||||||||||||||||||||||||
3393 | respectively enables all child widgets unless they have been | - | ||||||||||||||||||||||||||||||||||||
3394 | explicitly disabled. It it not possible to explicitly enable a child | - | ||||||||||||||||||||||||||||||||||||
3395 | widget which is not a window while its parent widget remains disabled. | - | ||||||||||||||||||||||||||||||||||||
3396 | - | |||||||||||||||||||||||||||||||||||||
3397 | By default, this property is \c true. | - | ||||||||||||||||||||||||||||||||||||
3398 | - | |||||||||||||||||||||||||||||||||||||
3399 | \sa isEnabledTo(), QKeyEvent, QMouseEvent, changeEvent() | - | ||||||||||||||||||||||||||||||||||||
3400 | */ | - | ||||||||||||||||||||||||||||||||||||
3401 | void QWidget::setEnabled(bool enable) | - | ||||||||||||||||||||||||||||||||||||
3402 | { | - | ||||||||||||||||||||||||||||||||||||
3403 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3404 | setAttribute(Qt::WA_ForceDisabled, !enable); | - | ||||||||||||||||||||||||||||||||||||
3405 | d->setEnabled_helper(enable); | - | ||||||||||||||||||||||||||||||||||||
3406 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3407 | - | |||||||||||||||||||||||||||||||||||||
3408 | void QWidgetPrivate::setEnabled_helper(bool enable) | - | ||||||||||||||||||||||||||||||||||||
3409 | { | - | ||||||||||||||||||||||||||||||||||||
3410 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3411 | - | |||||||||||||||||||||||||||||||||||||
3412 | if (enable && !q->isWindow() && q->parentWidget() && !q->parentWidget()->isEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
3413 | return; // nothing we can do never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
3414 | - | |||||||||||||||||||||||||||||||||||||
3415 | if (enable != q->testAttribute(Qt::WA_Disabled))
| 0 | ||||||||||||||||||||||||||||||||||||
3416 | return; // nothing to do never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
3417 | - | |||||||||||||||||||||||||||||||||||||
3418 | q->setAttribute(Qt::WA_Disabled, !enable); | - | ||||||||||||||||||||||||||||||||||||
3419 | updateSystemBackground(); | - | ||||||||||||||||||||||||||||||||||||
3420 | - | |||||||||||||||||||||||||||||||||||||
3421 | if (!enable && q->window()->focusWidget() == q) {
| 0 | ||||||||||||||||||||||||||||||||||||
3422 | bool parentIsEnabled = (!q->parentWidget() || q->parentWidget()->isEnabled());
| 0 | ||||||||||||||||||||||||||||||||||||
3423 | if (!parentIsEnabled || !q->focusNextChild())
| 0 | ||||||||||||||||||||||||||||||||||||
3424 | q->clearFocus(); never executed: q->clearFocus(); | 0 | ||||||||||||||||||||||||||||||||||||
3425 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3426 | - | |||||||||||||||||||||||||||||||||||||
3427 | Qt::WidgetAttribute attribute = enable ? Qt::WA_ForceDisabled : Qt::WA_Disabled;
| 0 | ||||||||||||||||||||||||||||||||||||
3428 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
3429 | QWidget *w = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
3430 | if (w && !w->testAttribute(attribute))
| 0 | ||||||||||||||||||||||||||||||||||||
3431 | w->d_func()->setEnabled_helper(enable); never executed: w->d_func()->setEnabled_helper(enable); | 0 | ||||||||||||||||||||||||||||||||||||
3432 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3433 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
3434 | if (q->testAttribute(Qt::WA_SetCursor) || q->isWindow()) { | - | ||||||||||||||||||||||||||||||||||||
3435 | // enforce the windows behavior of clearing the cursor on | - | ||||||||||||||||||||||||||||||||||||
3436 | // disabled widgets | - | ||||||||||||||||||||||||||||||||||||
3437 | qt_x11_enforce_cursor(q); | - | ||||||||||||||||||||||||||||||||||||
3438 | } | - | ||||||||||||||||||||||||||||||||||||
3439 | #endif | - | ||||||||||||||||||||||||||||||||||||
3440 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
3441 | if (q->testAttribute(Qt::WA_SetCursor) || q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
3442 | // enforce the windows behavior of clearing the cursor on | - | ||||||||||||||||||||||||||||||||||||
3443 | // disabled widgets | - | ||||||||||||||||||||||||||||||||||||
3444 | qt_qpa_set_cursor(q, false); | - | ||||||||||||||||||||||||||||||||||||
3445 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3446 | #endif | - | ||||||||||||||||||||||||||||||||||||
3447 | #if defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
3448 | setEnabled_helper_sys(enable); | - | ||||||||||||||||||||||||||||||||||||
3449 | #endif | - | ||||||||||||||||||||||||||||||||||||
3450 | #ifndef QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
3451 | if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) {
| 0 | ||||||||||||||||||||||||||||||||||||
3452 | QWidget *focusWidget = effectiveFocusWidget(); | - | ||||||||||||||||||||||||||||||||||||
3453 | - | |||||||||||||||||||||||||||||||||||||
3454 | if (enable) {
| 0 | ||||||||||||||||||||||||||||||||||||
3455 | if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
| 0 | ||||||||||||||||||||||||||||||||||||
3456 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); never executed: QGuiApplication::inputMethod()->update(Qt::ImEnabled); | 0 | ||||||||||||||||||||||||||||||||||||
3457 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3458 | QGuiApplication::inputMethod()->commit(); | - | ||||||||||||||||||||||||||||||||||||
3459 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); | - | ||||||||||||||||||||||||||||||||||||
3460 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3461 | } | - | ||||||||||||||||||||||||||||||||||||
3462 | #endif //QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
3463 | QEvent e(QEvent::EnabledChange); | - | ||||||||||||||||||||||||||||||||||||
3464 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
3465 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3466 | - | |||||||||||||||||||||||||||||||||||||
3467 | /*! | - | ||||||||||||||||||||||||||||||||||||
3468 | \property QWidget::acceptDrops | - | ||||||||||||||||||||||||||||||||||||
3469 | \brief whether drop events are enabled for this widget | - | ||||||||||||||||||||||||||||||||||||
3470 | - | |||||||||||||||||||||||||||||||||||||
3471 | Setting this property to true announces to the system that this | - | ||||||||||||||||||||||||||||||||||||
3472 | widget \e may be able to accept drop events. | - | ||||||||||||||||||||||||||||||||||||
3473 | - | |||||||||||||||||||||||||||||||||||||
3474 | If the widget is the desktop (windowType() == Qt::Desktop), this may | - | ||||||||||||||||||||||||||||||||||||
3475 | fail if another application is using the desktop; you can call | - | ||||||||||||||||||||||||||||||||||||
3476 | acceptDrops() to test if this occurs. | - | ||||||||||||||||||||||||||||||||||||
3477 | - | |||||||||||||||||||||||||||||||||||||
3478 | \warning Do not modify this property in a drag and drop event handler. | - | ||||||||||||||||||||||||||||||||||||
3479 | - | |||||||||||||||||||||||||||||||||||||
3480 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
3481 | - | |||||||||||||||||||||||||||||||||||||
3482 | \sa {Drag and Drop} | - | ||||||||||||||||||||||||||||||||||||
3483 | */ | - | ||||||||||||||||||||||||||||||||||||
3484 | bool QWidget::acceptDrops() const | - | ||||||||||||||||||||||||||||||||||||
3485 | { | - | ||||||||||||||||||||||||||||||||||||
3486 | return testAttribute(Qt::WA_AcceptDrops); never executed: return testAttribute(Qt::WA_AcceptDrops); | 0 | ||||||||||||||||||||||||||||||||||||
3487 | } | - | ||||||||||||||||||||||||||||||||||||
3488 | - | |||||||||||||||||||||||||||||||||||||
3489 | void QWidget::setAcceptDrops(bool on) | - | ||||||||||||||||||||||||||||||||||||
3490 | { | - | ||||||||||||||||||||||||||||||||||||
3491 | setAttribute(Qt::WA_AcceptDrops, on); | - | ||||||||||||||||||||||||||||||||||||
3492 | - | |||||||||||||||||||||||||||||||||||||
3493 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3494 | - | |||||||||||||||||||||||||||||||||||||
3495 | void QWidgetPrivate::registerDropSite(bool on) | - | ||||||||||||||||||||||||||||||||||||
3496 | { | - | ||||||||||||||||||||||||||||||||||||
3497 | Q_UNUSED(on); | - | ||||||||||||||||||||||||||||||||||||
3498 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3499 | - | |||||||||||||||||||||||||||||||||||||
3500 | /*! | - | ||||||||||||||||||||||||||||||||||||
3501 | Disables widget input events if \a disable is true; otherwise | - | ||||||||||||||||||||||||||||||||||||
3502 | enables input events. | - | ||||||||||||||||||||||||||||||||||||
3503 | - | |||||||||||||||||||||||||||||||||||||
3504 | See the \l enabled documentation for more information. | - | ||||||||||||||||||||||||||||||||||||
3505 | - | |||||||||||||||||||||||||||||||||||||
3506 | \sa isEnabledTo(), QKeyEvent, QMouseEvent, changeEvent() | - | ||||||||||||||||||||||||||||||||||||
3507 | */ | - | ||||||||||||||||||||||||||||||||||||
3508 | void QWidget::setDisabled(bool disable) | - | ||||||||||||||||||||||||||||||||||||
3509 | { | - | ||||||||||||||||||||||||||||||||||||
3510 | setEnabled(!disable); | - | ||||||||||||||||||||||||||||||||||||
3511 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3512 | - | |||||||||||||||||||||||||||||||||||||
3513 | /*! | - | ||||||||||||||||||||||||||||||||||||
3514 | \property QWidget::frameGeometry | - | ||||||||||||||||||||||||||||||||||||
3515 | \brief geometry of the widget relative to its parent including any | - | ||||||||||||||||||||||||||||||||||||
3516 | window frame | - | ||||||||||||||||||||||||||||||||||||
3517 | - | |||||||||||||||||||||||||||||||||||||
3518 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3519 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3520 | - | |||||||||||||||||||||||||||||||||||||
3521 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
3522 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
3523 | - | |||||||||||||||||||||||||||||||||||||
3524 | \sa geometry(), x(), y(), pos() | - | ||||||||||||||||||||||||||||||||||||
3525 | */ | - | ||||||||||||||||||||||||||||||||||||
3526 | QRect QWidget::frameGeometry() const | - | ||||||||||||||||||||||||||||||||||||
3527 | { | - | ||||||||||||||||||||||||||||||||||||
3528 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3529 | if (isWindow() && ! (windowType() == Qt::Popup)) {
| 0 | ||||||||||||||||||||||||||||||||||||
3530 | QRect fs = d->frameStrut(); | - | ||||||||||||||||||||||||||||||||||||
3531 | 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 | ||||||||||||||||||||||||||||||||||||
3532 | 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 | ||||||||||||||||||||||||||||||||||||
3533 | 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 | ||||||||||||||||||||||||||||||||||||
3534 | 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 | ||||||||||||||||||||||||||||||||||||
3535 | } | - | ||||||||||||||||||||||||||||||||||||
3536 | return data->crect; never executed: return data->crect; | 0 | ||||||||||||||||||||||||||||||||||||
3537 | } | - | ||||||||||||||||||||||||||||||||||||
3538 | - | |||||||||||||||||||||||||||||||||||||
3539 | /*! | - | ||||||||||||||||||||||||||||||||||||
3540 | \property QWidget::x | - | ||||||||||||||||||||||||||||||||||||
3541 | - | |||||||||||||||||||||||||||||||||||||
3542 | \brief the x coordinate of the widget relative to its parent including | - | ||||||||||||||||||||||||||||||||||||
3543 | any window frame | - | ||||||||||||||||||||||||||||||||||||
3544 | - | |||||||||||||||||||||||||||||||||||||
3545 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3546 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3547 | - | |||||||||||||||||||||||||||||||||||||
3548 | By default, this property has a value of 0. | - | ||||||||||||||||||||||||||||||||||||
3549 | - | |||||||||||||||||||||||||||||||||||||
3550 | \sa frameGeometry, y, pos | - | ||||||||||||||||||||||||||||||||||||
3551 | */ | - | ||||||||||||||||||||||||||||||||||||
3552 | int QWidget::x() const | - | ||||||||||||||||||||||||||||||||||||
3553 | { | - | ||||||||||||||||||||||||||||||||||||
3554 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3555 | if (isWindow() && ! (windowType() == Qt::Popup))
| 0 | ||||||||||||||||||||||||||||||||||||
3556 | return data->crect.x() - d->frameStrut().left(); never executed: return data->crect.x() - d->frameStrut().left(); | 0 | ||||||||||||||||||||||||||||||||||||
3557 | return data->crect.x(); never executed: return data->crect.x(); | 0 | ||||||||||||||||||||||||||||||||||||
3558 | } | - | ||||||||||||||||||||||||||||||||||||
3559 | - | |||||||||||||||||||||||||||||||||||||
3560 | /*! | - | ||||||||||||||||||||||||||||||||||||
3561 | \property QWidget::y | - | ||||||||||||||||||||||||||||||||||||
3562 | \brief the y coordinate of the widget relative to its parent and | - | ||||||||||||||||||||||||||||||||||||
3563 | including any window frame | - | ||||||||||||||||||||||||||||||||||||
3564 | - | |||||||||||||||||||||||||||||||||||||
3565 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3566 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3567 | - | |||||||||||||||||||||||||||||||||||||
3568 | By default, this property has a value of 0. | - | ||||||||||||||||||||||||||||||||||||
3569 | - | |||||||||||||||||||||||||||||||||||||
3570 | \sa frameGeometry, x, pos | - | ||||||||||||||||||||||||||||||||||||
3571 | */ | - | ||||||||||||||||||||||||||||||||||||
3572 | int QWidget::y() const | - | ||||||||||||||||||||||||||||||||||||
3573 | { | - | ||||||||||||||||||||||||||||||||||||
3574 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3575 | if (isWindow() && ! (windowType() == Qt::Popup))
| 0 | ||||||||||||||||||||||||||||||||||||
3576 | return data->crect.y() - d->frameStrut().top(); never executed: return data->crect.y() - d->frameStrut().top(); | 0 | ||||||||||||||||||||||||||||||||||||
3577 | return data->crect.y(); never executed: return data->crect.y(); | 0 | ||||||||||||||||||||||||||||||||||||
3578 | } | - | ||||||||||||||||||||||||||||||||||||
3579 | - | |||||||||||||||||||||||||||||||||||||
3580 | /*! | - | ||||||||||||||||||||||||||||||||||||
3581 | \property QWidget::pos | - | ||||||||||||||||||||||||||||||||||||
3582 | \brief the position of the widget within its parent widget | - | ||||||||||||||||||||||||||||||||||||
3583 | - | |||||||||||||||||||||||||||||||||||||
3584 | If the widget is a window, the position is that of the widget on | - | ||||||||||||||||||||||||||||||||||||
3585 | the desktop, including its frame. | - | ||||||||||||||||||||||||||||||||||||
3586 | - | |||||||||||||||||||||||||||||||||||||
3587 | When changing the position, the widget, if visible, receives a | - | ||||||||||||||||||||||||||||||||||||
3588 | move event (moveEvent()) immediately. If the widget is not | - | ||||||||||||||||||||||||||||||||||||
3589 | currently visible, it is guaranteed to receive an event before it | - | ||||||||||||||||||||||||||||||||||||
3590 | is shown. | - | ||||||||||||||||||||||||||||||||||||
3591 | - | |||||||||||||||||||||||||||||||||||||
3592 | By default, this property contains a position that refers to the | - | ||||||||||||||||||||||||||||||||||||
3593 | origin. | - | ||||||||||||||||||||||||||||||||||||
3594 | - | |||||||||||||||||||||||||||||||||||||
3595 | \warning Calling move() or setGeometry() inside moveEvent() can | - | ||||||||||||||||||||||||||||||||||||
3596 | lead to infinite recursion. | - | ||||||||||||||||||||||||||||||||||||
3597 | - | |||||||||||||||||||||||||||||||||||||
3598 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3599 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3600 | - | |||||||||||||||||||||||||||||||||||||
3601 | \sa frameGeometry, size, x(), y() | - | ||||||||||||||||||||||||||||||||||||
3602 | */ | - | ||||||||||||||||||||||||||||||||||||
3603 | QPoint QWidget::pos() const | - | ||||||||||||||||||||||||||||||||||||
3604 | { | - | ||||||||||||||||||||||||||||||||||||
3605 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3606 | QPoint result = data->crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
3607 | if (isWindow() && ! (windowType() == Qt::Popup))
| 0 | ||||||||||||||||||||||||||||||||||||
3608 | if (!d->maybeTopData() || !d->maybeTopData()->posIncludesFrame)
| 0 | ||||||||||||||||||||||||||||||||||||
3609 | result -= d->frameStrut().topLeft(); never executed: result -= d->frameStrut().topLeft(); | 0 | ||||||||||||||||||||||||||||||||||||
3610 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||||||||||||||
3611 | } | - | ||||||||||||||||||||||||||||||||||||
3612 | - | |||||||||||||||||||||||||||||||||||||
3613 | /*! | - | ||||||||||||||||||||||||||||||||||||
3614 | \property QWidget::geometry | - | ||||||||||||||||||||||||||||||||||||
3615 | \brief the geometry of the widget relative to its parent and | - | ||||||||||||||||||||||||||||||||||||
3616 | excluding the window frame | - | ||||||||||||||||||||||||||||||||||||
3617 | - | |||||||||||||||||||||||||||||||||||||
3618 | When changing the geometry, the widget, if visible, receives a | - | ||||||||||||||||||||||||||||||||||||
3619 | move event (moveEvent()) and/or a resize event (resizeEvent()) | - | ||||||||||||||||||||||||||||||||||||
3620 | immediately. If the widget is not currently visible, it is | - | ||||||||||||||||||||||||||||||||||||
3621 | guaranteed to receive appropriate events before it is shown. | - | ||||||||||||||||||||||||||||||||||||
3622 | - | |||||||||||||||||||||||||||||||||||||
3623 | The size component is adjusted if it lies outside the range | - | ||||||||||||||||||||||||||||||||||||
3624 | defined by minimumSize() and maximumSize(). | - | ||||||||||||||||||||||||||||||||||||
3625 | - | |||||||||||||||||||||||||||||||||||||
3626 | \warning Calling setGeometry() inside resizeEvent() or moveEvent() | - | ||||||||||||||||||||||||||||||||||||
3627 | can lead to infinite recursion. | - | ||||||||||||||||||||||||||||||||||||
3628 | - | |||||||||||||||||||||||||||||||||||||
3629 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3630 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3631 | - | |||||||||||||||||||||||||||||||||||||
3632 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
3633 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
3634 | - | |||||||||||||||||||||||||||||||||||||
3635 | \sa frameGeometry(), rect(), move(), resize(), moveEvent(), | - | ||||||||||||||||||||||||||||||||||||
3636 | resizeEvent(), minimumSize(), maximumSize() | - | ||||||||||||||||||||||||||||||||||||
3637 | */ | - | ||||||||||||||||||||||||||||||||||||
3638 | - | |||||||||||||||||||||||||||||||||||||
3639 | /*! | - | ||||||||||||||||||||||||||||||||||||
3640 | \property QWidget::normalGeometry | - | ||||||||||||||||||||||||||||||||||||
3641 | - | |||||||||||||||||||||||||||||||||||||
3642 | \brief the geometry of the widget as it will appear when shown as | - | ||||||||||||||||||||||||||||||||||||
3643 | a normal (not maximized or full screen) top-level widget | - | ||||||||||||||||||||||||||||||||||||
3644 | - | |||||||||||||||||||||||||||||||||||||
3645 | For child widgets this property always holds an empty rectangle. | - | ||||||||||||||||||||||||||||||||||||
3646 | - | |||||||||||||||||||||||||||||||||||||
3647 | By default, this property contains an empty rectangle. | - | ||||||||||||||||||||||||||||||||||||
3648 | - | |||||||||||||||||||||||||||||||||||||
3649 | \sa QWidget::windowState(), QWidget::geometry | - | ||||||||||||||||||||||||||||||||||||
3650 | */ | - | ||||||||||||||||||||||||||||||||||||
3651 | - | |||||||||||||||||||||||||||||||||||||
3652 | /*! | - | ||||||||||||||||||||||||||||||||||||
3653 | \property QWidget::size | - | ||||||||||||||||||||||||||||||||||||
3654 | \brief the size of the widget excluding any window frame | - | ||||||||||||||||||||||||||||||||||||
3655 | - | |||||||||||||||||||||||||||||||||||||
3656 | If the widget is visible when it is being resized, it receives a resize event | - | ||||||||||||||||||||||||||||||||||||
3657 | (resizeEvent()) immediately. If the widget is not currently | - | ||||||||||||||||||||||||||||||||||||
3658 | visible, it is guaranteed to receive an event before it is shown. | - | ||||||||||||||||||||||||||||||||||||
3659 | - | |||||||||||||||||||||||||||||||||||||
3660 | The size is adjusted if it lies outside the range defined by | - | ||||||||||||||||||||||||||||||||||||
3661 | minimumSize() and maximumSize(). | - | ||||||||||||||||||||||||||||||||||||
3662 | - | |||||||||||||||||||||||||||||||||||||
3663 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
3664 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
3665 | - | |||||||||||||||||||||||||||||||||||||
3666 | \warning Calling resize() or setGeometry() inside resizeEvent() can | - | ||||||||||||||||||||||||||||||||||||
3667 | lead to infinite recursion. | - | ||||||||||||||||||||||||||||||||||||
3668 | - | |||||||||||||||||||||||||||||||||||||
3669 | \note Setting the size to \c{QSize(0, 0)} will cause the widget to not | - | ||||||||||||||||||||||||||||||||||||
3670 | appear on screen. This also applies to windows. | - | ||||||||||||||||||||||||||||||||||||
3671 | - | |||||||||||||||||||||||||||||||||||||
3672 | \sa pos, geometry, minimumSize, maximumSize, resizeEvent(), adjustSize() | - | ||||||||||||||||||||||||||||||||||||
3673 | */ | - | ||||||||||||||||||||||||||||||||||||
3674 | - | |||||||||||||||||||||||||||||||||||||
3675 | /*! | - | ||||||||||||||||||||||||||||||||||||
3676 | \property QWidget::width | - | ||||||||||||||||||||||||||||||||||||
3677 | \brief the width of the widget excluding any window frame | - | ||||||||||||||||||||||||||||||||||||
3678 | - | |||||||||||||||||||||||||||||||||||||
3679 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3680 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3681 | - | |||||||||||||||||||||||||||||||||||||
3682 | \note Do not use this function to find the width of a screen on | - | ||||||||||||||||||||||||||||||||||||
3683 | a \l{QDesktopWidget}{multiple screen desktop}. Read | - | ||||||||||||||||||||||||||||||||||||
3684 | \l{QDesktopWidget#Screen Geometry}{this note} for details. | - | ||||||||||||||||||||||||||||||||||||
3685 | - | |||||||||||||||||||||||||||||||||||||
3686 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
3687 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
3688 | - | |||||||||||||||||||||||||||||||||||||
3689 | \sa geometry, height, size | - | ||||||||||||||||||||||||||||||||||||
3690 | */ | - | ||||||||||||||||||||||||||||||||||||
3691 | - | |||||||||||||||||||||||||||||||||||||
3692 | /*! | - | ||||||||||||||||||||||||||||||||||||
3693 | \property QWidget::height | - | ||||||||||||||||||||||||||||||||||||
3694 | \brief the height of the widget excluding any window frame | - | ||||||||||||||||||||||||||||||||||||
3695 | - | |||||||||||||||||||||||||||||||||||||
3696 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3697 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3698 | - | |||||||||||||||||||||||||||||||||||||
3699 | \note Do not use this function to find the height of a screen | - | ||||||||||||||||||||||||||||||||||||
3700 | on a \l{QDesktopWidget}{multiple screen desktop}. Read | - | ||||||||||||||||||||||||||||||||||||
3701 | \l{QDesktopWidget#Screen Geometry}{this note} for details. | - | ||||||||||||||||||||||||||||||||||||
3702 | - | |||||||||||||||||||||||||||||||||||||
3703 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
3704 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
3705 | - | |||||||||||||||||||||||||||||||||||||
3706 | \sa geometry, width, size | - | ||||||||||||||||||||||||||||||||||||
3707 | */ | - | ||||||||||||||||||||||||||||||||||||
3708 | - | |||||||||||||||||||||||||||||||||||||
3709 | /*! | - | ||||||||||||||||||||||||||||||||||||
3710 | \property QWidget::rect | - | ||||||||||||||||||||||||||||||||||||
3711 | \brief the internal geometry of the widget excluding any window | - | ||||||||||||||||||||||||||||||||||||
3712 | frame | - | ||||||||||||||||||||||||||||||||||||
3713 | - | |||||||||||||||||||||||||||||||||||||
3714 | The rect property equals QRect(0, 0, width(), height()). | - | ||||||||||||||||||||||||||||||||||||
3715 | - | |||||||||||||||||||||||||||||||||||||
3716 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
3717 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
3718 | - | |||||||||||||||||||||||||||||||||||||
3719 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
3720 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
3721 | - | |||||||||||||||||||||||||||||||||||||
3722 | \sa size | - | ||||||||||||||||||||||||||||||||||||
3723 | */ | - | ||||||||||||||||||||||||||||||||||||
3724 | - | |||||||||||||||||||||||||||||||||||||
3725 | - | |||||||||||||||||||||||||||||||||||||
3726 | QRect QWidget::normalGeometry() const | - | ||||||||||||||||||||||||||||||||||||
3727 | { | - | ||||||||||||||||||||||||||||||||||||
3728 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3729 | if (!d->extra || !d->extra->topextra)
| 0 | ||||||||||||||||||||||||||||||||||||
3730 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||||||||||||||
3731 | - | |||||||||||||||||||||||||||||||||||||
3732 | if (!isMaximized() && !isFullScreen())
| 0 | ||||||||||||||||||||||||||||||||||||
3733 | return geometry(); never executed: return geometry(); | 0 | ||||||||||||||||||||||||||||||||||||
3734 | - | |||||||||||||||||||||||||||||||||||||
3735 | return d->topData()->normalGeometry; never executed: return d->topData()->normalGeometry; | 0 | ||||||||||||||||||||||||||||||||||||
3736 | } | - | ||||||||||||||||||||||||||||||||||||
3737 | - | |||||||||||||||||||||||||||||||||||||
3738 | - | |||||||||||||||||||||||||||||||||||||
3739 | /*! | - | ||||||||||||||||||||||||||||||||||||
3740 | \property QWidget::childrenRect | - | ||||||||||||||||||||||||||||||||||||
3741 | \brief the bounding rectangle of the widget's children | - | ||||||||||||||||||||||||||||||||||||
3742 | - | |||||||||||||||||||||||||||||||||||||
3743 | Hidden children are excluded. | - | ||||||||||||||||||||||||||||||||||||
3744 | - | |||||||||||||||||||||||||||||||||||||
3745 | By default, for a widget with no children, this property contains a | - | ||||||||||||||||||||||||||||||||||||
3746 | rectangle with zero width and height located at the origin. | - | ||||||||||||||||||||||||||||||||||||
3747 | - | |||||||||||||||||||||||||||||||||||||
3748 | \sa childrenRegion(), geometry() | - | ||||||||||||||||||||||||||||||||||||
3749 | */ | - | ||||||||||||||||||||||||||||||||||||
3750 | - | |||||||||||||||||||||||||||||||||||||
3751 | QRect QWidget::childrenRect() const | - | ||||||||||||||||||||||||||||||||||||
3752 | { | - | ||||||||||||||||||||||||||||||||||||
3753 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3754 | QRect r(0, 0, 0, 0); | - | ||||||||||||||||||||||||||||||||||||
3755 | for (int i = 0; i < d->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
3756 | QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
3757 | if (w && !w->isWindow() && !w->isHidden())
| 0 | ||||||||||||||||||||||||||||||||||||
3758 | r |= w->geometry(); never executed: r |= w->geometry(); | 0 | ||||||||||||||||||||||||||||||||||||
3759 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3760 | return r; never executed: return r; | 0 | ||||||||||||||||||||||||||||||||||||
3761 | } | - | ||||||||||||||||||||||||||||||||||||
3762 | - | |||||||||||||||||||||||||||||||||||||
3763 | /*! | - | ||||||||||||||||||||||||||||||||||||
3764 | \property QWidget::childrenRegion | - | ||||||||||||||||||||||||||||||||||||
3765 | \brief the combined region occupied by the widget's children | - | ||||||||||||||||||||||||||||||||||||
3766 | - | |||||||||||||||||||||||||||||||||||||
3767 | Hidden children are excluded. | - | ||||||||||||||||||||||||||||||||||||
3768 | - | |||||||||||||||||||||||||||||||||||||
3769 | By default, for a widget with no children, this property contains an | - | ||||||||||||||||||||||||||||||||||||
3770 | empty region. | - | ||||||||||||||||||||||||||||||||||||
3771 | - | |||||||||||||||||||||||||||||||||||||
3772 | \sa childrenRect(), geometry(), mask() | - | ||||||||||||||||||||||||||||||||||||
3773 | */ | - | ||||||||||||||||||||||||||||||||||||
3774 | - | |||||||||||||||||||||||||||||||||||||
3775 | QRegion QWidget::childrenRegion() const | - | ||||||||||||||||||||||||||||||||||||
3776 | { | - | ||||||||||||||||||||||||||||||||||||
3777 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3778 | QRegion r; | - | ||||||||||||||||||||||||||||||||||||
3779 | for (int i = 0; i < d->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
3780 | QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
3781 | if (w && !w->isWindow() && !w->isHidden()) {
| 0 | ||||||||||||||||||||||||||||||||||||
3782 | QRegion mask = w->mask(); | - | ||||||||||||||||||||||||||||||||||||
3783 | if (mask.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
3784 | r |= w->geometry(); never executed: r |= w->geometry(); | 0 | ||||||||||||||||||||||||||||||||||||
3785 | else | - | ||||||||||||||||||||||||||||||||||||
3786 | r |= mask.translated(w->pos()); never executed: r |= mask.translated(w->pos()); | 0 | ||||||||||||||||||||||||||||||||||||
3787 | } | - | ||||||||||||||||||||||||||||||||||||
3788 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3789 | return r; never executed: return r; | 0 | ||||||||||||||||||||||||||||||||||||
3790 | } | - | ||||||||||||||||||||||||||||||||||||
3791 | - | |||||||||||||||||||||||||||||||||||||
3792 | - | |||||||||||||||||||||||||||||||||||||
3793 | /*! | - | ||||||||||||||||||||||||||||||||||||
3794 | \property QWidget::minimumSize | - | ||||||||||||||||||||||||||||||||||||
3795 | \brief the widget's minimum size | - | ||||||||||||||||||||||||||||||||||||
3796 | - | |||||||||||||||||||||||||||||||||||||
3797 | The widget cannot be resized to a smaller size than the minimum | - | ||||||||||||||||||||||||||||||||||||
3798 | widget size. The widget's size is forced to the minimum size if | - | ||||||||||||||||||||||||||||||||||||
3799 | the current size is smaller. | - | ||||||||||||||||||||||||||||||||||||
3800 | - | |||||||||||||||||||||||||||||||||||||
3801 | The minimum size set by this function will override the minimum size | - | ||||||||||||||||||||||||||||||||||||
3802 | defined by QLayout. In order to unset the minimum size, use a | - | ||||||||||||||||||||||||||||||||||||
3803 | value of \c{QSize(0, 0)}. | - | ||||||||||||||||||||||||||||||||||||
3804 | - | |||||||||||||||||||||||||||||||||||||
3805 | By default, this property contains a size with zero width and height. | - | ||||||||||||||||||||||||||||||||||||
3806 | - | |||||||||||||||||||||||||||||||||||||
3807 | \sa minimumWidth, minimumHeight, maximumSize, sizeIncrement | - | ||||||||||||||||||||||||||||||||||||
3808 | */ | - | ||||||||||||||||||||||||||||||||||||
3809 | - | |||||||||||||||||||||||||||||||||||||
3810 | QSize QWidget::minimumSize() const | - | ||||||||||||||||||||||||||||||||||||
3811 | { | - | ||||||||||||||||||||||||||||||||||||
3812 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3813 | 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 | ||||||||||||||||||||||||||||||||||||
3814 | } | - | ||||||||||||||||||||||||||||||||||||
3815 | - | |||||||||||||||||||||||||||||||||||||
3816 | /*! | - | ||||||||||||||||||||||||||||||||||||
3817 | \property QWidget::maximumSize | - | ||||||||||||||||||||||||||||||||||||
3818 | \brief the widget's maximum size in pixels | - | ||||||||||||||||||||||||||||||||||||
3819 | - | |||||||||||||||||||||||||||||||||||||
3820 | The widget cannot be resized to a larger size than the maximum | - | ||||||||||||||||||||||||||||||||||||
3821 | widget size. | - | ||||||||||||||||||||||||||||||||||||
3822 | - | |||||||||||||||||||||||||||||||||||||
3823 | By default, this property contains a size in which both width and height | - | ||||||||||||||||||||||||||||||||||||
3824 | have values of 16777215. | - | ||||||||||||||||||||||||||||||||||||
3825 | - | |||||||||||||||||||||||||||||||||||||
3826 | \note The definition of the \c QWIDGETSIZE_MAX macro limits the maximum size | - | ||||||||||||||||||||||||||||||||||||
3827 | of widgets. | - | ||||||||||||||||||||||||||||||||||||
3828 | - | |||||||||||||||||||||||||||||||||||||
3829 | \sa maximumWidth, maximumHeight, minimumSize, sizeIncrement | - | ||||||||||||||||||||||||||||||||||||
3830 | */ | - | ||||||||||||||||||||||||||||||||||||
3831 | - | |||||||||||||||||||||||||||||||||||||
3832 | QSize QWidget::maximumSize() const | - | ||||||||||||||||||||||||||||||||||||
3833 | { | - | ||||||||||||||||||||||||||||||||||||
3834 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3835 | 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 | ||||||||||||||||||||||||||||||||||||
3836 | : 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 | ||||||||||||||||||||||||||||||||||||
3837 | } | - | ||||||||||||||||||||||||||||||||||||
3838 | - | |||||||||||||||||||||||||||||||||||||
3839 | - | |||||||||||||||||||||||||||||||||||||
3840 | /*! | - | ||||||||||||||||||||||||||||||||||||
3841 | \property QWidget::minimumWidth | - | ||||||||||||||||||||||||||||||||||||
3842 | \brief the widget's minimum width in pixels | - | ||||||||||||||||||||||||||||||||||||
3843 | - | |||||||||||||||||||||||||||||||||||||
3844 | This property corresponds to the width held by the \l minimumSize property. | - | ||||||||||||||||||||||||||||||||||||
3845 | - | |||||||||||||||||||||||||||||||||||||
3846 | By default, this property has a value of 0. | - | ||||||||||||||||||||||||||||||||||||
3847 | - | |||||||||||||||||||||||||||||||||||||
3848 | \sa minimumSize, minimumHeight | - | ||||||||||||||||||||||||||||||||||||
3849 | */ | - | ||||||||||||||||||||||||||||||||||||
3850 | - | |||||||||||||||||||||||||||||||||||||
3851 | /*! | - | ||||||||||||||||||||||||||||||||||||
3852 | \property QWidget::minimumHeight | - | ||||||||||||||||||||||||||||||||||||
3853 | \brief the widget's minimum height in pixels | - | ||||||||||||||||||||||||||||||||||||
3854 | - | |||||||||||||||||||||||||||||||||||||
3855 | This property corresponds to the height held by the \l minimumSize property. | - | ||||||||||||||||||||||||||||||||||||
3856 | - | |||||||||||||||||||||||||||||||||||||
3857 | By default, this property has a value of 0. | - | ||||||||||||||||||||||||||||||||||||
3858 | - | |||||||||||||||||||||||||||||||||||||
3859 | \sa minimumSize, minimumWidth | - | ||||||||||||||||||||||||||||||||||||
3860 | */ | - | ||||||||||||||||||||||||||||||||||||
3861 | - | |||||||||||||||||||||||||||||||||||||
3862 | /*! | - | ||||||||||||||||||||||||||||||||||||
3863 | \property QWidget::maximumWidth | - | ||||||||||||||||||||||||||||||||||||
3864 | \brief the widget's maximum width in pixels | - | ||||||||||||||||||||||||||||||||||||
3865 | - | |||||||||||||||||||||||||||||||||||||
3866 | This property corresponds to the width held by the \l maximumSize property. | - | ||||||||||||||||||||||||||||||||||||
3867 | - | |||||||||||||||||||||||||||||||||||||
3868 | By default, this property contains a value of 16777215. | - | ||||||||||||||||||||||||||||||||||||
3869 | - | |||||||||||||||||||||||||||||||||||||
3870 | \note The definition of the \c QWIDGETSIZE_MAX macro limits the maximum size | - | ||||||||||||||||||||||||||||||||||||
3871 | of widgets. | - | ||||||||||||||||||||||||||||||||||||
3872 | - | |||||||||||||||||||||||||||||||||||||
3873 | \sa maximumSize, maximumHeight | - | ||||||||||||||||||||||||||||||||||||
3874 | */ | - | ||||||||||||||||||||||||||||||||||||
3875 | - | |||||||||||||||||||||||||||||||||||||
3876 | /*! | - | ||||||||||||||||||||||||||||||||||||
3877 | \property QWidget::maximumHeight | - | ||||||||||||||||||||||||||||||||||||
3878 | \brief the widget's maximum height in pixels | - | ||||||||||||||||||||||||||||||||||||
3879 | - | |||||||||||||||||||||||||||||||||||||
3880 | This property corresponds to the height held by the \l maximumSize property. | - | ||||||||||||||||||||||||||||||||||||
3881 | - | |||||||||||||||||||||||||||||||||||||
3882 | By default, this property contains a value of 16777215. | - | ||||||||||||||||||||||||||||||||||||
3883 | - | |||||||||||||||||||||||||||||||||||||
3884 | \note The definition of the \c QWIDGETSIZE_MAX macro limits the maximum size | - | ||||||||||||||||||||||||||||||||||||
3885 | of widgets. | - | ||||||||||||||||||||||||||||||||||||
3886 | - | |||||||||||||||||||||||||||||||||||||
3887 | \sa maximumSize, maximumWidth | - | ||||||||||||||||||||||||||||||||||||
3888 | */ | - | ||||||||||||||||||||||||||||||||||||
3889 | - | |||||||||||||||||||||||||||||||||||||
3890 | /*! | - | ||||||||||||||||||||||||||||||||||||
3891 | \property QWidget::sizeIncrement | - | ||||||||||||||||||||||||||||||||||||
3892 | \brief the size increment of the widget | - | ||||||||||||||||||||||||||||||||||||
3893 | - | |||||||||||||||||||||||||||||||||||||
3894 | When the user resizes the window, the size will move in steps of | - | ||||||||||||||||||||||||||||||||||||
3895 | sizeIncrement().width() pixels horizontally and | - | ||||||||||||||||||||||||||||||||||||
3896 | sizeIncrement.height() pixels vertically, with baseSize() as the | - | ||||||||||||||||||||||||||||||||||||
3897 | basis. Preferred widget sizes are for non-negative integers \e i | - | ||||||||||||||||||||||||||||||||||||
3898 | and \e j: | - | ||||||||||||||||||||||||||||||||||||
3899 | \snippet code/src_gui_kernel_qwidget.cpp 2 | - | ||||||||||||||||||||||||||||||||||||
3900 | - | |||||||||||||||||||||||||||||||||||||
3901 | Note that while you can set the size increment for all widgets, it | - | ||||||||||||||||||||||||||||||||||||
3902 | only affects windows. | - | ||||||||||||||||||||||||||||||||||||
3903 | - | |||||||||||||||||||||||||||||||||||||
3904 | By default, this property contains a size with zero width and height. | - | ||||||||||||||||||||||||||||||||||||
3905 | - | |||||||||||||||||||||||||||||||||||||
3906 | \warning The size increment has no effect under Windows, and may | - | ||||||||||||||||||||||||||||||||||||
3907 | be disregarded by the window manager on X11. | - | ||||||||||||||||||||||||||||||||||||
3908 | - | |||||||||||||||||||||||||||||||||||||
3909 | \sa size, minimumSize, maximumSize | - | ||||||||||||||||||||||||||||||||||||
3910 | */ | - | ||||||||||||||||||||||||||||||||||||
3911 | QSize QWidget::sizeIncrement() const | - | ||||||||||||||||||||||||||||||||||||
3912 | { | - | ||||||||||||||||||||||||||||||||||||
3913 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3914 | 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 | ||||||||||||||||||||||||||||||||||||
3915 | ? 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 | ||||||||||||||||||||||||||||||||||||
3916 | : QSize(0, 0); never executed: return (d->extra && d->extra->topextra) ? QSize(d->extra->topextra->incw, d->extra->topextra->inch) : QSize(0, 0); | 0 | ||||||||||||||||||||||||||||||||||||
3917 | } | - | ||||||||||||||||||||||||||||||||||||
3918 | - | |||||||||||||||||||||||||||||||||||||
3919 | /*! | - | ||||||||||||||||||||||||||||||||||||
3920 | \property QWidget::baseSize | - | ||||||||||||||||||||||||||||||||||||
3921 | \brief the base size of the widget | - | ||||||||||||||||||||||||||||||||||||
3922 | - | |||||||||||||||||||||||||||||||||||||
3923 | The base size is used to calculate a proper widget size if the | - | ||||||||||||||||||||||||||||||||||||
3924 | widget defines sizeIncrement(). | - | ||||||||||||||||||||||||||||||||||||
3925 | - | |||||||||||||||||||||||||||||||||||||
3926 | By default, for a newly-created widget, this property contains a size with | - | ||||||||||||||||||||||||||||||||||||
3927 | zero width and height. | - | ||||||||||||||||||||||||||||||||||||
3928 | - | |||||||||||||||||||||||||||||||||||||
3929 | \sa setSizeIncrement() | - | ||||||||||||||||||||||||||||||||||||
3930 | */ | - | ||||||||||||||||||||||||||||||||||||
3931 | - | |||||||||||||||||||||||||||||||||||||
3932 | QSize QWidget::baseSize() const | - | ||||||||||||||||||||||||||||||||||||
3933 | { | - | ||||||||||||||||||||||||||||||||||||
3934 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
3935 | 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 | ||||||||||||||||||||||||||||||||||||
3936 | ? 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 | ||||||||||||||||||||||||||||||||||||
3937 | : 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 | ||||||||||||||||||||||||||||||||||||
3938 | } | - | ||||||||||||||||||||||||||||||||||||
3939 | - | |||||||||||||||||||||||||||||||||||||
3940 | bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh) | - | ||||||||||||||||||||||||||||||||||||
3941 | { | - | ||||||||||||||||||||||||||||||||||||
3942 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3943 | - | |||||||||||||||||||||||||||||||||||||
3944 | int mw = minw, mh = minh; | - | ||||||||||||||||||||||||||||||||||||
3945 | if (mw == QWIDGETSIZE_MAX)
| 0 | ||||||||||||||||||||||||||||||||||||
3946 | mw = 0; never executed: mw = 0; | 0 | ||||||||||||||||||||||||||||||||||||
3947 | if (mh == QWIDGETSIZE_MAX)
| 0 | ||||||||||||||||||||||||||||||||||||
3948 | mh = 0; never executed: mh = 0; | 0 | ||||||||||||||||||||||||||||||||||||
3949 | if (minw > QWIDGETSIZE_MAX || minh > QWIDGETSIZE_MAX) {
| 0 | ||||||||||||||||||||||||||||||||||||
3950 | qWarning("QWidget::setMinimumSize: (%s/%s) " | - | ||||||||||||||||||||||||||||||||||||
3951 | "The largest allowed size is (%d,%d)", | - | ||||||||||||||||||||||||||||||||||||
3952 | q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX, | - | ||||||||||||||||||||||||||||||||||||
3953 | QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||||||||
3954 | minw = mw = qMin<int>(minw, QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||||||||
3955 | minh = mh = qMin<int>(minh, QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||||||||
3956 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3957 | if (minw < 0 || minh < 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
3958 | qWarning("QWidget::setMinimumSize: (%s/%s) Negative sizes (%d,%d) " | - | ||||||||||||||||||||||||||||||||||||
3959 | "are not possible", | - | ||||||||||||||||||||||||||||||||||||
3960 | q->objectName().toLocal8Bit().data(), q->metaObject()->className(), minw, minh); | - | ||||||||||||||||||||||||||||||||||||
3961 | minw = mw = qMax(minw, 0); | - | ||||||||||||||||||||||||||||||||||||
3962 | minh = mh = qMax(minh, 0); | - | ||||||||||||||||||||||||||||||||||||
3963 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3964 | createExtra(); | - | ||||||||||||||||||||||||||||||||||||
3965 | if (extra->minw == mw && extra->minh == mh)
| 0 | ||||||||||||||||||||||||||||||||||||
3966 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
3967 | extra->minw = mw; | - | ||||||||||||||||||||||||||||||||||||
3968 | extra->minh = mh; | - | ||||||||||||||||||||||||||||||||||||
3969 | extra->explicitMinSize = (mw ? Qt::Horizontal : 0) | (mh ? Qt::Vertical : 0);
| 0 | ||||||||||||||||||||||||||||||||||||
3970 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
3971 | } | - | ||||||||||||||||||||||||||||||||||||
3972 | - | |||||||||||||||||||||||||||||||||||||
3973 | void QWidgetPrivate::setConstraints_sys() | - | ||||||||||||||||||||||||||||||||||||
3974 | { | - | ||||||||||||||||||||||||||||||||||||
3975 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
3976 | if (extra && q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
3977 | QWindow *win = q->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
3978 | QWindowPrivate *winp = qt_window_private(win); | - | ||||||||||||||||||||||||||||||||||||
3979 | - | |||||||||||||||||||||||||||||||||||||
3980 | winp->minimumSize = QSize(extra->minw, extra->minh); | - | ||||||||||||||||||||||||||||||||||||
3981 | winp->maximumSize = QSize(extra->maxw, extra->maxh); | - | ||||||||||||||||||||||||||||||||||||
3982 | - | |||||||||||||||||||||||||||||||||||||
3983 | if (extra->topextra) {
| 0 | ||||||||||||||||||||||||||||||||||||
3984 | winp->baseSize = QSize(extra->topextra->basew, extra->topextra->baseh); | - | ||||||||||||||||||||||||||||||||||||
3985 | winp->sizeIncrement = QSize(extra->topextra->incw, extra->topextra->inch); | - | ||||||||||||||||||||||||||||||||||||
3986 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3987 | - | |||||||||||||||||||||||||||||||||||||
3988 | if (winp->platformWindow) {
| 0 | ||||||||||||||||||||||||||||||||||||
3989 | fixPosIncludesFrame(); | - | ||||||||||||||||||||||||||||||||||||
3990 | winp->platformWindow->propagateSizeHints(); | - | ||||||||||||||||||||||||||||||||||||
3991 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3992 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3993 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
3994 | - | |||||||||||||||||||||||||||||||||||||
3995 | /*! | - | ||||||||||||||||||||||||||||||||||||
3996 | \overload | - | ||||||||||||||||||||||||||||||||||||
3997 | - | |||||||||||||||||||||||||||||||||||||
3998 | This function corresponds to setMinimumSize(QSize(minw, minh)). | - | ||||||||||||||||||||||||||||||||||||
3999 | Sets the minimum width to \a minw and the minimum height to \a | - | ||||||||||||||||||||||||||||||||||||
4000 | minh. | - | ||||||||||||||||||||||||||||||||||||
4001 | */ | - | ||||||||||||||||||||||||||||||||||||
4002 | - | |||||||||||||||||||||||||||||||||||||
4003 | void QWidget::setMinimumSize(int minw, int minh) | - | ||||||||||||||||||||||||||||||||||||
4004 | { | - | ||||||||||||||||||||||||||||||||||||
4005 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4006 | if (!d->setMinimumSize_helper(minw, minh))
| 0 | ||||||||||||||||||||||||||||||||||||
4007 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4008 | - | |||||||||||||||||||||||||||||||||||||
4009 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
4010 | d->setConstraints_sys(); never executed: d->setConstraints_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
4011 | if (minw > width() || minh > height()) {
| 0 | ||||||||||||||||||||||||||||||||||||
4012 | bool resized = testAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||||||||||||||
4013 | bool maximized = isMaximized(); | - | ||||||||||||||||||||||||||||||||||||
4014 | resize(qMax(minw,width()), qMax(minh,height())); | - | ||||||||||||||||||||||||||||||||||||
4015 | setAttribute(Qt::WA_Resized, resized); //not a user resize | - | ||||||||||||||||||||||||||||||||||||
4016 | if (maximized)
| 0 | ||||||||||||||||||||||||||||||||||||
4017 | data->window_state = data->window_state | Qt::WindowMaximized; never executed: data->window_state = data->window_state | Qt::WindowMaximized; | 0 | ||||||||||||||||||||||||||||||||||||
4018 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4019 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4020 | if (d->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
4021 | if (d->extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
4022 | d->extra->proxyWidget->setMinimumSize(minw, minh); never executed: d->extra->proxyWidget->setMinimumSize(minw, minh); | 0 | ||||||||||||||||||||||||||||||||||||
4023 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4024 | #endif | - | ||||||||||||||||||||||||||||||||||||
4025 | d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh); | - | ||||||||||||||||||||||||||||||||||||
4026 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4027 | - | |||||||||||||||||||||||||||||||||||||
4028 | bool QWidgetPrivate::setMaximumSize_helper(int &maxw, int &maxh) | - | ||||||||||||||||||||||||||||||||||||
4029 | { | - | ||||||||||||||||||||||||||||||||||||
4030 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4031 | if (maxw > QWIDGETSIZE_MAX || maxh > QWIDGETSIZE_MAX) {
| 0 | ||||||||||||||||||||||||||||||||||||
4032 | qWarning("QWidget::setMaximumSize: (%s/%s) " | - | ||||||||||||||||||||||||||||||||||||
4033 | "The largest allowed size is (%d,%d)", | - | ||||||||||||||||||||||||||||||||||||
4034 | q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX, | - | ||||||||||||||||||||||||||||||||||||
4035 | QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||||||||
4036 | maxw = qMin<int>(maxw, QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||||||||
4037 | maxh = qMin<int>(maxh, QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||||||||
4038 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4039 | if (maxw < 0 || maxh < 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
4040 | qWarning("QWidget::setMaximumSize: (%s/%s) Negative sizes (%d,%d) " | - | ||||||||||||||||||||||||||||||||||||
4041 | "are not possible", | - | ||||||||||||||||||||||||||||||||||||
4042 | q->objectName().toLocal8Bit().data(), q->metaObject()->className(), maxw, maxh); | - | ||||||||||||||||||||||||||||||||||||
4043 | maxw = qMax(maxw, 0); | - | ||||||||||||||||||||||||||||||||||||
4044 | maxh = qMax(maxh, 0); | - | ||||||||||||||||||||||||||||||||||||
4045 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4046 | createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4047 | if (extra->maxw == maxw && extra->maxh == maxh)
| 0 | ||||||||||||||||||||||||||||||||||||
4048 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
4049 | extra->maxw = maxw; | - | ||||||||||||||||||||||||||||||||||||
4050 | extra->maxh = maxh; | - | ||||||||||||||||||||||||||||||||||||
4051 | extra->explicitMaxSize = (maxw != QWIDGETSIZE_MAX ? Qt::Horizontal : 0) |
| 0 | ||||||||||||||||||||||||||||||||||||
4052 | (maxh != QWIDGETSIZE_MAX ? Qt::Vertical : 0); | - | ||||||||||||||||||||||||||||||||||||
4053 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
4054 | } | - | ||||||||||||||||||||||||||||||||||||
4055 | - | |||||||||||||||||||||||||||||||||||||
4056 | /*! | - | ||||||||||||||||||||||||||||||||||||
4057 | \overload | - | ||||||||||||||||||||||||||||||||||||
4058 | - | |||||||||||||||||||||||||||||||||||||
4059 | This function corresponds to setMaximumSize(QSize(\a maxw, \a | - | ||||||||||||||||||||||||||||||||||||
4060 | maxh)). Sets the maximum width to \a maxw and the maximum height | - | ||||||||||||||||||||||||||||||||||||
4061 | to \a maxh. | - | ||||||||||||||||||||||||||||||||||||
4062 | */ | - | ||||||||||||||||||||||||||||||||||||
4063 | void QWidget::setMaximumSize(int maxw, int maxh) | - | ||||||||||||||||||||||||||||||||||||
4064 | { | - | ||||||||||||||||||||||||||||||||||||
4065 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4066 | if (!d->setMaximumSize_helper(maxw, maxh))
| 0 | ||||||||||||||||||||||||||||||||||||
4067 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4068 | - | |||||||||||||||||||||||||||||||||||||
4069 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
4070 | d->setConstraints_sys(); never executed: d->setConstraints_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
4071 | if (maxw < width() || maxh < height()) {
| 0 | ||||||||||||||||||||||||||||||||||||
4072 | bool resized = testAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||||||||||||||
4073 | resize(qMin(maxw,width()), qMin(maxh,height())); | - | ||||||||||||||||||||||||||||||||||||
4074 | setAttribute(Qt::WA_Resized, resized); //not a user resize | - | ||||||||||||||||||||||||||||||||||||
4075 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4076 | - | |||||||||||||||||||||||||||||||||||||
4077 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4078 | if (d->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
4079 | if (d->extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
4080 | d->extra->proxyWidget->setMaximumSize(maxw, maxh); never executed: d->extra->proxyWidget->setMaximumSize(maxw, maxh); | 0 | ||||||||||||||||||||||||||||||||||||
4081 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4082 | #endif | - | ||||||||||||||||||||||||||||||||||||
4083 | - | |||||||||||||||||||||||||||||||||||||
4084 | d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh); | - | ||||||||||||||||||||||||||||||||||||
4085 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4086 | - | |||||||||||||||||||||||||||||||||||||
4087 | /*! | - | ||||||||||||||||||||||||||||||||||||
4088 | \overload | - | ||||||||||||||||||||||||||||||||||||
4089 | - | |||||||||||||||||||||||||||||||||||||
4090 | Sets the x (width) size increment to \a w and the y (height) size | - | ||||||||||||||||||||||||||||||||||||
4091 | increment to \a h. | - | ||||||||||||||||||||||||||||||||||||
4092 | */ | - | ||||||||||||||||||||||||||||||||||||
4093 | void QWidget::setSizeIncrement(int w, int h) | - | ||||||||||||||||||||||||||||||||||||
4094 | { | - | ||||||||||||||||||||||||||||||||||||
4095 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4096 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
4097 | QTLWExtra* x = d->topData(); | - | ||||||||||||||||||||||||||||||||||||
4098 | if (x->incw == w && x->inch == h)
| 0 | ||||||||||||||||||||||||||||||||||||
4099 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4100 | x->incw = w; | - | ||||||||||||||||||||||||||||||||||||
4101 | x->inch = h; | - | ||||||||||||||||||||||||||||||||||||
4102 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
4103 | d->setConstraints_sys(); never executed: d->setConstraints_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
4104 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4105 | - | |||||||||||||||||||||||||||||||||||||
4106 | /*! | - | ||||||||||||||||||||||||||||||||||||
4107 | \overload | - | ||||||||||||||||||||||||||||||||||||
4108 | - | |||||||||||||||||||||||||||||||||||||
4109 | This corresponds to setBaseSize(QSize(\a basew, \a baseh)). Sets | - | ||||||||||||||||||||||||||||||||||||
4110 | the widgets base size to width \a basew and height \a baseh. | - | ||||||||||||||||||||||||||||||||||||
4111 | */ | - | ||||||||||||||||||||||||||||||||||||
4112 | void QWidget::setBaseSize(int basew, int baseh) | - | ||||||||||||||||||||||||||||||||||||
4113 | { | - | ||||||||||||||||||||||||||||||||||||
4114 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4115 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
4116 | QTLWExtra* x = d->topData(); | - | ||||||||||||||||||||||||||||||||||||
4117 | if (x->basew == basew && x->baseh == baseh)
| 0 | ||||||||||||||||||||||||||||||||||||
4118 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4119 | x->basew = basew; | - | ||||||||||||||||||||||||||||||||||||
4120 | x->baseh = baseh; | - | ||||||||||||||||||||||||||||||||||||
4121 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
4122 | d->setConstraints_sys(); never executed: d->setConstraints_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
4123 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4124 | - | |||||||||||||||||||||||||||||||||||||
4125 | /*! | - | ||||||||||||||||||||||||||||||||||||
4126 | Sets both the minimum and maximum sizes of the widget to \a s, | - | ||||||||||||||||||||||||||||||||||||
4127 | thereby preventing it from ever growing or shrinking. | - | ||||||||||||||||||||||||||||||||||||
4128 | - | |||||||||||||||||||||||||||||||||||||
4129 | This will override the default size constraints set by QLayout. | - | ||||||||||||||||||||||||||||||||||||
4130 | - | |||||||||||||||||||||||||||||||||||||
4131 | To remove constraints, set the size to QWIDGETSIZE_MAX. | - | ||||||||||||||||||||||||||||||||||||
4132 | - | |||||||||||||||||||||||||||||||||||||
4133 | Alternatively, if you want the widget to have a | - | ||||||||||||||||||||||||||||||||||||
4134 | fixed size based on its contents, you can call | - | ||||||||||||||||||||||||||||||||||||
4135 | QLayout::setSizeConstraint(QLayout::SetFixedSize); | - | ||||||||||||||||||||||||||||||||||||
4136 | - | |||||||||||||||||||||||||||||||||||||
4137 | \sa maximumSize, minimumSize | - | ||||||||||||||||||||||||||||||||||||
4138 | */ | - | ||||||||||||||||||||||||||||||||||||
4139 | - | |||||||||||||||||||||||||||||||||||||
4140 | void QWidget::setFixedSize(const QSize & s) | - | ||||||||||||||||||||||||||||||||||||
4141 | { | - | ||||||||||||||||||||||||||||||||||||
4142 | setFixedSize(s.width(), s.height()); | - | ||||||||||||||||||||||||||||||||||||
4143 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4144 | - | |||||||||||||||||||||||||||||||||||||
4145 | - | |||||||||||||||||||||||||||||||||||||
4146 | /*! | - | ||||||||||||||||||||||||||||||||||||
4147 | \fn void QWidget::setFixedSize(int w, int h) | - | ||||||||||||||||||||||||||||||||||||
4148 | \overload | - | ||||||||||||||||||||||||||||||||||||
4149 | - | |||||||||||||||||||||||||||||||||||||
4150 | Sets the width of the widget to \a w and the height to \a h. | - | ||||||||||||||||||||||||||||||||||||
4151 | */ | - | ||||||||||||||||||||||||||||||||||||
4152 | - | |||||||||||||||||||||||||||||||||||||
4153 | void QWidget::setFixedSize(int w, int h) | - | ||||||||||||||||||||||||||||||||||||
4154 | { | - | ||||||||||||||||||||||||||||||||||||
4155 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4156 | bool minSizeSet = d->setMinimumSize_helper(w, h); | - | ||||||||||||||||||||||||||||||||||||
4157 | bool maxSizeSet = d->setMaximumSize_helper(w, h); | - | ||||||||||||||||||||||||||||||||||||
4158 | if (!minSizeSet && !maxSizeSet)
| 0 | ||||||||||||||||||||||||||||||||||||
4159 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4160 | - | |||||||||||||||||||||||||||||||||||||
4161 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
4162 | d->setConstraints_sys(); never executed: d->setConstraints_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
4163 | else | - | ||||||||||||||||||||||||||||||||||||
4164 | d->updateGeometry_helper(true); never executed: d->updateGeometry_helper(true); | 0 | ||||||||||||||||||||||||||||||||||||
4165 | - | |||||||||||||||||||||||||||||||||||||
4166 | if (w != QWIDGETSIZE_MAX || h != QWIDGETSIZE_MAX)
| 0 | ||||||||||||||||||||||||||||||||||||
4167 | resize(w, h); never executed: resize(w, h); | 0 | ||||||||||||||||||||||||||||||||||||
4168 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4169 | - | |||||||||||||||||||||||||||||||||||||
4170 | void QWidget::setMinimumWidth(int w) | - | ||||||||||||||||||||||||||||||||||||
4171 | { | - | ||||||||||||||||||||||||||||||||||||
4172 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4173 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4174 | uint expl = d->extra->explicitMinSize | (w ? Qt::Horizontal : 0); | - | ||||||||||||||||||||||||||||||||||||
4175 | setMinimumSize(w, minimumSize().height()); | - | ||||||||||||||||||||||||||||||||||||
4176 | d->extra->explicitMinSize = expl; | - | ||||||||||||||||||||||||||||||||||||
4177 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4178 | - | |||||||||||||||||||||||||||||||||||||
4179 | void QWidget::setMinimumHeight(int h) | - | ||||||||||||||||||||||||||||||||||||
4180 | { | - | ||||||||||||||||||||||||||||||||||||
4181 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4182 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4183 | uint expl = d->extra->explicitMinSize | (h ? Qt::Vertical : 0); | - | ||||||||||||||||||||||||||||||||||||
4184 | setMinimumSize(minimumSize().width(), h); | - | ||||||||||||||||||||||||||||||||||||
4185 | d->extra->explicitMinSize = expl; | - | ||||||||||||||||||||||||||||||||||||
4186 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4187 | - | |||||||||||||||||||||||||||||||||||||
4188 | void QWidget::setMaximumWidth(int w) | - | ||||||||||||||||||||||||||||||||||||
4189 | { | - | ||||||||||||||||||||||||||||||||||||
4190 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4191 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4192 | uint expl = d->extra->explicitMaxSize | (w == QWIDGETSIZE_MAX ? 0 : Qt::Horizontal); | - | ||||||||||||||||||||||||||||||||||||
4193 | setMaximumSize(w, maximumSize().height()); | - | ||||||||||||||||||||||||||||||||||||
4194 | d->extra->explicitMaxSize = expl; | - | ||||||||||||||||||||||||||||||||||||
4195 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4196 | - | |||||||||||||||||||||||||||||||||||||
4197 | void QWidget::setMaximumHeight(int h) | - | ||||||||||||||||||||||||||||||||||||
4198 | { | - | ||||||||||||||||||||||||||||||||||||
4199 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4200 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4201 | uint expl = d->extra->explicitMaxSize | (h == QWIDGETSIZE_MAX ? 0 : Qt::Vertical); | - | ||||||||||||||||||||||||||||||||||||
4202 | setMaximumSize(maximumSize().width(), h); | - | ||||||||||||||||||||||||||||||||||||
4203 | d->extra->explicitMaxSize = expl; | - | ||||||||||||||||||||||||||||||||||||
4204 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4205 | - | |||||||||||||||||||||||||||||||||||||
4206 | /*! | - | ||||||||||||||||||||||||||||||||||||
4207 | Sets both the minimum and maximum width of the widget to \a w | - | ||||||||||||||||||||||||||||||||||||
4208 | without changing the heights. Provided for convenience. | - | ||||||||||||||||||||||||||||||||||||
4209 | - | |||||||||||||||||||||||||||||||||||||
4210 | \sa sizeHint(), minimumSize(), maximumSize(), setFixedSize() | - | ||||||||||||||||||||||||||||||||||||
4211 | */ | - | ||||||||||||||||||||||||||||||||||||
4212 | - | |||||||||||||||||||||||||||||||||||||
4213 | void QWidget::setFixedWidth(int w) | - | ||||||||||||||||||||||||||||||||||||
4214 | { | - | ||||||||||||||||||||||||||||||||||||
4215 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4216 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4217 | uint explMin = d->extra->explicitMinSize | Qt::Horizontal; | - | ||||||||||||||||||||||||||||||||||||
4218 | uint explMax = d->extra->explicitMaxSize | Qt::Horizontal; | - | ||||||||||||||||||||||||||||||||||||
4219 | setMinimumSize(w, minimumSize().height()); | - | ||||||||||||||||||||||||||||||||||||
4220 | setMaximumSize(w, maximumSize().height()); | - | ||||||||||||||||||||||||||||||||||||
4221 | d->extra->explicitMinSize = explMin; | - | ||||||||||||||||||||||||||||||||||||
4222 | d->extra->explicitMaxSize = explMax; | - | ||||||||||||||||||||||||||||||||||||
4223 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4224 | - | |||||||||||||||||||||||||||||||||||||
4225 | - | |||||||||||||||||||||||||||||||||||||
4226 | /*! | - | ||||||||||||||||||||||||||||||||||||
4227 | Sets both the minimum and maximum heights of the widget to \a h | - | ||||||||||||||||||||||||||||||||||||
4228 | without changing the widths. Provided for convenience. | - | ||||||||||||||||||||||||||||||||||||
4229 | - | |||||||||||||||||||||||||||||||||||||
4230 | \sa sizeHint(), minimumSize(), maximumSize(), setFixedSize() | - | ||||||||||||||||||||||||||||||||||||
4231 | */ | - | ||||||||||||||||||||||||||||||||||||
4232 | - | |||||||||||||||||||||||||||||||||||||
4233 | void QWidget::setFixedHeight(int h) | - | ||||||||||||||||||||||||||||||||||||
4234 | { | - | ||||||||||||||||||||||||||||||||||||
4235 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4236 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4237 | uint explMin = d->extra->explicitMinSize | Qt::Vertical; | - | ||||||||||||||||||||||||||||||||||||
4238 | uint explMax = d->extra->explicitMaxSize | Qt::Vertical; | - | ||||||||||||||||||||||||||||||||||||
4239 | setMinimumSize(minimumSize().width(), h); | - | ||||||||||||||||||||||||||||||||||||
4240 | setMaximumSize(maximumSize().width(), h); | - | ||||||||||||||||||||||||||||||||||||
4241 | d->extra->explicitMinSize = explMin; | - | ||||||||||||||||||||||||||||||||||||
4242 | d->extra->explicitMaxSize = explMax; | - | ||||||||||||||||||||||||||||||||||||
4243 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4244 | - | |||||||||||||||||||||||||||||||||||||
4245 | - | |||||||||||||||||||||||||||||||||||||
4246 | /*! | - | ||||||||||||||||||||||||||||||||||||
4247 | Translates the widget coordinate \a pos to the coordinate system | - | ||||||||||||||||||||||||||||||||||||
4248 | of \a parent. The \a parent must not be 0 and must be a parent | - | ||||||||||||||||||||||||||||||||||||
4249 | of the calling widget. | - | ||||||||||||||||||||||||||||||||||||
4250 | - | |||||||||||||||||||||||||||||||||||||
4251 | \sa mapFrom(), mapToParent(), mapToGlobal(), underMouse() | - | ||||||||||||||||||||||||||||||||||||
4252 | */ | - | ||||||||||||||||||||||||||||||||||||
4253 | - | |||||||||||||||||||||||||||||||||||||
4254 | QPoint QWidget::mapTo(const QWidget * parent, const QPoint & pos) const | - | ||||||||||||||||||||||||||||||||||||
4255 | { | - | ||||||||||||||||||||||||||||||||||||
4256 | QPoint p = pos; | - | ||||||||||||||||||||||||||||||||||||
4257 | if (parent) {
| 0 | ||||||||||||||||||||||||||||||||||||
4258 | const QWidget * w = this; | - | ||||||||||||||||||||||||||||||||||||
4259 | while (w != parent) {
| 0 | ||||||||||||||||||||||||||||||||||||
4260 | Q_ASSERT_X(w, "QWidget::mapTo(const QWidget *parent, const QPoint &pos)", | - | ||||||||||||||||||||||||||||||||||||
4261 | "parent must be in parent hierarchy"); | - | ||||||||||||||||||||||||||||||||||||
4262 | p = w->mapToParent(p); | - | ||||||||||||||||||||||||||||||||||||
4263 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
4264 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4265 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4266 | return p; never executed: return p; | 0 | ||||||||||||||||||||||||||||||||||||
4267 | } | - | ||||||||||||||||||||||||||||||||||||
4268 | - | |||||||||||||||||||||||||||||||||||||
4269 | - | |||||||||||||||||||||||||||||||||||||
4270 | /*! | - | ||||||||||||||||||||||||||||||||||||
4271 | Translates the widget coordinate \a pos from the coordinate system | - | ||||||||||||||||||||||||||||||||||||
4272 | of \a parent to this widget's coordinate system. The \a parent | - | ||||||||||||||||||||||||||||||||||||
4273 | must not be 0 and must be a parent of the calling widget. | - | ||||||||||||||||||||||||||||||||||||
4274 | - | |||||||||||||||||||||||||||||||||||||
4275 | \sa mapTo(), mapFromParent(), mapFromGlobal(), underMouse() | - | ||||||||||||||||||||||||||||||||||||
4276 | */ | - | ||||||||||||||||||||||||||||||||||||
4277 | - | |||||||||||||||||||||||||||||||||||||
4278 | QPoint QWidget::mapFrom(const QWidget * parent, const QPoint & pos) const | - | ||||||||||||||||||||||||||||||||||||
4279 | { | - | ||||||||||||||||||||||||||||||||||||
4280 | QPoint p(pos); | - | ||||||||||||||||||||||||||||||||||||
4281 | if (parent) {
| 0 | ||||||||||||||||||||||||||||||||||||
4282 | const QWidget * w = this; | - | ||||||||||||||||||||||||||||||||||||
4283 | while (w != parent) {
| 0 | ||||||||||||||||||||||||||||||||||||
4284 | Q_ASSERT_X(w, "QWidget::mapFrom(const QWidget *parent, const QPoint &pos)", | - | ||||||||||||||||||||||||||||||||||||
4285 | "parent must be in parent hierarchy"); | - | ||||||||||||||||||||||||||||||||||||
4286 | - | |||||||||||||||||||||||||||||||||||||
4287 | p = w->mapFromParent(p); | - | ||||||||||||||||||||||||||||||||||||
4288 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
4289 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4290 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4291 | return p; never executed: return p; | 0 | ||||||||||||||||||||||||||||||||||||
4292 | } | - | ||||||||||||||||||||||||||||||||||||
4293 | - | |||||||||||||||||||||||||||||||||||||
4294 | - | |||||||||||||||||||||||||||||||||||||
4295 | /*! | - | ||||||||||||||||||||||||||||||||||||
4296 | Translates the widget coordinate \a pos to a coordinate in the | - | ||||||||||||||||||||||||||||||||||||
4297 | parent widget. | - | ||||||||||||||||||||||||||||||||||||
4298 | - | |||||||||||||||||||||||||||||||||||||
4299 | Same as mapToGlobal() if the widget has no parent. | - | ||||||||||||||||||||||||||||||||||||
4300 | - | |||||||||||||||||||||||||||||||||||||
4301 | \sa mapFromParent(), mapTo(), mapToGlobal(), underMouse() | - | ||||||||||||||||||||||||||||||||||||
4302 | */ | - | ||||||||||||||||||||||||||||||||||||
4303 | - | |||||||||||||||||||||||||||||||||||||
4304 | QPoint QWidget::mapToParent(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
4305 | { | - | ||||||||||||||||||||||||||||||||||||
4306 | return pos + data->crect.topLeft(); never executed: return pos + data->crect.topLeft(); | 0 | ||||||||||||||||||||||||||||||||||||
4307 | } | - | ||||||||||||||||||||||||||||||||||||
4308 | - | |||||||||||||||||||||||||||||||||||||
4309 | /*! | - | ||||||||||||||||||||||||||||||||||||
4310 | Translates the parent widget coordinate \a pos to widget | - | ||||||||||||||||||||||||||||||||||||
4311 | coordinates. | - | ||||||||||||||||||||||||||||||||||||
4312 | - | |||||||||||||||||||||||||||||||||||||
4313 | Same as mapFromGlobal() if the widget has no parent. | - | ||||||||||||||||||||||||||||||||||||
4314 | - | |||||||||||||||||||||||||||||||||||||
4315 | \sa mapToParent(), mapFrom(), mapFromGlobal(), underMouse() | - | ||||||||||||||||||||||||||||||||||||
4316 | */ | - | ||||||||||||||||||||||||||||||||||||
4317 | - | |||||||||||||||||||||||||||||||||||||
4318 | QPoint QWidget::mapFromParent(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
4319 | { | - | ||||||||||||||||||||||||||||||||||||
4320 | return pos - data->crect.topLeft(); never executed: return pos - data->crect.topLeft(); | 0 | ||||||||||||||||||||||||||||||||||||
4321 | } | - | ||||||||||||||||||||||||||||||||||||
4322 | - | |||||||||||||||||||||||||||||||||||||
4323 | - | |||||||||||||||||||||||||||||||||||||
4324 | /*! | - | ||||||||||||||||||||||||||||||||||||
4325 | Returns the window for this widget, i.e. the next ancestor widget | - | ||||||||||||||||||||||||||||||||||||
4326 | that has (or could have) a window-system frame. | - | ||||||||||||||||||||||||||||||||||||
4327 | - | |||||||||||||||||||||||||||||||||||||
4328 | If the widget is a window, the widget itself is returned. | - | ||||||||||||||||||||||||||||||||||||
4329 | - | |||||||||||||||||||||||||||||||||||||
4330 | Typical usage is changing the window title: | - | ||||||||||||||||||||||||||||||||||||
4331 | - | |||||||||||||||||||||||||||||||||||||
4332 | \snippet code/src_gui_kernel_qwidget.cpp 3 | - | ||||||||||||||||||||||||||||||||||||
4333 | - | |||||||||||||||||||||||||||||||||||||
4334 | \sa isWindow() | - | ||||||||||||||||||||||||||||||||||||
4335 | */ | - | ||||||||||||||||||||||||||||||||||||
4336 | - | |||||||||||||||||||||||||||||||||||||
4337 | QWidget *QWidget::window() const | - | ||||||||||||||||||||||||||||||||||||
4338 | { | - | ||||||||||||||||||||||||||||||||||||
4339 | QWidget *w = const_cast<QWidget *>(this); | - | ||||||||||||||||||||||||||||||||||||
4340 | QWidget *p = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
4341 | while (!w->isWindow() && p) {
| 0 | ||||||||||||||||||||||||||||||||||||
4342 | w = p; | - | ||||||||||||||||||||||||||||||||||||
4343 | p = p->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
4344 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4345 | return w; never executed: return w; | 0 | ||||||||||||||||||||||||||||||||||||
4346 | } | - | ||||||||||||||||||||||||||||||||||||
4347 | - | |||||||||||||||||||||||||||||||||||||
4348 | /*! | - | ||||||||||||||||||||||||||||||||||||
4349 | \since 4.4 | - | ||||||||||||||||||||||||||||||||||||
4350 | - | |||||||||||||||||||||||||||||||||||||
4351 | Returns the native parent for this widget, i.e. the next ancestor widget | - | ||||||||||||||||||||||||||||||||||||
4352 | that has a system identifier, or 0 if it does not have any native parent. | - | ||||||||||||||||||||||||||||||||||||
4353 | - | |||||||||||||||||||||||||||||||||||||
4354 | \sa effectiveWinId() | - | ||||||||||||||||||||||||||||||||||||
4355 | */ | - | ||||||||||||||||||||||||||||||||||||
4356 | QWidget *QWidget::nativeParentWidget() const | - | ||||||||||||||||||||||||||||||||||||
4357 | { | - | ||||||||||||||||||||||||||||||||||||
4358 | QWidget *parent = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
4359 | while (parent && !parent->internalWinId())
| 0 | ||||||||||||||||||||||||||||||||||||
4360 | parent = parent->parentWidget(); never executed: parent = parent->parentWidget(); | 0 | ||||||||||||||||||||||||||||||||||||
4361 | return parent; never executed: return parent; | 0 | ||||||||||||||||||||||||||||||||||||
4362 | } | - | ||||||||||||||||||||||||||||||||||||
4363 | - | |||||||||||||||||||||||||||||||||||||
4364 | /*! \fn QWidget *QWidget::topLevelWidget() const | - | ||||||||||||||||||||||||||||||||||||
4365 | \obsolete | - | ||||||||||||||||||||||||||||||||||||
4366 | - | |||||||||||||||||||||||||||||||||||||
4367 | Use window() instead. | - | ||||||||||||||||||||||||||||||||||||
4368 | */ | - | ||||||||||||||||||||||||||||||||||||
4369 | - | |||||||||||||||||||||||||||||||||||||
4370 | - | |||||||||||||||||||||||||||||||||||||
4371 | - | |||||||||||||||||||||||||||||||||||||
4372 | /*! | - | ||||||||||||||||||||||||||||||||||||
4373 | Returns the background role of the widget. | - | ||||||||||||||||||||||||||||||||||||
4374 | - | |||||||||||||||||||||||||||||||||||||
4375 | The background role defines the brush from the widget's \l palette that | - | ||||||||||||||||||||||||||||||||||||
4376 | is used to render the background. | - | ||||||||||||||||||||||||||||||||||||
4377 | - | |||||||||||||||||||||||||||||||||||||
4378 | If no explicit background role is set, the widget inherts its parent | - | ||||||||||||||||||||||||||||||||||||
4379 | widget's background role. | - | ||||||||||||||||||||||||||||||||||||
4380 | - | |||||||||||||||||||||||||||||||||||||
4381 | \sa setBackgroundRole(), foregroundRole() | - | ||||||||||||||||||||||||||||||||||||
4382 | */ | - | ||||||||||||||||||||||||||||||||||||
4383 | QPalette::ColorRole QWidget::backgroundRole() const | - | ||||||||||||||||||||||||||||||||||||
4384 | { | - | ||||||||||||||||||||||||||||||||||||
4385 | - | |||||||||||||||||||||||||||||||||||||
4386 | const QWidget *w = this; | - | ||||||||||||||||||||||||||||||||||||
4387 | do { | - | ||||||||||||||||||||||||||||||||||||
4388 | QPalette::ColorRole role = w->d_func()->bg_role; | - | ||||||||||||||||||||||||||||||||||||
4389 | if (role != QPalette::NoRole)
| 0 | ||||||||||||||||||||||||||||||||||||
4390 | return role; never executed: return role; | 0 | ||||||||||||||||||||||||||||||||||||
4391 | if (w->isWindow() || w->windowType() == Qt::SubWindow)
| 0 | ||||||||||||||||||||||||||||||||||||
4392 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
4393 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
4394 | } while (w); never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
4395 | return QPalette::Window; never executed: return QPalette::Window; | 0 | ||||||||||||||||||||||||||||||||||||
4396 | } | - | ||||||||||||||||||||||||||||||||||||
4397 | - | |||||||||||||||||||||||||||||||||||||
4398 | /*! | - | ||||||||||||||||||||||||||||||||||||
4399 | Sets the background role of the widget to \a role. | - | ||||||||||||||||||||||||||||||||||||
4400 | - | |||||||||||||||||||||||||||||||||||||
4401 | The background role defines the brush from the widget's \l palette that | - | ||||||||||||||||||||||||||||||||||||
4402 | is used to render the background. | - | ||||||||||||||||||||||||||||||||||||
4403 | - | |||||||||||||||||||||||||||||||||||||
4404 | If \a role is QPalette::NoRole, then the widget inherits its | - | ||||||||||||||||||||||||||||||||||||
4405 | parent's background role. | - | ||||||||||||||||||||||||||||||||||||
4406 | - | |||||||||||||||||||||||||||||||||||||
4407 | Note that styles are free to choose any color from the palette. | - | ||||||||||||||||||||||||||||||||||||
4408 | You can modify the palette or set a style sheet if you don't | - | ||||||||||||||||||||||||||||||||||||
4409 | achieve the result you want with setBackgroundRole(). | - | ||||||||||||||||||||||||||||||||||||
4410 | - | |||||||||||||||||||||||||||||||||||||
4411 | \sa backgroundRole(), foregroundRole() | - | ||||||||||||||||||||||||||||||||||||
4412 | */ | - | ||||||||||||||||||||||||||||||||||||
4413 | - | |||||||||||||||||||||||||||||||||||||
4414 | void QWidget::setBackgroundRole(QPalette::ColorRole role) | - | ||||||||||||||||||||||||||||||||||||
4415 | { | - | ||||||||||||||||||||||||||||||||||||
4416 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4417 | d->bg_role = role; | - | ||||||||||||||||||||||||||||||||||||
4418 | d->updateSystemBackground(); | - | ||||||||||||||||||||||||||||||||||||
4419 | d->propagatePaletteChange(); | - | ||||||||||||||||||||||||||||||||||||
4420 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
4421 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4422 | - | |||||||||||||||||||||||||||||||||||||
4423 | /*! | - | ||||||||||||||||||||||||||||||||||||
4424 | Returns the foreground role. | - | ||||||||||||||||||||||||||||||||||||
4425 | - | |||||||||||||||||||||||||||||||||||||
4426 | The foreground role defines the color from the widget's \l palette that | - | ||||||||||||||||||||||||||||||||||||
4427 | is used to draw the foreground. | - | ||||||||||||||||||||||||||||||||||||
4428 | - | |||||||||||||||||||||||||||||||||||||
4429 | If no explicit foreground role is set, the function returns a role | - | ||||||||||||||||||||||||||||||||||||
4430 | that contrasts with the background role. | - | ||||||||||||||||||||||||||||||||||||
4431 | - | |||||||||||||||||||||||||||||||||||||
4432 | \sa setForegroundRole(), backgroundRole() | - | ||||||||||||||||||||||||||||||||||||
4433 | */ | - | ||||||||||||||||||||||||||||||||||||
4434 | QPalette::ColorRole QWidget::foregroundRole() const | - | ||||||||||||||||||||||||||||||||||||
4435 | { | - | ||||||||||||||||||||||||||||||||||||
4436 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
4437 | QPalette::ColorRole rl = QPalette::ColorRole(d->fg_role); | - | ||||||||||||||||||||||||||||||||||||
4438 | if (rl != QPalette::NoRole)
| 0 | ||||||||||||||||||||||||||||||||||||
4439 | return rl; never executed: return rl; | 0 | ||||||||||||||||||||||||||||||||||||
4440 | QPalette::ColorRole role = QPalette::WindowText; | - | ||||||||||||||||||||||||||||||||||||
4441 | switch (backgroundRole()) { | - | ||||||||||||||||||||||||||||||||||||
4442 | case QPalette::Button: never executed: case QPalette::Button: | 0 | ||||||||||||||||||||||||||||||||||||
4443 | role = QPalette::ButtonText; | - | ||||||||||||||||||||||||||||||||||||
4444 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
4445 | case QPalette::Base: never executed: case QPalette::Base: | 0 | ||||||||||||||||||||||||||||||||||||
4446 | role = QPalette::Text; | - | ||||||||||||||||||||||||||||||||||||
4447 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
4448 | case QPalette::Dark: never executed: case QPalette::Dark: | 0 | ||||||||||||||||||||||||||||||||||||
4449 | case QPalette::Shadow: never executed: case QPalette::Shadow: | 0 | ||||||||||||||||||||||||||||||||||||
4450 | role = QPalette::Light; | - | ||||||||||||||||||||||||||||||||||||
4451 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
4452 | case QPalette::Highlight: never executed: case QPalette::Highlight: | 0 | ||||||||||||||||||||||||||||||||||||
4453 | role = QPalette::HighlightedText; | - | ||||||||||||||||||||||||||||||||||||
4454 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
4455 | case QPalette::ToolTipBase: never executed: case QPalette::ToolTipBase: | 0 | ||||||||||||||||||||||||||||||||||||
4456 | role = QPalette::ToolTipText; | - | ||||||||||||||||||||||||||||||||||||
4457 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
4458 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
4459 | ; | - | ||||||||||||||||||||||||||||||||||||
4460 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4461 | return role; never executed: return role; | 0 | ||||||||||||||||||||||||||||||||||||
4462 | } | - | ||||||||||||||||||||||||||||||||||||
4463 | - | |||||||||||||||||||||||||||||||||||||
4464 | /*! | - | ||||||||||||||||||||||||||||||||||||
4465 | Sets the foreground role of the widget to \a role. | - | ||||||||||||||||||||||||||||||||||||
4466 | - | |||||||||||||||||||||||||||||||||||||
4467 | The foreground role defines the color from the widget's \l palette that | - | ||||||||||||||||||||||||||||||||||||
4468 | is used to draw the foreground. | - | ||||||||||||||||||||||||||||||||||||
4469 | - | |||||||||||||||||||||||||||||||||||||
4470 | If \a role is QPalette::NoRole, the widget uses a foreground role | - | ||||||||||||||||||||||||||||||||||||
4471 | that contrasts with the background role. | - | ||||||||||||||||||||||||||||||||||||
4472 | - | |||||||||||||||||||||||||||||||||||||
4473 | Note that styles are free to choose any color from the palette. | - | ||||||||||||||||||||||||||||||||||||
4474 | You can modify the palette or set a style sheet if you don't | - | ||||||||||||||||||||||||||||||||||||
4475 | achieve the result you want with setForegroundRole(). | - | ||||||||||||||||||||||||||||||||||||
4476 | - | |||||||||||||||||||||||||||||||||||||
4477 | \sa foregroundRole(), backgroundRole() | - | ||||||||||||||||||||||||||||||||||||
4478 | */ | - | ||||||||||||||||||||||||||||||||||||
4479 | void QWidget::setForegroundRole(QPalette::ColorRole role) | - | ||||||||||||||||||||||||||||||||||||
4480 | { | - | ||||||||||||||||||||||||||||||||||||
4481 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4482 | d->fg_role = role; | - | ||||||||||||||||||||||||||||||||||||
4483 | d->updateSystemBackground(); | - | ||||||||||||||||||||||||||||||||||||
4484 | d->propagatePaletteChange(); | - | ||||||||||||||||||||||||||||||||||||
4485 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4486 | - | |||||||||||||||||||||||||||||||||||||
4487 | /*! | - | ||||||||||||||||||||||||||||||||||||
4488 | \property QWidget::palette | - | ||||||||||||||||||||||||||||||||||||
4489 | \brief the widget's palette | - | ||||||||||||||||||||||||||||||||||||
4490 | - | |||||||||||||||||||||||||||||||||||||
4491 | This property describes the widget's palette. The palette is used by the | - | ||||||||||||||||||||||||||||||||||||
4492 | widget's style when rendering standard components, and is available as a | - | ||||||||||||||||||||||||||||||||||||
4493 | means to ensure that custom widgets can maintain consistency with the | - | ||||||||||||||||||||||||||||||||||||
4494 | native platform's look and feel. It's common that different platforms, or | - | ||||||||||||||||||||||||||||||||||||
4495 | different styles, have different palettes. | - | ||||||||||||||||||||||||||||||||||||
4496 | - | |||||||||||||||||||||||||||||||||||||
4497 | When you assign a new palette to a widget, the color roles from this | - | ||||||||||||||||||||||||||||||||||||
4498 | palette are combined with the widget's default palette to form the | - | ||||||||||||||||||||||||||||||||||||
4499 | widget's final palette. The palette entry for the widget's background role | - | ||||||||||||||||||||||||||||||||||||
4500 | is used to fill the widget's background (see QWidget::autoFillBackground), | - | ||||||||||||||||||||||||||||||||||||
4501 | and the foreground role initializes QPainter's pen. | - | ||||||||||||||||||||||||||||||||||||
4502 | - | |||||||||||||||||||||||||||||||||||||
4503 | The default depends on the system environment. QApplication maintains a | - | ||||||||||||||||||||||||||||||||||||
4504 | system/theme palette which serves as a default for all widgets. There may | - | ||||||||||||||||||||||||||||||||||||
4505 | also be special palette defaults for certain types of widgets (e.g., on | - | ||||||||||||||||||||||||||||||||||||
4506 | Windows XP and Vista, all classes that derive from QMenuBar have a special | - | ||||||||||||||||||||||||||||||||||||
4507 | default palette). You can also define default palettes for widgets | - | ||||||||||||||||||||||||||||||||||||
4508 | yourself by passing a custom palette and the name of a widget to | - | ||||||||||||||||||||||||||||||||||||
4509 | QApplication::setPalette(). Finally, the style always has the option of | - | ||||||||||||||||||||||||||||||||||||
4510 | polishing the palette as it's assigned (see QStyle::polish()). | - | ||||||||||||||||||||||||||||||||||||
4511 | - | |||||||||||||||||||||||||||||||||||||
4512 | QWidget propagates explicit palette roles from parent to child. If you | - | ||||||||||||||||||||||||||||||||||||
4513 | assign a brush or color to a specific role on a palette and assign that | - | ||||||||||||||||||||||||||||||||||||
4514 | palette to a widget, that role will propagate to all the widget's | - | ||||||||||||||||||||||||||||||||||||
4515 | children, overriding any system defaults for that role. Note that palettes | - | ||||||||||||||||||||||||||||||||||||
4516 | by default don't propagate to windows (see isWindow()) unless the | - | ||||||||||||||||||||||||||||||||||||
4517 | Qt::WA_WindowPropagation attribute is enabled. | - | ||||||||||||||||||||||||||||||||||||
4518 | - | |||||||||||||||||||||||||||||||||||||
4519 | QWidget's palette propagation is similar to its font propagation. | - | ||||||||||||||||||||||||||||||||||||
4520 | - | |||||||||||||||||||||||||||||||||||||
4521 | The current style, which is used to render the content of all standard Qt | - | ||||||||||||||||||||||||||||||||||||
4522 | widgets, is free to choose colors and brushes from the widget palette, or | - | ||||||||||||||||||||||||||||||||||||
4523 | in some cases, to ignore the palette (partially, or completely). In | - | ||||||||||||||||||||||||||||||||||||
4524 | particular, certain styles like GTK style, Mac style, Windows XP, and | - | ||||||||||||||||||||||||||||||||||||
4525 | Vista style, depend on third party APIs to render the content of widgets, | - | ||||||||||||||||||||||||||||||||||||
4526 | and these styles typically do not follow the palette. Because of this, | - | ||||||||||||||||||||||||||||||||||||
4527 | assigning roles to a widget's palette is not guaranteed to change the | - | ||||||||||||||||||||||||||||||||||||
4528 | appearance of the widget. Instead, you may choose to apply a \l | - | ||||||||||||||||||||||||||||||||||||
4529 | styleSheet. You can refer to our Knowledge Base article | - | ||||||||||||||||||||||||||||||||||||
4530 | \l{http://qt.nokia.com/developer/knowledgebase/22}{here} for more | - | ||||||||||||||||||||||||||||||||||||
4531 | information. | - | ||||||||||||||||||||||||||||||||||||
4532 | - | |||||||||||||||||||||||||||||||||||||
4533 | \warning Do not use this function in conjunction with \l{Qt Style Sheets}. | - | ||||||||||||||||||||||||||||||||||||
4534 | When using style sheets, the palette of a widget can be customized using | - | ||||||||||||||||||||||||||||||||||||
4535 | the "color", "background-color", "selection-color", | - | ||||||||||||||||||||||||||||||||||||
4536 | "selection-background-color" and "alternate-background-color". | - | ||||||||||||||||||||||||||||||||||||
4537 | - | |||||||||||||||||||||||||||||||||||||
4538 | \sa QApplication::palette(), QWidget::font() | - | ||||||||||||||||||||||||||||||||||||
4539 | */ | - | ||||||||||||||||||||||||||||||||||||
4540 | const QPalette &QWidget::palette() const | - | ||||||||||||||||||||||||||||||||||||
4541 | { | - | ||||||||||||||||||||||||||||||||||||
4542 | if (!isEnabled()) {
| 0 | ||||||||||||||||||||||||||||||||||||
4543 | data->pal.setCurrentColorGroup(QPalette::Disabled); | - | ||||||||||||||||||||||||||||||||||||
4544 | } else if ((!isVisible() || isActiveWindow()) never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
4545 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) | - | ||||||||||||||||||||||||||||||||||||
4546 | && !QApplicationPrivate::isBlockedByModal(const_cast<QWidget *>(this)) | - | ||||||||||||||||||||||||||||||||||||
4547 | #endif | - | ||||||||||||||||||||||||||||||||||||
4548 | ) { | - | ||||||||||||||||||||||||||||||||||||
4549 | data->pal.setCurrentColorGroup(QPalette::Active); | - | ||||||||||||||||||||||||||||||||||||
4550 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4551 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
4552 | extern bool qt_mac_can_clickThrough(const QWidget *); //qwidget_mac.cpp | - | ||||||||||||||||||||||||||||||||||||
4553 | if (qt_mac_can_clickThrough(this)) | - | ||||||||||||||||||||||||||||||||||||
4554 | data->pal.setCurrentColorGroup(QPalette::Active); | - | ||||||||||||||||||||||||||||||||||||
4555 | else | - | ||||||||||||||||||||||||||||||||||||
4556 | #endif | - | ||||||||||||||||||||||||||||||||||||
4557 | data->pal.setCurrentColorGroup(QPalette::Inactive); | - | ||||||||||||||||||||||||||||||||||||
4558 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4559 | return data->pal; never executed: return data->pal; | 0 | ||||||||||||||||||||||||||||||||||||
4560 | } | - | ||||||||||||||||||||||||||||||||||||
4561 | - | |||||||||||||||||||||||||||||||||||||
4562 | void QWidget::setPalette(const QPalette &palette) | - | ||||||||||||||||||||||||||||||||||||
4563 | { | - | ||||||||||||||||||||||||||||||||||||
4564 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4565 | setAttribute(Qt::WA_SetPalette, palette.resolve() != 0); | - | ||||||||||||||||||||||||||||||||||||
4566 | - | |||||||||||||||||||||||||||||||||||||
4567 | // Determine which palette is inherited from this widget's ancestors and | - | ||||||||||||||||||||||||||||||||||||
4568 | // QApplication::palette, resolve this against \a palette (attributes from | - | ||||||||||||||||||||||||||||||||||||
4569 | // the inherited palette are copied over this widget's palette). Then | - | ||||||||||||||||||||||||||||||||||||
4570 | // propagate this palette to this widget's children. | - | ||||||||||||||||||||||||||||||||||||
4571 | QPalette naturalPalette = d->naturalWidgetPalette(d->inheritedPaletteResolveMask); | - | ||||||||||||||||||||||||||||||||||||
4572 | QPalette resolvedPalette = palette.resolve(naturalPalette); | - | ||||||||||||||||||||||||||||||||||||
4573 | d->setPalette_helper(resolvedPalette); | - | ||||||||||||||||||||||||||||||||||||
4574 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4575 | - | |||||||||||||||||||||||||||||||||||||
4576 | /*! | - | ||||||||||||||||||||||||||||||||||||
4577 | \internal | - | ||||||||||||||||||||||||||||||||||||
4578 | - | |||||||||||||||||||||||||||||||||||||
4579 | Returns the palette that the widget \a w inherits from its ancestors and | - | ||||||||||||||||||||||||||||||||||||
4580 | QApplication::palette. \a inheritedMask is the combination of the widget's | - | ||||||||||||||||||||||||||||||||||||
4581 | ancestors palette request masks (i.e., which attributes from the parent | - | ||||||||||||||||||||||||||||||||||||
4582 | widget's palette are implicitly imposed on this widget by the user). Note | - | ||||||||||||||||||||||||||||||||||||
4583 | that this font does not take into account the palette set on \a w itself. | - | ||||||||||||||||||||||||||||||||||||
4584 | */ | - | ||||||||||||||||||||||||||||||||||||
4585 | QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const | - | ||||||||||||||||||||||||||||||||||||
4586 | { | - | ||||||||||||||||||||||||||||||||||||
4587 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
4588 | QPalette naturalPalette = QApplication::palette(q); | - | ||||||||||||||||||||||||||||||||||||
4589 | if (!q->testAttribute(Qt::WA_StyleSheet)
| 0 | ||||||||||||||||||||||||||||||||||||
4590 | && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
| 0 | ||||||||||||||||||||||||||||||||||||
4591 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4592 | || (extra && extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
4593 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4594 | )) { | - | ||||||||||||||||||||||||||||||||||||
4595 | if (QWidget *p = q->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
4596 | if (!p->testAttribute(Qt::WA_StyleSheet)) {
| 0 | ||||||||||||||||||||||||||||||||||||
4597 | if (!naturalPalette.isCopyOf(QApplication::palette())) {
| 0 | ||||||||||||||||||||||||||||||||||||
4598 | QPalette inheritedPalette = p->palette(); | - | ||||||||||||||||||||||||||||||||||||
4599 | inheritedPalette.resolve(inheritedMask); | - | ||||||||||||||||||||||||||||||||||||
4600 | naturalPalette = inheritedPalette.resolve(naturalPalette); | - | ||||||||||||||||||||||||||||||||||||
4601 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4602 | naturalPalette = p->palette(); | - | ||||||||||||||||||||||||||||||||||||
4603 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4604 | } | - | ||||||||||||||||||||||||||||||||||||
4605 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4606 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4607 | else if (extra && extra->proxyWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
4608 | QPalette inheritedPalette = extra->proxyWidget->palette(); | - | ||||||||||||||||||||||||||||||||||||
4609 | inheritedPalette.resolve(inheritedMask); | - | ||||||||||||||||||||||||||||||||||||
4610 | naturalPalette = inheritedPalette.resolve(naturalPalette); | - | ||||||||||||||||||||||||||||||||||||
4611 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4612 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4613 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4614 | naturalPalette.resolve(0); | - | ||||||||||||||||||||||||||||||||||||
4615 | return naturalPalette; never executed: return naturalPalette; | 0 | ||||||||||||||||||||||||||||||||||||
4616 | } | - | ||||||||||||||||||||||||||||||||||||
4617 | /*! | - | ||||||||||||||||||||||||||||||||||||
4618 | \internal | - | ||||||||||||||||||||||||||||||||||||
4619 | - | |||||||||||||||||||||||||||||||||||||
4620 | Determine which palette is inherited from this widget's ancestors and | - | ||||||||||||||||||||||||||||||||||||
4621 | QApplication::palette, resolve this against this widget's palette | - | ||||||||||||||||||||||||||||||||||||
4622 | (attributes from the inherited palette are copied over this widget's | - | ||||||||||||||||||||||||||||||||||||
4623 | palette). Then propagate this palette to this widget's children. | - | ||||||||||||||||||||||||||||||||||||
4624 | */ | - | ||||||||||||||||||||||||||||||||||||
4625 | void QWidgetPrivate::resolvePalette() | - | ||||||||||||||||||||||||||||||||||||
4626 | { | - | ||||||||||||||||||||||||||||||||||||
4627 | QPalette naturalPalette = naturalWidgetPalette(inheritedPaletteResolveMask); | - | ||||||||||||||||||||||||||||||||||||
4628 | QPalette resolvedPalette = data.pal.resolve(naturalPalette); | - | ||||||||||||||||||||||||||||||||||||
4629 | setPalette_helper(resolvedPalette); | - | ||||||||||||||||||||||||||||||||||||
4630 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4631 | - | |||||||||||||||||||||||||||||||||||||
4632 | void QWidgetPrivate::setPalette_helper(const QPalette &palette) | - | ||||||||||||||||||||||||||||||||||||
4633 | { | - | ||||||||||||||||||||||||||||||||||||
4634 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4635 | if (data.pal == palette && data.pal.resolve() == palette.resolve())
| 0 | ||||||||||||||||||||||||||||||||||||
4636 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4637 | data.pal = palette; | - | ||||||||||||||||||||||||||||||||||||
4638 | updateSystemBackground(); | - | ||||||||||||||||||||||||||||||||||||
4639 | propagatePaletteChange(); | - | ||||||||||||||||||||||||||||||||||||
4640 | updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
4641 | q->update(); | - | ||||||||||||||||||||||||||||||||||||
4642 | updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
4643 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4644 | - | |||||||||||||||||||||||||||||||||||||
4645 | void QWidgetPrivate::updateSystemBackground() | - | ||||||||||||||||||||||||||||||||||||
4646 | { | - | ||||||||||||||||||||||||||||||||||||
4647 | } | - | ||||||||||||||||||||||||||||||||||||
4648 | - | |||||||||||||||||||||||||||||||||||||
4649 | /*! | - | ||||||||||||||||||||||||||||||||||||
4650 | \property QWidget::font | - | ||||||||||||||||||||||||||||||||||||
4651 | \brief the font currently set for the widget | - | ||||||||||||||||||||||||||||||||||||
4652 | - | |||||||||||||||||||||||||||||||||||||
4653 | This property describes the widget's requested font. The font is used by | - | ||||||||||||||||||||||||||||||||||||
4654 | the widget's style when rendering standard components, and is available as | - | ||||||||||||||||||||||||||||||||||||
4655 | a means to ensure that custom widgets can maintain consistency with the | - | ||||||||||||||||||||||||||||||||||||
4656 | native platform's look and feel. It's common that different platforms, or | - | ||||||||||||||||||||||||||||||||||||
4657 | different styles, define different fonts for an application. | - | ||||||||||||||||||||||||||||||||||||
4658 | - | |||||||||||||||||||||||||||||||||||||
4659 | When you assign a new font to a widget, the properties from this font are | - | ||||||||||||||||||||||||||||||||||||
4660 | combined with the widget's default font to form the widget's final | - | ||||||||||||||||||||||||||||||||||||
4661 | font. You can call fontInfo() to get a copy of the widget's final | - | ||||||||||||||||||||||||||||||||||||
4662 | font. The final font is also used to initialize QPainter's font. | - | ||||||||||||||||||||||||||||||||||||
4663 | - | |||||||||||||||||||||||||||||||||||||
4664 | The default depends on the system environment. QApplication maintains a | - | ||||||||||||||||||||||||||||||||||||
4665 | system/theme font which serves as a default for all widgets. There may | - | ||||||||||||||||||||||||||||||||||||
4666 | also be special font defaults for certain types of widgets. You can also | - | ||||||||||||||||||||||||||||||||||||
4667 | define default fonts for widgets yourself by passing a custom font and the | - | ||||||||||||||||||||||||||||||||||||
4668 | name of a widget to QApplication::setFont(). Finally, the font is matched | - | ||||||||||||||||||||||||||||||||||||
4669 | against Qt's font database to find the best match. | - | ||||||||||||||||||||||||||||||||||||
4670 | - | |||||||||||||||||||||||||||||||||||||
4671 | QWidget propagates explicit font properties from parent to child. If you | - | ||||||||||||||||||||||||||||||||||||
4672 | change a specific property on a font and assign that font to a widget, | - | ||||||||||||||||||||||||||||||||||||
4673 | that property will propagate to all the widget's children, overriding any | - | ||||||||||||||||||||||||||||||||||||
4674 | system defaults for that property. Note that fonts by default don't | - | ||||||||||||||||||||||||||||||||||||
4675 | propagate to windows (see isWindow()) unless the Qt::WA_WindowPropagation | - | ||||||||||||||||||||||||||||||||||||
4676 | attribute is enabled. | - | ||||||||||||||||||||||||||||||||||||
4677 | - | |||||||||||||||||||||||||||||||||||||
4678 | QWidget's font propagation is similar to its palette propagation. | - | ||||||||||||||||||||||||||||||||||||
4679 | - | |||||||||||||||||||||||||||||||||||||
4680 | The current style, which is used to render the content of all standard Qt | - | ||||||||||||||||||||||||||||||||||||
4681 | widgets, is free to choose to use the widget font, or in some cases, to | - | ||||||||||||||||||||||||||||||||||||
4682 | ignore it (partially, or completely). In particular, certain styles like | - | ||||||||||||||||||||||||||||||||||||
4683 | GTK style, Mac style, Windows XP, and Vista style, apply special | - | ||||||||||||||||||||||||||||||||||||
4684 | modifications to the widget font to match the platform's native look and | - | ||||||||||||||||||||||||||||||||||||
4685 | feel. Because of this, assigning properties to a widget's font is not | - | ||||||||||||||||||||||||||||||||||||
4686 | guaranteed to change the appearance of the widget. Instead, you may choose | - | ||||||||||||||||||||||||||||||||||||
4687 | to apply a \l styleSheet. | - | ||||||||||||||||||||||||||||||||||||
4688 | - | |||||||||||||||||||||||||||||||||||||
4689 | \note If \l{Qt Style Sheets} are used on the same widget as setFont(), | - | ||||||||||||||||||||||||||||||||||||
4690 | style sheets will take precedence if the settings conflict. | - | ||||||||||||||||||||||||||||||||||||
4691 | - | |||||||||||||||||||||||||||||||||||||
4692 | \sa fontInfo(), fontMetrics() | - | ||||||||||||||||||||||||||||||||||||
4693 | */ | - | ||||||||||||||||||||||||||||||||||||
4694 | - | |||||||||||||||||||||||||||||||||||||
4695 | void QWidget::setFont(const QFont &font) | - | ||||||||||||||||||||||||||||||||||||
4696 | { | - | ||||||||||||||||||||||||||||||||||||
4697 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4698 | - | |||||||||||||||||||||||||||||||||||||
4699 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
4700 | const QStyleSheetStyle* style; | - | ||||||||||||||||||||||||||||||||||||
4701 | if (d->extra && (style = qobject_cast<const QStyleSheetStyle*>(d->extra->style))) {
| 0 | ||||||||||||||||||||||||||||||||||||
4702 | style->saveWidgetFont(this, font); | - | ||||||||||||||||||||||||||||||||||||
4703 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4704 | #endif | - | ||||||||||||||||||||||||||||||||||||
4705 | - | |||||||||||||||||||||||||||||||||||||
4706 | setAttribute(Qt::WA_SetFont, font.resolve() != 0); | - | ||||||||||||||||||||||||||||||||||||
4707 | - | |||||||||||||||||||||||||||||||||||||
4708 | // Determine which font is inherited from this widget's ancestors and | - | ||||||||||||||||||||||||||||||||||||
4709 | // QApplication::font, resolve this against \a font (attributes from the | - | ||||||||||||||||||||||||||||||||||||
4710 | // inherited font are copied over). Then propagate this font to this | - | ||||||||||||||||||||||||||||||||||||
4711 | // widget's children. | - | ||||||||||||||||||||||||||||||||||||
4712 | QFont naturalFont = d->naturalWidgetFont(d->inheritedFontResolveMask); | - | ||||||||||||||||||||||||||||||||||||
4713 | QFont resolvedFont = font.resolve(naturalFont); | - | ||||||||||||||||||||||||||||||||||||
4714 | d->setFont_helper(resolvedFont); | - | ||||||||||||||||||||||||||||||||||||
4715 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4716 | - | |||||||||||||||||||||||||||||||||||||
4717 | /* | - | ||||||||||||||||||||||||||||||||||||
4718 | \internal | - | ||||||||||||||||||||||||||||||||||||
4719 | - | |||||||||||||||||||||||||||||||||||||
4720 | Returns the font that the widget \a w inherits from its ancestors and | - | ||||||||||||||||||||||||||||||||||||
4721 | QApplication::font. \a inheritedMask is the combination of the widget's | - | ||||||||||||||||||||||||||||||||||||
4722 | ancestors font request masks (i.e., which attributes from the parent | - | ||||||||||||||||||||||||||||||||||||
4723 | widget's font are implicitly imposed on this widget by the user). Note | - | ||||||||||||||||||||||||||||||||||||
4724 | that this font does not take into account the font set on \a w itself. | - | ||||||||||||||||||||||||||||||||||||
4725 | - | |||||||||||||||||||||||||||||||||||||
4726 | ### Stylesheet has a different font propagation mechanism. When a stylesheet | - | ||||||||||||||||||||||||||||||||||||
4727 | is applied, fonts are not propagated anymore | - | ||||||||||||||||||||||||||||||||||||
4728 | */ | - | ||||||||||||||||||||||||||||||||||||
4729 | QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const | - | ||||||||||||||||||||||||||||||||||||
4730 | { | - | ||||||||||||||||||||||||||||||||||||
4731 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
4732 | QFont naturalFont = QApplication::font(q); | - | ||||||||||||||||||||||||||||||||||||
4733 | if (!q->testAttribute(Qt::WA_StyleSheet)
| 0 | ||||||||||||||||||||||||||||||||||||
4734 | && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
| 0 | ||||||||||||||||||||||||||||||||||||
4735 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4736 | || (extra && extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
4737 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4738 | )) { | - | ||||||||||||||||||||||||||||||||||||
4739 | if (QWidget *p = q->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
4740 | if (!p->testAttribute(Qt::WA_StyleSheet)) {
| 0 | ||||||||||||||||||||||||||||||||||||
4741 | if (!naturalFont.isCopyOf(QApplication::font())) {
| 0 | ||||||||||||||||||||||||||||||||||||
4742 | if (inheritedMask != 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
4743 | QFont inheritedFont = p->font(); | - | ||||||||||||||||||||||||||||||||||||
4744 | inheritedFont.resolve(inheritedMask); | - | ||||||||||||||||||||||||||||||||||||
4745 | naturalFont = inheritedFont.resolve(naturalFont); | - | ||||||||||||||||||||||||||||||||||||
4746 | } // else nothing to do (naturalFont = naturalFont) never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4747 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4748 | naturalFont = p->font(); | - | ||||||||||||||||||||||||||||||||||||
4749 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4750 | } | - | ||||||||||||||||||||||||||||||||||||
4751 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4752 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4753 | else if (extra && extra->proxyWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
4754 | if (inheritedMask != 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
4755 | QFont inheritedFont = extra->proxyWidget->font(); | - | ||||||||||||||||||||||||||||||||||||
4756 | inheritedFont.resolve(inheritedMask); | - | ||||||||||||||||||||||||||||||||||||
4757 | naturalFont = inheritedFont.resolve(naturalFont); | - | ||||||||||||||||||||||||||||||||||||
4758 | } // else nothing to do (naturalFont = naturalFont) never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4759 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4760 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4761 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4762 | naturalFont.resolve(0); | - | ||||||||||||||||||||||||||||||||||||
4763 | return naturalFont; never executed: return naturalFont; | 0 | ||||||||||||||||||||||||||||||||||||
4764 | } | - | ||||||||||||||||||||||||||||||||||||
4765 | - | |||||||||||||||||||||||||||||||||||||
4766 | /*! | - | ||||||||||||||||||||||||||||||||||||
4767 | \internal | - | ||||||||||||||||||||||||||||||||||||
4768 | - | |||||||||||||||||||||||||||||||||||||
4769 | Determine which font is implicitly imposed on this widget by its ancestors | - | ||||||||||||||||||||||||||||||||||||
4770 | and QApplication::font, resolve this against its own font (attributes from | - | ||||||||||||||||||||||||||||||||||||
4771 | the implicit font are copied over). Then propagate this font to this | - | ||||||||||||||||||||||||||||||||||||
4772 | widget's children. | - | ||||||||||||||||||||||||||||||||||||
4773 | */ | - | ||||||||||||||||||||||||||||||||||||
4774 | void QWidgetPrivate::resolveFont() | - | ||||||||||||||||||||||||||||||||||||
4775 | { | - | ||||||||||||||||||||||||||||||||||||
4776 | QFont naturalFont = naturalWidgetFont(inheritedFontResolveMask); | - | ||||||||||||||||||||||||||||||||||||
4777 | QFont resolvedFont = data.fnt.resolve(naturalFont); | - | ||||||||||||||||||||||||||||||||||||
4778 | setFont_helper(resolvedFont); | - | ||||||||||||||||||||||||||||||||||||
4779 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4780 | - | |||||||||||||||||||||||||||||||||||||
4781 | /*! | - | ||||||||||||||||||||||||||||||||||||
4782 | \internal | - | ||||||||||||||||||||||||||||||||||||
4783 | - | |||||||||||||||||||||||||||||||||||||
4784 | Assign \a font to this widget, and propagate it to all children, except | - | ||||||||||||||||||||||||||||||||||||
4785 | style sheet widgets (handled differently) and windows that don't enable | - | ||||||||||||||||||||||||||||||||||||
4786 | window propagation. \a implicitMask is the union of all ancestor widgets' | - | ||||||||||||||||||||||||||||||||||||
4787 | font request masks, and determines which attributes from this widget's | - | ||||||||||||||||||||||||||||||||||||
4788 | font should propagate. | - | ||||||||||||||||||||||||||||||||||||
4789 | */ | - | ||||||||||||||||||||||||||||||||||||
4790 | void QWidgetPrivate::updateFont(const QFont &font) | - | ||||||||||||||||||||||||||||||||||||
4791 | { | - | ||||||||||||||||||||||||||||||||||||
4792 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4793 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
4794 | const QStyleSheetStyle* cssStyle; | - | ||||||||||||||||||||||||||||||||||||
4795 | cssStyle = extra ? qobject_cast<const QStyleSheetStyle*>(extra->style) : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
4796 | #endif | - | ||||||||||||||||||||||||||||||||||||
4797 | - | |||||||||||||||||||||||||||||||||||||
4798 | data.fnt = QFont(font, q); | - | ||||||||||||||||||||||||||||||||||||
4799 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
4800 | // make sure the font set on this widget is associated with the correct screen | - | ||||||||||||||||||||||||||||||||||||
4801 | data.fnt.x11SetScreen(xinfo.screen()); | - | ||||||||||||||||||||||||||||||||||||
4802 | #endif | - | ||||||||||||||||||||||||||||||||||||
4803 | // Combine new mask with natural mask and propagate to children. | - | ||||||||||||||||||||||||||||||||||||
4804 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4805 | if (!q->parentWidget() && extra && extra->proxyWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
4806 | QGraphicsProxyWidget *p = extra->proxyWidget; | - | ||||||||||||||||||||||||||||||||||||
4807 | inheritedFontResolveMask = p->d_func()->inheritedFontResolveMask | p->font().resolve(); | - | ||||||||||||||||||||||||||||||||||||
4808 | } else never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4809 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
4810 | if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
| 0 | ||||||||||||||||||||||||||||||||||||
4811 | inheritedFontResolveMask = 0; | - | ||||||||||||||||||||||||||||||||||||
4812 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4813 | uint newMask = data.fnt.resolve() | inheritedFontResolveMask; | - | ||||||||||||||||||||||||||||||||||||
4814 | - | |||||||||||||||||||||||||||||||||||||
4815 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
4816 | QWidget *w = qobject_cast<QWidget*>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
4817 | if (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
4818 | if (0) { dead code: { } | - | ||||||||||||||||||||||||||||||||||||
4819 | #ifndef QT_NO_STYLE_STYLESHEET dead code: { } | - | ||||||||||||||||||||||||||||||||||||
4820 | } else if (w->testAttribute(Qt::WA_StyleSheet)) {
dead code: { } | - | ||||||||||||||||||||||||||||||||||||
4821 | // Style sheets follow a different font propagation scheme. | - | ||||||||||||||||||||||||||||||||||||
4822 | if (cssStyle)
| 0 | ||||||||||||||||||||||||||||||||||||
4823 | cssStyle->updateStyleSheetFont(w); never executed: cssStyle->updateStyleSheetFont(w); | 0 | ||||||||||||||||||||||||||||||||||||
4824 | #endif | - | ||||||||||||||||||||||||||||||||||||
4825 | } else if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
4826 | // Propagate font changes. | - | ||||||||||||||||||||||||||||||||||||
4827 | QWidgetPrivate *wd = w->d_func(); | - | ||||||||||||||||||||||||||||||||||||
4828 | wd->inheritedFontResolveMask = newMask; | - | ||||||||||||||||||||||||||||||||||||
4829 | wd->resolveFont(); | - | ||||||||||||||||||||||||||||||||||||
4830 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4831 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4832 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4833 | - | |||||||||||||||||||||||||||||||||||||
4834 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||||||||||||||
4835 | if (cssStyle) {
| 0 | ||||||||||||||||||||||||||||||||||||
4836 | cssStyle->updateStyleSheetFont(q); | - | ||||||||||||||||||||||||||||||||||||
4837 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4838 | #endif | - | ||||||||||||||||||||||||||||||||||||
4839 | - | |||||||||||||||||||||||||||||||||||||
4840 | QEvent e(QEvent::FontChange); | - | ||||||||||||||||||||||||||||||||||||
4841 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
4842 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4843 | - | |||||||||||||||||||||||||||||||||||||
4844 | void QWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction) | - | ||||||||||||||||||||||||||||||||||||
4845 | { | - | ||||||||||||||||||||||||||||||||||||
4846 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4847 | - | |||||||||||||||||||||||||||||||||||||
4848 | if ( (direction == Qt::RightToLeft) == q->testAttribute(Qt::WA_RightToLeft))
| 0 | ||||||||||||||||||||||||||||||||||||
4849 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4850 | q->setAttribute(Qt::WA_RightToLeft, (direction == Qt::RightToLeft)); | - | ||||||||||||||||||||||||||||||||||||
4851 | if (!children.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
4852 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
4853 | QWidget *w = qobject_cast<QWidget*>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
4854 | if (w && !w->isWindow() && !w->testAttribute(Qt::WA_SetLayoutDirection))
| 0 | ||||||||||||||||||||||||||||||||||||
4855 | w->d_func()->setLayoutDirection_helper(direction); never executed: w->d_func()->setLayoutDirection_helper(direction); | 0 | ||||||||||||||||||||||||||||||||||||
4856 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4857 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4858 | QEvent e(QEvent::LayoutDirectionChange); | - | ||||||||||||||||||||||||||||||||||||
4859 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
4860 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4861 | - | |||||||||||||||||||||||||||||||||||||
4862 | void QWidgetPrivate::resolveLayoutDirection() | - | ||||||||||||||||||||||||||||||||||||
4863 | { | - | ||||||||||||||||||||||||||||||||||||
4864 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
4865 | if (!q->testAttribute(Qt::WA_SetLayoutDirection))
| 0 | ||||||||||||||||||||||||||||||||||||
4866 | setLayoutDirection_helper(q->isWindow() ? QApplication::layoutDirection() : q->parentWidget()->layoutDirection()); never executed: setLayoutDirection_helper(q->isWindow() ? QApplication::layoutDirection() : q->parentWidget()->layoutDirection()); | 0 | ||||||||||||||||||||||||||||||||||||
4867 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4868 | - | |||||||||||||||||||||||||||||||||||||
4869 | /*! | - | ||||||||||||||||||||||||||||||||||||
4870 | \property QWidget::layoutDirection | - | ||||||||||||||||||||||||||||||||||||
4871 | - | |||||||||||||||||||||||||||||||||||||
4872 | \brief the layout direction for this widget | - | ||||||||||||||||||||||||||||||||||||
4873 | - | |||||||||||||||||||||||||||||||||||||
4874 | By default, this property is set to Qt::LeftToRight. | - | ||||||||||||||||||||||||||||||||||||
4875 | - | |||||||||||||||||||||||||||||||||||||
4876 | When the layout direction is set on a widget, it will propagate to | - | ||||||||||||||||||||||||||||||||||||
4877 | the widget's children, but not to a child that is a window and not | - | ||||||||||||||||||||||||||||||||||||
4878 | to a child for which setLayoutDirection() has been explicitly | - | ||||||||||||||||||||||||||||||||||||
4879 | called. Also, child widgets added \e after setLayoutDirection() | - | ||||||||||||||||||||||||||||||||||||
4880 | has been called for the parent do not inherit the parent's layout | - | ||||||||||||||||||||||||||||||||||||
4881 | direction. | - | ||||||||||||||||||||||||||||||||||||
4882 | - | |||||||||||||||||||||||||||||||||||||
4883 | This method no longer affects text layout direction since Qt 4.7. | - | ||||||||||||||||||||||||||||||||||||
4884 | - | |||||||||||||||||||||||||||||||||||||
4885 | \sa QApplication::layoutDirection | - | ||||||||||||||||||||||||||||||||||||
4886 | */ | - | ||||||||||||||||||||||||||||||||||||
4887 | void QWidget::setLayoutDirection(Qt::LayoutDirection direction) | - | ||||||||||||||||||||||||||||||||||||
4888 | { | - | ||||||||||||||||||||||||||||||||||||
4889 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4890 | - | |||||||||||||||||||||||||||||||||||||
4891 | if (direction == Qt::LayoutDirectionAuto) {
| 0 | ||||||||||||||||||||||||||||||||||||
4892 | unsetLayoutDirection(); | - | ||||||||||||||||||||||||||||||||||||
4893 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
4894 | } | - | ||||||||||||||||||||||||||||||||||||
4895 | - | |||||||||||||||||||||||||||||||||||||
4896 | setAttribute(Qt::WA_SetLayoutDirection); | - | ||||||||||||||||||||||||||||||||||||
4897 | d->setLayoutDirection_helper(direction); | - | ||||||||||||||||||||||||||||||||||||
4898 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4899 | - | |||||||||||||||||||||||||||||||||||||
4900 | Qt::LayoutDirection QWidget::layoutDirection() const | - | ||||||||||||||||||||||||||||||||||||
4901 | { | - | ||||||||||||||||||||||||||||||||||||
4902 | return testAttribute(Qt::WA_RightToLeft) ? Qt::RightToLeft : Qt::LeftToRight; never executed: return testAttribute(Qt::WA_RightToLeft) ? Qt::RightToLeft : Qt::LeftToRight;
| 0 | ||||||||||||||||||||||||||||||||||||
4903 | } | - | ||||||||||||||||||||||||||||||||||||
4904 | - | |||||||||||||||||||||||||||||||||||||
4905 | void QWidget::unsetLayoutDirection() | - | ||||||||||||||||||||||||||||||||||||
4906 | { | - | ||||||||||||||||||||||||||||||||||||
4907 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4908 | setAttribute(Qt::WA_SetLayoutDirection, false); | - | ||||||||||||||||||||||||||||||||||||
4909 | d->resolveLayoutDirection(); | - | ||||||||||||||||||||||||||||||||||||
4910 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4911 | - | |||||||||||||||||||||||||||||||||||||
4912 | /*! | - | ||||||||||||||||||||||||||||||||||||
4913 | \fn QFontMetrics QWidget::fontMetrics() const | - | ||||||||||||||||||||||||||||||||||||
4914 | - | |||||||||||||||||||||||||||||||||||||
4915 | Returns the font metrics for the widget's current font. | - | ||||||||||||||||||||||||||||||||||||
4916 | Equivalent to \c QFontMetrics(widget->font()). | - | ||||||||||||||||||||||||||||||||||||
4917 | - | |||||||||||||||||||||||||||||||||||||
4918 | \sa font(), fontInfo(), setFont() | - | ||||||||||||||||||||||||||||||||||||
4919 | */ | - | ||||||||||||||||||||||||||||||||||||
4920 | - | |||||||||||||||||||||||||||||||||||||
4921 | /*! | - | ||||||||||||||||||||||||||||||||||||
4922 | \fn QFontInfo QWidget::fontInfo() const | - | ||||||||||||||||||||||||||||||||||||
4923 | - | |||||||||||||||||||||||||||||||||||||
4924 | Returns the font info for the widget's current font. | - | ||||||||||||||||||||||||||||||||||||
4925 | Equivalent to \c QFontInfo(widget->font()). | - | ||||||||||||||||||||||||||||||||||||
4926 | - | |||||||||||||||||||||||||||||||||||||
4927 | \sa font(), fontMetrics(), setFont() | - | ||||||||||||||||||||||||||||||||||||
4928 | */ | - | ||||||||||||||||||||||||||||||||||||
4929 | - | |||||||||||||||||||||||||||||||||||||
4930 | - | |||||||||||||||||||||||||||||||||||||
4931 | /*! | - | ||||||||||||||||||||||||||||||||||||
4932 | \property QWidget::cursor | - | ||||||||||||||||||||||||||||||||||||
4933 | \brief the cursor shape for this widget | - | ||||||||||||||||||||||||||||||||||||
4934 | - | |||||||||||||||||||||||||||||||||||||
4935 | The mouse cursor will assume this shape when it's over this | - | ||||||||||||||||||||||||||||||||||||
4936 | widget. See the \l{Qt::CursorShape}{list of predefined cursor objects} for a range of useful shapes. | - | ||||||||||||||||||||||||||||||||||||
4937 | - | |||||||||||||||||||||||||||||||||||||
4938 | An editor widget might use an I-beam cursor: | - | ||||||||||||||||||||||||||||||||||||
4939 | \snippet code/src_gui_kernel_qwidget.cpp 6 | - | ||||||||||||||||||||||||||||||||||||
4940 | - | |||||||||||||||||||||||||||||||||||||
4941 | If no cursor has been set, or after a call to unsetCursor(), the | - | ||||||||||||||||||||||||||||||||||||
4942 | parent's cursor is used. | - | ||||||||||||||||||||||||||||||||||||
4943 | - | |||||||||||||||||||||||||||||||||||||
4944 | By default, this property contains a cursor with the Qt::ArrowCursor | - | ||||||||||||||||||||||||||||||||||||
4945 | shape. | - | ||||||||||||||||||||||||||||||||||||
4946 | - | |||||||||||||||||||||||||||||||||||||
4947 | Some underlying window implementations will reset the cursor if it | - | ||||||||||||||||||||||||||||||||||||
4948 | leaves a widget even if the mouse is grabbed. If you want to have | - | ||||||||||||||||||||||||||||||||||||
4949 | a cursor set for all widgets, even when outside the window, consider | - | ||||||||||||||||||||||||||||||||||||
4950 | QApplication::setOverrideCursor(). | - | ||||||||||||||||||||||||||||||||||||
4951 | - | |||||||||||||||||||||||||||||||||||||
4952 | \sa QApplication::setOverrideCursor() | - | ||||||||||||||||||||||||||||||||||||
4953 | */ | - | ||||||||||||||||||||||||||||||||||||
4954 | - | |||||||||||||||||||||||||||||||||||||
4955 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
4956 | QCursor QWidget::cursor() const | - | ||||||||||||||||||||||||||||||||||||
4957 | { | - | ||||||||||||||||||||||||||||||||||||
4958 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
4959 | if (testAttribute(Qt::WA_SetCursor))
| 0 | ||||||||||||||||||||||||||||||||||||
4960 | return (d->extra && d->extra->curs) never executed: return (d->extra && d->extra->curs) ? *d->extra->curs : QCursor(Qt::ArrowCursor);
| 0 | ||||||||||||||||||||||||||||||||||||
4961 | ? *d->extra->curs never executed: return (d->extra && d->extra->curs) ? *d->extra->curs : QCursor(Qt::ArrowCursor); | 0 | ||||||||||||||||||||||||||||||||||||
4962 | : QCursor(Qt::ArrowCursor); never executed: return (d->extra && d->extra->curs) ? *d->extra->curs : QCursor(Qt::ArrowCursor); | 0 | ||||||||||||||||||||||||||||||||||||
4963 | if (isWindow() || !parentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
4964 | return QCursor(Qt::ArrowCursor); never executed: return QCursor(Qt::ArrowCursor); | 0 | ||||||||||||||||||||||||||||||||||||
4965 | return parentWidget()->cursor(); never executed: return parentWidget()->cursor(); | 0 | ||||||||||||||||||||||||||||||||||||
4966 | } | - | ||||||||||||||||||||||||||||||||||||
4967 | - | |||||||||||||||||||||||||||||||||||||
4968 | void QWidget::setCursor(const QCursor &cursor) | - | ||||||||||||||||||||||||||||||||||||
4969 | { | - | ||||||||||||||||||||||||||||||||||||
4970 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4971 | // On Mac we must set the cursor even if it is the ArrowCursor. | - | ||||||||||||||||||||||||||||||||||||
4972 | #if !defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
4973 | if (cursor.shape() != Qt::ArrowCursor
| 0 | ||||||||||||||||||||||||||||||||||||
4974 | || (d->extra && d->extra->curs))
| 0 | ||||||||||||||||||||||||||||||||||||
4975 | #endif | - | ||||||||||||||||||||||||||||||||||||
4976 | { | - | ||||||||||||||||||||||||||||||||||||
4977 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
4978 | QCursor *newCursor = new QCursor(cursor); | - | ||||||||||||||||||||||||||||||||||||
4979 | delete d->extra->curs; | - | ||||||||||||||||||||||||||||||||||||
4980 | d->extra->curs = newCursor; | - | ||||||||||||||||||||||||||||||||||||
4981 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4982 | setAttribute(Qt::WA_SetCursor); | - | ||||||||||||||||||||||||||||||||||||
4983 | d->setCursor_sys(cursor); | - | ||||||||||||||||||||||||||||||||||||
4984 | - | |||||||||||||||||||||||||||||||||||||
4985 | QEvent event(QEvent::CursorChange); | - | ||||||||||||||||||||||||||||||||||||
4986 | QApplication::sendEvent(this, &event); | - | ||||||||||||||||||||||||||||||||||||
4987 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4988 | - | |||||||||||||||||||||||||||||||||||||
4989 | void QWidgetPrivate::setCursor_sys(const QCursor &cursor) | - | ||||||||||||||||||||||||||||||||||||
4990 | { | - | ||||||||||||||||||||||||||||||||||||
4991 | Q_UNUSED(cursor); | - | ||||||||||||||||||||||||||||||||||||
4992 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4993 | qt_qpa_set_cursor(q, false); | - | ||||||||||||||||||||||||||||||||||||
4994 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
4995 | - | |||||||||||||||||||||||||||||||||||||
4996 | void QWidget::unsetCursor() | - | ||||||||||||||||||||||||||||||||||||
4997 | { | - | ||||||||||||||||||||||||||||||||||||
4998 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
4999 | if (d->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
5000 | delete d->extra->curs; | - | ||||||||||||||||||||||||||||||||||||
5001 | d->extra->curs = 0; | - | ||||||||||||||||||||||||||||||||||||
5002 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5003 | if (!isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
5004 | setAttribute(Qt::WA_SetCursor, false); never executed: setAttribute(Qt::WA_SetCursor, false); | 0 | ||||||||||||||||||||||||||||||||||||
5005 | d->unsetCursor_sys(); | - | ||||||||||||||||||||||||||||||||||||
5006 | - | |||||||||||||||||||||||||||||||||||||
5007 | QEvent event(QEvent::CursorChange); | - | ||||||||||||||||||||||||||||||||||||
5008 | QApplication::sendEvent(this, &event); | - | ||||||||||||||||||||||||||||||||||||
5009 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5010 | - | |||||||||||||||||||||||||||||||||||||
5011 | void QWidgetPrivate::unsetCursor_sys() | - | ||||||||||||||||||||||||||||||||||||
5012 | { | - | ||||||||||||||||||||||||||||||||||||
5013 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5014 | qt_qpa_set_cursor(q, false); | - | ||||||||||||||||||||||||||||||||||||
5015 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5016 | - | |||||||||||||||||||||||||||||||||||||
5017 | static inline void applyCursor(QWidget *w, QCursor c) | - | ||||||||||||||||||||||||||||||||||||
5018 | { | - | ||||||||||||||||||||||||||||||||||||
5019 | if (QWindow *window = w->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
5020 | window->setCursor(c); never executed: window->setCursor(c); | 0 | ||||||||||||||||||||||||||||||||||||
5021 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5022 | - | |||||||||||||||||||||||||||||||||||||
5023 | static inline void unsetCursor(QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
5024 | { | - | ||||||||||||||||||||||||||||||||||||
5025 | if (QWindow *window = w->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
5026 | window->unsetCursor(); never executed: window->unsetCursor(); | 0 | ||||||||||||||||||||||||||||||||||||
5027 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5028 | - | |||||||||||||||||||||||||||||||||||||
5029 | void qt_qpa_set_cursor(QWidget *w, bool force) | - | ||||||||||||||||||||||||||||||||||||
5030 | { | - | ||||||||||||||||||||||||||||||||||||
5031 | if (!w->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
5032 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5033 | - | |||||||||||||||||||||||||||||||||||||
5034 | static QPointer<QWidget> lastUnderMouse = 0; | - | ||||||||||||||||||||||||||||||||||||
5035 | if (force) {
| 0 | ||||||||||||||||||||||||||||||||||||
5036 | lastUnderMouse = w; | - | ||||||||||||||||||||||||||||||||||||
5037 | } else if (lastUnderMouse) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
5038 | const WId lastWinId = lastUnderMouse->effectiveWinId(); | - | ||||||||||||||||||||||||||||||||||||
5039 | const WId winId = w->effectiveWinId(); | - | ||||||||||||||||||||||||||||||||||||
5040 | if (lastWinId && lastWinId == winId)
| 0 | ||||||||||||||||||||||||||||||||||||
5041 | w = lastUnderMouse; never executed: w = lastUnderMouse; | 0 | ||||||||||||||||||||||||||||||||||||
5042 | } else if (!w->internalWinId()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
5043 | return; // The mouse is not under this widget, and it's not native, so don't change it. never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5044 | } | - | ||||||||||||||||||||||||||||||||||||
5045 | - | |||||||||||||||||||||||||||||||||||||
5046 | while (!w->internalWinId() && w->parentWidget() && !w->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
5047 | && !w->testAttribute(Qt::WA_SetCursor))
| 0 | ||||||||||||||||||||||||||||||||||||
5048 | w = w->parentWidget(); never executed: w = w->parentWidget(); | 0 | ||||||||||||||||||||||||||||||||||||
5049 | - | |||||||||||||||||||||||||||||||||||||
5050 | QWidget *nativeParent = w; | - | ||||||||||||||||||||||||||||||||||||
5051 | if (!w->internalWinId())
| 0 | ||||||||||||||||||||||||||||||||||||
5052 | nativeParent = w->nativeParentWidget(); never executed: nativeParent = w->nativeParentWidget(); | 0 | ||||||||||||||||||||||||||||||||||||
5053 | if (!nativeParent || !nativeParent->internalWinId())
| 0 | ||||||||||||||||||||||||||||||||||||
5054 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5055 | - | |||||||||||||||||||||||||||||||||||||
5056 | if (w->isWindow() || w->testAttribute(Qt::WA_SetCursor)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5057 | if (w->isEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
5058 | applyCursor(nativeParent, w->cursor()); never executed: applyCursor(nativeParent, w->cursor()); | 0 | ||||||||||||||||||||||||||||||||||||
5059 | else | - | ||||||||||||||||||||||||||||||||||||
5060 | // Enforce the windows behavior of clearing the cursor on | - | ||||||||||||||||||||||||||||||||||||
5061 | // disabled widgets. | - | ||||||||||||||||||||||||||||||||||||
5062 | unsetCursor(nativeParent); never executed: unsetCursor(nativeParent); | 0 | ||||||||||||||||||||||||||||||||||||
5063 | } else { | - | ||||||||||||||||||||||||||||||||||||
5064 | unsetCursor(nativeParent); | - | ||||||||||||||||||||||||||||||||||||
5065 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5066 | } | - | ||||||||||||||||||||||||||||||||||||
5067 | #endif | - | ||||||||||||||||||||||||||||||||||||
5068 | - | |||||||||||||||||||||||||||||||||||||
5069 | /*! | - | ||||||||||||||||||||||||||||||||||||
5070 | \enum QWidget::RenderFlag | - | ||||||||||||||||||||||||||||||||||||
5071 | - | |||||||||||||||||||||||||||||||||||||
5072 | This enum describes how to render the widget when calling QWidget::render(). | - | ||||||||||||||||||||||||||||||||||||
5073 | - | |||||||||||||||||||||||||||||||||||||
5074 | \value DrawWindowBackground If you enable this option, the widget's background | - | ||||||||||||||||||||||||||||||||||||
5075 | is rendered into the target even if autoFillBackground is not set. By default, | - | ||||||||||||||||||||||||||||||||||||
5076 | this option is enabled. | - | ||||||||||||||||||||||||||||||||||||
5077 | - | |||||||||||||||||||||||||||||||||||||
5078 | \value DrawChildren If you enable this option, the widget's children | - | ||||||||||||||||||||||||||||||||||||
5079 | are rendered recursively into the target. By default, this option is enabled. | - | ||||||||||||||||||||||||||||||||||||
5080 | - | |||||||||||||||||||||||||||||||||||||
5081 | \value IgnoreMask If you enable this option, the widget's QWidget::mask() | - | ||||||||||||||||||||||||||||||||||||
5082 | is ignored when rendering into the target. By default, this option is disabled. | - | ||||||||||||||||||||||||||||||||||||
5083 | - | |||||||||||||||||||||||||||||||||||||
5084 | \since 4.3 | - | ||||||||||||||||||||||||||||||||||||
5085 | */ | - | ||||||||||||||||||||||||||||||||||||
5086 | - | |||||||||||||||||||||||||||||||||||||
5087 | /*! | - | ||||||||||||||||||||||||||||||||||||
5088 | \since 4.3 | - | ||||||||||||||||||||||||||||||||||||
5089 | - | |||||||||||||||||||||||||||||||||||||
5090 | Renders the \a sourceRegion of this widget into the \a target | - | ||||||||||||||||||||||||||||||||||||
5091 | using \a renderFlags to determine how to render. Rendering | - | ||||||||||||||||||||||||||||||||||||
5092 | starts at \a targetOffset in the \a target. For example: | - | ||||||||||||||||||||||||||||||||||||
5093 | - | |||||||||||||||||||||||||||||||||||||
5094 | \snippet code/src_gui_kernel_qwidget.cpp 7 | - | ||||||||||||||||||||||||||||||||||||
5095 | - | |||||||||||||||||||||||||||||||||||||
5096 | If \a sourceRegion is a null region, this function will use QWidget::rect() as | - | ||||||||||||||||||||||||||||||||||||
5097 | the region, i.e. the entire widget. | - | ||||||||||||||||||||||||||||||||||||
5098 | - | |||||||||||||||||||||||||||||||||||||
5099 | Ensure that you call QPainter::end() for the \a target device's | - | ||||||||||||||||||||||||||||||||||||
5100 | active painter (if any) before rendering. For example: | - | ||||||||||||||||||||||||||||||||||||
5101 | - | |||||||||||||||||||||||||||||||||||||
5102 | \snippet code/src_gui_kernel_qwidget.cpp 8 | - | ||||||||||||||||||||||||||||||||||||
5103 | - | |||||||||||||||||||||||||||||||||||||
5104 | \note To obtain the contents of an OpenGL widget, use QGLWidget::grabFrameBuffer() | - | ||||||||||||||||||||||||||||||||||||
5105 | or QGLWidget::renderPixmap() instead. | - | ||||||||||||||||||||||||||||||||||||
5106 | */ | - | ||||||||||||||||||||||||||||||||||||
5107 | void QWidget::render(QPaintDevice *target, const QPoint &targetOffset, | - | ||||||||||||||||||||||||||||||||||||
5108 | const QRegion &sourceRegion, RenderFlags renderFlags) | - | ||||||||||||||||||||||||||||||||||||
5109 | { | - | ||||||||||||||||||||||||||||||||||||
5110 | QPainter p(target); | - | ||||||||||||||||||||||||||||||||||||
5111 | render(&p, targetOffset, sourceRegion, renderFlags); | - | ||||||||||||||||||||||||||||||||||||
5112 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5113 | - | |||||||||||||||||||||||||||||||||||||
5114 | /*! | - | ||||||||||||||||||||||||||||||||||||
5115 | \overload | - | ||||||||||||||||||||||||||||||||||||
5116 | - | |||||||||||||||||||||||||||||||||||||
5117 | Renders the widget into the \a painter's QPainter::device(). | - | ||||||||||||||||||||||||||||||||||||
5118 | - | |||||||||||||||||||||||||||||||||||||
5119 | Transformations and settings applied to the \a painter will be used | - | ||||||||||||||||||||||||||||||||||||
5120 | when rendering. | - | ||||||||||||||||||||||||||||||||||||
5121 | - | |||||||||||||||||||||||||||||||||||||
5122 | \note The \a painter must be active. On \macos the widget will be | - | ||||||||||||||||||||||||||||||||||||
5123 | rendered into a QPixmap and then drawn by the \a painter. | - | ||||||||||||||||||||||||||||||||||||
5124 | - | |||||||||||||||||||||||||||||||||||||
5125 | \sa QPainter::device() | - | ||||||||||||||||||||||||||||||||||||
5126 | */ | - | ||||||||||||||||||||||||||||||||||||
5127 | void QWidget::render(QPainter *painter, const QPoint &targetOffset, | - | ||||||||||||||||||||||||||||||||||||
5128 | const QRegion &sourceRegion, RenderFlags renderFlags) | - | ||||||||||||||||||||||||||||||||||||
5129 | { | - | ||||||||||||||||||||||||||||||||||||
5130 | if (!painter) {
| 0 | ||||||||||||||||||||||||||||||||||||
5131 | qWarning("QWidget::render: Null pointer to painter"); | - | ||||||||||||||||||||||||||||||||||||
5132 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5133 | } | - | ||||||||||||||||||||||||||||||||||||
5134 | - | |||||||||||||||||||||||||||||||||||||
5135 | if (!painter->isActive()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5136 | qWarning("QWidget::render: Cannot render with an inactive painter"); | - | ||||||||||||||||||||||||||||||||||||
5137 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5138 | } | - | ||||||||||||||||||||||||||||||||||||
5139 | - | |||||||||||||||||||||||||||||||||||||
5140 | const qreal opacity = painter->opacity(); | - | ||||||||||||||||||||||||||||||||||||
5141 | if (qFuzzyIsNull(opacity))
| 0 | ||||||||||||||||||||||||||||||||||||
5142 | return; // Fully transparent. never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5143 | - | |||||||||||||||||||||||||||||||||||||
5144 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5145 | const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter;
| 0 | ||||||||||||||||||||||||||||||||||||
5146 | const QRegion toBePainted = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags)
| 0 | ||||||||||||||||||||||||||||||||||||
5147 | : sourceRegion; | - | ||||||||||||||||||||||||||||||||||||
5148 | if (toBePainted.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
5149 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5150 | - | |||||||||||||||||||||||||||||||||||||
5151 | if (!d->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
5152 | d->createExtra(); never executed: d->createExtra(); | 0 | ||||||||||||||||||||||||||||||||||||
5153 | d->extra->inRenderWithPainter = true; | - | ||||||||||||||||||||||||||||||||||||
5154 | - | |||||||||||||||||||||||||||||||||||||
5155 | QPaintEngine *engine = painter->paintEngine(); | - | ||||||||||||||||||||||||||||||||||||
5156 | Q_ASSERT(engine); | - | ||||||||||||||||||||||||||||||||||||
5157 | QPaintEnginePrivate *enginePriv = engine->d_func(); | - | ||||||||||||||||||||||||||||||||||||
5158 | Q_ASSERT(enginePriv); | - | ||||||||||||||||||||||||||||||||||||
5159 | QPaintDevice *target = engine->paintDevice(); | - | ||||||||||||||||||||||||||||||||||||
5160 | Q_ASSERT(target); | - | ||||||||||||||||||||||||||||||||||||
5161 | - | |||||||||||||||||||||||||||||||||||||
5162 | // Render via a pixmap when dealing with non-opaque painters or printers. | - | ||||||||||||||||||||||||||||||||||||
5163 | if (!inRenderWithPainter && (opacity < 1.0 || (target->devType() == QInternal::Printer))) {
| 0 | ||||||||||||||||||||||||||||||||||||
5164 | d->render_helper(painter, targetOffset, toBePainted, renderFlags); | - | ||||||||||||||||||||||||||||||||||||
5165 | d->extra->inRenderWithPainter = inRenderWithPainter; | - | ||||||||||||||||||||||||||||||||||||
5166 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5167 | } | - | ||||||||||||||||||||||||||||||||||||
5168 | - | |||||||||||||||||||||||||||||||||||||
5169 | // Set new shared painter. | - | ||||||||||||||||||||||||||||||||||||
5170 | QPainter *oldPainter = d->sharedPainter(); | - | ||||||||||||||||||||||||||||||||||||
5171 | d->setSharedPainter(painter); | - | ||||||||||||||||||||||||||||||||||||
5172 | - | |||||||||||||||||||||||||||||||||||||
5173 | // Save current system clip, viewport and transform, | - | ||||||||||||||||||||||||||||||||||||
5174 | const QTransform oldTransform = enginePriv->systemTransform; | - | ||||||||||||||||||||||||||||||||||||
5175 | const QRegion oldSystemClip = enginePriv->systemClip; | - | ||||||||||||||||||||||||||||||||||||
5176 | const QRegion oldSystemViewport = enginePriv->systemViewport; | - | ||||||||||||||||||||||||||||||||||||
5177 | - | |||||||||||||||||||||||||||||||||||||
5178 | // This ensures that all painting triggered by render() is clipped to the current engine clip. | - | ||||||||||||||||||||||||||||||||||||
5179 | if (painter->hasClipping()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5180 | const QRegion painterClip = painter->deviceTransform().map(painter->clipRegion()); | - | ||||||||||||||||||||||||||||||||||||
5181 | enginePriv->setSystemViewport(oldSystemClip.isEmpty() ? painterClip : oldSystemClip & painterClip); | - | ||||||||||||||||||||||||||||||||||||
5182 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5183 | enginePriv->setSystemViewport(oldSystemClip); | - | ||||||||||||||||||||||||||||||||||||
5184 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5185 | - | |||||||||||||||||||||||||||||||||||||
5186 | d->render(target, targetOffset, toBePainted, renderFlags); | - | ||||||||||||||||||||||||||||||||||||
5187 | - | |||||||||||||||||||||||||||||||||||||
5188 | // Restore system clip, viewport and transform. | - | ||||||||||||||||||||||||||||||||||||
5189 | enginePriv->systemClip = oldSystemClip; | - | ||||||||||||||||||||||||||||||||||||
5190 | enginePriv->setSystemViewport(oldSystemViewport); | - | ||||||||||||||||||||||||||||||||||||
5191 | enginePriv->setSystemTransform(oldTransform); | - | ||||||||||||||||||||||||||||||||||||
5192 | - | |||||||||||||||||||||||||||||||||||||
5193 | // Restore shared painter. | - | ||||||||||||||||||||||||||||||||||||
5194 | d->setSharedPainter(oldPainter); | - | ||||||||||||||||||||||||||||||||||||
5195 | - | |||||||||||||||||||||||||||||||||||||
5196 | d->extra->inRenderWithPainter = inRenderWithPainter; | - | ||||||||||||||||||||||||||||||||||||
5197 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5198 | - | |||||||||||||||||||||||||||||||||||||
5199 | static void sendResizeEvents(QWidget *target) | - | ||||||||||||||||||||||||||||||||||||
5200 | { | - | ||||||||||||||||||||||||||||||||||||
5201 | QResizeEvent e(target->size(), QSize()); | - | ||||||||||||||||||||||||||||||||||||
5202 | QApplication::sendEvent(target, &e); | - | ||||||||||||||||||||||||||||||||||||
5203 | - | |||||||||||||||||||||||||||||||||||||
5204 | const QObjectList children = target->children(); | - | ||||||||||||||||||||||||||||||||||||
5205 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
5206 | if (!children.at(i)->isWidgetType())
| 0 | ||||||||||||||||||||||||||||||||||||
5207 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
5208 | QWidget *child = static_cast<QWidget*>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
5209 | if (!child->isWindow() && child->testAttribute(Qt::WA_PendingResizeEvent))
| 0 | ||||||||||||||||||||||||||||||||||||
5210 | sendResizeEvents(child); never executed: sendResizeEvents(child); | 0 | ||||||||||||||||||||||||||||||||||||
5211 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5212 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5213 | - | |||||||||||||||||||||||||||||||||||||
5214 | /*! | - | ||||||||||||||||||||||||||||||||||||
5215 | \since 5.0 | - | ||||||||||||||||||||||||||||||||||||
5216 | - | |||||||||||||||||||||||||||||||||||||
5217 | Renders the widget into a pixmap restricted by the | - | ||||||||||||||||||||||||||||||||||||
5218 | given \a rectangle. If the widget has any children, then | - | ||||||||||||||||||||||||||||||||||||
5219 | they are also painted in the appropriate positions. | - | ||||||||||||||||||||||||||||||||||||
5220 | - | |||||||||||||||||||||||||||||||||||||
5221 | If a rectangle with an invalid size is specified (the default), | - | ||||||||||||||||||||||||||||||||||||
5222 | the entire widget is painted. | - | ||||||||||||||||||||||||||||||||||||
5223 | - | |||||||||||||||||||||||||||||||||||||
5224 | \sa render(), QPixmap | - | ||||||||||||||||||||||||||||||||||||
5225 | */ | - | ||||||||||||||||||||||||||||||||||||
5226 | - | |||||||||||||||||||||||||||||||||||||
5227 | /* INVOKABLE since used by QPixmap::grabWidget(). */ | - | ||||||||||||||||||||||||||||||||||||
5228 | QPixmap QWidget::grab(const QRect &rectangle) | - | ||||||||||||||||||||||||||||||||||||
5229 | { | - | ||||||||||||||||||||||||||||||||||||
5230 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5231 | if (testAttribute(Qt::WA_PendingResizeEvent) || !testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
5232 | sendResizeEvents(this); never executed: sendResizeEvents(this); | 0 | ||||||||||||||||||||||||||||||||||||
5233 | - | |||||||||||||||||||||||||||||||||||||
5234 | const QWidget::RenderFlags renderFlags = QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask; | - | ||||||||||||||||||||||||||||||||||||
5235 | - | |||||||||||||||||||||||||||||||||||||
5236 | const bool oldDirtyOpaqueChildren = d->dirtyOpaqueChildren; | - | ||||||||||||||||||||||||||||||||||||
5237 | QRect r(rectangle); | - | ||||||||||||||||||||||||||||||||||||
5238 | if (r.width() < 0 || r.height() < 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
5239 | // For grabbing widgets that haven't been shown yet, | - | ||||||||||||||||||||||||||||||||||||
5240 | // we trigger the layouting mechanism to determine the widget's size. | - | ||||||||||||||||||||||||||||||||||||
5241 | r = d->prepareToRender(QRegion(), renderFlags).boundingRect(); | - | ||||||||||||||||||||||||||||||||||||
5242 | r.setTopLeft(rectangle.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
5243 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5244 | - | |||||||||||||||||||||||||||||||||||||
5245 | if (!r.intersects(rect()))
| 0 | ||||||||||||||||||||||||||||||||||||
5246 | return QPixmap(); never executed: return QPixmap(); | 0 | ||||||||||||||||||||||||||||||||||||
5247 | - | |||||||||||||||||||||||||||||||||||||
5248 | const qreal dpr = devicePixelRatioF(); | - | ||||||||||||||||||||||||||||||||||||
5249 | QPixmap res((QSizeF(r.size()) * dpr).toSize()); | - | ||||||||||||||||||||||||||||||||||||
5250 | res.setDevicePixelRatio(dpr); | - | ||||||||||||||||||||||||||||||||||||
5251 | if (!d->isOpaque)
| 0 | ||||||||||||||||||||||||||||||||||||
5252 | res.fill(Qt::transparent); never executed: res.fill(Qt::transparent); | 0 | ||||||||||||||||||||||||||||||||||||
5253 | d->render(&res, QPoint(), QRegion(r), renderFlags); | - | ||||||||||||||||||||||||||||||||||||
5254 | - | |||||||||||||||||||||||||||||||||||||
5255 | d->dirtyOpaqueChildren = oldDirtyOpaqueChildren; | - | ||||||||||||||||||||||||||||||||||||
5256 | return res; never executed: return res; | 0 | ||||||||||||||||||||||||||||||||||||
5257 | } | - | ||||||||||||||||||||||||||||||||||||
5258 | - | |||||||||||||||||||||||||||||||||||||
5259 | /*! | - | ||||||||||||||||||||||||||||||||||||
5260 | \brief The graphicsEffect function returns a pointer to the | - | ||||||||||||||||||||||||||||||||||||
5261 | widget's graphics effect. | - | ||||||||||||||||||||||||||||||||||||
5262 | - | |||||||||||||||||||||||||||||||||||||
5263 | If the widget has no graphics effect, 0 is returned. | - | ||||||||||||||||||||||||||||||||||||
5264 | - | |||||||||||||||||||||||||||||||||||||
5265 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
5266 | - | |||||||||||||||||||||||||||||||||||||
5267 | \sa setGraphicsEffect() | - | ||||||||||||||||||||||||||||||||||||
5268 | */ | - | ||||||||||||||||||||||||||||||||||||
5269 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5270 | QGraphicsEffect *QWidget::graphicsEffect() const | - | ||||||||||||||||||||||||||||||||||||
5271 | { | - | ||||||||||||||||||||||||||||||||||||
5272 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
5273 | return d->graphicsEffect; never executed: return d->graphicsEffect; | 0 | ||||||||||||||||||||||||||||||||||||
5274 | } | - | ||||||||||||||||||||||||||||||||||||
5275 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5276 | - | |||||||||||||||||||||||||||||||||||||
5277 | /*! | - | ||||||||||||||||||||||||||||||||||||
5278 | - | |||||||||||||||||||||||||||||||||||||
5279 | \brief The setGraphicsEffect function is for setting the widget's graphics effect. | - | ||||||||||||||||||||||||||||||||||||
5280 | - | |||||||||||||||||||||||||||||||||||||
5281 | Sets \a effect as the widget's effect. If there already is an effect installed | - | ||||||||||||||||||||||||||||||||||||
5282 | on this widget, QWidget will delete the existing effect before installing | - | ||||||||||||||||||||||||||||||||||||
5283 | the new \a effect. | - | ||||||||||||||||||||||||||||||||||||
5284 | - | |||||||||||||||||||||||||||||||||||||
5285 | If \a effect is the installed effect on a different widget, setGraphicsEffect() will remove | - | ||||||||||||||||||||||||||||||||||||
5286 | the effect from the widget and install it on this widget. | - | ||||||||||||||||||||||||||||||||||||
5287 | - | |||||||||||||||||||||||||||||||||||||
5288 | QWidget takes ownership of \a effect. | - | ||||||||||||||||||||||||||||||||||||
5289 | - | |||||||||||||||||||||||||||||||||||||
5290 | \note This function will apply the effect on itself and all its children. | - | ||||||||||||||||||||||||||||||||||||
5291 | - | |||||||||||||||||||||||||||||||||||||
5292 | \note Graphics effects are not supported for OpenGL-based widgets, such as QGLWidget, | - | ||||||||||||||||||||||||||||||||||||
5293 | QOpenGLWidget and QQuickWidget. | - | ||||||||||||||||||||||||||||||||||||
5294 | - | |||||||||||||||||||||||||||||||||||||
5295 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
5296 | - | |||||||||||||||||||||||||||||||||||||
5297 | \sa graphicsEffect() | - | ||||||||||||||||||||||||||||||||||||
5298 | */ | - | ||||||||||||||||||||||||||||||||||||
5299 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5300 | void QWidget::setGraphicsEffect(QGraphicsEffect *effect) | - | ||||||||||||||||||||||||||||||||||||
5301 | { | - | ||||||||||||||||||||||||||||||||||||
5302 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5303 | if (d->graphicsEffect == effect)
| 0 | ||||||||||||||||||||||||||||||||||||
5304 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5305 | - | |||||||||||||||||||||||||||||||||||||
5306 | if (d->graphicsEffect) {
| 0 | ||||||||||||||||||||||||||||||||||||
5307 | d->invalidateBuffer(rect()); | - | ||||||||||||||||||||||||||||||||||||
5308 | delete d->graphicsEffect; | - | ||||||||||||||||||||||||||||||||||||
5309 | d->graphicsEffect = 0; | - | ||||||||||||||||||||||||||||||||||||
5310 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5311 | - | |||||||||||||||||||||||||||||||||||||
5312 | if (effect) {
| 0 | ||||||||||||||||||||||||||||||||||||
5313 | // Set new effect. | - | ||||||||||||||||||||||||||||||||||||
5314 | QGraphicsEffectSourcePrivate *sourced = new QWidgetEffectSourcePrivate(this); | - | ||||||||||||||||||||||||||||||||||||
5315 | QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced); | - | ||||||||||||||||||||||||||||||||||||
5316 | d->graphicsEffect = effect; | - | ||||||||||||||||||||||||||||||||||||
5317 | effect->d_func()->setGraphicsEffectSource(source); | - | ||||||||||||||||||||||||||||||||||||
5318 | update(); | - | ||||||||||||||||||||||||||||||||||||
5319 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5320 | - | |||||||||||||||||||||||||||||||||||||
5321 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
5322 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5323 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5324 | - | |||||||||||||||||||||||||||||||||||||
5325 | bool QWidgetPrivate::isAboutToShow() const | - | ||||||||||||||||||||||||||||||||||||
5326 | { | - | ||||||||||||||||||||||||||||||||||||
5327 | if (data.in_show)
| 0 | ||||||||||||||||||||||||||||||||||||
5328 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
5329 | - | |||||||||||||||||||||||||||||||||||||
5330 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
5331 | if (q->isHidden())
| 0 | ||||||||||||||||||||||||||||||||||||
5332 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
5333 | - | |||||||||||||||||||||||||||||||||||||
5334 | // The widget will be shown if any of its ancestors are about to show. | - | ||||||||||||||||||||||||||||||||||||
5335 | QWidget *parent = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
5336 | return parent ? parent->d_func()->isAboutToShow() : false; never executed: return parent ? parent->d_func()->isAboutToShow() : false;
| 0 | ||||||||||||||||||||||||||||||||||||
5337 | } | - | ||||||||||||||||||||||||||||||||||||
5338 | - | |||||||||||||||||||||||||||||||||||||
5339 | QRegion QWidgetPrivate::prepareToRender(const QRegion ®ion, QWidget::RenderFlags renderFlags) | - | ||||||||||||||||||||||||||||||||||||
5340 | { | - | ||||||||||||||||||||||||||||||||||||
5341 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5342 | const bool isVisible = q->isVisible(); | - | ||||||||||||||||||||||||||||||||||||
5343 | - | |||||||||||||||||||||||||||||||||||||
5344 | // Make sure the widget is laid out correctly. | - | ||||||||||||||||||||||||||||||||||||
5345 | if (!isVisible && !isAboutToShow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5346 | QWidget *topLevel = q->window(); | - | ||||||||||||||||||||||||||||||||||||
5347 | (void)topLevel->d_func()->topData(); // Make sure we at least have top-data. | - | ||||||||||||||||||||||||||||||||||||
5348 | topLevel->ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
5349 | - | |||||||||||||||||||||||||||||||||||||
5350 | // Invalidate the layout of hidden ancestors (incl. myself) and pretend | - | ||||||||||||||||||||||||||||||||||||
5351 | // they're not explicitly hidden. | - | ||||||||||||||||||||||||||||||||||||
5352 | QWidget *widget = q; | - | ||||||||||||||||||||||||||||||||||||
5353 | QWidgetList hiddenWidgets; | - | ||||||||||||||||||||||||||||||||||||
5354 | while (widget) {
| 0 | ||||||||||||||||||||||||||||||||||||
5355 | if (widget->isHidden()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5356 | widget->setAttribute(Qt::WA_WState_Hidden, false); | - | ||||||||||||||||||||||||||||||||||||
5357 | hiddenWidgets.append(widget); | - | ||||||||||||||||||||||||||||||||||||
5358 | if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
5359 | widget->d_func()->updateGeometry_helper(true); never executed: widget->d_func()->updateGeometry_helper(true); | 0 | ||||||||||||||||||||||||||||||||||||
5360 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5361 | widget = widget->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
5362 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5363 | - | |||||||||||||||||||||||||||||||||||||
5364 | // Activate top-level layout. | - | ||||||||||||||||||||||||||||||||||||
5365 | if (topLevel->d_func()->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
5366 | topLevel->d_func()->layout->activate(); never executed: topLevel->d_func()->layout->activate(); | 0 | ||||||||||||||||||||||||||||||||||||
5367 | - | |||||||||||||||||||||||||||||||||||||
5368 | // Adjust size if necessary. | - | ||||||||||||||||||||||||||||||||||||
5369 | QTLWExtra *topLevelExtra = topLevel->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
5370 | if (topLevelExtra && !topLevelExtra->sizeAdjusted
| 0 | ||||||||||||||||||||||||||||||||||||
5371 | && !topLevel->testAttribute(Qt::WA_Resized)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5372 | topLevel->adjustSize(); | - | ||||||||||||||||||||||||||||||||||||
5373 | topLevel->setAttribute(Qt::WA_Resized, false); | - | ||||||||||||||||||||||||||||||||||||
5374 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5375 | - | |||||||||||||||||||||||||||||||||||||
5376 | // Activate child layouts. | - | ||||||||||||||||||||||||||||||||||||
5377 | topLevel->d_func()->activateChildLayoutsRecursively(); | - | ||||||||||||||||||||||||||||||||||||
5378 | - | |||||||||||||||||||||||||||||||||||||
5379 | // We're not cheating with WA_WState_Hidden anymore. | - | ||||||||||||||||||||||||||||||||||||
5380 | for (int i = 0; i < hiddenWidgets.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
5381 | QWidget *widget = hiddenWidgets.at(i); | - | ||||||||||||||||||||||||||||||||||||
5382 | widget->setAttribute(Qt::WA_WState_Hidden); | - | ||||||||||||||||||||||||||||||||||||
5383 | if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
5384 | widget->parentWidget()->d_func()->layout->invalidate(); never executed: widget->parentWidget()->d_func()->layout->invalidate(); | 0 | ||||||||||||||||||||||||||||||||||||
5385 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5386 | } else if (isVisible) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
5387 | q->window()->d_func()->sendPendingMoveAndResizeEvents(true, true); | - | ||||||||||||||||||||||||||||||||||||
5388 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5389 | - | |||||||||||||||||||||||||||||||||||||
5390 | // Calculate the region to be painted. | - | ||||||||||||||||||||||||||||||||||||
5391 | QRegion toBePainted = !region.isEmpty() ? region : QRegion(q->rect());
| 0 | ||||||||||||||||||||||||||||||||||||
5392 | if (!(renderFlags & QWidget::IgnoreMask) && extra && extra->hasMask)
| 0 | ||||||||||||||||||||||||||||||||||||
5393 | toBePainted &= extra->mask; never executed: toBePainted &= extra->mask; | 0 | ||||||||||||||||||||||||||||||||||||
5394 | return toBePainted; never executed: return toBePainted; | 0 | ||||||||||||||||||||||||||||||||||||
5395 | } | - | ||||||||||||||||||||||||||||||||||||
5396 | - | |||||||||||||||||||||||||||||||||||||
5397 | void QWidgetPrivate::render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &toBePainted, | - | ||||||||||||||||||||||||||||||||||||
5398 | QWidget::RenderFlags renderFlags) | - | ||||||||||||||||||||||||||||||||||||
5399 | { | - | ||||||||||||||||||||||||||||||||||||
5400 | Q_ASSERT(painter); | - | ||||||||||||||||||||||||||||||||||||
5401 | Q_ASSERT(!toBePainted.isEmpty()); | - | ||||||||||||||||||||||||||||||||||||
5402 | - | |||||||||||||||||||||||||||||||||||||
5403 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5404 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
5405 | const QTransform originalTransform = painter->worldTransform(); | - | ||||||||||||||||||||||||||||||||||||
5406 | const bool useDeviceCoordinates = originalTransform.isScaling(); | - | ||||||||||||||||||||||||||||||||||||
5407 | if (!useDeviceCoordinates) {
| 0 | ||||||||||||||||||||||||||||||||||||
5408 | #endif | - | ||||||||||||||||||||||||||||||||||||
5409 | // Render via a pixmap. | - | ||||||||||||||||||||||||||||||||||||
5410 | const QRect rect = toBePainted.boundingRect(); | - | ||||||||||||||||||||||||||||||||||||
5411 | const QSize size = rect.size(); | - | ||||||||||||||||||||||||||||||||||||
5412 | if (size.isNull())
| 0 | ||||||||||||||||||||||||||||||||||||
5413 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5414 | - | |||||||||||||||||||||||||||||||||||||
5415 | const qreal pixmapDevicePixelRatio = painter->device()->devicePixelRatioF(); | - | ||||||||||||||||||||||||||||||||||||
5416 | QPixmap pixmap(size * pixmapDevicePixelRatio); | - | ||||||||||||||||||||||||||||||||||||
5417 | pixmap.setDevicePixelRatio(pixmapDevicePixelRatio); | - | ||||||||||||||||||||||||||||||||||||
5418 | - | |||||||||||||||||||||||||||||||||||||
5419 | if (!(renderFlags & QWidget::DrawWindowBackground) || !isOpaque)
| 0 | ||||||||||||||||||||||||||||||||||||
5420 | pixmap.fill(Qt::transparent); never executed: pixmap.fill(Qt::transparent); | 0 | ||||||||||||||||||||||||||||||||||||
5421 | q->render(&pixmap, QPoint(), toBePainted, renderFlags); | - | ||||||||||||||||||||||||||||||||||||
5422 | - | |||||||||||||||||||||||||||||||||||||
5423 | const bool restore = !(painter->renderHints() & QPainter::SmoothPixmapTransform); | - | ||||||||||||||||||||||||||||||||||||
5424 | painter->setRenderHints(QPainter::SmoothPixmapTransform, true); | - | ||||||||||||||||||||||||||||||||||||
5425 | - | |||||||||||||||||||||||||||||||||||||
5426 | painter->drawPixmap(targetOffset, pixmap); | - | ||||||||||||||||||||||||||||||||||||
5427 | - | |||||||||||||||||||||||||||||||||||||
5428 | if (restore)
| 0 | ||||||||||||||||||||||||||||||||||||
5429 | painter->setRenderHints(QPainter::SmoothPixmapTransform, false); never executed: painter->setRenderHints(QPainter::SmoothPixmapTransform, false); | 0 | ||||||||||||||||||||||||||||||||||||
5430 | - | |||||||||||||||||||||||||||||||||||||
5431 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
5432 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5433 | // Render via a pixmap in device coordinates (to avoid pixmap scaling). | - | ||||||||||||||||||||||||||||||||||||
5434 | QTransform transform = originalTransform; | - | ||||||||||||||||||||||||||||||||||||
5435 | transform.translate(targetOffset.x(), targetOffset.y()); | - | ||||||||||||||||||||||||||||||||||||
5436 | - | |||||||||||||||||||||||||||||||||||||
5437 | QPaintDevice *device = painter->device(); | - | ||||||||||||||||||||||||||||||||||||
5438 | Q_ASSERT(device); | - | ||||||||||||||||||||||||||||||||||||
5439 | - | |||||||||||||||||||||||||||||||||||||
5440 | // Calculate device rect. | - | ||||||||||||||||||||||||||||||||||||
5441 | const QRectF rect(toBePainted.boundingRect()); | - | ||||||||||||||||||||||||||||||||||||
5442 | QRect deviceRect = transform.mapRect(QRectF(0, 0, rect.width(), rect.height())).toAlignedRect(); | - | ||||||||||||||||||||||||||||||||||||
5443 | deviceRect &= QRect(0, 0, device->width(), device->height()); | - | ||||||||||||||||||||||||||||||||||||
5444 | - | |||||||||||||||||||||||||||||||||||||
5445 | QPixmap pixmap(deviceRect.size()); | - | ||||||||||||||||||||||||||||||||||||
5446 | pixmap.fill(Qt::transparent); | - | ||||||||||||||||||||||||||||||||||||
5447 | - | |||||||||||||||||||||||||||||||||||||
5448 | // Create a pixmap device coordinate painter. | - | ||||||||||||||||||||||||||||||||||||
5449 | QPainter pixmapPainter(&pixmap); | - | ||||||||||||||||||||||||||||||||||||
5450 | pixmapPainter.setRenderHints(painter->renderHints()); | - | ||||||||||||||||||||||||||||||||||||
5451 | transform *= QTransform::fromTranslate(-deviceRect.x(), -deviceRect.y()); | - | ||||||||||||||||||||||||||||||||||||
5452 | pixmapPainter.setTransform(transform); | - | ||||||||||||||||||||||||||||||||||||
5453 | - | |||||||||||||||||||||||||||||||||||||
5454 | q->render(&pixmapPainter, QPoint(), toBePainted, renderFlags); | - | ||||||||||||||||||||||||||||||||||||
5455 | pixmapPainter.end(); | - | ||||||||||||||||||||||||||||||||||||
5456 | - | |||||||||||||||||||||||||||||||||||||
5457 | // And then draw the pixmap. | - | ||||||||||||||||||||||||||||||||||||
5458 | painter->setTransform(QTransform()); | - | ||||||||||||||||||||||||||||||||||||
5459 | painter->drawPixmap(deviceRect.topLeft(), pixmap); | - | ||||||||||||||||||||||||||||||||||||
5460 | painter->setTransform(originalTransform); | - | ||||||||||||||||||||||||||||||||||||
5461 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5462 | #endif | - | ||||||||||||||||||||||||||||||||||||
5463 | } | - | ||||||||||||||||||||||||||||||||||||
5464 | - | |||||||||||||||||||||||||||||||||||||
5465 | void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, | - | ||||||||||||||||||||||||||||||||||||
5466 | QPainter *sharedPainter, QWidgetBackingStore *backingStore) | - | ||||||||||||||||||||||||||||||||||||
5467 | { | - | ||||||||||||||||||||||||||||||||||||
5468 | if (rgn.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
5469 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5470 | - | |||||||||||||||||||||||||||||||||||||
5471 | const bool asRoot = flags & DrawAsRoot; | - | ||||||||||||||||||||||||||||||||||||
5472 | bool onScreen = paintOnScreen(); | - | ||||||||||||||||||||||||||||||||||||
5473 | - | |||||||||||||||||||||||||||||||||||||
5474 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5475 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5476 | if (graphicsEffect && graphicsEffect->isEnabled()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5477 | QGraphicsEffectSource *source = graphicsEffect->d_func()->source; | - | ||||||||||||||||||||||||||||||||||||
5478 | QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *> | - | ||||||||||||||||||||||||||||||||||||
5479 | (source->d_func()); | - | ||||||||||||||||||||||||||||||||||||
5480 | if (!sourced->context) {
| 0 | ||||||||||||||||||||||||||||||||||||
5481 | QWidgetPaintContext context(pdev, rgn, offset, flags, sharedPainter, backingStore); | - | ||||||||||||||||||||||||||||||||||||
5482 | sourced->context = &context; | - | ||||||||||||||||||||||||||||||||||||
5483 | if (!sharedPainter) {
| 0 | ||||||||||||||||||||||||||||||||||||
5484 | setSystemClip(pdev, rgn.translated(offset)); | - | ||||||||||||||||||||||||||||||||||||
5485 | QPainter p(pdev); | - | ||||||||||||||||||||||||||||||||||||
5486 | p.translate(offset); | - | ||||||||||||||||||||||||||||||||||||
5487 | context.painter = &p; | - | ||||||||||||||||||||||||||||||||||||
5488 | graphicsEffect->draw(&p); | - | ||||||||||||||||||||||||||||||||||||
5489 | setSystemClip(pdev, QRegion()); | - | ||||||||||||||||||||||||||||||||||||
5490 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5491 | context.painter = sharedPainter; | - | ||||||||||||||||||||||||||||||||||||
5492 | if (sharedPainter->worldTransform() != sourced->lastEffectTransform) {
| 0 | ||||||||||||||||||||||||||||||||||||
5493 | sourced->invalidateCache(); | - | ||||||||||||||||||||||||||||||||||||
5494 | sourced->lastEffectTransform = sharedPainter->worldTransform(); | - | ||||||||||||||||||||||||||||||||||||
5495 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5496 | sharedPainter->save(); | - | ||||||||||||||||||||||||||||||||||||
5497 | sharedPainter->translate(offset); | - | ||||||||||||||||||||||||||||||||||||
5498 | graphicsEffect->draw(sharedPainter); | - | ||||||||||||||||||||||||||||||||||||
5499 | sharedPainter->restore(); | - | ||||||||||||||||||||||||||||||||||||
5500 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5501 | sourced->context = 0; | - | ||||||||||||||||||||||||||||||||||||
5502 | - | |||||||||||||||||||||||||||||||||||||
5503 | // Native widgets need to be marked dirty on screen so painting will be done in correct context | - | ||||||||||||||||||||||||||||||||||||
5504 | // Same check as in the no effects case below. | - | ||||||||||||||||||||||||||||||||||||
5505 | if (backingStore && !onScreen && !asRoot && (q->internalWinId() || !q->nativeParentWidget()->isWindow()))
| 0 | ||||||||||||||||||||||||||||||||||||
5506 | backingStore->markDirtyOnScreen(rgn, q, offset); never executed: backingStore->markDirtyOnScreen(rgn, q, offset); | 0 | ||||||||||||||||||||||||||||||||||||
5507 | - | |||||||||||||||||||||||||||||||||||||
5508 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5509 | } | - | ||||||||||||||||||||||||||||||||||||
5510 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5511 | #endif //QT_NO_GRAFFICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5512 | - | |||||||||||||||||||||||||||||||||||||
5513 | const bool alsoOnScreen = flags & DrawPaintOnScreen; | - | ||||||||||||||||||||||||||||||||||||
5514 | const bool recursive = flags & DrawRecursive; | - | ||||||||||||||||||||||||||||||||||||
5515 | const bool alsoInvisible = flags & DrawInvisible; | - | ||||||||||||||||||||||||||||||||||||
5516 | - | |||||||||||||||||||||||||||||||||||||
5517 | Q_ASSERT(sharedPainter ? sharedPainter->isActive() : true); | - | ||||||||||||||||||||||||||||||||||||
5518 | - | |||||||||||||||||||||||||||||||||||||
5519 | QRegion toBePainted(rgn); | - | ||||||||||||||||||||||||||||||||||||
5520 | if (asRoot && !alsoInvisible)
| 0 | ||||||||||||||||||||||||||||||||||||
5521 | toBePainted &= clipRect(); //(rgn & visibleRegion()); never executed: toBePainted &= clipRect(); | 0 | ||||||||||||||||||||||||||||||||||||
5522 | if (!(flags & DontSubtractOpaqueChildren))
| 0 | ||||||||||||||||||||||||||||||||||||
5523 | subtractOpaqueChildren(toBePainted, q->rect()); never executed: subtractOpaqueChildren(toBePainted, q->rect()); | 0 | ||||||||||||||||||||||||||||||||||||
5524 | - | |||||||||||||||||||||||||||||||||||||
5525 | if (!toBePainted.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5526 | if (!onScreen || alsoOnScreen) {
| 0 | ||||||||||||||||||||||||||||||||||||
5527 | //update the "in paint event" flag | - | ||||||||||||||||||||||||||||||||||||
5528 | if (q->testAttribute(Qt::WA_WState_InPaintEvent))
| 0 | ||||||||||||||||||||||||||||||||||||
5529 | qWarning("QWidget::repaint: Recursive repaint detected"); never executed: QMessageLogger(__FILE__, 5529, __PRETTY_FUNCTION__).warning("QWidget::repaint: Recursive repaint detected"); | 0 | ||||||||||||||||||||||||||||||||||||
5530 | q->setAttribute(Qt::WA_WState_InPaintEvent); | - | ||||||||||||||||||||||||||||||||||||
5531 | - | |||||||||||||||||||||||||||||||||||||
5532 | //clip away the new area | - | ||||||||||||||||||||||||||||||||||||
5533 | #ifndef QT_NO_PAINT_DEBUG | - | ||||||||||||||||||||||||||||||||||||
5534 | bool flushed = QWidgetBackingStore::flushPaint(q, toBePainted); | - | ||||||||||||||||||||||||||||||||||||
5535 | #endif | - | ||||||||||||||||||||||||||||||||||||
5536 | QPaintEngine *paintEngine = pdev->paintEngine(); | - | ||||||||||||||||||||||||||||||||||||
5537 | if (paintEngine) {
| 0 | ||||||||||||||||||||||||||||||||||||
5538 | setRedirected(pdev, -offset); | - | ||||||||||||||||||||||||||||||||||||
5539 | - | |||||||||||||||||||||||||||||||||||||
5540 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
5541 | // (Alien support) Special case for Mac when redirecting: If the paint device | - | ||||||||||||||||||||||||||||||||||||
5542 | // is of the Widget type we need to set WA_WState_InPaintEvent since painting | - | ||||||||||||||||||||||||||||||||||||
5543 | // outside the paint event is not supported on QWidgets. The attributeis | - | ||||||||||||||||||||||||||||||||||||
5544 | // restored further down. | - | ||||||||||||||||||||||||||||||||||||
5545 | if (pdev->devType() == QInternal::Widget) | - | ||||||||||||||||||||||||||||||||||||
5546 | static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent); | - | ||||||||||||||||||||||||||||||||||||
5547 | - | |||||||||||||||||||||||||||||||||||||
5548 | #endif | - | ||||||||||||||||||||||||||||||||||||
5549 | if (sharedPainter)
| 0 | ||||||||||||||||||||||||||||||||||||
5550 | setSystemClip(pdev, toBePainted); never executed: setSystemClip(pdev, toBePainted); | 0 | ||||||||||||||||||||||||||||||||||||
5551 | else | - | ||||||||||||||||||||||||||||||||||||
5552 | paintEngine->d_func()->systemRect = q->data->crect; never executed: paintEngine->d_func()->systemRect = q->data->crect; | 0 | ||||||||||||||||||||||||||||||||||||
5553 | - | |||||||||||||||||||||||||||||||||||||
5554 | //paint the background | - | ||||||||||||||||||||||||||||||||||||
5555 | if ((asRoot || q->autoFillBackground() || onScreen || q->testAttribute(Qt::WA_StyledBackground))
| 0 | ||||||||||||||||||||||||||||||||||||
5556 | && !q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5557 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5558 | beginBackingStorePainting(); | - | ||||||||||||||||||||||||||||||||||||
5559 | #endif | - | ||||||||||||||||||||||||||||||||||||
5560 | QPainter p(q); | - | ||||||||||||||||||||||||||||||||||||
5561 | paintBackground(&p, toBePainted, (asRoot || onScreen) ? flags | DrawAsRoot : 0); | - | ||||||||||||||||||||||||||||||||||||
5562 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5563 | endBackingStorePainting(); | - | ||||||||||||||||||||||||||||||||||||
5564 | #endif | - | ||||||||||||||||||||||||||||||||||||
5565 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5566 | - | |||||||||||||||||||||||||||||||||||||
5567 | if (!sharedPainter)
| 0 | ||||||||||||||||||||||||||||||||||||
5568 | setSystemClip(pdev, toBePainted.translated(offset)); never executed: setSystemClip(pdev, toBePainted.translated(offset)); | 0 | ||||||||||||||||||||||||||||||||||||
5569 | - | |||||||||||||||||||||||||||||||||||||
5570 | if (!onScreen && !asRoot && !isOpaque && q->testAttribute(Qt::WA_TintedBackground)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5571 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5572 | beginBackingStorePainting(); | - | ||||||||||||||||||||||||||||||||||||
5573 | #endif | - | ||||||||||||||||||||||||||||||||||||
5574 | QPainter p(q); | - | ||||||||||||||||||||||||||||||||||||
5575 | QColor tint = q->palette().window().color(); | - | ||||||||||||||||||||||||||||||||||||
5576 | tint.setAlphaF(qreal(.6)); | - | ||||||||||||||||||||||||||||||||||||
5577 | p.fillRect(toBePainted.boundingRect(), tint); | - | ||||||||||||||||||||||||||||||||||||
5578 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5579 | endBackingStorePainting(); | - | ||||||||||||||||||||||||||||||||||||
5580 | #endif | - | ||||||||||||||||||||||||||||||||||||
5581 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5582 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5583 | - | |||||||||||||||||||||||||||||||||||||
5584 | #if 0 | - | ||||||||||||||||||||||||||||||||||||
5585 | qDebug() << "painting" << q << "opaque ==" << isOpaque(); | - | ||||||||||||||||||||||||||||||||||||
5586 | qDebug() << "clipping to" << toBePainted << "location == " << offset | - | ||||||||||||||||||||||||||||||||||||
5587 | << "geometry ==" << QRect(q->mapTo(q->window(), QPoint(0, 0)), q->size()); | - | ||||||||||||||||||||||||||||||||||||
5588 | #endif | - | ||||||||||||||||||||||||||||||||||||
5589 | - | |||||||||||||||||||||||||||||||||||||
5590 | bool skipPaintEvent = false; | - | ||||||||||||||||||||||||||||||||||||
5591 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5592 | if (renderToTexture) {
| 0 | ||||||||||||||||||||||||||||||||||||
5593 | // This widget renders into a texture which is composed later. We just need to | - | ||||||||||||||||||||||||||||||||||||
5594 | // punch a hole in the backingstore, so the texture will be visible. | - | ||||||||||||||||||||||||||||||||||||
5595 | if (!q->testAttribute(Qt::WA_AlwaysStackOnTop)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5596 | beginBackingStorePainting(); | - | ||||||||||||||||||||||||||||||||||||
5597 | if (backingStore) {
| 0 | ||||||||||||||||||||||||||||||||||||
5598 | QPainter p(q); | - | ||||||||||||||||||||||||||||||||||||
5599 | p.setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||||||||||||||||||||||||||||||||
5600 | p.fillRect(q->rect(), Qt::transparent); | - | ||||||||||||||||||||||||||||||||||||
5601 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5602 | QImage img = grabFramebuffer(); | - | ||||||||||||||||||||||||||||||||||||
5603 | QPainter p(q); | - | ||||||||||||||||||||||||||||||||||||
5604 | // We are not drawing to a backingstore: fall back to QImage | - | ||||||||||||||||||||||||||||||||||||
5605 | p.drawImage(q->rect(), img); | - | ||||||||||||||||||||||||||||||||||||
5606 | skipPaintEvent = true; | - | ||||||||||||||||||||||||||||||||||||
5607 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5608 | endBackingStorePainting(); | - | ||||||||||||||||||||||||||||||||||||
5609 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5610 | if (renderToTextureReallyDirty)
| 0 | ||||||||||||||||||||||||||||||||||||
5611 | renderToTextureReallyDirty = 0; never executed: renderToTextureReallyDirty = 0; | 0 | ||||||||||||||||||||||||||||||||||||
5612 | else | - | ||||||||||||||||||||||||||||||||||||
5613 | skipPaintEvent = true; never executed: skipPaintEvent = true; | 0 | ||||||||||||||||||||||||||||||||||||
5614 | } | - | ||||||||||||||||||||||||||||||||||||
5615 | #endif // QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5616 | - | |||||||||||||||||||||||||||||||||||||
5617 | if (!skipPaintEvent) {
| 0 | ||||||||||||||||||||||||||||||||||||
5618 | //actually send the paint event | - | ||||||||||||||||||||||||||||||||||||
5619 | sendPaintEvent(toBePainted); | - | ||||||||||||||||||||||||||||||||||||
5620 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5621 | - | |||||||||||||||||||||||||||||||||||||
5622 | // Native widgets need to be marked dirty on screen so painting will be done in correct context | - | ||||||||||||||||||||||||||||||||||||
5623 | if (backingStore && !onScreen && !asRoot && (q->internalWinId() || (q->nativeParentWidget() && !q->nativeParentWidget()->isWindow())))
| 0 | ||||||||||||||||||||||||||||||||||||
5624 | backingStore->markDirtyOnScreen(toBePainted, q, offset); never executed: backingStore->markDirtyOnScreen(toBePainted, q, offset); | 0 | ||||||||||||||||||||||||||||||||||||
5625 | - | |||||||||||||||||||||||||||||||||||||
5626 | //restore | - | ||||||||||||||||||||||||||||||||||||
5627 | if (paintEngine) {
| 0 | ||||||||||||||||||||||||||||||||||||
5628 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
5629 | if (pdev->devType() == QInternal::Widget) | - | ||||||||||||||||||||||||||||||||||||
5630 | static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent, false); | - | ||||||||||||||||||||||||||||||||||||
5631 | #endif | - | ||||||||||||||||||||||||||||||||||||
5632 | restoreRedirected(); | - | ||||||||||||||||||||||||||||||||||||
5633 | if (!sharedPainter)
| 0 | ||||||||||||||||||||||||||||||||||||
5634 | paintEngine->d_func()->systemRect = QRect(); never executed: paintEngine->d_func()->systemRect = QRect(); | 0 | ||||||||||||||||||||||||||||||||||||
5635 | else | - | ||||||||||||||||||||||||||||||||||||
5636 | paintEngine->d_func()->currentClipDevice = 0; never executed: paintEngine->d_func()->currentClipDevice = 0; | 0 | ||||||||||||||||||||||||||||||||||||
5637 | - | |||||||||||||||||||||||||||||||||||||
5638 | setSystemClip(pdev, QRegion()); | - | ||||||||||||||||||||||||||||||||||||
5639 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5640 | q->setAttribute(Qt::WA_WState_InPaintEvent, false); | - | ||||||||||||||||||||||||||||||||||||
5641 | if (q->paintingActive())
| 0 | ||||||||||||||||||||||||||||||||||||
5642 | qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent"); never executed: QMessageLogger(__FILE__, 5642, __PRETTY_FUNCTION__).warning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent"); | 0 | ||||||||||||||||||||||||||||||||||||
5643 | - | |||||||||||||||||||||||||||||||||||||
5644 | if (paintEngine && paintEngine->autoDestruct()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5645 | delete paintEngine; | - | ||||||||||||||||||||||||||||||||||||
5646 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5647 | - | |||||||||||||||||||||||||||||||||||||
5648 | #ifndef QT_NO_PAINT_DEBUG | - | ||||||||||||||||||||||||||||||||||||
5649 | if (flushed)
| 0 | ||||||||||||||||||||||||||||||||||||
5650 | QWidgetBackingStore::unflushPaint(q, toBePainted); never executed: QWidgetBackingStore::unflushPaint(q, toBePainted); | 0 | ||||||||||||||||||||||||||||||||||||
5651 | #endif | - | ||||||||||||||||||||||||||||||||||||
5652 | } else if (q->isWindow()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
5653 | QPaintEngine *engine = pdev->paintEngine(); | - | ||||||||||||||||||||||||||||||||||||
5654 | if (engine) {
| 0 | ||||||||||||||||||||||||||||||||||||
5655 | QPainter p(pdev); | - | ||||||||||||||||||||||||||||||||||||
5656 | p.setClipRegion(toBePainted); | - | ||||||||||||||||||||||||||||||||||||
5657 | const QBrush bg = q->palette().brush(QPalette::Window); | - | ||||||||||||||||||||||||||||||||||||
5658 | if (bg.style() == Qt::TexturePattern)
| 0 | ||||||||||||||||||||||||||||||||||||
5659 | p.drawTiledPixmap(q->rect(), bg.texture()); never executed: p.drawTiledPixmap(q->rect(), bg.texture()); | 0 | ||||||||||||||||||||||||||||||||||||
5660 | else | - | ||||||||||||||||||||||||||||||||||||
5661 | p.fillRect(q->rect(), bg); never executed: p.fillRect(q->rect(), bg); | 0 | ||||||||||||||||||||||||||||||||||||
5662 | - | |||||||||||||||||||||||||||||||||||||
5663 | if (engine->autoDestruct())
| 0 | ||||||||||||||||||||||||||||||||||||
5664 | delete engine; never executed: delete engine; | 0 | ||||||||||||||||||||||||||||||||||||
5665 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5666 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5667 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5668 | - | |||||||||||||||||||||||||||||||||||||
5669 | if (recursive && !children.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5670 | paintSiblingsRecursive(pdev, children, children.size() - 1, rgn, offset, flags & ~DrawAsRoot | - | ||||||||||||||||||||||||||||||||||||
5671 | , sharedPainter, backingStore); | - | ||||||||||||||||||||||||||||||||||||
5672 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5673 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5674 | - | |||||||||||||||||||||||||||||||||||||
5675 | void QWidgetPrivate::sendPaintEvent(const QRegion &toBePainted) | - | ||||||||||||||||||||||||||||||||||||
5676 | { | - | ||||||||||||||||||||||||||||||||||||
5677 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5678 | QPaintEvent e(toBePainted); | - | ||||||||||||||||||||||||||||||||||||
5679 | QCoreApplication::sendSpontaneousEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
5680 | - | |||||||||||||||||||||||||||||||||||||
5681 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5682 | if (renderToTexture)
| 0 | ||||||||||||||||||||||||||||||||||||
5683 | resolveSamples(); never executed: resolveSamples(); | 0 | ||||||||||||||||||||||||||||||||||||
5684 | #endif // QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
5685 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5686 | - | |||||||||||||||||||||||||||||||||||||
5687 | void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, | - | ||||||||||||||||||||||||||||||||||||
5688 | const QRegion &sourceRegion, QWidget::RenderFlags renderFlags) | - | ||||||||||||||||||||||||||||||||||||
5689 | { | - | ||||||||||||||||||||||||||||||||||||
5690 | if (!target) {
| 0 | ||||||||||||||||||||||||||||||||||||
5691 | qWarning("QWidget::render: null pointer to paint device"); | - | ||||||||||||||||||||||||||||||||||||
5692 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5693 | } | - | ||||||||||||||||||||||||||||||||||||
5694 | - | |||||||||||||||||||||||||||||||||||||
5695 | const bool inRenderWithPainter = extra && extra->inRenderWithPainter;
| 0 | ||||||||||||||||||||||||||||||||||||
5696 | QRegion paintRegion = !inRenderWithPainter
| 0 | ||||||||||||||||||||||||||||||||||||
5697 | ? prepareToRender(sourceRegion, renderFlags) | - | ||||||||||||||||||||||||||||||||||||
5698 | : sourceRegion; | - | ||||||||||||||||||||||||||||||||||||
5699 | if (paintRegion.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
5700 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5701 | - | |||||||||||||||||||||||||||||||||||||
5702 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
5703 | QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
5704 | - | |||||||||||||||||||||||||||||||||||||
5705 | // Use the target's shared painter if set (typically set when doing | - | ||||||||||||||||||||||||||||||||||||
5706 | // "other->render(widget);" in the widget's paintEvent. | - | ||||||||||||||||||||||||||||||||||||
5707 | if (target->devType() == QInternal::Widget) {
| 0 | ||||||||||||||||||||||||||||||||||||
5708 | QWidgetPrivate *targetPrivate = static_cast<QWidget *>(target)->d_func(); | - | ||||||||||||||||||||||||||||||||||||
5709 | if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) {
| 0 | ||||||||||||||||||||||||||||||||||||
5710 | QPainter *targetPainter = targetPrivate->sharedPainter(); | - | ||||||||||||||||||||||||||||||||||||
5711 | if (targetPainter && targetPainter->isActive())
| 0 | ||||||||||||||||||||||||||||||||||||
5712 | setSharedPainter(targetPainter); never executed: setSharedPainter(targetPainter); | 0 | ||||||||||||||||||||||||||||||||||||
5713 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5714 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5715 | #endif | - | ||||||||||||||||||||||||||||||||||||
5716 | - | |||||||||||||||||||||||||||||||||||||
5717 | // Use the target's redirected device if set and adjust offset and paint | - | ||||||||||||||||||||||||||||||||||||
5718 | // region accordingly. This is typically the case when people call render | - | ||||||||||||||||||||||||||||||||||||
5719 | // from the paintEvent. | - | ||||||||||||||||||||||||||||||||||||
5720 | QPoint offset = targetOffset; | - | ||||||||||||||||||||||||||||||||||||
5721 | offset -= paintRegion.boundingRect().topLeft(); | - | ||||||||||||||||||||||||||||||||||||
5722 | QPoint redirectionOffset; | - | ||||||||||||||||||||||||||||||||||||
5723 | QPaintDevice *redirected = 0; | - | ||||||||||||||||||||||||||||||||||||
5724 | - | |||||||||||||||||||||||||||||||||||||
5725 | if (target->devType() == QInternal::Widget)
| 0 | ||||||||||||||||||||||||||||||||||||
5726 | redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset); never executed: redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset); | 0 | ||||||||||||||||||||||||||||||||||||
5727 | if (!redirected)
| 0 | ||||||||||||||||||||||||||||||||||||
5728 | redirected = QPainter::redirected(target, &redirectionOffset); never executed: redirected = QPainter::redirected(target, &redirectionOffset); | 0 | ||||||||||||||||||||||||||||||||||||
5729 | - | |||||||||||||||||||||||||||||||||||||
5730 | if (redirected) {
| 0 | ||||||||||||||||||||||||||||||||||||
5731 | target = redirected; | - | ||||||||||||||||||||||||||||||||||||
5732 | offset -= redirectionOffset; | - | ||||||||||||||||||||||||||||||||||||
5733 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5734 | - | |||||||||||||||||||||||||||||||||||||
5735 | if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp).
| 0 | ||||||||||||||||||||||||||||||||||||
5736 | if (QPaintEngine *targetEngine = target->paintEngine()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5737 | const QRegion targetSystemClip = targetEngine->systemClip(); | - | ||||||||||||||||||||||||||||||||||||
5738 | if (!targetSystemClip.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
5739 | paintRegion &= targetSystemClip.translated(-offset); never executed: paintRegion &= targetSystemClip.translated(-offset); | 0 | ||||||||||||||||||||||||||||||||||||
5740 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5741 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5742 | - | |||||||||||||||||||||||||||||||||||||
5743 | // Set backingstore flags. | - | ||||||||||||||||||||||||||||||||||||
5744 | int flags = DrawPaintOnScreen | DrawInvisible; | - | ||||||||||||||||||||||||||||||||||||
5745 | if (renderFlags & QWidget::DrawWindowBackground)
| 0 | ||||||||||||||||||||||||||||||||||||
5746 | flags |= DrawAsRoot; never executed: flags |= DrawAsRoot; | 0 | ||||||||||||||||||||||||||||||||||||
5747 | - | |||||||||||||||||||||||||||||||||||||
5748 | if (renderFlags & QWidget::DrawChildren)
| 0 | ||||||||||||||||||||||||||||||||||||
5749 | flags |= DrawRecursive; never executed: flags |= DrawRecursive; | 0 | ||||||||||||||||||||||||||||||||||||
5750 | else | - | ||||||||||||||||||||||||||||||||||||
5751 | flags |= DontSubtractOpaqueChildren; never executed: flags |= DontSubtractOpaqueChildren; | 0 | ||||||||||||||||||||||||||||||||||||
5752 | - | |||||||||||||||||||||||||||||||||||||
5753 | flags |= DontSetCompositionMode; | - | ||||||||||||||||||||||||||||||||||||
5754 | - | |||||||||||||||||||||||||||||||||||||
5755 | // Render via backingstore. | - | ||||||||||||||||||||||||||||||||||||
5756 | drawWidget(target, paintRegion, offset, flags, sharedPainter()); | - | ||||||||||||||||||||||||||||||||||||
5757 | - | |||||||||||||||||||||||||||||||||||||
5758 | // Restore shared painter. | - | ||||||||||||||||||||||||||||||||||||
5759 | if (oldSharedPainter)
| 0 | ||||||||||||||||||||||||||||||||||||
5760 | setSharedPainter(oldSharedPainter); never executed: setSharedPainter(oldSharedPainter); | 0 | ||||||||||||||||||||||||||||||||||||
5761 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5762 | - | |||||||||||||||||||||||||||||||||||||
5763 | void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& siblings, int index, const QRegion &rgn, | - | ||||||||||||||||||||||||||||||||||||
5764 | const QPoint &offset, int flags | - | ||||||||||||||||||||||||||||||||||||
5765 | , QPainter *sharedPainter, QWidgetBackingStore *backingStore) | - | ||||||||||||||||||||||||||||||||||||
5766 | { | - | ||||||||||||||||||||||||||||||||||||
5767 | QWidget *w = 0; | - | ||||||||||||||||||||||||||||||||||||
5768 | QRect boundingRect; | - | ||||||||||||||||||||||||||||||||||||
5769 | bool dirtyBoundingRect = true; | - | ||||||||||||||||||||||||||||||||||||
5770 | const bool exludeOpaqueChildren = (flags & DontDrawOpaqueChildren); | - | ||||||||||||||||||||||||||||||||||||
5771 | const bool excludeNativeChildren = (flags & DontDrawNativeChildren); | - | ||||||||||||||||||||||||||||||||||||
5772 | - | |||||||||||||||||||||||||||||||||||||
5773 | do { | - | ||||||||||||||||||||||||||||||||||||
5774 | QWidget *x = qobject_cast<QWidget*>(siblings.at(index)); | - | ||||||||||||||||||||||||||||||||||||
5775 | if (x && !(exludeOpaqueChildren && x->d_func()->isOpaque) && !x->isHidden() && !x->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
5776 | && !(excludeNativeChildren && x->internalWinId())) {
| 0 | ||||||||||||||||||||||||||||||||||||
5777 | if (dirtyBoundingRect) {
| 0 | ||||||||||||||||||||||||||||||||||||
5778 | boundingRect = rgn.boundingRect(); | - | ||||||||||||||||||||||||||||||||||||
5779 | dirtyBoundingRect = false; | - | ||||||||||||||||||||||||||||||||||||
5780 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5781 | - | |||||||||||||||||||||||||||||||||||||
5782 | if (qRectIntersects(boundingRect, x->d_func()->effectiveRectFor(x->data->crect))) {
| 0 | ||||||||||||||||||||||||||||||||||||
5783 | w = x; | - | ||||||||||||||||||||||||||||||||||||
5784 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
5785 | } | - | ||||||||||||||||||||||||||||||||||||
5786 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5787 | --index; | - | ||||||||||||||||||||||||||||||||||||
5788 | } while (index >= 0); never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
5789 | - | |||||||||||||||||||||||||||||||||||||
5790 | if (!w)
| 0 | ||||||||||||||||||||||||||||||||||||
5791 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5792 | - | |||||||||||||||||||||||||||||||||||||
5793 | QWidgetPrivate *wd = w->d_func(); | - | ||||||||||||||||||||||||||||||||||||
5794 | const QPoint widgetPos(w->data->crect.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
5795 | const bool hasMask = wd->extra && wd->extra->hasMask && !wd->graphicsEffect;
| 0 | ||||||||||||||||||||||||||||||||||||
5796 | if (index > 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
5797 | QRegion wr(rgn); | - | ||||||||||||||||||||||||||||||||||||
5798 | if (wd->isOpaque)
| 0 | ||||||||||||||||||||||||||||||||||||
5799 | wr -= hasMask ? wd->extra->mask.translated(widgetPos) : w->data->crect; never executed: wr -= hasMask ? wd->extra->mask.translated(widgetPos) : w->data->crect;
| 0 | ||||||||||||||||||||||||||||||||||||
5800 | paintSiblingsRecursive(pdev, siblings, --index, wr, offset, flags | - | ||||||||||||||||||||||||||||||||||||
5801 | , sharedPainter, backingStore); | - | ||||||||||||||||||||||||||||||||||||
5802 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5803 | - | |||||||||||||||||||||||||||||||||||||
5804 | if (w->updatesEnabled()
| 0 | ||||||||||||||||||||||||||||||||||||
5805 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
5806 | && (!w->d_func()->extra || !w->d_func()->extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
5807 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
5808 | ) { | - | ||||||||||||||||||||||||||||||||||||
5809 | QRegion wRegion(rgn); | - | ||||||||||||||||||||||||||||||||||||
5810 | wRegion &= wd->effectiveRectFor(w->data->crect); | - | ||||||||||||||||||||||||||||||||||||
5811 | wRegion.translate(-widgetPos); | - | ||||||||||||||||||||||||||||||||||||
5812 | if (hasMask)
| 0 | ||||||||||||||||||||||||||||||||||||
5813 | wRegion &= wd->extra->mask; never executed: wRegion &= wd->extra->mask; | 0 | ||||||||||||||||||||||||||||||||||||
5814 | wd->drawWidget(pdev, wRegion, offset + widgetPos, flags, sharedPainter, backingStore); | - | ||||||||||||||||||||||||||||||||||||
5815 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5816 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5817 | - | |||||||||||||||||||||||||||||||||||||
5818 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5819 | QRectF QWidgetEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const | - | ||||||||||||||||||||||||||||||||||||
5820 | { | - | ||||||||||||||||||||||||||||||||||||
5821 | if (system != Qt::DeviceCoordinates)
| 0 | ||||||||||||||||||||||||||||||||||||
5822 | return m_widget->rect(); never executed: return m_widget->rect(); | 0 | ||||||||||||||||||||||||||||||||||||
5823 | - | |||||||||||||||||||||||||||||||||||||
5824 | if (!context) {
| 0 | ||||||||||||||||||||||||||||||||||||
5825 | // Device coordinates without context not yet supported. | - | ||||||||||||||||||||||||||||||||||||
5826 | qWarning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context"); | - | ||||||||||||||||||||||||||||||||||||
5827 | return QRectF(); never executed: return QRectF(); | 0 | ||||||||||||||||||||||||||||||||||||
5828 | } | - | ||||||||||||||||||||||||||||||||||||
5829 | - | |||||||||||||||||||||||||||||||||||||
5830 | return context->painter->worldTransform().mapRect(m_widget->rect()); never executed: return context->painter->worldTransform().mapRect(m_widget->rect()); | 0 | ||||||||||||||||||||||||||||||||||||
5831 | } | - | ||||||||||||||||||||||||||||||||||||
5832 | - | |||||||||||||||||||||||||||||||||||||
5833 | void QWidgetEffectSourcePrivate::draw(QPainter *painter) | - | ||||||||||||||||||||||||||||||||||||
5834 | { | - | ||||||||||||||||||||||||||||||||||||
5835 | if (!context || context->painter != painter) {
| 0 | ||||||||||||||||||||||||||||||||||||
5836 | m_widget->render(painter); | - | ||||||||||||||||||||||||||||||||||||
5837 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5838 | } | - | ||||||||||||||||||||||||||||||||||||
5839 | - | |||||||||||||||||||||||||||||||||||||
5840 | // The region saved in the context is neither clipped to the rect | - | ||||||||||||||||||||||||||||||||||||
5841 | // nor the mask, so we have to clip it here before calling drawWidget. | - | ||||||||||||||||||||||||||||||||||||
5842 | QRegion toBePainted = context->rgn; | - | ||||||||||||||||||||||||||||||||||||
5843 | toBePainted &= m_widget->rect(); | - | ||||||||||||||||||||||||||||||||||||
5844 | QWidgetPrivate *wd = qt_widget_private(m_widget); | - | ||||||||||||||||||||||||||||||||||||
5845 | if (wd->extra && wd->extra->hasMask)
| 0 | ||||||||||||||||||||||||||||||||||||
5846 | toBePainted &= wd->extra->mask; never executed: toBePainted &= wd->extra->mask; | 0 | ||||||||||||||||||||||||||||||||||||
5847 | - | |||||||||||||||||||||||||||||||||||||
5848 | wd->drawWidget(context->pdev, toBePainted, context->offset, context->flags, | - | ||||||||||||||||||||||||||||||||||||
5849 | context->sharedPainter, context->backingStore); | - | ||||||||||||||||||||||||||||||||||||
5850 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5851 | - | |||||||||||||||||||||||||||||||||||||
5852 | QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset, | - | ||||||||||||||||||||||||||||||||||||
5853 | QGraphicsEffect::PixmapPadMode mode) const | - | ||||||||||||||||||||||||||||||||||||
5854 | { | - | ||||||||||||||||||||||||||||||||||||
5855 | const bool deviceCoordinates = (system == Qt::DeviceCoordinates); | - | ||||||||||||||||||||||||||||||||||||
5856 | if (!context && deviceCoordinates) {
| 0 | ||||||||||||||||||||||||||||||||||||
5857 | // Device coordinates without context not yet supported. | - | ||||||||||||||||||||||||||||||||||||
5858 | qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); | - | ||||||||||||||||||||||||||||||||||||
5859 | return QPixmap(); never executed: return QPixmap(); | 0 | ||||||||||||||||||||||||||||||||||||
5860 | } | - | ||||||||||||||||||||||||||||||||||||
5861 | - | |||||||||||||||||||||||||||||||||||||
5862 | QPoint pixmapOffset; | - | ||||||||||||||||||||||||||||||||||||
5863 | QRectF sourceRect = m_widget->rect(); | - | ||||||||||||||||||||||||||||||||||||
5864 | - | |||||||||||||||||||||||||||||||||||||
5865 | if (deviceCoordinates) {
| 0 | ||||||||||||||||||||||||||||||||||||
5866 | const QTransform &painterTransform = context->painter->worldTransform(); | - | ||||||||||||||||||||||||||||||||||||
5867 | sourceRect = painterTransform.mapRect(sourceRect); | - | ||||||||||||||||||||||||||||||||||||
5868 | pixmapOffset = painterTransform.map(pixmapOffset); | - | ||||||||||||||||||||||||||||||||||||
5869 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5870 | - | |||||||||||||||||||||||||||||||||||||
5871 | QRect effectRect; | - | ||||||||||||||||||||||||||||||||||||
5872 | - | |||||||||||||||||||||||||||||||||||||
5873 | if (mode == QGraphicsEffect::PadToEffectiveBoundingRect)
| 0 | ||||||||||||||||||||||||||||||||||||
5874 | effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); never executed: effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); | 0 | ||||||||||||||||||||||||||||||||||||
5875 | else if (mode == QGraphicsEffect::PadToTransparentBorder)
| 0 | ||||||||||||||||||||||||||||||||||||
5876 | effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); never executed: effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); | 0 | ||||||||||||||||||||||||||||||||||||
5877 | else | - | ||||||||||||||||||||||||||||||||||||
5878 | effectRect = sourceRect.toAlignedRect(); never executed: effectRect = sourceRect.toAlignedRect(); | 0 | ||||||||||||||||||||||||||||||||||||
5879 | - | |||||||||||||||||||||||||||||||||||||
5880 | if (offset)
| 0 | ||||||||||||||||||||||||||||||||||||
5881 | *offset = effectRect.topLeft(); never executed: *offset = effectRect.topLeft(); | 0 | ||||||||||||||||||||||||||||||||||||
5882 | - | |||||||||||||||||||||||||||||||||||||
5883 | pixmapOffset -= effectRect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
5884 | - | |||||||||||||||||||||||||||||||||||||
5885 | const qreal dpr = context->painter->device()->devicePixelRatio(); | - | ||||||||||||||||||||||||||||||||||||
5886 | QPixmap pixmap(effectRect.size() * dpr); | - | ||||||||||||||||||||||||||||||||||||
5887 | pixmap.setDevicePixelRatio(dpr); | - | ||||||||||||||||||||||||||||||||||||
5888 | - | |||||||||||||||||||||||||||||||||||||
5889 | pixmap.fill(Qt::transparent); | - | ||||||||||||||||||||||||||||||||||||
5890 | m_widget->render(&pixmap, pixmapOffset, QRegion(), QWidget::DrawChildren); | - | ||||||||||||||||||||||||||||||||||||
5891 | return pixmap; never executed: return pixmap; | 0 | ||||||||||||||||||||||||||||||||||||
5892 | } | - | ||||||||||||||||||||||||||||||||||||
5893 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||||||||||||||
5894 | - | |||||||||||||||||||||||||||||||||||||
5895 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
5896 | /*! | - | ||||||||||||||||||||||||||||||||||||
5897 | \internal | - | ||||||||||||||||||||||||||||||||||||
5898 | - | |||||||||||||||||||||||||||||||||||||
5899 | Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this | - | ||||||||||||||||||||||||||||||||||||
5900 | widget and its ancestors. The search starts at \a origin (inclusive). | - | ||||||||||||||||||||||||||||||||||||
5901 | If successful, the function returns the proxy that embeds the widget, or 0 if no embedded | - | ||||||||||||||||||||||||||||||||||||
5902 | widget was found. | - | ||||||||||||||||||||||||||||||||||||
5903 | */ | - | ||||||||||||||||||||||||||||||||||||
5904 | QGraphicsProxyWidget * QWidgetPrivate::nearestGraphicsProxyWidget(const QWidget *origin) | - | ||||||||||||||||||||||||||||||||||||
5905 | { | - | ||||||||||||||||||||||||||||||||||||
5906 | if (origin) {
| 0 | ||||||||||||||||||||||||||||||||||||
5907 | QWExtra *extra = origin->d_func()->extra; | - | ||||||||||||||||||||||||||||||||||||
5908 | if (extra && extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
5909 | return extra->proxyWidget; never executed: return extra->proxyWidget; | 0 | ||||||||||||||||||||||||||||||||||||
5910 | return nearestGraphicsProxyWidget(origin->parentWidget()); never executed: return nearestGraphicsProxyWidget(origin->parentWidget()); | 0 | ||||||||||||||||||||||||||||||||||||
5911 | } | - | ||||||||||||||||||||||||||||||||||||
5912 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
5913 | } | - | ||||||||||||||||||||||||||||||||||||
5914 | #endif | - | ||||||||||||||||||||||||||||||||||||
5915 | - | |||||||||||||||||||||||||||||||||||||
5916 | /*! | - | ||||||||||||||||||||||||||||||||||||
5917 | \property QWidget::locale | - | ||||||||||||||||||||||||||||||||||||
5918 | \brief the widget's locale | - | ||||||||||||||||||||||||||||||||||||
5919 | \since 4.3 | - | ||||||||||||||||||||||||||||||||||||
5920 | - | |||||||||||||||||||||||||||||||||||||
5921 | As long as no special locale has been set, this is either | - | ||||||||||||||||||||||||||||||||||||
5922 | the parent's locale or (if this widget is a top level widget), | - | ||||||||||||||||||||||||||||||||||||
5923 | the default locale. | - | ||||||||||||||||||||||||||||||||||||
5924 | - | |||||||||||||||||||||||||||||||||||||
5925 | If the widget displays dates or numbers, these should be formatted | - | ||||||||||||||||||||||||||||||||||||
5926 | using the widget's locale. | - | ||||||||||||||||||||||||||||||||||||
5927 | - | |||||||||||||||||||||||||||||||||||||
5928 | \sa QLocale, QLocale::setDefault() | - | ||||||||||||||||||||||||||||||||||||
5929 | */ | - | ||||||||||||||||||||||||||||||||||||
5930 | - | |||||||||||||||||||||||||||||||||||||
5931 | void QWidgetPrivate::setLocale_helper(const QLocale &loc, bool forceUpdate) | - | ||||||||||||||||||||||||||||||||||||
5932 | { | - | ||||||||||||||||||||||||||||||||||||
5933 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5934 | if (locale == loc && !forceUpdate)
| 0 | ||||||||||||||||||||||||||||||||||||
5935 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
5936 | - | |||||||||||||||||||||||||||||||||||||
5937 | locale = loc; | - | ||||||||||||||||||||||||||||||||||||
5938 | - | |||||||||||||||||||||||||||||||||||||
5939 | if (!children.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
5940 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
5941 | QWidget *w = qobject_cast<QWidget*>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
5942 | if (!w)
| 0 | ||||||||||||||||||||||||||||||||||||
5943 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
5944 | if (w->testAttribute(Qt::WA_SetLocale))
| 0 | ||||||||||||||||||||||||||||||||||||
5945 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
5946 | if (w->isWindow() && !w->testAttribute(Qt::WA_WindowPropagation))
| 0 | ||||||||||||||||||||||||||||||||||||
5947 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
5948 | w->d_func()->setLocale_helper(loc, forceUpdate); | - | ||||||||||||||||||||||||||||||||||||
5949 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5950 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5951 | QEvent e(QEvent::LocaleChange); | - | ||||||||||||||||||||||||||||||||||||
5952 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
5953 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5954 | - | |||||||||||||||||||||||||||||||||||||
5955 | void QWidget::setLocale(const QLocale &locale) | - | ||||||||||||||||||||||||||||||||||||
5956 | { | - | ||||||||||||||||||||||||||||||||||||
5957 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5958 | - | |||||||||||||||||||||||||||||||||||||
5959 | setAttribute(Qt::WA_SetLocale); | - | ||||||||||||||||||||||||||||||||||||
5960 | d->setLocale_helper(locale); | - | ||||||||||||||||||||||||||||||||||||
5961 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5962 | - | |||||||||||||||||||||||||||||||||||||
5963 | QLocale QWidget::locale() const | - | ||||||||||||||||||||||||||||||||||||
5964 | { | - | ||||||||||||||||||||||||||||||||||||
5965 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
5966 | - | |||||||||||||||||||||||||||||||||||||
5967 | return d->locale; never executed: return d->locale; | 0 | ||||||||||||||||||||||||||||||||||||
5968 | } | - | ||||||||||||||||||||||||||||||||||||
5969 | - | |||||||||||||||||||||||||||||||||||||
5970 | void QWidgetPrivate::resolveLocale() | - | ||||||||||||||||||||||||||||||||||||
5971 | { | - | ||||||||||||||||||||||||||||||||||||
5972 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
5973 | - | |||||||||||||||||||||||||||||||||||||
5974 | if (!q->testAttribute(Qt::WA_SetLocale)) {
| 0 | ||||||||||||||||||||||||||||||||||||
5975 | setLocale_helper(q->isWindow() | - | ||||||||||||||||||||||||||||||||||||
5976 | ? QLocale() | - | ||||||||||||||||||||||||||||||||||||
5977 | : q->parentWidget()->locale()); | - | ||||||||||||||||||||||||||||||||||||
5978 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5979 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5980 | - | |||||||||||||||||||||||||||||||||||||
5981 | void QWidget::unsetLocale() | - | ||||||||||||||||||||||||||||||||||||
5982 | { | - | ||||||||||||||||||||||||||||||||||||
5983 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
5984 | setAttribute(Qt::WA_SetLocale, false); | - | ||||||||||||||||||||||||||||||||||||
5985 | d->resolveLocale(); | - | ||||||||||||||||||||||||||||||||||||
5986 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
5987 | - | |||||||||||||||||||||||||||||||||||||
5988 | /*! | - | ||||||||||||||||||||||||||||||||||||
5989 | \property QWidget::windowTitle | - | ||||||||||||||||||||||||||||||||||||
5990 | \brief the window title (caption) | - | ||||||||||||||||||||||||||||||||||||
5991 | - | |||||||||||||||||||||||||||||||||||||
5992 | This property only makes sense for top-level widgets, such as | - | ||||||||||||||||||||||||||||||||||||
5993 | windows and dialogs. If no caption has been set, the title is based of the | - | ||||||||||||||||||||||||||||||||||||
5994 | \l windowFilePath. If neither of these is set, then the title is | - | ||||||||||||||||||||||||||||||||||||
5995 | an empty string. | - | ||||||||||||||||||||||||||||||||||||
5996 | - | |||||||||||||||||||||||||||||||||||||
5997 | If you use the \l windowModified mechanism, the window title must | - | ||||||||||||||||||||||||||||||||||||
5998 | contain a "[*]" placeholder, which indicates where the '*' should | - | ||||||||||||||||||||||||||||||||||||
5999 | appear. Normally, it should appear right after the file name | - | ||||||||||||||||||||||||||||||||||||
6000 | (e.g., "document1.txt[*] - Text Editor"). If the \l | - | ||||||||||||||||||||||||||||||||||||
6001 | windowModified property is \c false (the default), the placeholder | - | ||||||||||||||||||||||||||||||||||||
6002 | is simply removed. | - | ||||||||||||||||||||||||||||||||||||
6003 | - | |||||||||||||||||||||||||||||||||||||
6004 | On some desktop platforms (including Windows and Unix), the application name | - | ||||||||||||||||||||||||||||||||||||
6005 | (from QGuiApplication::applicationDisplayName) is added at the end of the | - | ||||||||||||||||||||||||||||||||||||
6006 | window title, if set. This is done by the QPA plugin, so it is shown to the | - | ||||||||||||||||||||||||||||||||||||
6007 | user, but isn't part of the windowTitle string. | - | ||||||||||||||||||||||||||||||||||||
6008 | - | |||||||||||||||||||||||||||||||||||||
6009 | \sa windowIcon, windowModified, windowFilePath | - | ||||||||||||||||||||||||||||||||||||
6010 | */ | - | ||||||||||||||||||||||||||||||||||||
6011 | QString QWidget::windowTitle() const | - | ||||||||||||||||||||||||||||||||||||
6012 | { | - | ||||||||||||||||||||||||||||||||||||
6013 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
6014 | if (d->extra && d->extra->topextra) {
| 0 | ||||||||||||||||||||||||||||||||||||
6015 | if (!d->extra->topextra->caption.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
6016 | return d->extra->topextra->caption; never executed: return d->extra->topextra->caption; | 0 | ||||||||||||||||||||||||||||||||||||
6017 | if (!d->extra->topextra->filePath.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
6018 | return QFileInfo(d->extra->topextra->filePath).fileName() + QLatin1String("[*]"); never executed: return QFileInfo(d->extra->topextra->filePath).fileName() + QLatin1String("[*]"); | 0 | ||||||||||||||||||||||||||||||||||||
6019 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6020 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||||||||||||||
6021 | } | - | ||||||||||||||||||||||||||||||||||||
6022 | - | |||||||||||||||||||||||||||||||||||||
6023 | /*! | - | ||||||||||||||||||||||||||||||||||||
6024 | Returns a modified window title with the [*] place holder | - | ||||||||||||||||||||||||||||||||||||
6025 | replaced according to the rules described in QWidget::setWindowTitle | - | ||||||||||||||||||||||||||||||||||||
6026 | - | |||||||||||||||||||||||||||||||||||||
6027 | This function assumes that "[*]" can be quoted by another | - | ||||||||||||||||||||||||||||||||||||
6028 | "[*]", so it will replace two place holders by one and | - | ||||||||||||||||||||||||||||||||||||
6029 | a single last one by either "*" or nothing depending on | - | ||||||||||||||||||||||||||||||||||||
6030 | the modified flag. | - | ||||||||||||||||||||||||||||||||||||
6031 | - | |||||||||||||||||||||||||||||||||||||
6032 | \internal | - | ||||||||||||||||||||||||||||||||||||
6033 | */ | - | ||||||||||||||||||||||||||||||||||||
6034 | QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
6035 | { | - | ||||||||||||||||||||||||||||||||||||
6036 | Q_ASSERT(widget); | - | ||||||||||||||||||||||||||||||||||||
6037 | - | |||||||||||||||||||||||||||||||||||||
6038 | #ifdef QT_EVAL | - | ||||||||||||||||||||||||||||||||||||
6039 | extern QString qt_eval_adapt_window_title(const QString &title); | - | ||||||||||||||||||||||||||||||||||||
6040 | QString cap = qt_eval_adapt_window_title(title); | - | ||||||||||||||||||||||||||||||||||||
6041 | #else | - | ||||||||||||||||||||||||||||||||||||
6042 | QString cap = title; | - | ||||||||||||||||||||||||||||||||||||
6043 | #endif | - | ||||||||||||||||||||||||||||||||||||
6044 | - | |||||||||||||||||||||||||||||||||||||
6045 | if (cap.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
6046 | return cap; never executed: return cap; | 0 | ||||||||||||||||||||||||||||||||||||
6047 | - | |||||||||||||||||||||||||||||||||||||
6048 | QLatin1String placeHolder("[*]"); | - | ||||||||||||||||||||||||||||||||||||
6049 | int index = cap.indexOf(placeHolder); | - | ||||||||||||||||||||||||||||||||||||
6050 | - | |||||||||||||||||||||||||||||||||||||
6051 | // here the magic begins | - | ||||||||||||||||||||||||||||||||||||
6052 | while (index != -1) {
| 0 | ||||||||||||||||||||||||||||||||||||
6053 | index += placeHolder.size(); | - | ||||||||||||||||||||||||||||||||||||
6054 | int count = 1; | - | ||||||||||||||||||||||||||||||||||||
6055 | while (cap.indexOf(placeHolder, index) == index) {
| 0 | ||||||||||||||||||||||||||||||||||||
6056 | ++count; | - | ||||||||||||||||||||||||||||||||||||
6057 | index += placeHolder.size(); | - | ||||||||||||||||||||||||||||||||||||
6058 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6059 | - | |||||||||||||||||||||||||||||||||||||
6060 | if (count%2) { // odd number of [*] -> replace last one
| 0 | ||||||||||||||||||||||||||||||||||||
6061 | int lastIndex = cap.lastIndexOf(placeHolder, index - 1); | - | ||||||||||||||||||||||||||||||||||||
6062 | if (widget->isWindowModified()
| 0 | ||||||||||||||||||||||||||||||||||||
6063 | && widget->style()->styleHint(QStyle::SH_TitleBar_ModifyNotification, 0, widget))
| 0 | ||||||||||||||||||||||||||||||||||||
6064 | cap.replace(lastIndex, 3, QWidget::tr("*")); never executed: cap.replace(lastIndex, 3, QWidget::tr("*")); | 0 | ||||||||||||||||||||||||||||||||||||
6065 | else | - | ||||||||||||||||||||||||||||||||||||
6066 | cap.remove(lastIndex, 3); never executed: cap.remove(lastIndex, 3); | 0 | ||||||||||||||||||||||||||||||||||||
6067 | } | - | ||||||||||||||||||||||||||||||||||||
6068 | - | |||||||||||||||||||||||||||||||||||||
6069 | index = cap.indexOf(placeHolder, index); | - | ||||||||||||||||||||||||||||||||||||
6070 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6071 | - | |||||||||||||||||||||||||||||||||||||
6072 | cap.replace(QLatin1String("[*][*]"), placeHolder); | - | ||||||||||||||||||||||||||||||||||||
6073 | - | |||||||||||||||||||||||||||||||||||||
6074 | return cap; never executed: return cap; | 0 | ||||||||||||||||||||||||||||||||||||
6075 | } | - | ||||||||||||||||||||||||||||||||||||
6076 | - | |||||||||||||||||||||||||||||||||||||
6077 | void QWidgetPrivate::setWindowTitle_helper(const QString &title) | - | ||||||||||||||||||||||||||||||||||||
6078 | { | - | ||||||||||||||||||||||||||||||||||||
6079 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6080 | if (q->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
6081 | setWindowTitle_sys(qt_setWindowTitle_helperHelper(title, q)); never executed: setWindowTitle_sys(qt_setWindowTitle_helperHelper(title, q)); | 0 | ||||||||||||||||||||||||||||||||||||
6082 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6083 | - | |||||||||||||||||||||||||||||||||||||
6084 | void QWidgetPrivate::setWindowTitle_sys(const QString &caption) | - | ||||||||||||||||||||||||||||||||||||
6085 | { | - | ||||||||||||||||||||||||||||||||||||
6086 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6087 | if (!q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
6088 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6089 | - | |||||||||||||||||||||||||||||||||||||
6090 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
6091 | window->setTitle(caption); never executed: window->setTitle(caption); | 0 | ||||||||||||||||||||||||||||||||||||
6092 | - | |||||||||||||||||||||||||||||||||||||
6093 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6094 | - | |||||||||||||||||||||||||||||||||||||
6095 | void QWidgetPrivate::setWindowIconText_helper(const QString &title) | - | ||||||||||||||||||||||||||||||||||||
6096 | { | - | ||||||||||||||||||||||||||||||||||||
6097 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6098 | if (q->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
6099 | setWindowIconText_sys(qt_setWindowTitle_helperHelper(title, q)); never executed: setWindowIconText_sys(qt_setWindowTitle_helperHelper(title, q)); | 0 | ||||||||||||||||||||||||||||||||||||
6100 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6101 | - | |||||||||||||||||||||||||||||||||||||
6102 | void QWidgetPrivate::setWindowIconText_sys(const QString &iconText) | - | ||||||||||||||||||||||||||||||||||||
6103 | { | - | ||||||||||||||||||||||||||||||||||||
6104 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6105 | // ### The QWidget property is deprecated, but the XCB window function is not. | - | ||||||||||||||||||||||||||||||||||||
6106 | // It should remain available for the rare application that needs it. | - | ||||||||||||||||||||||||||||||||||||
6107 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
6108 | QXcbWindowFunctions::setWmWindowIconText(window, iconText); never executed: QXcbWindowFunctions::setWmWindowIconText(window, iconText); | 0 | ||||||||||||||||||||||||||||||||||||
6109 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6110 | - | |||||||||||||||||||||||||||||||||||||
6111 | /*! | - | ||||||||||||||||||||||||||||||||||||
6112 | \fn void QWidget::windowIconTextChanged(const QString &iconText) | - | ||||||||||||||||||||||||||||||||||||
6113 | - | |||||||||||||||||||||||||||||||||||||
6114 | This signal is emitted when the window's icon text has changed, with the | - | ||||||||||||||||||||||||||||||||||||
6115 | new \a iconText as an argument. | - | ||||||||||||||||||||||||||||||||||||
6116 | - | |||||||||||||||||||||||||||||||||||||
6117 | \since 5.2 | - | ||||||||||||||||||||||||||||||||||||
6118 | \obsolete | - | ||||||||||||||||||||||||||||||||||||
6119 | - | |||||||||||||||||||||||||||||||||||||
6120 | This signal is deprecated. | - | ||||||||||||||||||||||||||||||||||||
6121 | */ | - | ||||||||||||||||||||||||||||||||||||
6122 | - | |||||||||||||||||||||||||||||||||||||
6123 | void QWidget::setWindowIconText(const QString &iconText) | - | ||||||||||||||||||||||||||||||||||||
6124 | { | - | ||||||||||||||||||||||||||||||||||||
6125 | if (QWidget::windowIconText() == iconText)
| 0 | ||||||||||||||||||||||||||||||||||||
6126 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6127 | - | |||||||||||||||||||||||||||||||||||||
6128 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6129 | d->topData()->iconText = iconText; | - | ||||||||||||||||||||||||||||||||||||
6130 | d->setWindowIconText_helper(iconText); | - | ||||||||||||||||||||||||||||||||||||
6131 | - | |||||||||||||||||||||||||||||||||||||
6132 | QEvent e(QEvent::IconTextChange); | - | ||||||||||||||||||||||||||||||||||||
6133 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
6134 | - | |||||||||||||||||||||||||||||||||||||
6135 | emit windowIconTextChanged(iconText); | - | ||||||||||||||||||||||||||||||||||||
6136 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6137 | - | |||||||||||||||||||||||||||||||||||||
6138 | /*! | - | ||||||||||||||||||||||||||||||||||||
6139 | \fn void QWidget::windowTitleChanged(const QString &title) | - | ||||||||||||||||||||||||||||||||||||
6140 | - | |||||||||||||||||||||||||||||||||||||
6141 | This signal is emitted when the window's title has changed, with the | - | ||||||||||||||||||||||||||||||||||||
6142 | new \a title as an argument. | - | ||||||||||||||||||||||||||||||||||||
6143 | - | |||||||||||||||||||||||||||||||||||||
6144 | \since 5.2 | - | ||||||||||||||||||||||||||||||||||||
6145 | */ | - | ||||||||||||||||||||||||||||||||||||
6146 | - | |||||||||||||||||||||||||||||||||||||
6147 | void QWidget::setWindowTitle(const QString &title) | - | ||||||||||||||||||||||||||||||||||||
6148 | { | - | ||||||||||||||||||||||||||||||||||||
6149 | if (QWidget::windowTitle() == title && !title.isEmpty() && !title.isNull())
| 0 | ||||||||||||||||||||||||||||||||||||
6150 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6151 | - | |||||||||||||||||||||||||||||||||||||
6152 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6153 | d->topData()->caption = title; | - | ||||||||||||||||||||||||||||||||||||
6154 | d->setWindowTitle_helper(title); | - | ||||||||||||||||||||||||||||||||||||
6155 | - | |||||||||||||||||||||||||||||||||||||
6156 | QEvent e(QEvent::WindowTitleChange); | - | ||||||||||||||||||||||||||||||||||||
6157 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
6158 | - | |||||||||||||||||||||||||||||||||||||
6159 | emit windowTitleChanged(title); | - | ||||||||||||||||||||||||||||||||||||
6160 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6161 | - | |||||||||||||||||||||||||||||||||||||
6162 | - | |||||||||||||||||||||||||||||||||||||
6163 | /*! | - | ||||||||||||||||||||||||||||||||||||
6164 | \property QWidget::windowIcon | - | ||||||||||||||||||||||||||||||||||||
6165 | \brief the widget's icon | - | ||||||||||||||||||||||||||||||||||||
6166 | - | |||||||||||||||||||||||||||||||||||||
6167 | This property only makes sense for windows. If no icon | - | ||||||||||||||||||||||||||||||||||||
6168 | has been set, windowIcon() returns the application icon | - | ||||||||||||||||||||||||||||||||||||
6169 | (QApplication::windowIcon()). | - | ||||||||||||||||||||||||||||||||||||
6170 | - | |||||||||||||||||||||||||||||||||||||
6171 | \sa windowTitle | - | ||||||||||||||||||||||||||||||||||||
6172 | */ | - | ||||||||||||||||||||||||||||||||||||
6173 | QIcon QWidget::windowIcon() const | - | ||||||||||||||||||||||||||||||||||||
6174 | { | - | ||||||||||||||||||||||||||||||||||||
6175 | const QWidget *w = this; | - | ||||||||||||||||||||||||||||||||||||
6176 | while (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
6177 | const QWidgetPrivate *d = w->d_func(); | - | ||||||||||||||||||||||||||||||||||||
6178 | if (d->extra && d->extra->topextra && d->extra->topextra->icon)
| 0 | ||||||||||||||||||||||||||||||||||||
6179 | return *d->extra->topextra->icon; never executed: return *d->extra->topextra->icon; | 0 | ||||||||||||||||||||||||||||||||||||
6180 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
6181 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6182 | return QApplication::windowIcon(); never executed: return QApplication::windowIcon(); | 0 | ||||||||||||||||||||||||||||||||||||
6183 | } | - | ||||||||||||||||||||||||||||||||||||
6184 | - | |||||||||||||||||||||||||||||||||||||
6185 | void QWidgetPrivate::setWindowIcon_helper() | - | ||||||||||||||||||||||||||||||||||||
6186 | { | - | ||||||||||||||||||||||||||||||||||||
6187 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6188 | QEvent e(QEvent::WindowIconChange); | - | ||||||||||||||||||||||||||||||||||||
6189 | - | |||||||||||||||||||||||||||||||||||||
6190 | // Do not send the event if the widget is a top level. | - | ||||||||||||||||||||||||||||||||||||
6191 | // In that case, setWindowIcon_sys does it, and event propagation from | - | ||||||||||||||||||||||||||||||||||||
6192 | // QWidgetWindow to the top level QWidget ensures that the event reaches | - | ||||||||||||||||||||||||||||||||||||
6193 | // the top level anyhow | - | ||||||||||||||||||||||||||||||||||||
6194 | if (!q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
6195 | QApplication::sendEvent(q, &e); never executed: QApplication::sendEvent(q, &e); | 0 | ||||||||||||||||||||||||||||||||||||
6196 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
6197 | QWidget *w = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
6198 | if (w && !w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
6199 | QApplication::sendEvent(w, &e); never executed: QApplication::sendEvent(w, &e); | 0 | ||||||||||||||||||||||||||||||||||||
6200 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6201 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6202 | - | |||||||||||||||||||||||||||||||||||||
6203 | /*! | - | ||||||||||||||||||||||||||||||||||||
6204 | \fn void QWidget::windowIconChanged(const QIcon &icon) | - | ||||||||||||||||||||||||||||||||||||
6205 | - | |||||||||||||||||||||||||||||||||||||
6206 | This signal is emitted when the window's icon has changed, with the | - | ||||||||||||||||||||||||||||||||||||
6207 | new \a icon as an argument. | - | ||||||||||||||||||||||||||||||||||||
6208 | - | |||||||||||||||||||||||||||||||||||||
6209 | \since 5.2 | - | ||||||||||||||||||||||||||||||||||||
6210 | */ | - | ||||||||||||||||||||||||||||||||||||
6211 | - | |||||||||||||||||||||||||||||||||||||
6212 | void QWidget::setWindowIcon(const QIcon &icon) | - | ||||||||||||||||||||||||||||||||||||
6213 | { | - | ||||||||||||||||||||||||||||||||||||
6214 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6215 | - | |||||||||||||||||||||||||||||||||||||
6216 | setAttribute(Qt::WA_SetWindowIcon, !icon.isNull()); | - | ||||||||||||||||||||||||||||||||||||
6217 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
6218 | - | |||||||||||||||||||||||||||||||||||||
6219 | if (!d->extra->topextra->icon)
| 0 | ||||||||||||||||||||||||||||||||||||
6220 | d->extra->topextra->icon = new QIcon(); never executed: d->extra->topextra->icon = new QIcon(); | 0 | ||||||||||||||||||||||||||||||||||||
6221 | *d->extra->topextra->icon = icon; | - | ||||||||||||||||||||||||||||||||||||
6222 | - | |||||||||||||||||||||||||||||||||||||
6223 | d->setWindowIcon_sys(); | - | ||||||||||||||||||||||||||||||||||||
6224 | d->setWindowIcon_helper(); | - | ||||||||||||||||||||||||||||||||||||
6225 | - | |||||||||||||||||||||||||||||||||||||
6226 | emit windowIconChanged(icon); | - | ||||||||||||||||||||||||||||||||||||
6227 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6228 | - | |||||||||||||||||||||||||||||||||||||
6229 | void QWidgetPrivate::setWindowIcon_sys() | - | ||||||||||||||||||||||||||||||||||||
6230 | { | - | ||||||||||||||||||||||||||||||||||||
6231 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6232 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
6233 | window->setIcon(q->windowIcon()); never executed: window->setIcon(q->windowIcon()); | 0 | ||||||||||||||||||||||||||||||||||||
6234 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6235 | - | |||||||||||||||||||||||||||||||||||||
6236 | /*! | - | ||||||||||||||||||||||||||||||||||||
6237 | \property QWidget::windowIconText | - | ||||||||||||||||||||||||||||||||||||
6238 | \brief the text to be displayed on the icon of a minimized window | - | ||||||||||||||||||||||||||||||||||||
6239 | - | |||||||||||||||||||||||||||||||||||||
6240 | This property only makes sense for windows. If no icon | - | ||||||||||||||||||||||||||||||||||||
6241 | text has been set, this accessor returns an empty string. | - | ||||||||||||||||||||||||||||||||||||
6242 | It is only implemented on the X11 platform, and only certain | - | ||||||||||||||||||||||||||||||||||||
6243 | window managers use this window property. | - | ||||||||||||||||||||||||||||||||||||
6244 | - | |||||||||||||||||||||||||||||||||||||
6245 | \obsolete | - | ||||||||||||||||||||||||||||||||||||
6246 | This property is deprecated. | - | ||||||||||||||||||||||||||||||||||||
6247 | - | |||||||||||||||||||||||||||||||||||||
6248 | \sa windowIcon, windowTitle | - | ||||||||||||||||||||||||||||||||||||
6249 | */ | - | ||||||||||||||||||||||||||||||||||||
6250 | - | |||||||||||||||||||||||||||||||||||||
6251 | QString QWidget::windowIconText() const | - | ||||||||||||||||||||||||||||||||||||
6252 | { | - | ||||||||||||||||||||||||||||||||||||
6253 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
6254 | 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 | ||||||||||||||||||||||||||||||||||||
6255 | } | - | ||||||||||||||||||||||||||||||||||||
6256 | - | |||||||||||||||||||||||||||||||||||||
6257 | /*! | - | ||||||||||||||||||||||||||||||||||||
6258 | \property QWidget::windowFilePath | - | ||||||||||||||||||||||||||||||||||||
6259 | \since 4.4 | - | ||||||||||||||||||||||||||||||||||||
6260 | \brief the file path associated with a widget | - | ||||||||||||||||||||||||||||||||||||
6261 | - | |||||||||||||||||||||||||||||||||||||
6262 | This property only makes sense for windows. It associates a file path with | - | ||||||||||||||||||||||||||||||||||||
6263 | a window. If you set the file path, but have not set the window title, Qt | - | ||||||||||||||||||||||||||||||||||||
6264 | sets the window title to the file name of the specified path, obtained using | - | ||||||||||||||||||||||||||||||||||||
6265 | QFileInfo::fileName(). | - | ||||||||||||||||||||||||||||||||||||
6266 | - | |||||||||||||||||||||||||||||||||||||
6267 | If the window title is set at any point, then the window title takes precedence and | - | ||||||||||||||||||||||||||||||||||||
6268 | will be shown instead of the file path string. | - | ||||||||||||||||||||||||||||||||||||
6269 | - | |||||||||||||||||||||||||||||||||||||
6270 | Additionally, on \macos, this has an added benefit that it sets the | - | ||||||||||||||||||||||||||||||||||||
6271 | \l{http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGWindows/chapter_17_section_3.html}{proxy icon} | - | ||||||||||||||||||||||||||||||||||||
6272 | for the window, assuming that the file path exists. | - | ||||||||||||||||||||||||||||||||||||
6273 | - | |||||||||||||||||||||||||||||||||||||
6274 | If no file path is set, this property contains an empty string. | - | ||||||||||||||||||||||||||||||||||||
6275 | - | |||||||||||||||||||||||||||||||||||||
6276 | By default, this property contains an empty string. | - | ||||||||||||||||||||||||||||||||||||
6277 | - | |||||||||||||||||||||||||||||||||||||
6278 | \sa windowTitle, windowIcon | - | ||||||||||||||||||||||||||||||||||||
6279 | */ | - | ||||||||||||||||||||||||||||||||||||
6280 | - | |||||||||||||||||||||||||||||||||||||
6281 | QString QWidget::windowFilePath() const | - | ||||||||||||||||||||||||||||||||||||
6282 | { | - | ||||||||||||||||||||||||||||||||||||
6283 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
6284 | 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 | ||||||||||||||||||||||||||||||||||||
6285 | } | - | ||||||||||||||||||||||||||||||||||||
6286 | - | |||||||||||||||||||||||||||||||||||||
6287 | void QWidget::setWindowFilePath(const QString &filePath) | - | ||||||||||||||||||||||||||||||||||||
6288 | { | - | ||||||||||||||||||||||||||||||||||||
6289 | if (filePath == windowFilePath())
| 0 | ||||||||||||||||||||||||||||||||||||
6290 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6291 | - | |||||||||||||||||||||||||||||||||||||
6292 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6293 | - | |||||||||||||||||||||||||||||||||||||
6294 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
6295 | d->extra->topextra->filePath = filePath; | - | ||||||||||||||||||||||||||||||||||||
6296 | d->setWindowFilePath_helper(filePath); | - | ||||||||||||||||||||||||||||||||||||
6297 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6298 | - | |||||||||||||||||||||||||||||||||||||
6299 | void QWidgetPrivate::setWindowFilePath_helper(const QString &filePath) | - | ||||||||||||||||||||||||||||||||||||
6300 | { | - | ||||||||||||||||||||||||||||||||||||
6301 | if (extra->topextra && extra->topextra->caption.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6302 | #ifdef Q_OS_MAC | - | ||||||||||||||||||||||||||||||||||||
6303 | setWindowTitle_helper(QFileInfo(filePath).fileName()); | - | ||||||||||||||||||||||||||||||||||||
6304 | #else | - | ||||||||||||||||||||||||||||||||||||
6305 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6306 | Q_UNUSED(filePath); | - | ||||||||||||||||||||||||||||||||||||
6307 | setWindowTitle_helper(q->windowTitle()); | - | ||||||||||||||||||||||||||||||||||||
6308 | #endif | - | ||||||||||||||||||||||||||||||||||||
6309 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6310 | #ifdef Q_OS_MAC | - | ||||||||||||||||||||||||||||||||||||
6311 | setWindowFilePath_sys(filePath); | - | ||||||||||||||||||||||||||||||||||||
6312 | #endif | - | ||||||||||||||||||||||||||||||||||||
6313 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6314 | - | |||||||||||||||||||||||||||||||||||||
6315 | void QWidgetPrivate::setWindowFilePath_sys(const QString &filePath) | - | ||||||||||||||||||||||||||||||||||||
6316 | { | - | ||||||||||||||||||||||||||||||||||||
6317 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6318 | if (!q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
6319 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6320 | - | |||||||||||||||||||||||||||||||||||||
6321 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
6322 | window->setFilePath(filePath); never executed: window->setFilePath(filePath); | 0 | ||||||||||||||||||||||||||||||||||||
6323 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6324 | - | |||||||||||||||||||||||||||||||||||||
6325 | /*! | - | ||||||||||||||||||||||||||||||||||||
6326 | Returns the window's role, or an empty string. | - | ||||||||||||||||||||||||||||||||||||
6327 | - | |||||||||||||||||||||||||||||||||||||
6328 | \sa windowIcon, windowTitle | - | ||||||||||||||||||||||||||||||||||||
6329 | */ | - | ||||||||||||||||||||||||||||||||||||
6330 | - | |||||||||||||||||||||||||||||||||||||
6331 | QString QWidget::windowRole() const | - | ||||||||||||||||||||||||||||||||||||
6332 | { | - | ||||||||||||||||||||||||||||||||||||
6333 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
6334 | 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 | ||||||||||||||||||||||||||||||||||||
6335 | } | - | ||||||||||||||||||||||||||||||||||||
6336 | - | |||||||||||||||||||||||||||||||||||||
6337 | /*! | - | ||||||||||||||||||||||||||||||||||||
6338 | Sets the window's role to \a role. This only makes sense for | - | ||||||||||||||||||||||||||||||||||||
6339 | windows on X11. | - | ||||||||||||||||||||||||||||||||||||
6340 | */ | - | ||||||||||||||||||||||||||||||||||||
6341 | void QWidget::setWindowRole(const QString &role) | - | ||||||||||||||||||||||||||||||||||||
6342 | { | - | ||||||||||||||||||||||||||||||||||||
6343 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6344 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
6345 | d->topData()->role = role; | - | ||||||||||||||||||||||||||||||||||||
6346 | if (windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
6347 | QXcbWindowFunctions::setWmWindowRole(windowHandle(), role.toLatin1()); never executed: QXcbWindowFunctions::setWmWindowRole(windowHandle(), role.toLatin1()); | 0 | ||||||||||||||||||||||||||||||||||||
6348 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6349 | - | |||||||||||||||||||||||||||||||||||||
6350 | /*! | - | ||||||||||||||||||||||||||||||||||||
6351 | \property QWidget::mouseTracking | - | ||||||||||||||||||||||||||||||||||||
6352 | \brief whether mouse tracking is enabled for the widget | - | ||||||||||||||||||||||||||||||||||||
6353 | - | |||||||||||||||||||||||||||||||||||||
6354 | If mouse tracking is disabled (the default), the widget only | - | ||||||||||||||||||||||||||||||||||||
6355 | receives mouse move events when at least one mouse button is | - | ||||||||||||||||||||||||||||||||||||
6356 | pressed while the mouse is being moved. | - | ||||||||||||||||||||||||||||||||||||
6357 | - | |||||||||||||||||||||||||||||||||||||
6358 | If mouse tracking is enabled, the widget receives mouse move | - | ||||||||||||||||||||||||||||||||||||
6359 | events even if no buttons are pressed. | - | ||||||||||||||||||||||||||||||||||||
6360 | - | |||||||||||||||||||||||||||||||||||||
6361 | \sa mouseMoveEvent() | - | ||||||||||||||||||||||||||||||||||||
6362 | */ | - | ||||||||||||||||||||||||||||||||||||
6363 | - | |||||||||||||||||||||||||||||||||||||
6364 | - | |||||||||||||||||||||||||||||||||||||
6365 | /*! | - | ||||||||||||||||||||||||||||||||||||
6366 | Sets the widget's focus proxy to widget \a w. If \a w is 0, the | - | ||||||||||||||||||||||||||||||||||||
6367 | function resets this widget to have no focus proxy. | - | ||||||||||||||||||||||||||||||||||||
6368 | - | |||||||||||||||||||||||||||||||||||||
6369 | Some widgets can "have focus", but create a child widget, such as | - | ||||||||||||||||||||||||||||||||||||
6370 | QLineEdit, to actually handle the focus. In this case, the widget | - | ||||||||||||||||||||||||||||||||||||
6371 | can set the line edit to be its focus proxy. | - | ||||||||||||||||||||||||||||||||||||
6372 | - | |||||||||||||||||||||||||||||||||||||
6373 | setFocusProxy() sets the widget which will actually get focus when | - | ||||||||||||||||||||||||||||||||||||
6374 | "this widget" gets it. If there is a focus proxy, setFocus() and | - | ||||||||||||||||||||||||||||||||||||
6375 | hasFocus() operate on the focus proxy. | - | ||||||||||||||||||||||||||||||||||||
6376 | - | |||||||||||||||||||||||||||||||||||||
6377 | \sa focusProxy() | - | ||||||||||||||||||||||||||||||||||||
6378 | */ | - | ||||||||||||||||||||||||||||||||||||
6379 | - | |||||||||||||||||||||||||||||||||||||
6380 | void QWidget::setFocusProxy(QWidget * w) | - | ||||||||||||||||||||||||||||||||||||
6381 | { | - | ||||||||||||||||||||||||||||||||||||
6382 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6383 | if (!w && !d->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
6384 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6385 | - | |||||||||||||||||||||||||||||||||||||
6386 | for (QWidget* fp = w; fp; fp = fp->focusProxy()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6387 | if (fp == this) {
| 0 | ||||||||||||||||||||||||||||||||||||
6388 | qWarning("QWidget: %s (%s) already in focus proxy chain", metaObject()->className(), objectName().toLocal8Bit().constData()); | - | ||||||||||||||||||||||||||||||||||||
6389 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6390 | } | - | ||||||||||||||||||||||||||||||||||||
6391 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6392 | - | |||||||||||||||||||||||||||||||||||||
6393 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
6394 | d->extra->focus_proxy = w; | - | ||||||||||||||||||||||||||||||||||||
6395 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6396 | - | |||||||||||||||||||||||||||||||||||||
6397 | - | |||||||||||||||||||||||||||||||||||||
6398 | /*! | - | ||||||||||||||||||||||||||||||||||||
6399 | Returns the focus proxy, or 0 if there is no focus proxy. | - | ||||||||||||||||||||||||||||||||||||
6400 | - | |||||||||||||||||||||||||||||||||||||
6401 | \sa setFocusProxy() | - | ||||||||||||||||||||||||||||||||||||
6402 | */ | - | ||||||||||||||||||||||||||||||||||||
6403 | - | |||||||||||||||||||||||||||||||||||||
6404 | QWidget * QWidget::focusProxy() const | - | ||||||||||||||||||||||||||||||||||||
6405 | { | - | ||||||||||||||||||||||||||||||||||||
6406 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
6407 | return d->extra ? (QWidget *)d->extra->focus_proxy : 0; never executed: return d->extra ? (QWidget *)d->extra->focus_proxy : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
6408 | } | - | ||||||||||||||||||||||||||||||||||||
6409 | - | |||||||||||||||||||||||||||||||||||||
6410 | - | |||||||||||||||||||||||||||||||||||||
6411 | /*! | - | ||||||||||||||||||||||||||||||||||||
6412 | \property QWidget::focus | - | ||||||||||||||||||||||||||||||||||||
6413 | \brief whether this widget (or its focus proxy) has the keyboard | - | ||||||||||||||||||||||||||||||||||||
6414 | input focus | - | ||||||||||||||||||||||||||||||||||||
6415 | - | |||||||||||||||||||||||||||||||||||||
6416 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
6417 | - | |||||||||||||||||||||||||||||||||||||
6418 | \note Obtaining the value of this property for a widget is effectively equivalent | - | ||||||||||||||||||||||||||||||||||||
6419 | to checking whether QApplication::focusWidget() refers to the widget. | - | ||||||||||||||||||||||||||||||||||||
6420 | - | |||||||||||||||||||||||||||||||||||||
6421 | \sa setFocus(), clearFocus(), setFocusPolicy(), QApplication::focusWidget() | - | ||||||||||||||||||||||||||||||||||||
6422 | */ | - | ||||||||||||||||||||||||||||||||||||
6423 | bool QWidget::hasFocus() const | - | ||||||||||||||||||||||||||||||||||||
6424 | { | - | ||||||||||||||||||||||||||||||||||||
6425 | const QWidget* w = this; | - | ||||||||||||||||||||||||||||||||||||
6426 | while (w->d_func()->extra && w->d_func()->extra->focus_proxy)
| 0 | ||||||||||||||||||||||||||||||||||||
6427 | w = w->d_func()->extra->focus_proxy; never executed: w = w->d_func()->extra->focus_proxy; | 0 | ||||||||||||||||||||||||||||||||||||
6428 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6429 | if (QWidget *window = w->window()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6430 | QWExtra *e = window->d_func()->extra; | - | ||||||||||||||||||||||||||||||||||||
6431 | if (e && e->proxyWidget && e->proxyWidget->hasFocus() && window->focusWidget() == w)
| 0 | ||||||||||||||||||||||||||||||||||||
6432 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
6433 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6434 | #endif // !QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6435 | return (QApplication::focusWidget() == w); never executed: return (QApplication::focusWidget() == w); | 0 | ||||||||||||||||||||||||||||||||||||
6436 | } | - | ||||||||||||||||||||||||||||||||||||
6437 | - | |||||||||||||||||||||||||||||||||||||
6438 | /*! | - | ||||||||||||||||||||||||||||||||||||
6439 | Gives the keyboard input focus to this widget (or its focus | - | ||||||||||||||||||||||||||||||||||||
6440 | proxy) if this widget or one of its parents is the \l{isActiveWindow()}{active window}. The \a reason argument will | - | ||||||||||||||||||||||||||||||||||||
6441 | be passed into any focus event sent from this function, it is used | - | ||||||||||||||||||||||||||||||||||||
6442 | to give an explanation of what caused the widget to get focus. | - | ||||||||||||||||||||||||||||||||||||
6443 | If the window is not active, the widget will be given the focus when | - | ||||||||||||||||||||||||||||||||||||
6444 | the window becomes active. | - | ||||||||||||||||||||||||||||||||||||
6445 | - | |||||||||||||||||||||||||||||||||||||
6446 | First, a focus about to change event is sent to the focus widget (if any) to | - | ||||||||||||||||||||||||||||||||||||
6447 | tell it that it is about to lose the focus. Then focus is changed, a | - | ||||||||||||||||||||||||||||||||||||
6448 | focus out event is sent to the previous focus item and a focus in event is sent | - | ||||||||||||||||||||||||||||||||||||
6449 | to the new item to tell it that it just received the focus. | - | ||||||||||||||||||||||||||||||||||||
6450 | (Nothing happens if the focus in and focus out widgets are the | - | ||||||||||||||||||||||||||||||||||||
6451 | same.) | - | ||||||||||||||||||||||||||||||||||||
6452 | - | |||||||||||||||||||||||||||||||||||||
6453 | \note On embedded platforms, setFocus() will not cause an input panel | - | ||||||||||||||||||||||||||||||||||||
6454 | to be opened by the input method. If you want this to happen, you | - | ||||||||||||||||||||||||||||||||||||
6455 | have to send a QEvent::RequestSoftwareInputPanel event to the | - | ||||||||||||||||||||||||||||||||||||
6456 | widget yourself. | - | ||||||||||||||||||||||||||||||||||||
6457 | - | |||||||||||||||||||||||||||||||||||||
6458 | setFocus() gives focus to a widget regardless of its focus policy, | - | ||||||||||||||||||||||||||||||||||||
6459 | but does not clear any keyboard grab (see grabKeyboard()). | - | ||||||||||||||||||||||||||||||||||||
6460 | - | |||||||||||||||||||||||||||||||||||||
6461 | Be aware that if the widget is hidden, it will not accept focus | - | ||||||||||||||||||||||||||||||||||||
6462 | until it is shown. | - | ||||||||||||||||||||||||||||||||||||
6463 | - | |||||||||||||||||||||||||||||||||||||
6464 | \warning If you call setFocus() in a function which may itself be | - | ||||||||||||||||||||||||||||||||||||
6465 | called from focusOutEvent() or focusInEvent(), you may get an | - | ||||||||||||||||||||||||||||||||||||
6466 | infinite recursion. | - | ||||||||||||||||||||||||||||||||||||
6467 | - | |||||||||||||||||||||||||||||||||||||
6468 | \sa hasFocus(), clearFocus(), focusInEvent(), focusOutEvent(), | - | ||||||||||||||||||||||||||||||||||||
6469 | setFocusPolicy(), focusWidget(), QApplication::focusWidget(), grabKeyboard(), | - | ||||||||||||||||||||||||||||||||||||
6470 | grabMouse(), {Keyboard Focus in Widgets}, QEvent::RequestSoftwareInputPanel | - | ||||||||||||||||||||||||||||||||||||
6471 | */ | - | ||||||||||||||||||||||||||||||||||||
6472 | - | |||||||||||||||||||||||||||||||||||||
6473 | void QWidget::setFocus(Qt::FocusReason reason) | - | ||||||||||||||||||||||||||||||||||||
6474 | { | - | ||||||||||||||||||||||||||||||||||||
6475 | if (!isEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
6476 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6477 | - | |||||||||||||||||||||||||||||||||||||
6478 | QWidget *f = this; | - | ||||||||||||||||||||||||||||||||||||
6479 | while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
| 0 | ||||||||||||||||||||||||||||||||||||
6480 | f = f->d_func()->extra->focus_proxy; never executed: f = f->d_func()->extra->focus_proxy; | 0 | ||||||||||||||||||||||||||||||||||||
6481 | - | |||||||||||||||||||||||||||||||||||||
6482 | if (QApplication::focusWidget() == f
| 0 | ||||||||||||||||||||||||||||||||||||
6483 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
6484 | && GetFocus() == f->internalWinId() | - | ||||||||||||||||||||||||||||||||||||
6485 | #endif | - | ||||||||||||||||||||||||||||||||||||
6486 | ) | - | ||||||||||||||||||||||||||||||||||||
6487 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6488 | - | |||||||||||||||||||||||||||||||||||||
6489 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6490 | QWidget *previousProxyFocus = 0; | - | ||||||||||||||||||||||||||||||||||||
6491 | if (QWExtra *topData = window()->d_func()->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
6492 | if (topData->proxyWidget && topData->proxyWidget->hasFocus()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6493 | previousProxyFocus = topData->proxyWidget->widget()->focusWidget(); | - | ||||||||||||||||||||||||||||||||||||
6494 | if (previousProxyFocus && previousProxyFocus->focusProxy())
| 0 | ||||||||||||||||||||||||||||||||||||
6495 | previousProxyFocus = previousProxyFocus->focusProxy(); never executed: previousProxyFocus = previousProxyFocus->focusProxy(); | 0 | ||||||||||||||||||||||||||||||||||||
6496 | if (previousProxyFocus == this && !topData->proxyWidget->d_func()->proxyIsGivingFocus)
| 0 | ||||||||||||||||||||||||||||||||||||
6497 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6498 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6499 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6500 | #endif | - | ||||||||||||||||||||||||||||||||||||
6501 | - | |||||||||||||||||||||||||||||||||||||
6502 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6503 | // Update proxy state | - | ||||||||||||||||||||||||||||||||||||
6504 | if (QWExtra *topData = window()->d_func()->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
6505 | if (topData->proxyWidget && !topData->proxyWidget->hasFocus()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6506 | f->d_func()->updateFocusChild(); | - | ||||||||||||||||||||||||||||||||||||
6507 | topData->proxyWidget->d_func()->focusFromWidgetToProxy = 1; | - | ||||||||||||||||||||||||||||||||||||
6508 | topData->proxyWidget->setFocus(reason); | - | ||||||||||||||||||||||||||||||||||||
6509 | topData->proxyWidget->d_func()->focusFromWidgetToProxy = 0; | - | ||||||||||||||||||||||||||||||||||||
6510 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6511 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6512 | #endif | - | ||||||||||||||||||||||||||||||||||||
6513 | - | |||||||||||||||||||||||||||||||||||||
6514 | if (f->isActiveWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6515 | QWidget *prev = QApplicationPrivate::focus_widget; | - | ||||||||||||||||||||||||||||||||||||
6516 | if (prev) {
| 0 | ||||||||||||||||||||||||||||||||||||
6517 | if (reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
| 0 | ||||||||||||||||||||||||||||||||||||
6518 | && prev->testAttribute(Qt::WA_InputMethodEnabled)) {
| 0 | ||||||||||||||||||||||||||||||||||||
6519 | QGuiApplication::inputMethod()->commit(); | - | ||||||||||||||||||||||||||||||||||||
6520 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6521 | - | |||||||||||||||||||||||||||||||||||||
6522 | if (reason != Qt::NoFocusReason) {
| 0 | ||||||||||||||||||||||||||||||||||||
6523 | QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, reason); | - | ||||||||||||||||||||||||||||||||||||
6524 | QApplication::sendEvent(prev, &focusAboutToChange); | - | ||||||||||||||||||||||||||||||||||||
6525 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6526 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6527 | - | |||||||||||||||||||||||||||||||||||||
6528 | f->d_func()->updateFocusChild(); | - | ||||||||||||||||||||||||||||||||||||
6529 | - | |||||||||||||||||||||||||||||||||||||
6530 | QApplicationPrivate::setFocusWidget(f, reason); | - | ||||||||||||||||||||||||||||||||||||
6531 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
6532 | # ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
6533 | // The negation of the condition in setFocus_sys | - | ||||||||||||||||||||||||||||||||||||
6534 | if (!(testAttribute(Qt::WA_WState_Created) && window()->windowType() != Qt::Popup && internalWinId())) | - | ||||||||||||||||||||||||||||||||||||
6535 | //setFocusWidget will already post a focus event for us (that the AT client receives) on Windows | - | ||||||||||||||||||||||||||||||||||||
6536 | # endif | - | ||||||||||||||||||||||||||||||||||||
6537 | // menus update the focus manually and this would create bogus events | - | ||||||||||||||||||||||||||||||||||||
6538 | if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem")))
| 0 | ||||||||||||||||||||||||||||||||||||
6539 | { | - | ||||||||||||||||||||||||||||||||||||
6540 | QAccessibleEvent event(f, QAccessible::Focus); | - | ||||||||||||||||||||||||||||||||||||
6541 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
6542 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6543 | #endif | - | ||||||||||||||||||||||||||||||||||||
6544 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6545 | if (QWExtra *topData = window()->d_func()->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
6546 | if (topData->proxyWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
6547 | if (previousProxyFocus && previousProxyFocus != f) {
| 0 | ||||||||||||||||||||||||||||||||||||
6548 | // Send event to self | - | ||||||||||||||||||||||||||||||||||||
6549 | QFocusEvent event(QEvent::FocusOut, reason); | - | ||||||||||||||||||||||||||||||||||||
6550 | QPointer<QWidget> that = previousProxyFocus; | - | ||||||||||||||||||||||||||||||||||||
6551 | QApplication::sendEvent(previousProxyFocus, &event); | - | ||||||||||||||||||||||||||||||||||||
6552 | if (that)
| 0 | ||||||||||||||||||||||||||||||||||||
6553 | QApplication::sendEvent(that->style(), &event); never executed: QApplication::sendEvent(that->style(), &event); | 0 | ||||||||||||||||||||||||||||||||||||
6554 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6555 | if (!isHidden()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6556 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6557 | // Update proxy state | - | ||||||||||||||||||||||||||||||||||||
6558 | if (QWExtra *topData = window()->d_func()->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
6559 | if (topData->proxyWidget && topData->proxyWidget->hasFocus())
| 0 | ||||||||||||||||||||||||||||||||||||
6560 | topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget(); never executed: topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget(); | 0 | ||||||||||||||||||||||||||||||||||||
6561 | #endif | - | ||||||||||||||||||||||||||||||||||||
6562 | // Send event to self | - | ||||||||||||||||||||||||||||||||||||
6563 | QFocusEvent event(QEvent::FocusIn, reason); | - | ||||||||||||||||||||||||||||||||||||
6564 | QPointer<QWidget> that = f; | - | ||||||||||||||||||||||||||||||||||||
6565 | QApplication::sendEvent(f, &event); | - | ||||||||||||||||||||||||||||||||||||
6566 | if (that)
| 0 | ||||||||||||||||||||||||||||||||||||
6567 | QApplication::sendEvent(that->style(), &event); never executed: QApplication::sendEvent(that->style(), &event); | 0 | ||||||||||||||||||||||||||||||||||||
6568 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6569 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6570 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6571 | #endif | - | ||||||||||||||||||||||||||||||||||||
6572 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6573 | f->d_func()->updateFocusChild(); | - | ||||||||||||||||||||||||||||||||||||
6574 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6575 | - | |||||||||||||||||||||||||||||||||||||
6576 | if (QTLWExtra *extra = f->window()->d_func()->maybeTopData()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6577 | if (extra->window)
| 0 | ||||||||||||||||||||||||||||||||||||
6578 | emit extra->window->focusObjectChanged(f); never executed: extra->window->focusObjectChanged(f); | 0 | ||||||||||||||||||||||||||||||||||||
6579 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6580 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6581 | - | |||||||||||||||||||||||||||||||||||||
6582 | void QWidgetPrivate::setFocus_sys() | - | ||||||||||||||||||||||||||||||||||||
6583 | { | - | ||||||||||||||||||||||||||||||||||||
6584 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6585 | // Embedded native widget may have taken the focus; get it back to toplevel if that is the case | - | ||||||||||||||||||||||||||||||||||||
6586 | const QWidget *topLevel = q->window(); | - | ||||||||||||||||||||||||||||||||||||
6587 | if (topLevel->windowType() != Qt::Popup) {
| 0 | ||||||||||||||||||||||||||||||||||||
6588 | if (QWindow *nativeWindow = q->window()->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6589 | if (nativeWindow != QGuiApplication::focusWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
6590 | && q->testAttribute(Qt::WA_WState_Created)) {
| 0 | ||||||||||||||||||||||||||||||||||||
6591 | nativeWindow->requestActivate(); | - | ||||||||||||||||||||||||||||||||||||
6592 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6593 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6594 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6595 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6596 | - | |||||||||||||||||||||||||||||||||||||
6597 | // updates focus_child on parent widgets to point into this widget | - | ||||||||||||||||||||||||||||||||||||
6598 | void QWidgetPrivate::updateFocusChild() | - | ||||||||||||||||||||||||||||||||||||
6599 | { | - | ||||||||||||||||||||||||||||||||||||
6600 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6601 | - | |||||||||||||||||||||||||||||||||||||
6602 | QWidget *w = q; | - | ||||||||||||||||||||||||||||||||||||
6603 | if (q->isHidden()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6604 | while (w && w->isHidden()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6605 | w->d_func()->focus_child = q; | - | ||||||||||||||||||||||||||||||||||||
6606 | w = w->isWindow() ? 0 : w->parentWidget();
| 0 | ||||||||||||||||||||||||||||||||||||
6607 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6608 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6609 | while (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
6610 | w->d_func()->focus_child = q; | - | ||||||||||||||||||||||||||||||||||||
6611 | w = w->isWindow() ? 0 : w->parentWidget();
| 0 | ||||||||||||||||||||||||||||||||||||
6612 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6613 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6614 | } | - | ||||||||||||||||||||||||||||||||||||
6615 | - | |||||||||||||||||||||||||||||||||||||
6616 | /*! | - | ||||||||||||||||||||||||||||||||||||
6617 | \fn void QWidget::setFocus() | - | ||||||||||||||||||||||||||||||||||||
6618 | \overload | - | ||||||||||||||||||||||||||||||||||||
6619 | - | |||||||||||||||||||||||||||||||||||||
6620 | Gives the keyboard input focus to this widget (or its focus | - | ||||||||||||||||||||||||||||||||||||
6621 | proxy) if this widget or one of its parents is the | - | ||||||||||||||||||||||||||||||||||||
6622 | \l{isActiveWindow()}{active window}. | - | ||||||||||||||||||||||||||||||||||||
6623 | */ | - | ||||||||||||||||||||||||||||||||||||
6624 | - | |||||||||||||||||||||||||||||||||||||
6625 | /*! | - | ||||||||||||||||||||||||||||||||||||
6626 | Takes keyboard input focus from the widget. | - | ||||||||||||||||||||||||||||||||||||
6627 | - | |||||||||||||||||||||||||||||||||||||
6628 | If the widget has active focus, a \l{focusOutEvent()}{focus out event} is sent to this widget to tell it that it has | - | ||||||||||||||||||||||||||||||||||||
6629 | lost the focus. | - | ||||||||||||||||||||||||||||||||||||
6630 | - | |||||||||||||||||||||||||||||||||||||
6631 | This widget must enable focus setting in order to get the keyboard | - | ||||||||||||||||||||||||||||||||||||
6632 | input focus, i.e. it must call setFocusPolicy(). | - | ||||||||||||||||||||||||||||||||||||
6633 | - | |||||||||||||||||||||||||||||||||||||
6634 | \sa hasFocus(), setFocus(), focusInEvent(), focusOutEvent(), | - | ||||||||||||||||||||||||||||||||||||
6635 | setFocusPolicy(), QApplication::focusWidget() | - | ||||||||||||||||||||||||||||||||||||
6636 | */ | - | ||||||||||||||||||||||||||||||||||||
6637 | - | |||||||||||||||||||||||||||||||||||||
6638 | void QWidget::clearFocus() | - | ||||||||||||||||||||||||||||||||||||
6639 | { | - | ||||||||||||||||||||||||||||||||||||
6640 | if (hasFocus()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6641 | if (testAttribute(Qt::WA_InputMethodEnabled))
| 0 | ||||||||||||||||||||||||||||||||||||
6642 | QGuiApplication::inputMethod()->commit(); never executed: QGuiApplication::inputMethod()->commit(); | 0 | ||||||||||||||||||||||||||||||||||||
6643 | - | |||||||||||||||||||||||||||||||||||||
6644 | QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); | - | ||||||||||||||||||||||||||||||||||||
6645 | QApplication::sendEvent(this, &focusAboutToChange); | - | ||||||||||||||||||||||||||||||||||||
6646 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6647 | - | |||||||||||||||||||||||||||||||||||||
6648 | QWidget *w = this; | - | ||||||||||||||||||||||||||||||||||||
6649 | while (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
6650 | // Just like setFocus(), we update (clear) the focus_child of our parents | - | ||||||||||||||||||||||||||||||||||||
6651 | if (w->d_func()->focus_child == this)
| 0 | ||||||||||||||||||||||||||||||||||||
6652 | w->d_func()->focus_child = 0; never executed: w->d_func()->focus_child = 0; | 0 | ||||||||||||||||||||||||||||||||||||
6653 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
6654 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6655 | // Since focus_child is the basis for the top level QWidgetWindow's focusObject() | - | ||||||||||||||||||||||||||||||||||||
6656 | // we need to report this change to the rest of Qt, but we match setFocus() and | - | ||||||||||||||||||||||||||||||||||||
6657 | // do it at the end of the function. | - | ||||||||||||||||||||||||||||||||||||
6658 | - | |||||||||||||||||||||||||||||||||||||
6659 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6660 | QWExtra *topData = d_func()->extra; | - | ||||||||||||||||||||||||||||||||||||
6661 | if (topData && topData->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
6662 | topData->proxyWidget->clearFocus(); never executed: topData->proxyWidget->clearFocus(); | 0 | ||||||||||||||||||||||||||||||||||||
6663 | #endif | - | ||||||||||||||||||||||||||||||||||||
6664 | - | |||||||||||||||||||||||||||||||||||||
6665 | if (hasFocus()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6666 | // Update proxy state | - | ||||||||||||||||||||||||||||||||||||
6667 | QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason); | - | ||||||||||||||||||||||||||||||||||||
6668 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
6669 | if (!(windowType() == Qt::Popup) && GetFocus() == internalWinId()) | - | ||||||||||||||||||||||||||||||||||||
6670 | SetFocus(0); | - | ||||||||||||||||||||||||||||||||||||
6671 | else | - | ||||||||||||||||||||||||||||||||||||
6672 | #endif | - | ||||||||||||||||||||||||||||||||||||
6673 | { | - | ||||||||||||||||||||||||||||||||||||
6674 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
6675 | QAccessibleEvent event(this, QAccessible::Focus); | - | ||||||||||||||||||||||||||||||||||||
6676 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
6677 | #endif | - | ||||||||||||||||||||||||||||||||||||
6678 | } | - | ||||||||||||||||||||||||||||||||||||
6679 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6680 | - | |||||||||||||||||||||||||||||||||||||
6681 | // Since we've unconditionally cleared the focus_child of our parents, we need | - | ||||||||||||||||||||||||||||||||||||
6682 | // to report this to the rest of Qt. Note that the focus_child is not the same | - | ||||||||||||||||||||||||||||||||||||
6683 | // thing as the application's focusWidget, which is why this piece of code is | - | ||||||||||||||||||||||||||||||||||||
6684 | // not inside the hasFocus() block above. | - | ||||||||||||||||||||||||||||||||||||
6685 | if (QTLWExtra *extra = window()->d_func()->maybeTopData()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6686 | if (extra->window)
| 0 | ||||||||||||||||||||||||||||||||||||
6687 | emit extra->window->focusObjectChanged(extra->window->focusObject()); never executed: extra->window->focusObjectChanged(extra->window->focusObject()); | 0 | ||||||||||||||||||||||||||||||||||||
6688 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6689 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6690 | - | |||||||||||||||||||||||||||||||||||||
6691 | - | |||||||||||||||||||||||||||||||||||||
6692 | /*! | - | ||||||||||||||||||||||||||||||||||||
6693 | \fn bool QWidget::focusNextChild() | - | ||||||||||||||||||||||||||||||||||||
6694 | - | |||||||||||||||||||||||||||||||||||||
6695 | Finds a new widget to give the keyboard focus to, as appropriate | - | ||||||||||||||||||||||||||||||||||||
6696 | for \uicontrol Tab, and returns \c true if it can find a new widget, or | - | ||||||||||||||||||||||||||||||||||||
6697 | false if it can't. | - | ||||||||||||||||||||||||||||||||||||
6698 | - | |||||||||||||||||||||||||||||||||||||
6699 | \sa focusPreviousChild() | - | ||||||||||||||||||||||||||||||||||||
6700 | */ | - | ||||||||||||||||||||||||||||||||||||
6701 | - | |||||||||||||||||||||||||||||||||||||
6702 | /*! | - | ||||||||||||||||||||||||||||||||||||
6703 | \fn bool QWidget::focusPreviousChild() | - | ||||||||||||||||||||||||||||||||||||
6704 | - | |||||||||||||||||||||||||||||||||||||
6705 | Finds a new widget to give the keyboard focus to, as appropriate | - | ||||||||||||||||||||||||||||||||||||
6706 | for \uicontrol Shift+Tab, and returns \c true if it can find a new widget, | - | ||||||||||||||||||||||||||||||||||||
6707 | or false if it can't. | - | ||||||||||||||||||||||||||||||||||||
6708 | - | |||||||||||||||||||||||||||||||||||||
6709 | \sa focusNextChild() | - | ||||||||||||||||||||||||||||||||||||
6710 | */ | - | ||||||||||||||||||||||||||||||||||||
6711 | - | |||||||||||||||||||||||||||||||||||||
6712 | /*! | - | ||||||||||||||||||||||||||||||||||||
6713 | Finds a new widget to give the keyboard focus to, as appropriate | - | ||||||||||||||||||||||||||||||||||||
6714 | for Tab and Shift+Tab, and returns \c true if it can find a new | - | ||||||||||||||||||||||||||||||||||||
6715 | widget, or false if it can't. | - | ||||||||||||||||||||||||||||||||||||
6716 | - | |||||||||||||||||||||||||||||||||||||
6717 | If \a next is true, this function searches forward, if \a next | - | ||||||||||||||||||||||||||||||||||||
6718 | is false, it searches backward. | - | ||||||||||||||||||||||||||||||||||||
6719 | - | |||||||||||||||||||||||||||||||||||||
6720 | Sometimes, you will want to reimplement this function. For | - | ||||||||||||||||||||||||||||||||||||
6721 | example, a web browser might reimplement it to move its "current | - | ||||||||||||||||||||||||||||||||||||
6722 | active link" forward or backward, and call | - | ||||||||||||||||||||||||||||||||||||
6723 | focusNextPrevChild() only when it reaches the last or | - | ||||||||||||||||||||||||||||||||||||
6724 | first link on the "page". | - | ||||||||||||||||||||||||||||||||||||
6725 | - | |||||||||||||||||||||||||||||||||||||
6726 | Child widgets call focusNextPrevChild() on their parent widgets, | - | ||||||||||||||||||||||||||||||||||||
6727 | but only the window that contains the child widgets decides where | - | ||||||||||||||||||||||||||||||||||||
6728 | to redirect focus. By reimplementing this function for an object, | - | ||||||||||||||||||||||||||||||||||||
6729 | you thus gain control of focus traversal for all child widgets. | - | ||||||||||||||||||||||||||||||||||||
6730 | - | |||||||||||||||||||||||||||||||||||||
6731 | \sa focusNextChild(), focusPreviousChild() | - | ||||||||||||||||||||||||||||||||||||
6732 | */ | - | ||||||||||||||||||||||||||||||||||||
6733 | - | |||||||||||||||||||||||||||||||||||||
6734 | bool QWidget::focusNextPrevChild(bool next) | - | ||||||||||||||||||||||||||||||||||||
6735 | { | - | ||||||||||||||||||||||||||||||||||||
6736 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6737 | QWidget* p = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
6738 | bool isSubWindow = (windowType() == Qt::SubWindow); | - | ||||||||||||||||||||||||||||||||||||
6739 | if (!isWindow() && !isSubWindow && p)
| 0 | ||||||||||||||||||||||||||||||||||||
6740 | return p->focusNextPrevChild(next); never executed: return p->focusNextPrevChild(next); | 0 | ||||||||||||||||||||||||||||||||||||
6741 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6742 | if (d->extra && d->extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
6743 | return d->extra->proxyWidget->focusNextPrevChild(next); never executed: return d->extra->proxyWidget->focusNextPrevChild(next); | 0 | ||||||||||||||||||||||||||||||||||||
6744 | #endif | - | ||||||||||||||||||||||||||||||||||||
6745 | - | |||||||||||||||||||||||||||||||||||||
6746 | bool wrappingOccurred = false; | - | ||||||||||||||||||||||||||||||||||||
6747 | QWidget *w = QApplicationPrivate::focusNextPrevChild_helper(this, next, | - | ||||||||||||||||||||||||||||||||||||
6748 | &wrappingOccurred); | - | ||||||||||||||||||||||||||||||||||||
6749 | if (!w) return false; never executed: return false;
| 0 | ||||||||||||||||||||||||||||||||||||
6750 | - | |||||||||||||||||||||||||||||||||||||
6751 | Qt::FocusReason reason = next ? Qt::TabFocusReason : Qt::BacktabFocusReason;
| 0 | ||||||||||||||||||||||||||||||||||||
6752 | - | |||||||||||||||||||||||||||||||||||||
6753 | /* If we are about to wrap the focus chain, give the platform | - | ||||||||||||||||||||||||||||||||||||
6754 | * implementation a chance to alter the wrapping behavior. This is | - | ||||||||||||||||||||||||||||||||||||
6755 | * especially needed when the window is embedded in a window created by | - | ||||||||||||||||||||||||||||||||||||
6756 | * another process. | - | ||||||||||||||||||||||||||||||||||||
6757 | */ | - | ||||||||||||||||||||||||||||||||||||
6758 | if (wrappingOccurred) {
| 0 | ||||||||||||||||||||||||||||||||||||
6759 | QWindow *window = windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
6760 | if (window != 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
6761 | QWindowPrivate *winp = qt_window_private(window); | - | ||||||||||||||||||||||||||||||||||||
6762 | - | |||||||||||||||||||||||||||||||||||||
6763 | if (winp->platformWindow != 0) {
| 0 | ||||||||||||||||||||||||||||||||||||
6764 | QFocusEvent event(QEvent::FocusIn, reason); | - | ||||||||||||||||||||||||||||||||||||
6765 | event.ignore(); | - | ||||||||||||||||||||||||||||||||||||
6766 | winp->platformWindow->windowEvent(&event); | - | ||||||||||||||||||||||||||||||||||||
6767 | if (event.isAccepted()) return true; never executed: return true;
| 0 | ||||||||||||||||||||||||||||||||||||
6768 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6769 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6770 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6771 | - | |||||||||||||||||||||||||||||||||||||
6772 | w->setFocus(reason); | - | ||||||||||||||||||||||||||||||||||||
6773 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
6774 | } | - | ||||||||||||||||||||||||||||||||||||
6775 | - | |||||||||||||||||||||||||||||||||||||
6776 | /*! | - | ||||||||||||||||||||||||||||||||||||
6777 | Returns the last child of this widget that setFocus had been | - | ||||||||||||||||||||||||||||||||||||
6778 | called on. For top level widgets this is the widget that will get | - | ||||||||||||||||||||||||||||||||||||
6779 | focus in case this window gets activated | - | ||||||||||||||||||||||||||||||||||||
6780 | - | |||||||||||||||||||||||||||||||||||||
6781 | This is not the same as QApplication::focusWidget(), which returns | - | ||||||||||||||||||||||||||||||||||||
6782 | the focus widget in the currently active window. | - | ||||||||||||||||||||||||||||||||||||
6783 | */ | - | ||||||||||||||||||||||||||||||||||||
6784 | - | |||||||||||||||||||||||||||||||||||||
6785 | QWidget *QWidget::focusWidget() const | - | ||||||||||||||||||||||||||||||||||||
6786 | { | - | ||||||||||||||||||||||||||||||||||||
6787 | return const_cast<QWidget *>(d_func()->focus_child); never executed: return const_cast<QWidget *>(d_func()->focus_child); | 0 | ||||||||||||||||||||||||||||||||||||
6788 | } | - | ||||||||||||||||||||||||||||||||||||
6789 | - | |||||||||||||||||||||||||||||||||||||
6790 | /*! | - | ||||||||||||||||||||||||||||||||||||
6791 | Returns the next widget in this widget's focus chain. | - | ||||||||||||||||||||||||||||||||||||
6792 | - | |||||||||||||||||||||||||||||||||||||
6793 | \sa previousInFocusChain() | - | ||||||||||||||||||||||||||||||||||||
6794 | */ | - | ||||||||||||||||||||||||||||||||||||
6795 | QWidget *QWidget::nextInFocusChain() const | - | ||||||||||||||||||||||||||||||||||||
6796 | { | - | ||||||||||||||||||||||||||||||||||||
6797 | return const_cast<QWidget *>(d_func()->focus_next); never executed: return const_cast<QWidget *>(d_func()->focus_next); | 0 | ||||||||||||||||||||||||||||||||||||
6798 | } | - | ||||||||||||||||||||||||||||||||||||
6799 | - | |||||||||||||||||||||||||||||||||||||
6800 | /*! | - | ||||||||||||||||||||||||||||||||||||
6801 | \brief The previousInFocusChain function returns the previous | - | ||||||||||||||||||||||||||||||||||||
6802 | widget in this widget's focus chain. | - | ||||||||||||||||||||||||||||||||||||
6803 | - | |||||||||||||||||||||||||||||||||||||
6804 | \sa nextInFocusChain() | - | ||||||||||||||||||||||||||||||||||||
6805 | - | |||||||||||||||||||||||||||||||||||||
6806 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
6807 | */ | - | ||||||||||||||||||||||||||||||||||||
6808 | QWidget *QWidget::previousInFocusChain() const | - | ||||||||||||||||||||||||||||||||||||
6809 | { | - | ||||||||||||||||||||||||||||||||||||
6810 | return const_cast<QWidget *>(d_func()->focus_prev); never executed: return const_cast<QWidget *>(d_func()->focus_prev); | 0 | ||||||||||||||||||||||||||||||||||||
6811 | } | - | ||||||||||||||||||||||||||||||||||||
6812 | - | |||||||||||||||||||||||||||||||||||||
6813 | /*! | - | ||||||||||||||||||||||||||||||||||||
6814 | \property QWidget::isActiveWindow | - | ||||||||||||||||||||||||||||||||||||
6815 | \brief whether this widget's window is the active window | - | ||||||||||||||||||||||||||||||||||||
6816 | - | |||||||||||||||||||||||||||||||||||||
6817 | The active window is the window that contains the widget that has | - | ||||||||||||||||||||||||||||||||||||
6818 | keyboard focus (The window may still have focus if it has no | - | ||||||||||||||||||||||||||||||||||||
6819 | widgets or none of its widgets accepts keyboard focus). | - | ||||||||||||||||||||||||||||||||||||
6820 | - | |||||||||||||||||||||||||||||||||||||
6821 | When popup windows are visible, this property is \c true for both the | - | ||||||||||||||||||||||||||||||||||||
6822 | active window \e and for the popup. | - | ||||||||||||||||||||||||||||||||||||
6823 | - | |||||||||||||||||||||||||||||||||||||
6824 | By default, this property is \c false. | - | ||||||||||||||||||||||||||||||||||||
6825 | - | |||||||||||||||||||||||||||||||||||||
6826 | \sa activateWindow(), QApplication::activeWindow() | - | ||||||||||||||||||||||||||||||||||||
6827 | */ | - | ||||||||||||||||||||||||||||||||||||
6828 | bool QWidget::isActiveWindow() const | - | ||||||||||||||||||||||||||||||||||||
6829 | { | - | ||||||||||||||||||||||||||||||||||||
6830 | QWidget *tlw = window(); | - | ||||||||||||||||||||||||||||||||||||
6831 | if(tlw == QApplication::activeWindow() || (isVisible() && (tlw->windowType() == Qt::Popup)))
| 0 | ||||||||||||||||||||||||||||||||||||
6832 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
6833 | - | |||||||||||||||||||||||||||||||||||||
6834 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
6835 | if (QWExtra *tlwExtra = tlw->d_func()->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
6836 | if (isVisible() && tlwExtra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
6837 | return tlwExtra->proxyWidget->isActiveWindow(); never executed: return tlwExtra->proxyWidget->isActiveWindow(); | 0 | ||||||||||||||||||||||||||||||||||||
6838 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6839 | #endif | - | ||||||||||||||||||||||||||||||||||||
6840 | - | |||||||||||||||||||||||||||||||||||||
6841 | if(style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, this)) {
| 0 | ||||||||||||||||||||||||||||||||||||
6842 | if(tlw->windowType() == Qt::Tool &&
| 0 | ||||||||||||||||||||||||||||||||||||
6843 | !tlw->isModal() &&
| 0 | ||||||||||||||||||||||||||||||||||||
6844 | (!tlw->parentWidget() || tlw->parentWidget()->isActiveWindow()))
| 0 | ||||||||||||||||||||||||||||||||||||
6845 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
6846 | QWidget *w = QApplication::activeWindow(); | - | ||||||||||||||||||||||||||||||||||||
6847 | while(w && tlw->windowType() == Qt::Tool &&
| 0 | ||||||||||||||||||||||||||||||||||||
6848 | !w->isModal() && w->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6849 | w = w->parentWidget()->window(); | - | ||||||||||||||||||||||||||||||||||||
6850 | if(w == tlw)
| 0 | ||||||||||||||||||||||||||||||||||||
6851 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
6852 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6853 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6854 | - | |||||||||||||||||||||||||||||||||||||
6855 | // Check for an active window container | - | ||||||||||||||||||||||||||||||||||||
6856 | if (QWindow *ww = QGuiApplication::focusWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6857 | while (ww) {
| 0 | ||||||||||||||||||||||||||||||||||||
6858 | QWidgetWindow *qww = qobject_cast<QWidgetWindow *>(ww); | - | ||||||||||||||||||||||||||||||||||||
6859 | QWindowContainer *qwc = qww ? qobject_cast<QWindowContainer *>(qww->widget()) : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
6860 | if (qwc && qwc->topLevelWidget() == tlw)
| 0 | ||||||||||||||||||||||||||||||||||||
6861 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
6862 | ww = ww->parent(); | - | ||||||||||||||||||||||||||||||||||||
6863 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6864 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6865 | - | |||||||||||||||||||||||||||||||||||||
6866 | // Check if platform adaptation thinks the window is active. This is necessary for | - | ||||||||||||||||||||||||||||||||||||
6867 | // example in case of ActiveQt servers that are embedded into another application. | - | ||||||||||||||||||||||||||||||||||||
6868 | // Those are separate processes that are not part of the parent application Qt window/widget | - | ||||||||||||||||||||||||||||||||||||
6869 | // hierarchy, so they need to rely on native methods to determine if they are part of the | - | ||||||||||||||||||||||||||||||||||||
6870 | // active window. | - | ||||||||||||||||||||||||||||||||||||
6871 | if (const QWindow *w = tlw->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6872 | if (w->handle())
| 0 | ||||||||||||||||||||||||||||||||||||
6873 | return w->handle()->isActive(); never executed: return w->handle()->isActive(); | 0 | ||||||||||||||||||||||||||||||||||||
6874 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6875 | - | |||||||||||||||||||||||||||||||||||||
6876 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
6877 | } | - | ||||||||||||||||||||||||||||||||||||
6878 | - | |||||||||||||||||||||||||||||||||||||
6879 | /*! | - | ||||||||||||||||||||||||||||||||||||
6880 | Puts the \a second widget after the \a first widget in the focus order. | - | ||||||||||||||||||||||||||||||||||||
6881 | - | |||||||||||||||||||||||||||||||||||||
6882 | Note that since the tab order of the \a second widget is changed, you | - | ||||||||||||||||||||||||||||||||||||
6883 | should order a chain like this: | - | ||||||||||||||||||||||||||||||||||||
6884 | - | |||||||||||||||||||||||||||||||||||||
6885 | \snippet code/src_gui_kernel_qwidget.cpp 9 | - | ||||||||||||||||||||||||||||||||||||
6886 | - | |||||||||||||||||||||||||||||||||||||
6887 | \e not like this: | - | ||||||||||||||||||||||||||||||||||||
6888 | - | |||||||||||||||||||||||||||||||||||||
6889 | \snippet code/src_gui_kernel_qwidget.cpp 10 | - | ||||||||||||||||||||||||||||||||||||
6890 | - | |||||||||||||||||||||||||||||||||||||
6891 | If \a first or \a second has a focus proxy, setTabOrder() | - | ||||||||||||||||||||||||||||||||||||
6892 | correctly substitutes the proxy. | - | ||||||||||||||||||||||||||||||||||||
6893 | - | |||||||||||||||||||||||||||||||||||||
6894 | \sa setFocusPolicy(), setFocusProxy(), {Keyboard Focus in Widgets} | - | ||||||||||||||||||||||||||||||||||||
6895 | */ | - | ||||||||||||||||||||||||||||||||||||
6896 | void QWidget::setTabOrder(QWidget* first, QWidget *second) | - | ||||||||||||||||||||||||||||||||||||
6897 | { | - | ||||||||||||||||||||||||||||||||||||
6898 | if (!first || !second || first->focusPolicy() == Qt::NoFocus || second->focusPolicy() == Qt::NoFocus)
| 0 | ||||||||||||||||||||||||||||||||||||
6899 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6900 | - | |||||||||||||||||||||||||||||||||||||
6901 | if (first->window() != second->window()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6902 | qWarning("QWidget::setTabOrder: 'first' and 'second' must be in the same window"); | - | ||||||||||||||||||||||||||||||||||||
6903 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6904 | } | - | ||||||||||||||||||||||||||||||||||||
6905 | - | |||||||||||||||||||||||||||||||||||||
6906 | QWidget *fp = first->focusProxy(); | - | ||||||||||||||||||||||||||||||||||||
6907 | if (fp) {
| 0 | ||||||||||||||||||||||||||||||||||||
6908 | // If first is redirected, set first to the last child of first | - | ||||||||||||||||||||||||||||||||||||
6909 | // that can take keyboard focus so that second is inserted after | - | ||||||||||||||||||||||||||||||||||||
6910 | // that last child, and the focus order within first is (more | - | ||||||||||||||||||||||||||||||||||||
6911 | // likely to be) preserved. | - | ||||||||||||||||||||||||||||||||||||
6912 | QList<QWidget *> l = first->findChildren<QWidget *>(); | - | ||||||||||||||||||||||||||||||||||||
6913 | for (int i = l.size()-1; i >= 0; --i) {
| 0 | ||||||||||||||||||||||||||||||||||||
6914 | QWidget * next = l.at(i); | - | ||||||||||||||||||||||||||||||||||||
6915 | if (next->window() == fp->window()) {
| 0 | ||||||||||||||||||||||||||||||||||||
6916 | fp = next; | - | ||||||||||||||||||||||||||||||||||||
6917 | if (fp->focusPolicy() != Qt::NoFocus)
| 0 | ||||||||||||||||||||||||||||||||||||
6918 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
6919 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6920 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6921 | first = fp; | - | ||||||||||||||||||||||||||||||||||||
6922 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6923 | - | |||||||||||||||||||||||||||||||||||||
6924 | if (fp == second)
| 0 | ||||||||||||||||||||||||||||||||||||
6925 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6926 | - | |||||||||||||||||||||||||||||||||||||
6927 | if (QWidget *sp = second->focusProxy())
| 0 | ||||||||||||||||||||||||||||||||||||
6928 | second = sp; never executed: second = sp; | 0 | ||||||||||||||||||||||||||||||||||||
6929 | - | |||||||||||||||||||||||||||||||||||||
6930 | // QWidget *fp = first->d_func()->focus_prev; | - | ||||||||||||||||||||||||||||||||||||
6931 | QWidget *fn = first->d_func()->focus_next; | - | ||||||||||||||||||||||||||||||||||||
6932 | - | |||||||||||||||||||||||||||||||||||||
6933 | if (fn == second || first == second)
| 0 | ||||||||||||||||||||||||||||||||||||
6934 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6935 | - | |||||||||||||||||||||||||||||||||||||
6936 | QWidget *sp = second->d_func()->focus_prev; | - | ||||||||||||||||||||||||||||||||||||
6937 | QWidget *sn = second->d_func()->focus_next; | - | ||||||||||||||||||||||||||||||||||||
6938 | - | |||||||||||||||||||||||||||||||||||||
6939 | fn->d_func()->focus_prev = second; | - | ||||||||||||||||||||||||||||||||||||
6940 | first->d_func()->focus_next = second; | - | ||||||||||||||||||||||||||||||||||||
6941 | - | |||||||||||||||||||||||||||||||||||||
6942 | second->d_func()->focus_next = fn; | - | ||||||||||||||||||||||||||||||||||||
6943 | second->d_func()->focus_prev = first; | - | ||||||||||||||||||||||||||||||||||||
6944 | - | |||||||||||||||||||||||||||||||||||||
6945 | sp->d_func()->focus_next = sn; | - | ||||||||||||||||||||||||||||||||||||
6946 | sn->d_func()->focus_prev = sp; | - | ||||||||||||||||||||||||||||||||||||
6947 | - | |||||||||||||||||||||||||||||||||||||
6948 | - | |||||||||||||||||||||||||||||||||||||
6949 | Q_ASSERT(first->d_func()->focus_next->d_func()->focus_prev == first); | - | ||||||||||||||||||||||||||||||||||||
6950 | Q_ASSERT(first->d_func()->focus_prev->d_func()->focus_next == first); | - | ||||||||||||||||||||||||||||||||||||
6951 | - | |||||||||||||||||||||||||||||||||||||
6952 | Q_ASSERT(second->d_func()->focus_next->d_func()->focus_prev == second); | - | ||||||||||||||||||||||||||||||||||||
6953 | Q_ASSERT(second->d_func()->focus_prev->d_func()->focus_next == second); | - | ||||||||||||||||||||||||||||||||||||
6954 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6955 | - | |||||||||||||||||||||||||||||||||||||
6956 | /*!\internal | - | ||||||||||||||||||||||||||||||||||||
6957 | - | |||||||||||||||||||||||||||||||||||||
6958 | Moves the relevant subwidgets of this widget from the \a oldtlw's | - | ||||||||||||||||||||||||||||||||||||
6959 | tab chain to that of the new parent, if there's anything to move and | - | ||||||||||||||||||||||||||||||||||||
6960 | we're really moving | - | ||||||||||||||||||||||||||||||||||||
6961 | - | |||||||||||||||||||||||||||||||||||||
6962 | This function is called from QWidget::reparent() *after* the widget | - | ||||||||||||||||||||||||||||||||||||
6963 | has been reparented. | - | ||||||||||||||||||||||||||||||||||||
6964 | - | |||||||||||||||||||||||||||||||||||||
6965 | \sa reparent() | - | ||||||||||||||||||||||||||||||||||||
6966 | */ | - | ||||||||||||||||||||||||||||||||||||
6967 | - | |||||||||||||||||||||||||||||||||||||
6968 | void QWidgetPrivate::reparentFocusWidgets(QWidget * oldtlw) | - | ||||||||||||||||||||||||||||||||||||
6969 | { | - | ||||||||||||||||||||||||||||||||||||
6970 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
6971 | if (oldtlw == q->window())
| 0 | ||||||||||||||||||||||||||||||||||||
6972 | return; // nothing to do never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
6973 | - | |||||||||||||||||||||||||||||||||||||
6974 | if(focus_child)
| 0 | ||||||||||||||||||||||||||||||||||||
6975 | focus_child->clearFocus(); never executed: focus_child->clearFocus(); | 0 | ||||||||||||||||||||||||||||||||||||
6976 | - | |||||||||||||||||||||||||||||||||||||
6977 | // separate the focus chain into new (children of myself) and old (the rest) | - | ||||||||||||||||||||||||||||||||||||
6978 | QWidget *firstOld = 0; | - | ||||||||||||||||||||||||||||||||||||
6979 | //QWidget *firstNew = q; //invariant | - | ||||||||||||||||||||||||||||||||||||
6980 | QWidget *o = 0; // last in the old list | - | ||||||||||||||||||||||||||||||||||||
6981 | QWidget *n = q; // last in the new list | - | ||||||||||||||||||||||||||||||||||||
6982 | - | |||||||||||||||||||||||||||||||||||||
6983 | bool prevWasNew = true; | - | ||||||||||||||||||||||||||||||||||||
6984 | QWidget *w = focus_next; | - | ||||||||||||||||||||||||||||||||||||
6985 | - | |||||||||||||||||||||||||||||||||||||
6986 | //Note: for efficiency, we do not maintain the list invariant inside the loop | - | ||||||||||||||||||||||||||||||||||||
6987 | //we append items to the relevant list, and we optimize by not changing pointers | - | ||||||||||||||||||||||||||||||||||||
6988 | //when subsequent items are going into the same list. | - | ||||||||||||||||||||||||||||||||||||
6989 | while (w != q) {
| 0 | ||||||||||||||||||||||||||||||||||||
6990 | bool currentIsNew = q->isAncestorOf(w); | - | ||||||||||||||||||||||||||||||||||||
6991 | if (currentIsNew) {
| 0 | ||||||||||||||||||||||||||||||||||||
6992 | if (!prevWasNew) {
| 0 | ||||||||||||||||||||||||||||||||||||
6993 | //prev was old -- append to new list | - | ||||||||||||||||||||||||||||||||||||
6994 | n->d_func()->focus_next = w; | - | ||||||||||||||||||||||||||||||||||||
6995 | w->d_func()->focus_prev = n; | - | ||||||||||||||||||||||||||||||||||||
6996 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6997 | n = w; | - | ||||||||||||||||||||||||||||||||||||
6998 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
6999 | if (prevWasNew) {
| 0 | ||||||||||||||||||||||||||||||||||||
7000 | //prev was new -- append to old list, if there is one | - | ||||||||||||||||||||||||||||||||||||
7001 | if (o) {
| 0 | ||||||||||||||||||||||||||||||||||||
7002 | o->d_func()->focus_next = w; | - | ||||||||||||||||||||||||||||||||||||
7003 | w->d_func()->focus_prev = o; | - | ||||||||||||||||||||||||||||||||||||
7004 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7005 | // "create" the old list | - | ||||||||||||||||||||||||||||||||||||
7006 | firstOld = w; | - | ||||||||||||||||||||||||||||||||||||
7007 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7008 | } | - | ||||||||||||||||||||||||||||||||||||
7009 | o = w; | - | ||||||||||||||||||||||||||||||||||||
7010 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7011 | w = w->d_func()->focus_next; | - | ||||||||||||||||||||||||||||||||||||
7012 | prevWasNew = currentIsNew; | - | ||||||||||||||||||||||||||||||||||||
7013 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7014 | - | |||||||||||||||||||||||||||||||||||||
7015 | //repair the old list: | - | ||||||||||||||||||||||||||||||||||||
7016 | if (firstOld) {
| 0 | ||||||||||||||||||||||||||||||||||||
7017 | o->d_func()->focus_next = firstOld; | - | ||||||||||||||||||||||||||||||||||||
7018 | firstOld->d_func()->focus_prev = o; | - | ||||||||||||||||||||||||||||||||||||
7019 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7020 | - | |||||||||||||||||||||||||||||||||||||
7021 | if (!q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7022 | QWidget *topLevel = q->window(); | - | ||||||||||||||||||||||||||||||||||||
7023 | //insert new chain into toplevel's chain | - | ||||||||||||||||||||||||||||||||||||
7024 | - | |||||||||||||||||||||||||||||||||||||
7025 | QWidget *prev = topLevel->d_func()->focus_prev; | - | ||||||||||||||||||||||||||||||||||||
7026 | - | |||||||||||||||||||||||||||||||||||||
7027 | topLevel->d_func()->focus_prev = n; | - | ||||||||||||||||||||||||||||||||||||
7028 | prev->d_func()->focus_next = q; | - | ||||||||||||||||||||||||||||||||||||
7029 | - | |||||||||||||||||||||||||||||||||||||
7030 | focus_prev = prev; | - | ||||||||||||||||||||||||||||||||||||
7031 | n->d_func()->focus_next = topLevel; | - | ||||||||||||||||||||||||||||||||||||
7032 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7033 | //repair the new list | - | ||||||||||||||||||||||||||||||||||||
7034 | n->d_func()->focus_next = q; | - | ||||||||||||||||||||||||||||||||||||
7035 | focus_prev = n; | - | ||||||||||||||||||||||||||||||||||||
7036 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7037 | - | |||||||||||||||||||||||||||||||||||||
7038 | } | - | ||||||||||||||||||||||||||||||||||||
7039 | - | |||||||||||||||||||||||||||||||||||||
7040 | /*!\internal | - | ||||||||||||||||||||||||||||||||||||
7041 | - | |||||||||||||||||||||||||||||||||||||
7042 | Measures the shortest distance from a point to a rect. | - | ||||||||||||||||||||||||||||||||||||
7043 | - | |||||||||||||||||||||||||||||||||||||
7044 | This function is called from QDesktopwidget::screen(QPoint) to find the | - | ||||||||||||||||||||||||||||||||||||
7045 | closest screen for a point. | - | ||||||||||||||||||||||||||||||||||||
7046 | In directional KeypadNavigation, it is called to find the closest | - | ||||||||||||||||||||||||||||||||||||
7047 | widget to the current focus widget center. | - | ||||||||||||||||||||||||||||||||||||
7048 | */ | - | ||||||||||||||||||||||||||||||||||||
7049 | int QWidgetPrivate::pointToRect(const QPoint &p, const QRect &r) | - | ||||||||||||||||||||||||||||||||||||
7050 | { | - | ||||||||||||||||||||||||||||||||||||
7051 | int dx = 0; | - | ||||||||||||||||||||||||||||||||||||
7052 | int dy = 0; | - | ||||||||||||||||||||||||||||||||||||
7053 | if (p.x() < r.left())
| 0 | ||||||||||||||||||||||||||||||||||||
7054 | dx = r.left() - p.x(); never executed: dx = r.left() - p.x(); | 0 | ||||||||||||||||||||||||||||||||||||
7055 | else if (p.x() > r.right())
| 0 | ||||||||||||||||||||||||||||||||||||
7056 | dx = p.x() - r.right(); never executed: dx = p.x() - r.right(); | 0 | ||||||||||||||||||||||||||||||||||||
7057 | if (p.y() < r.top())
| 0 | ||||||||||||||||||||||||||||||||||||
7058 | dy = r.top() - p.y(); never executed: dy = r.top() - p.y(); | 0 | ||||||||||||||||||||||||||||||||||||
7059 | else if (p.y() > r.bottom())
| 0 | ||||||||||||||||||||||||||||||||||||
7060 | dy = p.y() - r.bottom(); never executed: dy = p.y() - r.bottom(); | 0 | ||||||||||||||||||||||||||||||||||||
7061 | return dx + dy; never executed: return dx + dy; | 0 | ||||||||||||||||||||||||||||||||||||
7062 | } | - | ||||||||||||||||||||||||||||||||||||
7063 | - | |||||||||||||||||||||||||||||||||||||
7064 | /*! | - | ||||||||||||||||||||||||||||||||||||
7065 | \property QWidget::frameSize | - | ||||||||||||||||||||||||||||||||||||
7066 | \brief the size of the widget including any window frame | - | ||||||||||||||||||||||||||||||||||||
7067 | - | |||||||||||||||||||||||||||||||||||||
7068 | By default, this property contains a value that depends on the user's | - | ||||||||||||||||||||||||||||||||||||
7069 | platform and screen geometry. | - | ||||||||||||||||||||||||||||||||||||
7070 | */ | - | ||||||||||||||||||||||||||||||||||||
7071 | QSize QWidget::frameSize() const | - | ||||||||||||||||||||||||||||||||||||
7072 | { | - | ||||||||||||||||||||||||||||||||||||
7073 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
7074 | if (isWindow() && !(windowType() == Qt::Popup)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7075 | QRect fs = d->frameStrut(); | - | ||||||||||||||||||||||||||||||||||||
7076 | 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 | ||||||||||||||||||||||||||||||||||||
7077 | 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 | ||||||||||||||||||||||||||||||||||||
7078 | } | - | ||||||||||||||||||||||||||||||||||||
7079 | return data->crect.size(); never executed: return data->crect.size(); | 0 | ||||||||||||||||||||||||||||||||||||
7080 | } | - | ||||||||||||||||||||||||||||||||||||
7081 | - | |||||||||||||||||||||||||||||||||||||
7082 | /*! \fn void QWidget::move(int x, int y) | - | ||||||||||||||||||||||||||||||||||||
7083 | - | |||||||||||||||||||||||||||||||||||||
7084 | \overload | - | ||||||||||||||||||||||||||||||||||||
7085 | - | |||||||||||||||||||||||||||||||||||||
7086 | This corresponds to move(QPoint(\a x, \a y)). | - | ||||||||||||||||||||||||||||||||||||
7087 | */ | - | ||||||||||||||||||||||||||||||||||||
7088 | - | |||||||||||||||||||||||||||||||||||||
7089 | void QWidget::move(const QPoint &p) | - | ||||||||||||||||||||||||||||||||||||
7090 | { | - | ||||||||||||||||||||||||||||||||||||
7091 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7092 | setAttribute(Qt::WA_Moved); | - | ||||||||||||||||||||||||||||||||||||
7093 | if (testAttribute(Qt::WA_WState_Created)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7094 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7095 | d->topData()->posIncludesFrame = false; never executed: d->topData()->posIncludesFrame = false; | 0 | ||||||||||||||||||||||||||||||||||||
7096 | d->setGeometry_sys(p.x() + geometry().x() - QWidget::x(), | - | ||||||||||||||||||||||||||||||||||||
7097 | p.y() + geometry().y() - QWidget::y(), | - | ||||||||||||||||||||||||||||||||||||
7098 | width(), height(), true); | - | ||||||||||||||||||||||||||||||||||||
7099 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
7100 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7101 | // no frame yet: see also QWidgetPrivate::fixPosIncludesFrame(), QWindowPrivate::PositionPolicy. | - | ||||||||||||||||||||||||||||||||||||
7102 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7103 | d->topData()->posIncludesFrame = true; never executed: d->topData()->posIncludesFrame = true; | 0 | ||||||||||||||||||||||||||||||||||||
7104 | data->crect.moveTopLeft(p); // no frame yet | - | ||||||||||||||||||||||||||||||||||||
7105 | setAttribute(Qt::WA_PendingMoveEvent); | - | ||||||||||||||||||||||||||||||||||||
7106 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7107 | - | |||||||||||||||||||||||||||||||||||||
7108 | if (d->extra && d->extra->hasWindowContainer)
| 0 | ||||||||||||||||||||||||||||||||||||
7109 | QWindowContainer::parentWasMoved(this); never executed: QWindowContainer::parentWasMoved(this); | 0 | ||||||||||||||||||||||||||||||||||||
7110 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7111 | - | |||||||||||||||||||||||||||||||||||||
7112 | // move() was invoked with Qt::WA_WState_Created not set (frame geometry | - | ||||||||||||||||||||||||||||||||||||
7113 | // unknown), that is, crect has a position including the frame. | - | ||||||||||||||||||||||||||||||||||||
7114 | // If we can determine the frame strut, fix that and clear the flag. | - | ||||||||||||||||||||||||||||||||||||
7115 | void QWidgetPrivate::fixPosIncludesFrame() | - | ||||||||||||||||||||||||||||||||||||
7116 | { | - | ||||||||||||||||||||||||||||||||||||
7117 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7118 | if (QTLWExtra *te = maybeTopData()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7119 | if (te->posIncludesFrame) {
| 0 | ||||||||||||||||||||||||||||||||||||
7120 | // For Qt::WA_DontShowOnScreen, assume a frame of 0 (for | - | ||||||||||||||||||||||||||||||||||||
7121 | // example, in QGraphicsProxyWidget). | - | ||||||||||||||||||||||||||||||||||||
7122 | if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7123 | te->posIncludesFrame = 0; | - | ||||||||||||||||||||||||||||||||||||
7124 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7125 | if (q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7126 | updateFrameStrut(); | - | ||||||||||||||||||||||||||||||||||||
7127 | if (!q->data->fstrut_dirty) {
| 0 | ||||||||||||||||||||||||||||||||||||
7128 | data.crect.translate(te->frameStrut.x(), te->frameStrut.y()); | - | ||||||||||||||||||||||||||||||||||||
7129 | te->posIncludesFrame = 0; | - | ||||||||||||||||||||||||||||||||||||
7130 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7131 | } // windowHandle() never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7132 | } // !WA_DontShowOnScreen never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7133 | } // posIncludesFrame | - | ||||||||||||||||||||||||||||||||||||
7134 | } // QTLWExtra never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7135 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7136 | - | |||||||||||||||||||||||||||||||||||||
7137 | /*! \fn void QWidget::resize(int w, int h) | - | ||||||||||||||||||||||||||||||||||||
7138 | \overload | - | ||||||||||||||||||||||||||||||||||||
7139 | - | |||||||||||||||||||||||||||||||||||||
7140 | This corresponds to resize(QSize(\a w, \a h)). | - | ||||||||||||||||||||||||||||||||||||
7141 | */ | - | ||||||||||||||||||||||||||||||||||||
7142 | - | |||||||||||||||||||||||||||||||||||||
7143 | void QWidget::resize(const QSize &s) | - | ||||||||||||||||||||||||||||||||||||
7144 | { | - | ||||||||||||||||||||||||||||||||||||
7145 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7146 | setAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||||||||||||||
7147 | if (testAttribute(Qt::WA_WState_Created)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7148 | d->fixPosIncludesFrame(); | - | ||||||||||||||||||||||||||||||||||||
7149 | d->setGeometry_sys(geometry().x(), geometry().y(), s.width(), s.height(), false); | - | ||||||||||||||||||||||||||||||||||||
7150 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
7151 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7152 | data->crect.setSize(s.boundedTo(maximumSize()).expandedTo(minimumSize())); | - | ||||||||||||||||||||||||||||||||||||
7153 | setAttribute(Qt::WA_PendingResizeEvent); | - | ||||||||||||||||||||||||||||||||||||
7154 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7155 | } | - | ||||||||||||||||||||||||||||||||||||
7156 | - | |||||||||||||||||||||||||||||||||||||
7157 | void QWidget::setGeometry(const QRect &r) | - | ||||||||||||||||||||||||||||||||||||
7158 | { | - | ||||||||||||||||||||||||||||||||||||
7159 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7160 | setAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||||||||||||||
7161 | setAttribute(Qt::WA_Moved); | - | ||||||||||||||||||||||||||||||||||||
7162 | if (isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7163 | d->topData()->posIncludesFrame = 0; never executed: d->topData()->posIncludesFrame = 0; | 0 | ||||||||||||||||||||||||||||||||||||
7164 | if (testAttribute(Qt::WA_WState_Created)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7165 | d->setGeometry_sys(r.x(), r.y(), r.width(), r.height(), true); | - | ||||||||||||||||||||||||||||||||||||
7166 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
7167 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7168 | data->crect.setTopLeft(r.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
7169 | data->crect.setSize(r.size().boundedTo(maximumSize()).expandedTo(minimumSize())); | - | ||||||||||||||||||||||||||||||||||||
7170 | setAttribute(Qt::WA_PendingMoveEvent); | - | ||||||||||||||||||||||||||||||||||||
7171 | setAttribute(Qt::WA_PendingResizeEvent); | - | ||||||||||||||||||||||||||||||||||||
7172 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7173 | - | |||||||||||||||||||||||||||||||||||||
7174 | if (d->extra && d->extra->hasWindowContainer)
| 0 | ||||||||||||||||||||||||||||||||||||
7175 | QWindowContainer::parentWasMoved(this); never executed: QWindowContainer::parentWasMoved(this); | 0 | ||||||||||||||||||||||||||||||||||||
7176 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7177 | - | |||||||||||||||||||||||||||||||||||||
7178 | void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) | - | ||||||||||||||||||||||||||||||||||||
7179 | { | - | ||||||||||||||||||||||||||||||||||||
7180 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7181 | if (extra) { // any size restrictions?
| 0 | ||||||||||||||||||||||||||||||||||||
7182 | w = qMin(w,extra->maxw); | - | ||||||||||||||||||||||||||||||||||||
7183 | h = qMin(h,extra->maxh); | - | ||||||||||||||||||||||||||||||||||||
7184 | w = qMax(w,extra->minw); | - | ||||||||||||||||||||||||||||||||||||
7185 | h = qMax(h,extra->minh); | - | ||||||||||||||||||||||||||||||||||||
7186 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7187 | - | |||||||||||||||||||||||||||||||||||||
7188 | if (q->isWindow() && q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7189 | QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration(); | - | ||||||||||||||||||||||||||||||||||||
7190 | if (!integration->hasCapability(QPlatformIntegration::NonFullScreenWindows)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7191 | x = 0; | - | ||||||||||||||||||||||||||||||||||||
7192 | y = 0; | - | ||||||||||||||||||||||||||||||||||||
7193 | w = q->windowHandle()->width(); | - | ||||||||||||||||||||||||||||||||||||
7194 | h = q->windowHandle()->height(); | - | ||||||||||||||||||||||||||||||||||||
7195 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7196 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7197 | - | |||||||||||||||||||||||||||||||||||||
7198 | QPoint oldp = q->geometry().topLeft(); | - | ||||||||||||||||||||||||||||||||||||
7199 | QSize olds = q->size(); | - | ||||||||||||||||||||||||||||||||||||
7200 | QRect r(x, y, w, h); | - | ||||||||||||||||||||||||||||||||||||
7201 | - | |||||||||||||||||||||||||||||||||||||
7202 | bool isResize = olds != r.size(); | - | ||||||||||||||||||||||||||||||||||||
7203 | isMove = oldp != r.topLeft(); //### why do we have isMove as a parameter? | - | ||||||||||||||||||||||||||||||||||||
7204 | - | |||||||||||||||||||||||||||||||||||||
7205 | - | |||||||||||||||||||||||||||||||||||||
7206 | // We only care about stuff that changes the geometry, or may | - | ||||||||||||||||||||||||||||||||||||
7207 | // cause the window manager to change its state | - | ||||||||||||||||||||||||||||||||||||
7208 | if (r.size() == olds && oldp == r.topLeft())
| 0 | ||||||||||||||||||||||||||||||||||||
7209 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
7210 | - | |||||||||||||||||||||||||||||||||||||
7211 | if (!data.in_set_window_state) {
| 0 | ||||||||||||||||||||||||||||||||||||
7212 | q->data->window_state &= ~Qt::WindowMaximized; | - | ||||||||||||||||||||||||||||||||||||
7213 | q->data->window_state &= ~Qt::WindowFullScreen; | - | ||||||||||||||||||||||||||||||||||||
7214 | if (q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7215 | topData()->normalGeometry = QRect(0, 0, -1, -1); never executed: topData()->normalGeometry = QRect(0, 0, -1, -1); | 0 | ||||||||||||||||||||||||||||||||||||
7216 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7217 | - | |||||||||||||||||||||||||||||||||||||
7218 | QPoint oldPos = q->pos(); | - | ||||||||||||||||||||||||||||||||||||
7219 | data.crect = r; | - | ||||||||||||||||||||||||||||||||||||
7220 | - | |||||||||||||||||||||||||||||||||||||
7221 | bool needsShow = false; | - | ||||||||||||||||||||||||||||||||||||
7222 | - | |||||||||||||||||||||||||||||||||||||
7223 | if (q->isWindow() || q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7224 | if (!(data.window_state & Qt::WindowFullScreen) && (w == 0 || h == 0)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7225 | q->setAttribute(Qt::WA_OutsideWSRange, true); | - | ||||||||||||||||||||||||||||||||||||
7226 | if (q->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
7227 | hide_sys(); never executed: hide_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
7228 | data.crect = QRect(x, y, w, h); | - | ||||||||||||||||||||||||||||||||||||
7229 | } else if (q->testAttribute(Qt::WA_OutsideWSRange)) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
7230 | q->setAttribute(Qt::WA_OutsideWSRange, false); | - | ||||||||||||||||||||||||||||||||||||
7231 | needsShow = true; | - | ||||||||||||||||||||||||||||||||||||
7232 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7233 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7234 | - | |||||||||||||||||||||||||||||||||||||
7235 | if (q->isVisible()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7236 | if (!q->testAttribute(Qt::WA_DontShowOnScreen) && !q->testAttribute(Qt::WA_OutsideWSRange)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7237 | if (q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7238 | if (q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7239 | q->windowHandle()->setGeometry(q->geometry()); | - | ||||||||||||||||||||||||||||||||||||
7240 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7241 | QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint()); | - | ||||||||||||||||||||||||||||||||||||
7242 | q->windowHandle()->setGeometry(QRect(posInNativeParent,r.size())); | - | ||||||||||||||||||||||||||||||||||||
7243 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7244 | - | |||||||||||||||||||||||||||||||||||||
7245 | if (needsShow)
| 0 | ||||||||||||||||||||||||||||||||||||
7246 | show_sys(); never executed: show_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
7247 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7248 | - | |||||||||||||||||||||||||||||||||||||
7249 | if (!q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7250 | if (renderToTexture) {
| 0 | ||||||||||||||||||||||||||||||||||||
7251 | QRegion updateRegion(q->geometry()); | - | ||||||||||||||||||||||||||||||||||||
7252 | updateRegion += QRect(oldPos, olds); | - | ||||||||||||||||||||||||||||||||||||
7253 | q->parentWidget()->d_func()->invalidateBuffer(updateRegion); | - | ||||||||||||||||||||||||||||||||||||
7254 | } else if (isMove && !isResize) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
7255 | moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y()); | - | ||||||||||||||||||||||||||||||||||||
7256 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7257 | invalidateBuffer_resizeHelper(oldPos, olds); | - | ||||||||||||||||||||||||||||||||||||
7258 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7259 | } | - | ||||||||||||||||||||||||||||||||||||
7260 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7261 | - | |||||||||||||||||||||||||||||||||||||
7262 | if (isMove) {
| 0 | ||||||||||||||||||||||||||||||||||||
7263 | QMoveEvent e(q->pos(), oldPos); | - | ||||||||||||||||||||||||||||||||||||
7264 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
7265 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7266 | if (isResize) {
| 0 | ||||||||||||||||||||||||||||||||||||
7267 | QResizeEvent e(r.size(), olds); | - | ||||||||||||||||||||||||||||||||||||
7268 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
7269 | if (q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
7270 | q->update(); never executed: q->update(); | 0 | ||||||||||||||||||||||||||||||||||||
7271 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7272 | } else { // not visible never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7273 | if (isMove && q->pos() != oldPos)
| 0 | ||||||||||||||||||||||||||||||||||||
7274 | q->setAttribute(Qt::WA_PendingMoveEvent, true); never executed: q->setAttribute(Qt::WA_PendingMoveEvent, true); | 0 | ||||||||||||||||||||||||||||||||||||
7275 | if (isResize)
| 0 | ||||||||||||||||||||||||||||||||||||
7276 | q->setAttribute(Qt::WA_PendingResizeEvent, true); never executed: q->setAttribute(Qt::WA_PendingResizeEvent, true); | 0 | ||||||||||||||||||||||||||||||||||||
7277 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7278 | - | |||||||||||||||||||||||||||||||||||||
7279 | } | - | ||||||||||||||||||||||||||||||||||||
7280 | - | |||||||||||||||||||||||||||||||||||||
7281 | /*! | - | ||||||||||||||||||||||||||||||||||||
7282 | \since 4.2 | - | ||||||||||||||||||||||||||||||||||||
7283 | Saves the current geometry and state for top-level widgets. | - | ||||||||||||||||||||||||||||||||||||
7284 | - | |||||||||||||||||||||||||||||||||||||
7285 | To save the geometry when the window closes, you can | - | ||||||||||||||||||||||||||||||||||||
7286 | implement a close event like this: | - | ||||||||||||||||||||||||||||||||||||
7287 | - | |||||||||||||||||||||||||||||||||||||
7288 | \snippet code/src_gui_kernel_qwidget.cpp 11 | - | ||||||||||||||||||||||||||||||||||||
7289 | - | |||||||||||||||||||||||||||||||||||||
7290 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
7291 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
7292 | - | |||||||||||||||||||||||||||||||||||||
7293 | Use QMainWindow::saveState() to save the geometry and the state of | - | ||||||||||||||||||||||||||||||||||||
7294 | toolbars and dock widgets. | - | ||||||||||||||||||||||||||||||||||||
7295 | - | |||||||||||||||||||||||||||||||||||||
7296 | \sa restoreGeometry(), QMainWindow::saveState(), QMainWindow::restoreState() | - | ||||||||||||||||||||||||||||||||||||
7297 | */ | - | ||||||||||||||||||||||||||||||||||||
7298 | QByteArray QWidget::saveGeometry() const | - | ||||||||||||||||||||||||||||||||||||
7299 | { | - | ||||||||||||||||||||||||||||||||||||
7300 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
7301 | // We check if the window was maximized during this invocation. If so, we need to record the | - | ||||||||||||||||||||||||||||||||||||
7302 | // starting position as 0,0. | - | ||||||||||||||||||||||||||||||||||||
7303 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
7304 | QRect newFramePosition = frameGeometry(); | - | ||||||||||||||||||||||||||||||||||||
7305 | QRect newNormalPosition = normalGeometry(); | - | ||||||||||||||||||||||||||||||||||||
7306 | if(d->topData()->wasMaximized && !(windowState() & Qt::WindowMaximized)) { | - | ||||||||||||||||||||||||||||||||||||
7307 | // Change the starting position | - | ||||||||||||||||||||||||||||||||||||
7308 | newFramePosition.moveTo(0, 0); | - | ||||||||||||||||||||||||||||||||||||
7309 | newNormalPosition.moveTo(0, 0); | - | ||||||||||||||||||||||||||||||||||||
7310 | } | - | ||||||||||||||||||||||||||||||||||||
7311 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
7312 | QByteArray array; | - | ||||||||||||||||||||||||||||||||||||
7313 | QDataStream stream(&array, QIODevice::WriteOnly); | - | ||||||||||||||||||||||||||||||||||||
7314 | stream.setVersion(QDataStream::Qt_4_0); | - | ||||||||||||||||||||||||||||||||||||
7315 | const quint32 magicNumber = 0x1D9D0CB; | - | ||||||||||||||||||||||||||||||||||||
7316 | // Version history: | - | ||||||||||||||||||||||||||||||||||||
7317 | // - Qt 4.2 - 4.8.6, 5.0 - 5.3 : Version 1.0 | - | ||||||||||||||||||||||||||||||||||||
7318 | // - Qt 4.8.6 - today, 5.4 - today: Version 2.0, save screen width in addition to check for high DPI scaling. | - | ||||||||||||||||||||||||||||||||||||
7319 | quint16 majorVersion = 2; | - | ||||||||||||||||||||||||||||||||||||
7320 | quint16 minorVersion = 0; | - | ||||||||||||||||||||||||||||||||||||
7321 | const int screenNumber = QApplication::desktop()->screenNumber(this); | - | ||||||||||||||||||||||||||||||||||||
7322 | stream << magicNumber | - | ||||||||||||||||||||||||||||||||||||
7323 | << majorVersion | - | ||||||||||||||||||||||||||||||||||||
7324 | << minorVersion | - | ||||||||||||||||||||||||||||||||||||
7325 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
7326 | << newFramePosition | - | ||||||||||||||||||||||||||||||||||||
7327 | << newNormalPosition | - | ||||||||||||||||||||||||||||||||||||
7328 | #else | - | ||||||||||||||||||||||||||||||||||||
7329 | << frameGeometry() | - | ||||||||||||||||||||||||||||||||||||
7330 | << normalGeometry() | - | ||||||||||||||||||||||||||||||||||||
7331 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
7332 | << qint32(screenNumber) | - | ||||||||||||||||||||||||||||||||||||
7333 | << quint8(windowState() & Qt::WindowMaximized) | - | ||||||||||||||||||||||||||||||||||||
7334 | << quint8(windowState() & Qt::WindowFullScreen) | - | ||||||||||||||||||||||||||||||||||||
7335 | << qint32(QApplication::desktop()->screenGeometry(screenNumber).width()); // 1.1 onwards | - | ||||||||||||||||||||||||||||||||||||
7336 | return array; never executed: return array; | 0 | ||||||||||||||||||||||||||||||||||||
7337 | } | - | ||||||||||||||||||||||||||||||||||||
7338 | - | |||||||||||||||||||||||||||||||||||||
7339 | /*! | - | ||||||||||||||||||||||||||||||||||||
7340 | \since 4.2 | - | ||||||||||||||||||||||||||||||||||||
7341 | - | |||||||||||||||||||||||||||||||||||||
7342 | Restores the geometry and state of top-level widgets stored in the | - | ||||||||||||||||||||||||||||||||||||
7343 | byte array \a geometry. Returns \c true on success; otherwise | - | ||||||||||||||||||||||||||||||||||||
7344 | returns \c false. | - | ||||||||||||||||||||||||||||||||||||
7345 | - | |||||||||||||||||||||||||||||||||||||
7346 | If the restored geometry is off-screen, it will be modified to be | - | ||||||||||||||||||||||||||||||||||||
7347 | inside the available screen geometry. | - | ||||||||||||||||||||||||||||||||||||
7348 | - | |||||||||||||||||||||||||||||||||||||
7349 | To restore geometry saved using QSettings, you can use code like | - | ||||||||||||||||||||||||||||||||||||
7350 | this: | - | ||||||||||||||||||||||||||||||||||||
7351 | - | |||||||||||||||||||||||||||||||||||||
7352 | \snippet code/src_gui_kernel_qwidget.cpp 12 | - | ||||||||||||||||||||||||||||||||||||
7353 | - | |||||||||||||||||||||||||||||||||||||
7354 | See the \l{Window Geometry} documentation for an overview of geometry | - | ||||||||||||||||||||||||||||||||||||
7355 | issues with windows. | - | ||||||||||||||||||||||||||||||||||||
7356 | - | |||||||||||||||||||||||||||||||||||||
7357 | Use QMainWindow::restoreState() to restore the geometry and the | - | ||||||||||||||||||||||||||||||||||||
7358 | state of toolbars and dock widgets. | - | ||||||||||||||||||||||||||||||||||||
7359 | - | |||||||||||||||||||||||||||||||||||||
7360 | \sa saveGeometry(), QSettings, QMainWindow::saveState(), QMainWindow::restoreState() | - | ||||||||||||||||||||||||||||||||||||
7361 | */ | - | ||||||||||||||||||||||||||||||||||||
7362 | bool QWidget::restoreGeometry(const QByteArray &geometry) | - | ||||||||||||||||||||||||||||||||||||
7363 | { | - | ||||||||||||||||||||||||||||||||||||
7364 | if (geometry.size() < 4)
| 0 | ||||||||||||||||||||||||||||||||||||
7365 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
7366 | QDataStream stream(geometry); | - | ||||||||||||||||||||||||||||||||||||
7367 | stream.setVersion(QDataStream::Qt_4_0); | - | ||||||||||||||||||||||||||||||||||||
7368 | - | |||||||||||||||||||||||||||||||||||||
7369 | const quint32 magicNumber = 0x1D9D0CB; | - | ||||||||||||||||||||||||||||||||||||
7370 | quint32 storedMagicNumber; | - | ||||||||||||||||||||||||||||||||||||
7371 | stream >> storedMagicNumber; | - | ||||||||||||||||||||||||||||||||||||
7372 | if (storedMagicNumber != magicNumber)
| 0 | ||||||||||||||||||||||||||||||||||||
7373 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
7374 | - | |||||||||||||||||||||||||||||||||||||
7375 | const quint16 currentMajorVersion = 2; | - | ||||||||||||||||||||||||||||||||||||
7376 | quint16 majorVersion = 0; | - | ||||||||||||||||||||||||||||||||||||
7377 | quint16 minorVersion = 0; | - | ||||||||||||||||||||||||||||||||||||
7378 | - | |||||||||||||||||||||||||||||||||||||
7379 | stream >> majorVersion >> minorVersion; | - | ||||||||||||||||||||||||||||||||||||
7380 | - | |||||||||||||||||||||||||||||||||||||
7381 | if (majorVersion > currentMajorVersion)
| 0 | ||||||||||||||||||||||||||||||||||||
7382 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
7383 | // (Allow all minor versions.) | - | ||||||||||||||||||||||||||||||||||||
7384 | - | |||||||||||||||||||||||||||||||||||||
7385 | QRect restoredFrameGeometry; | - | ||||||||||||||||||||||||||||||||||||
7386 | QRect restoredNormalGeometry; | - | ||||||||||||||||||||||||||||||||||||
7387 | qint32 restoredScreenNumber; | - | ||||||||||||||||||||||||||||||||||||
7388 | quint8 maximized; | - | ||||||||||||||||||||||||||||||||||||
7389 | quint8 fullScreen; | - | ||||||||||||||||||||||||||||||||||||
7390 | qint32 restoredScreenWidth = 0; | - | ||||||||||||||||||||||||||||||||||||
7391 | - | |||||||||||||||||||||||||||||||||||||
7392 | stream >> restoredFrameGeometry | - | ||||||||||||||||||||||||||||||||||||
7393 | >> restoredNormalGeometry | - | ||||||||||||||||||||||||||||||||||||
7394 | >> restoredScreenNumber | - | ||||||||||||||||||||||||||||||||||||
7395 | >> maximized | - | ||||||||||||||||||||||||||||||||||||
7396 | >> fullScreen; | - | ||||||||||||||||||||||||||||||||||||
7397 | - | |||||||||||||||||||||||||||||||||||||
7398 | if (majorVersion > 1)
| 0 | ||||||||||||||||||||||||||||||||||||
7399 | stream >> restoredScreenWidth; never executed: stream >> restoredScreenWidth; | 0 | ||||||||||||||||||||||||||||||||||||
7400 | - | |||||||||||||||||||||||||||||||||||||
7401 | const QDesktopWidget * const desktop = QApplication::desktop(); | - | ||||||||||||||||||||||||||||||||||||
7402 | if (restoredScreenNumber >= desktop->numScreens())
| 0 | ||||||||||||||||||||||||||||||||||||
7403 | restoredScreenNumber = desktop->primaryScreen(); never executed: restoredScreenNumber = desktop->primaryScreen(); | 0 | ||||||||||||||||||||||||||||||||||||
7404 | const qreal screenWidthF = qreal(desktop->screenGeometry(restoredScreenNumber).width()); | - | ||||||||||||||||||||||||||||||||||||
7405 | // Sanity check bailing out when large variations of screen sizes occur due to | - | ||||||||||||||||||||||||||||||||||||
7406 | // high DPI scaling or different levels of DPI awareness. | - | ||||||||||||||||||||||||||||||||||||
7407 | if (restoredScreenWidth) {
| 0 | ||||||||||||||||||||||||||||||||||||
7408 | const qreal factor = qreal(restoredScreenWidth) / screenWidthF; | - | ||||||||||||||||||||||||||||||||||||
7409 | if (factor < 0.8 || factor > 1.25)
| 0 | ||||||||||||||||||||||||||||||||||||
7410 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
7411 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7412 | // Saved by Qt 5.3 and earlier, try to prevent too large windows | - | ||||||||||||||||||||||||||||||||||||
7413 | // unless the size will be adapted by maximized or fullscreen. | - | ||||||||||||||||||||||||||||||||||||
7414 | if (!maximized && !fullScreen && qreal(restoredFrameGeometry.width()) / screenWidthF > 1.5)
| 0 | ||||||||||||||||||||||||||||||||||||
7415 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
7416 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7417 | - | |||||||||||||||||||||||||||||||||||||
7418 | const int frameHeight = 20; | - | ||||||||||||||||||||||||||||||||||||
7419 | if (!restoredFrameGeometry.isValid())
| 0 | ||||||||||||||||||||||||||||||||||||
7420 | restoredFrameGeometry = QRect(QPoint(0,0), sizeHint()); never executed: restoredFrameGeometry = QRect(QPoint(0,0), sizeHint()); | 0 | ||||||||||||||||||||||||||||||||||||
7421 | - | |||||||||||||||||||||||||||||||||||||
7422 | if (!restoredNormalGeometry.isValid())
| 0 | ||||||||||||||||||||||||||||||||||||
7423 | restoredNormalGeometry = QRect(QPoint(0, frameHeight), sizeHint()); never executed: restoredNormalGeometry = QRect(QPoint(0, frameHeight), sizeHint()); | 0 | ||||||||||||||||||||||||||||||||||||
7424 | if (!restoredNormalGeometry.isValid()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7425 | // use the widget's adjustedSize if the sizeHint() doesn't help | - | ||||||||||||||||||||||||||||||||||||
7426 | restoredNormalGeometry.setSize(restoredNormalGeometry | - | ||||||||||||||||||||||||||||||||||||
7427 | .size() | - | ||||||||||||||||||||||||||||||||||||
7428 | .expandedTo(d_func()->adjustedSize())); | - | ||||||||||||||||||||||||||||||||||||
7429 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7430 | - | |||||||||||||||||||||||||||||||||||||
7431 | const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber); | - | ||||||||||||||||||||||||||||||||||||
7432 | - | |||||||||||||||||||||||||||||||||||||
7433 | // Modify the restored geometry if we are about to restore to coordinates | - | ||||||||||||||||||||||||||||||||||||
7434 | // that would make the window "lost". This happens if: | - | ||||||||||||||||||||||||||||||||||||
7435 | // - The restored geometry is completely oustside the available geometry | - | ||||||||||||||||||||||||||||||||||||
7436 | // - The title bar is outside the available geometry. | - | ||||||||||||||||||||||||||||||||||||
7437 | // - (Mac only) The window is higher than the available geometry. It must | - | ||||||||||||||||||||||||||||||||||||
7438 | // be possible to bring the size grip on screen by moving the window. | - | ||||||||||||||||||||||||||||||||||||
7439 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
7440 | restoredFrameGeometry.setHeight(qMin(restoredFrameGeometry.height(), availableGeometry.height())); | - | ||||||||||||||||||||||||||||||||||||
7441 | restoredNormalGeometry.setHeight(qMin(restoredNormalGeometry.height(), availableGeometry.height() - frameHeight)); | - | ||||||||||||||||||||||||||||||||||||
7442 | #endif | - | ||||||||||||||||||||||||||||||||||||
7443 | - | |||||||||||||||||||||||||||||||||||||
7444 | if (!restoredFrameGeometry.intersects(availableGeometry)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7445 | restoredFrameGeometry.moveBottom(qMin(restoredFrameGeometry.bottom(), availableGeometry.bottom())); | - | ||||||||||||||||||||||||||||||||||||
7446 | restoredFrameGeometry.moveLeft(qMax(restoredFrameGeometry.left(), availableGeometry.left())); | - | ||||||||||||||||||||||||||||||||||||
7447 | restoredFrameGeometry.moveRight(qMin(restoredFrameGeometry.right(), availableGeometry.right())); | - | ||||||||||||||||||||||||||||||||||||
7448 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7449 | restoredFrameGeometry.moveTop(qMax(restoredFrameGeometry.top(), availableGeometry.top())); | - | ||||||||||||||||||||||||||||||||||||
7450 | - | |||||||||||||||||||||||||||||||||||||
7451 | if (!restoredNormalGeometry.intersects(availableGeometry)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7452 | restoredNormalGeometry.moveBottom(qMin(restoredNormalGeometry.bottom(), availableGeometry.bottom())); | - | ||||||||||||||||||||||||||||||||||||
7453 | restoredNormalGeometry.moveLeft(qMax(restoredNormalGeometry.left(), availableGeometry.left())); | - | ||||||||||||||||||||||||||||||||||||
7454 | restoredNormalGeometry.moveRight(qMin(restoredNormalGeometry.right(), availableGeometry.right())); | - | ||||||||||||||||||||||||||||||||||||
7455 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7456 | restoredNormalGeometry.moveTop(qMax(restoredNormalGeometry.top(), availableGeometry.top() + frameHeight)); | - | ||||||||||||||||||||||||||||||||||||
7457 | - | |||||||||||||||||||||||||||||||||||||
7458 | if (maximized || fullScreen) {
| 0 | ||||||||||||||||||||||||||||||||||||
7459 | // set geometry before setting the window state to make | - | ||||||||||||||||||||||||||||||||||||
7460 | // sure the window is maximized to the right screen. | - | ||||||||||||||||||||||||||||||||||||
7461 | Qt::WindowStates ws = windowState(); | - | ||||||||||||||||||||||||||||||||||||
7462 | #ifndef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
7463 | setGeometry(restoredNormalGeometry); | - | ||||||||||||||||||||||||||||||||||||
7464 | #else | - | ||||||||||||||||||||||||||||||||||||
7465 | if (ws & Qt::WindowFullScreen) { | - | ||||||||||||||||||||||||||||||||||||
7466 | // Full screen is not a real window state on Windows. | - | ||||||||||||||||||||||||||||||||||||
7467 | move(availableGeometry.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
7468 | } else if (ws & Qt::WindowMaximized) { | - | ||||||||||||||||||||||||||||||||||||
7469 | // Setting a geometry on an already maximized window causes this to be | - | ||||||||||||||||||||||||||||||||||||
7470 | // restored into a broken, half-maximized state, non-resizable state (QTBUG-4397). | - | ||||||||||||||||||||||||||||||||||||
7471 | // Move the window in normal state if needed. | - | ||||||||||||||||||||||||||||||||||||
7472 | if (restoredScreenNumber != desktop->screenNumber(this)) { | - | ||||||||||||||||||||||||||||||||||||
7473 | setWindowState(Qt::WindowNoState); | - | ||||||||||||||||||||||||||||||||||||
7474 | setGeometry(restoredNormalGeometry); | - | ||||||||||||||||||||||||||||||||||||
7475 | } | - | ||||||||||||||||||||||||||||||||||||
7476 | } else { | - | ||||||||||||||||||||||||||||||||||||
7477 | setGeometry(restoredNormalGeometry); | - | ||||||||||||||||||||||||||||||||||||
7478 | } | - | ||||||||||||||||||||||||||||||||||||
7479 | #endif // Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
7480 | if (maximized)
| 0 | ||||||||||||||||||||||||||||||||||||
7481 | ws |= Qt::WindowMaximized; never executed: ws |= Qt::WindowMaximized; | 0 | ||||||||||||||||||||||||||||||||||||
7482 | if (fullScreen)
| 0 | ||||||||||||||||||||||||||||||||||||
7483 | ws |= Qt::WindowFullScreen; never executed: ws |= Qt::WindowFullScreen; | 0 | ||||||||||||||||||||||||||||||||||||
7484 | setWindowState(ws); | - | ||||||||||||||||||||||||||||||||||||
7485 | d_func()->topData()->normalGeometry = restoredNormalGeometry; | - | ||||||||||||||||||||||||||||||||||||
7486 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7487 | QPoint offset; | - | ||||||||||||||||||||||||||||||||||||
7488 | #ifdef Q_DEAD_CODE_FROM_QT4_X11 | - | ||||||||||||||||||||||||||||||||||||
7489 | if (isFullScreen()) | - | ||||||||||||||||||||||||||||||||||||
7490 | offset = d_func()->topData()->fullScreenOffset; | - | ||||||||||||||||||||||||||||||||||||
7491 | #endif | - | ||||||||||||||||||||||||||||||||||||
7492 | setWindowState(windowState() & ~(Qt::WindowMaximized | Qt::WindowFullScreen)); | - | ||||||||||||||||||||||||||||||||||||
7493 | move(restoredFrameGeometry.topLeft() + offset); | - | ||||||||||||||||||||||||||||||||||||
7494 | resize(restoredNormalGeometry.size()); | - | ||||||||||||||||||||||||||||||||||||
7495 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7496 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
7497 | } | - | ||||||||||||||||||||||||||||||||||||
7498 | - | |||||||||||||||||||||||||||||||||||||
7499 | /*!\fn void QWidget::setGeometry(int x, int y, int w, int h) | - | ||||||||||||||||||||||||||||||||||||
7500 | \overload | - | ||||||||||||||||||||||||||||||||||||
7501 | - | |||||||||||||||||||||||||||||||||||||
7502 | This corresponds to setGeometry(QRect(\a x, \a y, \a w, \a h)). | - | ||||||||||||||||||||||||||||||||||||
7503 | */ | - | ||||||||||||||||||||||||||||||||||||
7504 | - | |||||||||||||||||||||||||||||||||||||
7505 | /*! | - | ||||||||||||||||||||||||||||||||||||
7506 | Sets the margins around the contents of the widget to have the sizes | - | ||||||||||||||||||||||||||||||||||||
7507 | \a left, \a top, \a right, and \a bottom. The margins are used by | - | ||||||||||||||||||||||||||||||||||||
7508 | the layout system, and may be used by subclasses to specify the area | - | ||||||||||||||||||||||||||||||||||||
7509 | to draw in (e.g. excluding the frame). | - | ||||||||||||||||||||||||||||||||||||
7510 | - | |||||||||||||||||||||||||||||||||||||
7511 | Changing the margins will trigger a resizeEvent(). | - | ||||||||||||||||||||||||||||||||||||
7512 | - | |||||||||||||||||||||||||||||||||||||
7513 | \sa contentsRect(), getContentsMargins() | - | ||||||||||||||||||||||||||||||||||||
7514 | */ | - | ||||||||||||||||||||||||||||||||||||
7515 | void QWidget::setContentsMargins(int left, int top, int right, int bottom) | - | ||||||||||||||||||||||||||||||||||||
7516 | { | - | ||||||||||||||||||||||||||||||||||||
7517 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7518 | if (left == d->leftmargin && top == d->topmargin
| 0 | ||||||||||||||||||||||||||||||||||||
7519 | && right == d->rightmargin && bottom == d->bottommargin)
| 0 | ||||||||||||||||||||||||||||||||||||
7520 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
7521 | d->leftmargin = left; | - | ||||||||||||||||||||||||||||||||||||
7522 | d->topmargin = top; | - | ||||||||||||||||||||||||||||||||||||
7523 | d->rightmargin = right; | - | ||||||||||||||||||||||||||||||||||||
7524 | d->bottommargin = bottom; | - | ||||||||||||||||||||||||||||||||||||
7525 | - | |||||||||||||||||||||||||||||||||||||
7526 | if (QLayout *l=d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
7527 | l->update(); //force activate; will do updateGeometry never executed: l->update(); | 0 | ||||||||||||||||||||||||||||||||||||
7528 | else | - | ||||||||||||||||||||||||||||||||||||
7529 | updateGeometry(); never executed: updateGeometry(); | 0 | ||||||||||||||||||||||||||||||||||||
7530 | - | |||||||||||||||||||||||||||||||||||||
7531 | if (isVisible()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7532 | update(); | - | ||||||||||||||||||||||||||||||||||||
7533 | QResizeEvent e(data->crect.size(), data->crect.size()); | - | ||||||||||||||||||||||||||||||||||||
7534 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
7535 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7536 | setAttribute(Qt::WA_PendingResizeEvent, true); | - | ||||||||||||||||||||||||||||||||||||
7537 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7538 | - | |||||||||||||||||||||||||||||||||||||
7539 | QEvent e(QEvent::ContentsRectChange); | - | ||||||||||||||||||||||||||||||||||||
7540 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
7541 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7542 | - | |||||||||||||||||||||||||||||||||||||
7543 | /*! | - | ||||||||||||||||||||||||||||||||||||
7544 | \overload | - | ||||||||||||||||||||||||||||||||||||
7545 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
7546 | - | |||||||||||||||||||||||||||||||||||||
7547 | \brief The setContentsMargins function sets the margins around the | - | ||||||||||||||||||||||||||||||||||||
7548 | widget's contents. | - | ||||||||||||||||||||||||||||||||||||
7549 | - | |||||||||||||||||||||||||||||||||||||
7550 | Sets the margins around the contents of the widget to have the | - | ||||||||||||||||||||||||||||||||||||
7551 | sizes determined by \a margins. The margins are | - | ||||||||||||||||||||||||||||||||||||
7552 | used by the layout system, and may be used by subclasses to | - | ||||||||||||||||||||||||||||||||||||
7553 | specify the area to draw in (e.g. excluding the frame). | - | ||||||||||||||||||||||||||||||||||||
7554 | - | |||||||||||||||||||||||||||||||||||||
7555 | Changing the margins will trigger a resizeEvent(). | - | ||||||||||||||||||||||||||||||||||||
7556 | - | |||||||||||||||||||||||||||||||||||||
7557 | \sa contentsRect(), getContentsMargins() | - | ||||||||||||||||||||||||||||||||||||
7558 | */ | - | ||||||||||||||||||||||||||||||||||||
7559 | void QWidget::setContentsMargins(const QMargins &margins) | - | ||||||||||||||||||||||||||||||||||||
7560 | { | - | ||||||||||||||||||||||||||||||||||||
7561 | setContentsMargins(margins.left(), margins.top(), | - | ||||||||||||||||||||||||||||||||||||
7562 | margins.right(), margins.bottom()); | - | ||||||||||||||||||||||||||||||||||||
7563 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7564 | - | |||||||||||||||||||||||||||||||||||||
7565 | /*! | - | ||||||||||||||||||||||||||||||||||||
7566 | Returns the widget's contents margins for \a left, \a top, \a | - | ||||||||||||||||||||||||||||||||||||
7567 | right, and \a bottom. | - | ||||||||||||||||||||||||||||||||||||
7568 | - | |||||||||||||||||||||||||||||||||||||
7569 | \sa setContentsMargins(), contentsRect() | - | ||||||||||||||||||||||||||||||||||||
7570 | */ | - | ||||||||||||||||||||||||||||||||||||
7571 | void QWidget::getContentsMargins(int *left, int *top, int *right, int *bottom) const | - | ||||||||||||||||||||||||||||||||||||
7572 | { | - | ||||||||||||||||||||||||||||||||||||
7573 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
7574 | if (left)
| 0 | ||||||||||||||||||||||||||||||||||||
7575 | *left = d->leftmargin; never executed: *left = d->leftmargin; | 0 | ||||||||||||||||||||||||||||||||||||
7576 | if (top)
| 0 | ||||||||||||||||||||||||||||||||||||
7577 | *top = d->topmargin; never executed: *top = d->topmargin; | 0 | ||||||||||||||||||||||||||||||||||||
7578 | if (right)
| 0 | ||||||||||||||||||||||||||||||||||||
7579 | *right = d->rightmargin; never executed: *right = d->rightmargin; | 0 | ||||||||||||||||||||||||||||||||||||
7580 | if (bottom)
| 0 | ||||||||||||||||||||||||||||||||||||
7581 | *bottom = d->bottommargin; never executed: *bottom = d->bottommargin; | 0 | ||||||||||||||||||||||||||||||||||||
7582 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7583 | - | |||||||||||||||||||||||||||||||||||||
7584 | /*! | - | ||||||||||||||||||||||||||||||||||||
7585 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
7586 | - | |||||||||||||||||||||||||||||||||||||
7587 | \brief The contentsMargins function returns the widget's contents margins. | - | ||||||||||||||||||||||||||||||||||||
7588 | - | |||||||||||||||||||||||||||||||||||||
7589 | \sa getContentsMargins(), setContentsMargins(), contentsRect() | - | ||||||||||||||||||||||||||||||||||||
7590 | */ | - | ||||||||||||||||||||||||||||||||||||
7591 | QMargins QWidget::contentsMargins() const | - | ||||||||||||||||||||||||||||||||||||
7592 | { | - | ||||||||||||||||||||||||||||||||||||
7593 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
7594 | return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin); never executed: return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin); | 0 | ||||||||||||||||||||||||||||||||||||
7595 | } | - | ||||||||||||||||||||||||||||||||||||
7596 | - | |||||||||||||||||||||||||||||||||||||
7597 | - | |||||||||||||||||||||||||||||||||||||
7598 | /*! | - | ||||||||||||||||||||||||||||||||||||
7599 | Returns the area inside the widget's margins. | - | ||||||||||||||||||||||||||||||||||||
7600 | - | |||||||||||||||||||||||||||||||||||||
7601 | \sa setContentsMargins(), getContentsMargins() | - | ||||||||||||||||||||||||||||||||||||
7602 | */ | - | ||||||||||||||||||||||||||||||||||||
7603 | QRect QWidget::contentsRect() const | - | ||||||||||||||||||||||||||||||||||||
7604 | { | - | ||||||||||||||||||||||||||||||||||||
7605 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
7606 | 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 | ||||||||||||||||||||||||||||||||||||
7607 | 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 | ||||||||||||||||||||||||||||||||||||
7608 | 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 | ||||||||||||||||||||||||||||||||||||
7609 | - | |||||||||||||||||||||||||||||||||||||
7610 | } | - | ||||||||||||||||||||||||||||||||||||
7611 | - | |||||||||||||||||||||||||||||||||||||
7612 | - | |||||||||||||||||||||||||||||||||||||
7613 | - | |||||||||||||||||||||||||||||||||||||
7614 | /*! | - | ||||||||||||||||||||||||||||||||||||
7615 | \fn void QWidget::customContextMenuRequested(const QPoint &pos) | - | ||||||||||||||||||||||||||||||||||||
7616 | - | |||||||||||||||||||||||||||||||||||||
7617 | This signal is emitted when the widget's \l contextMenuPolicy is | - | ||||||||||||||||||||||||||||||||||||
7618 | Qt::CustomContextMenu, and the user has requested a context menu on | - | ||||||||||||||||||||||||||||||||||||
7619 | the widget. The position \a pos is the position of the context menu | - | ||||||||||||||||||||||||||||||||||||
7620 | event that the widget receives. Normally this is in widget | - | ||||||||||||||||||||||||||||||||||||
7621 | coordinates. The exception to this rule is QAbstractScrollArea and | - | ||||||||||||||||||||||||||||||||||||
7622 | its subclasses that map the context menu event to coordinates of the | - | ||||||||||||||||||||||||||||||||||||
7623 | \l{QAbstractScrollArea::viewport()}{viewport()}. | - | ||||||||||||||||||||||||||||||||||||
7624 | - | |||||||||||||||||||||||||||||||||||||
7625 | - | |||||||||||||||||||||||||||||||||||||
7626 | \sa mapToGlobal(), QMenu, contextMenuPolicy | - | ||||||||||||||||||||||||||||||||||||
7627 | */ | - | ||||||||||||||||||||||||||||||||||||
7628 | - | |||||||||||||||||||||||||||||||||||||
7629 | - | |||||||||||||||||||||||||||||||||||||
7630 | /*! | - | ||||||||||||||||||||||||||||||||||||
7631 | \property QWidget::contextMenuPolicy | - | ||||||||||||||||||||||||||||||||||||
7632 | \brief how the widget shows a context menu | - | ||||||||||||||||||||||||||||||||||||
7633 | - | |||||||||||||||||||||||||||||||||||||
7634 | The default value of this property is Qt::DefaultContextMenu, | - | ||||||||||||||||||||||||||||||||||||
7635 | which means the contextMenuEvent() handler is called. Other values | - | ||||||||||||||||||||||||||||||||||||
7636 | are Qt::NoContextMenu, Qt::PreventContextMenu, | - | ||||||||||||||||||||||||||||||||||||
7637 | Qt::ActionsContextMenu, and Qt::CustomContextMenu. With | - | ||||||||||||||||||||||||||||||||||||
7638 | Qt::CustomContextMenu, the signal customContextMenuRequested() is | - | ||||||||||||||||||||||||||||||||||||
7639 | emitted. | - | ||||||||||||||||||||||||||||||||||||
7640 | - | |||||||||||||||||||||||||||||||||||||
7641 | \sa contextMenuEvent(), customContextMenuRequested(), actions() | - | ||||||||||||||||||||||||||||||||||||
7642 | */ | - | ||||||||||||||||||||||||||||||||||||
7643 | - | |||||||||||||||||||||||||||||||||||||
7644 | Qt::ContextMenuPolicy QWidget::contextMenuPolicy() const | - | ||||||||||||||||||||||||||||||||||||
7645 | { | - | ||||||||||||||||||||||||||||||||||||
7646 | return (Qt::ContextMenuPolicy)data->context_menu_policy; never executed: return (Qt::ContextMenuPolicy)data->context_menu_policy; | 0 | ||||||||||||||||||||||||||||||||||||
7647 | } | - | ||||||||||||||||||||||||||||||||||||
7648 | - | |||||||||||||||||||||||||||||||||||||
7649 | void QWidget::setContextMenuPolicy(Qt::ContextMenuPolicy policy) | - | ||||||||||||||||||||||||||||||||||||
7650 | { | - | ||||||||||||||||||||||||||||||||||||
7651 | data->context_menu_policy = (uint) policy; | - | ||||||||||||||||||||||||||||||||||||
7652 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7653 | - | |||||||||||||||||||||||||||||||||||||
7654 | /*! | - | ||||||||||||||||||||||||||||||||||||
7655 | \property QWidget::focusPolicy | - | ||||||||||||||||||||||||||||||||||||
7656 | \brief the way the widget accepts keyboard focus | - | ||||||||||||||||||||||||||||||||||||
7657 | - | |||||||||||||||||||||||||||||||||||||
7658 | The policy is Qt::TabFocus if the widget accepts keyboard | - | ||||||||||||||||||||||||||||||||||||
7659 | focus by tabbing, Qt::ClickFocus if the widget accepts | - | ||||||||||||||||||||||||||||||||||||
7660 | focus by clicking, Qt::StrongFocus if it accepts both, and | - | ||||||||||||||||||||||||||||||||||||
7661 | Qt::NoFocus (the default) if it does not accept focus at | - | ||||||||||||||||||||||||||||||||||||
7662 | all. | - | ||||||||||||||||||||||||||||||||||||
7663 | - | |||||||||||||||||||||||||||||||||||||
7664 | You must enable keyboard focus for a widget if it processes | - | ||||||||||||||||||||||||||||||||||||
7665 | keyboard events. This is normally done from the widget's | - | ||||||||||||||||||||||||||||||||||||
7666 | constructor. For instance, the QLineEdit constructor calls | - | ||||||||||||||||||||||||||||||||||||
7667 | setFocusPolicy(Qt::StrongFocus). | - | ||||||||||||||||||||||||||||||||||||
7668 | - | |||||||||||||||||||||||||||||||||||||
7669 | If the widget has a focus proxy, then the focus policy will | - | ||||||||||||||||||||||||||||||||||||
7670 | be propagated to it. | - | ||||||||||||||||||||||||||||||||||||
7671 | - | |||||||||||||||||||||||||||||||||||||
7672 | \sa focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), enabled | - | ||||||||||||||||||||||||||||||||||||
7673 | */ | - | ||||||||||||||||||||||||||||||||||||
7674 | - | |||||||||||||||||||||||||||||||||||||
7675 | - | |||||||||||||||||||||||||||||||||||||
7676 | Qt::FocusPolicy QWidget::focusPolicy() const | - | ||||||||||||||||||||||||||||||||||||
7677 | { | - | ||||||||||||||||||||||||||||||||||||
7678 | return (Qt::FocusPolicy)data->focus_policy; never executed: return (Qt::FocusPolicy)data->focus_policy; | 0 | ||||||||||||||||||||||||||||||||||||
7679 | } | - | ||||||||||||||||||||||||||||||||||||
7680 | - | |||||||||||||||||||||||||||||||||||||
7681 | void QWidget::setFocusPolicy(Qt::FocusPolicy policy) | - | ||||||||||||||||||||||||||||||||||||
7682 | { | - | ||||||||||||||||||||||||||||||||||||
7683 | data->focus_policy = (uint) policy; | - | ||||||||||||||||||||||||||||||||||||
7684 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7685 | if (d->extra && d->extra->focus_proxy)
| 0 | ||||||||||||||||||||||||||||||||||||
7686 | d->extra->focus_proxy->setFocusPolicy(policy); never executed: d->extra->focus_proxy->setFocusPolicy(policy); | 0 | ||||||||||||||||||||||||||||||||||||
7687 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7688 | - | |||||||||||||||||||||||||||||||||||||
7689 | /*! | - | ||||||||||||||||||||||||||||||||||||
7690 | \property QWidget::updatesEnabled | - | ||||||||||||||||||||||||||||||||||||
7691 | \brief whether updates are enabled | - | ||||||||||||||||||||||||||||||||||||
7692 | - | |||||||||||||||||||||||||||||||||||||
7693 | An updates enabled widget receives paint events and has a system | - | ||||||||||||||||||||||||||||||||||||
7694 | background; a disabled widget does not. This also implies that | - | ||||||||||||||||||||||||||||||||||||
7695 | calling update() and repaint() has no effect if updates are | - | ||||||||||||||||||||||||||||||||||||
7696 | disabled. | - | ||||||||||||||||||||||||||||||||||||
7697 | - | |||||||||||||||||||||||||||||||||||||
7698 | By default, this property is \c true. | - | ||||||||||||||||||||||||||||||||||||
7699 | - | |||||||||||||||||||||||||||||||||||||
7700 | setUpdatesEnabled() is normally used to disable updates for a | - | ||||||||||||||||||||||||||||||||||||
7701 | short period of time, for instance to avoid screen flicker during | - | ||||||||||||||||||||||||||||||||||||
7702 | large changes. In Qt, widgets normally do not generate screen | - | ||||||||||||||||||||||||||||||||||||
7703 | flicker, but on X11 the server might erase regions on the screen | - | ||||||||||||||||||||||||||||||||||||
7704 | when widgets get hidden before they can be replaced by other | - | ||||||||||||||||||||||||||||||||||||
7705 | widgets. Disabling updates solves this. | - | ||||||||||||||||||||||||||||||||||||
7706 | - | |||||||||||||||||||||||||||||||||||||
7707 | Example: | - | ||||||||||||||||||||||||||||||||||||
7708 | \snippet code/src_gui_kernel_qwidget.cpp 13 | - | ||||||||||||||||||||||||||||||||||||
7709 | - | |||||||||||||||||||||||||||||||||||||
7710 | Disabling a widget implicitly disables all its children. Enabling a widget | - | ||||||||||||||||||||||||||||||||||||
7711 | enables all child widgets \e except top-level widgets or those that | - | ||||||||||||||||||||||||||||||||||||
7712 | have been explicitly disabled. Re-enabling updates implicitly calls | - | ||||||||||||||||||||||||||||||||||||
7713 | update() on the widget. | - | ||||||||||||||||||||||||||||||||||||
7714 | - | |||||||||||||||||||||||||||||||||||||
7715 | \sa paintEvent() | - | ||||||||||||||||||||||||||||||||||||
7716 | */ | - | ||||||||||||||||||||||||||||||||||||
7717 | void QWidget::setUpdatesEnabled(bool enable) | - | ||||||||||||||||||||||||||||||||||||
7718 | { | - | ||||||||||||||||||||||||||||||||||||
7719 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7720 | setAttribute(Qt::WA_ForceUpdatesDisabled, !enable); | - | ||||||||||||||||||||||||||||||||||||
7721 | d->setUpdatesEnabled_helper(enable); | - | ||||||||||||||||||||||||||||||||||||
7722 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7723 | - | |||||||||||||||||||||||||||||||||||||
7724 | /*! | - | ||||||||||||||||||||||||||||||||||||
7725 | Shows the widget and its child widgets. | - | ||||||||||||||||||||||||||||||||||||
7726 | - | |||||||||||||||||||||||||||||||||||||
7727 | This is equivalent to calling showFullScreen(), showMaximized(), or setVisible(true), | - | ||||||||||||||||||||||||||||||||||||
7728 | depending on the platform's default behavior for the window flags. | - | ||||||||||||||||||||||||||||||||||||
7729 | - | |||||||||||||||||||||||||||||||||||||
7730 | \sa raise(), showEvent(), hide(), setVisible(), showMinimized(), showMaximized(), | - | ||||||||||||||||||||||||||||||||||||
7731 | showNormal(), isVisible(), windowFlags() | - | ||||||||||||||||||||||||||||||||||||
7732 | */ | - | ||||||||||||||||||||||||||||||||||||
7733 | void QWidget::show() | - | ||||||||||||||||||||||||||||||||||||
7734 | { | - | ||||||||||||||||||||||||||||||||||||
7735 | Qt::WindowState defaultState = QGuiApplicationPrivate::platformIntegration()->defaultWindowState(data->window_flags); | - | ||||||||||||||||||||||||||||||||||||
7736 | if (defaultState == Qt::WindowFullScreen)
| 0 | ||||||||||||||||||||||||||||||||||||
7737 | showFullScreen(); never executed: showFullScreen(); | 0 | ||||||||||||||||||||||||||||||||||||
7738 | else if (defaultState == Qt::WindowMaximized)
| 0 | ||||||||||||||||||||||||||||||||||||
7739 | showMaximized(); never executed: showMaximized(); | 0 | ||||||||||||||||||||||||||||||||||||
7740 | else | - | ||||||||||||||||||||||||||||||||||||
7741 | setVisible(true); // FIXME: Why not showNormal(), like QWindow::show()? never executed: setVisible(true); | 0 | ||||||||||||||||||||||||||||||||||||
7742 | } | - | ||||||||||||||||||||||||||||||||||||
7743 | - | |||||||||||||||||||||||||||||||||||||
7744 | /*! \internal | - | ||||||||||||||||||||||||||||||||||||
7745 | - | |||||||||||||||||||||||||||||||||||||
7746 | Makes the widget visible in the isVisible() meaning of the word. | - | ||||||||||||||||||||||||||||||||||||
7747 | It is only called for toplevels or widgets with visible parents. | - | ||||||||||||||||||||||||||||||||||||
7748 | */ | - | ||||||||||||||||||||||||||||||||||||
7749 | void QWidgetPrivate::show_recursive() | - | ||||||||||||||||||||||||||||||||||||
7750 | { | - | ||||||||||||||||||||||||||||||||||||
7751 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7752 | // polish if necessary | - | ||||||||||||||||||||||||||||||||||||
7753 | - | |||||||||||||||||||||||||||||||||||||
7754 | if (!q->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
7755 | createRecursively(); never executed: createRecursively(); | 0 | ||||||||||||||||||||||||||||||||||||
7756 | q->ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
7757 | - | |||||||||||||||||||||||||||||||||||||
7758 | if (!q->isWindow() && q->parentWidget()->d_func()->layout && !q->parentWidget()->data->in_show)
| 0 | ||||||||||||||||||||||||||||||||||||
7759 | q->parentWidget()->d_func()->layout->activate(); never executed: q->parentWidget()->d_func()->layout->activate(); | 0 | ||||||||||||||||||||||||||||||||||||
7760 | // activate our layout before we and our children become visible | - | ||||||||||||||||||||||||||||||||||||
7761 | if (layout)
| 0 | ||||||||||||||||||||||||||||||||||||
7762 | layout->activate(); never executed: layout->activate(); | 0 | ||||||||||||||||||||||||||||||||||||
7763 | - | |||||||||||||||||||||||||||||||||||||
7764 | show_helper(); | - | ||||||||||||||||||||||||||||||||||||
7765 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7766 | - | |||||||||||||||||||||||||||||||||||||
7767 | void QWidgetPrivate::sendPendingMoveAndResizeEvents(bool recursive, bool disableUpdates) | - | ||||||||||||||||||||||||||||||||||||
7768 | { | - | ||||||||||||||||||||||||||||||||||||
7769 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7770 | - | |||||||||||||||||||||||||||||||||||||
7771 | disableUpdates = disableUpdates && q->updatesEnabled();
| 0 | ||||||||||||||||||||||||||||||||||||
7772 | if (disableUpdates)
| 0 | ||||||||||||||||||||||||||||||||||||
7773 | q->setAttribute(Qt::WA_UpdatesDisabled); never executed: q->setAttribute(Qt::WA_UpdatesDisabled); | 0 | ||||||||||||||||||||||||||||||||||||
7774 | - | |||||||||||||||||||||||||||||||||||||
7775 | if (q->testAttribute(Qt::WA_PendingMoveEvent)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7776 | QMoveEvent e(data.crect.topLeft(), data.crect.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
7777 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
7778 | q->setAttribute(Qt::WA_PendingMoveEvent, false); | - | ||||||||||||||||||||||||||||||||||||
7779 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7780 | - | |||||||||||||||||||||||||||||||||||||
7781 | if (q->testAttribute(Qt::WA_PendingResizeEvent)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7782 | QResizeEvent e(data.crect.size(), QSize()); | - | ||||||||||||||||||||||||||||||||||||
7783 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||||||||||||||
7784 | q->setAttribute(Qt::WA_PendingResizeEvent, false); | - | ||||||||||||||||||||||||||||||||||||
7785 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7786 | - | |||||||||||||||||||||||||||||||||||||
7787 | if (disableUpdates)
| 0 | ||||||||||||||||||||||||||||||||||||
7788 | q->setAttribute(Qt::WA_UpdatesDisabled, false); never executed: q->setAttribute(Qt::WA_UpdatesDisabled, false); | 0 | ||||||||||||||||||||||||||||||||||||
7789 | - | |||||||||||||||||||||||||||||||||||||
7790 | if (!recursive)
| 0 | ||||||||||||||||||||||||||||||||||||
7791 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
7792 | - | |||||||||||||||||||||||||||||||||||||
7793 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
7794 | if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
| 0 | ||||||||||||||||||||||||||||||||||||
7795 | child->d_func()->sendPendingMoveAndResizeEvents(recursive, disableUpdates); never executed: child->d_func()->sendPendingMoveAndResizeEvents(recursive, disableUpdates); | 0 | ||||||||||||||||||||||||||||||||||||
7796 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7797 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7798 | - | |||||||||||||||||||||||||||||||||||||
7799 | void QWidgetPrivate::activateChildLayoutsRecursively() | - | ||||||||||||||||||||||||||||||||||||
7800 | { | - | ||||||||||||||||||||||||||||||||||||
7801 | sendPendingMoveAndResizeEvents(false, true); | - | ||||||||||||||||||||||||||||||||||||
7802 | - | |||||||||||||||||||||||||||||||||||||
7803 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
7804 | QWidget *child = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
7805 | if (!child || child->isHidden() || child->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7806 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
7807 | - | |||||||||||||||||||||||||||||||||||||
7808 | child->ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
7809 | - | |||||||||||||||||||||||||||||||||||||
7810 | // Activate child's layout | - | ||||||||||||||||||||||||||||||||||||
7811 | QWidgetPrivate *childPrivate = child->d_func(); | - | ||||||||||||||||||||||||||||||||||||
7812 | if (childPrivate->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
7813 | childPrivate->layout->activate(); never executed: childPrivate->layout->activate(); | 0 | ||||||||||||||||||||||||||||||||||||
7814 | - | |||||||||||||||||||||||||||||||||||||
7815 | // Pretend we're visible. | - | ||||||||||||||||||||||||||||||||||||
7816 | const bool wasVisible = child->isVisible(); | - | ||||||||||||||||||||||||||||||||||||
7817 | if (!wasVisible)
| 0 | ||||||||||||||||||||||||||||||||||||
7818 | child->setAttribute(Qt::WA_WState_Visible); never executed: child->setAttribute(Qt::WA_WState_Visible); | 0 | ||||||||||||||||||||||||||||||||||||
7819 | - | |||||||||||||||||||||||||||||||||||||
7820 | // Do the same for all my children. | - | ||||||||||||||||||||||||||||||||||||
7821 | childPrivate->activateChildLayoutsRecursively(); | - | ||||||||||||||||||||||||||||||||||||
7822 | - | |||||||||||||||||||||||||||||||||||||
7823 | // We're not cheating anymore. | - | ||||||||||||||||||||||||||||||||||||
7824 | if (!wasVisible)
| 0 | ||||||||||||||||||||||||||||||||||||
7825 | child->setAttribute(Qt::WA_WState_Visible, false); never executed: child->setAttribute(Qt::WA_WState_Visible, false); | 0 | ||||||||||||||||||||||||||||||||||||
7826 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7827 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7828 | - | |||||||||||||||||||||||||||||||||||||
7829 | void QWidgetPrivate::show_helper() | - | ||||||||||||||||||||||||||||||||||||
7830 | { | - | ||||||||||||||||||||||||||||||||||||
7831 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7832 | data.in_show = true; // qws optimization | - | ||||||||||||||||||||||||||||||||||||
7833 | // make sure we receive pending move and resize events | - | ||||||||||||||||||||||||||||||||||||
7834 | sendPendingMoveAndResizeEvents(); | - | ||||||||||||||||||||||||||||||||||||
7835 | - | |||||||||||||||||||||||||||||||||||||
7836 | // become visible before showing all children | - | ||||||||||||||||||||||||||||||||||||
7837 | q->setAttribute(Qt::WA_WState_Visible); | - | ||||||||||||||||||||||||||||||||||||
7838 | - | |||||||||||||||||||||||||||||||||||||
7839 | // finally show all children recursively | - | ||||||||||||||||||||||||||||||||||||
7840 | showChildren(false); | - | ||||||||||||||||||||||||||||||||||||
7841 | - | |||||||||||||||||||||||||||||||||||||
7842 | - | |||||||||||||||||||||||||||||||||||||
7843 | - | |||||||||||||||||||||||||||||||||||||
7844 | const bool isWindow = q->isWindow(); | - | ||||||||||||||||||||||||||||||||||||
7845 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
7846 | bool isEmbedded = isWindow && q->graphicsProxyWidget() != Q_NULLPTR;
| 0 | ||||||||||||||||||||||||||||||||||||
7847 | #else | - | ||||||||||||||||||||||||||||||||||||
7848 | bool isEmbedded = false; | - | ||||||||||||||||||||||||||||||||||||
7849 | #endif | - | ||||||||||||||||||||||||||||||||||||
7850 | - | |||||||||||||||||||||||||||||||||||||
7851 | // popup handling: new popups and tools need to be raised, and | - | ||||||||||||||||||||||||||||||||||||
7852 | // existing popups must be closed. Also propagate the current | - | ||||||||||||||||||||||||||||||||||||
7853 | // windows's KeyboardFocusChange status. | - | ||||||||||||||||||||||||||||||||||||
7854 | if (isWindow && !isEmbedded) {
| 0 | ||||||||||||||||||||||||||||||||||||
7855 | if ((q->windowType() == Qt::Tool) || (q->windowType() == Qt::Popup) || q->windowType() == Qt::ToolTip) {
| 0 | ||||||||||||||||||||||||||||||||||||
7856 | q->raise(); | - | ||||||||||||||||||||||||||||||||||||
7857 | if (q->parentWidget() && q->parentWidget()->window()->testAttribute(Qt::WA_KeyboardFocusChange))
| 0 | ||||||||||||||||||||||||||||||||||||
7858 | q->setAttribute(Qt::WA_KeyboardFocusChange); never executed: q->setAttribute(Qt::WA_KeyboardFocusChange); | 0 | ||||||||||||||||||||||||||||||||||||
7859 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7860 | while (QApplication::activePopupWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7861 | if (!QApplication::activePopupWidget()->close())
| 0 | ||||||||||||||||||||||||||||||||||||
7862 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
7863 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7864 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7865 | } | - | ||||||||||||||||||||||||||||||||||||
7866 | - | |||||||||||||||||||||||||||||||||||||
7867 | // Automatic embedding of child windows of widgets already embedded into | - | ||||||||||||||||||||||||||||||||||||
7868 | // QGraphicsProxyWidget when they are shown the first time. | - | ||||||||||||||||||||||||||||||||||||
7869 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
7870 | if (isWindow) {
| 0 | ||||||||||||||||||||||||||||||||||||
7871 | if (!isEmbedded && !bypassGraphicsProxyWidget(q)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7872 | QGraphicsProxyWidget *ancestorProxy = nearestGraphicsProxyWidget(q->parentWidget()); | - | ||||||||||||||||||||||||||||||||||||
7873 | if (ancestorProxy) {
| 0 | ||||||||||||||||||||||||||||||||||||
7874 | isEmbedded = true; | - | ||||||||||||||||||||||||||||||||||||
7875 | ancestorProxy->d_func()->embedSubWindow(q); | - | ||||||||||||||||||||||||||||||||||||
7876 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7877 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7878 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7879 | #else | - | ||||||||||||||||||||||||||||||||||||
7880 | Q_UNUSED(isEmbedded); | - | ||||||||||||||||||||||||||||||||||||
7881 | #endif | - | ||||||||||||||||||||||||||||||||||||
7882 | - | |||||||||||||||||||||||||||||||||||||
7883 | // On Windows, show the popup now so that our own focus handling | - | ||||||||||||||||||||||||||||||||||||
7884 | // stores the correct old focus widget even if it's stolen in the | - | ||||||||||||||||||||||||||||||||||||
7885 | // showevent | - | ||||||||||||||||||||||||||||||||||||
7886 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
7887 | if (!isEmbedded && q->windowType() == Qt::Popup) | - | ||||||||||||||||||||||||||||||||||||
7888 | qApp->d_func()->openPopup(q); | - | ||||||||||||||||||||||||||||||||||||
7889 | #endif | - | ||||||||||||||||||||||||||||||||||||
7890 | - | |||||||||||||||||||||||||||||||||||||
7891 | // send the show event before showing the window | - | ||||||||||||||||||||||||||||||||||||
7892 | QShowEvent showEvent; | - | ||||||||||||||||||||||||||||||||||||
7893 | QApplication::sendEvent(q, &showEvent); | - | ||||||||||||||||||||||||||||||||||||
7894 | - | |||||||||||||||||||||||||||||||||||||
7895 | show_sys(); | - | ||||||||||||||||||||||||||||||||||||
7896 | - | |||||||||||||||||||||||||||||||||||||
7897 | if (!isEmbedded && q->windowType() == Qt::Popup)
| 0 | ||||||||||||||||||||||||||||||||||||
7898 | qApp->d_func()->openPopup(q); never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->openPopup(q); | 0 | ||||||||||||||||||||||||||||||||||||
7899 | - | |||||||||||||||||||||||||||||||||||||
7900 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
7901 | if (q->windowType() != Qt::ToolTip) { // Tooltips are read aloud twice in MS narrator.
| 0 | ||||||||||||||||||||||||||||||||||||
7902 | QAccessibleEvent event(q, QAccessible::ObjectShow); | - | ||||||||||||||||||||||||||||||||||||
7903 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
7904 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7905 | #endif | - | ||||||||||||||||||||||||||||||||||||
7906 | - | |||||||||||||||||||||||||||||||||||||
7907 | if (QApplicationPrivate::hidden_focus_widget == q) {
| 0 | ||||||||||||||||||||||||||||||||||||
7908 | QApplicationPrivate::hidden_focus_widget = 0; | - | ||||||||||||||||||||||||||||||||||||
7909 | q->setFocus(Qt::OtherFocusReason); | - | ||||||||||||||||||||||||||||||||||||
7910 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7911 | - | |||||||||||||||||||||||||||||||||||||
7912 | // Process events when showing a Qt::SplashScreen widget before the event loop | - | ||||||||||||||||||||||||||||||||||||
7913 | // is spinnning; otherwise it might not show up on particular platforms. | - | ||||||||||||||||||||||||||||||||||||
7914 | // This makes QSplashScreen behave the same on all platforms. | - | ||||||||||||||||||||||||||||||||||||
7915 | if (!qApp->d_func()->in_exec && q->windowType() == Qt::SplashScreen)
| 0 | ||||||||||||||||||||||||||||||||||||
7916 | QApplication::processEvents(); never executed: QApplication::processEvents(); | 0 | ||||||||||||||||||||||||||||||||||||
7917 | - | |||||||||||||||||||||||||||||||||||||
7918 | data.in_show = false; // reset qws optimization | - | ||||||||||||||||||||||||||||||||||||
7919 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7920 | - | |||||||||||||||||||||||||||||||||||||
7921 | void QWidgetPrivate::show_sys() | - | ||||||||||||||||||||||||||||||||||||
7922 | { | - | ||||||||||||||||||||||||||||||||||||
7923 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
7924 | - | |||||||||||||||||||||||||||||||||||||
7925 | QWindow *window = q->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
7926 | - | |||||||||||||||||||||||||||||||||||||
7927 | if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7928 | invalidateBuffer(q->rect()); | - | ||||||||||||||||||||||||||||||||||||
7929 | q->setAttribute(Qt::WA_Mapped); | - | ||||||||||||||||||||||||||||||||||||
7930 | // add our window the modal window list (native dialogs) | - | ||||||||||||||||||||||||||||||||||||
7931 | if (window && q->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
7932 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
7933 | && (!extra || !extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
7934 | #endif | - | ||||||||||||||||||||||||||||||||||||
7935 | && q->windowModality() != Qt::NonModal) {
| 0 | ||||||||||||||||||||||||||||||||||||
7936 | QGuiApplicationPrivate::showModalWindow(window); | - | ||||||||||||||||||||||||||||||||||||
7937 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7938 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
7939 | } | - | ||||||||||||||||||||||||||||||||||||
7940 | - | |||||||||||||||||||||||||||||||||||||
7941 | if (renderToTexture && !q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7942 | QApplication::postEvent(q->parentWidget(), new QUpdateLaterEvent(q->geometry())); never executed: QApplication::postEvent(q->parentWidget(), new QUpdateLaterEvent(q->geometry())); | 0 | ||||||||||||||||||||||||||||||||||||
7943 | else | - | ||||||||||||||||||||||||||||||||||||
7944 | QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); never executed: QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); | 0 | ||||||||||||||||||||||||||||||||||||
7945 | - | |||||||||||||||||||||||||||||||||||||
7946 | if ((!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow))
| 0 | ||||||||||||||||||||||||||||||||||||
7947 | || q->testAttribute(Qt::WA_OutsideWSRange)) {
| 0 | ||||||||||||||||||||||||||||||||||||
7948 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
7949 | } | - | ||||||||||||||||||||||||||||||||||||
7950 | - | |||||||||||||||||||||||||||||||||||||
7951 | if (window) {
| 0 | ||||||||||||||||||||||||||||||||||||
7952 | if (q->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
7953 | fixPosIncludesFrame(); never executed: fixPosIncludesFrame(); | 0 | ||||||||||||||||||||||||||||||||||||
7954 | QRect geomRect = q->geometry(); | - | ||||||||||||||||||||||||||||||||||||
7955 | if (!q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7956 | QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),QPoint()); | - | ||||||||||||||||||||||||||||||||||||
7957 | geomRect.moveTopLeft(topLeftOfWindow); | - | ||||||||||||||||||||||||||||||||||||
7958 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7959 | const QRect windowRect = window->geometry(); | - | ||||||||||||||||||||||||||||||||||||
7960 | if (windowRect != geomRect) {
| 0 | ||||||||||||||||||||||||||||||||||||
7961 | if (q->testAttribute(Qt::WA_Moved)
| 0 | ||||||||||||||||||||||||||||||||||||
7962 | || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowManagement))
| 0 | ||||||||||||||||||||||||||||||||||||
7963 | window->setGeometry(geomRect); never executed: window->setGeometry(geomRect); | 0 | ||||||||||||||||||||||||||||||||||||
7964 | else | - | ||||||||||||||||||||||||||||||||||||
7965 | window->resize(geomRect.size()); never executed: window->resize(geomRect.size()); | 0 | ||||||||||||||||||||||||||||||||||||
7966 | } | - | ||||||||||||||||||||||||||||||||||||
7967 | - | |||||||||||||||||||||||||||||||||||||
7968 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
7969 | qt_qpa_set_cursor(q, false); // Needed in case cursor was set before show | - | ||||||||||||||||||||||||||||||||||||
7970 | #endif | - | ||||||||||||||||||||||||||||||||||||
7971 | invalidateBuffer(q->rect()); | - | ||||||||||||||||||||||||||||||||||||
7972 | window->setVisible(true); | - | ||||||||||||||||||||||||||||||||||||
7973 | // Was the window moved by the Window system or QPlatformWindow::initialGeometry() ? | - | ||||||||||||||||||||||||||||||||||||
7974 | if (window->isTopLevel()) {
| 0 | ||||||||||||||||||||||||||||||||||||
7975 | const QPoint crectTopLeft = q->data->crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
7976 | const QPoint windowTopLeft = window->geometry().topLeft(); | - | ||||||||||||||||||||||||||||||||||||
7977 | if (crectTopLeft == QPoint(0, 0) && windowTopLeft != crectTopLeft)
| 0 | ||||||||||||||||||||||||||||||||||||
7978 | q->data->crect.moveTopLeft(windowTopLeft); never executed: q->data->crect.moveTopLeft(windowTopLeft); | 0 | ||||||||||||||||||||||||||||||||||||
7979 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7980 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7981 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7982 | - | |||||||||||||||||||||||||||||||||||||
7983 | /*! | - | ||||||||||||||||||||||||||||||||||||
7984 | Hides the widget. This function is equivalent to | - | ||||||||||||||||||||||||||||||||||||
7985 | setVisible(false). | - | ||||||||||||||||||||||||||||||||||||
7986 | - | |||||||||||||||||||||||||||||||||||||
7987 | - | |||||||||||||||||||||||||||||||||||||
7988 | \note If you are working with QDialog or its subclasses and you invoke | - | ||||||||||||||||||||||||||||||||||||
7989 | the show() function after this function, the dialog will be displayed in | - | ||||||||||||||||||||||||||||||||||||
7990 | its original position. | - | ||||||||||||||||||||||||||||||||||||
7991 | - | |||||||||||||||||||||||||||||||||||||
7992 | \sa hideEvent(), isHidden(), show(), setVisible(), isVisible(), close() | - | ||||||||||||||||||||||||||||||||||||
7993 | */ | - | ||||||||||||||||||||||||||||||||||||
7994 | void QWidget::hide() | - | ||||||||||||||||||||||||||||||||||||
7995 | { | - | ||||||||||||||||||||||||||||||||||||
7996 | setVisible(false); | - | ||||||||||||||||||||||||||||||||||||
7997 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
7998 | - | |||||||||||||||||||||||||||||||||||||
7999 | /*!\internal | - | ||||||||||||||||||||||||||||||||||||
8000 | */ | - | ||||||||||||||||||||||||||||||||||||
8001 | void QWidgetPrivate::hide_helper() | - | ||||||||||||||||||||||||||||||||||||
8002 | { | - | ||||||||||||||||||||||||||||||||||||
8003 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8004 | - | |||||||||||||||||||||||||||||||||||||
8005 | bool isEmbedded = false; | - | ||||||||||||||||||||||||||||||||||||
8006 | #if !defined QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
8007 | isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != 0;
| 0 | ||||||||||||||||||||||||||||||||||||
8008 | #else | - | ||||||||||||||||||||||||||||||||||||
8009 | Q_UNUSED(isEmbedded); | - | ||||||||||||||||||||||||||||||||||||
8010 | #endif | - | ||||||||||||||||||||||||||||||||||||
8011 | - | |||||||||||||||||||||||||||||||||||||
8012 | if (!isEmbedded && (q->windowType() == Qt::Popup))
| 0 | ||||||||||||||||||||||||||||||||||||
8013 | qApp->d_func()->closePopup(q); never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->closePopup(q); | 0 | ||||||||||||||||||||||||||||||||||||
8014 | - | |||||||||||||||||||||||||||||||||||||
8015 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
8016 | if (q->isWindow() && !(q->windowType() == Qt::Popup) && q->parentWidget() | - | ||||||||||||||||||||||||||||||||||||
8017 | && !q->parentWidget()->isHidden() && q->isActiveWindow()) | - | ||||||||||||||||||||||||||||||||||||
8018 | q->parentWidget()->activateWindow(); // Activate parent | - | ||||||||||||||||||||||||||||||||||||
8019 | #endif | - | ||||||||||||||||||||||||||||||||||||
8020 | - | |||||||||||||||||||||||||||||||||||||
8021 | q->setAttribute(Qt::WA_Mapped, false); | - | ||||||||||||||||||||||||||||||||||||
8022 | hide_sys(); | - | ||||||||||||||||||||||||||||||||||||
8023 | - | |||||||||||||||||||||||||||||||||||||
8024 | bool wasVisible = q->testAttribute(Qt::WA_WState_Visible); | - | ||||||||||||||||||||||||||||||||||||
8025 | - | |||||||||||||||||||||||||||||||||||||
8026 | if (wasVisible) {
| 0 | ||||||||||||||||||||||||||||||||||||
8027 | q->setAttribute(Qt::WA_WState_Visible, false); | - | ||||||||||||||||||||||||||||||||||||
8028 | - | |||||||||||||||||||||||||||||||||||||
8029 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8030 | - | |||||||||||||||||||||||||||||||||||||
8031 | QHideEvent hideEvent; | - | ||||||||||||||||||||||||||||||||||||
8032 | QApplication::sendEvent(q, &hideEvent); | - | ||||||||||||||||||||||||||||||||||||
8033 | hideChildren(false); | - | ||||||||||||||||||||||||||||||||||||
8034 | - | |||||||||||||||||||||||||||||||||||||
8035 | // next bit tries to move the focus if the focus widget is now | - | ||||||||||||||||||||||||||||||||||||
8036 | // hidden. | - | ||||||||||||||||||||||||||||||||||||
8037 | if (wasVisible) {
| 0 | ||||||||||||||||||||||||||||||||||||
8038 | qApp->d_func()->sendSyntheticEnterLeave(q); | - | ||||||||||||||||||||||||||||||||||||
8039 | QWidget *fw = QApplication::focusWidget(); | - | ||||||||||||||||||||||||||||||||||||
8040 | while (fw && !fw->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8041 | if (fw == q) {
| 0 | ||||||||||||||||||||||||||||||||||||
8042 | q->focusNextPrevChild(true); | - | ||||||||||||||||||||||||||||||||||||
8043 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8044 | } | - | ||||||||||||||||||||||||||||||||||||
8045 | fw = fw->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8046 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8047 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8048 | - | |||||||||||||||||||||||||||||||||||||
8049 | if (QWidgetBackingStore *bs = maybeBackingStore())
| 0 | ||||||||||||||||||||||||||||||||||||
8050 | bs->removeDirtyWidget(q); never executed: bs->removeDirtyWidget(q); | 0 | ||||||||||||||||||||||||||||||||||||
8051 | - | |||||||||||||||||||||||||||||||||||||
8052 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
8053 | if (wasVisible) {
| 0 | ||||||||||||||||||||||||||||||||||||
8054 | QAccessibleEvent event(q, QAccessible::ObjectHide); | - | ||||||||||||||||||||||||||||||||||||
8055 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
8056 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8057 | #endif | - | ||||||||||||||||||||||||||||||||||||
8058 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8059 | - | |||||||||||||||||||||||||||||||||||||
8060 | void QWidgetPrivate::hide_sys() | - | ||||||||||||||||||||||||||||||||||||
8061 | { | - | ||||||||||||||||||||||||||||||||||||
8062 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8063 | - | |||||||||||||||||||||||||||||||||||||
8064 | QWindow *window = q->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
8065 | - | |||||||||||||||||||||||||||||||||||||
8066 | if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
| 0 | ||||||||||||||||||||||||||||||||||||
8067 | q->setAttribute(Qt::WA_Mapped, false); | - | ||||||||||||||||||||||||||||||||||||
8068 | // remove our window from the modal window list (native dialogs) | - | ||||||||||||||||||||||||||||||||||||
8069 | if (window && q->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
8070 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
8071 | && (!extra || !extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
8072 | #endif | - | ||||||||||||||||||||||||||||||||||||
8073 | && q->windowModality() != Qt::NonModal) {
| 0 | ||||||||||||||||||||||||||||||||||||
8074 | QGuiApplicationPrivate::hideModalWindow(window); | - | ||||||||||||||||||||||||||||||||||||
8075 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8076 | // do not return here, if window non-zero, we must hide it | - | ||||||||||||||||||||||||||||||||||||
8077 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8078 | - | |||||||||||||||||||||||||||||||||||||
8079 | deactivateWidgetCleanup(); | - | ||||||||||||||||||||||||||||||||||||
8080 | - | |||||||||||||||||||||||||||||||||||||
8081 | if (!q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8082 | QWidget *p = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8083 | if (p &&p->isVisible()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8084 | if (renderToTexture)
| 0 | ||||||||||||||||||||||||||||||||||||
8085 | p->d_func()->invalidateBuffer(q->geometry()); never executed: p->d_func()->invalidateBuffer(q->geometry()); | 0 | ||||||||||||||||||||||||||||||||||||
8086 | else | - | ||||||||||||||||||||||||||||||||||||
8087 | invalidateBuffer(q->rect()); never executed: invalidateBuffer(q->rect()); | 0 | ||||||||||||||||||||||||||||||||||||
8088 | } | - | ||||||||||||||||||||||||||||||||||||
8089 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8090 | invalidateBuffer(q->rect()); | - | ||||||||||||||||||||||||||||||||||||
8091 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8092 | - | |||||||||||||||||||||||||||||||||||||
8093 | if (window)
| 0 | ||||||||||||||||||||||||||||||||||||
8094 | window->setVisible(false); never executed: window->setVisible(false); | 0 | ||||||||||||||||||||||||||||||||||||
8095 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8096 | - | |||||||||||||||||||||||||||||||||||||
8097 | /*! | - | ||||||||||||||||||||||||||||||||||||
8098 | \fn bool QWidget::isHidden() const | - | ||||||||||||||||||||||||||||||||||||
8099 | - | |||||||||||||||||||||||||||||||||||||
8100 | Returns \c true if the widget is hidden, otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
8101 | - | |||||||||||||||||||||||||||||||||||||
8102 | A hidden widget will only become visible when show() is called on | - | ||||||||||||||||||||||||||||||||||||
8103 | it. It will not be automatically shown when the parent is shown. | - | ||||||||||||||||||||||||||||||||||||
8104 | - | |||||||||||||||||||||||||||||||||||||
8105 | To check visibility, use !isVisible() instead (notice the exclamation mark). | - | ||||||||||||||||||||||||||||||||||||
8106 | - | |||||||||||||||||||||||||||||||||||||
8107 | isHidden() implies !isVisible(), but a widget can be not visible | - | ||||||||||||||||||||||||||||||||||||
8108 | and not hidden at the same time. This is the case for widgets that are children of | - | ||||||||||||||||||||||||||||||||||||
8109 | widgets that are not visible. | - | ||||||||||||||||||||||||||||||||||||
8110 | - | |||||||||||||||||||||||||||||||||||||
8111 | - | |||||||||||||||||||||||||||||||||||||
8112 | Widgets are hidden if: | - | ||||||||||||||||||||||||||||||||||||
8113 | \list | - | ||||||||||||||||||||||||||||||||||||
8114 | \li they were created as independent windows, | - | ||||||||||||||||||||||||||||||||||||
8115 | \li they were created as children of visible widgets, | - | ||||||||||||||||||||||||||||||||||||
8116 | \li hide() or setVisible(false) was called. | - | ||||||||||||||||||||||||||||||||||||
8117 | \endlist | - | ||||||||||||||||||||||||||||||||||||
8118 | */ | - | ||||||||||||||||||||||||||||||||||||
8119 | - | |||||||||||||||||||||||||||||||||||||
8120 | - | |||||||||||||||||||||||||||||||||||||
8121 | void QWidget::setVisible(bool visible) | - | ||||||||||||||||||||||||||||||||||||
8122 | { | - | ||||||||||||||||||||||||||||||||||||
8123 | if (visible) { // show
| 0 | ||||||||||||||||||||||||||||||||||||
8124 | if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
| 0 | ||||||||||||||||||||||||||||||||||||
8125 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
8126 | - | |||||||||||||||||||||||||||||||||||||
8127 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8128 | - | |||||||||||||||||||||||||||||||||||||
8129 | // Designer uses a trick to make grabWidget work without showing | - | ||||||||||||||||||||||||||||||||||||
8130 | if (!isWindow() && parentWidget() && parentWidget()->isVisible()
| 0 | ||||||||||||||||||||||||||||||||||||
8131 | && !parentWidget()->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
8132 | parentWidget()->window()->d_func()->createRecursively(); never executed: parentWidget()->window()->d_func()->createRecursively(); | 0 | ||||||||||||||||||||||||||||||||||||
8133 | - | |||||||||||||||||||||||||||||||||||||
8134 | //create toplevels but not children of non-visible parents | - | ||||||||||||||||||||||||||||||||||||
8135 | QWidget *pw = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8136 | if (!testAttribute(Qt::WA_WState_Created)
| 0 | ||||||||||||||||||||||||||||||||||||
8137 | && (isWindow() || pw->testAttribute(Qt::WA_WState_Created))) {
| 0 | ||||||||||||||||||||||||||||||||||||
8138 | create(); | - | ||||||||||||||||||||||||||||||||||||
8139 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8140 | - | |||||||||||||||||||||||||||||||||||||
8141 | bool wasResized = testAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||||||||||||||
8142 | Qt::WindowStates initialWindowState = windowState(); | - | ||||||||||||||||||||||||||||||||||||
8143 | - | |||||||||||||||||||||||||||||||||||||
8144 | // polish if necessary | - | ||||||||||||||||||||||||||||||||||||
8145 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
8146 | - | |||||||||||||||||||||||||||||||||||||
8147 | // remember that show was called explicitly | - | ||||||||||||||||||||||||||||||||||||
8148 | setAttribute(Qt::WA_WState_ExplicitShowHide); | - | ||||||||||||||||||||||||||||||||||||
8149 | // whether we need to inform the parent widget immediately | - | ||||||||||||||||||||||||||||||||||||
8150 | bool needUpdateGeometry = !isWindow() && testAttribute(Qt::WA_WState_Hidden);
| 0 | ||||||||||||||||||||||||||||||||||||
8151 | // we are no longer hidden | - | ||||||||||||||||||||||||||||||||||||
8152 | setAttribute(Qt::WA_WState_Hidden, false); | - | ||||||||||||||||||||||||||||||||||||
8153 | - | |||||||||||||||||||||||||||||||||||||
8154 | if (needUpdateGeometry)
| 0 | ||||||||||||||||||||||||||||||||||||
8155 | d->updateGeometry_helper(true); never executed: d->updateGeometry_helper(true); | 0 | ||||||||||||||||||||||||||||||||||||
8156 | - | |||||||||||||||||||||||||||||||||||||
8157 | // activate our layout before we and our children become visible | - | ||||||||||||||||||||||||||||||||||||
8158 | if (d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
8159 | d->layout->activate(); never executed: d->layout->activate(); | 0 | ||||||||||||||||||||||||||||||||||||
8160 | - | |||||||||||||||||||||||||||||||||||||
8161 | if (!isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8162 | QWidget *parent = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8163 | while (parent && parent->isVisible() && parent->d_func()->layout && !parent->data->in_show) {
| 0 | ||||||||||||||||||||||||||||||||||||
8164 | parent->d_func()->layout->activate(); | - | ||||||||||||||||||||||||||||||||||||
8165 | if (parent->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
8166 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8167 | parent = parent->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8168 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8169 | if (parent)
| 0 | ||||||||||||||||||||||||||||||||||||
8170 | parent->d_func()->setDirtyOpaqueRegion(); never executed: parent->d_func()->setDirtyOpaqueRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
8171 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8172 | - | |||||||||||||||||||||||||||||||||||||
8173 | // adjust size if necessary | - | ||||||||||||||||||||||||||||||||||||
8174 | if (!wasResized
| 0 | ||||||||||||||||||||||||||||||||||||
8175 | && (isWindow() || !parentWidget()->d_func()->layout)) {
| 0 | ||||||||||||||||||||||||||||||||||||
8176 | if (isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8177 | adjustSize(); | - | ||||||||||||||||||||||||||||||||||||
8178 | if (windowState() != initialWindowState)
| 0 | ||||||||||||||||||||||||||||||||||||
8179 | setWindowState(initialWindowState); never executed: setWindowState(initialWindowState); | 0 | ||||||||||||||||||||||||||||||||||||
8180 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8181 | adjustSize(); | - | ||||||||||||||||||||||||||||||||||||
8182 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8183 | setAttribute(Qt::WA_Resized, false); | - | ||||||||||||||||||||||||||||||||||||
8184 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8185 | - | |||||||||||||||||||||||||||||||||||||
8186 | setAttribute(Qt::WA_KeyboardFocusChange, false); | - | ||||||||||||||||||||||||||||||||||||
8187 | - | |||||||||||||||||||||||||||||||||||||
8188 | if (isWindow() || parentWidget()->isVisible()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8189 | d->show_helper(); | - | ||||||||||||||||||||||||||||||||||||
8190 | - | |||||||||||||||||||||||||||||||||||||
8191 | qApp->d_func()->sendSyntheticEnterLeave(this); | - | ||||||||||||||||||||||||||||||||||||
8192 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8193 | - | |||||||||||||||||||||||||||||||||||||
8194 | QEvent showToParentEvent(QEvent::ShowToParent); | - | ||||||||||||||||||||||||||||||||||||
8195 | QApplication::sendEvent(this, &showToParentEvent); | - | ||||||||||||||||||||||||||||||||||||
8196 | } else { // hide never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8197 | if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
| 0 | ||||||||||||||||||||||||||||||||||||
8198 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
8199 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
8200 | // reset WS_DISABLED style in a Blocked window | - | ||||||||||||||||||||||||||||||||||||
8201 | if(isWindow() && testAttribute(Qt::WA_WState_Created) | - | ||||||||||||||||||||||||||||||||||||
8202 | && QApplicationPrivate::isBlockedByModal(this)) | - | ||||||||||||||||||||||||||||||||||||
8203 | { | - | ||||||||||||||||||||||||||||||||||||
8204 | LONG dwStyle = GetWindowLong(winId(), GWL_STYLE); | - | ||||||||||||||||||||||||||||||||||||
8205 | dwStyle &= ~WS_DISABLED; | - | ||||||||||||||||||||||||||||||||||||
8206 | SetWindowLong(winId(), GWL_STYLE, dwStyle); | - | ||||||||||||||||||||||||||||||||||||
8207 | } | - | ||||||||||||||||||||||||||||||||||||
8208 | #endif | - | ||||||||||||||||||||||||||||||||||||
8209 | if (QApplicationPrivate::hidden_focus_widget == this)
| 0 | ||||||||||||||||||||||||||||||||||||
8210 | QApplicationPrivate::hidden_focus_widget = 0; never executed: QApplicationPrivate::hidden_focus_widget = 0; | 0 | ||||||||||||||||||||||||||||||||||||
8211 | - | |||||||||||||||||||||||||||||||||||||
8212 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8213 | - | |||||||||||||||||||||||||||||||||||||
8214 | // hw: The test on getOpaqueRegion() needs to be more intelligent | - | ||||||||||||||||||||||||||||||||||||
8215 | // currently it doesn't work if the widget is hidden (the region will | - | ||||||||||||||||||||||||||||||||||||
8216 | // be clipped). The real check should be testing the cached region | - | ||||||||||||||||||||||||||||||||||||
8217 | // (and dirty flag) directly. | - | ||||||||||||||||||||||||||||||||||||
8218 | if (!isWindow() && parentWidget()) // && !d->getOpaqueRegion().isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
8219 | parentWidget()->d_func()->setDirtyOpaqueRegion(); never executed: parentWidget()->d_func()->setDirtyOpaqueRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
8220 | - | |||||||||||||||||||||||||||||||||||||
8221 | setAttribute(Qt::WA_WState_Hidden); | - | ||||||||||||||||||||||||||||||||||||
8222 | setAttribute(Qt::WA_WState_ExplicitShowHide); | - | ||||||||||||||||||||||||||||||||||||
8223 | if (testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
8224 | d->hide_helper(); never executed: d->hide_helper(); | 0 | ||||||||||||||||||||||||||||||||||||
8225 | - | |||||||||||||||||||||||||||||||||||||
8226 | // invalidate layout similar to updateGeometry() | - | ||||||||||||||||||||||||||||||||||||
8227 | if (!isWindow() && parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8228 | if (parentWidget()->d_func()->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
8229 | parentWidget()->d_func()->layout->invalidate(); never executed: parentWidget()->d_func()->layout->invalidate(); | 0 | ||||||||||||||||||||||||||||||||||||
8230 | else if (parentWidget()->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
8231 | QApplication::postEvent(parentWidget(), new QEvent(QEvent::LayoutRequest)); never executed: QApplication::postEvent(parentWidget(), new QEvent(QEvent::LayoutRequest)); | 0 | ||||||||||||||||||||||||||||||||||||
8232 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8233 | - | |||||||||||||||||||||||||||||||||||||
8234 | QEvent hideToParentEvent(QEvent::HideToParent); | - | ||||||||||||||||||||||||||||||||||||
8235 | QApplication::sendEvent(this, &hideToParentEvent); | - | ||||||||||||||||||||||||||||||||||||
8236 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8237 | } | - | ||||||||||||||||||||||||||||||||||||
8238 | - | |||||||||||||||||||||||||||||||||||||
8239 | /*! | - | ||||||||||||||||||||||||||||||||||||
8240 | Convenience function, equivalent to setVisible(!\a hidden). | - | ||||||||||||||||||||||||||||||||||||
8241 | */ | - | ||||||||||||||||||||||||||||||||||||
8242 | void QWidget::setHidden(bool hidden) | - | ||||||||||||||||||||||||||||||||||||
8243 | { | - | ||||||||||||||||||||||||||||||||||||
8244 | setVisible(!hidden); | - | ||||||||||||||||||||||||||||||||||||
8245 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8246 | - | |||||||||||||||||||||||||||||||||||||
8247 | void QWidgetPrivate::_q_showIfNotHidden() | - | ||||||||||||||||||||||||||||||||||||
8248 | { | - | ||||||||||||||||||||||||||||||||||||
8249 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8250 | if ( !(q->isHidden() && q->testAttribute(Qt::WA_WState_ExplicitShowHide)) )
| 0 | ||||||||||||||||||||||||||||||||||||
8251 | q->setVisible(true); never executed: q->setVisible(true); | 0 | ||||||||||||||||||||||||||||||||||||
8252 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8253 | - | |||||||||||||||||||||||||||||||||||||
8254 | void QWidgetPrivate::showChildren(bool spontaneous) | - | ||||||||||||||||||||||||||||||||||||
8255 | { | - | ||||||||||||||||||||||||||||||||||||
8256 | QList<QObject*> childList = children; | - | ||||||||||||||||||||||||||||||||||||
8257 | for (int i = 0; i < childList.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
8258 | QWidget *widget = qobject_cast<QWidget*>(childList.at(i)); | - | ||||||||||||||||||||||||||||||||||||
8259 | if (!widget
| 0 | ||||||||||||||||||||||||||||||||||||
8260 | || widget->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
8261 | || widget->testAttribute(Qt::WA_WState_Hidden))
| 0 | ||||||||||||||||||||||||||||||||||||
8262 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
8263 | if (spontaneous) {
| 0 | ||||||||||||||||||||||||||||||||||||
8264 | widget->setAttribute(Qt::WA_Mapped); | - | ||||||||||||||||||||||||||||||||||||
8265 | widget->d_func()->showChildren(true); | - | ||||||||||||||||||||||||||||||||||||
8266 | QShowEvent e; | - | ||||||||||||||||||||||||||||||||||||
8267 | QApplication::sendSpontaneousEvent(widget, &e); | - | ||||||||||||||||||||||||||||||||||||
8268 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8269 | if (widget->testAttribute(Qt::WA_WState_ExplicitShowHide))
| 0 | ||||||||||||||||||||||||||||||||||||
8270 | widget->d_func()->show_recursive(); never executed: widget->d_func()->show_recursive(); | 0 | ||||||||||||||||||||||||||||||||||||
8271 | else | - | ||||||||||||||||||||||||||||||||||||
8272 | widget->show(); never executed: widget->show(); | 0 | ||||||||||||||||||||||||||||||||||||
8273 | } | - | ||||||||||||||||||||||||||||||||||||
8274 | } | - | ||||||||||||||||||||||||||||||||||||
8275 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8276 | - | |||||||||||||||||||||||||||||||||||||
8277 | void QWidgetPrivate::hideChildren(bool spontaneous) | - | ||||||||||||||||||||||||||||||||||||
8278 | { | - | ||||||||||||||||||||||||||||||||||||
8279 | QList<QObject*> childList = children; | - | ||||||||||||||||||||||||||||||||||||
8280 | for (int i = 0; i < childList.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
8281 | QWidget *widget = qobject_cast<QWidget*>(childList.at(i)); | - | ||||||||||||||||||||||||||||||||||||
8282 | if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden))
| 0 | ||||||||||||||||||||||||||||||||||||
8283 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
8284 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
8285 | // Before doing anything we need to make sure that we don't leave anything in a non-consistent state. | - | ||||||||||||||||||||||||||||||||||||
8286 | // When hiding a widget we need to make sure that no mouse_down events are active, because | - | ||||||||||||||||||||||||||||||||||||
8287 | // the mouse_up event will never be received by a hidden widget or one of its descendants. | - | ||||||||||||||||||||||||||||||||||||
8288 | // The solution is simple, before going through with this we check if there are any mouse_down events in | - | ||||||||||||||||||||||||||||||||||||
8289 | // progress, if so we check if it is related to this widget or not. If so, we just reset the mouse_down and | - | ||||||||||||||||||||||||||||||||||||
8290 | // then we continue. | - | ||||||||||||||||||||||||||||||||||||
8291 | // In X11 and Windows we send a mouse_release event, however we don't do that here because we were already | - | ||||||||||||||||||||||||||||||||||||
8292 | // ignoring that from before. I.e. Carbon did not send the mouse release event, so we will not send the | - | ||||||||||||||||||||||||||||||||||||
8293 | // mouse release event. There are two ways to interpret this: | - | ||||||||||||||||||||||||||||||||||||
8294 | // 1. If we don't send the mouse release event, the widget might get into an inconsistent state, i.e. it | - | ||||||||||||||||||||||||||||||||||||
8295 | // might be waiting for a release event that will never arrive. | - | ||||||||||||||||||||||||||||||||||||
8296 | // 2. If we send the mouse release event, then the widget might decide to trigger an action that is not | - | ||||||||||||||||||||||||||||||||||||
8297 | // supposed to trigger because it is not visible. | - | ||||||||||||||||||||||||||||||||||||
8298 | if(widget == qt_button_down) | - | ||||||||||||||||||||||||||||||||||||
8299 | qt_button_down = 0; | - | ||||||||||||||||||||||||||||||||||||
8300 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
8301 | if (spontaneous)
| 0 | ||||||||||||||||||||||||||||||||||||
8302 | widget->setAttribute(Qt::WA_Mapped, false); never executed: widget->setAttribute(Qt::WA_Mapped, false); | 0 | ||||||||||||||||||||||||||||||||||||
8303 | else | - | ||||||||||||||||||||||||||||||||||||
8304 | widget->setAttribute(Qt::WA_WState_Visible, false); never executed: widget->setAttribute(Qt::WA_WState_Visible, false); | 0 | ||||||||||||||||||||||||||||||||||||
8305 | widget->d_func()->hideChildren(spontaneous); | - | ||||||||||||||||||||||||||||||||||||
8306 | QHideEvent e; | - | ||||||||||||||||||||||||||||||||||||
8307 | if (spontaneous) {
| 0 | ||||||||||||||||||||||||||||||||||||
8308 | QApplication::sendSpontaneousEvent(widget, &e); | - | ||||||||||||||||||||||||||||||||||||
8309 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8310 | QApplication::sendEvent(widget, &e); | - | ||||||||||||||||||||||||||||||||||||
8311 | if (widget->internalWinId()
| 0 | ||||||||||||||||||||||||||||||||||||
8312 | && widget->testAttribute(Qt::WA_DontCreateNativeAncestors)) {
| 0 | ||||||||||||||||||||||||||||||||||||
8313 | // hide_sys() on an ancestor won't have any affect on this | - | ||||||||||||||||||||||||||||||||||||
8314 | // widget, so it needs an explicit hide_sys() of its own | - | ||||||||||||||||||||||||||||||||||||
8315 | widget->d_func()->hide_sys(); | - | ||||||||||||||||||||||||||||||||||||
8316 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8317 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8318 | qApp->d_func()->sendSyntheticEnterLeave(widget); | - | ||||||||||||||||||||||||||||||||||||
8319 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
8320 | if (!spontaneous) {
| 0 | ||||||||||||||||||||||||||||||||||||
8321 | QAccessibleEvent event(widget, QAccessible::ObjectHide); | - | ||||||||||||||||||||||||||||||||||||
8322 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
8323 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8324 | #endif | - | ||||||||||||||||||||||||||||||||||||
8325 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8326 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8327 | - | |||||||||||||||||||||||||||||||||||||
8328 | bool QWidgetPrivate::close_helper(CloseMode mode) | - | ||||||||||||||||||||||||||||||||||||
8329 | { | - | ||||||||||||||||||||||||||||||||||||
8330 | if (data.is_closing)
| 0 | ||||||||||||||||||||||||||||||||||||
8331 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
8332 | - | |||||||||||||||||||||||||||||||||||||
8333 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8334 | data.is_closing = 1; | - | ||||||||||||||||||||||||||||||||||||
8335 | - | |||||||||||||||||||||||||||||||||||||
8336 | QPointer<QWidget> that = q; | - | ||||||||||||||||||||||||||||||||||||
8337 | QPointer<QWidget> parentWidget = q->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8338 | - | |||||||||||||||||||||||||||||||||||||
8339 | bool quitOnClose = q->testAttribute(Qt::WA_QuitOnClose); | - | ||||||||||||||||||||||||||||||||||||
8340 | if (mode != CloseNoEvent) {
| 0 | ||||||||||||||||||||||||||||||||||||
8341 | QCloseEvent e; | - | ||||||||||||||||||||||||||||||||||||
8342 | if (mode == CloseWithSpontaneousEvent)
| 0 | ||||||||||||||||||||||||||||||||||||
8343 | QApplication::sendSpontaneousEvent(q, &e); never executed: QApplication::sendSpontaneousEvent(q, &e); | 0 | ||||||||||||||||||||||||||||||||||||
8344 | else | - | ||||||||||||||||||||||||||||||||||||
8345 | QApplication::sendEvent(q, &e); never executed: QApplication::sendEvent(q, &e); | 0 | ||||||||||||||||||||||||||||||||||||
8346 | if (!that.isNull() && !e.isAccepted()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8347 | data.is_closing = 0; | - | ||||||||||||||||||||||||||||||||||||
8348 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
8349 | } | - | ||||||||||||||||||||||||||||||||||||
8350 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8351 | - | |||||||||||||||||||||||||||||||||||||
8352 | if (!that.isNull() && !q->isHidden())
| 0 | ||||||||||||||||||||||||||||||||||||
8353 | q->hide(); never executed: q->hide(); | 0 | ||||||||||||||||||||||||||||||||||||
8354 | - | |||||||||||||||||||||||||||||||||||||
8355 | // Attempt to close the application only if this has WA_QuitOnClose set and a non-visible parent | - | ||||||||||||||||||||||||||||||||||||
8356 | quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible());
| 0 | ||||||||||||||||||||||||||||||||||||
8357 | - | |||||||||||||||||||||||||||||||||||||
8358 | if (quitOnClose) {
| 0 | ||||||||||||||||||||||||||||||||||||
8359 | /* if there is no non-withdrawn primary window left (except | - | ||||||||||||||||||||||||||||||||||||
8360 | the ones without QuitOnClose), we emit the lastWindowClosed | - | ||||||||||||||||||||||||||||||||||||
8361 | signal */ | - | ||||||||||||||||||||||||||||||||||||
8362 | QWidgetList list = QApplication::topLevelWidgets(); | - | ||||||||||||||||||||||||||||||||||||
8363 | bool lastWindowClosed = true; | - | ||||||||||||||||||||||||||||||||||||
8364 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
8365 | QWidget *w = list.at(i); | - | ||||||||||||||||||||||||||||||||||||
8366 | if (!w->isVisible() || w->parentWidget() || !w->testAttribute(Qt::WA_QuitOnClose))
| 0 | ||||||||||||||||||||||||||||||||||||
8367 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
8368 | lastWindowClosed = false; | - | ||||||||||||||||||||||||||||||||||||
8369 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8370 | } | - | ||||||||||||||||||||||||||||||||||||
8371 | if (lastWindowClosed) {
| 0 | ||||||||||||||||||||||||||||||||||||
8372 | QGuiApplicationPrivate::emitLastWindowClosed(); | - | ||||||||||||||||||||||||||||||||||||
8373 | QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance())); | - | ||||||||||||||||||||||||||||||||||||
8374 | applicationPrivate->maybeQuit(); | - | ||||||||||||||||||||||||||||||||||||
8375 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8376 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8377 | - | |||||||||||||||||||||||||||||||||||||
8378 | - | |||||||||||||||||||||||||||||||||||||
8379 | if (!that.isNull()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8380 | data.is_closing = 0; | - | ||||||||||||||||||||||||||||||||||||
8381 | if (q->testAttribute(Qt::WA_DeleteOnClose)) {
| 0 | ||||||||||||||||||||||||||||||||||||
8382 | q->setAttribute(Qt::WA_DeleteOnClose, false); | - | ||||||||||||||||||||||||||||||||||||
8383 | q->deleteLater(); | - | ||||||||||||||||||||||||||||||||||||
8384 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8385 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8386 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
8387 | } | - | ||||||||||||||||||||||||||||||||||||
8388 | - | |||||||||||||||||||||||||||||||||||||
8389 | - | |||||||||||||||||||||||||||||||||||||
8390 | /*! | - | ||||||||||||||||||||||||||||||||||||
8391 | Closes this widget. Returns \c true if the widget was closed; | - | ||||||||||||||||||||||||||||||||||||
8392 | otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
8393 | - | |||||||||||||||||||||||||||||||||||||
8394 | First it sends the widget a QCloseEvent. The widget is | - | ||||||||||||||||||||||||||||||||||||
8395 | \l{hide()}{hidden} if it \l{QEvent::accept()}{accepts} | - | ||||||||||||||||||||||||||||||||||||
8396 | the close event. If it \l{QEvent::ignore()}{ignores} | - | ||||||||||||||||||||||||||||||||||||
8397 | the event, nothing happens. The default | - | ||||||||||||||||||||||||||||||||||||
8398 | implementation of QWidget::closeEvent() accepts the close event. | - | ||||||||||||||||||||||||||||||||||||
8399 | - | |||||||||||||||||||||||||||||||||||||
8400 | If the widget has the Qt::WA_DeleteOnClose flag, the widget | - | ||||||||||||||||||||||||||||||||||||
8401 | is also deleted. A close events is delivered to the widget no | - | ||||||||||||||||||||||||||||||||||||
8402 | matter if the widget is visible or not. | - | ||||||||||||||||||||||||||||||||||||
8403 | - | |||||||||||||||||||||||||||||||||||||
8404 | The \l QApplication::lastWindowClosed() signal is emitted when the | - | ||||||||||||||||||||||||||||||||||||
8405 | last visible primary window (i.e. window with no parent) with the | - | ||||||||||||||||||||||||||||||||||||
8406 | Qt::WA_QuitOnClose attribute set is closed. By default this | - | ||||||||||||||||||||||||||||||||||||
8407 | attribute is set for all widgets except transient windows such as | - | ||||||||||||||||||||||||||||||||||||
8408 | splash screens, tool windows, and popup menus. | - | ||||||||||||||||||||||||||||||||||||
8409 | - | |||||||||||||||||||||||||||||||||||||
8410 | */ | - | ||||||||||||||||||||||||||||||||||||
8411 | - | |||||||||||||||||||||||||||||||||||||
8412 | bool QWidget::close() | - | ||||||||||||||||||||||||||||||||||||
8413 | { | - | ||||||||||||||||||||||||||||||||||||
8414 | return d_func()->close_helper(QWidgetPrivate::CloseWithEvent); never executed: return d_func()->close_helper(QWidgetPrivate::CloseWithEvent); | 0 | ||||||||||||||||||||||||||||||||||||
8415 | } | - | ||||||||||||||||||||||||||||||||||||
8416 | - | |||||||||||||||||||||||||||||||||||||
8417 | /*! | - | ||||||||||||||||||||||||||||||||||||
8418 | \property QWidget::visible | - | ||||||||||||||||||||||||||||||||||||
8419 | \brief whether the widget is visible | - | ||||||||||||||||||||||||||||||||||||
8420 | - | |||||||||||||||||||||||||||||||||||||
8421 | Calling setVisible(true) or show() sets the widget to visible | - | ||||||||||||||||||||||||||||||||||||
8422 | status if all its parent widgets up to the window are visible. If | - | ||||||||||||||||||||||||||||||||||||
8423 | an ancestor is not visible, the widget won't become visible until | - | ||||||||||||||||||||||||||||||||||||
8424 | all its ancestors are shown. If its size or position has changed, | - | ||||||||||||||||||||||||||||||||||||
8425 | Qt guarantees that a widget gets move and resize events just | - | ||||||||||||||||||||||||||||||||||||
8426 | before it is shown. If the widget has not been resized yet, Qt | - | ||||||||||||||||||||||||||||||||||||
8427 | will adjust the widget's size to a useful default using | - | ||||||||||||||||||||||||||||||||||||
8428 | adjustSize(). | - | ||||||||||||||||||||||||||||||||||||
8429 | - | |||||||||||||||||||||||||||||||||||||
8430 | Calling setVisible(false) or hide() hides a widget explicitly. An | - | ||||||||||||||||||||||||||||||||||||
8431 | explicitly hidden widget will never become visible, even if all | - | ||||||||||||||||||||||||||||||||||||
8432 | its ancestors become visible, unless you show it. | - | ||||||||||||||||||||||||||||||||||||
8433 | - | |||||||||||||||||||||||||||||||||||||
8434 | A widget receives show and hide events when its visibility status | - | ||||||||||||||||||||||||||||||||||||
8435 | changes. Between a hide and a show event, there is no need to | - | ||||||||||||||||||||||||||||||||||||
8436 | waste CPU cycles preparing or displaying information to the user. | - | ||||||||||||||||||||||||||||||||||||
8437 | A video application, for example, might simply stop generating new | - | ||||||||||||||||||||||||||||||||||||
8438 | frames. | - | ||||||||||||||||||||||||||||||||||||
8439 | - | |||||||||||||||||||||||||||||||||||||
8440 | A widget that happens to be obscured by other windows on the | - | ||||||||||||||||||||||||||||||||||||
8441 | screen is considered to be visible. The same applies to iconified | - | ||||||||||||||||||||||||||||||||||||
8442 | windows and windows that exist on another virtual | - | ||||||||||||||||||||||||||||||||||||
8443 | desktop (on platforms that support this concept). A widget | - | ||||||||||||||||||||||||||||||||||||
8444 | receives spontaneous show and hide events when its mapping status | - | ||||||||||||||||||||||||||||||||||||
8445 | is changed by the window system, e.g. a spontaneous hide event | - | ||||||||||||||||||||||||||||||||||||
8446 | when the user minimizes the window, and a spontaneous show event | - | ||||||||||||||||||||||||||||||||||||
8447 | when the window is restored again. | - | ||||||||||||||||||||||||||||||||||||
8448 | - | |||||||||||||||||||||||||||||||||||||
8449 | You almost never have to reimplement the setVisible() function. If | - | ||||||||||||||||||||||||||||||||||||
8450 | you need to change some settings before a widget is shown, use | - | ||||||||||||||||||||||||||||||||||||
8451 | showEvent() instead. If you need to do some delayed initialization | - | ||||||||||||||||||||||||||||||||||||
8452 | use the Polish event delivered to the event() function. | - | ||||||||||||||||||||||||||||||||||||
8453 | - | |||||||||||||||||||||||||||||||||||||
8454 | \sa show(), hide(), isHidden(), isVisibleTo(), isMinimized(), | - | ||||||||||||||||||||||||||||||||||||
8455 | showEvent(), hideEvent() | - | ||||||||||||||||||||||||||||||||||||
8456 | */ | - | ||||||||||||||||||||||||||||||||||||
8457 | - | |||||||||||||||||||||||||||||||||||||
8458 | - | |||||||||||||||||||||||||||||||||||||
8459 | /*! | - | ||||||||||||||||||||||||||||||||||||
8460 | Returns \c true if this widget would become visible if \a ancestor is | - | ||||||||||||||||||||||||||||||||||||
8461 | shown; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
8462 | - | |||||||||||||||||||||||||||||||||||||
8463 | The true case occurs if neither the widget itself nor any parent | - | ||||||||||||||||||||||||||||||||||||
8464 | up to but excluding \a ancestor has been explicitly hidden. | - | ||||||||||||||||||||||||||||||||||||
8465 | - | |||||||||||||||||||||||||||||||||||||
8466 | This function will still return true if the widget is obscured by | - | ||||||||||||||||||||||||||||||||||||
8467 | other windows on the screen, but could be physically visible if it | - | ||||||||||||||||||||||||||||||||||||
8468 | or they were to be moved. | - | ||||||||||||||||||||||||||||||||||||
8469 | - | |||||||||||||||||||||||||||||||||||||
8470 | isVisibleTo(0) is identical to isVisible(). | - | ||||||||||||||||||||||||||||||||||||
8471 | - | |||||||||||||||||||||||||||||||||||||
8472 | \sa show(), hide(), isVisible() | - | ||||||||||||||||||||||||||||||||||||
8473 | */ | - | ||||||||||||||||||||||||||||||||||||
8474 | - | |||||||||||||||||||||||||||||||||||||
8475 | bool QWidget::isVisibleTo(const QWidget *ancestor) const | - | ||||||||||||||||||||||||||||||||||||
8476 | { | - | ||||||||||||||||||||||||||||||||||||
8477 | if (!ancestor)
| 0 | ||||||||||||||||||||||||||||||||||||
8478 | return isVisible(); never executed: return isVisible(); | 0 | ||||||||||||||||||||||||||||||||||||
8479 | const QWidget * w = this; | - | ||||||||||||||||||||||||||||||||||||
8480 | while (!w->isHidden()
| 0 | ||||||||||||||||||||||||||||||||||||
8481 | && !w->isWindow()
| 0 | ||||||||||||||||||||||||||||||||||||
8482 | && w->parentWidget()
| 0 | ||||||||||||||||||||||||||||||||||||
8483 | && w->parentWidget() != ancestor)
| 0 | ||||||||||||||||||||||||||||||||||||
8484 | w = w->parentWidget(); never executed: w = w->parentWidget(); | 0 | ||||||||||||||||||||||||||||||||||||
8485 | return !w->isHidden(); never executed: return !w->isHidden(); | 0 | ||||||||||||||||||||||||||||||||||||
8486 | } | - | ||||||||||||||||||||||||||||||||||||
8487 | - | |||||||||||||||||||||||||||||||||||||
8488 | - | |||||||||||||||||||||||||||||||||||||
8489 | /*! | - | ||||||||||||||||||||||||||||||||||||
8490 | Returns the unobscured region where paint events can occur. | - | ||||||||||||||||||||||||||||||||||||
8491 | - | |||||||||||||||||||||||||||||||||||||
8492 | For visible widgets, this is an approximation of the area not | - | ||||||||||||||||||||||||||||||||||||
8493 | covered by other widgets; otherwise, this is an empty region. | - | ||||||||||||||||||||||||||||||||||||
8494 | - | |||||||||||||||||||||||||||||||||||||
8495 | The repaint() function calls this function if necessary, so in | - | ||||||||||||||||||||||||||||||||||||
8496 | general you do not need to call it. | - | ||||||||||||||||||||||||||||||||||||
8497 | - | |||||||||||||||||||||||||||||||||||||
8498 | */ | - | ||||||||||||||||||||||||||||||||||||
8499 | QRegion QWidget::visibleRegion() const | - | ||||||||||||||||||||||||||||||||||||
8500 | { | - | ||||||||||||||||||||||||||||||||||||
8501 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
8502 | - | |||||||||||||||||||||||||||||||||||||
8503 | QRect clipRect = d->clipRect(); | - | ||||||||||||||||||||||||||||||||||||
8504 | if (clipRect.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
8505 | return QRegion(); never executed: return QRegion(); | 0 | ||||||||||||||||||||||||||||||||||||
8506 | QRegion r(clipRect); | - | ||||||||||||||||||||||||||||||||||||
8507 | d->subtractOpaqueChildren(r, clipRect); | - | ||||||||||||||||||||||||||||||||||||
8508 | d->subtractOpaqueSiblings(r); | - | ||||||||||||||||||||||||||||||||||||
8509 | return r; never executed: return r; | 0 | ||||||||||||||||||||||||||||||||||||
8510 | } | - | ||||||||||||||||||||||||||||||||||||
8511 | - | |||||||||||||||||||||||||||||||||||||
8512 | - | |||||||||||||||||||||||||||||||||||||
8513 | QSize QWidgetPrivate::adjustedSize() const | - | ||||||||||||||||||||||||||||||||||||
8514 | { | - | ||||||||||||||||||||||||||||||||||||
8515 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
8516 | - | |||||||||||||||||||||||||||||||||||||
8517 | QSize s = q->sizeHint(); | - | ||||||||||||||||||||||||||||||||||||
8518 | - | |||||||||||||||||||||||||||||||||||||
8519 | if (q->isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8520 | Qt::Orientations exp; | - | ||||||||||||||||||||||||||||||||||||
8521 | if (layout) {
| 0 | ||||||||||||||||||||||||||||||||||||
8522 | if (layout->hasHeightForWidth())
| 0 | ||||||||||||||||||||||||||||||||||||
8523 | s.setHeight(layout->totalHeightForWidth(s.width())); never executed: s.setHeight(layout->totalHeightForWidth(s.width())); | 0 | ||||||||||||||||||||||||||||||||||||
8524 | exp = layout->expandingDirections(); | - | ||||||||||||||||||||||||||||||||||||
8525 | } else never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8526 | { | - | ||||||||||||||||||||||||||||||||||||
8527 | if (q->sizePolicy().hasHeightForWidth())
| 0 | ||||||||||||||||||||||||||||||||||||
8528 | s.setHeight(q->heightForWidth(s.width())); never executed: s.setHeight(q->heightForWidth(s.width())); | 0 | ||||||||||||||||||||||||||||||||||||
8529 | exp = q->sizePolicy().expandingDirections(); | - | ||||||||||||||||||||||||||||||||||||
8530 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8531 | if (exp & Qt::Horizontal)
| 0 | ||||||||||||||||||||||||||||||||||||
8532 | s.setWidth(qMax(s.width(), 200)); never executed: s.setWidth(qMax(s.width(), 200)); | 0 | ||||||||||||||||||||||||||||||||||||
8533 | if (exp & Qt::Vertical)
| 0 | ||||||||||||||||||||||||||||||||||||
8534 | s.setHeight(qMax(s.height(), 100)); never executed: s.setHeight(qMax(s.height(), 100)); | 0 | ||||||||||||||||||||||||||||||||||||
8535 | #if defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
8536 | QRect screen = QApplication::desktop()->screenGeometry(q->x11Info().screen()); | - | ||||||||||||||||||||||||||||||||||||
8537 | #else // all others | - | ||||||||||||||||||||||||||||||||||||
8538 | QRect screen = QApplication::desktop()->screenGeometry(q->pos()); | - | ||||||||||||||||||||||||||||||||||||
8539 | #endif | - | ||||||||||||||||||||||||||||||||||||
8540 | #if defined (Q_OS_WINCE) | - | ||||||||||||||||||||||||||||||||||||
8541 | s.setWidth(qMin(s.width(), screen.width())); | - | ||||||||||||||||||||||||||||||||||||
8542 | s.setHeight(qMin(s.height(), screen.height())); | - | ||||||||||||||||||||||||||||||||||||
8543 | #else | - | ||||||||||||||||||||||||||||||||||||
8544 | s.setWidth(qMin(s.width(), screen.width()*2/3)); | - | ||||||||||||||||||||||||||||||||||||
8545 | s.setHeight(qMin(s.height(), screen.height()*2/3)); | - | ||||||||||||||||||||||||||||||||||||
8546 | #endif | - | ||||||||||||||||||||||||||||||||||||
8547 | if (QTLWExtra *extra = maybeTopData())
| 0 | ||||||||||||||||||||||||||||||||||||
8548 | extra->sizeAdjusted = true; never executed: extra->sizeAdjusted = true; | 0 | ||||||||||||||||||||||||||||||||||||
8549 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8550 | - | |||||||||||||||||||||||||||||||||||||
8551 | if (!s.isValid()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8552 | QRect r = q->childrenRect(); // get children rectangle | - | ||||||||||||||||||||||||||||||||||||
8553 | if (r.isNull())
| 0 | ||||||||||||||||||||||||||||||||||||
8554 | return s; never executed: return s; | 0 | ||||||||||||||||||||||||||||||||||||
8555 | s = r.size() + QSize(2 * r.x(), 2 * r.y()); | - | ||||||||||||||||||||||||||||||||||||
8556 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8557 | - | |||||||||||||||||||||||||||||||||||||
8558 | return s; never executed: return s; | 0 | ||||||||||||||||||||||||||||||||||||
8559 | } | - | ||||||||||||||||||||||||||||||||||||
8560 | - | |||||||||||||||||||||||||||||||||||||
8561 | /*! | - | ||||||||||||||||||||||||||||||||||||
8562 | Adjusts the size of the widget to fit its contents. | - | ||||||||||||||||||||||||||||||||||||
8563 | - | |||||||||||||||||||||||||||||||||||||
8564 | This function uses sizeHint() if it is valid, i.e., the size hint's width | - | ||||||||||||||||||||||||||||||||||||
8565 | and height are \>= 0. Otherwise, it sets the size to the children | - | ||||||||||||||||||||||||||||||||||||
8566 | rectangle that covers all child widgets (the union of all child widget | - | ||||||||||||||||||||||||||||||||||||
8567 | rectangles). | - | ||||||||||||||||||||||||||||||||||||
8568 | - | |||||||||||||||||||||||||||||||||||||
8569 | For windows, the screen size is also taken into account. If the sizeHint() | - | ||||||||||||||||||||||||||||||||||||
8570 | is less than (200, 100) and the size policy is \l{QSizePolicy::Expanding} | - | ||||||||||||||||||||||||||||||||||||
8571 | {expanding}, the window will be at least (200, 100). The maximum size of | - | ||||||||||||||||||||||||||||||||||||
8572 | a window is 2/3 of the screen's width and height. | - | ||||||||||||||||||||||||||||||||||||
8573 | - | |||||||||||||||||||||||||||||||||||||
8574 | \sa sizeHint(), childrenRect() | - | ||||||||||||||||||||||||||||||||||||
8575 | */ | - | ||||||||||||||||||||||||||||||||||||
8576 | - | |||||||||||||||||||||||||||||||||||||
8577 | void QWidget::adjustSize() | - | ||||||||||||||||||||||||||||||||||||
8578 | { | - | ||||||||||||||||||||||||||||||||||||
8579 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8580 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
8581 | QSize s = d->adjustedSize(); | - | ||||||||||||||||||||||||||||||||||||
8582 | - | |||||||||||||||||||||||||||||||||||||
8583 | if (d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
8584 | d->layout->activate(); never executed: d->layout->activate(); | 0 | ||||||||||||||||||||||||||||||||||||
8585 | - | |||||||||||||||||||||||||||||||||||||
8586 | if (s.isValid())
| 0 | ||||||||||||||||||||||||||||||||||||
8587 | resize(s); never executed: resize(s); | 0 | ||||||||||||||||||||||||||||||||||||
8588 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8589 | - | |||||||||||||||||||||||||||||||||||||
8590 | - | |||||||||||||||||||||||||||||||||||||
8591 | /*! | - | ||||||||||||||||||||||||||||||||||||
8592 | \property QWidget::sizeHint | - | ||||||||||||||||||||||||||||||||||||
8593 | \brief the recommended size for the widget | - | ||||||||||||||||||||||||||||||||||||
8594 | - | |||||||||||||||||||||||||||||||||||||
8595 | If the value of this property is an invalid size, no size is | - | ||||||||||||||||||||||||||||||||||||
8596 | recommended. | - | ||||||||||||||||||||||||||||||||||||
8597 | - | |||||||||||||||||||||||||||||||||||||
8598 | The default implementation of sizeHint() returns an invalid size | - | ||||||||||||||||||||||||||||||||||||
8599 | if there is no layout for this widget, and returns the layout's | - | ||||||||||||||||||||||||||||||||||||
8600 | preferred size otherwise. | - | ||||||||||||||||||||||||||||||||||||
8601 | - | |||||||||||||||||||||||||||||||||||||
8602 | \sa QSize::isValid(), minimumSizeHint(), sizePolicy(), | - | ||||||||||||||||||||||||||||||||||||
8603 | setMinimumSize(), updateGeometry() | - | ||||||||||||||||||||||||||||||||||||
8604 | */ | - | ||||||||||||||||||||||||||||||||||||
8605 | - | |||||||||||||||||||||||||||||||||||||
8606 | QSize QWidget::sizeHint() const | - | ||||||||||||||||||||||||||||||||||||
8607 | { | - | ||||||||||||||||||||||||||||||||||||
8608 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
8609 | if (d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
8610 | return d->layout->totalSizeHint(); never executed: return d->layout->totalSizeHint(); | 0 | ||||||||||||||||||||||||||||||||||||
8611 | return QSize(-1, -1); never executed: return QSize(-1, -1); | 0 | ||||||||||||||||||||||||||||||||||||
8612 | } | - | ||||||||||||||||||||||||||||||||||||
8613 | - | |||||||||||||||||||||||||||||||||||||
8614 | /*! | - | ||||||||||||||||||||||||||||||||||||
8615 | \property QWidget::minimumSizeHint | - | ||||||||||||||||||||||||||||||||||||
8616 | \brief the recommended minimum size for the widget | - | ||||||||||||||||||||||||||||||||||||
8617 | - | |||||||||||||||||||||||||||||||||||||
8618 | If the value of this property is an invalid size, no minimum size | - | ||||||||||||||||||||||||||||||||||||
8619 | is recommended. | - | ||||||||||||||||||||||||||||||||||||
8620 | - | |||||||||||||||||||||||||||||||||||||
8621 | The default implementation of minimumSizeHint() returns an invalid | - | ||||||||||||||||||||||||||||||||||||
8622 | size if there is no layout for this widget, and returns the | - | ||||||||||||||||||||||||||||||||||||
8623 | layout's minimum size otherwise. Most built-in widgets reimplement | - | ||||||||||||||||||||||||||||||||||||
8624 | minimumSizeHint(). | - | ||||||||||||||||||||||||||||||||||||
8625 | - | |||||||||||||||||||||||||||||||||||||
8626 | \l QLayout will never resize a widget to a size smaller than the | - | ||||||||||||||||||||||||||||||||||||
8627 | minimum size hint unless minimumSize() is set or the size policy is | - | ||||||||||||||||||||||||||||||||||||
8628 | set to QSizePolicy::Ignore. If minimumSize() is set, the minimum | - | ||||||||||||||||||||||||||||||||||||
8629 | size hint will be ignored. | - | ||||||||||||||||||||||||||||||||||||
8630 | - | |||||||||||||||||||||||||||||||||||||
8631 | \sa QSize::isValid(), resize(), setMinimumSize(), sizePolicy() | - | ||||||||||||||||||||||||||||||||||||
8632 | */ | - | ||||||||||||||||||||||||||||||||||||
8633 | QSize QWidget::minimumSizeHint() const | - | ||||||||||||||||||||||||||||||||||||
8634 | { | - | ||||||||||||||||||||||||||||||||||||
8635 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
8636 | if (d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
8637 | return d->layout->totalMinimumSize(); never executed: return d->layout->totalMinimumSize(); | 0 | ||||||||||||||||||||||||||||||||||||
8638 | return QSize(-1, -1); never executed: return QSize(-1, -1); | 0 | ||||||||||||||||||||||||||||||||||||
8639 | } | - | ||||||||||||||||||||||||||||||||||||
8640 | - | |||||||||||||||||||||||||||||||||||||
8641 | - | |||||||||||||||||||||||||||||||||||||
8642 | /*! | - | ||||||||||||||||||||||||||||||||||||
8643 | \fn QWidget *QWidget::parentWidget() const | - | ||||||||||||||||||||||||||||||||||||
8644 | - | |||||||||||||||||||||||||||||||||||||
8645 | Returns the parent of this widget, or 0 if it does not have any | - | ||||||||||||||||||||||||||||||||||||
8646 | parent widget. | - | ||||||||||||||||||||||||||||||||||||
8647 | */ | - | ||||||||||||||||||||||||||||||||||||
8648 | - | |||||||||||||||||||||||||||||||||||||
8649 | - | |||||||||||||||||||||||||||||||||||||
8650 | /*! | - | ||||||||||||||||||||||||||||||||||||
8651 | Returns \c true if this widget is a parent, (or grandparent and so on | - | ||||||||||||||||||||||||||||||||||||
8652 | to any level), of the given \a child, and both widgets are within | - | ||||||||||||||||||||||||||||||||||||
8653 | the same window; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
8654 | */ | - | ||||||||||||||||||||||||||||||||||||
8655 | - | |||||||||||||||||||||||||||||||||||||
8656 | bool QWidget::isAncestorOf(const QWidget *child) const | - | ||||||||||||||||||||||||||||||||||||
8657 | { | - | ||||||||||||||||||||||||||||||||||||
8658 | while (child) {
| 0 | ||||||||||||||||||||||||||||||||||||
8659 | if (child == this)
| 0 | ||||||||||||||||||||||||||||||||||||
8660 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
8661 | if (child->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
8662 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
8663 | child = child->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
8664 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8665 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
8666 | } | - | ||||||||||||||||||||||||||||||||||||
8667 | - | |||||||||||||||||||||||||||||||||||||
8668 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
8669 | inline void setDisabledStyle(QWidget *w, bool setStyle) | - | ||||||||||||||||||||||||||||||||||||
8670 | { | - | ||||||||||||||||||||||||||||||||||||
8671 | // set/reset WS_DISABLED style. | - | ||||||||||||||||||||||||||||||||||||
8672 | if(w && w->isWindow() && w->isVisible() && w->isEnabled()) { | - | ||||||||||||||||||||||||||||||||||||
8673 | LONG dwStyle = GetWindowLong(w->winId(), GWL_STYLE); | - | ||||||||||||||||||||||||||||||||||||
8674 | LONG newStyle = dwStyle; | - | ||||||||||||||||||||||||||||||||||||
8675 | if (setStyle) | - | ||||||||||||||||||||||||||||||||||||
8676 | newStyle |= WS_DISABLED; | - | ||||||||||||||||||||||||||||||||||||
8677 | else | - | ||||||||||||||||||||||||||||||||||||
8678 | newStyle &= ~WS_DISABLED; | - | ||||||||||||||||||||||||||||||||||||
8679 | if (newStyle != dwStyle) { | - | ||||||||||||||||||||||||||||||||||||
8680 | SetWindowLong(w->winId(), GWL_STYLE, newStyle); | - | ||||||||||||||||||||||||||||||||||||
8681 | // we might need to repaint in some situations (eg. menu) | - | ||||||||||||||||||||||||||||||||||||
8682 | w->repaint(); | - | ||||||||||||||||||||||||||||||||||||
8683 | } | - | ||||||||||||||||||||||||||||||||||||
8684 | } | - | ||||||||||||||||||||||||||||||||||||
8685 | } | - | ||||||||||||||||||||||||||||||||||||
8686 | #endif | - | ||||||||||||||||||||||||||||||||||||
8687 | - | |||||||||||||||||||||||||||||||||||||
8688 | /***************************************************************************** | - | ||||||||||||||||||||||||||||||||||||
8689 | QWidget event handling | - | ||||||||||||||||||||||||||||||||||||
8690 | *****************************************************************************/ | - | ||||||||||||||||||||||||||||||||||||
8691 | - | |||||||||||||||||||||||||||||||||||||
8692 | /*! | - | ||||||||||||||||||||||||||||||||||||
8693 | This is the main event handler; it handles event \a event. You can | - | ||||||||||||||||||||||||||||||||||||
8694 | reimplement this function in a subclass, but we recommend using | - | ||||||||||||||||||||||||||||||||||||
8695 | one of the specialized event handlers instead. | - | ||||||||||||||||||||||||||||||||||||
8696 | - | |||||||||||||||||||||||||||||||||||||
8697 | Key press and release events are treated differently from other | - | ||||||||||||||||||||||||||||||||||||
8698 | events. event() checks for Tab and Shift+Tab and tries to move the | - | ||||||||||||||||||||||||||||||||||||
8699 | focus appropriately. If there is no widget to move the focus to | - | ||||||||||||||||||||||||||||||||||||
8700 | (or the key press is not Tab or Shift+Tab), event() calls | - | ||||||||||||||||||||||||||||||||||||
8701 | keyPressEvent(). | - | ||||||||||||||||||||||||||||||||||||
8702 | - | |||||||||||||||||||||||||||||||||||||
8703 | Mouse and tablet event handling is also slightly special: only | - | ||||||||||||||||||||||||||||||||||||
8704 | when the widget is \l enabled, event() will call the specialized | - | ||||||||||||||||||||||||||||||||||||
8705 | handlers such as mousePressEvent(); otherwise it will discard the | - | ||||||||||||||||||||||||||||||||||||
8706 | event. | - | ||||||||||||||||||||||||||||||||||||
8707 | - | |||||||||||||||||||||||||||||||||||||
8708 | This function returns \c true if the event was recognized, otherwise | - | ||||||||||||||||||||||||||||||||||||
8709 | it returns \c false. If the recognized event was accepted (see \l | - | ||||||||||||||||||||||||||||||||||||
8710 | QEvent::accepted), any further processing such as event | - | ||||||||||||||||||||||||||||||||||||
8711 | propagation to the parent widget stops. | - | ||||||||||||||||||||||||||||||||||||
8712 | - | |||||||||||||||||||||||||||||||||||||
8713 | \sa closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(), | - | ||||||||||||||||||||||||||||||||||||
8714 | keyPressEvent(), keyReleaseEvent(), leaveEvent(), | - | ||||||||||||||||||||||||||||||||||||
8715 | mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), | - | ||||||||||||||||||||||||||||||||||||
8716 | mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent(), | - | ||||||||||||||||||||||||||||||||||||
8717 | QObject::event(), QObject::timerEvent() | - | ||||||||||||||||||||||||||||||||||||
8718 | */ | - | ||||||||||||||||||||||||||||||||||||
8719 | - | |||||||||||||||||||||||||||||||||||||
8720 | bool QWidget::event(QEvent *event) | - | ||||||||||||||||||||||||||||||||||||
8721 | { | - | ||||||||||||||||||||||||||||||||||||
8722 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
8723 | - | |||||||||||||||||||||||||||||||||||||
8724 | // ignore mouse and key events when disabled | - | ||||||||||||||||||||||||||||||||||||
8725 | if (!isEnabled()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8726 | switch(event->type()) { | - | ||||||||||||||||||||||||||||||||||||
8727 | case QEvent::TabletPress: never executed: case QEvent::TabletPress: | 0 | ||||||||||||||||||||||||||||||||||||
8728 | case QEvent::TabletRelease: never executed: case QEvent::TabletRelease: | 0 | ||||||||||||||||||||||||||||||||||||
8729 | case QEvent::TabletMove: never executed: case QEvent::TabletMove: | 0 | ||||||||||||||||||||||||||||||||||||
8730 | case QEvent::MouseButtonPress: never executed: case QEvent::MouseButtonPress: | 0 | ||||||||||||||||||||||||||||||||||||
8731 | case QEvent::MouseButtonRelease: never executed: case QEvent::MouseButtonRelease: | 0 | ||||||||||||||||||||||||||||||||||||
8732 | case QEvent::MouseButtonDblClick: never executed: case QEvent::MouseButtonDblClick: | 0 | ||||||||||||||||||||||||||||||||||||
8733 | case QEvent::MouseMove: never executed: case QEvent::MouseMove: | 0 | ||||||||||||||||||||||||||||||||||||
8734 | case QEvent::TouchBegin: never executed: case QEvent::TouchBegin: | 0 | ||||||||||||||||||||||||||||||||||||
8735 | case QEvent::TouchUpdate: never executed: case QEvent::TouchUpdate: | 0 | ||||||||||||||||||||||||||||||||||||
8736 | case QEvent::TouchEnd: never executed: case QEvent::TouchEnd: | 0 | ||||||||||||||||||||||||||||||||||||
8737 | case QEvent::TouchCancel: never executed: case QEvent::TouchCancel: | 0 | ||||||||||||||||||||||||||||||||||||
8738 | case QEvent::ContextMenu: never executed: case QEvent::ContextMenu: | 0 | ||||||||||||||||||||||||||||||||||||
8739 | case QEvent::KeyPress: never executed: case QEvent::KeyPress: | 0 | ||||||||||||||||||||||||||||||||||||
8740 | case QEvent::KeyRelease: never executed: case QEvent::KeyRelease: | 0 | ||||||||||||||||||||||||||||||||||||
8741 | #ifndef QT_NO_WHEELEVENT | - | ||||||||||||||||||||||||||||||||||||
8742 | case QEvent::Wheel: never executed: case QEvent::Wheel: | 0 | ||||||||||||||||||||||||||||||||||||
8743 | #endif | - | ||||||||||||||||||||||||||||||||||||
8744 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
8745 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
8746 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8747 | } | - | ||||||||||||||||||||||||||||||||||||
8748 | } | - | ||||||||||||||||||||||||||||||||||||
8749 | switch (event->type()) { | - | ||||||||||||||||||||||||||||||||||||
8750 | case QEvent::MouseMove: never executed: case QEvent::MouseMove: | 0 | ||||||||||||||||||||||||||||||||||||
8751 | mouseMoveEvent((QMouseEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8752 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8753 | - | |||||||||||||||||||||||||||||||||||||
8754 | case QEvent::MouseButtonPress: never executed: case QEvent::MouseButtonPress: | 0 | ||||||||||||||||||||||||||||||||||||
8755 | mousePressEvent((QMouseEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8756 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8757 | - | |||||||||||||||||||||||||||||||||||||
8758 | case QEvent::MouseButtonRelease: never executed: case QEvent::MouseButtonRelease: | 0 | ||||||||||||||||||||||||||||||||||||
8759 | mouseReleaseEvent((QMouseEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8760 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8761 | - | |||||||||||||||||||||||||||||||||||||
8762 | case QEvent::MouseButtonDblClick: never executed: case QEvent::MouseButtonDblClick: | 0 | ||||||||||||||||||||||||||||||||||||
8763 | mouseDoubleClickEvent((QMouseEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8764 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8765 | #ifndef QT_NO_WHEELEVENT | - | ||||||||||||||||||||||||||||||||||||
8766 | case QEvent::Wheel: never executed: case QEvent::Wheel: | 0 | ||||||||||||||||||||||||||||||||||||
8767 | wheelEvent((QWheelEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8768 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8769 | #endif | - | ||||||||||||||||||||||||||||||||||||
8770 | #ifndef QT_NO_TABLETEVENT | - | ||||||||||||||||||||||||||||||||||||
8771 | case QEvent::TabletMove: never executed: case QEvent::TabletMove: | 0 | ||||||||||||||||||||||||||||||||||||
8772 | case QEvent::TabletPress: never executed: case QEvent::TabletPress: | 0 | ||||||||||||||||||||||||||||||||||||
8773 | case QEvent::TabletRelease: never executed: case QEvent::TabletRelease: | 0 | ||||||||||||||||||||||||||||||||||||
8774 | tabletEvent((QTabletEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8775 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8776 | #endif | - | ||||||||||||||||||||||||||||||||||||
8777 | case QEvent::KeyPress: { never executed: case QEvent::KeyPress: | 0 | ||||||||||||||||||||||||||||||||||||
8778 | QKeyEvent *k = (QKeyEvent *)event; | - | ||||||||||||||||||||||||||||||||||||
8779 | bool res = false; | - | ||||||||||||||||||||||||||||||||||||
8780 | if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
| 0 | ||||||||||||||||||||||||||||||||||||
8781 | if (k->key() == Qt::Key_Backtab
| 0 | ||||||||||||||||||||||||||||||||||||
8782 | || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier)))
| 0 | ||||||||||||||||||||||||||||||||||||
8783 | res = focusNextPrevChild(false); never executed: res = focusNextPrevChild(false); | 0 | ||||||||||||||||||||||||||||||||||||
8784 | else if (k->key() == Qt::Key_Tab)
| 0 | ||||||||||||||||||||||||||||||||||||
8785 | res = focusNextPrevChild(true); never executed: res = focusNextPrevChild(true); | 0 | ||||||||||||||||||||||||||||||||||||
8786 | if (res)
| 0 | ||||||||||||||||||||||||||||||||||||
8787 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8788 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8789 | keyPressEvent(k); | - | ||||||||||||||||||||||||||||||||||||
8790 | #ifdef QT_KEYPAD_NAVIGATION | - | ||||||||||||||||||||||||||||||||||||
8791 | if (!k->isAccepted() && QApplication::keypadNavigationEnabled() | - | ||||||||||||||||||||||||||||||||||||
8792 | && !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::ShiftModifier))) { | - | ||||||||||||||||||||||||||||||||||||
8793 | if (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder) { | - | ||||||||||||||||||||||||||||||||||||
8794 | if (k->key() == Qt::Key_Up) | - | ||||||||||||||||||||||||||||||||||||
8795 | res = focusNextPrevChild(false); | - | ||||||||||||||||||||||||||||||||||||
8796 | else if (k->key() == Qt::Key_Down) | - | ||||||||||||||||||||||||||||||||||||
8797 | res = focusNextPrevChild(true); | - | ||||||||||||||||||||||||||||||||||||
8798 | } else if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) { | - | ||||||||||||||||||||||||||||||||||||
8799 | if (k->key() == Qt::Key_Up) | - | ||||||||||||||||||||||||||||||||||||
8800 | res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionNorth); | - | ||||||||||||||||||||||||||||||||||||
8801 | else if (k->key() == Qt::Key_Right) | - | ||||||||||||||||||||||||||||||||||||
8802 | res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionEast); | - | ||||||||||||||||||||||||||||||||||||
8803 | else if (k->key() == Qt::Key_Down) | - | ||||||||||||||||||||||||||||||||||||
8804 | res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionSouth); | - | ||||||||||||||||||||||||||||||||||||
8805 | else if (k->key() == Qt::Key_Left) | - | ||||||||||||||||||||||||||||||||||||
8806 | res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionWest); | - | ||||||||||||||||||||||||||||||||||||
8807 | } | - | ||||||||||||||||||||||||||||||||||||
8808 | if (res) { | - | ||||||||||||||||||||||||||||||||||||
8809 | k->accept(); | - | ||||||||||||||||||||||||||||||||||||
8810 | break; | - | ||||||||||||||||||||||||||||||||||||
8811 | } | - | ||||||||||||||||||||||||||||||||||||
8812 | } | - | ||||||||||||||||||||||||||||||||||||
8813 | #endif | - | ||||||||||||||||||||||||||||||||||||
8814 | #ifndef QT_NO_WHATSTHIS | - | ||||||||||||||||||||||||||||||||||||
8815 | if (!k->isAccepted()
| 0 | ||||||||||||||||||||||||||||||||||||
8816 | && k->modifiers() & Qt::ShiftModifier && k->key() == Qt::Key_F1
| 0 | ||||||||||||||||||||||||||||||||||||
8817 | && d->whatsThis.size()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8818 | QWhatsThis::showText(mapToGlobal(inputMethodQuery(Qt::ImCursorRectangle).toRect().center()), d->whatsThis, this); | - | ||||||||||||||||||||||||||||||||||||
8819 | k->accept(); | - | ||||||||||||||||||||||||||||||||||||
8820 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8821 | #endif | - | ||||||||||||||||||||||||||||||||||||
8822 | } | - | ||||||||||||||||||||||||||||||||||||
8823 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8824 | - | |||||||||||||||||||||||||||||||||||||
8825 | case QEvent::KeyRelease: never executed: case QEvent::KeyRelease: | 0 | ||||||||||||||||||||||||||||||||||||
8826 | keyReleaseEvent((QKeyEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8827 | // fall through | - | ||||||||||||||||||||||||||||||||||||
8828 | case QEvent::ShortcutOverride: code before this statement never executed: case QEvent::ShortcutOverride: never executed: case QEvent::ShortcutOverride: | 0 | ||||||||||||||||||||||||||||||||||||
8829 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8830 | - | |||||||||||||||||||||||||||||||||||||
8831 | case QEvent::InputMethod: never executed: case QEvent::InputMethod: | 0 | ||||||||||||||||||||||||||||||||||||
8832 | inputMethodEvent((QInputMethodEvent *) event); | - | ||||||||||||||||||||||||||||||||||||
8833 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8834 | - | |||||||||||||||||||||||||||||||||||||
8835 | case QEvent::InputMethodQuery: never executed: case QEvent::InputMethodQuery: | 0 | ||||||||||||||||||||||||||||||||||||
8836 | if (testAttribute(Qt::WA_InputMethodEnabled)) {
| 0 | ||||||||||||||||||||||||||||||||||||
8837 | QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(event); | - | ||||||||||||||||||||||||||||||||||||
8838 | Qt::InputMethodQueries queries = query->queries(); | - | ||||||||||||||||||||||||||||||||||||
8839 | for (uint i = 0; i < 32; ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
8840 | Qt::InputMethodQuery q = (Qt::InputMethodQuery)(int)(queries & (1<<i)); | - | ||||||||||||||||||||||||||||||||||||
8841 | if (q) {
| 0 | ||||||||||||||||||||||||||||||||||||
8842 | QVariant v = inputMethodQuery(q); | - | ||||||||||||||||||||||||||||||||||||
8843 | if (q == Qt::ImEnabled && !v.isValid() && isEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
8844 | v = QVariant(true); // special case for Qt4 compatibility never executed: v = QVariant(true); | 0 | ||||||||||||||||||||||||||||||||||||
8845 | query->setValue(q, v); | - | ||||||||||||||||||||||||||||||||||||
8846 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8847 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8848 | query->accept(); | - | ||||||||||||||||||||||||||||||||||||
8849 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8850 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8851 | - | |||||||||||||||||||||||||||||||||||||
8852 | case QEvent::PolishRequest: never executed: case QEvent::PolishRequest: | 0 | ||||||||||||||||||||||||||||||||||||
8853 | ensurePolished(); | - | ||||||||||||||||||||||||||||||||||||
8854 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8855 | - | |||||||||||||||||||||||||||||||||||||
8856 | case QEvent::Polish: { never executed: case QEvent::Polish: | 0 | ||||||||||||||||||||||||||||||||||||
8857 | style()->polish(this); | - | ||||||||||||||||||||||||||||||||||||
8858 | setAttribute(Qt::WA_WState_Polished); | - | ||||||||||||||||||||||||||||||||||||
8859 | if (!QApplication::font(this).isCopyOf(QApplication::font()))
| 0 | ||||||||||||||||||||||||||||||||||||
8860 | d->resolveFont(); never executed: d->resolveFont(); | 0 | ||||||||||||||||||||||||||||||||||||
8861 | if (!QApplication::palette(this).isCopyOf(QApplication::palette()))
| 0 | ||||||||||||||||||||||||||||||||||||
8862 | d->resolvePalette(); never executed: d->resolvePalette(); | 0 | ||||||||||||||||||||||||||||||||||||
8863 | } | - | ||||||||||||||||||||||||||||||||||||
8864 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8865 | - | |||||||||||||||||||||||||||||||||||||
8866 | case QEvent::ApplicationWindowIconChange: never executed: case QEvent::ApplicationWindowIconChange: | 0 | ||||||||||||||||||||||||||||||||||||
8867 | if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon)) {
| 0 | ||||||||||||||||||||||||||||||||||||
8868 | d->setWindowIcon_sys(); | - | ||||||||||||||||||||||||||||||||||||
8869 | d->setWindowIcon_helper(); | - | ||||||||||||||||||||||||||||||||||||
8870 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8871 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8872 | case QEvent::FocusIn: never executed: case QEvent::FocusIn: | 0 | ||||||||||||||||||||||||||||||||||||
8873 | focusInEvent((QFocusEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8874 | d->updateWidgetTransform(event); | - | ||||||||||||||||||||||||||||||||||||
8875 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8876 | - | |||||||||||||||||||||||||||||||||||||
8877 | case QEvent::FocusOut: never executed: case QEvent::FocusOut: | 0 | ||||||||||||||||||||||||||||||||||||
8878 | focusOutEvent((QFocusEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8879 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8880 | - | |||||||||||||||||||||||||||||||||||||
8881 | case QEvent::Enter: never executed: case QEvent::Enter: | 0 | ||||||||||||||||||||||||||||||||||||
8882 | #ifndef QT_NO_STATUSTIP | - | ||||||||||||||||||||||||||||||||||||
8883 | if (d->statusTip.size()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8884 | QStatusTipEvent tip(d->statusTip); | - | ||||||||||||||||||||||||||||||||||||
8885 | QApplication::sendEvent(const_cast<QWidget *>(this), &tip); | - | ||||||||||||||||||||||||||||||||||||
8886 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8887 | #endif | - | ||||||||||||||||||||||||||||||||||||
8888 | enterEvent(event); | - | ||||||||||||||||||||||||||||||||||||
8889 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8890 | - | |||||||||||||||||||||||||||||||||||||
8891 | case QEvent::Leave: never executed: case QEvent::Leave: | 0 | ||||||||||||||||||||||||||||||||||||
8892 | #ifndef QT_NO_STATUSTIP | - | ||||||||||||||||||||||||||||||||||||
8893 | if (d->statusTip.size()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8894 | QString empty; | - | ||||||||||||||||||||||||||||||||||||
8895 | QStatusTipEvent tip(empty); | - | ||||||||||||||||||||||||||||||||||||
8896 | QApplication::sendEvent(const_cast<QWidget *>(this), &tip); | - | ||||||||||||||||||||||||||||||||||||
8897 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
8898 | #endif | - | ||||||||||||||||||||||||||||||||||||
8899 | leaveEvent(event); | - | ||||||||||||||||||||||||||||||||||||
8900 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8901 | - | |||||||||||||||||||||||||||||||||||||
8902 | case QEvent::HoverEnter: never executed: case QEvent::HoverEnter: | 0 | ||||||||||||||||||||||||||||||||||||
8903 | case QEvent::HoverLeave: never executed: case QEvent::HoverLeave: | 0 | ||||||||||||||||||||||||||||||||||||
8904 | update(); | - | ||||||||||||||||||||||||||||||||||||
8905 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8906 | - | |||||||||||||||||||||||||||||||||||||
8907 | case QEvent::Paint: never executed: case QEvent::Paint: | 0 | ||||||||||||||||||||||||||||||||||||
8908 | // At this point the event has to be delivered, regardless | - | ||||||||||||||||||||||||||||||||||||
8909 | // whether the widget isVisible() or not because it | - | ||||||||||||||||||||||||||||||||||||
8910 | // already went through the filters | - | ||||||||||||||||||||||||||||||||||||
8911 | paintEvent((QPaintEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8912 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8913 | - | |||||||||||||||||||||||||||||||||||||
8914 | case QEvent::Move: never executed: case QEvent::Move: | 0 | ||||||||||||||||||||||||||||||||||||
8915 | moveEvent((QMoveEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8916 | d->updateWidgetTransform(event); | - | ||||||||||||||||||||||||||||||||||||
8917 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8918 | - | |||||||||||||||||||||||||||||||||||||
8919 | case QEvent::Resize: never executed: case QEvent::Resize: | 0 | ||||||||||||||||||||||||||||||||||||
8920 | resizeEvent((QResizeEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
8921 | d->updateWidgetTransform(event); | - | ||||||||||||||||||||||||||||||||||||
8922 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8923 | - | |||||||||||||||||||||||||||||||||||||
8924 | case QEvent::Close: never executed: case QEvent::Close: | 0 | ||||||||||||||||||||||||||||||||||||
8925 | closeEvent((QCloseEvent *)event); | - | ||||||||||||||||||||||||||||||||||||
8926 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8927 | - | |||||||||||||||||||||||||||||||||||||
8928 | #ifndef QT_NO_CONTEXTMENU | - | ||||||||||||||||||||||||||||||||||||
8929 | case QEvent::ContextMenu: never executed: case QEvent::ContextMenu: | 0 | ||||||||||||||||||||||||||||||||||||
8930 | switch (data->context_menu_policy) { | - | ||||||||||||||||||||||||||||||||||||
8931 | case Qt::PreventContextMenu: never executed: case Qt::PreventContextMenu: | 0 | ||||||||||||||||||||||||||||||||||||
8932 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8933 | case Qt::DefaultContextMenu: never executed: case Qt::DefaultContextMenu: | 0 | ||||||||||||||||||||||||||||||||||||
8934 | contextMenuEvent(static_cast<QContextMenuEvent *>(event)); | - | ||||||||||||||||||||||||||||||||||||
8935 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8936 | case Qt::CustomContextMenu: never executed: case Qt::CustomContextMenu: | 0 | ||||||||||||||||||||||||||||||||||||
8937 | emit customContextMenuRequested(static_cast<QContextMenuEvent *>(event)->pos()); | - | ||||||||||||||||||||||||||||||||||||
8938 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8939 | #ifndef QT_NO_MENU | - | ||||||||||||||||||||||||||||||||||||
8940 | case Qt::ActionsContextMenu: never executed: case Qt::ActionsContextMenu: | 0 | ||||||||||||||||||||||||||||||||||||
8941 | if (d->actions.count()) {
| 0 | ||||||||||||||||||||||||||||||||||||
8942 | QMenu::exec(d->actions, static_cast<QContextMenuEvent *>(event)->globalPos(), | - | ||||||||||||||||||||||||||||||||||||
8943 | 0, this); | - | ||||||||||||||||||||||||||||||||||||
8944 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8945 | } | - | ||||||||||||||||||||||||||||||||||||
8946 | // fall through | - | ||||||||||||||||||||||||||||||||||||
8947 | #endif | - | ||||||||||||||||||||||||||||||||||||
8948 | default: code before this statement never executed: default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
8949 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
8950 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8951 | } | - | ||||||||||||||||||||||||||||||||||||
8952 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8953 | #endif // QT_NO_CONTEXTMENU | - | ||||||||||||||||||||||||||||||||||||
8954 | - | |||||||||||||||||||||||||||||||||||||
8955 | #ifndef QT_NO_DRAGANDDROP | - | ||||||||||||||||||||||||||||||||||||
8956 | case QEvent::Drop: never executed: case QEvent::Drop: | 0 | ||||||||||||||||||||||||||||||||||||
8957 | dropEvent((QDropEvent*) event); | - | ||||||||||||||||||||||||||||||||||||
8958 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8959 | - | |||||||||||||||||||||||||||||||||||||
8960 | case QEvent::DragEnter: never executed: case QEvent::DragEnter: | 0 | ||||||||||||||||||||||||||||||||||||
8961 | dragEnterEvent((QDragEnterEvent*) event); | - | ||||||||||||||||||||||||||||||||||||
8962 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8963 | - | |||||||||||||||||||||||||||||||||||||
8964 | case QEvent::DragMove: never executed: case QEvent::DragMove: | 0 | ||||||||||||||||||||||||||||||||||||
8965 | dragMoveEvent((QDragMoveEvent*) event); | - | ||||||||||||||||||||||||||||||||||||
8966 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8967 | - | |||||||||||||||||||||||||||||||||||||
8968 | case QEvent::DragLeave: never executed: case QEvent::DragLeave: | 0 | ||||||||||||||||||||||||||||||||||||
8969 | dragLeaveEvent((QDragLeaveEvent*) event); | - | ||||||||||||||||||||||||||||||||||||
8970 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8971 | #endif | - | ||||||||||||||||||||||||||||||||||||
8972 | - | |||||||||||||||||||||||||||||||||||||
8973 | case QEvent::Show: never executed: case QEvent::Show: | 0 | ||||||||||||||||||||||||||||||||||||
8974 | showEvent((QShowEvent*) event); | - | ||||||||||||||||||||||||||||||||||||
8975 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8976 | - | |||||||||||||||||||||||||||||||||||||
8977 | case QEvent::Hide: never executed: case QEvent::Hide: | 0 | ||||||||||||||||||||||||||||||||||||
8978 | hideEvent((QHideEvent*) event); | - | ||||||||||||||||||||||||||||||||||||
8979 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8980 | - | |||||||||||||||||||||||||||||||||||||
8981 | case QEvent::ShowWindowRequest: never executed: case QEvent::ShowWindowRequest: | 0 | ||||||||||||||||||||||||||||||||||||
8982 | if (!isHidden())
| 0 | ||||||||||||||||||||||||||||||||||||
8983 | d->show_sys(); never executed: d->show_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
8984 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8985 | - | |||||||||||||||||||||||||||||||||||||
8986 | case QEvent::ApplicationFontChange: never executed: case QEvent::ApplicationFontChange: | 0 | ||||||||||||||||||||||||||||||||||||
8987 | d->resolveFont(); | - | ||||||||||||||||||||||||||||||||||||
8988 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8989 | case QEvent::ApplicationPaletteChange: never executed: case QEvent::ApplicationPaletteChange: | 0 | ||||||||||||||||||||||||||||||||||||
8990 | if (!(windowType() == Qt::Desktop))
| 0 | ||||||||||||||||||||||||||||||||||||
8991 | d->resolvePalette(); never executed: d->resolvePalette(); | 0 | ||||||||||||||||||||||||||||||||||||
8992 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
8993 | - | |||||||||||||||||||||||||||||||||||||
8994 | case QEvent::ToolBarChange: never executed: case QEvent::ToolBarChange: | 0 | ||||||||||||||||||||||||||||||||||||
8995 | case QEvent::ActivationChange: never executed: case QEvent::ActivationChange: | 0 | ||||||||||||||||||||||||||||||||||||
8996 | case QEvent::EnabledChange: never executed: case QEvent::EnabledChange: | 0 | ||||||||||||||||||||||||||||||||||||
8997 | case QEvent::FontChange: never executed: case QEvent::FontChange: | 0 | ||||||||||||||||||||||||||||||||||||
8998 | case QEvent::StyleChange: never executed: case QEvent::StyleChange: | 0 | ||||||||||||||||||||||||||||||||||||
8999 | case QEvent::PaletteChange: never executed: case QEvent::PaletteChange: | 0 | ||||||||||||||||||||||||||||||||||||
9000 | case QEvent::WindowTitleChange: never executed: case QEvent::WindowTitleChange: | 0 | ||||||||||||||||||||||||||||||||||||
9001 | case QEvent::IconTextChange: never executed: case QEvent::IconTextChange: | 0 | ||||||||||||||||||||||||||||||||||||
9002 | case QEvent::ModifiedChange: never executed: case QEvent::ModifiedChange: | 0 | ||||||||||||||||||||||||||||||||||||
9003 | case QEvent::MouseTrackingChange: never executed: case QEvent::MouseTrackingChange: | 0 | ||||||||||||||||||||||||||||||||||||
9004 | case QEvent::ParentChange: never executed: case QEvent::ParentChange: | 0 | ||||||||||||||||||||||||||||||||||||
9005 | case QEvent::LocaleChange: never executed: case QEvent::LocaleChange: | 0 | ||||||||||||||||||||||||||||||||||||
9006 | case QEvent::MacSizeChange: never executed: case QEvent::MacSizeChange: | 0 | ||||||||||||||||||||||||||||||||||||
9007 | case QEvent::ContentsRectChange: never executed: case QEvent::ContentsRectChange: | 0 | ||||||||||||||||||||||||||||||||||||
9008 | case QEvent::ThemeChange: never executed: case QEvent::ThemeChange: | 0 | ||||||||||||||||||||||||||||||||||||
9009 | case QEvent::ReadOnlyChange: never executed: case QEvent::ReadOnlyChange: | 0 | ||||||||||||||||||||||||||||||||||||
9010 | changeEvent(event); | - | ||||||||||||||||||||||||||||||||||||
9011 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9012 | - | |||||||||||||||||||||||||||||||||||||
9013 | case QEvent::WindowStateChange: { never executed: case QEvent::WindowStateChange: | 0 | ||||||||||||||||||||||||||||||||||||
9014 | const bool wasMinimized = static_cast<const QWindowStateChangeEvent *>(event)->oldState() & Qt::WindowMinimized; | - | ||||||||||||||||||||||||||||||||||||
9015 | if (wasMinimized != isMinimized()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9016 | QWidget *widget = const_cast<QWidget *>(this); | - | ||||||||||||||||||||||||||||||||||||
9017 | if (wasMinimized) {
| 0 | ||||||||||||||||||||||||||||||||||||
9018 | // Always send the spontaneous events here, otherwise it can break the application! | - | ||||||||||||||||||||||||||||||||||||
9019 | if (!d->childrenShownByExpose) {
| 0 | ||||||||||||||||||||||||||||||||||||
9020 | // Show widgets only when they are not yet shown by the expose event | - | ||||||||||||||||||||||||||||||||||||
9021 | d->showChildren(true); | - | ||||||||||||||||||||||||||||||||||||
9022 | QShowEvent showEvent; | - | ||||||||||||||||||||||||||||||||||||
9023 | QCoreApplication::sendSpontaneousEvent(widget, &showEvent); | - | ||||||||||||||||||||||||||||||||||||
9024 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9025 | d->childrenHiddenByWState = false; // Set it always to "false" when window is restored | - | ||||||||||||||||||||||||||||||||||||
9026 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9027 | QHideEvent hideEvent; | - | ||||||||||||||||||||||||||||||||||||
9028 | QCoreApplication::sendSpontaneousEvent(widget, &hideEvent); | - | ||||||||||||||||||||||||||||||||||||
9029 | d->hideChildren(true); | - | ||||||||||||||||||||||||||||||||||||
9030 | d->childrenHiddenByWState = true; | - | ||||||||||||||||||||||||||||||||||||
9031 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9032 | d->childrenShownByExpose = false; // Set it always to "false" when window state changes | - | ||||||||||||||||||||||||||||||||||||
9033 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9034 | changeEvent(event); | - | ||||||||||||||||||||||||||||||||||||
9035 | } | - | ||||||||||||||||||||||||||||||||||||
9036 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9037 | - | |||||||||||||||||||||||||||||||||||||
9038 | case QEvent::WindowActivate: never executed: case QEvent::WindowActivate: | 0 | ||||||||||||||||||||||||||||||||||||
9039 | case QEvent::WindowDeactivate: { never executed: case QEvent::WindowDeactivate: | 0 | ||||||||||||||||||||||||||||||||||||
9040 | if (isVisible() && !palette().isEqual(QPalette::Active, QPalette::Inactive))
| 0 | ||||||||||||||||||||||||||||||||||||
9041 | update(); never executed: update(); | 0 | ||||||||||||||||||||||||||||||||||||
9042 | QList<QObject*> childList = d->children; | - | ||||||||||||||||||||||||||||||||||||
9043 | for (int i = 0; i < childList.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
9044 | QWidget *w = qobject_cast<QWidget *>(childList.at(i)); | - | ||||||||||||||||||||||||||||||||||||
9045 | if (w && w->isVisible() && !w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
9046 | QApplication::sendEvent(w, event); never executed: QApplication::sendEvent(w, event); | 0 | ||||||||||||||||||||||||||||||||||||
9047 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9048 | break; } never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9049 | - | |||||||||||||||||||||||||||||||||||||
9050 | case QEvent::LanguageChange: never executed: case QEvent::LanguageChange: | 0 | ||||||||||||||||||||||||||||||||||||
9051 | changeEvent(event); | - | ||||||||||||||||||||||||||||||||||||
9052 | { | - | ||||||||||||||||||||||||||||||||||||
9053 | QList<QObject*> childList = d->children; | - | ||||||||||||||||||||||||||||||||||||
9054 | for (int i = 0; i < childList.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
9055 | QObject *o = childList.at(i); | - | ||||||||||||||||||||||||||||||||||||
9056 | if (o)
| 0 | ||||||||||||||||||||||||||||||||||||
9057 | QApplication::sendEvent(o, event); never executed: QApplication::sendEvent(o, event); | 0 | ||||||||||||||||||||||||||||||||||||
9058 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9059 | } | - | ||||||||||||||||||||||||||||||||||||
9060 | update(); | - | ||||||||||||||||||||||||||||||||||||
9061 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9062 | - | |||||||||||||||||||||||||||||||||||||
9063 | case QEvent::ApplicationLayoutDirectionChange: never executed: case QEvent::ApplicationLayoutDirectionChange: | 0 | ||||||||||||||||||||||||||||||||||||
9064 | d->resolveLayoutDirection(); | - | ||||||||||||||||||||||||||||||||||||
9065 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9066 | - | |||||||||||||||||||||||||||||||||||||
9067 | case QEvent::LayoutDirectionChange: never executed: case QEvent::LayoutDirectionChange: | 0 | ||||||||||||||||||||||||||||||||||||
9068 | if (d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
9069 | d->layout->invalidate(); never executed: d->layout->invalidate(); | 0 | ||||||||||||||||||||||||||||||||||||
9070 | update(); | - | ||||||||||||||||||||||||||||||||||||
9071 | changeEvent(event); | - | ||||||||||||||||||||||||||||||||||||
9072 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9073 | case QEvent::UpdateRequest: never executed: case QEvent::UpdateRequest: | 0 | ||||||||||||||||||||||||||||||||||||
9074 | d->syncBackingStore(); | - | ||||||||||||||||||||||||||||||||||||
9075 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9076 | case QEvent::UpdateLater: never executed: case QEvent::UpdateLater: | 0 | ||||||||||||||||||||||||||||||||||||
9077 | update(static_cast<QUpdateLaterEvent*>(event)->region()); | - | ||||||||||||||||||||||||||||||||||||
9078 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9079 | case QEvent::StyleAnimationUpdate: never executed: case QEvent::StyleAnimationUpdate: | 0 | ||||||||||||||||||||||||||||||||||||
9080 | if (isVisible() && !window()->isMinimized()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9081 | event->accept(); | - | ||||||||||||||||||||||||||||||||||||
9082 | update(); | - | ||||||||||||||||||||||||||||||||||||
9083 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9084 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9085 | - | |||||||||||||||||||||||||||||||||||||
9086 | case QEvent::WindowBlocked: never executed: case QEvent::WindowBlocked: | 0 | ||||||||||||||||||||||||||||||||||||
9087 | case QEvent::WindowUnblocked: never executed: case QEvent::WindowUnblocked: | 0 | ||||||||||||||||||||||||||||||||||||
9088 | if (!d->children.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9089 | QWidget *modalWidget = QApplication::activeModalWidget(); | - | ||||||||||||||||||||||||||||||||||||
9090 | for (int i = 0; i < d->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
9091 | QObject *o = d->children.at(i); | - | ||||||||||||||||||||||||||||||||||||
9092 | if (o && o != modalWidget && o->isWidgetType()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9093 | QWidget *w = static_cast<QWidget *>(o); | - | ||||||||||||||||||||||||||||||||||||
9094 | // do not forward the event to child windows; QApplication does this for us | - | ||||||||||||||||||||||||||||||||||||
9095 | if (!w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
9096 | QApplication::sendEvent(w, event); never executed: QApplication::sendEvent(w, event); | 0 | ||||||||||||||||||||||||||||||||||||
9097 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9098 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9099 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9100 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||||||||||||||
9101 | setDisabledStyle(this, (event->type() == QEvent::WindowBlocked)); | - | ||||||||||||||||||||||||||||||||||||
9102 | #endif | - | ||||||||||||||||||||||||||||||||||||
9103 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9104 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||||||||||||||
9105 | case QEvent::ToolTip: never executed: case QEvent::ToolTip: | 0 | ||||||||||||||||||||||||||||||||||||
9106 | if (!d->toolTip.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
9107 | 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 | ||||||||||||||||||||||||||||||||||||
9108 | else | - | ||||||||||||||||||||||||||||||||||||
9109 | event->ignore(); never executed: event->ignore(); | 0 | ||||||||||||||||||||||||||||||||||||
9110 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9111 | #endif | - | ||||||||||||||||||||||||||||||||||||
9112 | #ifndef QT_NO_WHATSTHIS | - | ||||||||||||||||||||||||||||||||||||
9113 | case QEvent::WhatsThis: never executed: case QEvent::WhatsThis: | 0 | ||||||||||||||||||||||||||||||||||||
9114 | if (d->whatsThis.size())
| 0 | ||||||||||||||||||||||||||||||||||||
9115 | QWhatsThis::showText(static_cast<QHelpEvent *>(event)->globalPos(), d->whatsThis, this); never executed: QWhatsThis::showText(static_cast<QHelpEvent *>(event)->globalPos(), d->whatsThis, this); | 0 | ||||||||||||||||||||||||||||||||||||
9116 | else | - | ||||||||||||||||||||||||||||||||||||
9117 | event->ignore(); never executed: event->ignore(); | 0 | ||||||||||||||||||||||||||||||||||||
9118 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9119 | case QEvent::QueryWhatsThis: never executed: case QEvent::QueryWhatsThis: | 0 | ||||||||||||||||||||||||||||||||||||
9120 | if (d->whatsThis.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
9121 | event->ignore(); never executed: event->ignore(); | 0 | ||||||||||||||||||||||||||||||||||||
9122 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9123 | #endif | - | ||||||||||||||||||||||||||||||||||||
9124 | case QEvent::EmbeddingControl: never executed: case QEvent::EmbeddingControl: | 0 | ||||||||||||||||||||||||||||||||||||
9125 | d->topData()->frameStrut.setCoords(0 ,0, 0, 0); | - | ||||||||||||||||||||||||||||||||||||
9126 | data->fstrut_dirty = false; | - | ||||||||||||||||||||||||||||||||||||
9127 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_X11) | - | ||||||||||||||||||||||||||||||||||||
9128 | d->topData()->embedded = 1; | - | ||||||||||||||||||||||||||||||||||||
9129 | #endif | - | ||||||||||||||||||||||||||||||||||||
9130 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9131 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||||||||||||||
9132 | case QEvent::ActionAdded: never executed: case QEvent::ActionAdded: | 0 | ||||||||||||||||||||||||||||||||||||
9133 | case QEvent::ActionRemoved: never executed: case QEvent::ActionRemoved: | 0 | ||||||||||||||||||||||||||||||||||||
9134 | case QEvent::ActionChanged: never executed: case QEvent::ActionChanged: | 0 | ||||||||||||||||||||||||||||||||||||
9135 | actionEvent((QActionEvent*)event); | - | ||||||||||||||||||||||||||||||||||||
9136 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9137 | #endif | - | ||||||||||||||||||||||||||||||||||||
9138 | - | |||||||||||||||||||||||||||||||||||||
9139 | case QEvent::KeyboardLayoutChange: never executed: case QEvent::KeyboardLayoutChange: | 0 | ||||||||||||||||||||||||||||||||||||
9140 | { | - | ||||||||||||||||||||||||||||||||||||
9141 | changeEvent(event); | - | ||||||||||||||||||||||||||||||||||||
9142 | - | |||||||||||||||||||||||||||||||||||||
9143 | // inform children of the change | - | ||||||||||||||||||||||||||||||||||||
9144 | QList<QObject*> childList = d->children; | - | ||||||||||||||||||||||||||||||||||||
9145 | for (int i = 0; i < childList.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
9146 | QWidget *w = qobject_cast<QWidget *>(childList.at(i)); | - | ||||||||||||||||||||||||||||||||||||
9147 | if (w && w->isVisible() && !w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
9148 | QApplication::sendEvent(w, event); never executed: QApplication::sendEvent(w, event); | 0 | ||||||||||||||||||||||||||||||||||||
9149 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9150 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9151 | } | - | ||||||||||||||||||||||||||||||||||||
9152 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
9153 | case QEvent::MacGLWindowChange: | - | ||||||||||||||||||||||||||||||||||||
9154 | d->needWindowChange = false; | - | ||||||||||||||||||||||||||||||||||||
9155 | break; | - | ||||||||||||||||||||||||||||||||||||
9156 | #endif | - | ||||||||||||||||||||||||||||||||||||
9157 | case QEvent::TouchBegin: never executed: case QEvent::TouchBegin: | 0 | ||||||||||||||||||||||||||||||||||||
9158 | case QEvent::TouchUpdate: never executed: case QEvent::TouchUpdate: | 0 | ||||||||||||||||||||||||||||||||||||
9159 | case QEvent::TouchEnd: never executed: case QEvent::TouchEnd: | 0 | ||||||||||||||||||||||||||||||||||||
9160 | case QEvent::TouchCancel: never executed: case QEvent::TouchCancel: | 0 | ||||||||||||||||||||||||||||||||||||
9161 | { | - | ||||||||||||||||||||||||||||||||||||
9162 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9163 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9164 | } | - | ||||||||||||||||||||||||||||||||||||
9165 | #ifndef QT_NO_GESTURES | - | ||||||||||||||||||||||||||||||||||||
9166 | case QEvent::Gesture: never executed: case QEvent::Gesture: | 0 | ||||||||||||||||||||||||||||||||||||
9167 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9168 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9169 | #endif | - | ||||||||||||||||||||||||||||||||||||
9170 | case QEvent::ScreenChangeInternal: never executed: case QEvent::ScreenChangeInternal: | 0 | ||||||||||||||||||||||||||||||||||||
9171 | if (const QTLWExtra *te = d->maybeTopData()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9172 | const QWindow *win = te->window; | - | ||||||||||||||||||||||||||||||||||||
9173 | d->setWinId((win && win->handle()) ? win->handle()->winId() : 0); | - | ||||||||||||||||||||||||||||||||||||
9174 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9175 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
9176 | d->renderToTextureReallyDirty = 1; | - | ||||||||||||||||||||||||||||||||||||
9177 | #endif | - | ||||||||||||||||||||||||||||||||||||
9178 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9179 | #ifndef QT_NO_PROPERTIES | - | ||||||||||||||||||||||||||||||||||||
9180 | case QEvent::DynamicPropertyChange: { never executed: case QEvent::DynamicPropertyChange: | 0 | ||||||||||||||||||||||||||||||||||||
9181 | const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName(); | - | ||||||||||||||||||||||||||||||||||||
9182 | if (propName.length() == 13 && !qstrncmp(propName, "_q_customDpi", 12)) {
| 0 | ||||||||||||||||||||||||||||||||||||
9183 | uint value = property(propName.constData()).toUInt(); | - | ||||||||||||||||||||||||||||||||||||
9184 | if (!d->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
9185 | d->createExtra(); never executed: d->createExtra(); | 0 | ||||||||||||||||||||||||||||||||||||
9186 | const char axis = propName.at(12); | - | ||||||||||||||||||||||||||||||||||||
9187 | if (axis == 'X')
| 0 | ||||||||||||||||||||||||||||||||||||
9188 | d->extra->customDpiX = value; never executed: d->extra->customDpiX = value; | 0 | ||||||||||||||||||||||||||||||||||||
9189 | else if (axis == 'Y')
| 0 | ||||||||||||||||||||||||||||||||||||
9190 | d->extra->customDpiY = value; never executed: d->extra->customDpiY = value; | 0 | ||||||||||||||||||||||||||||||||||||
9191 | d->updateFont(d->data.fnt); | - | ||||||||||||||||||||||||||||||||||||
9192 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9193 | if (windowHandle() && !qstrncmp(propName, "_q_platform_", 12))
| 0 | ||||||||||||||||||||||||||||||||||||
9194 | windowHandle()->setProperty(propName, property(propName)); never executed: windowHandle()->setProperty(propName, property(propName)); | 0 | ||||||||||||||||||||||||||||||||||||
9195 | // fall through | - | ||||||||||||||||||||||||||||||||||||
9196 | } | - | ||||||||||||||||||||||||||||||||||||
9197 | #endif | - | ||||||||||||||||||||||||||||||||||||
9198 | default: code before this statement never executed: default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
9199 | return QObject::event(event); never executed: return QObject::event(event); | 0 | ||||||||||||||||||||||||||||||||||||
9200 | } | - | ||||||||||||||||||||||||||||||||||||
9201 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||||||||
9202 | } | - | ||||||||||||||||||||||||||||||||||||
9203 | - | |||||||||||||||||||||||||||||||||||||
9204 | /*! | - | ||||||||||||||||||||||||||||||||||||
9205 | This event handler can be reimplemented to handle state changes. | - | ||||||||||||||||||||||||||||||||||||
9206 | - | |||||||||||||||||||||||||||||||||||||
9207 | The state being changed in this event can be retrieved through the \a event | - | ||||||||||||||||||||||||||||||||||||
9208 | supplied. | - | ||||||||||||||||||||||||||||||||||||
9209 | - | |||||||||||||||||||||||||||||||||||||
9210 | Change events include: QEvent::ToolBarChange, | - | ||||||||||||||||||||||||||||||||||||
9211 | QEvent::ActivationChange, QEvent::EnabledChange, QEvent::FontChange, | - | ||||||||||||||||||||||||||||||||||||
9212 | QEvent::StyleChange, QEvent::PaletteChange, | - | ||||||||||||||||||||||||||||||||||||
9213 | QEvent::WindowTitleChange, QEvent::IconTextChange, | - | ||||||||||||||||||||||||||||||||||||
9214 | QEvent::ModifiedChange, QEvent::MouseTrackingChange, | - | ||||||||||||||||||||||||||||||||||||
9215 | QEvent::ParentChange, QEvent::WindowStateChange, | - | ||||||||||||||||||||||||||||||||||||
9216 | QEvent::LanguageChange, QEvent::LocaleChange, | - | ||||||||||||||||||||||||||||||||||||
9217 | QEvent::LayoutDirectionChange, QEvent::ReadOnlyChange. | - | ||||||||||||||||||||||||||||||||||||
9218 | - | |||||||||||||||||||||||||||||||||||||
9219 | */ | - | ||||||||||||||||||||||||||||||||||||
9220 | void QWidget::changeEvent(QEvent * event) | - | ||||||||||||||||||||||||||||||||||||
9221 | { | - | ||||||||||||||||||||||||||||||||||||
9222 | switch(event->type()) { | - | ||||||||||||||||||||||||||||||||||||
9223 | case QEvent::EnabledChange: { never executed: case QEvent::EnabledChange: | 0 | ||||||||||||||||||||||||||||||||||||
9224 | update(); | - | ||||||||||||||||||||||||||||||||||||
9225 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
9226 | QAccessible::State s; | - | ||||||||||||||||||||||||||||||||||||
9227 | s.disabled = true; | - | ||||||||||||||||||||||||||||||||||||
9228 | QAccessibleStateChangeEvent event(this, s); | - | ||||||||||||||||||||||||||||||||||||
9229 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
9230 | #endif | - | ||||||||||||||||||||||||||||||||||||
9231 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9232 | } | - | ||||||||||||||||||||||||||||||||||||
9233 | - | |||||||||||||||||||||||||||||||||||||
9234 | case QEvent::FontChange: never executed: case QEvent::FontChange: | 0 | ||||||||||||||||||||||||||||||||||||
9235 | case QEvent::StyleChange: { never executed: case QEvent::StyleChange: | 0 | ||||||||||||||||||||||||||||||||||||
9236 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
9237 | update(); | - | ||||||||||||||||||||||||||||||||||||
9238 | updateGeometry(); | - | ||||||||||||||||||||||||||||||||||||
9239 | if (d->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
9240 | d->layout->invalidate(); never executed: d->layout->invalidate(); | 0 | ||||||||||||||||||||||||||||||||||||
9241 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9242 | } | - | ||||||||||||||||||||||||||||||||||||
9243 | - | |||||||||||||||||||||||||||||||||||||
9244 | case QEvent::PaletteChange: never executed: case QEvent::PaletteChange: | 0 | ||||||||||||||||||||||||||||||||||||
9245 | update(); | - | ||||||||||||||||||||||||||||||||||||
9246 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9247 | - | |||||||||||||||||||||||||||||||||||||
9248 | case QEvent::ThemeChange: never executed: case QEvent::ThemeChange: | 0 | ||||||||||||||||||||||||||||||||||||
9249 | if (QApplication::desktopSettingsAware() && windowType() != Qt::Desktop
| 0 | ||||||||||||||||||||||||||||||||||||
9250 | && qApp && !QApplication::closingDown()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9251 | if (testAttribute(Qt::WA_WState_Polished))
| 0 | ||||||||||||||||||||||||||||||||||||
9252 | QApplication::style()->unpolish(this); never executed: QApplication::style()->unpolish(this); | 0 | ||||||||||||||||||||||||||||||||||||
9253 | if (testAttribute(Qt::WA_WState_Polished))
| 0 | ||||||||||||||||||||||||||||||||||||
9254 | QApplication::style()->polish(this); never executed: QApplication::style()->polish(this); | 0 | ||||||||||||||||||||||||||||||||||||
9255 | QEvent styleChangedEvent(QEvent::StyleChange); | - | ||||||||||||||||||||||||||||||||||||
9256 | QCoreApplication::sendEvent(this, &styleChangedEvent); | - | ||||||||||||||||||||||||||||||||||||
9257 | if (isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
9258 | update(); never executed: update(); | 0 | ||||||||||||||||||||||||||||||||||||
9259 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9260 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9261 | - | |||||||||||||||||||||||||||||||||||||
9262 | #ifdef Q_OS_MAC | - | ||||||||||||||||||||||||||||||||||||
9263 | case QEvent::MacSizeChange: | - | ||||||||||||||||||||||||||||||||||||
9264 | updateGeometry(); | - | ||||||||||||||||||||||||||||||||||||
9265 | break; | - | ||||||||||||||||||||||||||||||||||||
9266 | #elif defined Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
9267 | case QEvent::ToolTipChange: | - | ||||||||||||||||||||||||||||||||||||
9268 | case QEvent::MouseTrackingChange: | - | ||||||||||||||||||||||||||||||||||||
9269 | qt_mac_update_mouseTracking(this); | - | ||||||||||||||||||||||||||||||||||||
9270 | break; | - | ||||||||||||||||||||||||||||||||||||
9271 | #endif | - | ||||||||||||||||||||||||||||||||||||
9272 | - | |||||||||||||||||||||||||||||||||||||
9273 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
9274 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
9275 | } | - | ||||||||||||||||||||||||||||||||||||
9276 | } | - | ||||||||||||||||||||||||||||||||||||
9277 | - | |||||||||||||||||||||||||||||||||||||
9278 | /*! | - | ||||||||||||||||||||||||||||||||||||
9279 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9280 | subclass to receive mouse move events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9281 | - | |||||||||||||||||||||||||||||||||||||
9282 | If mouse tracking is switched off, mouse move events only occur if | - | ||||||||||||||||||||||||||||||||||||
9283 | a mouse button is pressed while the mouse is being moved. If mouse | - | ||||||||||||||||||||||||||||||||||||
9284 | tracking is switched on, mouse move events occur even if no mouse | - | ||||||||||||||||||||||||||||||||||||
9285 | button is pressed. | - | ||||||||||||||||||||||||||||||||||||
9286 | - | |||||||||||||||||||||||||||||||||||||
9287 | QMouseEvent::pos() reports the position of the mouse cursor, | - | ||||||||||||||||||||||||||||||||||||
9288 | relative to this widget. For press and release events, the | - | ||||||||||||||||||||||||||||||||||||
9289 | position is usually the same as the position of the last mouse | - | ||||||||||||||||||||||||||||||||||||
9290 | move event, but it might be different if the user's hand shakes. | - | ||||||||||||||||||||||||||||||||||||
9291 | This is a feature of the underlying window system, not Qt. | - | ||||||||||||||||||||||||||||||||||||
9292 | - | |||||||||||||||||||||||||||||||||||||
9293 | If you want to show a tooltip immediately, while the mouse is | - | ||||||||||||||||||||||||||||||||||||
9294 | moving (e.g., to get the mouse coordinates with QMouseEvent::pos() | - | ||||||||||||||||||||||||||||||||||||
9295 | and show them as a tooltip), you must first enable mouse tracking | - | ||||||||||||||||||||||||||||||||||||
9296 | as described above. Then, to ensure that the tooltip is updated | - | ||||||||||||||||||||||||||||||||||||
9297 | immediately, you must call QToolTip::showText() instead of | - | ||||||||||||||||||||||||||||||||||||
9298 | setToolTip() in your implementation of mouseMoveEvent(). | - | ||||||||||||||||||||||||||||||||||||
9299 | - | |||||||||||||||||||||||||||||||||||||
9300 | \sa setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), | - | ||||||||||||||||||||||||||||||||||||
9301 | mouseDoubleClickEvent(), event(), QMouseEvent, {Scribble Example} | - | ||||||||||||||||||||||||||||||||||||
9302 | */ | - | ||||||||||||||||||||||||||||||||||||
9303 | - | |||||||||||||||||||||||||||||||||||||
9304 | void QWidget::mouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9305 | { | - | ||||||||||||||||||||||||||||||||||||
9306 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9307 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9308 | - | |||||||||||||||||||||||||||||||||||||
9309 | /*! | - | ||||||||||||||||||||||||||||||||||||
9310 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9311 | subclass to receive mouse press events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9312 | - | |||||||||||||||||||||||||||||||||||||
9313 | If you create new widgets in the mousePressEvent() the | - | ||||||||||||||||||||||||||||||||||||
9314 | mouseReleaseEvent() may not end up where you expect, depending on | - | ||||||||||||||||||||||||||||||||||||
9315 | the underlying window system (or X11 window manager), the widgets' | - | ||||||||||||||||||||||||||||||||||||
9316 | location and maybe more. | - | ||||||||||||||||||||||||||||||||||||
9317 | - | |||||||||||||||||||||||||||||||||||||
9318 | The default implementation implements the closing of popup widgets | - | ||||||||||||||||||||||||||||||||||||
9319 | when you click outside the window. For other widget types it does | - | ||||||||||||||||||||||||||||||||||||
9320 | nothing. | - | ||||||||||||||||||||||||||||||||||||
9321 | - | |||||||||||||||||||||||||||||||||||||
9322 | \sa mouseReleaseEvent(), mouseDoubleClickEvent(), | - | ||||||||||||||||||||||||||||||||||||
9323 | mouseMoveEvent(), event(), QMouseEvent, {Scribble Example} | - | ||||||||||||||||||||||||||||||||||||
9324 | */ | - | ||||||||||||||||||||||||||||||||||||
9325 | - | |||||||||||||||||||||||||||||||||||||
9326 | void QWidget::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9327 | { | - | ||||||||||||||||||||||||||||||||||||
9328 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9329 | if ((windowType() == Qt::Popup)) {
| 0 | ||||||||||||||||||||||||||||||||||||
9330 | event->accept(); | - | ||||||||||||||||||||||||||||||||||||
9331 | QWidget* w; | - | ||||||||||||||||||||||||||||||||||||
9332 | while ((w = QApplication::activePopupWidget()) && w != this){
| 0 | ||||||||||||||||||||||||||||||||||||
9333 | w->close(); | - | ||||||||||||||||||||||||||||||||||||
9334 | if (QApplication::activePopupWidget() == w) // widget does not want to disappear
| 0 | ||||||||||||||||||||||||||||||||||||
9335 | w->hide(); // hide at least never executed: w->hide(); | 0 | ||||||||||||||||||||||||||||||||||||
9336 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9337 | if (!rect().contains(event->pos())){
| 0 | ||||||||||||||||||||||||||||||||||||
9338 | close(); | - | ||||||||||||||||||||||||||||||||||||
9339 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9340 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9341 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9342 | - | |||||||||||||||||||||||||||||||||||||
9343 | /*! | - | ||||||||||||||||||||||||||||||||||||
9344 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9345 | subclass to receive mouse release events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9346 | - | |||||||||||||||||||||||||||||||||||||
9347 | \sa mousePressEvent(), mouseDoubleClickEvent(), | - | ||||||||||||||||||||||||||||||||||||
9348 | mouseMoveEvent(), event(), QMouseEvent, {Scribble Example} | - | ||||||||||||||||||||||||||||||||||||
9349 | */ | - | ||||||||||||||||||||||||||||||||||||
9350 | - | |||||||||||||||||||||||||||||||||||||
9351 | void QWidget::mouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9352 | { | - | ||||||||||||||||||||||||||||||||||||
9353 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9354 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9355 | - | |||||||||||||||||||||||||||||||||||||
9356 | /*! | - | ||||||||||||||||||||||||||||||||||||
9357 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9358 | subclass to receive mouse double click events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9359 | - | |||||||||||||||||||||||||||||||||||||
9360 | The default implementation calls mousePressEvent(). | - | ||||||||||||||||||||||||||||||||||||
9361 | - | |||||||||||||||||||||||||||||||||||||
9362 | \note The widget will also receive mouse press and mouse release | - | ||||||||||||||||||||||||||||||||||||
9363 | events in addition to the double click event. It is up to the | - | ||||||||||||||||||||||||||||||||||||
9364 | developer to ensure that the application interprets these events | - | ||||||||||||||||||||||||||||||||||||
9365 | correctly. | - | ||||||||||||||||||||||||||||||||||||
9366 | - | |||||||||||||||||||||||||||||||||||||
9367 | \sa mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), | - | ||||||||||||||||||||||||||||||||||||
9368 | event(), QMouseEvent | - | ||||||||||||||||||||||||||||||||||||
9369 | */ | - | ||||||||||||||||||||||||||||||||||||
9370 | - | |||||||||||||||||||||||||||||||||||||
9371 | void QWidget::mouseDoubleClickEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9372 | { | - | ||||||||||||||||||||||||||||||||||||
9373 | mousePressEvent(event); | - | ||||||||||||||||||||||||||||||||||||
9374 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9375 | - | |||||||||||||||||||||||||||||||||||||
9376 | #ifndef QT_NO_WHEELEVENT | - | ||||||||||||||||||||||||||||||||||||
9377 | /*! | - | ||||||||||||||||||||||||||||||||||||
9378 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9379 | subclass to receive wheel events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9380 | - | |||||||||||||||||||||||||||||||||||||
9381 | If you reimplement this handler, it is very important that you | - | ||||||||||||||||||||||||||||||||||||
9382 | \l{QEvent}{ignore()} the event if you do not handle | - | ||||||||||||||||||||||||||||||||||||
9383 | it, so that the widget's parent can interpret it. | - | ||||||||||||||||||||||||||||||||||||
9384 | - | |||||||||||||||||||||||||||||||||||||
9385 | The default implementation ignores the event. | - | ||||||||||||||||||||||||||||||||||||
9386 | - | |||||||||||||||||||||||||||||||||||||
9387 | \sa QEvent::ignore(), QEvent::accept(), event(), | - | ||||||||||||||||||||||||||||||||||||
9388 | QWheelEvent | - | ||||||||||||||||||||||||||||||||||||
9389 | */ | - | ||||||||||||||||||||||||||||||||||||
9390 | - | |||||||||||||||||||||||||||||||||||||
9391 | void QWidget::wheelEvent(QWheelEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9392 | { | - | ||||||||||||||||||||||||||||||||||||
9393 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9394 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9395 | #endif // QT_NO_WHEELEVENT | - | ||||||||||||||||||||||||||||||||||||
9396 | - | |||||||||||||||||||||||||||||||||||||
9397 | #ifndef QT_NO_TABLETEVENT | - | ||||||||||||||||||||||||||||||||||||
9398 | /*! | - | ||||||||||||||||||||||||||||||||||||
9399 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9400 | subclass to receive tablet events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9401 | - | |||||||||||||||||||||||||||||||||||||
9402 | If you reimplement this handler, it is very important that you | - | ||||||||||||||||||||||||||||||||||||
9403 | \l{QEvent}{ignore()} the event if you do not handle | - | ||||||||||||||||||||||||||||||||||||
9404 | it, so that the widget's parent can interpret it. | - | ||||||||||||||||||||||||||||||||||||
9405 | - | |||||||||||||||||||||||||||||||||||||
9406 | The default implementation ignores the event. | - | ||||||||||||||||||||||||||||||||||||
9407 | - | |||||||||||||||||||||||||||||||||||||
9408 | \sa QEvent::ignore(), QEvent::accept(), event(), | - | ||||||||||||||||||||||||||||||||||||
9409 | QTabletEvent | - | ||||||||||||||||||||||||||||||||||||
9410 | */ | - | ||||||||||||||||||||||||||||||||||||
9411 | - | |||||||||||||||||||||||||||||||||||||
9412 | void QWidget::tabletEvent(QTabletEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9413 | { | - | ||||||||||||||||||||||||||||||||||||
9414 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9415 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9416 | #endif // QT_NO_TABLETEVENT | - | ||||||||||||||||||||||||||||||||||||
9417 | - | |||||||||||||||||||||||||||||||||||||
9418 | /*! | - | ||||||||||||||||||||||||||||||||||||
9419 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9420 | subclass to receive key press events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9421 | - | |||||||||||||||||||||||||||||||||||||
9422 | A widget must call setFocusPolicy() to accept focus initially and | - | ||||||||||||||||||||||||||||||||||||
9423 | have focus in order to receive a key press event. | - | ||||||||||||||||||||||||||||||||||||
9424 | - | |||||||||||||||||||||||||||||||||||||
9425 | If you reimplement this handler, it is very important that you | - | ||||||||||||||||||||||||||||||||||||
9426 | call the base class implementation if you do not act upon the key. | - | ||||||||||||||||||||||||||||||||||||
9427 | - | |||||||||||||||||||||||||||||||||||||
9428 | The default implementation closes popup widgets if the user | - | ||||||||||||||||||||||||||||||||||||
9429 | presses the key sequence for QKeySequence::Cancel (typically the | - | ||||||||||||||||||||||||||||||||||||
9430 | Escape key). Otherwise the event is ignored, so that the widget's | - | ||||||||||||||||||||||||||||||||||||
9431 | parent can interpret it. | - | ||||||||||||||||||||||||||||||||||||
9432 | - | |||||||||||||||||||||||||||||||||||||
9433 | Note that QKeyEvent starts with isAccepted() == true, so you do not | - | ||||||||||||||||||||||||||||||||||||
9434 | need to call QKeyEvent::accept() - just do not call the base class | - | ||||||||||||||||||||||||||||||||||||
9435 | implementation if you act upon the key. | - | ||||||||||||||||||||||||||||||||||||
9436 | - | |||||||||||||||||||||||||||||||||||||
9437 | \sa keyReleaseEvent(), setFocusPolicy(), | - | ||||||||||||||||||||||||||||||||||||
9438 | focusInEvent(), focusOutEvent(), event(), QKeyEvent, {Tetrix Example} | - | ||||||||||||||||||||||||||||||||||||
9439 | */ | - | ||||||||||||||||||||||||||||||||||||
9440 | - | |||||||||||||||||||||||||||||||||||||
9441 | void QWidget::keyPressEvent(QKeyEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9442 | { | - | ||||||||||||||||||||||||||||||||||||
9443 | if ((windowType() == Qt::Popup) && event->matches(QKeySequence::Cancel)) {
| 0 | ||||||||||||||||||||||||||||||||||||
9444 | event->accept(); | - | ||||||||||||||||||||||||||||||||||||
9445 | close(); | - | ||||||||||||||||||||||||||||||||||||
9446 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9447 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9448 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9449 | } | - | ||||||||||||||||||||||||||||||||||||
9450 | - | |||||||||||||||||||||||||||||||||||||
9451 | /*! | - | ||||||||||||||||||||||||||||||||||||
9452 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9453 | subclass to receive key release events for the widget. | - | ||||||||||||||||||||||||||||||||||||
9454 | - | |||||||||||||||||||||||||||||||||||||
9455 | A widget must \l{setFocusPolicy()}{accept focus} | - | ||||||||||||||||||||||||||||||||||||
9456 | initially and \l{hasFocus()}{have focus} in order to | - | ||||||||||||||||||||||||||||||||||||
9457 | receive a key release event. | - | ||||||||||||||||||||||||||||||||||||
9458 | - | |||||||||||||||||||||||||||||||||||||
9459 | If you reimplement this handler, it is very important that you | - | ||||||||||||||||||||||||||||||||||||
9460 | call the base class implementation if you do not act upon the key. | - | ||||||||||||||||||||||||||||||||||||
9461 | - | |||||||||||||||||||||||||||||||||||||
9462 | The default implementation ignores the event, so that the widget's | - | ||||||||||||||||||||||||||||||||||||
9463 | parent can interpret it. | - | ||||||||||||||||||||||||||||||||||||
9464 | - | |||||||||||||||||||||||||||||||||||||
9465 | Note that QKeyEvent starts with isAccepted() == true, so you do not | - | ||||||||||||||||||||||||||||||||||||
9466 | need to call QKeyEvent::accept() - just do not call the base class | - | ||||||||||||||||||||||||||||||||||||
9467 | implementation if you act upon the key. | - | ||||||||||||||||||||||||||||||||||||
9468 | - | |||||||||||||||||||||||||||||||||||||
9469 | \sa keyPressEvent(), QEvent::ignore(), setFocusPolicy(), | - | ||||||||||||||||||||||||||||||||||||
9470 | focusInEvent(), focusOutEvent(), event(), QKeyEvent | - | ||||||||||||||||||||||||||||||||||||
9471 | */ | - | ||||||||||||||||||||||||||||||||||||
9472 | - | |||||||||||||||||||||||||||||||||||||
9473 | void QWidget::keyReleaseEvent(QKeyEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9474 | { | - | ||||||||||||||||||||||||||||||||||||
9475 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9476 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9477 | - | |||||||||||||||||||||||||||||||||||||
9478 | /*! | - | ||||||||||||||||||||||||||||||||||||
9479 | \fn void QWidget::focusInEvent(QFocusEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9480 | - | |||||||||||||||||||||||||||||||||||||
9481 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9482 | keyboard focus events (focus received) for the widget. The event | - | ||||||||||||||||||||||||||||||||||||
9483 | is passed in the \a event parameter | - | ||||||||||||||||||||||||||||||||||||
9484 | - | |||||||||||||||||||||||||||||||||||||
9485 | A widget normally must setFocusPolicy() to something other than | - | ||||||||||||||||||||||||||||||||||||
9486 | Qt::NoFocus in order to receive focus events. (Note that the | - | ||||||||||||||||||||||||||||||||||||
9487 | application programmer can call setFocus() on any widget, even | - | ||||||||||||||||||||||||||||||||||||
9488 | those that do not normally accept focus.) | - | ||||||||||||||||||||||||||||||||||||
9489 | - | |||||||||||||||||||||||||||||||||||||
9490 | The default implementation updates the widget (except for windows | - | ||||||||||||||||||||||||||||||||||||
9491 | that do not specify a focusPolicy()). | - | ||||||||||||||||||||||||||||||||||||
9492 | - | |||||||||||||||||||||||||||||||||||||
9493 | \sa focusOutEvent(), setFocusPolicy(), keyPressEvent(), | - | ||||||||||||||||||||||||||||||||||||
9494 | keyReleaseEvent(), event(), QFocusEvent | - | ||||||||||||||||||||||||||||||||||||
9495 | */ | - | ||||||||||||||||||||||||||||||||||||
9496 | - | |||||||||||||||||||||||||||||||||||||
9497 | void QWidget::focusInEvent(QFocusEvent *) | - | ||||||||||||||||||||||||||||||||||||
9498 | { | - | ||||||||||||||||||||||||||||||||||||
9499 | if (focusPolicy() != Qt::NoFocus || !isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
9500 | update(); | - | ||||||||||||||||||||||||||||||||||||
9501 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9502 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9503 | - | |||||||||||||||||||||||||||||||||||||
9504 | /*! | - | ||||||||||||||||||||||||||||||||||||
9505 | \fn void QWidget::focusOutEvent(QFocusEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9506 | - | |||||||||||||||||||||||||||||||||||||
9507 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9508 | keyboard focus events (focus lost) for the widget. The events is | - | ||||||||||||||||||||||||||||||||||||
9509 | passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9510 | - | |||||||||||||||||||||||||||||||||||||
9511 | A widget normally must setFocusPolicy() to something other than | - | ||||||||||||||||||||||||||||||||||||
9512 | Qt::NoFocus in order to receive focus events. (Note that the | - | ||||||||||||||||||||||||||||||||||||
9513 | application programmer can call setFocus() on any widget, even | - | ||||||||||||||||||||||||||||||||||||
9514 | those that do not normally accept focus.) | - | ||||||||||||||||||||||||||||||||||||
9515 | - | |||||||||||||||||||||||||||||||||||||
9516 | The default implementation updates the widget (except for windows | - | ||||||||||||||||||||||||||||||||||||
9517 | that do not specify a focusPolicy()). | - | ||||||||||||||||||||||||||||||||||||
9518 | - | |||||||||||||||||||||||||||||||||||||
9519 | \sa focusInEvent(), setFocusPolicy(), keyPressEvent(), | - | ||||||||||||||||||||||||||||||||||||
9520 | keyReleaseEvent(), event(), QFocusEvent | - | ||||||||||||||||||||||||||||||||||||
9521 | */ | - | ||||||||||||||||||||||||||||||||||||
9522 | - | |||||||||||||||||||||||||||||||||||||
9523 | void QWidget::focusOutEvent(QFocusEvent *) | - | ||||||||||||||||||||||||||||||||||||
9524 | { | - | ||||||||||||||||||||||||||||||||||||
9525 | if (focusPolicy() != Qt::NoFocus || !isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
9526 | update(); never executed: update(); | 0 | ||||||||||||||||||||||||||||||||||||
9527 | - | |||||||||||||||||||||||||||||||||||||
9528 | #ifndef Q_OS_IOS | - | ||||||||||||||||||||||||||||||||||||
9529 | // FIXME: revisit autoSIP logic, QTBUG-42906 | - | ||||||||||||||||||||||||||||||||||||
9530 | if (qApp->autoSipEnabled() && testAttribute(Qt::WA_InputMethodEnabled))
| 0 | ||||||||||||||||||||||||||||||||||||
9531 | QGuiApplication::inputMethod()->hide(); never executed: QGuiApplication::inputMethod()->hide(); | 0 | ||||||||||||||||||||||||||||||||||||
9532 | #endif | - | ||||||||||||||||||||||||||||||||||||
9533 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9534 | - | |||||||||||||||||||||||||||||||||||||
9535 | /*! | - | ||||||||||||||||||||||||||||||||||||
9536 | \fn void QWidget::enterEvent(QEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9537 | - | |||||||||||||||||||||||||||||||||||||
9538 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9539 | widget enter events which are passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9540 | - | |||||||||||||||||||||||||||||||||||||
9541 | An event is sent to the widget when the mouse cursor enters the | - | ||||||||||||||||||||||||||||||||||||
9542 | widget. | - | ||||||||||||||||||||||||||||||||||||
9543 | - | |||||||||||||||||||||||||||||||||||||
9544 | \sa leaveEvent(), mouseMoveEvent(), event() | - | ||||||||||||||||||||||||||||||||||||
9545 | */ | - | ||||||||||||||||||||||||||||||||||||
9546 | - | |||||||||||||||||||||||||||||||||||||
9547 | void QWidget::enterEvent(QEvent *) | - | ||||||||||||||||||||||||||||||||||||
9548 | { | - | ||||||||||||||||||||||||||||||||||||
9549 | } | - | ||||||||||||||||||||||||||||||||||||
9550 | - | |||||||||||||||||||||||||||||||||||||
9551 | // ### Qt 6: void QWidget::enterEvent(QEnterEvent *). | - | ||||||||||||||||||||||||||||||||||||
9552 | - | |||||||||||||||||||||||||||||||||||||
9553 | /*! | - | ||||||||||||||||||||||||||||||||||||
9554 | \fn void QWidget::leaveEvent(QEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9555 | - | |||||||||||||||||||||||||||||||||||||
9556 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9557 | widget leave events which are passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9558 | - | |||||||||||||||||||||||||||||||||||||
9559 | A leave event is sent to the widget when the mouse cursor leaves | - | ||||||||||||||||||||||||||||||||||||
9560 | the widget. | - | ||||||||||||||||||||||||||||||||||||
9561 | - | |||||||||||||||||||||||||||||||||||||
9562 | \sa enterEvent(), mouseMoveEvent(), event() | - | ||||||||||||||||||||||||||||||||||||
9563 | */ | - | ||||||||||||||||||||||||||||||||||||
9564 | - | |||||||||||||||||||||||||||||||||||||
9565 | void QWidget::leaveEvent(QEvent *) | - | ||||||||||||||||||||||||||||||||||||
9566 | { | - | ||||||||||||||||||||||||||||||||||||
9567 | } | - | ||||||||||||||||||||||||||||||||||||
9568 | - | |||||||||||||||||||||||||||||||||||||
9569 | /*! | - | ||||||||||||||||||||||||||||||||||||
9570 | \fn void QWidget::paintEvent(QPaintEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9571 | - | |||||||||||||||||||||||||||||||||||||
9572 | This event handler can be reimplemented in a subclass to receive paint | - | ||||||||||||||||||||||||||||||||||||
9573 | events passed in \a event. | - | ||||||||||||||||||||||||||||||||||||
9574 | - | |||||||||||||||||||||||||||||||||||||
9575 | A paint event is a request to repaint all or part of a widget. It can | - | ||||||||||||||||||||||||||||||||||||
9576 | happen for one of the following reasons: | - | ||||||||||||||||||||||||||||||||||||
9577 | - | |||||||||||||||||||||||||||||||||||||
9578 | \list | - | ||||||||||||||||||||||||||||||||||||
9579 | \li repaint() or update() was invoked, | - | ||||||||||||||||||||||||||||||||||||
9580 | \li the widget was obscured and has now been uncovered, or | - | ||||||||||||||||||||||||||||||||||||
9581 | \li many other reasons. | - | ||||||||||||||||||||||||||||||||||||
9582 | \endlist | - | ||||||||||||||||||||||||||||||||||||
9583 | - | |||||||||||||||||||||||||||||||||||||
9584 | Many widgets can simply repaint their entire surface when asked to, but | - | ||||||||||||||||||||||||||||||||||||
9585 | some slow widgets need to optimize by painting only the requested region: | - | ||||||||||||||||||||||||||||||||||||
9586 | QPaintEvent::region(). This speed optimization does not change the result, | - | ||||||||||||||||||||||||||||||||||||
9587 | as painting is clipped to that region during event processing. QListView | - | ||||||||||||||||||||||||||||||||||||
9588 | and QTableView do this, for example. | - | ||||||||||||||||||||||||||||||||||||
9589 | - | |||||||||||||||||||||||||||||||||||||
9590 | Qt also tries to speed up painting by merging multiple paint events into | - | ||||||||||||||||||||||||||||||||||||
9591 | one. When update() is called several times or the window system sends | - | ||||||||||||||||||||||||||||||||||||
9592 | several paint events, Qt merges these events into one event with a larger | - | ||||||||||||||||||||||||||||||||||||
9593 | region (see QRegion::united()). The repaint() function does not permit this | - | ||||||||||||||||||||||||||||||||||||
9594 | optimization, so we suggest using update() whenever possible. | - | ||||||||||||||||||||||||||||||||||||
9595 | - | |||||||||||||||||||||||||||||||||||||
9596 | When the paint event occurs, the update region has normally been erased, so | - | ||||||||||||||||||||||||||||||||||||
9597 | you are painting on the widget's background. | - | ||||||||||||||||||||||||||||||||||||
9598 | - | |||||||||||||||||||||||||||||||||||||
9599 | The background can be set using setBackgroundRole() and setPalette(). | - | ||||||||||||||||||||||||||||||||||||
9600 | - | |||||||||||||||||||||||||||||||||||||
9601 | Since Qt 4.0, QWidget automatically double-buffers its painting, so there | - | ||||||||||||||||||||||||||||||||||||
9602 | is no need to write double-buffering code in paintEvent() to avoid flicker. | - | ||||||||||||||||||||||||||||||||||||
9603 | - | |||||||||||||||||||||||||||||||||||||
9604 | \note Generally, you should refrain from calling update() or repaint() | - | ||||||||||||||||||||||||||||||||||||
9605 | \b{inside} a paintEvent(). For example, calling update() or repaint() on | - | ||||||||||||||||||||||||||||||||||||
9606 | children inside a paintevent() results in undefined behavior; the child may | - | ||||||||||||||||||||||||||||||||||||
9607 | or may not get a paint event. | - | ||||||||||||||||||||||||||||||||||||
9608 | - | |||||||||||||||||||||||||||||||||||||
9609 | \warning If you are using a custom paint engine without Qt's backingstore, | - | ||||||||||||||||||||||||||||||||||||
9610 | Qt::WA_PaintOnScreen must be set. Otherwise, QWidget::paintEngine() will | - | ||||||||||||||||||||||||||||||||||||
9611 | never be called; the backingstore will be used instead. | - | ||||||||||||||||||||||||||||||||||||
9612 | - | |||||||||||||||||||||||||||||||||||||
9613 | \sa event(), repaint(), update(), QPainter, QPixmap, QPaintEvent, | - | ||||||||||||||||||||||||||||||||||||
9614 | {Analog Clock Example} | - | ||||||||||||||||||||||||||||||||||||
9615 | */ | - | ||||||||||||||||||||||||||||||||||||
9616 | - | |||||||||||||||||||||||||||||||||||||
9617 | void QWidget::paintEvent(QPaintEvent *) | - | ||||||||||||||||||||||||||||||||||||
9618 | { | - | ||||||||||||||||||||||||||||||||||||
9619 | } | - | ||||||||||||||||||||||||||||||||||||
9620 | - | |||||||||||||||||||||||||||||||||||||
9621 | - | |||||||||||||||||||||||||||||||||||||
9622 | /*! | - | ||||||||||||||||||||||||||||||||||||
9623 | \fn void QWidget::moveEvent(QMoveEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9624 | - | |||||||||||||||||||||||||||||||||||||
9625 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9626 | widget move events which are passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9627 | When the widget receives this event, it is already at the new | - | ||||||||||||||||||||||||||||||||||||
9628 | position. | - | ||||||||||||||||||||||||||||||||||||
9629 | - | |||||||||||||||||||||||||||||||||||||
9630 | The old position is accessible through QMoveEvent::oldPos(). | - | ||||||||||||||||||||||||||||||||||||
9631 | - | |||||||||||||||||||||||||||||||||||||
9632 | \sa resizeEvent(), event(), move(), QMoveEvent | - | ||||||||||||||||||||||||||||||||||||
9633 | */ | - | ||||||||||||||||||||||||||||||||||||
9634 | - | |||||||||||||||||||||||||||||||||||||
9635 | void QWidget::moveEvent(QMoveEvent *) | - | ||||||||||||||||||||||||||||||||||||
9636 | { | - | ||||||||||||||||||||||||||||||||||||
9637 | } | - | ||||||||||||||||||||||||||||||||||||
9638 | - | |||||||||||||||||||||||||||||||||||||
9639 | - | |||||||||||||||||||||||||||||||||||||
9640 | /*! | - | ||||||||||||||||||||||||||||||||||||
9641 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9642 | widget resize events which are passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9643 | When resizeEvent() is called, the widget already has its new | - | ||||||||||||||||||||||||||||||||||||
9644 | geometry. The old size is accessible through | - | ||||||||||||||||||||||||||||||||||||
9645 | QResizeEvent::oldSize(). | - | ||||||||||||||||||||||||||||||||||||
9646 | - | |||||||||||||||||||||||||||||||||||||
9647 | The widget will be erased and receive a paint event immediately | - | ||||||||||||||||||||||||||||||||||||
9648 | after processing the resize event. No drawing need be (or should | - | ||||||||||||||||||||||||||||||||||||
9649 | be) done inside this handler. | - | ||||||||||||||||||||||||||||||||||||
9650 | - | |||||||||||||||||||||||||||||||||||||
9651 | - | |||||||||||||||||||||||||||||||||||||
9652 | \sa moveEvent(), event(), resize(), QResizeEvent, paintEvent(), | - | ||||||||||||||||||||||||||||||||||||
9653 | {Scribble Example} | - | ||||||||||||||||||||||||||||||||||||
9654 | */ | - | ||||||||||||||||||||||||||||||||||||
9655 | - | |||||||||||||||||||||||||||||||||||||
9656 | void QWidget::resizeEvent(QResizeEvent * /* event */) | - | ||||||||||||||||||||||||||||||||||||
9657 | { | - | ||||||||||||||||||||||||||||||||||||
9658 | } | - | ||||||||||||||||||||||||||||||||||||
9659 | - | |||||||||||||||||||||||||||||||||||||
9660 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||||||||||||||
9661 | /*! | - | ||||||||||||||||||||||||||||||||||||
9662 | \fn void QWidget::actionEvent(QActionEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9663 | - | |||||||||||||||||||||||||||||||||||||
9664 | This event handler is called with the given \a event whenever the | - | ||||||||||||||||||||||||||||||||||||
9665 | widget's actions are changed. | - | ||||||||||||||||||||||||||||||||||||
9666 | - | |||||||||||||||||||||||||||||||||||||
9667 | \sa addAction(), insertAction(), removeAction(), actions(), QActionEvent | - | ||||||||||||||||||||||||||||||||||||
9668 | */ | - | ||||||||||||||||||||||||||||||||||||
9669 | void QWidget::actionEvent(QActionEvent *) | - | ||||||||||||||||||||||||||||||||||||
9670 | { | - | ||||||||||||||||||||||||||||||||||||
9671 | - | |||||||||||||||||||||||||||||||||||||
9672 | } | - | ||||||||||||||||||||||||||||||||||||
9673 | #endif | - | ||||||||||||||||||||||||||||||||||||
9674 | - | |||||||||||||||||||||||||||||||||||||
9675 | /*! | - | ||||||||||||||||||||||||||||||||||||
9676 | This event handler is called with the given \a event when Qt receives a window | - | ||||||||||||||||||||||||||||||||||||
9677 | close request for a top-level widget from the window system. | - | ||||||||||||||||||||||||||||||||||||
9678 | - | |||||||||||||||||||||||||||||||||||||
9679 | By default, the event is accepted and the widget is closed. You can reimplement | - | ||||||||||||||||||||||||||||||||||||
9680 | this function to change the way the widget responds to window close requests. | - | ||||||||||||||||||||||||||||||||||||
9681 | For example, you can prevent the window from closing by calling \l{QEvent::}{ignore()} | - | ||||||||||||||||||||||||||||||||||||
9682 | on all events. | - | ||||||||||||||||||||||||||||||||||||
9683 | - | |||||||||||||||||||||||||||||||||||||
9684 | Main window applications typically use reimplementations of this function to check | - | ||||||||||||||||||||||||||||||||||||
9685 | whether the user's work has been saved and ask for permission before closing. | - | ||||||||||||||||||||||||||||||||||||
9686 | For example, the \l{Application Example} uses a helper function to determine whether | - | ||||||||||||||||||||||||||||||||||||
9687 | or not to close the window: | - | ||||||||||||||||||||||||||||||||||||
9688 | - | |||||||||||||||||||||||||||||||||||||
9689 | \snippet mainwindows/application/mainwindow.cpp 3 | - | ||||||||||||||||||||||||||||||||||||
9690 | \snippet mainwindows/application/mainwindow.cpp 4 | - | ||||||||||||||||||||||||||||||||||||
9691 | - | |||||||||||||||||||||||||||||||||||||
9692 | \sa event(), hide(), close(), QCloseEvent, {Application Example} | - | ||||||||||||||||||||||||||||||||||||
9693 | */ | - | ||||||||||||||||||||||||||||||||||||
9694 | - | |||||||||||||||||||||||||||||||||||||
9695 | void QWidget::closeEvent(QCloseEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9696 | { | - | ||||||||||||||||||||||||||||||||||||
9697 | event->accept(); | - | ||||||||||||||||||||||||||||||||||||
9698 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9699 | - | |||||||||||||||||||||||||||||||||||||
9700 | #ifndef QT_NO_CONTEXTMENU | - | ||||||||||||||||||||||||||||||||||||
9701 | /*! | - | ||||||||||||||||||||||||||||||||||||
9702 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9703 | subclass to receive widget context menu events. | - | ||||||||||||||||||||||||||||||||||||
9704 | - | |||||||||||||||||||||||||||||||||||||
9705 | The handler is called when the widget's \l contextMenuPolicy is | - | ||||||||||||||||||||||||||||||||||||
9706 | Qt::DefaultContextMenu. | - | ||||||||||||||||||||||||||||||||||||
9707 | - | |||||||||||||||||||||||||||||||||||||
9708 | The default implementation ignores the context event. | - | ||||||||||||||||||||||||||||||||||||
9709 | See the \l QContextMenuEvent documentation for more details. | - | ||||||||||||||||||||||||||||||||||||
9710 | - | |||||||||||||||||||||||||||||||||||||
9711 | \sa event(), QContextMenuEvent, customContextMenuRequested() | - | ||||||||||||||||||||||||||||||||||||
9712 | */ | - | ||||||||||||||||||||||||||||||||||||
9713 | - | |||||||||||||||||||||||||||||||||||||
9714 | void QWidget::contextMenuEvent(QContextMenuEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9715 | { | - | ||||||||||||||||||||||||||||||||||||
9716 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9717 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9718 | #endif // QT_NO_CONTEXTMENU | - | ||||||||||||||||||||||||||||||||||||
9719 | - | |||||||||||||||||||||||||||||||||||||
9720 | - | |||||||||||||||||||||||||||||||||||||
9721 | /*! | - | ||||||||||||||||||||||||||||||||||||
9722 | This event handler, for event \a event, can be reimplemented in a | - | ||||||||||||||||||||||||||||||||||||
9723 | subclass to receive Input Method composition events. This handler | - | ||||||||||||||||||||||||||||||||||||
9724 | is called when the state of the input method changes. | - | ||||||||||||||||||||||||||||||||||||
9725 | - | |||||||||||||||||||||||||||||||||||||
9726 | Note that when creating custom text editing widgets, the | - | ||||||||||||||||||||||||||||||||||||
9727 | Qt::WA_InputMethodEnabled window attribute must be set explicitly | - | ||||||||||||||||||||||||||||||||||||
9728 | (using the setAttribute() function) in order to receive input | - | ||||||||||||||||||||||||||||||||||||
9729 | method events. | - | ||||||||||||||||||||||||||||||||||||
9730 | - | |||||||||||||||||||||||||||||||||||||
9731 | The default implementation calls event->ignore(), which rejects the | - | ||||||||||||||||||||||||||||||||||||
9732 | Input Method event. See the \l QInputMethodEvent documentation for more | - | ||||||||||||||||||||||||||||||||||||
9733 | details. | - | ||||||||||||||||||||||||||||||||||||
9734 | - | |||||||||||||||||||||||||||||||||||||
9735 | \sa event(), QInputMethodEvent | - | ||||||||||||||||||||||||||||||||||||
9736 | */ | - | ||||||||||||||||||||||||||||||||||||
9737 | void QWidget::inputMethodEvent(QInputMethodEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9738 | { | - | ||||||||||||||||||||||||||||||||||||
9739 | event->ignore(); | - | ||||||||||||||||||||||||||||||||||||
9740 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9741 | - | |||||||||||||||||||||||||||||||||||||
9742 | /*! | - | ||||||||||||||||||||||||||||||||||||
9743 | This method is only relevant for input widgets. It is used by the | - | ||||||||||||||||||||||||||||||||||||
9744 | input method to query a set of properties of the widget to be | - | ||||||||||||||||||||||||||||||||||||
9745 | able to support complex input method operations as support for | - | ||||||||||||||||||||||||||||||||||||
9746 | surrounding text and reconversions. | - | ||||||||||||||||||||||||||||||||||||
9747 | - | |||||||||||||||||||||||||||||||||||||
9748 | \a query specifies which property is queried. | - | ||||||||||||||||||||||||||||||||||||
9749 | - | |||||||||||||||||||||||||||||||||||||
9750 | \sa inputMethodEvent(), QInputMethodEvent, QInputMethodQueryEvent, inputMethodHints | - | ||||||||||||||||||||||||||||||||||||
9751 | */ | - | ||||||||||||||||||||||||||||||||||||
9752 | QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const | - | ||||||||||||||||||||||||||||||||||||
9753 | { | - | ||||||||||||||||||||||||||||||||||||
9754 | switch(query) { | - | ||||||||||||||||||||||||||||||||||||
9755 | case Qt::ImCursorRectangle: never executed: case Qt::ImCursorRectangle: | 0 | ||||||||||||||||||||||||||||||||||||
9756 | return QRect(width()/2, 0, 1, height()); never executed: return QRect(width()/2, 0, 1, height()); | 0 | ||||||||||||||||||||||||||||||||||||
9757 | case Qt::ImFont: never executed: case Qt::ImFont: | 0 | ||||||||||||||||||||||||||||||||||||
9758 | return font(); never executed: return font(); | 0 | ||||||||||||||||||||||||||||||||||||
9759 | case Qt::ImAnchorPosition: never executed: case Qt::ImAnchorPosition: | 0 | ||||||||||||||||||||||||||||||||||||
9760 | // Fallback. | - | ||||||||||||||||||||||||||||||||||||
9761 | return inputMethodQuery(Qt::ImCursorPosition); never executed: return inputMethodQuery(Qt::ImCursorPosition); | 0 | ||||||||||||||||||||||||||||||||||||
9762 | case Qt::ImHints: never executed: case Qt::ImHints: | 0 | ||||||||||||||||||||||||||||||||||||
9763 | return (int)inputMethodHints(); never executed: return (int)inputMethodHints(); | 0 | ||||||||||||||||||||||||||||||||||||
9764 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
9765 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||||||||||||||||||||
9766 | } | - | ||||||||||||||||||||||||||||||||||||
9767 | } | - | ||||||||||||||||||||||||||||||||||||
9768 | - | |||||||||||||||||||||||||||||||||||||
9769 | /*! | - | ||||||||||||||||||||||||||||||||||||
9770 | \property QWidget::inputMethodHints | - | ||||||||||||||||||||||||||||||||||||
9771 | \brief What input method specific hints the widget has. | - | ||||||||||||||||||||||||||||||||||||
9772 | - | |||||||||||||||||||||||||||||||||||||
9773 | This is only relevant for input widgets. It is used by | - | ||||||||||||||||||||||||||||||||||||
9774 | the input method to retrieve hints as to how the input method | - | ||||||||||||||||||||||||||||||||||||
9775 | should operate. For example, if the Qt::ImhFormattedNumbersOnly flag | - | ||||||||||||||||||||||||||||||||||||
9776 | is set, the input method may change its visual components to reflect | - | ||||||||||||||||||||||||||||||||||||
9777 | that only numbers can be entered. | - | ||||||||||||||||||||||||||||||||||||
9778 | - | |||||||||||||||||||||||||||||||||||||
9779 | \warning Some widgets require certain flags in order to work as | - | ||||||||||||||||||||||||||||||||||||
9780 | intended. To set a flag, do \c{w->setInputMethodHints(w->inputMethodHints()|f)} | - | ||||||||||||||||||||||||||||||||||||
9781 | instead of \c{w->setInputMethodHints(f)}. | - | ||||||||||||||||||||||||||||||||||||
9782 | - | |||||||||||||||||||||||||||||||||||||
9783 | \note The flags are only hints, so the particular input method | - | ||||||||||||||||||||||||||||||||||||
9784 | implementation is free to ignore them. If you want to be | - | ||||||||||||||||||||||||||||||||||||
9785 | sure that a certain type of characters are entered, | - | ||||||||||||||||||||||||||||||||||||
9786 | you should also set a QValidator on the widget. | - | ||||||||||||||||||||||||||||||||||||
9787 | - | |||||||||||||||||||||||||||||||||||||
9788 | The default value is Qt::ImhNone. | - | ||||||||||||||||||||||||||||||||||||
9789 | - | |||||||||||||||||||||||||||||||||||||
9790 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
9791 | - | |||||||||||||||||||||||||||||||||||||
9792 | \sa inputMethodQuery() | - | ||||||||||||||||||||||||||||||||||||
9793 | */ | - | ||||||||||||||||||||||||||||||||||||
9794 | Qt::InputMethodHints QWidget::inputMethodHints() const | - | ||||||||||||||||||||||||||||||||||||
9795 | { | - | ||||||||||||||||||||||||||||||||||||
9796 | #ifndef QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
9797 | const QWidgetPrivate *priv = d_func(); | - | ||||||||||||||||||||||||||||||||||||
9798 | while (priv->inheritsInputMethodHints) {
| 0 | ||||||||||||||||||||||||||||||||||||
9799 | priv = priv->q_func()->parentWidget()->d_func(); | - | ||||||||||||||||||||||||||||||||||||
9800 | Q_ASSERT(priv); | - | ||||||||||||||||||||||||||||||||||||
9801 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9802 | return priv->imHints; never executed: return priv->imHints; | 0 | ||||||||||||||||||||||||||||||||||||
9803 | #else //QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
9804 | return 0; | - | ||||||||||||||||||||||||||||||||||||
9805 | #endif //QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
9806 | } | - | ||||||||||||||||||||||||||||||||||||
9807 | - | |||||||||||||||||||||||||||||||||||||
9808 | void QWidget::setInputMethodHints(Qt::InputMethodHints hints) | - | ||||||||||||||||||||||||||||||||||||
9809 | { | - | ||||||||||||||||||||||||||||||||||||
9810 | #ifndef QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
9811 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
9812 | if (d->imHints == hints)
| 0 | ||||||||||||||||||||||||||||||||||||
9813 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
9814 | d->imHints = hints; | - | ||||||||||||||||||||||||||||||||||||
9815 | if (this == QGuiApplication::focusObject())
| 0 | ||||||||||||||||||||||||||||||||||||
9816 | QGuiApplication::inputMethod()->update(Qt::ImHints); never executed: QGuiApplication::inputMethod()->update(Qt::ImHints); | 0 | ||||||||||||||||||||||||||||||||||||
9817 | #else | - | ||||||||||||||||||||||||||||||||||||
9818 | Q_UNUSED(hints); | - | ||||||||||||||||||||||||||||||||||||
9819 | #endif //QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
9820 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
9821 | - | |||||||||||||||||||||||||||||||||||||
9822 | - | |||||||||||||||||||||||||||||||||||||
9823 | #ifndef QT_NO_DRAGANDDROP | - | ||||||||||||||||||||||||||||||||||||
9824 | - | |||||||||||||||||||||||||||||||||||||
9825 | /*! | - | ||||||||||||||||||||||||||||||||||||
9826 | \fn void QWidget::dragEnterEvent(QDragEnterEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9827 | - | |||||||||||||||||||||||||||||||||||||
9828 | This event handler is called when a drag is in progress and the | - | ||||||||||||||||||||||||||||||||||||
9829 | mouse enters this widget. The event is passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9830 | - | |||||||||||||||||||||||||||||||||||||
9831 | If the event is ignored, the widget won't receive any \l{dragMoveEvent()}{drag | - | ||||||||||||||||||||||||||||||||||||
9832 | move events}. | - | ||||||||||||||||||||||||||||||||||||
9833 | - | |||||||||||||||||||||||||||||||||||||
9834 | See the \l{dnd.html}{Drag-and-drop documentation} for an | - | ||||||||||||||||||||||||||||||||||||
9835 | overview of how to provide drag-and-drop in your application. | - | ||||||||||||||||||||||||||||||||||||
9836 | - | |||||||||||||||||||||||||||||||||||||
9837 | \sa QDrag, QDragEnterEvent | - | ||||||||||||||||||||||||||||||||||||
9838 | */ | - | ||||||||||||||||||||||||||||||||||||
9839 | void QWidget::dragEnterEvent(QDragEnterEvent *) | - | ||||||||||||||||||||||||||||||||||||
9840 | { | - | ||||||||||||||||||||||||||||||||||||
9841 | } | - | ||||||||||||||||||||||||||||||||||||
9842 | - | |||||||||||||||||||||||||||||||||||||
9843 | /*! | - | ||||||||||||||||||||||||||||||||||||
9844 | \fn void QWidget::dragMoveEvent(QDragMoveEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9845 | - | |||||||||||||||||||||||||||||||||||||
9846 | This event handler is called if a drag is in progress, and when | - | ||||||||||||||||||||||||||||||||||||
9847 | any of the following conditions occur: the cursor enters this widget, | - | ||||||||||||||||||||||||||||||||||||
9848 | the cursor moves within this widget, or a modifier key is pressed on | - | ||||||||||||||||||||||||||||||||||||
9849 | the keyboard while this widget has the focus. The event is passed | - | ||||||||||||||||||||||||||||||||||||
9850 | in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9851 | - | |||||||||||||||||||||||||||||||||||||
9852 | See the \l{dnd.html}{Drag-and-drop documentation} for an | - | ||||||||||||||||||||||||||||||||||||
9853 | overview of how to provide drag-and-drop in your application. | - | ||||||||||||||||||||||||||||||||||||
9854 | - | |||||||||||||||||||||||||||||||||||||
9855 | \sa QDrag, QDragMoveEvent | - | ||||||||||||||||||||||||||||||||||||
9856 | */ | - | ||||||||||||||||||||||||||||||||||||
9857 | void QWidget::dragMoveEvent(QDragMoveEvent *) | - | ||||||||||||||||||||||||||||||||||||
9858 | { | - | ||||||||||||||||||||||||||||||||||||
9859 | } | - | ||||||||||||||||||||||||||||||||||||
9860 | - | |||||||||||||||||||||||||||||||||||||
9861 | /*! | - | ||||||||||||||||||||||||||||||||||||
9862 | \fn void QWidget::dragLeaveEvent(QDragLeaveEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9863 | - | |||||||||||||||||||||||||||||||||||||
9864 | This event handler is called when a drag is in progress and the | - | ||||||||||||||||||||||||||||||||||||
9865 | mouse leaves this widget. The event is passed in the \a event | - | ||||||||||||||||||||||||||||||||||||
9866 | parameter. | - | ||||||||||||||||||||||||||||||||||||
9867 | - | |||||||||||||||||||||||||||||||||||||
9868 | See the \l{dnd.html}{Drag-and-drop documentation} for an | - | ||||||||||||||||||||||||||||||||||||
9869 | overview of how to provide drag-and-drop in your application. | - | ||||||||||||||||||||||||||||||||||||
9870 | - | |||||||||||||||||||||||||||||||||||||
9871 | \sa QDrag, QDragLeaveEvent | - | ||||||||||||||||||||||||||||||||||||
9872 | */ | - | ||||||||||||||||||||||||||||||||||||
9873 | void QWidget::dragLeaveEvent(QDragLeaveEvent *) | - | ||||||||||||||||||||||||||||||||||||
9874 | { | - | ||||||||||||||||||||||||||||||||||||
9875 | } | - | ||||||||||||||||||||||||||||||||||||
9876 | - | |||||||||||||||||||||||||||||||||||||
9877 | /*! | - | ||||||||||||||||||||||||||||||||||||
9878 | \fn void QWidget::dropEvent(QDropEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9879 | - | |||||||||||||||||||||||||||||||||||||
9880 | This event handler is called when the drag is dropped on this | - | ||||||||||||||||||||||||||||||||||||
9881 | widget. The event is passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9882 | - | |||||||||||||||||||||||||||||||||||||
9883 | See the \l{dnd.html}{Drag-and-drop documentation} for an | - | ||||||||||||||||||||||||||||||||||||
9884 | overview of how to provide drag-and-drop in your application. | - | ||||||||||||||||||||||||||||||||||||
9885 | - | |||||||||||||||||||||||||||||||||||||
9886 | \sa QDrag, QDropEvent | - | ||||||||||||||||||||||||||||||||||||
9887 | */ | - | ||||||||||||||||||||||||||||||||||||
9888 | void QWidget::dropEvent(QDropEvent *) | - | ||||||||||||||||||||||||||||||||||||
9889 | { | - | ||||||||||||||||||||||||||||||||||||
9890 | } | - | ||||||||||||||||||||||||||||||||||||
9891 | - | |||||||||||||||||||||||||||||||||||||
9892 | #endif // QT_NO_DRAGANDDROP | - | ||||||||||||||||||||||||||||||||||||
9893 | - | |||||||||||||||||||||||||||||||||||||
9894 | /*! | - | ||||||||||||||||||||||||||||||||||||
9895 | \fn void QWidget::showEvent(QShowEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9896 | - | |||||||||||||||||||||||||||||||||||||
9897 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9898 | widget show events which are passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9899 | - | |||||||||||||||||||||||||||||||||||||
9900 | Non-spontaneous show events are sent to widgets immediately | - | ||||||||||||||||||||||||||||||||||||
9901 | before they are shown. The spontaneous show events of windows are | - | ||||||||||||||||||||||||||||||||||||
9902 | delivered afterwards. | - | ||||||||||||||||||||||||||||||||||||
9903 | - | |||||||||||||||||||||||||||||||||||||
9904 | Note: A widget receives spontaneous show and hide events when its | - | ||||||||||||||||||||||||||||||||||||
9905 | mapping status is changed by the window system, e.g. a spontaneous | - | ||||||||||||||||||||||||||||||||||||
9906 | hide event when the user minimizes the window, and a spontaneous | - | ||||||||||||||||||||||||||||||||||||
9907 | show event when the window is restored again. After receiving a | - | ||||||||||||||||||||||||||||||||||||
9908 | spontaneous hide event, a widget is still considered visible in | - | ||||||||||||||||||||||||||||||||||||
9909 | the sense of isVisible(). | - | ||||||||||||||||||||||||||||||||||||
9910 | - | |||||||||||||||||||||||||||||||||||||
9911 | \sa visible, event(), QShowEvent | - | ||||||||||||||||||||||||||||||||||||
9912 | */ | - | ||||||||||||||||||||||||||||||||||||
9913 | void QWidget::showEvent(QShowEvent *) | - | ||||||||||||||||||||||||||||||||||||
9914 | { | - | ||||||||||||||||||||||||||||||||||||
9915 | } | - | ||||||||||||||||||||||||||||||||||||
9916 | - | |||||||||||||||||||||||||||||||||||||
9917 | /*! | - | ||||||||||||||||||||||||||||||||||||
9918 | \fn void QWidget::hideEvent(QHideEvent *event) | - | ||||||||||||||||||||||||||||||||||||
9919 | - | |||||||||||||||||||||||||||||||||||||
9920 | This event handler can be reimplemented in a subclass to receive | - | ||||||||||||||||||||||||||||||||||||
9921 | widget hide events. The event is passed in the \a event parameter. | - | ||||||||||||||||||||||||||||||||||||
9922 | - | |||||||||||||||||||||||||||||||||||||
9923 | Hide events are sent to widgets immediately after they have been | - | ||||||||||||||||||||||||||||||||||||
9924 | hidden. | - | ||||||||||||||||||||||||||||||||||||
9925 | - | |||||||||||||||||||||||||||||||||||||
9926 | Note: A widget receives spontaneous show and hide events when its | - | ||||||||||||||||||||||||||||||||||||
9927 | mapping status is changed by the window system, e.g. a spontaneous | - | ||||||||||||||||||||||||||||||||||||
9928 | hide event when the user minimizes the window, and a spontaneous | - | ||||||||||||||||||||||||||||||||||||
9929 | show event when the window is restored again. After receiving a | - | ||||||||||||||||||||||||||||||||||||
9930 | spontaneous hide event, a widget is still considered visible in | - | ||||||||||||||||||||||||||||||||||||
9931 | the sense of isVisible(). | - | ||||||||||||||||||||||||||||||||||||
9932 | - | |||||||||||||||||||||||||||||||||||||
9933 | \sa visible, event(), QHideEvent | - | ||||||||||||||||||||||||||||||||||||
9934 | */ | - | ||||||||||||||||||||||||||||||||||||
9935 | void QWidget::hideEvent(QHideEvent *) | - | ||||||||||||||||||||||||||||||||||||
9936 | { | - | ||||||||||||||||||||||||||||||||||||
9937 | } | - | ||||||||||||||||||||||||||||||||||||
9938 | - | |||||||||||||||||||||||||||||||||||||
9939 | /*! | - | ||||||||||||||||||||||||||||||||||||
9940 | This special event handler can be reimplemented in a subclass to | - | ||||||||||||||||||||||||||||||||||||
9941 | receive native platform events identified by \a eventType | - | ||||||||||||||||||||||||||||||||||||
9942 | which are passed in the \a message parameter. | - | ||||||||||||||||||||||||||||||||||||
9943 | - | |||||||||||||||||||||||||||||||||||||
9944 | In your reimplementation of this function, if you want to stop the | - | ||||||||||||||||||||||||||||||||||||
9945 | event being handled by Qt, return true and set \a result. | - | ||||||||||||||||||||||||||||||||||||
9946 | If you return false, this native event is passed back to Qt, | - | ||||||||||||||||||||||||||||||||||||
9947 | which translates the event into a Qt event and sends it to the widget. | - | ||||||||||||||||||||||||||||||||||||
9948 | - | |||||||||||||||||||||||||||||||||||||
9949 | \note Events are only delivered to this event handler if the widget is | - | ||||||||||||||||||||||||||||||||||||
9950 | has a native Window handle. | - | ||||||||||||||||||||||||||||||||||||
9951 | - | |||||||||||||||||||||||||||||||||||||
9952 | \note This function superseedes the event filter functions | - | ||||||||||||||||||||||||||||||||||||
9953 | x11Event(), winEvent() and macEvent() of Qt 4. | - | ||||||||||||||||||||||||||||||||||||
9954 | - | |||||||||||||||||||||||||||||||||||||
9955 | \table | - | ||||||||||||||||||||||||||||||||||||
9956 | \header \li Platform \li Event Type Identifier \li Message Type \li Result Type | - | ||||||||||||||||||||||||||||||||||||
9957 | \row \li Windows \li "windows_generic_MSG" \li MSG * \li LRESULT | - | ||||||||||||||||||||||||||||||||||||
9958 | \endtable | - | ||||||||||||||||||||||||||||||||||||
9959 | */ | - | ||||||||||||||||||||||||||||||||||||
9960 | - | |||||||||||||||||||||||||||||||||||||
9961 | bool QWidget::nativeEvent(const QByteArray &eventType, void *message, long *result) | - | ||||||||||||||||||||||||||||||||||||
9962 | { | - | ||||||||||||||||||||||||||||||||||||
9963 | Q_UNUSED(eventType); | - | ||||||||||||||||||||||||||||||||||||
9964 | Q_UNUSED(message); | - | ||||||||||||||||||||||||||||||||||||
9965 | Q_UNUSED(result); | - | ||||||||||||||||||||||||||||||||||||
9966 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||||||||
9967 | } | - | ||||||||||||||||||||||||||||||||||||
9968 | - | |||||||||||||||||||||||||||||||||||||
9969 | /*! | - | ||||||||||||||||||||||||||||||||||||
9970 | Ensures that the widget has been polished by QStyle (i.e., has a | - | ||||||||||||||||||||||||||||||||||||
9971 | proper font and palette). | - | ||||||||||||||||||||||||||||||||||||
9972 | - | |||||||||||||||||||||||||||||||||||||
9973 | QWidget calls this function after it has been fully constructed | - | ||||||||||||||||||||||||||||||||||||
9974 | but before it is shown the very first time. You can call this | - | ||||||||||||||||||||||||||||||||||||
9975 | function if you want to ensure that the widget is polished before | - | ||||||||||||||||||||||||||||||||||||
9976 | doing an operation, e.g., the correct font size might be needed in | - | ||||||||||||||||||||||||||||||||||||
9977 | the widget's sizeHint() reimplementation. Note that this function | - | ||||||||||||||||||||||||||||||||||||
9978 | \e is called from the default implementation of sizeHint(). | - | ||||||||||||||||||||||||||||||||||||
9979 | - | |||||||||||||||||||||||||||||||||||||
9980 | Polishing is useful for final initialization that must happen after | - | ||||||||||||||||||||||||||||||||||||
9981 | all constructors (from base classes as well as from subclasses) | - | ||||||||||||||||||||||||||||||||||||
9982 | have been called. | - | ||||||||||||||||||||||||||||||||||||
9983 | - | |||||||||||||||||||||||||||||||||||||
9984 | If you need to change some settings when a widget is polished, | - | ||||||||||||||||||||||||||||||||||||
9985 | reimplement event() and handle the QEvent::Polish event type. | - | ||||||||||||||||||||||||||||||||||||
9986 | - | |||||||||||||||||||||||||||||||||||||
9987 | \b{Note:} The function is declared const so that it can be called from | - | ||||||||||||||||||||||||||||||||||||
9988 | other const functions (e.g., sizeHint()). | - | ||||||||||||||||||||||||||||||||||||
9989 | - | |||||||||||||||||||||||||||||||||||||
9990 | \sa event() | - | ||||||||||||||||||||||||||||||||||||
9991 | */ | - | ||||||||||||||||||||||||||||||||||||
9992 | void QWidget::ensurePolished() const | - | ||||||||||||||||||||||||||||||||||||
9993 | { | - | ||||||||||||||||||||||||||||||||||||
9994 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
9995 | - | |||||||||||||||||||||||||||||||||||||
9996 | const QMetaObject *m = metaObject(); | - | ||||||||||||||||||||||||||||||||||||
9997 | if (m == d->polished)
| 0 | ||||||||||||||||||||||||||||||||||||
9998 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
9999 | d->polished = m; | - | ||||||||||||||||||||||||||||||||||||
10000 | - | |||||||||||||||||||||||||||||||||||||
10001 | QEvent e(QEvent::Polish); | - | ||||||||||||||||||||||||||||||||||||
10002 | QCoreApplication::sendEvent(const_cast<QWidget *>(this), &e); | - | ||||||||||||||||||||||||||||||||||||
10003 | - | |||||||||||||||||||||||||||||||||||||
10004 | // polish children after 'this' | - | ||||||||||||||||||||||||||||||||||||
10005 | QList<QObject*> children = d->children; | - | ||||||||||||||||||||||||||||||||||||
10006 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
10007 | QObject *o = children.at(i); | - | ||||||||||||||||||||||||||||||||||||
10008 | if(!o->isWidgetType())
| 0 | ||||||||||||||||||||||||||||||||||||
10009 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
10010 | if (QWidget *w = qobject_cast<QWidget *>(o))
| 0 | ||||||||||||||||||||||||||||||||||||
10011 | w->ensurePolished(); never executed: w->ensurePolished(); | 0 | ||||||||||||||||||||||||||||||||||||
10012 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10013 | - | |||||||||||||||||||||||||||||||||||||
10014 | if (d->parent && d->sendChildEvents) {
| 0 | ||||||||||||||||||||||||||||||||||||
10015 | QChildEvent e(QEvent::ChildPolished, const_cast<QWidget *>(this)); | - | ||||||||||||||||||||||||||||||||||||
10016 | QCoreApplication::sendEvent(d->parent, &e); | - | ||||||||||||||||||||||||||||||||||||
10017 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10018 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10019 | - | |||||||||||||||||||||||||||||||||||||
10020 | /*! | - | ||||||||||||||||||||||||||||||||||||
10021 | Returns the mask currently set on a widget. If no mask is set the | - | ||||||||||||||||||||||||||||||||||||
10022 | return value will be an empty region. | - | ||||||||||||||||||||||||||||||||||||
10023 | - | |||||||||||||||||||||||||||||||||||||
10024 | \sa setMask(), clearMask(), QRegion::isEmpty(), {Shaped Clock Example} | - | ||||||||||||||||||||||||||||||||||||
10025 | */ | - | ||||||||||||||||||||||||||||||||||||
10026 | QRegion QWidget::mask() const | - | ||||||||||||||||||||||||||||||||||||
10027 | { | - | ||||||||||||||||||||||||||||||||||||
10028 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
10029 | return d->extra ? d->extra->mask : QRegion(); never executed: return d->extra ? d->extra->mask : QRegion();
| 0 | ||||||||||||||||||||||||||||||||||||
10030 | } | - | ||||||||||||||||||||||||||||||||||||
10031 | - | |||||||||||||||||||||||||||||||||||||
10032 | /*! | - | ||||||||||||||||||||||||||||||||||||
10033 | Returns the layout manager that is installed on this widget, or 0 | - | ||||||||||||||||||||||||||||||||||||
10034 | if no layout manager is installed. | - | ||||||||||||||||||||||||||||||||||||
10035 | - | |||||||||||||||||||||||||||||||||||||
10036 | The layout manager sets the geometry of the widget's children | - | ||||||||||||||||||||||||||||||||||||
10037 | that have been added to the layout. | - | ||||||||||||||||||||||||||||||||||||
10038 | - | |||||||||||||||||||||||||||||||||||||
10039 | \sa setLayout(), sizePolicy(), {Layout Management} | - | ||||||||||||||||||||||||||||||||||||
10040 | */ | - | ||||||||||||||||||||||||||||||||||||
10041 | QLayout *QWidget::layout() const | - | ||||||||||||||||||||||||||||||||||||
10042 | { | - | ||||||||||||||||||||||||||||||||||||
10043 | return d_func()->layout; never executed: return d_func()->layout; | 0 | ||||||||||||||||||||||||||||||||||||
10044 | } | - | ||||||||||||||||||||||||||||||||||||
10045 | - | |||||||||||||||||||||||||||||||||||||
10046 | - | |||||||||||||||||||||||||||||||||||||
10047 | /*! | - | ||||||||||||||||||||||||||||||||||||
10048 | \fn void QWidget::setLayout(QLayout *layout) | - | ||||||||||||||||||||||||||||||||||||
10049 | - | |||||||||||||||||||||||||||||||||||||
10050 | Sets the layout manager for this widget to \a layout. | - | ||||||||||||||||||||||||||||||||||||
10051 | - | |||||||||||||||||||||||||||||||||||||
10052 | If there already is a layout manager installed on this widget, | - | ||||||||||||||||||||||||||||||||||||
10053 | QWidget won't let you install another. You must first delete the | - | ||||||||||||||||||||||||||||||||||||
10054 | existing layout manager (returned by layout()) before you can | - | ||||||||||||||||||||||||||||||||||||
10055 | call setLayout() with the new layout. | - | ||||||||||||||||||||||||||||||||||||
10056 | - | |||||||||||||||||||||||||||||||||||||
10057 | If \a layout is the layout manager on a different widget, setLayout() | - | ||||||||||||||||||||||||||||||||||||
10058 | will reparent the layout and make it the layout manager for this widget. | - | ||||||||||||||||||||||||||||||||||||
10059 | - | |||||||||||||||||||||||||||||||||||||
10060 | Example: | - | ||||||||||||||||||||||||||||||||||||
10061 | - | |||||||||||||||||||||||||||||||||||||
10062 | \snippet layouts/layouts.cpp 24 | - | ||||||||||||||||||||||||||||||||||||
10063 | - | |||||||||||||||||||||||||||||||||||||
10064 | An alternative to calling this function is to pass this widget to | - | ||||||||||||||||||||||||||||||||||||
10065 | the layout's constructor. | - | ||||||||||||||||||||||||||||||||||||
10066 | - | |||||||||||||||||||||||||||||||||||||
10067 | The QWidget will take ownership of \a layout. | - | ||||||||||||||||||||||||||||||||||||
10068 | - | |||||||||||||||||||||||||||||||||||||
10069 | \sa layout(), {Layout Management} | - | ||||||||||||||||||||||||||||||||||||
10070 | */ | - | ||||||||||||||||||||||||||||||||||||
10071 | - | |||||||||||||||||||||||||||||||||||||
10072 | void QWidget::setLayout(QLayout *l) | - | ||||||||||||||||||||||||||||||||||||
10073 | { | - | ||||||||||||||||||||||||||||||||||||
10074 | if (!l) {
| 0 | ||||||||||||||||||||||||||||||||||||
10075 | qWarning("QWidget::setLayout: Cannot set layout to 0"); | - | ||||||||||||||||||||||||||||||||||||
10076 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10077 | } | - | ||||||||||||||||||||||||||||||||||||
10078 | if (layout()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10079 | if (layout() != l)
| 0 | ||||||||||||||||||||||||||||||||||||
10080 | qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a" never executed: QMessageLogger(__FILE__, 10080, __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 | ||||||||||||||||||||||||||||||||||||
10081 | " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(), never executed: QMessageLogger(__FILE__, 10080, __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 | ||||||||||||||||||||||||||||||||||||
10082 | objectName().toLocal8Bit().data()); never executed: QMessageLogger(__FILE__, 10080, __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 | ||||||||||||||||||||||||||||||||||||
10083 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10084 | } | - | ||||||||||||||||||||||||||||||||||||
10085 | - | |||||||||||||||||||||||||||||||||||||
10086 | QObject *oldParent = l->parent(); | - | ||||||||||||||||||||||||||||||||||||
10087 | if (oldParent && oldParent != this) {
| 0 | ||||||||||||||||||||||||||||||||||||
10088 | if (oldParent->isWidgetType()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10089 | // Steal the layout off a widget parent. Takes effect when | - | ||||||||||||||||||||||||||||||||||||
10090 | // morphing laid-out container widgets in Designer. | - | ||||||||||||||||||||||||||||||||||||
10091 | QWidget *oldParentWidget = static_cast<QWidget *>(oldParent); | - | ||||||||||||||||||||||||||||||||||||
10092 | oldParentWidget->takeLayout(); | - | ||||||||||||||||||||||||||||||||||||
10093 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10094 | qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent", | - | ||||||||||||||||||||||||||||||||||||
10095 | l->objectName().toLocal8Bit().data(), metaObject()->className(), | - | ||||||||||||||||||||||||||||||||||||
10096 | objectName().toLocal8Bit().data()); | - | ||||||||||||||||||||||||||||||||||||
10097 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10098 | } | - | ||||||||||||||||||||||||||||||||||||
10099 | } | - | ||||||||||||||||||||||||||||||||||||
10100 | - | |||||||||||||||||||||||||||||||||||||
10101 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10102 | l->d_func()->topLevel = true; | - | ||||||||||||||||||||||||||||||||||||
10103 | d->layout = l; | - | ||||||||||||||||||||||||||||||||||||
10104 | if (oldParent != this) {
| 0 | ||||||||||||||||||||||||||||||||||||
10105 | l->setParent(this); | - | ||||||||||||||||||||||||||||||||||||
10106 | l->d_func()->reparentChildWidgets(this); | - | ||||||||||||||||||||||||||||||||||||
10107 | l->invalidate(); | - | ||||||||||||||||||||||||||||||||||||
10108 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10109 | - | |||||||||||||||||||||||||||||||||||||
10110 | if (isWindow() && d->maybeTopData())
| 0 | ||||||||||||||||||||||||||||||||||||
10111 | d->topData()->sizeAdjusted = false; never executed: d->topData()->sizeAdjusted = false; | 0 | ||||||||||||||||||||||||||||||||||||
10112 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10113 | - | |||||||||||||||||||||||||||||||||||||
10114 | /*! | - | ||||||||||||||||||||||||||||||||||||
10115 | \fn QLayout *QWidget::takeLayout() | - | ||||||||||||||||||||||||||||||||||||
10116 | - | |||||||||||||||||||||||||||||||||||||
10117 | Remove the layout from the widget. | - | ||||||||||||||||||||||||||||||||||||
10118 | \since 4.5 | - | ||||||||||||||||||||||||||||||||||||
10119 | */ | - | ||||||||||||||||||||||||||||||||||||
10120 | - | |||||||||||||||||||||||||||||||||||||
10121 | QLayout *QWidget::takeLayout() | - | ||||||||||||||||||||||||||||||||||||
10122 | { | - | ||||||||||||||||||||||||||||||||||||
10123 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10124 | QLayout *l = layout(); | - | ||||||||||||||||||||||||||||||||||||
10125 | if (!l)
| 0 | ||||||||||||||||||||||||||||||||||||
10126 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
10127 | d->layout = 0; | - | ||||||||||||||||||||||||||||||||||||
10128 | l->setParent(0); | - | ||||||||||||||||||||||||||||||||||||
10129 | return l; never executed: return l; | 0 | ||||||||||||||||||||||||||||||||||||
10130 | } | - | ||||||||||||||||||||||||||||||||||||
10131 | - | |||||||||||||||||||||||||||||||||||||
10132 | /*! | - | ||||||||||||||||||||||||||||||||||||
10133 | \property QWidget::sizePolicy | - | ||||||||||||||||||||||||||||||||||||
10134 | \brief the default layout behavior of the widget | - | ||||||||||||||||||||||||||||||||||||
10135 | - | |||||||||||||||||||||||||||||||||||||
10136 | If there is a QLayout that manages this widget's children, the | - | ||||||||||||||||||||||||||||||||||||
10137 | size policy specified by that layout is used. If there is no such | - | ||||||||||||||||||||||||||||||||||||
10138 | QLayout, the result of this function is used. | - | ||||||||||||||||||||||||||||||||||||
10139 | - | |||||||||||||||||||||||||||||||||||||
10140 | The default policy is Preferred/Preferred, which means that the | - | ||||||||||||||||||||||||||||||||||||
10141 | widget can be freely resized, but prefers to be the size | - | ||||||||||||||||||||||||||||||||||||
10142 | sizeHint() returns. Button-like widgets set the size policy to | - | ||||||||||||||||||||||||||||||||||||
10143 | specify that they may stretch horizontally, but are fixed | - | ||||||||||||||||||||||||||||||||||||
10144 | vertically. The same applies to lineedit controls (such as | - | ||||||||||||||||||||||||||||||||||||
10145 | QLineEdit, QSpinBox or an editable QComboBox) and other | - | ||||||||||||||||||||||||||||||||||||
10146 | horizontally orientated widgets (such as QProgressBar). | - | ||||||||||||||||||||||||||||||||||||
10147 | QToolButton's are normally square, so they allow growth in both | - | ||||||||||||||||||||||||||||||||||||
10148 | directions. Widgets that support different directions (such as | - | ||||||||||||||||||||||||||||||||||||
10149 | QSlider, QScrollBar or QHeader) specify stretching in the | - | ||||||||||||||||||||||||||||||||||||
10150 | respective direction only. Widgets that can provide scroll bars | - | ||||||||||||||||||||||||||||||||||||
10151 | (usually subclasses of QScrollArea) tend to specify that they can | - | ||||||||||||||||||||||||||||||||||||
10152 | use additional space, and that they can make do with less than | - | ||||||||||||||||||||||||||||||||||||
10153 | sizeHint(). | - | ||||||||||||||||||||||||||||||||||||
10154 | - | |||||||||||||||||||||||||||||||||||||
10155 | \sa sizeHint(), QLayout, QSizePolicy, updateGeometry() | - | ||||||||||||||||||||||||||||||||||||
10156 | */ | - | ||||||||||||||||||||||||||||||||||||
10157 | QSizePolicy QWidget::sizePolicy() const | - | ||||||||||||||||||||||||||||||||||||
10158 | { | - | ||||||||||||||||||||||||||||||||||||
10159 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
10160 | return d->size_policy; never executed: return d->size_policy; | 0 | ||||||||||||||||||||||||||||||||||||
10161 | } | - | ||||||||||||||||||||||||||||||||||||
10162 | - | |||||||||||||||||||||||||||||||||||||
10163 | void QWidget::setSizePolicy(QSizePolicy policy) | - | ||||||||||||||||||||||||||||||||||||
10164 | { | - | ||||||||||||||||||||||||||||||||||||
10165 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10166 | setAttribute(Qt::WA_WState_OwnSizePolicy); | - | ||||||||||||||||||||||||||||||||||||
10167 | if (policy == d->size_policy)
| 0 | ||||||||||||||||||||||||||||||||||||
10168 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10169 | - | |||||||||||||||||||||||||||||||||||||
10170 | if (d->size_policy.retainSizeWhenHidden() != policy.retainSizeWhenHidden())
| 0 | ||||||||||||||||||||||||||||||||||||
10171 | d->retainSizeWhenHiddenChanged = 1; never executed: d->retainSizeWhenHiddenChanged = 1; | 0 | ||||||||||||||||||||||||||||||||||||
10172 | - | |||||||||||||||||||||||||||||||||||||
10173 | d->size_policy = policy; | - | ||||||||||||||||||||||||||||||||||||
10174 | - | |||||||||||||||||||||||||||||||||||||
10175 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
10176 | if (QWExtra *extra = d->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
10177 | if (extra->proxyWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
10178 | extra->proxyWidget->setSizePolicy(policy); never executed: extra->proxyWidget->setSizePolicy(policy); | 0 | ||||||||||||||||||||||||||||||||||||
10179 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10180 | #endif | - | ||||||||||||||||||||||||||||||||||||
10181 | - | |||||||||||||||||||||||||||||||||||||
10182 | updateGeometry(); | - | ||||||||||||||||||||||||||||||||||||
10183 | d->retainSizeWhenHiddenChanged = 0; | - | ||||||||||||||||||||||||||||||||||||
10184 | - | |||||||||||||||||||||||||||||||||||||
10185 | if (isWindow() && d->maybeTopData())
| 0 | ||||||||||||||||||||||||||||||||||||
10186 | d->topData()->sizeAdjusted = false; never executed: d->topData()->sizeAdjusted = false; | 0 | ||||||||||||||||||||||||||||||||||||
10187 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10188 | - | |||||||||||||||||||||||||||||||||||||
10189 | /*! | - | ||||||||||||||||||||||||||||||||||||
10190 | \fn void QWidget::setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical) | - | ||||||||||||||||||||||||||||||||||||
10191 | \overload | - | ||||||||||||||||||||||||||||||||||||
10192 | - | |||||||||||||||||||||||||||||||||||||
10193 | Sets the size policy of the widget to \a horizontal and \a | - | ||||||||||||||||||||||||||||||||||||
10194 | vertical, with standard stretch and no height-for-width. | - | ||||||||||||||||||||||||||||||||||||
10195 | - | |||||||||||||||||||||||||||||||||||||
10196 | \sa QSizePolicy::QSizePolicy() | - | ||||||||||||||||||||||||||||||||||||
10197 | */ | - | ||||||||||||||||||||||||||||||||||||
10198 | - | |||||||||||||||||||||||||||||||||||||
10199 | /*! | - | ||||||||||||||||||||||||||||||||||||
10200 | Returns the preferred height for this widget, given the width \a w. | - | ||||||||||||||||||||||||||||||||||||
10201 | - | |||||||||||||||||||||||||||||||||||||
10202 | If this widget has a layout, the default implementation returns | - | ||||||||||||||||||||||||||||||||||||
10203 | the layout's preferred height. if there is no layout, the default | - | ||||||||||||||||||||||||||||||||||||
10204 | implementation returns -1 indicating that the preferred height | - | ||||||||||||||||||||||||||||||||||||
10205 | does not depend on the width. | - | ||||||||||||||||||||||||||||||||||||
10206 | */ | - | ||||||||||||||||||||||||||||||||||||
10207 | - | |||||||||||||||||||||||||||||||||||||
10208 | int QWidget::heightForWidth(int w) const | - | ||||||||||||||||||||||||||||||||||||
10209 | { | - | ||||||||||||||||||||||||||||||||||||
10210 | if (layout() && layout()->hasHeightForWidth())
| 0 | ||||||||||||||||||||||||||||||||||||
10211 | return layout()->totalHeightForWidth(w); never executed: return layout()->totalHeightForWidth(w); | 0 | ||||||||||||||||||||||||||||||||||||
10212 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||
10213 | } | - | ||||||||||||||||||||||||||||||||||||
10214 | - | |||||||||||||||||||||||||||||||||||||
10215 | - | |||||||||||||||||||||||||||||||||||||
10216 | /*! | - | ||||||||||||||||||||||||||||||||||||
10217 | \since 5.0 | - | ||||||||||||||||||||||||||||||||||||
10218 | - | |||||||||||||||||||||||||||||||||||||
10219 | Returns \c true if the widget's preferred height depends on its width; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
10220 | */ | - | ||||||||||||||||||||||||||||||||||||
10221 | bool QWidget::hasHeightForWidth() const | - | ||||||||||||||||||||||||||||||||||||
10222 | { | - | ||||||||||||||||||||||||||||||||||||
10223 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
10224 | return d->layout ? d->layout->hasHeightForWidth() : d->size_policy.hasHeightForWidth(); never executed: return d->layout ? d->layout->hasHeightForWidth() : d->size_policy.hasHeightForWidth();
| 0 | ||||||||||||||||||||||||||||||||||||
10225 | } | - | ||||||||||||||||||||||||||||||||||||
10226 | - | |||||||||||||||||||||||||||||||||||||
10227 | /*! | - | ||||||||||||||||||||||||||||||||||||
10228 | \fn QWidget *QWidget::childAt(int x, int y) const | - | ||||||||||||||||||||||||||||||||||||
10229 | - | |||||||||||||||||||||||||||||||||||||
10230 | Returns the visible child widget at the position (\a{x}, \a{y}) | - | ||||||||||||||||||||||||||||||||||||
10231 | in the widget's coordinate system. If there is no visible child | - | ||||||||||||||||||||||||||||||||||||
10232 | widget at the specified position, the function returns 0. | - | ||||||||||||||||||||||||||||||||||||
10233 | */ | - | ||||||||||||||||||||||||||||||||||||
10234 | - | |||||||||||||||||||||||||||||||||||||
10235 | /*! | - | ||||||||||||||||||||||||||||||||||||
10236 | \overload | - | ||||||||||||||||||||||||||||||||||||
10237 | - | |||||||||||||||||||||||||||||||||||||
10238 | Returns the visible child widget at point \a p in the widget's own | - | ||||||||||||||||||||||||||||||||||||
10239 | coordinate system. | - | ||||||||||||||||||||||||||||||||||||
10240 | */ | - | ||||||||||||||||||||||||||||||||||||
10241 | - | |||||||||||||||||||||||||||||||||||||
10242 | QWidget *QWidget::childAt(const QPoint &p) const | - | ||||||||||||||||||||||||||||||||||||
10243 | { | - | ||||||||||||||||||||||||||||||||||||
10244 | return d_func()->childAt_helper(p, false); never executed: return d_func()->childAt_helper(p, false); | 0 | ||||||||||||||||||||||||||||||||||||
10245 | } | - | ||||||||||||||||||||||||||||||||||||
10246 | - | |||||||||||||||||||||||||||||||||||||
10247 | QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const | - | ||||||||||||||||||||||||||||||||||||
10248 | { | - | ||||||||||||||||||||||||||||||||||||
10249 | if (children.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
10250 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
10251 | - | |||||||||||||||||||||||||||||||||||||
10252 | if (!pointInsideRectAndMask(p))
| 0 | ||||||||||||||||||||||||||||||||||||
10253 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
10254 | return childAtRecursiveHelper(p, ignoreChildrenInDestructor); never executed: return childAtRecursiveHelper(p, ignoreChildrenInDestructor); | 0 | ||||||||||||||||||||||||||||||||||||
10255 | } | - | ||||||||||||||||||||||||||||||||||||
10256 | - | |||||||||||||||||||||||||||||||||||||
10257 | QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor) const | - | ||||||||||||||||||||||||||||||||||||
10258 | { | - | ||||||||||||||||||||||||||||||||||||
10259 | for (int i = children.size() - 1; i >= 0; --i) {
| 0 | ||||||||||||||||||||||||||||||||||||
10260 | QWidget *child = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
10261 | if (!child || child->isWindow() || child->isHidden() || child->testAttribute(Qt::WA_TransparentForMouseEvents)
| 0 | ||||||||||||||||||||||||||||||||||||
10262 | || (ignoreChildrenInDestructor && child->data->in_destructor)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10263 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
10264 | } | - | ||||||||||||||||||||||||||||||||||||
10265 | - | |||||||||||||||||||||||||||||||||||||
10266 | // Map the point 'p' from parent coordinates to child coordinates. | - | ||||||||||||||||||||||||||||||||||||
10267 | QPoint childPoint = p; | - | ||||||||||||||||||||||||||||||||||||
10268 | childPoint -= child->data->crect.topLeft(); | - | ||||||||||||||||||||||||||||||||||||
10269 | - | |||||||||||||||||||||||||||||||||||||
10270 | // Check if the point hits the child. | - | ||||||||||||||||||||||||||||||||||||
10271 | if (!child->d_func()->pointInsideRectAndMask(childPoint))
| 0 | ||||||||||||||||||||||||||||||||||||
10272 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
10273 | - | |||||||||||||||||||||||||||||||||||||
10274 | // Do the same for the child's descendants. | - | ||||||||||||||||||||||||||||||||||||
10275 | if (QWidget *w = child->d_func()->childAtRecursiveHelper(childPoint, ignoreChildrenInDestructor))
| 0 | ||||||||||||||||||||||||||||||||||||
10276 | return w; never executed: return w; | 0 | ||||||||||||||||||||||||||||||||||||
10277 | - | |||||||||||||||||||||||||||||||||||||
10278 | // We have found our target; namely the child at position 'p'. | - | ||||||||||||||||||||||||||||||||||||
10279 | return child; never executed: return child; | 0 | ||||||||||||||||||||||||||||||||||||
10280 | } | - | ||||||||||||||||||||||||||||||||||||
10281 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
10282 | } | - | ||||||||||||||||||||||||||||||||||||
10283 | - | |||||||||||||||||||||||||||||||||||||
10284 | void QWidgetPrivate::updateGeometry_helper(bool forceUpdate) | - | ||||||||||||||||||||||||||||||||||||
10285 | { | - | ||||||||||||||||||||||||||||||||||||
10286 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10287 | if (widgetItem)
| 0 | ||||||||||||||||||||||||||||||||||||
10288 | widgetItem->invalidateSizeCache(); never executed: widgetItem->invalidateSizeCache(); | 0 | ||||||||||||||||||||||||||||||||||||
10289 | QWidget *parent; | - | ||||||||||||||||||||||||||||||||||||
10290 | if (forceUpdate || !extra || extra->minw != extra->maxw || extra->minh != extra->maxh) {
| 0 | ||||||||||||||||||||||||||||||||||||
10291 | const int isHidden = q->isHidden() && !size_policy.retainSizeWhenHidden() && !retainSizeWhenHiddenChanged;
| 0 | ||||||||||||||||||||||||||||||||||||
10292 | - | |||||||||||||||||||||||||||||||||||||
10293 | if (!q->isWindow() && !isHidden && (parent = q->parentWidget())) {
| 0 | ||||||||||||||||||||||||||||||||||||
10294 | if (parent->d_func()->layout)
| 0 | ||||||||||||||||||||||||||||||||||||
10295 | parent->d_func()->layout->invalidate(); never executed: parent->d_func()->layout->invalidate(); | 0 | ||||||||||||||||||||||||||||||||||||
10296 | else if (parent->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
10297 | QApplication::postEvent(parent, new QEvent(QEvent::LayoutRequest)); never executed: QApplication::postEvent(parent, new QEvent(QEvent::LayoutRequest)); | 0 | ||||||||||||||||||||||||||||||||||||
10298 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10299 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10300 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10301 | - | |||||||||||||||||||||||||||||||||||||
10302 | /*! | - | ||||||||||||||||||||||||||||||||||||
10303 | Notifies the layout system that this widget has changed and may | - | ||||||||||||||||||||||||||||||||||||
10304 | need to change geometry. | - | ||||||||||||||||||||||||||||||||||||
10305 | - | |||||||||||||||||||||||||||||||||||||
10306 | Call this function if the sizeHint() or sizePolicy() have changed. | - | ||||||||||||||||||||||||||||||||||||
10307 | - | |||||||||||||||||||||||||||||||||||||
10308 | For explicitly hidden widgets, updateGeometry() is a no-op. The | - | ||||||||||||||||||||||||||||||||||||
10309 | layout system will be notified as soon as the widget is shown. | - | ||||||||||||||||||||||||||||||||||||
10310 | */ | - | ||||||||||||||||||||||||||||||||||||
10311 | - | |||||||||||||||||||||||||||||||||||||
10312 | void QWidget::updateGeometry() | - | ||||||||||||||||||||||||||||||||||||
10313 | { | - | ||||||||||||||||||||||||||||||||||||
10314 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10315 | d->updateGeometry_helper(false); | - | ||||||||||||||||||||||||||||||||||||
10316 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10317 | - | |||||||||||||||||||||||||||||||||||||
10318 | /*! \property QWidget::windowFlags | - | ||||||||||||||||||||||||||||||||||||
10319 | - | |||||||||||||||||||||||||||||||||||||
10320 | Window flags are a combination of a type (e.g. Qt::Dialog) and | - | ||||||||||||||||||||||||||||||||||||
10321 | zero or more hints to the window system (e.g. | - | ||||||||||||||||||||||||||||||||||||
10322 | Qt::FramelessWindowHint). | - | ||||||||||||||||||||||||||||||||||||
10323 | - | |||||||||||||||||||||||||||||||||||||
10324 | If the widget had type Qt::Widget or Qt::SubWindow and becomes a | - | ||||||||||||||||||||||||||||||||||||
10325 | window (Qt::Window, Qt::Dialog, etc.), it is put at position (0, | - | ||||||||||||||||||||||||||||||||||||
10326 | 0) on the desktop. If the widget is a window and becomes a | - | ||||||||||||||||||||||||||||||||||||
10327 | Qt::Widget or Qt::SubWindow, it is put at position (0, 0) | - | ||||||||||||||||||||||||||||||||||||
10328 | relative to its parent widget. | - | ||||||||||||||||||||||||||||||||||||
10329 | - | |||||||||||||||||||||||||||||||||||||
10330 | \note This function calls setParent() when changing the flags for | - | ||||||||||||||||||||||||||||||||||||
10331 | a window, causing the widget to be hidden. You must call show() to make | - | ||||||||||||||||||||||||||||||||||||
10332 | the widget visible again.. | - | ||||||||||||||||||||||||||||||||||||
10333 | - | |||||||||||||||||||||||||||||||||||||
10334 | \sa windowType(), {Window Flags Example} | - | ||||||||||||||||||||||||||||||||||||
10335 | */ | - | ||||||||||||||||||||||||||||||||||||
10336 | void QWidget::setWindowFlags(Qt::WindowFlags flags) | - | ||||||||||||||||||||||||||||||||||||
10337 | { | - | ||||||||||||||||||||||||||||||||||||
10338 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10339 | d->setWindowFlags(flags); | - | ||||||||||||||||||||||||||||||||||||
10340 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10341 | - | |||||||||||||||||||||||||||||||||||||
10342 | /*! \internal | - | ||||||||||||||||||||||||||||||||||||
10343 | - | |||||||||||||||||||||||||||||||||||||
10344 | Implemented in QWidgetPrivate so that QMdiSubWindowPrivate can reimplement it. | - | ||||||||||||||||||||||||||||||||||||
10345 | */ | - | ||||||||||||||||||||||||||||||||||||
10346 | void QWidgetPrivate::setWindowFlags(Qt::WindowFlags flags) | - | ||||||||||||||||||||||||||||||||||||
10347 | { | - | ||||||||||||||||||||||||||||||||||||
10348 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10349 | if (q->data->window_flags == flags)
| 0 | ||||||||||||||||||||||||||||||||||||
10350 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10351 | - | |||||||||||||||||||||||||||||||||||||
10352 | if ((q->data->window_flags | flags) & Qt::Window) {
| 0 | ||||||||||||||||||||||||||||||||||||
10353 | // the old type was a window and/or the new type is a window | - | ||||||||||||||||||||||||||||||||||||
10354 | QPoint oldPos = q->pos(); | - | ||||||||||||||||||||||||||||||||||||
10355 | bool visible = q->isVisible(); | - | ||||||||||||||||||||||||||||||||||||
10356 | const bool windowFlagChanged = (q->data->window_flags ^ flags) & Qt::Window; | - | ||||||||||||||||||||||||||||||||||||
10357 | q->setParent(q->parentWidget(), flags); | - | ||||||||||||||||||||||||||||||||||||
10358 | - | |||||||||||||||||||||||||||||||||||||
10359 | // if both types are windows or neither of them are, we restore | - | ||||||||||||||||||||||||||||||||||||
10360 | // the old position | - | ||||||||||||||||||||||||||||||||||||
10361 | if (!windowFlagChanged && (visible || q->testAttribute(Qt::WA_Moved)))
| 0 | ||||||||||||||||||||||||||||||||||||
10362 | q->move(oldPos); never executed: q->move(oldPos); | 0 | ||||||||||||||||||||||||||||||||||||
10363 | // for backward-compatibility we change Qt::WA_QuitOnClose attribute value only when the window was recreated. | - | ||||||||||||||||||||||||||||||||||||
10364 | adjustQuitOnCloseAttribute(); | - | ||||||||||||||||||||||||||||||||||||
10365 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10366 | q->data->window_flags = flags; | - | ||||||||||||||||||||||||||||||||||||
10367 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10368 | } | - | ||||||||||||||||||||||||||||||||||||
10369 | - | |||||||||||||||||||||||||||||||||||||
10370 | /*! | - | ||||||||||||||||||||||||||||||||||||
10371 | Sets the window flags for the widget to \a flags, | - | ||||||||||||||||||||||||||||||||||||
10372 | \e without telling the window system. | - | ||||||||||||||||||||||||||||||||||||
10373 | - | |||||||||||||||||||||||||||||||||||||
10374 | \warning Do not call this function unless you really know what | - | ||||||||||||||||||||||||||||||||||||
10375 | you're doing. | - | ||||||||||||||||||||||||||||||||||||
10376 | - | |||||||||||||||||||||||||||||||||||||
10377 | \sa setWindowFlags() | - | ||||||||||||||||||||||||||||||||||||
10378 | */ | - | ||||||||||||||||||||||||||||||||||||
10379 | void QWidget::overrideWindowFlags(Qt::WindowFlags flags) | - | ||||||||||||||||||||||||||||||||||||
10380 | { | - | ||||||||||||||||||||||||||||||||||||
10381 | data->window_flags = flags; | - | ||||||||||||||||||||||||||||||||||||
10382 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10383 | - | |||||||||||||||||||||||||||||||||||||
10384 | /*! | - | ||||||||||||||||||||||||||||||||||||
10385 | \fn Qt::WindowType QWidget::windowType() const | - | ||||||||||||||||||||||||||||||||||||
10386 | - | |||||||||||||||||||||||||||||||||||||
10387 | Returns the window type of this widget. This is identical to | - | ||||||||||||||||||||||||||||||||||||
10388 | windowFlags() & Qt::WindowType_Mask. | - | ||||||||||||||||||||||||||||||||||||
10389 | - | |||||||||||||||||||||||||||||||||||||
10390 | \sa windowFlags | - | ||||||||||||||||||||||||||||||||||||
10391 | */ | - | ||||||||||||||||||||||||||||||||||||
10392 | - | |||||||||||||||||||||||||||||||||||||
10393 | /*! | - | ||||||||||||||||||||||||||||||||||||
10394 | Sets the parent of the widget to \a parent, and resets the window | - | ||||||||||||||||||||||||||||||||||||
10395 | flags. The widget is moved to position (0, 0) in its new parent. | - | ||||||||||||||||||||||||||||||||||||
10396 | - | |||||||||||||||||||||||||||||||||||||
10397 | If the new parent widget is in a different window, the | - | ||||||||||||||||||||||||||||||||||||
10398 | reparented widget and its children are appended to the end of the | - | ||||||||||||||||||||||||||||||||||||
10399 | \l{setFocusPolicy()}{tab chain} of the new parent | - | ||||||||||||||||||||||||||||||||||||
10400 | widget, in the same internal order as before. If one of the moved | - | ||||||||||||||||||||||||||||||||||||
10401 | widgets had keyboard focus, setParent() calls clearFocus() for that | - | ||||||||||||||||||||||||||||||||||||
10402 | widget. | - | ||||||||||||||||||||||||||||||||||||
10403 | - | |||||||||||||||||||||||||||||||||||||
10404 | If the new parent widget is in the same window as the | - | ||||||||||||||||||||||||||||||||||||
10405 | old parent, setting the parent doesn't change the tab order or | - | ||||||||||||||||||||||||||||||||||||
10406 | keyboard focus. | - | ||||||||||||||||||||||||||||||||||||
10407 | - | |||||||||||||||||||||||||||||||||||||
10408 | If the "new" parent widget is the old parent widget, this function | - | ||||||||||||||||||||||||||||||||||||
10409 | does nothing. | - | ||||||||||||||||||||||||||||||||||||
10410 | - | |||||||||||||||||||||||||||||||||||||
10411 | \note The widget becomes invisible as part of changing its parent, | - | ||||||||||||||||||||||||||||||||||||
10412 | even if it was previously visible. You must call show() to make the | - | ||||||||||||||||||||||||||||||||||||
10413 | widget visible again. | - | ||||||||||||||||||||||||||||||||||||
10414 | - | |||||||||||||||||||||||||||||||||||||
10415 | \warning It is very unlikely that you will ever need this | - | ||||||||||||||||||||||||||||||||||||
10416 | function. If you have a widget that changes its content | - | ||||||||||||||||||||||||||||||||||||
10417 | dynamically, it is far easier to use \l QStackedWidget. | - | ||||||||||||||||||||||||||||||||||||
10418 | - | |||||||||||||||||||||||||||||||||||||
10419 | \sa setWindowFlags() | - | ||||||||||||||||||||||||||||||||||||
10420 | */ | - | ||||||||||||||||||||||||||||||||||||
10421 | void QWidget::setParent(QWidget *parent) | - | ||||||||||||||||||||||||||||||||||||
10422 | { | - | ||||||||||||||||||||||||||||||||||||
10423 | if (parent == parentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
10424 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10425 | setParent((QWidget*)parent, windowFlags() & ~Qt::WindowType_Mask); | - | ||||||||||||||||||||||||||||||||||||
10426 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10427 | - | |||||||||||||||||||||||||||||||||||||
10428 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
10429 | static void sendWindowChangeToTextureChildrenRecursively(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
10430 | { | - | ||||||||||||||||||||||||||||||||||||
10431 | QWidgetPrivate *d = QWidgetPrivate::get(widget); | - | ||||||||||||||||||||||||||||||||||||
10432 | if (d->renderToTexture) {
| 0 | ||||||||||||||||||||||||||||||||||||
10433 | QEvent e(QEvent::WindowChangeInternal); | - | ||||||||||||||||||||||||||||||||||||
10434 | QApplication::sendEvent(widget, &e); | - | ||||||||||||||||||||||||||||||||||||
10435 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10436 | - | |||||||||||||||||||||||||||||||||||||
10437 | for (int i = 0; i < d->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
10438 | QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
10439 | if (w && !w->isWindow() && !w->isHidden() && QWidgetPrivate::get(w)->textureChildSeen)
| 0 | ||||||||||||||||||||||||||||||||||||
10440 | sendWindowChangeToTextureChildrenRecursively(w); never executed: sendWindowChangeToTextureChildrenRecursively(w); | 0 | ||||||||||||||||||||||||||||||||||||
10441 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10442 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10443 | #endif | - | ||||||||||||||||||||||||||||||||||||
10444 | - | |||||||||||||||||||||||||||||||||||||
10445 | /*! | - | ||||||||||||||||||||||||||||||||||||
10446 | \overload | - | ||||||||||||||||||||||||||||||||||||
10447 | - | |||||||||||||||||||||||||||||||||||||
10448 | This function also takes widget flags, \a f as an argument. | - | ||||||||||||||||||||||||||||||||||||
10449 | */ | - | ||||||||||||||||||||||||||||||||||||
10450 | - | |||||||||||||||||||||||||||||||||||||
10451 | void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) | - | ||||||||||||||||||||||||||||||||||||
10452 | { | - | ||||||||||||||||||||||||||||||||||||
10453 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10454 | bool resized = testAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||||||||||||||
10455 | bool wasCreated = testAttribute(Qt::WA_WState_Created); | - | ||||||||||||||||||||||||||||||||||||
10456 | QWidget *oldtlw = window(); | - | ||||||||||||||||||||||||||||||||||||
10457 | - | |||||||||||||||||||||||||||||||||||||
10458 | if (f & Qt::Window) // Frame geometry likely changes, refresh.
| 0 | ||||||||||||||||||||||||||||||||||||
10459 | d->data.fstrut_dirty = true; never executed: d->data.fstrut_dirty = true; | 0 | ||||||||||||||||||||||||||||||||||||
10460 | - | |||||||||||||||||||||||||||||||||||||
10461 | QWidget *desktopWidget = 0; | - | ||||||||||||||||||||||||||||||||||||
10462 | if (parent && parent->windowType() == Qt::Desktop)
| 0 | ||||||||||||||||||||||||||||||||||||
10463 | desktopWidget = parent; never executed: desktopWidget = parent; | 0 | ||||||||||||||||||||||||||||||||||||
10464 | bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget;
| 0 | ||||||||||||||||||||||||||||||||||||
10465 | - | |||||||||||||||||||||||||||||||||||||
10466 | if (newParent && parent && !desktopWidget) {
| 0 | ||||||||||||||||||||||||||||||||||||
10467 | if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings))
| 0 | ||||||||||||||||||||||||||||||||||||
10468 | parent->d_func()->enforceNativeChildren(); never executed: parent->d_func()->enforceNativeChildren(); | 0 | ||||||||||||||||||||||||||||||||||||
10469 | else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))
| 0 | ||||||||||||||||||||||||||||||||||||
10470 | setAttribute(Qt::WA_NativeWindow); never executed: setAttribute(Qt::WA_NativeWindow); | 0 | ||||||||||||||||||||||||||||||||||||
10471 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10472 | - | |||||||||||||||||||||||||||||||||||||
10473 | if (wasCreated) {
| 0 | ||||||||||||||||||||||||||||||||||||
10474 | if (!testAttribute(Qt::WA_WState_Hidden)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10475 | hide(); | - | ||||||||||||||||||||||||||||||||||||
10476 | setAttribute(Qt::WA_WState_ExplicitShowHide, false); | - | ||||||||||||||||||||||||||||||||||||
10477 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10478 | if (newParent) {
| 0 | ||||||||||||||||||||||||||||||||||||
10479 | QEvent e(QEvent::ParentAboutToChange); | - | ||||||||||||||||||||||||||||||||||||
10480 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
10481 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10482 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10483 | if (newParent && isAncestorOf(focusWidget()))
| 0 | ||||||||||||||||||||||||||||||||||||
10484 | focusWidget()->clearFocus(); never executed: focusWidget()->clearFocus(); | 0 | ||||||||||||||||||||||||||||||||||||
10485 | - | |||||||||||||||||||||||||||||||||||||
10486 | QTLWExtra *oldTopExtra = window()->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
10487 | QWidgetBackingStoreTracker *oldBsTracker = oldTopExtra ? &oldTopExtra->backingStoreTracker : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
10488 | - | |||||||||||||||||||||||||||||||||||||
10489 | d->setParent_sys(parent, f); | - | ||||||||||||||||||||||||||||||||||||
10490 | - | |||||||||||||||||||||||||||||||||||||
10491 | QTLWExtra *topExtra = window()->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
10492 | QWidgetBackingStoreTracker *bsTracker = topExtra ? &topExtra->backingStoreTracker : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
10493 | if (oldBsTracker && oldBsTracker != bsTracker)
| 0 | ||||||||||||||||||||||||||||||||||||
10494 | oldBsTracker->unregisterWidgetSubtree(this); never executed: oldBsTracker->unregisterWidgetSubtree(this); | 0 | ||||||||||||||||||||||||||||||||||||
10495 | - | |||||||||||||||||||||||||||||||||||||
10496 | if (desktopWidget)
| 0 | ||||||||||||||||||||||||||||||||||||
10497 | parent = 0; never executed: parent = 0; | 0 | ||||||||||||||||||||||||||||||||||||
10498 | - | |||||||||||||||||||||||||||||||||||||
10499 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
10500 | if (d->textureChildSeen && parent) {
| 0 | ||||||||||||||||||||||||||||||||||||
10501 | // set the textureChildSeen flag up the whole parent chain | - | ||||||||||||||||||||||||||||||||||||
10502 | QWidgetPrivate::get(parent)->setTextureChildSeen(); | - | ||||||||||||||||||||||||||||||||||||
10503 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10504 | #endif | - | ||||||||||||||||||||||||||||||||||||
10505 | - | |||||||||||||||||||||||||||||||||||||
10506 | if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10507 | if (newParent)
| 0 | ||||||||||||||||||||||||||||||||||||
10508 | oldBs->removeDirtyWidget(this); never executed: oldBs->removeDirtyWidget(this); | 0 | ||||||||||||||||||||||||||||||||||||
10509 | // Move the widget and all its static children from | - | ||||||||||||||||||||||||||||||||||||
10510 | // the old backing store to the new one. | - | ||||||||||||||||||||||||||||||||||||
10511 | oldBs->moveStaticWidgets(this); | - | ||||||||||||||||||||||||||||||||||||
10512 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10513 | - | |||||||||||||||||||||||||||||||||||||
10514 | // ### fixme: Qt 6: Remove AA_ImmediateWidgetCreation. | - | ||||||||||||||||||||||||||||||||||||
10515 | if (QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation) && !testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
10516 | create(); never executed: create(); | 0 | ||||||||||||||||||||||||||||||||||||
10517 | - | |||||||||||||||||||||||||||||||||||||
10518 | d->reparentFocusWidgets(oldtlw); | - | ||||||||||||||||||||||||||||||||||||
10519 | setAttribute(Qt::WA_Resized, resized); | - | ||||||||||||||||||||||||||||||||||||
10520 | if (!testAttribute(Qt::WA_StyleSheet)
| 0 | ||||||||||||||||||||||||||||||||||||
10521 | && (!parent || !parent->testAttribute(Qt::WA_StyleSheet))) {
| 0 | ||||||||||||||||||||||||||||||||||||
10522 | d->resolveFont(); | - | ||||||||||||||||||||||||||||||||||||
10523 | d->resolvePalette(); | - | ||||||||||||||||||||||||||||||||||||
10524 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10525 | d->resolveLayoutDirection(); | - | ||||||||||||||||||||||||||||||||||||
10526 | d->resolveLocale(); | - | ||||||||||||||||||||||||||||||||||||
10527 | - | |||||||||||||||||||||||||||||||||||||
10528 | // Note: GL widgets under WGL or EGL will always need a ParentChange | - | ||||||||||||||||||||||||||||||||||||
10529 | // event to handle recreation/rebinding of the GL context, hence the | - | ||||||||||||||||||||||||||||||||||||
10530 | // (f & Qt::MSWindowsOwnDC) clause (which is set on QGLWidgets on all | - | ||||||||||||||||||||||||||||||||||||
10531 | // platforms). | - | ||||||||||||||||||||||||||||||||||||
10532 | if (newParent
| 0 | ||||||||||||||||||||||||||||||||||||
10533 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(QT_OPENGL_ES) | - | ||||||||||||||||||||||||||||||||||||
10534 | || (f & Qt::MSWindowsOwnDC) | - | ||||||||||||||||||||||||||||||||||||
10535 | #endif | - | ||||||||||||||||||||||||||||||||||||
10536 | ) { | - | ||||||||||||||||||||||||||||||||||||
10537 | // propagate enabled updates enabled state to non-windows | - | ||||||||||||||||||||||||||||||||||||
10538 | if (!isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10539 | if (!testAttribute(Qt::WA_ForceDisabled))
| 0 | ||||||||||||||||||||||||||||||||||||
10540 | d->setEnabled_helper(parent ? parent->isEnabled() : true); never executed: d->setEnabled_helper(parent ? parent->isEnabled() : true); | 0 | ||||||||||||||||||||||||||||||||||||
10541 | if (!testAttribute(Qt::WA_ForceUpdatesDisabled))
| 0 | ||||||||||||||||||||||||||||||||||||
10542 | d->setUpdatesEnabled_helper(parent ? parent->updatesEnabled() : true); never executed: d->setUpdatesEnabled_helper(parent ? parent->updatesEnabled() : true); | 0 | ||||||||||||||||||||||||||||||||||||
10543 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10544 | d->inheritStyle(); | - | ||||||||||||||||||||||||||||||||||||
10545 | - | |||||||||||||||||||||||||||||||||||||
10546 | // send and post remaining QObject events | - | ||||||||||||||||||||||||||||||||||||
10547 | if (parent && d->sendChildEvents) {
| 0 | ||||||||||||||||||||||||||||||||||||
10548 | QChildEvent e(QEvent::ChildAdded, this); | - | ||||||||||||||||||||||||||||||||||||
10549 | QApplication::sendEvent(parent, &e); | - | ||||||||||||||||||||||||||||||||||||
10550 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10551 | - | |||||||||||||||||||||||||||||||||||||
10552 | //### already hidden above ---> must probably do something smart on the mac | - | ||||||||||||||||||||||||||||||||||||
10553 | // #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
10554 | // extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp | - | ||||||||||||||||||||||||||||||||||||
10555 | // if(!qt_mac_is_macdrawer(q)) //special case | - | ||||||||||||||||||||||||||||||||||||
10556 | // q->setAttribute(Qt::WA_WState_Hidden); | - | ||||||||||||||||||||||||||||||||||||
10557 | // #else | - | ||||||||||||||||||||||||||||||||||||
10558 | // q->setAttribute(Qt::WA_WState_Hidden); | - | ||||||||||||||||||||||||||||||||||||
10559 | //#endif | - | ||||||||||||||||||||||||||||||||||||
10560 | - | |||||||||||||||||||||||||||||||||||||
10561 | if (parent && d->sendChildEvents && d->polished) {
| 0 | ||||||||||||||||||||||||||||||||||||
10562 | QChildEvent e(QEvent::ChildPolished, this); | - | ||||||||||||||||||||||||||||||||||||
10563 | QCoreApplication::sendEvent(parent, &e); | - | ||||||||||||||||||||||||||||||||||||
10564 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10565 | - | |||||||||||||||||||||||||||||||||||||
10566 | QEvent e(QEvent::ParentChange); | - | ||||||||||||||||||||||||||||||||||||
10567 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
10568 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10569 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
10570 | //renderToTexture widgets also need to know when their top-level window changes | - | ||||||||||||||||||||||||||||||||||||
10571 | if (d->textureChildSeen && oldtlw != window()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10572 | sendWindowChangeToTextureChildrenRecursively(this); | - | ||||||||||||||||||||||||||||||||||||
10573 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10574 | #endif | - | ||||||||||||||||||||||||||||||||||||
10575 | - | |||||||||||||||||||||||||||||||||||||
10576 | if (!wasCreated) {
| 0 | ||||||||||||||||||||||||||||||||||||
10577 | if (isWindow() || parentWidget()->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
10578 | setAttribute(Qt::WA_WState_Hidden, true); never executed: setAttribute(Qt::WA_WState_Hidden, true); | 0 | ||||||||||||||||||||||||||||||||||||
10579 | else if (!testAttribute(Qt::WA_WState_ExplicitShowHide))
| 0 | ||||||||||||||||||||||||||||||||||||
10580 | setAttribute(Qt::WA_WState_Hidden, false); never executed: setAttribute(Qt::WA_WState_Hidden, false); | 0 | ||||||||||||||||||||||||||||||||||||
10581 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10582 | - | |||||||||||||||||||||||||||||||||||||
10583 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
10584 | - | |||||||||||||||||||||||||||||||||||||
10585 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
10586 | // Embed the widget into a proxy if the parent is embedded. | - | ||||||||||||||||||||||||||||||||||||
10587 | // ### Doesn't handle reparenting out of an embedded widget. | - | ||||||||||||||||||||||||||||||||||||
10588 | if (oldtlw->graphicsProxyWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10589 | if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(oldtlw))
| 0 | ||||||||||||||||||||||||||||||||||||
10590 | ancestorProxy->d_func()->unembedSubWindow(this); never executed: ancestorProxy->d_func()->unembedSubWindow(this); | 0 | ||||||||||||||||||||||||||||||||||||
10591 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10592 | if (isWindow() && parent && !graphicsProxyWidget() && !bypassGraphicsProxyWidget(this)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10593 | if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(parent))
| 0 | ||||||||||||||||||||||||||||||||||||
10594 | ancestorProxy->d_func()->embedSubWindow(this); never executed: ancestorProxy->d_func()->embedSubWindow(this); | 0 | ||||||||||||||||||||||||||||||||||||
10595 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10596 | #endif | - | ||||||||||||||||||||||||||||||||||||
10597 | - | |||||||||||||||||||||||||||||||||||||
10598 | if (d->extra && d->extra->hasWindowContainer)
| 0 | ||||||||||||||||||||||||||||||||||||
10599 | QWindowContainer::parentWasChanged(this); never executed: QWindowContainer::parentWasChanged(this); | 0 | ||||||||||||||||||||||||||||||||||||
10600 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10601 | - | |||||||||||||||||||||||||||||||||||||
10602 | void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) | - | ||||||||||||||||||||||||||||||||||||
10603 | { | - | ||||||||||||||||||||||||||||||||||||
10604 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10605 | - | |||||||||||||||||||||||||||||||||||||
10606 | Qt::WindowFlags oldFlags = data.window_flags; | - | ||||||||||||||||||||||||||||||||||||
10607 | bool wasCreated = q->testAttribute(Qt::WA_WState_Created); | - | ||||||||||||||||||||||||||||||||||||
10608 | - | |||||||||||||||||||||||||||||||||||||
10609 | int targetScreen = -1; | - | ||||||||||||||||||||||||||||||||||||
10610 | // Handle a request to move the widget to a particular screen | - | ||||||||||||||||||||||||||||||||||||
10611 | if (newparent && newparent->windowType() == Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
10612 | // make sure the widget is created on the same screen as the | - | ||||||||||||||||||||||||||||||||||||
10613 | // programmer specified desktop widget | - | ||||||||||||||||||||||||||||||||||||
10614 | const QDesktopScreenWidget *sw = qobject_cast<const QDesktopScreenWidget *>(newparent); | - | ||||||||||||||||||||||||||||||||||||
10615 | targetScreen = sw ? sw->screenNumber() : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
10616 | newparent = 0; | - | ||||||||||||||||||||||||||||||||||||
10617 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10618 | - | |||||||||||||||||||||||||||||||||||||
10619 | setWinId(0); | - | ||||||||||||||||||||||||||||||||||||
10620 | - | |||||||||||||||||||||||||||||||||||||
10621 | if (parent != newparent) {
| 0 | ||||||||||||||||||||||||||||||||||||
10622 | QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function??? | - | ||||||||||||||||||||||||||||||||||||
10623 | if (q->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10624 | q->windowHandle()->setFlags(f); | - | ||||||||||||||||||||||||||||||||||||
10625 | QWidget *parentWithWindow = | - | ||||||||||||||||||||||||||||||||||||
10626 | newparent ? (newparent->windowHandle() ? newparent : newparent->nativeParentWidget()) : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
10627 | if (parentWithWindow) {
| 0 | ||||||||||||||||||||||||||||||||||||
10628 | QWidget *topLevel = parentWithWindow->window(); | - | ||||||||||||||||||||||||||||||||||||
10629 | if ((f & Qt::Window) && topLevel && topLevel->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10630 | q->windowHandle()->setTransientParent(topLevel->windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
10631 | q->windowHandle()->setParent(0); | - | ||||||||||||||||||||||||||||||||||||
10632 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10633 | q->windowHandle()->setTransientParent(0); | - | ||||||||||||||||||||||||||||||||||||
10634 | q->windowHandle()->setParent(parentWithWindow->windowHandle()); | - | ||||||||||||||||||||||||||||||||||||
10635 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10636 | } else { | - | ||||||||||||||||||||||||||||||||||||
10637 | q->windowHandle()->setTransientParent(0); | - | ||||||||||||||||||||||||||||||||||||
10638 | q->windowHandle()->setParent(0); | - | ||||||||||||||||||||||||||||||||||||
10639 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10640 | } | - | ||||||||||||||||||||||||||||||||||||
10641 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10642 | - | |||||||||||||||||||||||||||||||||||||
10643 | if (!newparent) {
| 0 | ||||||||||||||||||||||||||||||||||||
10644 | f |= Qt::Window; | - | ||||||||||||||||||||||||||||||||||||
10645 | if (targetScreen == -1) {
| 0 | ||||||||||||||||||||||||||||||||||||
10646 | if (parent)
| 0 | ||||||||||||||||||||||||||||||||||||
10647 | targetScreen = QApplication::desktop()->screenNumber(q->parentWidget()->window()); never executed: targetScreen = QApplication::desktop()->screenNumber(q->parentWidget()->window()); | 0 | ||||||||||||||||||||||||||||||||||||
10648 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10649 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10650 | - | |||||||||||||||||||||||||||||||||||||
10651 | bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
| 0 | ||||||||||||||||||||||||||||||||||||
10652 | - | |||||||||||||||||||||||||||||||||||||
10653 | // Reparenting toplevel to child | - | ||||||||||||||||||||||||||||||||||||
10654 | if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10655 | if (extra && extra->hasWindowContainer)
| 0 | ||||||||||||||||||||||||||||||||||||
10656 | QWindowContainer::toplevelAboutToBeDestroyed(q); never executed: QWindowContainer::toplevelAboutToBeDestroyed(q); | 0 | ||||||||||||||||||||||||||||||||||||
10657 | - | |||||||||||||||||||||||||||||||||||||
10658 | QWindow *newParentWindow = newparent->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
10659 | if (!newParentWindow)
| 0 | ||||||||||||||||||||||||||||||||||||
10660 | if (QWidget *npw = newparent->nativeParentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
10661 | newParentWindow = npw->windowHandle(); never executed: newParentWindow = npw->windowHandle(); | 0 | ||||||||||||||||||||||||||||||||||||
10662 | - | |||||||||||||||||||||||||||||||||||||
10663 | Q_FOREACH (QObject *child, q->windowHandle()->children()) { | - | ||||||||||||||||||||||||||||||||||||
10664 | QWindow *childWindow = qobject_cast<QWindow *>(child); | - | ||||||||||||||||||||||||||||||||||||
10665 | if (!childWindow)
| 0 | ||||||||||||||||||||||||||||||||||||
10666 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||
10667 | - | |||||||||||||||||||||||||||||||||||||
10668 | QWidgetWindow *childWW = qobject_cast<QWidgetWindow *>(childWindow); | - | ||||||||||||||||||||||||||||||||||||
10669 | QWidget *childWidget = childWW ? childWW->widget() : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
10670 | if (!childWW || (childWidget && childWidget->testAttribute(Qt::WA_NativeWindow)))
| 0 | ||||||||||||||||||||||||||||||||||||
10671 | childWindow->setParent(newParentWindow); never executed: childWindow->setParent(newParentWindow); | 0 | ||||||||||||||||||||||||||||||||||||
10672 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10673 | q->destroy(); | - | ||||||||||||||||||||||||||||||||||||
10674 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10675 | - | |||||||||||||||||||||||||||||||||||||
10676 | adjustFlags(f, q); | - | ||||||||||||||||||||||||||||||||||||
10677 | data.window_flags = f; | - | ||||||||||||||||||||||||||||||||||||
10678 | q->setAttribute(Qt::WA_WState_Created, false); | - | ||||||||||||||||||||||||||||||||||||
10679 | q->setAttribute(Qt::WA_WState_Visible, false); | - | ||||||||||||||||||||||||||||||||||||
10680 | q->setAttribute(Qt::WA_WState_Hidden, false); | - | ||||||||||||||||||||||||||||||||||||
10681 | - | |||||||||||||||||||||||||||||||||||||
10682 | if (newparent && wasCreated && (q->testAttribute(Qt::WA_NativeWindow) || (f & Qt::Window)))
| 0 | ||||||||||||||||||||||||||||||||||||
10683 | q->createWinId(); never executed: q->createWinId(); | 0 | ||||||||||||||||||||||||||||||||||||
10684 | - | |||||||||||||||||||||||||||||||||||||
10685 | if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
| 0 | ||||||||||||||||||||||||||||||||||||
10686 | q->setAttribute(Qt::WA_WState_Hidden); never executed: q->setAttribute(Qt::WA_WState_Hidden); | 0 | ||||||||||||||||||||||||||||||||||||
10687 | q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); | - | ||||||||||||||||||||||||||||||||||||
10688 | - | |||||||||||||||||||||||||||||||||||||
10689 | // move the window to the selected screen | - | ||||||||||||||||||||||||||||||||||||
10690 | if (!newparent && targetScreen != -1) {
| 0 | ||||||||||||||||||||||||||||||||||||
10691 | // only if it is already created | - | ||||||||||||||||||||||||||||||||||||
10692 | if (q->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
10693 | q->windowHandle()->setScreen(QGuiApplication::screens().value(targetScreen, 0)); never executed: q->windowHandle()->setScreen(QGuiApplication::screens().value(targetScreen, 0)); | 0 | ||||||||||||||||||||||||||||||||||||
10694 | else | - | ||||||||||||||||||||||||||||||||||||
10695 | topData()->initialScreenIndex = targetScreen; never executed: topData()->initialScreenIndex = targetScreen; | 0 | ||||||||||||||||||||||||||||||||||||
10696 | } | - | ||||||||||||||||||||||||||||||||||||
10697 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10698 | - | |||||||||||||||||||||||||||||||||||||
10699 | /*! | - | ||||||||||||||||||||||||||||||||||||
10700 | Scrolls the widget including its children \a dx pixels to the | - | ||||||||||||||||||||||||||||||||||||
10701 | right and \a dy downward. Both \a dx and \a dy may be negative. | - | ||||||||||||||||||||||||||||||||||||
10702 | - | |||||||||||||||||||||||||||||||||||||
10703 | After scrolling, the widgets will receive paint events for | - | ||||||||||||||||||||||||||||||||||||
10704 | the areas that need to be repainted. For widgets that Qt knows to | - | ||||||||||||||||||||||||||||||||||||
10705 | be opaque, this is only the newly exposed parts. | - | ||||||||||||||||||||||||||||||||||||
10706 | For example, if an opaque widget is scrolled 8 pixels to the left, | - | ||||||||||||||||||||||||||||||||||||
10707 | only an 8-pixel wide stripe at the right edge needs updating. | - | ||||||||||||||||||||||||||||||||||||
10708 | - | |||||||||||||||||||||||||||||||||||||
10709 | Since widgets propagate the contents of their parents by default, | - | ||||||||||||||||||||||||||||||||||||
10710 | you need to set the \l autoFillBackground property, or use | - | ||||||||||||||||||||||||||||||||||||
10711 | setAttribute() to set the Qt::WA_OpaquePaintEvent attribute, to make | - | ||||||||||||||||||||||||||||||||||||
10712 | a widget opaque. | - | ||||||||||||||||||||||||||||||||||||
10713 | - | |||||||||||||||||||||||||||||||||||||
10714 | For widgets that use contents propagation, a scroll will cause an | - | ||||||||||||||||||||||||||||||||||||
10715 | update of the entire scroll area. | - | ||||||||||||||||||||||||||||||||||||
10716 | - | |||||||||||||||||||||||||||||||||||||
10717 | \sa {Transparency and Double Buffering} | - | ||||||||||||||||||||||||||||||||||||
10718 | */ | - | ||||||||||||||||||||||||||||||||||||
10719 | - | |||||||||||||||||||||||||||||||||||||
10720 | void QWidget::scroll(int dx, int dy) | - | ||||||||||||||||||||||||||||||||||||
10721 | { | - | ||||||||||||||||||||||||||||||||||||
10722 | if ((!updatesEnabled() && children().size() == 0) || !isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
10723 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10724 | if (dx == 0 && dy == 0)
| 0 | ||||||||||||||||||||||||||||||||||||
10725 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10726 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10727 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
10728 | if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10729 | // Graphics View maintains its own dirty region as a list of rects; | - | ||||||||||||||||||||||||||||||||||||
10730 | // until we can connect item updates directly to the view, we must | - | ||||||||||||||||||||||||||||||||||||
10731 | // separately add a translated dirty region. | - | ||||||||||||||||||||||||||||||||||||
10732 | if (!d->dirty.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10733 | foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects()) | - | ||||||||||||||||||||||||||||||||||||
10734 | proxy->update(rect); never executed: proxy->update(rect); | 0 | ||||||||||||||||||||||||||||||||||||
10735 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10736 | proxy->scroll(dx, dy, proxy->subWidgetRect(this)); | - | ||||||||||||||||||||||||||||||||||||
10737 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10738 | } | - | ||||||||||||||||||||||||||||||||||||
10739 | #endif | - | ||||||||||||||||||||||||||||||||||||
10740 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
10741 | d->scroll_sys(dx, dy); | - | ||||||||||||||||||||||||||||||||||||
10742 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10743 | - | |||||||||||||||||||||||||||||||||||||
10744 | void QWidgetPrivate::scroll_sys(int dx, int dy) | - | ||||||||||||||||||||||||||||||||||||
10745 | { | - | ||||||||||||||||||||||||||||||||||||
10746 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10747 | scrollChildren(dx, dy); | - | ||||||||||||||||||||||||||||||||||||
10748 | scrollRect(q->rect(), dx, dy); | - | ||||||||||||||||||||||||||||||||||||
10749 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10750 | - | |||||||||||||||||||||||||||||||||||||
10751 | /*! | - | ||||||||||||||||||||||||||||||||||||
10752 | \overload | - | ||||||||||||||||||||||||||||||||||||
10753 | - | |||||||||||||||||||||||||||||||||||||
10754 | This version only scrolls \a r and does not move the children of | - | ||||||||||||||||||||||||||||||||||||
10755 | the widget. | - | ||||||||||||||||||||||||||||||||||||
10756 | - | |||||||||||||||||||||||||||||||||||||
10757 | If \a r is empty or invalid, the result is undefined. | - | ||||||||||||||||||||||||||||||||||||
10758 | - | |||||||||||||||||||||||||||||||||||||
10759 | \sa QScrollArea | - | ||||||||||||||||||||||||||||||||||||
10760 | */ | - | ||||||||||||||||||||||||||||||||||||
10761 | void QWidget::scroll(int dx, int dy, const QRect &r) | - | ||||||||||||||||||||||||||||||||||||
10762 | { | - | ||||||||||||||||||||||||||||||||||||
10763 | - | |||||||||||||||||||||||||||||||||||||
10764 | if ((!updatesEnabled() && children().size() == 0) || !isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
10765 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10766 | if (dx == 0 && dy == 0)
| 0 | ||||||||||||||||||||||||||||||||||||
10767 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10768 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10769 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
10770 | if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10771 | // Graphics View maintains its own dirty region as a list of rects; | - | ||||||||||||||||||||||||||||||||||||
10772 | // until we can connect item updates directly to the view, we must | - | ||||||||||||||||||||||||||||||||||||
10773 | // separately add a translated dirty region. | - | ||||||||||||||||||||||||||||||||||||
10774 | if (!d->dirty.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10775 | foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects()) | - | ||||||||||||||||||||||||||||||||||||
10776 | proxy->update(rect); never executed: proxy->update(rect); | 0 | ||||||||||||||||||||||||||||||||||||
10777 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10778 | proxy->scroll(dx, dy, r.translated(proxy->subWidgetRect(this).topLeft().toPoint())); | - | ||||||||||||||||||||||||||||||||||||
10779 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10780 | } | - | ||||||||||||||||||||||||||||||||||||
10781 | #endif | - | ||||||||||||||||||||||||||||||||||||
10782 | d->scroll_sys(dx, dy, r); | - | ||||||||||||||||||||||||||||||||||||
10783 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10784 | - | |||||||||||||||||||||||||||||||||||||
10785 | void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) | - | ||||||||||||||||||||||||||||||||||||
10786 | { | - | ||||||||||||||||||||||||||||||||||||
10787 | scrollRect(r, dx, dy); | - | ||||||||||||||||||||||||||||||||||||
10788 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10789 | - | |||||||||||||||||||||||||||||||||||||
10790 | /*! | - | ||||||||||||||||||||||||||||||||||||
10791 | Repaints the widget directly by calling paintEvent() immediately, | - | ||||||||||||||||||||||||||||||||||||
10792 | unless updates are disabled or the widget is hidden. | - | ||||||||||||||||||||||||||||||||||||
10793 | - | |||||||||||||||||||||||||||||||||||||
10794 | We suggest only using repaint() if you need an immediate repaint, | - | ||||||||||||||||||||||||||||||||||||
10795 | for example during animation. In almost all circumstances update() | - | ||||||||||||||||||||||||||||||||||||
10796 | is better, as it permits Qt to optimize for speed and minimize | - | ||||||||||||||||||||||||||||||||||||
10797 | flicker. | - | ||||||||||||||||||||||||||||||||||||
10798 | - | |||||||||||||||||||||||||||||||||||||
10799 | \warning If you call repaint() in a function which may itself be | - | ||||||||||||||||||||||||||||||||||||
10800 | called from paintEvent(), you may get infinite recursion. The | - | ||||||||||||||||||||||||||||||||||||
10801 | update() function never causes recursion. | - | ||||||||||||||||||||||||||||||||||||
10802 | - | |||||||||||||||||||||||||||||||||||||
10803 | \sa update(), paintEvent(), setUpdatesEnabled() | - | ||||||||||||||||||||||||||||||||||||
10804 | */ | - | ||||||||||||||||||||||||||||||||||||
10805 | - | |||||||||||||||||||||||||||||||||||||
10806 | void QWidget::repaint() | - | ||||||||||||||||||||||||||||||||||||
10807 | { | - | ||||||||||||||||||||||||||||||||||||
10808 | repaint(rect()); | - | ||||||||||||||||||||||||||||||||||||
10809 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10810 | - | |||||||||||||||||||||||||||||||||||||
10811 | /*! \overload | - | ||||||||||||||||||||||||||||||||||||
10812 | - | |||||||||||||||||||||||||||||||||||||
10813 | This version repaints a rectangle (\a x, \a y, \a w, \a h) inside | - | ||||||||||||||||||||||||||||||||||||
10814 | the widget. | - | ||||||||||||||||||||||||||||||||||||
10815 | - | |||||||||||||||||||||||||||||||||||||
10816 | If \a w is negative, it is replaced with \c{width() - x}, and if | - | ||||||||||||||||||||||||||||||||||||
10817 | \a h is negative, it is replaced width \c{height() - y}. | - | ||||||||||||||||||||||||||||||||||||
10818 | */ | - | ||||||||||||||||||||||||||||||||||||
10819 | void QWidget::repaint(int x, int y, int w, int h) | - | ||||||||||||||||||||||||||||||||||||
10820 | { | - | ||||||||||||||||||||||||||||||||||||
10821 | if (x > data->crect.width() || y > data->crect.height())
| 0 | ||||||||||||||||||||||||||||||||||||
10822 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10823 | - | |||||||||||||||||||||||||||||||||||||
10824 | if (w < 0)
| 0 | ||||||||||||||||||||||||||||||||||||
10825 | w = data->crect.width() - x; never executed: w = data->crect.width() - x; | 0 | ||||||||||||||||||||||||||||||||||||
10826 | if (h < 0)
| 0 | ||||||||||||||||||||||||||||||||||||
10827 | h = data->crect.height() - y; never executed: h = data->crect.height() - y; | 0 | ||||||||||||||||||||||||||||||||||||
10828 | - | |||||||||||||||||||||||||||||||||||||
10829 | repaint(QRect(x, y, w, h)); | - | ||||||||||||||||||||||||||||||||||||
10830 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10831 | - | |||||||||||||||||||||||||||||||||||||
10832 | /*! \overload | - | ||||||||||||||||||||||||||||||||||||
10833 | - | |||||||||||||||||||||||||||||||||||||
10834 | This version repaints a rectangle \a rect inside the widget. | - | ||||||||||||||||||||||||||||||||||||
10835 | */ | - | ||||||||||||||||||||||||||||||||||||
10836 | void QWidget::repaint(const QRect &rect) | - | ||||||||||||||||||||||||||||||||||||
10837 | { | - | ||||||||||||||||||||||||||||||||||||
10838 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10839 | - | |||||||||||||||||||||||||||||||||||||
10840 | if (testAttribute(Qt::WA_WState_ConfigPending)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10841 | update(rect); | - | ||||||||||||||||||||||||||||||||||||
10842 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10843 | } | - | ||||||||||||||||||||||||||||||||||||
10844 | - | |||||||||||||||||||||||||||||||||||||
10845 | if (!isVisible() || !updatesEnabled() || rect.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
10846 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10847 | - | |||||||||||||||||||||||||||||||||||||
10848 | if (hasBackingStoreSupport()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10849 | QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
10850 | if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
| 0 | ||||||||||||||||||||||||||||||||||||
10851 | tlwExtra->inRepaint = true; | - | ||||||||||||||||||||||||||||||||||||
10852 | tlwExtra->backingStoreTracker->markDirty(rect, this, QWidgetBackingStore::UpdateNow); | - | ||||||||||||||||||||||||||||||||||||
10853 | tlwExtra->inRepaint = false; | - | ||||||||||||||||||||||||||||||||||||
10854 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10855 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10856 | d->repaint_sys(rect); | - | ||||||||||||||||||||||||||||||||||||
10857 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10858 | } | - | ||||||||||||||||||||||||||||||||||||
10859 | - | |||||||||||||||||||||||||||||||||||||
10860 | /*! | - | ||||||||||||||||||||||||||||||||||||
10861 | \overload | - | ||||||||||||||||||||||||||||||||||||
10862 | - | |||||||||||||||||||||||||||||||||||||
10863 | This version repaints a region \a rgn inside the widget. | - | ||||||||||||||||||||||||||||||||||||
10864 | */ | - | ||||||||||||||||||||||||||||||||||||
10865 | void QWidget::repaint(const QRegion &rgn) | - | ||||||||||||||||||||||||||||||||||||
10866 | { | - | ||||||||||||||||||||||||||||||||||||
10867 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
10868 | - | |||||||||||||||||||||||||||||||||||||
10869 | if (testAttribute(Qt::WA_WState_ConfigPending)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10870 | update(rgn); | - | ||||||||||||||||||||||||||||||||||||
10871 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10872 | } | - | ||||||||||||||||||||||||||||||||||||
10873 | - | |||||||||||||||||||||||||||||||||||||
10874 | if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
10875 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10876 | - | |||||||||||||||||||||||||||||||||||||
10877 | if (hasBackingStoreSupport()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10878 | QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
10879 | if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
| 0 | ||||||||||||||||||||||||||||||||||||
10880 | tlwExtra->inRepaint = true; | - | ||||||||||||||||||||||||||||||||||||
10881 | tlwExtra->backingStoreTracker->markDirty(rgn, this, QWidgetBackingStore::UpdateNow); | - | ||||||||||||||||||||||||||||||||||||
10882 | tlwExtra->inRepaint = false; | - | ||||||||||||||||||||||||||||||||||||
10883 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10884 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10885 | d->repaint_sys(rgn); | - | ||||||||||||||||||||||||||||||||||||
10886 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10887 | } | - | ||||||||||||||||||||||||||||||||||||
10888 | - | |||||||||||||||||||||||||||||||||||||
10889 | /*! | - | ||||||||||||||||||||||||||||||||||||
10890 | Updates the widget unless updates are disabled or the widget is | - | ||||||||||||||||||||||||||||||||||||
10891 | hidden. | - | ||||||||||||||||||||||||||||||||||||
10892 | - | |||||||||||||||||||||||||||||||||||||
10893 | This function does not cause an immediate repaint; instead it | - | ||||||||||||||||||||||||||||||||||||
10894 | schedules a paint event for processing when Qt returns to the main | - | ||||||||||||||||||||||||||||||||||||
10895 | event loop. This permits Qt to optimize for more speed and less | - | ||||||||||||||||||||||||||||||||||||
10896 | flicker than a call to repaint() does. | - | ||||||||||||||||||||||||||||||||||||
10897 | - | |||||||||||||||||||||||||||||||||||||
10898 | Calling update() several times normally results in just one | - | ||||||||||||||||||||||||||||||||||||
10899 | paintEvent() call. | - | ||||||||||||||||||||||||||||||||||||
10900 | - | |||||||||||||||||||||||||||||||||||||
10901 | Qt normally erases the widget's area before the paintEvent() call. | - | ||||||||||||||||||||||||||||||||||||
10902 | If the Qt::WA_OpaquePaintEvent widget attribute is set, the widget is | - | ||||||||||||||||||||||||||||||||||||
10903 | responsible for painting all its pixels with an opaque color. | - | ||||||||||||||||||||||||||||||||||||
10904 | - | |||||||||||||||||||||||||||||||||||||
10905 | \sa repaint(), paintEvent(), setUpdatesEnabled(), {Analog Clock Example} | - | ||||||||||||||||||||||||||||||||||||
10906 | */ | - | ||||||||||||||||||||||||||||||||||||
10907 | void QWidget::update() | - | ||||||||||||||||||||||||||||||||||||
10908 | { | - | ||||||||||||||||||||||||||||||||||||
10909 | update(rect()); | - | ||||||||||||||||||||||||||||||||||||
10910 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10911 | - | |||||||||||||||||||||||||||||||||||||
10912 | /*! \fn void QWidget::update(int x, int y, int w, int h) | - | ||||||||||||||||||||||||||||||||||||
10913 | \overload | - | ||||||||||||||||||||||||||||||||||||
10914 | - | |||||||||||||||||||||||||||||||||||||
10915 | This version updates a rectangle (\a x, \a y, \a w, \a h) inside | - | ||||||||||||||||||||||||||||||||||||
10916 | the widget. | - | ||||||||||||||||||||||||||||||||||||
10917 | */ | - | ||||||||||||||||||||||||||||||||||||
10918 | - | |||||||||||||||||||||||||||||||||||||
10919 | /*! | - | ||||||||||||||||||||||||||||||||||||
10920 | \overload | - | ||||||||||||||||||||||||||||||||||||
10921 | - | |||||||||||||||||||||||||||||||||||||
10922 | This version updates a rectangle \a rect inside the widget. | - | ||||||||||||||||||||||||||||||||||||
10923 | */ | - | ||||||||||||||||||||||||||||||||||||
10924 | void QWidget::update(const QRect &rect) | - | ||||||||||||||||||||||||||||||||||||
10925 | { | - | ||||||||||||||||||||||||||||||||||||
10926 | if (!isVisible() || !updatesEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
10927 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10928 | - | |||||||||||||||||||||||||||||||||||||
10929 | QRect r = rect & QWidget::rect(); | - | ||||||||||||||||||||||||||||||||||||
10930 | - | |||||||||||||||||||||||||||||||||||||
10931 | if (r.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
10932 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10933 | - | |||||||||||||||||||||||||||||||||||||
10934 | if (testAttribute(Qt::WA_WState_InPaintEvent)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10935 | QApplication::postEvent(this, new QUpdateLaterEvent(r)); | - | ||||||||||||||||||||||||||||||||||||
10936 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10937 | } | - | ||||||||||||||||||||||||||||||||||||
10938 | - | |||||||||||||||||||||||||||||||||||||
10939 | if (hasBackingStoreSupport()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10940 | QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
10941 | if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
| 0 | ||||||||||||||||||||||||||||||||||||
10942 | tlwExtra->backingStoreTracker->markDirty(r, this); never executed: tlwExtra->backingStoreTracker->markDirty(r, this); | 0 | ||||||||||||||||||||||||||||||||||||
10943 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10944 | d_func()->repaint_sys(r); | - | ||||||||||||||||||||||||||||||||||||
10945 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10946 | } | - | ||||||||||||||||||||||||||||||||||||
10947 | - | |||||||||||||||||||||||||||||||||||||
10948 | /*! | - | ||||||||||||||||||||||||||||||||||||
10949 | \overload | - | ||||||||||||||||||||||||||||||||||||
10950 | - | |||||||||||||||||||||||||||||||||||||
10951 | This version repaints a region \a rgn inside the widget. | - | ||||||||||||||||||||||||||||||||||||
10952 | */ | - | ||||||||||||||||||||||||||||||||||||
10953 | void QWidget::update(const QRegion &rgn) | - | ||||||||||||||||||||||||||||||||||||
10954 | { | - | ||||||||||||||||||||||||||||||||||||
10955 | if (!isVisible() || !updatesEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
10956 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10957 | - | |||||||||||||||||||||||||||||||||||||
10958 | QRegion r = rgn & QWidget::rect(); | - | ||||||||||||||||||||||||||||||||||||
10959 | - | |||||||||||||||||||||||||||||||||||||
10960 | if (r.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
10961 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10962 | - | |||||||||||||||||||||||||||||||||||||
10963 | if (testAttribute(Qt::WA_WState_InPaintEvent)) {
| 0 | ||||||||||||||||||||||||||||||||||||
10964 | QApplication::postEvent(this, new QUpdateLaterEvent(r)); | - | ||||||||||||||||||||||||||||||||||||
10965 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
10966 | } | - | ||||||||||||||||||||||||||||||||||||
10967 | - | |||||||||||||||||||||||||||||||||||||
10968 | if (hasBackingStoreSupport()) {
| 0 | ||||||||||||||||||||||||||||||||||||
10969 | QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
10970 | if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
| 0 | ||||||||||||||||||||||||||||||||||||
10971 | tlwExtra->backingStoreTracker->markDirty(r, this); never executed: tlwExtra->backingStoreTracker->markDirty(r, this); | 0 | ||||||||||||||||||||||||||||||||||||
10972 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10973 | d_func()->repaint_sys(r); | - | ||||||||||||||||||||||||||||||||||||
10974 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
10975 | } | - | ||||||||||||||||||||||||||||||||||||
10976 | - | |||||||||||||||||||||||||||||||||||||
10977 | - | |||||||||||||||||||||||||||||||||||||
10978 | /*! | - | ||||||||||||||||||||||||||||||||||||
10979 | \internal | - | ||||||||||||||||||||||||||||||||||||
10980 | - | |||||||||||||||||||||||||||||||||||||
10981 | This just sets the corresponding attribute bit to 1 or 0 | - | ||||||||||||||||||||||||||||||||||||
10982 | */ | - | ||||||||||||||||||||||||||||||||||||
10983 | static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidgetData *data, | - | ||||||||||||||||||||||||||||||||||||
10984 | QWidgetPrivate *d) | - | ||||||||||||||||||||||||||||||||||||
10985 | { | - | ||||||||||||||||||||||||||||||||||||
10986 | if (attribute < int(8*sizeof(uint))) {
| 0 | ||||||||||||||||||||||||||||||||||||
10987 | if (on)
| 0 | ||||||||||||||||||||||||||||||||||||
10988 | data->widget_attributes |= (1<<attribute); never executed: data->widget_attributes |= (1<<attribute); | 0 | ||||||||||||||||||||||||||||||||||||
10989 | else | - | ||||||||||||||||||||||||||||||||||||
10990 | data->widget_attributes &= ~(1<<attribute); never executed: data->widget_attributes &= ~(1<<attribute); | 0 | ||||||||||||||||||||||||||||||||||||
10991 | } else { | - | ||||||||||||||||||||||||||||||||||||
10992 | const int x = attribute - 8*sizeof(uint); | - | ||||||||||||||||||||||||||||||||||||
10993 | const int int_off = x / (8*sizeof(uint)); | - | ||||||||||||||||||||||||||||||||||||
10994 | if (on)
| 0 | ||||||||||||||||||||||||||||||||||||
10995 | 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 | ||||||||||||||||||||||||||||||||||||
10996 | else | - | ||||||||||||||||||||||||||||||||||||
10997 | 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 | ||||||||||||||||||||||||||||||||||||
10998 | } | - | ||||||||||||||||||||||||||||||||||||
10999 | } | - | ||||||||||||||||||||||||||||||||||||
11000 | - | |||||||||||||||||||||||||||||||||||||
11001 | #ifdef Q_OS_MAC | - | ||||||||||||||||||||||||||||||||||||
11002 | void QWidgetPrivate::macUpdateSizeAttribute() | - | ||||||||||||||||||||||||||||||||||||
11003 | { | - | ||||||||||||||||||||||||||||||||||||
11004 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11005 | QEvent event(QEvent::MacSizeChange); | - | ||||||||||||||||||||||||||||||||||||
11006 | QApplication::sendEvent(q, &event); | - | ||||||||||||||||||||||||||||||||||||
11007 | for (int i = 0; i < children.size(); ++i) { | - | ||||||||||||||||||||||||||||||||||||
11008 | QWidget *w = qobject_cast<QWidget *>(children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
11009 | if (w && (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation)) | - | ||||||||||||||||||||||||||||||||||||
11010 | && !q->testAttribute(Qt::WA_MacMiniSize) // no attribute set? inherit from parent | - | ||||||||||||||||||||||||||||||||||||
11011 | && !w->testAttribute(Qt::WA_MacSmallSize) | - | ||||||||||||||||||||||||||||||||||||
11012 | && !w->testAttribute(Qt::WA_MacNormalSize)) | - | ||||||||||||||||||||||||||||||||||||
11013 | w->d_func()->macUpdateSizeAttribute(); | - | ||||||||||||||||||||||||||||||||||||
11014 | } | - | ||||||||||||||||||||||||||||||||||||
11015 | resolveFont(); | - | ||||||||||||||||||||||||||||||||||||
11016 | } | - | ||||||||||||||||||||||||||||||||||||
11017 | #endif | - | ||||||||||||||||||||||||||||||||||||
11018 | - | |||||||||||||||||||||||||||||||||||||
11019 | /*! | - | ||||||||||||||||||||||||||||||||||||
11020 | Sets the attribute \a attribute on this widget if \a on is true; | - | ||||||||||||||||||||||||||||||||||||
11021 | otherwise clears the attribute. | - | ||||||||||||||||||||||||||||||||||||
11022 | - | |||||||||||||||||||||||||||||||||||||
11023 | \sa testAttribute() | - | ||||||||||||||||||||||||||||||||||||
11024 | */ | - | ||||||||||||||||||||||||||||||||||||
11025 | void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) | - | ||||||||||||||||||||||||||||||||||||
11026 | { | - | ||||||||||||||||||||||||||||||||||||
11027 | if (testAttribute(attribute) == on)
| 0 | ||||||||||||||||||||||||||||||||||||
11028 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11029 | - | |||||||||||||||||||||||||||||||||||||
11030 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11031 | Q_STATIC_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8), | - | ||||||||||||||||||||||||||||||||||||
11032 | "QWidget::setAttribute(WidgetAttribute, bool): " | - | ||||||||||||||||||||||||||||||||||||
11033 | "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute"); | - | ||||||||||||||||||||||||||||||||||||
11034 | #ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
11035 | // ### Don't use PaintOnScreen+paintEngine() to do native painting in some future release | - | ||||||||||||||||||||||||||||||||||||
11036 | if (attribute == Qt::WA_PaintOnScreen && on && windowType() != Qt::Desktop && !inherits("QGLWidget")) { | - | ||||||||||||||||||||||||||||||||||||
11037 | // see ::paintEngine for details | - | ||||||||||||||||||||||||||||||||||||
11038 | paintEngine(); | - | ||||||||||||||||||||||||||||||||||||
11039 | if (d->noPaintOnScreen) | - | ||||||||||||||||||||||||||||||||||||
11040 | return; | - | ||||||||||||||||||||||||||||||||||||
11041 | } | - | ||||||||||||||||||||||||||||||||||||
11042 | #endif | - | ||||||||||||||||||||||||||||||||||||
11043 | - | |||||||||||||||||||||||||||||||||||||
11044 | // Don't set WA_NativeWindow on platforms that don't support it -- except for QGLWidget, which depends on it | - | ||||||||||||||||||||||||||||||||||||
11045 | if (attribute == Qt::WA_NativeWindow && !d->mustHaveWindowHandle) {
| 0 | ||||||||||||||||||||||||||||||||||||
11046 | QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); | - | ||||||||||||||||||||||||||||||||||||
11047 | if (!platformIntegration->hasCapability(QPlatformIntegration::NativeWidgets))
| 0 | ||||||||||||||||||||||||||||||||||||
11048 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11049 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11050 | - | |||||||||||||||||||||||||||||||||||||
11051 | setAttribute_internal(attribute, on, data, d); | - | ||||||||||||||||||||||||||||||||||||
11052 | - | |||||||||||||||||||||||||||||||||||||
11053 | switch (attribute) { | - | ||||||||||||||||||||||||||||||||||||
11054 | - | |||||||||||||||||||||||||||||||||||||
11055 | #ifndef QT_NO_DRAGANDDROP | - | ||||||||||||||||||||||||||||||||||||
11056 | case Qt::WA_AcceptDrops: { never executed: case Qt::WA_AcceptDrops: | 0 | ||||||||||||||||||||||||||||||||||||
11057 | if (on && !testAttribute(Qt::WA_DropSiteRegistered))
| 0 | ||||||||||||||||||||||||||||||||||||
11058 | setAttribute(Qt::WA_DropSiteRegistered, true); never executed: setAttribute(Qt::WA_DropSiteRegistered, true); | 0 | ||||||||||||||||||||||||||||||||||||
11059 | else if (!on && (isWindow() || !parentWidget() || !parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)))
| 0 | ||||||||||||||||||||||||||||||||||||
11060 | setAttribute(Qt::WA_DropSiteRegistered, false); never executed: setAttribute(Qt::WA_DropSiteRegistered, false); | 0 | ||||||||||||||||||||||||||||||||||||
11061 | QEvent e(QEvent::AcceptDropsChange); | - | ||||||||||||||||||||||||||||||||||||
11062 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
11063 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11064 | } | - | ||||||||||||||||||||||||||||||||||||
11065 | case Qt::WA_DropSiteRegistered: { never executed: case Qt::WA_DropSiteRegistered: | 0 | ||||||||||||||||||||||||||||||||||||
11066 | d->registerDropSite(on); | - | ||||||||||||||||||||||||||||||||||||
11067 | for (int i = 0; i < d->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
11068 | QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
11069 | if (w && !w->isWindow() && !w->testAttribute(Qt::WA_AcceptDrops) && w->testAttribute(Qt::WA_DropSiteRegistered) != on)
| 0 | ||||||||||||||||||||||||||||||||||||
11070 | w->setAttribute(Qt::WA_DropSiteRegistered, on); never executed: w->setAttribute(Qt::WA_DropSiteRegistered, on); | 0 | ||||||||||||||||||||||||||||||||||||
11071 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11072 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11073 | } | - | ||||||||||||||||||||||||||||||||||||
11074 | #endif | - | ||||||||||||||||||||||||||||||||||||
11075 | - | |||||||||||||||||||||||||||||||||||||
11076 | case Qt::WA_NoChildEventsForParent: never executed: case Qt::WA_NoChildEventsForParent: | 0 | ||||||||||||||||||||||||||||||||||||
11077 | d->sendChildEvents = !on; | - | ||||||||||||||||||||||||||||||||||||
11078 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11079 | case Qt::WA_NoChildEventsFromChildren: never executed: case Qt::WA_NoChildEventsFromChildren: | 0 | ||||||||||||||||||||||||||||||||||||
11080 | d->receiveChildEvents = !on; | - | ||||||||||||||||||||||||||||||||||||
11081 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11082 | case Qt::WA_MacBrushedMetal: never executed: case Qt::WA_MacBrushedMetal: | 0 | ||||||||||||||||||||||||||||||||||||
11083 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
11084 | d->setStyle_helper(style(), false, true); // Make sure things get unpolished/polished correctly. | - | ||||||||||||||||||||||||||||||||||||
11085 | // fall through since changing the metal attribute affects the opaque size grip. | - | ||||||||||||||||||||||||||||||||||||
11086 | case Qt::WA_MacOpaqueSizeGrip: | - | ||||||||||||||||||||||||||||||||||||
11087 | d->macUpdateOpaqueSizeGrip(); | - | ||||||||||||||||||||||||||||||||||||
11088 | break; | - | ||||||||||||||||||||||||||||||||||||
11089 | case Qt::WA_MacShowFocusRect: | - | ||||||||||||||||||||||||||||||||||||
11090 | if (hasFocus()) { | - | ||||||||||||||||||||||||||||||||||||
11091 | clearFocus(); | - | ||||||||||||||||||||||||||||||||||||
11092 | setFocus(); | - | ||||||||||||||||||||||||||||||||||||
11093 | } | - | ||||||||||||||||||||||||||||||||||||
11094 | break; | - | ||||||||||||||||||||||||||||||||||||
11095 | case Qt::WA_Hover: | - | ||||||||||||||||||||||||||||||||||||
11096 | qt_mac_update_mouseTracking(this); | - | ||||||||||||||||||||||||||||||||||||
11097 | break; | - | ||||||||||||||||||||||||||||||||||||
11098 | #endif | - | ||||||||||||||||||||||||||||||||||||
11099 | case Qt::WA_MacAlwaysShowToolWindow: never executed: case Qt::WA_MacAlwaysShowToolWindow: | 0 | ||||||||||||||||||||||||||||||||||||
11100 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
11101 | d->macUpdateHideOnSuspend(); | - | ||||||||||||||||||||||||||||||||||||
11102 | #endif | - | ||||||||||||||||||||||||||||||||||||
11103 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11104 | case Qt::WA_MacNormalSize: never executed: case Qt::WA_MacNormalSize: | 0 | ||||||||||||||||||||||||||||||||||||
11105 | case Qt::WA_MacSmallSize: never executed: case Qt::WA_MacSmallSize: | 0 | ||||||||||||||||||||||||||||||||||||
11106 | case Qt::WA_MacMiniSize: never executed: case Qt::WA_MacMiniSize: | 0 | ||||||||||||||||||||||||||||||||||||
11107 | #ifdef Q_OS_MAC | - | ||||||||||||||||||||||||||||||||||||
11108 | { | - | ||||||||||||||||||||||||||||||||||||
11109 | // We can only have one of these set at a time | - | ||||||||||||||||||||||||||||||||||||
11110 | const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize, | - | ||||||||||||||||||||||||||||||||||||
11111 | Qt::WA_MacMiniSize }; | - | ||||||||||||||||||||||||||||||||||||
11112 | for (int i = 0; i < 3; ++i) { | - | ||||||||||||||||||||||||||||||||||||
11113 | if (MacSizes[i] != attribute) | - | ||||||||||||||||||||||||||||||||||||
11114 | setAttribute_internal(MacSizes[i], false, data, d); | - | ||||||||||||||||||||||||||||||||||||
11115 | } | - | ||||||||||||||||||||||||||||||||||||
11116 | d->macUpdateSizeAttribute(); | - | ||||||||||||||||||||||||||||||||||||
11117 | } | - | ||||||||||||||||||||||||||||||||||||
11118 | #endif | - | ||||||||||||||||||||||||||||||||||||
11119 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11120 | case Qt::WA_ShowModal: never executed: case Qt::WA_ShowModal: | 0 | ||||||||||||||||||||||||||||||||||||
11121 | if (!on) {
| 0 | ||||||||||||||||||||||||||||||||||||
11122 | // reset modality type to NonModal when clearing WA_ShowModal | - | ||||||||||||||||||||||||||||||||||||
11123 | data->window_modality = Qt::NonModal; | - | ||||||||||||||||||||||||||||||||||||
11124 | } else if (data->window_modality == Qt::NonModal) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
11125 | // determine the modality type if it hasn't been set prior | - | ||||||||||||||||||||||||||||||||||||
11126 | // to setting WA_ShowModal. set the default to WindowModal | - | ||||||||||||||||||||||||||||||||||||
11127 | // if we are the child of a group leader; otherwise use | - | ||||||||||||||||||||||||||||||||||||
11128 | // ApplicationModal. | - | ||||||||||||||||||||||||||||||||||||
11129 | QWidget *w = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
11130 | if (w)
| 0 | ||||||||||||||||||||||||||||||||||||
11131 | w = w->window(); never executed: w = w->window(); | 0 | ||||||||||||||||||||||||||||||||||||
11132 | while (w && !w->testAttribute(Qt::WA_GroupLeader)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11133 | w = w->parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
11134 | if (w)
| 0 | ||||||||||||||||||||||||||||||||||||
11135 | w = w->window(); never executed: w = w->window(); | 0 | ||||||||||||||||||||||||||||||||||||
11136 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11137 | data->window_modality = (w && w->testAttribute(Qt::WA_GroupLeader))
| 0 | ||||||||||||||||||||||||||||||||||||
11138 | ? Qt::WindowModal | - | ||||||||||||||||||||||||||||||||||||
11139 | : Qt::ApplicationModal; | - | ||||||||||||||||||||||||||||||||||||
11140 | // Some window managers do not allow us to enter modality after the | - | ||||||||||||||||||||||||||||||||||||
11141 | // window is visible.The window must be hidden before changing the | - | ||||||||||||||||||||||||||||||||||||
11142 | // windowModality property and then reshown. | - | ||||||||||||||||||||||||||||||||||||
11143 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11144 | if (testAttribute(Qt::WA_WState_Created)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11145 | // don't call setModal_sys() before create_sys() | - | ||||||||||||||||||||||||||||||||||||
11146 | d->setModal_sys(); | - | ||||||||||||||||||||||||||||||||||||
11147 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11148 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11149 | case Qt::WA_MouseTracking: { never executed: case Qt::WA_MouseTracking: | 0 | ||||||||||||||||||||||||||||||||||||
11150 | QEvent e(QEvent::MouseTrackingChange); | - | ||||||||||||||||||||||||||||||||||||
11151 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
11152 | break; } never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11153 | case Qt::WA_NativeWindow: { never executed: case Qt::WA_NativeWindow: | 0 | ||||||||||||||||||||||||||||||||||||
11154 | d->createTLExtra(); | - | ||||||||||||||||||||||||||||||||||||
11155 | if (on)
| 0 | ||||||||||||||||||||||||||||||||||||
11156 | d->createTLSysExtra(); never executed: d->createTLSysExtra(); | 0 | ||||||||||||||||||||||||||||||||||||
11157 | #ifndef QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
11158 | QWidget *focusWidget = d->effectiveFocusWidget(); | - | ||||||||||||||||||||||||||||||||||||
11159 | if (on && !internalWinId() && this == QGuiApplication::focusObject()
| 0 | ||||||||||||||||||||||||||||||||||||
11160 | && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11161 | QGuiApplication::inputMethod()->commit(); | - | ||||||||||||||||||||||||||||||||||||
11162 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); | - | ||||||||||||||||||||||||||||||||||||
11163 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11164 | if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
11165 | parentWidget()->d_func()->enforceNativeChildren(); never executed: parentWidget()->d_func()->enforceNativeChildren(); | 0 | ||||||||||||||||||||||||||||||||||||
11166 | if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11167 | d->createWinId(); never executed: d->createWinId(); | 0 | ||||||||||||||||||||||||||||||||||||
11168 | if (isEnabled() && focusWidget->isEnabled() && this == QGuiApplication::focusObject()
| 0 | ||||||||||||||||||||||||||||||||||||
11169 | && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11170 | QGuiApplication::inputMethod()->update(Qt::ImEnabled); | - | ||||||||||||||||||||||||||||||||||||
11171 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11172 | #endif //QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
11173 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11174 | } | - | ||||||||||||||||||||||||||||||||||||
11175 | case Qt::WA_PaintOnScreen: never executed: case Qt::WA_PaintOnScreen: | 0 | ||||||||||||||||||||||||||||||||||||
11176 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
11177 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_X11) || defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
11178 | // Recreate the widget if it's already created as an alien widget and | - | ||||||||||||||||||||||||||||||||||||
11179 | // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id. | - | ||||||||||||||||||||||||||||||||||||
11180 | // So must their children. | - | ||||||||||||||||||||||||||||||||||||
11181 | if (on) { | - | ||||||||||||||||||||||||||||||||||||
11182 | setAttribute(Qt::WA_NativeWindow); | - | ||||||||||||||||||||||||||||||||||||
11183 | d->enforceNativeChildren(); | - | ||||||||||||||||||||||||||||||||||||
11184 | } | - | ||||||||||||||||||||||||||||||||||||
11185 | #endif | - | ||||||||||||||||||||||||||||||||||||
11186 | // fall through | - | ||||||||||||||||||||||||||||||||||||
11187 | case Qt::WA_OpaquePaintEvent: code before this statement never executed: case Qt::WA_OpaquePaintEvent: never executed: case Qt::WA_OpaquePaintEvent: | 0 | ||||||||||||||||||||||||||||||||||||
11188 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
11189 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11190 | case Qt::WA_NoSystemBackground: never executed: case Qt::WA_NoSystemBackground: | 0 | ||||||||||||||||||||||||||||||||||||
11191 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
11192 | // fall through... | - | ||||||||||||||||||||||||||||||||||||
11193 | case Qt::WA_UpdatesDisabled: code before this statement never executed: case Qt::WA_UpdatesDisabled: never executed: case Qt::WA_UpdatesDisabled: | 0 | ||||||||||||||||||||||||||||||||||||
11194 | d->updateSystemBackground(); | - | ||||||||||||||||||||||||||||||||||||
11195 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11196 | case Qt::WA_TransparentForMouseEvents: never executed: case Qt::WA_TransparentForMouseEvents: | 0 | ||||||||||||||||||||||||||||||||||||
11197 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
11198 | d->macUpdateIgnoreMouseEvents(); | - | ||||||||||||||||||||||||||||||||||||
11199 | #endif | - | ||||||||||||||||||||||||||||||||||||
11200 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11201 | case Qt::WA_InputMethodEnabled: { never executed: case Qt::WA_InputMethodEnabled: | 0 | ||||||||||||||||||||||||||||||||||||
11202 | #ifndef QT_NO_IM | - | ||||||||||||||||||||||||||||||||||||
11203 | if (QGuiApplication::focusObject() == this) {
| 0 | ||||||||||||||||||||||||||||||||||||
11204 | if (!on)
| 0 | ||||||||||||||||||||||||||||||||||||
11205 | QGuiApplication::inputMethod()->commit(); never executed: QGuiApplication::inputMethod()->commit(); | 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_WindowPropagation: never executed: case Qt::WA_WindowPropagation: | 0 | ||||||||||||||||||||||||||||||||||||
11212 | d->resolvePalette(); | - | ||||||||||||||||||||||||||||||||||||
11213 | d->resolveFont(); | - | ||||||||||||||||||||||||||||||||||||
11214 | d->resolveLocale(); | - | ||||||||||||||||||||||||||||||||||||
11215 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11216 | #ifdef Q_DEAD_CODE_FROM_QT4_X11 | - | ||||||||||||||||||||||||||||||||||||
11217 | case Qt::WA_NoX11EventCompression: | - | ||||||||||||||||||||||||||||||||||||
11218 | if (!d->extra) | - | ||||||||||||||||||||||||||||||||||||
11219 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
11220 | d->extra->compress_events = on; | - | ||||||||||||||||||||||||||||||||||||
11221 | break; | - | ||||||||||||||||||||||||||||||||||||
11222 | case Qt::WA_X11OpenGLOverlay: | - | ||||||||||||||||||||||||||||||||||||
11223 | d->updateIsOpaque(); | - | ||||||||||||||||||||||||||||||||||||
11224 | break; | - | ||||||||||||||||||||||||||||||||||||
11225 | case Qt::WA_X11DoNotAcceptFocus: | - | ||||||||||||||||||||||||||||||||||||
11226 | if (testAttribute(Qt::WA_WState_Created)) | - | ||||||||||||||||||||||||||||||||||||
11227 | d->updateX11AcceptFocus(); | - | ||||||||||||||||||||||||||||||||||||
11228 | break; | - | ||||||||||||||||||||||||||||||||||||
11229 | #endif | - | ||||||||||||||||||||||||||||||||||||
11230 | case Qt::WA_DontShowOnScreen: { never executed: case Qt::WA_DontShowOnScreen: | 0 | ||||||||||||||||||||||||||||||||||||
11231 | if (on && isVisible()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11232 | // Make sure we keep the current state and only hide the widget | - | ||||||||||||||||||||||||||||||||||||
11233 | // from the desktop. show_sys will only update platform specific | - | ||||||||||||||||||||||||||||||||||||
11234 | // attributes at this point. | - | ||||||||||||||||||||||||||||||||||||
11235 | d->hide_sys(); | - | ||||||||||||||||||||||||||||||||||||
11236 | d->show_sys(); | - | ||||||||||||||||||||||||||||||||||||
11237 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11238 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11239 | } | - | ||||||||||||||||||||||||||||||||||||
11240 | - | |||||||||||||||||||||||||||||||||||||
11241 | case Qt::WA_X11NetWmWindowTypeDesktop: never executed: case Qt::WA_X11NetWmWindowTypeDesktop: | 0 | ||||||||||||||||||||||||||||||||||||
11242 | case Qt::WA_X11NetWmWindowTypeDock: never executed: case Qt::WA_X11NetWmWindowTypeDock: | 0 | ||||||||||||||||||||||||||||||||||||
11243 | case Qt::WA_X11NetWmWindowTypeToolBar: never executed: case Qt::WA_X11NetWmWindowTypeToolBar: | 0 | ||||||||||||||||||||||||||||||||||||
11244 | case Qt::WA_X11NetWmWindowTypeMenu: never executed: case Qt::WA_X11NetWmWindowTypeMenu: | 0 | ||||||||||||||||||||||||||||||||||||
11245 | case Qt::WA_X11NetWmWindowTypeUtility: never executed: case Qt::WA_X11NetWmWindowTypeUtility: | 0 | ||||||||||||||||||||||||||||||||||||
11246 | case Qt::WA_X11NetWmWindowTypeSplash: never executed: case Qt::WA_X11NetWmWindowTypeSplash: | 0 | ||||||||||||||||||||||||||||||||||||
11247 | case Qt::WA_X11NetWmWindowTypeDialog: never executed: case Qt::WA_X11NetWmWindowTypeDialog: | 0 | ||||||||||||||||||||||||||||||||||||
11248 | case Qt::WA_X11NetWmWindowTypeDropDownMenu: never executed: case Qt::WA_X11NetWmWindowTypeDropDownMenu: | 0 | ||||||||||||||||||||||||||||||||||||
11249 | case Qt::WA_X11NetWmWindowTypePopupMenu: never executed: case Qt::WA_X11NetWmWindowTypePopupMenu: | 0 | ||||||||||||||||||||||||||||||||||||
11250 | case Qt::WA_X11NetWmWindowTypeToolTip: never executed: case Qt::WA_X11NetWmWindowTypeToolTip: | 0 | ||||||||||||||||||||||||||||||||||||
11251 | case Qt::WA_X11NetWmWindowTypeNotification: never executed: case Qt::WA_X11NetWmWindowTypeNotification: | 0 | ||||||||||||||||||||||||||||||||||||
11252 | case Qt::WA_X11NetWmWindowTypeCombo: never executed: case Qt::WA_X11NetWmWindowTypeCombo: | 0 | ||||||||||||||||||||||||||||||||||||
11253 | case Qt::WA_X11NetWmWindowTypeDND: never executed: case Qt::WA_X11NetWmWindowTypeDND: | 0 | ||||||||||||||||||||||||||||||||||||
11254 | d->setNetWmWindowTypes(); | - | ||||||||||||||||||||||||||||||||||||
11255 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11256 | - | |||||||||||||||||||||||||||||||||||||
11257 | case Qt::WA_StaticContents: never executed: case Qt::WA_StaticContents: | 0 | ||||||||||||||||||||||||||||||||||||
11258 | if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11259 | if (on)
| 0 | ||||||||||||||||||||||||||||||||||||
11260 | bs->addStaticWidget(this); never executed: bs->addStaticWidget(this); | 0 | ||||||||||||||||||||||||||||||||||||
11261 | else | - | ||||||||||||||||||||||||||||||||||||
11262 | bs->removeStaticWidget(this); never executed: bs->removeStaticWidget(this); | 0 | ||||||||||||||||||||||||||||||||||||
11263 | } | - | ||||||||||||||||||||||||||||||||||||
11264 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11265 | case Qt::WA_TranslucentBackground: never executed: case Qt::WA_TranslucentBackground: | 0 | ||||||||||||||||||||||||||||||||||||
11266 | if (on) {
| 0 | ||||||||||||||||||||||||||||||||||||
11267 | setAttribute(Qt::WA_NoSystemBackground); | - | ||||||||||||||||||||||||||||||||||||
11268 | d->updateIsTranslucent(); | - | ||||||||||||||||||||||||||||||||||||
11269 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11270 | - | |||||||||||||||||||||||||||||||||||||
11271 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11272 | case Qt::WA_AcceptTouchEvents: never executed: case Qt::WA_AcceptTouchEvents: | 0 | ||||||||||||||||||||||||||||||||||||
11273 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_MAC) | - | ||||||||||||||||||||||||||||||||||||
11274 | if (on) | - | ||||||||||||||||||||||||||||||||||||
11275 | d->registerTouchWindow(); | - | ||||||||||||||||||||||||||||||||||||
11276 | #endif | - | ||||||||||||||||||||||||||||||||||||
11277 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11278 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
11279 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
11280 | } | - | ||||||||||||||||||||||||||||||||||||
11281 | } | - | ||||||||||||||||||||||||||||||||||||
11282 | - | |||||||||||||||||||||||||||||||||||||
11283 | /*! \fn bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const | - | ||||||||||||||||||||||||||||||||||||
11284 | - | |||||||||||||||||||||||||||||||||||||
11285 | Returns \c true if attribute \a attribute is set on this widget; | - | ||||||||||||||||||||||||||||||||||||
11286 | otherwise returns \c false. | - | ||||||||||||||||||||||||||||||||||||
11287 | - | |||||||||||||||||||||||||||||||||||||
11288 | \sa setAttribute() | - | ||||||||||||||||||||||||||||||||||||
11289 | */ | - | ||||||||||||||||||||||||||||||||||||
11290 | bool QWidget::testAttribute_helper(Qt::WidgetAttribute attribute) const | - | ||||||||||||||||||||||||||||||||||||
11291 | { | - | ||||||||||||||||||||||||||||||||||||
11292 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11293 | const int x = attribute - 8*sizeof(uint); | - | ||||||||||||||||||||||||||||||||||||
11294 | const int int_off = x / (8*sizeof(uint)); | - | ||||||||||||||||||||||||||||||||||||
11295 | 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 | ||||||||||||||||||||||||||||||||||||
11296 | } | - | ||||||||||||||||||||||||||||||||||||
11297 | - | |||||||||||||||||||||||||||||||||||||
11298 | /*! | - | ||||||||||||||||||||||||||||||||||||
11299 | \property QWidget::windowOpacity | - | ||||||||||||||||||||||||||||||||||||
11300 | - | |||||||||||||||||||||||||||||||||||||
11301 | \brief The level of opacity for the window. | - | ||||||||||||||||||||||||||||||||||||
11302 | - | |||||||||||||||||||||||||||||||||||||
11303 | The valid range of opacity is from 1.0 (completely opaque) to | - | ||||||||||||||||||||||||||||||||||||
11304 | 0.0 (completely transparent). | - | ||||||||||||||||||||||||||||||||||||
11305 | - | |||||||||||||||||||||||||||||||||||||
11306 | By default the value of this property is 1.0. | - | ||||||||||||||||||||||||||||||||||||
11307 | - | |||||||||||||||||||||||||||||||||||||
11308 | This feature is available on Embedded Linux, \macos, Windows, | - | ||||||||||||||||||||||||||||||||||||
11309 | and X11 platforms that support the Composite extension. | - | ||||||||||||||||||||||||||||||||||||
11310 | - | |||||||||||||||||||||||||||||||||||||
11311 | This feature is not available on Windows CE. | - | ||||||||||||||||||||||||||||||||||||
11312 | - | |||||||||||||||||||||||||||||||||||||
11313 | Note that under X11 you need to have a composite manager running, | - | ||||||||||||||||||||||||||||||||||||
11314 | and the X11 specific _NET_WM_WINDOW_OPACITY atom needs to be | - | ||||||||||||||||||||||||||||||||||||
11315 | supported by the window manager you are using. | - | ||||||||||||||||||||||||||||||||||||
11316 | - | |||||||||||||||||||||||||||||||||||||
11317 | \warning Changing this property from opaque to transparent might issue a | - | ||||||||||||||||||||||||||||||||||||
11318 | paint event that needs to be processed before the window is displayed | - | ||||||||||||||||||||||||||||||||||||
11319 | correctly. This affects mainly the use of QPixmap::grabWindow(). Also note | - | ||||||||||||||||||||||||||||||||||||
11320 | that semi-transparent windows update and resize significantly slower than | - | ||||||||||||||||||||||||||||||||||||
11321 | opaque windows. | - | ||||||||||||||||||||||||||||||||||||
11322 | - | |||||||||||||||||||||||||||||||||||||
11323 | \sa setMask() | - | ||||||||||||||||||||||||||||||||||||
11324 | */ | - | ||||||||||||||||||||||||||||||||||||
11325 | qreal QWidget::windowOpacity() const | - | ||||||||||||||||||||||||||||||||||||
11326 | { | - | ||||||||||||||||||||||||||||||||||||
11327 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11328 | return (isWindow() && d->maybeTopData()) ? d->maybeTopData()->opacity / 255. : 1.0; never executed: return (isWindow() && d->maybeTopData()) ? d->maybeTopData()->opacity / 255. : 1.0;
| 0 | ||||||||||||||||||||||||||||||||||||
11329 | } | - | ||||||||||||||||||||||||||||||||||||
11330 | - | |||||||||||||||||||||||||||||||||||||
11331 | void QWidget::setWindowOpacity(qreal opacity) | - | ||||||||||||||||||||||||||||||||||||
11332 | { | - | ||||||||||||||||||||||||||||||||||||
11333 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11334 | if (!isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
11335 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11336 | - | |||||||||||||||||||||||||||||||||||||
11337 | opacity = qBound(qreal(0.0), opacity, qreal(1.0)); | - | ||||||||||||||||||||||||||||||||||||
11338 | QTLWExtra *extra = d->topData(); | - | ||||||||||||||||||||||||||||||||||||
11339 | extra->opacity = uint(opacity * 255); | - | ||||||||||||||||||||||||||||||||||||
11340 | setAttribute(Qt::WA_WState_WindowOpacitySet); | - | ||||||||||||||||||||||||||||||||||||
11341 | d->setWindowOpacity_sys(opacity); | - | ||||||||||||||||||||||||||||||||||||
11342 | - | |||||||||||||||||||||||||||||||||||||
11343 | if (!testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11344 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11345 | - | |||||||||||||||||||||||||||||||||||||
11346 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
11347 | if (QGraphicsProxyWidget *proxy = graphicsProxyWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11348 | // Avoid invalidating the cache if set. | - | ||||||||||||||||||||||||||||||||||||
11349 | if (proxy->cacheMode() == QGraphicsItem::NoCache)
| 0 | ||||||||||||||||||||||||||||||||||||
11350 | proxy->update(); never executed: proxy->update(); | 0 | ||||||||||||||||||||||||||||||||||||
11351 | else if (QGraphicsScene *scene = proxy->scene())
| 0 | ||||||||||||||||||||||||||||||||||||
11352 | scene->update(proxy->sceneBoundingRect()); never executed: scene->update(proxy->sceneBoundingRect()); | 0 | ||||||||||||||||||||||||||||||||||||
11353 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11354 | } | - | ||||||||||||||||||||||||||||||||||||
11355 | #endif | - | ||||||||||||||||||||||||||||||||||||
11356 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11357 | - | |||||||||||||||||||||||||||||||||||||
11358 | void QWidgetPrivate::setWindowOpacity_sys(qreal level) | - | ||||||||||||||||||||||||||||||||||||
11359 | { | - | ||||||||||||||||||||||||||||||||||||
11360 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11361 | if (q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
11362 | q->windowHandle()->setOpacity(level); never executed: q->windowHandle()->setOpacity(level); | 0 | ||||||||||||||||||||||||||||||||||||
11363 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11364 | - | |||||||||||||||||||||||||||||||||||||
11365 | /*! | - | ||||||||||||||||||||||||||||||||||||
11366 | \property QWidget::windowModified | - | ||||||||||||||||||||||||||||||||||||
11367 | \brief whether the document shown in the window has unsaved changes | - | ||||||||||||||||||||||||||||||||||||
11368 | - | |||||||||||||||||||||||||||||||||||||
11369 | A modified window is a window whose content has changed but has | - | ||||||||||||||||||||||||||||||||||||
11370 | not been saved to disk. This flag will have different effects | - | ||||||||||||||||||||||||||||||||||||
11371 | varied by the platform. On \macos the close button will have a | - | ||||||||||||||||||||||||||||||||||||
11372 | modified look; on other platforms, the window title will have an | - | ||||||||||||||||||||||||||||||||||||
11373 | '*' (asterisk). | - | ||||||||||||||||||||||||||||||||||||
11374 | - | |||||||||||||||||||||||||||||||||||||
11375 | The window title must contain a "[*]" placeholder, which | - | ||||||||||||||||||||||||||||||||||||
11376 | indicates where the '*' should appear. Normally, it should appear | - | ||||||||||||||||||||||||||||||||||||
11377 | right after the file name (e.g., "document1.txt[*] - Text | - | ||||||||||||||||||||||||||||||||||||
11378 | Editor"). If the window isn't modified, the placeholder is simply | - | ||||||||||||||||||||||||||||||||||||
11379 | removed. | - | ||||||||||||||||||||||||||||||||||||
11380 | - | |||||||||||||||||||||||||||||||||||||
11381 | Note that if a widget is set as modified, all its ancestors will | - | ||||||||||||||||||||||||||||||||||||
11382 | also be set as modified. However, if you call \c | - | ||||||||||||||||||||||||||||||||||||
11383 | {setWindowModified(false)} on a widget, this will not propagate to | - | ||||||||||||||||||||||||||||||||||||
11384 | its parent because other children of the parent might have been | - | ||||||||||||||||||||||||||||||||||||
11385 | modified. | - | ||||||||||||||||||||||||||||||||||||
11386 | - | |||||||||||||||||||||||||||||||||||||
11387 | \sa windowTitle, {Application Example}, {SDI Example}, {MDI Example} | - | ||||||||||||||||||||||||||||||||||||
11388 | */ | - | ||||||||||||||||||||||||||||||||||||
11389 | bool QWidget::isWindowModified() const | - | ||||||||||||||||||||||||||||||||||||
11390 | { | - | ||||||||||||||||||||||||||||||||||||
11391 | return testAttribute(Qt::WA_WindowModified); never executed: return testAttribute(Qt::WA_WindowModified); | 0 | ||||||||||||||||||||||||||||||||||||
11392 | } | - | ||||||||||||||||||||||||||||||||||||
11393 | - | |||||||||||||||||||||||||||||||||||||
11394 | void QWidget::setWindowModified(bool mod) | - | ||||||||||||||||||||||||||||||||||||
11395 | { | - | ||||||||||||||||||||||||||||||||||||
11396 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11397 | setAttribute(Qt::WA_WindowModified, mod); | - | ||||||||||||||||||||||||||||||||||||
11398 | - | |||||||||||||||||||||||||||||||||||||
11399 | d->setWindowModified_helper(); | - | ||||||||||||||||||||||||||||||||||||
11400 | - | |||||||||||||||||||||||||||||||||||||
11401 | QEvent e(QEvent::ModifiedChange); | - | ||||||||||||||||||||||||||||||||||||
11402 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
11403 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11404 | - | |||||||||||||||||||||||||||||||||||||
11405 | void QWidgetPrivate::setWindowModified_helper() | - | ||||||||||||||||||||||||||||||||||||
11406 | { | - | ||||||||||||||||||||||||||||||||||||
11407 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11408 | QWindow *window = q->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
11409 | if (!window)
| 0 | ||||||||||||||||||||||||||||||||||||
11410 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11411 | QPlatformWindow *platformWindow = window->handle(); | - | ||||||||||||||||||||||||||||||||||||
11412 | if (!platformWindow)
| 0 | ||||||||||||||||||||||||||||||||||||
11413 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11414 | bool on = q->testAttribute(Qt::WA_WindowModified); | - | ||||||||||||||||||||||||||||||||||||
11415 | if (!platformWindow->setWindowModified(on)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11416 | if (!q->windowTitle().contains(QLatin1String("[*]")) && on)
| 0 | ||||||||||||||||||||||||||||||||||||
11417 | qWarning("QWidget::setWindowModified: The window title does not contain a '[*]' placeholder"); never executed: QMessageLogger(__FILE__, 11417, __PRETTY_FUNCTION__).warning("QWidget::setWindowModified: The window title does not contain a '[*]' placeholder"); | 0 | ||||||||||||||||||||||||||||||||||||
11418 | setWindowTitle_helper(q->windowTitle()); | - | ||||||||||||||||||||||||||||||||||||
11419 | setWindowIconText_helper(q->windowIconText()); | - | ||||||||||||||||||||||||||||||||||||
11420 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11421 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11422 | - | |||||||||||||||||||||||||||||||||||||
11423 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||||||||||||||
11424 | /*! | - | ||||||||||||||||||||||||||||||||||||
11425 | \property QWidget::toolTip | - | ||||||||||||||||||||||||||||||||||||
11426 | - | |||||||||||||||||||||||||||||||||||||
11427 | \brief the widget's tooltip | - | ||||||||||||||||||||||||||||||||||||
11428 | - | |||||||||||||||||||||||||||||||||||||
11429 | Note that by default tooltips are only shown for widgets that are | - | ||||||||||||||||||||||||||||||||||||
11430 | children of the active window. You can change this behavior by | - | ||||||||||||||||||||||||||||||||||||
11431 | setting the attribute Qt::WA_AlwaysShowToolTips on the \e window, | - | ||||||||||||||||||||||||||||||||||||
11432 | not on the widget with the tooltip. | - | ||||||||||||||||||||||||||||||||||||
11433 | - | |||||||||||||||||||||||||||||||||||||
11434 | If you want to control a tooltip's behavior, you can intercept the | - | ||||||||||||||||||||||||||||||||||||
11435 | event() function and catch the QEvent::ToolTip event (e.g., if you | - | ||||||||||||||||||||||||||||||||||||
11436 | want to customize the area for which the tooltip should be shown). | - | ||||||||||||||||||||||||||||||||||||
11437 | - | |||||||||||||||||||||||||||||||||||||
11438 | By default, this property contains an empty string. | - | ||||||||||||||||||||||||||||||||||||
11439 | - | |||||||||||||||||||||||||||||||||||||
11440 | \sa QToolTip, statusTip, whatsThis | - | ||||||||||||||||||||||||||||||||||||
11441 | */ | - | ||||||||||||||||||||||||||||||||||||
11442 | void QWidget::setToolTip(const QString &s) | - | ||||||||||||||||||||||||||||||||||||
11443 | { | - | ||||||||||||||||||||||||||||||||||||
11444 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11445 | d->toolTip = s; | - | ||||||||||||||||||||||||||||||||||||
11446 | - | |||||||||||||||||||||||||||||||||||||
11447 | QEvent event(QEvent::ToolTipChange); | - | ||||||||||||||||||||||||||||||||||||
11448 | QApplication::sendEvent(this, &event); | - | ||||||||||||||||||||||||||||||||||||
11449 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11450 | - | |||||||||||||||||||||||||||||||||||||
11451 | QString QWidget::toolTip() const | - | ||||||||||||||||||||||||||||||||||||
11452 | { | - | ||||||||||||||||||||||||||||||||||||
11453 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11454 | return d->toolTip; never executed: return d->toolTip; | 0 | ||||||||||||||||||||||||||||||||||||
11455 | } | - | ||||||||||||||||||||||||||||||||||||
11456 | - | |||||||||||||||||||||||||||||||||||||
11457 | /*! | - | ||||||||||||||||||||||||||||||||||||
11458 | \property QWidget::toolTipDuration | - | ||||||||||||||||||||||||||||||||||||
11459 | \brief the widget's tooltip duration | - | ||||||||||||||||||||||||||||||||||||
11460 | \since 5.2 | - | ||||||||||||||||||||||||||||||||||||
11461 | - | |||||||||||||||||||||||||||||||||||||
11462 | Specifies how long time the tooltip will be displayed, in milliseconds. | - | ||||||||||||||||||||||||||||||||||||
11463 | If the value is -1 (default) the duration is calculated depending on the length of the tooltip. | - | ||||||||||||||||||||||||||||||||||||
11464 | - | |||||||||||||||||||||||||||||||||||||
11465 | \sa toolTip | - | ||||||||||||||||||||||||||||||||||||
11466 | */ | - | ||||||||||||||||||||||||||||||||||||
11467 | - | |||||||||||||||||||||||||||||||||||||
11468 | void QWidget::setToolTipDuration(int msec) | - | ||||||||||||||||||||||||||||||||||||
11469 | { | - | ||||||||||||||||||||||||||||||||||||
11470 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11471 | d->toolTipDuration = msec; | - | ||||||||||||||||||||||||||||||||||||
11472 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11473 | - | |||||||||||||||||||||||||||||||||||||
11474 | int QWidget::toolTipDuration() const | - | ||||||||||||||||||||||||||||||||||||
11475 | { | - | ||||||||||||||||||||||||||||||||||||
11476 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11477 | return d->toolTipDuration; never executed: return d->toolTipDuration; | 0 | ||||||||||||||||||||||||||||||||||||
11478 | } | - | ||||||||||||||||||||||||||||||||||||
11479 | - | |||||||||||||||||||||||||||||||||||||
11480 | #endif // QT_NO_TOOLTIP | - | ||||||||||||||||||||||||||||||||||||
11481 | - | |||||||||||||||||||||||||||||||||||||
11482 | - | |||||||||||||||||||||||||||||||||||||
11483 | #ifndef QT_NO_STATUSTIP | - | ||||||||||||||||||||||||||||||||||||
11484 | /*! | - | ||||||||||||||||||||||||||||||||||||
11485 | \property QWidget::statusTip | - | ||||||||||||||||||||||||||||||||||||
11486 | \brief the widget's status tip | - | ||||||||||||||||||||||||||||||||||||
11487 | - | |||||||||||||||||||||||||||||||||||||
11488 | By default, this property contains an empty string. | - | ||||||||||||||||||||||||||||||||||||
11489 | - | |||||||||||||||||||||||||||||||||||||
11490 | \sa toolTip, whatsThis | - | ||||||||||||||||||||||||||||||||||||
11491 | */ | - | ||||||||||||||||||||||||||||||||||||
11492 | void QWidget::setStatusTip(const QString &s) | - | ||||||||||||||||||||||||||||||||||||
11493 | { | - | ||||||||||||||||||||||||||||||||||||
11494 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11495 | d->statusTip = s; | - | ||||||||||||||||||||||||||||||||||||
11496 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11497 | - | |||||||||||||||||||||||||||||||||||||
11498 | QString QWidget::statusTip() const | - | ||||||||||||||||||||||||||||||||||||
11499 | { | - | ||||||||||||||||||||||||||||||||||||
11500 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11501 | return d->statusTip; never executed: return d->statusTip; | 0 | ||||||||||||||||||||||||||||||||||||
11502 | } | - | ||||||||||||||||||||||||||||||||||||
11503 | #endif // QT_NO_STATUSTIP | - | ||||||||||||||||||||||||||||||||||||
11504 | - | |||||||||||||||||||||||||||||||||||||
11505 | #ifndef QT_NO_WHATSTHIS | - | ||||||||||||||||||||||||||||||||||||
11506 | /*! | - | ||||||||||||||||||||||||||||||||||||
11507 | \property QWidget::whatsThis | - | ||||||||||||||||||||||||||||||||||||
11508 | - | |||||||||||||||||||||||||||||||||||||
11509 | \brief the widget's What's This help text. | - | ||||||||||||||||||||||||||||||||||||
11510 | - | |||||||||||||||||||||||||||||||||||||
11511 | By default, this property contains an empty string. | - | ||||||||||||||||||||||||||||||||||||
11512 | - | |||||||||||||||||||||||||||||||||||||
11513 | \sa QWhatsThis, QWidget::toolTip, QWidget::statusTip | - | ||||||||||||||||||||||||||||||||||||
11514 | */ | - | ||||||||||||||||||||||||||||||||||||
11515 | void QWidget::setWhatsThis(const QString &s) | - | ||||||||||||||||||||||||||||||||||||
11516 | { | - | ||||||||||||||||||||||||||||||||||||
11517 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11518 | d->whatsThis = s; | - | ||||||||||||||||||||||||||||||||||||
11519 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11520 | - | |||||||||||||||||||||||||||||||||||||
11521 | QString QWidget::whatsThis() const | - | ||||||||||||||||||||||||||||||||||||
11522 | { | - | ||||||||||||||||||||||||||||||||||||
11523 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11524 | return d->whatsThis; never executed: return d->whatsThis; | 0 | ||||||||||||||||||||||||||||||||||||
11525 | } | - | ||||||||||||||||||||||||||||||||||||
11526 | #endif // QT_NO_WHATSTHIS | - | ||||||||||||||||||||||||||||||||||||
11527 | - | |||||||||||||||||||||||||||||||||||||
11528 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
11529 | /*! | - | ||||||||||||||||||||||||||||||||||||
11530 | \property QWidget::accessibleName | - | ||||||||||||||||||||||||||||||||||||
11531 | - | |||||||||||||||||||||||||||||||||||||
11532 | \brief the widget's name as seen by assistive technologies | - | ||||||||||||||||||||||||||||||||||||
11533 | - | |||||||||||||||||||||||||||||||||||||
11534 | This is the primary name by which assistive technology such as screen readers | - | ||||||||||||||||||||||||||||||||||||
11535 | announce this widget. For most widgets setting this property is not required. | - | ||||||||||||||||||||||||||||||||||||
11536 | For example for QPushButton the button's text will be used. | - | ||||||||||||||||||||||||||||||||||||
11537 | - | |||||||||||||||||||||||||||||||||||||
11538 | It is important to set this property when the widget does not provide any | - | ||||||||||||||||||||||||||||||||||||
11539 | text. For example a button that only contains an icon needs to set this | - | ||||||||||||||||||||||||||||||||||||
11540 | property to work with screen readers. | - | ||||||||||||||||||||||||||||||||||||
11541 | The name should be short and equivalent to the visual information conveyed | - | ||||||||||||||||||||||||||||||||||||
11542 | by the widget. | - | ||||||||||||||||||||||||||||||||||||
11543 | - | |||||||||||||||||||||||||||||||||||||
11544 | This property has to be \l{Internationalization with Qt}{localized}. | - | ||||||||||||||||||||||||||||||||||||
11545 | - | |||||||||||||||||||||||||||||||||||||
11546 | By default, this property contains an empty string. | - | ||||||||||||||||||||||||||||||||||||
11547 | - | |||||||||||||||||||||||||||||||||||||
11548 | \sa QWidget::accessibleDescription, QAccessibleInterface::text() | - | ||||||||||||||||||||||||||||||||||||
11549 | */ | - | ||||||||||||||||||||||||||||||||||||
11550 | void QWidget::setAccessibleName(const QString &name) | - | ||||||||||||||||||||||||||||||||||||
11551 | { | - | ||||||||||||||||||||||||||||||||||||
11552 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11553 | d->accessibleName = name; | - | ||||||||||||||||||||||||||||||||||||
11554 | QAccessibleEvent event(this, QAccessible::NameChanged); | - | ||||||||||||||||||||||||||||||||||||
11555 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
11556 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11557 | - | |||||||||||||||||||||||||||||||||||||
11558 | QString QWidget::accessibleName() const | - | ||||||||||||||||||||||||||||||||||||
11559 | { | - | ||||||||||||||||||||||||||||||||||||
11560 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11561 | return d->accessibleName; never executed: return d->accessibleName; | 0 | ||||||||||||||||||||||||||||||||||||
11562 | } | - | ||||||||||||||||||||||||||||||||||||
11563 | - | |||||||||||||||||||||||||||||||||||||
11564 | /*! | - | ||||||||||||||||||||||||||||||||||||
11565 | \property QWidget::accessibleDescription | - | ||||||||||||||||||||||||||||||||||||
11566 | - | |||||||||||||||||||||||||||||||||||||
11567 | \brief the widget's description as seen by assistive technologies | - | ||||||||||||||||||||||||||||||||||||
11568 | - | |||||||||||||||||||||||||||||||||||||
11569 | The accessible description of a widget should convey what a widget does. | - | ||||||||||||||||||||||||||||||||||||
11570 | While the \l accessibleName should be a short and consise string (e.g. \gui{Save}), | - | ||||||||||||||||||||||||||||||||||||
11571 | the description should give more context, such as \gui{Saves the current document}. | - | ||||||||||||||||||||||||||||||||||||
11572 | - | |||||||||||||||||||||||||||||||||||||
11573 | This property has to be \l{Internationalization with Qt}{localized}. | - | ||||||||||||||||||||||||||||||||||||
11574 | - | |||||||||||||||||||||||||||||||||||||
11575 | By default, this property contains an empty string and Qt falls back | - | ||||||||||||||||||||||||||||||||||||
11576 | to using the tool tip to provide this information. | - | ||||||||||||||||||||||||||||||||||||
11577 | - | |||||||||||||||||||||||||||||||||||||
11578 | \sa QWidget::accessibleName, QAccessibleInterface::text() | - | ||||||||||||||||||||||||||||||||||||
11579 | */ | - | ||||||||||||||||||||||||||||||||||||
11580 | void QWidget::setAccessibleDescription(const QString &description) | - | ||||||||||||||||||||||||||||||||||||
11581 | { | - | ||||||||||||||||||||||||||||||||||||
11582 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11583 | d->accessibleDescription = description; | - | ||||||||||||||||||||||||||||||||||||
11584 | QAccessibleEvent event(this, QAccessible::DescriptionChanged); | - | ||||||||||||||||||||||||||||||||||||
11585 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||||||||
11586 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11587 | - | |||||||||||||||||||||||||||||||||||||
11588 | QString QWidget::accessibleDescription() const | - | ||||||||||||||||||||||||||||||||||||
11589 | { | - | ||||||||||||||||||||||||||||||||||||
11590 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11591 | return d->accessibleDescription; never executed: return d->accessibleDescription; | 0 | ||||||||||||||||||||||||||||||||||||
11592 | } | - | ||||||||||||||||||||||||||||||||||||
11593 | #endif // QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||||||||||||||
11594 | - | |||||||||||||||||||||||||||||||||||||
11595 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||||||||||||||||||||
11596 | /*! | - | ||||||||||||||||||||||||||||||||||||
11597 | Adds a shortcut to Qt's shortcut system that watches for the given | - | ||||||||||||||||||||||||||||||||||||
11598 | \a key sequence in the given \a context. If the \a context is | - | ||||||||||||||||||||||||||||||||||||
11599 | Qt::ApplicationShortcut, the shortcut applies to the application as a | - | ||||||||||||||||||||||||||||||||||||
11600 | whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut, | - | ||||||||||||||||||||||||||||||||||||
11601 | or to the window itself, Qt::WindowShortcut. | - | ||||||||||||||||||||||||||||||||||||
11602 | - | |||||||||||||||||||||||||||||||||||||
11603 | If the same \a key sequence has been grabbed by several widgets, | - | ||||||||||||||||||||||||||||||||||||
11604 | when the \a key sequence occurs a QEvent::Shortcut event is sent | - | ||||||||||||||||||||||||||||||||||||
11605 | to all the widgets to which it applies in a non-deterministic | - | ||||||||||||||||||||||||||||||||||||
11606 | order, but with the ``ambiguous'' flag set to true. | - | ||||||||||||||||||||||||||||||||||||
11607 | - | |||||||||||||||||||||||||||||||||||||
11608 | \warning You should not normally need to use this function; | - | ||||||||||||||||||||||||||||||||||||
11609 | instead create \l{QAction}s with the shortcut key sequences you | - | ||||||||||||||||||||||||||||||||||||
11610 | require (if you also want equivalent menu options and toolbar | - | ||||||||||||||||||||||||||||||||||||
11611 | buttons), or create \l{QShortcut}s if you just need key sequences. | - | ||||||||||||||||||||||||||||||||||||
11612 | Both QAction and QShortcut handle all the event filtering for you, | - | ||||||||||||||||||||||||||||||||||||
11613 | and provide signals which are triggered when the user triggers the | - | ||||||||||||||||||||||||||||||||||||
11614 | key sequence, so are much easier to use than this low-level | - | ||||||||||||||||||||||||||||||||||||
11615 | function. | - | ||||||||||||||||||||||||||||||||||||
11616 | - | |||||||||||||||||||||||||||||||||||||
11617 | \sa releaseShortcut(), setShortcutEnabled() | - | ||||||||||||||||||||||||||||||||||||
11618 | */ | - | ||||||||||||||||||||||||||||||||||||
11619 | int QWidget::grabShortcut(const QKeySequence &key, Qt::ShortcutContext context) | - | ||||||||||||||||||||||||||||||||||||
11620 | { | - | ||||||||||||||||||||||||||||||||||||
11621 | Q_ASSERT(qApp); | - | ||||||||||||||||||||||||||||||||||||
11622 | if (key.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
11623 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
11624 | setAttribute(Qt::WA_GrabbedShortcut); | - | ||||||||||||||||||||||||||||||||||||
11625 | 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 | ||||||||||||||||||||||||||||||||||||
11626 | } | - | ||||||||||||||||||||||||||||||||||||
11627 | - | |||||||||||||||||||||||||||||||||||||
11628 | /*! | - | ||||||||||||||||||||||||||||||||||||
11629 | Removes the shortcut with the given \a id from Qt's shortcut | - | ||||||||||||||||||||||||||||||||||||
11630 | system. The widget will no longer receive QEvent::Shortcut events | - | ||||||||||||||||||||||||||||||||||||
11631 | for the shortcut's key sequence (unless it has other shortcuts | - | ||||||||||||||||||||||||||||||||||||
11632 | with the same key sequence). | - | ||||||||||||||||||||||||||||||||||||
11633 | - | |||||||||||||||||||||||||||||||||||||
11634 | \warning You should not normally need to use this function since | - | ||||||||||||||||||||||||||||||||||||
11635 | Qt's shortcut system removes shortcuts automatically when their | - | ||||||||||||||||||||||||||||||||||||
11636 | parent widget is destroyed. It is best to use QAction or | - | ||||||||||||||||||||||||||||||||||||
11637 | QShortcut to handle shortcuts, since they are easier to use than | - | ||||||||||||||||||||||||||||||||||||
11638 | this low-level function. Note also that this is an expensive | - | ||||||||||||||||||||||||||||||||||||
11639 | operation. | - | ||||||||||||||||||||||||||||||||||||
11640 | - | |||||||||||||||||||||||||||||||||||||
11641 | \sa grabShortcut(), setShortcutEnabled() | - | ||||||||||||||||||||||||||||||||||||
11642 | */ | - | ||||||||||||||||||||||||||||||||||||
11643 | void QWidget::releaseShortcut(int id) | - | ||||||||||||||||||||||||||||||||||||
11644 | { | - | ||||||||||||||||||||||||||||||||||||
11645 | Q_ASSERT(qApp); | - | ||||||||||||||||||||||||||||||||||||
11646 | if (id)
| 0 | ||||||||||||||||||||||||||||||||||||
11647 | qApp->d_func()->shortcutMap.removeShortcut(id, this, 0); never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(id, this, 0); | 0 | ||||||||||||||||||||||||||||||||||||
11648 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11649 | - | |||||||||||||||||||||||||||||||||||||
11650 | /*! | - | ||||||||||||||||||||||||||||||||||||
11651 | If \a enable is true, the shortcut with the given \a id is | - | ||||||||||||||||||||||||||||||||||||
11652 | enabled; otherwise the shortcut is disabled. | - | ||||||||||||||||||||||||||||||||||||
11653 | - | |||||||||||||||||||||||||||||||||||||
11654 | \warning You should not normally need to use this function since | - | ||||||||||||||||||||||||||||||||||||
11655 | Qt's shortcut system enables/disables shortcuts automatically as | - | ||||||||||||||||||||||||||||||||||||
11656 | widgets become hidden/visible and gain or lose focus. It is best | - | ||||||||||||||||||||||||||||||||||||
11657 | to use QAction or QShortcut to handle shortcuts, since they are | - | ||||||||||||||||||||||||||||||||||||
11658 | easier to use than this low-level function. | - | ||||||||||||||||||||||||||||||||||||
11659 | - | |||||||||||||||||||||||||||||||||||||
11660 | \sa grabShortcut(), releaseShortcut() | - | ||||||||||||||||||||||||||||||||||||
11661 | */ | - | ||||||||||||||||||||||||||||||||||||
11662 | void QWidget::setShortcutEnabled(int id, bool enable) | - | ||||||||||||||||||||||||||||||||||||
11663 | { | - | ||||||||||||||||||||||||||||||||||||
11664 | Q_ASSERT(qApp); | - | ||||||||||||||||||||||||||||||||||||
11665 | if (id)
| 0 | ||||||||||||||||||||||||||||||||||||
11666 | 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 | ||||||||||||||||||||||||||||||||||||
11667 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11668 | - | |||||||||||||||||||||||||||||||||||||
11669 | /*! | - | ||||||||||||||||||||||||||||||||||||
11670 | \since 4.2 | - | ||||||||||||||||||||||||||||||||||||
11671 | - | |||||||||||||||||||||||||||||||||||||
11672 | If \a enable is true, auto repeat of the shortcut with the | - | ||||||||||||||||||||||||||||||||||||
11673 | given \a id is enabled; otherwise it is disabled. | - | ||||||||||||||||||||||||||||||||||||
11674 | - | |||||||||||||||||||||||||||||||||||||
11675 | \sa grabShortcut(), releaseShortcut() | - | ||||||||||||||||||||||||||||||||||||
11676 | */ | - | ||||||||||||||||||||||||||||||||||||
11677 | void QWidget::setShortcutAutoRepeat(int id, bool enable) | - | ||||||||||||||||||||||||||||||||||||
11678 | { | - | ||||||||||||||||||||||||||||||||||||
11679 | Q_ASSERT(qApp); | - | ||||||||||||||||||||||||||||||||||||
11680 | if (id)
| 0 | ||||||||||||||||||||||||||||||||||||
11681 | 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 | ||||||||||||||||||||||||||||||||||||
11682 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11683 | #endif // QT_NO_SHORTCUT | - | ||||||||||||||||||||||||||||||||||||
11684 | - | |||||||||||||||||||||||||||||||||||||
11685 | /*! | - | ||||||||||||||||||||||||||||||||||||
11686 | Updates the widget's micro focus. | - | ||||||||||||||||||||||||||||||||||||
11687 | */ | - | ||||||||||||||||||||||||||||||||||||
11688 | void QWidget::updateMicroFocus() | - | ||||||||||||||||||||||||||||||||||||
11689 | { | - | ||||||||||||||||||||||||||||||||||||
11690 | // updating everything since this is currently called for any kind of state change | - | ||||||||||||||||||||||||||||||||||||
11691 | if (this == QGuiApplication::focusObject())
| 0 | ||||||||||||||||||||||||||||||||||||
11692 | QGuiApplication::inputMethod()->update(Qt::ImQueryAll); never executed: QGuiApplication::inputMethod()->update(Qt::ImQueryAll); | 0 | ||||||||||||||||||||||||||||||||||||
11693 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11694 | - | |||||||||||||||||||||||||||||||||||||
11695 | /*! | - | ||||||||||||||||||||||||||||||||||||
11696 | Raises this widget to the top of the parent widget's stack. | - | ||||||||||||||||||||||||||||||||||||
11697 | - | |||||||||||||||||||||||||||||||||||||
11698 | After this call the widget will be visually in front of any | - | ||||||||||||||||||||||||||||||||||||
11699 | overlapping sibling widgets. | - | ||||||||||||||||||||||||||||||||||||
11700 | - | |||||||||||||||||||||||||||||||||||||
11701 | \note When using activateWindow(), you can call this function to | - | ||||||||||||||||||||||||||||||||||||
11702 | ensure that the window is stacked on top. | - | ||||||||||||||||||||||||||||||||||||
11703 | - | |||||||||||||||||||||||||||||||||||||
11704 | \sa lower(), stackUnder() | - | ||||||||||||||||||||||||||||||||||||
11705 | */ | - | ||||||||||||||||||||||||||||||||||||
11706 | - | |||||||||||||||||||||||||||||||||||||
11707 | void QWidget::raise() | - | ||||||||||||||||||||||||||||||||||||
11708 | { | - | ||||||||||||||||||||||||||||||||||||
11709 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11710 | if (!isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11711 | QWidget *p = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
11712 | const int parentChildCount = p->d_func()->children.size(); | - | ||||||||||||||||||||||||||||||||||||
11713 | if (parentChildCount < 2)
| 0 | ||||||||||||||||||||||||||||||||||||
11714 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11715 | const int from = p->d_func()->children.indexOf(this); | - | ||||||||||||||||||||||||||||||||||||
11716 | Q_ASSERT(from >= 0); | - | ||||||||||||||||||||||||||||||||||||
11717 | // Do nothing if the widget is already in correct stacking order _and_ created. | - | ||||||||||||||||||||||||||||||||||||
11718 | if (from != parentChildCount -1)
| 0 | ||||||||||||||||||||||||||||||||||||
11719 | p->d_func()->children.move(from, parentChildCount - 1); never executed: p->d_func()->children.move(from, parentChildCount - 1); | 0 | ||||||||||||||||||||||||||||||||||||
11720 | if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11721 | create(); never executed: create(); | 0 | ||||||||||||||||||||||||||||||||||||
11722 | else if (from == parentChildCount - 1)
| 0 | ||||||||||||||||||||||||||||||||||||
11723 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11724 | - | |||||||||||||||||||||||||||||||||||||
11725 | QRegion region(rect()); | - | ||||||||||||||||||||||||||||||||||||
11726 | d->subtractOpaqueSiblings(region); | - | ||||||||||||||||||||||||||||||||||||
11727 | d->invalidateBuffer(region); | - | ||||||||||||||||||||||||||||||||||||
11728 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11729 | if (testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11730 | d->raise_sys(); never executed: d->raise_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
11731 | - | |||||||||||||||||||||||||||||||||||||
11732 | if (d->extra && d->extra->hasWindowContainer)
| 0 | ||||||||||||||||||||||||||||||||||||
11733 | QWindowContainer::parentWasRaised(this); never executed: QWindowContainer::parentWasRaised(this); | 0 | ||||||||||||||||||||||||||||||||||||
11734 | - | |||||||||||||||||||||||||||||||||||||
11735 | QEvent e(QEvent::ZOrderChange); | - | ||||||||||||||||||||||||||||||||||||
11736 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
11737 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11738 | - | |||||||||||||||||||||||||||||||||||||
11739 | void QWidgetPrivate::raise_sys() | - | ||||||||||||||||||||||||||||||||||||
11740 | { | - | ||||||||||||||||||||||||||||||||||||
11741 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11742 | if (q->isWindow() || q->testAttribute(Qt::WA_NativeWindow)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11743 | q->windowHandle()->raise(); | - | ||||||||||||||||||||||||||||||||||||
11744 | } else if (renderToTexture) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
11745 | if (QWidget *p = q->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11746 | setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
11747 | p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); | - | ||||||||||||||||||||||||||||||||||||
11748 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11749 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11750 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11751 | - | |||||||||||||||||||||||||||||||||||||
11752 | /*! | - | ||||||||||||||||||||||||||||||||||||
11753 | Lowers the widget to the bottom of the parent widget's stack. | - | ||||||||||||||||||||||||||||||||||||
11754 | - | |||||||||||||||||||||||||||||||||||||
11755 | After this call the widget will be visually behind (and therefore | - | ||||||||||||||||||||||||||||||||||||
11756 | obscured by) any overlapping sibling widgets. | - | ||||||||||||||||||||||||||||||||||||
11757 | - | |||||||||||||||||||||||||||||||||||||
11758 | \sa raise(), stackUnder() | - | ||||||||||||||||||||||||||||||||||||
11759 | */ | - | ||||||||||||||||||||||||||||||||||||
11760 | - | |||||||||||||||||||||||||||||||||||||
11761 | void QWidget::lower() | - | ||||||||||||||||||||||||||||||||||||
11762 | { | - | ||||||||||||||||||||||||||||||||||||
11763 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11764 | if (!isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11765 | QWidget *p = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
11766 | const int parentChildCount = p->d_func()->children.size(); | - | ||||||||||||||||||||||||||||||||||||
11767 | if (parentChildCount < 2)
| 0 | ||||||||||||||||||||||||||||||||||||
11768 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11769 | const int from = p->d_func()->children.indexOf(this); | - | ||||||||||||||||||||||||||||||||||||
11770 | Q_ASSERT(from >= 0); | - | ||||||||||||||||||||||||||||||||||||
11771 | // Do nothing if the widget is already in correct stacking order _and_ created. | - | ||||||||||||||||||||||||||||||||||||
11772 | if (from != 0)
| 0 | ||||||||||||||||||||||||||||||||||||
11773 | p->d_func()->children.move(from, 0); never executed: p->d_func()->children.move(from, 0); | 0 | ||||||||||||||||||||||||||||||||||||
11774 | if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11775 | create(); never executed: create(); | 0 | ||||||||||||||||||||||||||||||||||||
11776 | else if (from == 0)
| 0 | ||||||||||||||||||||||||||||||||||||
11777 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11778 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11779 | if (testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11780 | d->lower_sys(); never executed: d->lower_sys(); | 0 | ||||||||||||||||||||||||||||||||||||
11781 | - | |||||||||||||||||||||||||||||||||||||
11782 | if (d->extra && d->extra->hasWindowContainer)
| 0 | ||||||||||||||||||||||||||||||||||||
11783 | QWindowContainer::parentWasLowered(this); never executed: QWindowContainer::parentWasLowered(this); | 0 | ||||||||||||||||||||||||||||||||||||
11784 | - | |||||||||||||||||||||||||||||||||||||
11785 | QEvent e(QEvent::ZOrderChange); | - | ||||||||||||||||||||||||||||||||||||
11786 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
11787 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11788 | - | |||||||||||||||||||||||||||||||||||||
11789 | void QWidgetPrivate::lower_sys() | - | ||||||||||||||||||||||||||||||||||||
11790 | { | - | ||||||||||||||||||||||||||||||||||||
11791 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11792 | if (q->isWindow() || q->testAttribute(Qt::WA_NativeWindow)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11793 | Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); | - | ||||||||||||||||||||||||||||||||||||
11794 | q->windowHandle()->lower(); | - | ||||||||||||||||||||||||||||||||||||
11795 | } else if (QWidget *p = q->parentWidget()) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
11796 | setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
11797 | p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); | - | ||||||||||||||||||||||||||||||||||||
11798 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11799 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11800 | - | |||||||||||||||||||||||||||||||||||||
11801 | /*! | - | ||||||||||||||||||||||||||||||||||||
11802 | Places the widget under \a w in the parent widget's stack. | - | ||||||||||||||||||||||||||||||||||||
11803 | - | |||||||||||||||||||||||||||||||||||||
11804 | To make this work, the widget itself and \a w must be siblings. | - | ||||||||||||||||||||||||||||||||||||
11805 | - | |||||||||||||||||||||||||||||||||||||
11806 | \sa raise(), lower() | - | ||||||||||||||||||||||||||||||||||||
11807 | */ | - | ||||||||||||||||||||||||||||||||||||
11808 | void QWidget::stackUnder(QWidget* w) | - | ||||||||||||||||||||||||||||||||||||
11809 | { | - | ||||||||||||||||||||||||||||||||||||
11810 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11811 | QWidget *p = parentWidget(); | - | ||||||||||||||||||||||||||||||||||||
11812 | if (!w || isWindow() || p != w->parentWidget() || this == w)
| 0 | ||||||||||||||||||||||||||||||||||||
11813 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11814 | if (p) {
| 0 | ||||||||||||||||||||||||||||||||||||
11815 | int from = p->d_func()->children.indexOf(this); | - | ||||||||||||||||||||||||||||||||||||
11816 | int to = p->d_func()->children.indexOf(w); | - | ||||||||||||||||||||||||||||||||||||
11817 | Q_ASSERT(from >= 0); | - | ||||||||||||||||||||||||||||||||||||
11818 | Q_ASSERT(to >= 0); | - | ||||||||||||||||||||||||||||||||||||
11819 | if (from < to)
| 0 | ||||||||||||||||||||||||||||||||||||
11820 | --to; never executed: --to; | 0 | ||||||||||||||||||||||||||||||||||||
11821 | // Do nothing if the widget is already in correct stacking order _and_ created. | - | ||||||||||||||||||||||||||||||||||||
11822 | if (from != to)
| 0 | ||||||||||||||||||||||||||||||||||||
11823 | p->d_func()->children.move(from, to); never executed: p->d_func()->children.move(from, to); | 0 | ||||||||||||||||||||||||||||||||||||
11824 | if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11825 | create(); never executed: create(); | 0 | ||||||||||||||||||||||||||||||||||||
11826 | else if (from == to)
| 0 | ||||||||||||||||||||||||||||||||||||
11827 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
11828 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11829 | if (testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11830 | d->stackUnder_sys(w); never executed: d->stackUnder_sys(w); | 0 | ||||||||||||||||||||||||||||||||||||
11831 | - | |||||||||||||||||||||||||||||||||||||
11832 | QEvent e(QEvent::ZOrderChange); | - | ||||||||||||||||||||||||||||||||||||
11833 | QApplication::sendEvent(this, &e); | - | ||||||||||||||||||||||||||||||||||||
11834 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11835 | - | |||||||||||||||||||||||||||||||||||||
11836 | void QWidgetPrivate::stackUnder_sys(QWidget*) | - | ||||||||||||||||||||||||||||||||||||
11837 | { | - | ||||||||||||||||||||||||||||||||||||
11838 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11839 | if (QWidget *p = q->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11840 | setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
11841 | p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); | - | ||||||||||||||||||||||||||||||||||||
11842 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11843 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11844 | - | |||||||||||||||||||||||||||||||||||||
11845 | /*! | - | ||||||||||||||||||||||||||||||||||||
11846 | \fn bool QWidget::isTopLevel() const | - | ||||||||||||||||||||||||||||||||||||
11847 | \obsolete | - | ||||||||||||||||||||||||||||||||||||
11848 | - | |||||||||||||||||||||||||||||||||||||
11849 | Use isWindow() instead. | - | ||||||||||||||||||||||||||||||||||||
11850 | */ | - | ||||||||||||||||||||||||||||||||||||
11851 | - | |||||||||||||||||||||||||||||||||||||
11852 | /*! | - | ||||||||||||||||||||||||||||||||||||
11853 | \fn bool QWidget::isRightToLeft() const | - | ||||||||||||||||||||||||||||||||||||
11854 | \internal | - | ||||||||||||||||||||||||||||||||||||
11855 | */ | - | ||||||||||||||||||||||||||||||||||||
11856 | - | |||||||||||||||||||||||||||||||||||||
11857 | /*! | - | ||||||||||||||||||||||||||||||||||||
11858 | \fn bool QWidget::isLeftToRight() const | - | ||||||||||||||||||||||||||||||||||||
11859 | \internal | - | ||||||||||||||||||||||||||||||||||||
11860 | */ | - | ||||||||||||||||||||||||||||||||||||
11861 | - | |||||||||||||||||||||||||||||||||||||
11862 | /*! | - | ||||||||||||||||||||||||||||||||||||
11863 | \macro QWIDGETSIZE_MAX | - | ||||||||||||||||||||||||||||||||||||
11864 | \relates QWidget | - | ||||||||||||||||||||||||||||||||||||
11865 | - | |||||||||||||||||||||||||||||||||||||
11866 | Defines the maximum size for a QWidget object. | - | ||||||||||||||||||||||||||||||||||||
11867 | - | |||||||||||||||||||||||||||||||||||||
11868 | The largest allowed size for a widget is QSize(QWIDGETSIZE_MAX, | - | ||||||||||||||||||||||||||||||||||||
11869 | QWIDGETSIZE_MAX), i.e. QSize (16777215,16777215). | - | ||||||||||||||||||||||||||||||||||||
11870 | - | |||||||||||||||||||||||||||||||||||||
11871 | \sa QWidget::setMaximumSize() | - | ||||||||||||||||||||||||||||||||||||
11872 | */ | - | ||||||||||||||||||||||||||||||||||||
11873 | - | |||||||||||||||||||||||||||||||||||||
11874 | /*! | - | ||||||||||||||||||||||||||||||||||||
11875 | \fn QWidget::setupUi(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
11876 | - | |||||||||||||||||||||||||||||||||||||
11877 | Sets up the user interface for the specified \a widget. | - | ||||||||||||||||||||||||||||||||||||
11878 | - | |||||||||||||||||||||||||||||||||||||
11879 | \note This function is available with widgets that derive from user | - | ||||||||||||||||||||||||||||||||||||
11880 | interface descriptions created using \l{uic}. | - | ||||||||||||||||||||||||||||||||||||
11881 | - | |||||||||||||||||||||||||||||||||||||
11882 | \sa {Using a Designer UI File in Your Application} | - | ||||||||||||||||||||||||||||||||||||
11883 | */ | - | ||||||||||||||||||||||||||||||||||||
11884 | - | |||||||||||||||||||||||||||||||||||||
11885 | QRect QWidgetPrivate::frameStrut() const | - | ||||||||||||||||||||||||||||||||||||
11886 | { | - | ||||||||||||||||||||||||||||||||||||
11887 | Q_Q(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
11888 | if (!q->isWindow() || (q->windowType() == Qt::Desktop) || q->testAttribute(Qt::WA_DontShowOnScreen)) {
| 0 | ||||||||||||||||||||||||||||||||||||
11889 | // x2 = x1 + w - 1, so w/h = 1 | - | ||||||||||||||||||||||||||||||||||||
11890 | return QRect(0, 0, 1, 1); never executed: return QRect(0, 0, 1, 1); | 0 | ||||||||||||||||||||||||||||||||||||
11891 | } | - | ||||||||||||||||||||||||||||||||||||
11892 | - | |||||||||||||||||||||||||||||||||||||
11893 | if (data.fstrut_dirty
| 0 | ||||||||||||||||||||||||||||||||||||
11894 | #ifndef Q_DEAD_CODE_FROM_QT4_WIN | - | ||||||||||||||||||||||||||||||||||||
11895 | // ### Fix properly for 4.3 | - | ||||||||||||||||||||||||||||||||||||
11896 | && q->isVisible()
| 0 | ||||||||||||||||||||||||||||||||||||
11897 | #endif | - | ||||||||||||||||||||||||||||||||||||
11898 | && q->testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
11899 | const_cast<QWidgetPrivate *>(this)->updateFrameStrut(); never executed: const_cast<QWidgetPrivate *>(this)->updateFrameStrut(); | 0 | ||||||||||||||||||||||||||||||||||||
11900 | - | |||||||||||||||||||||||||||||||||||||
11901 | return maybeTopData() ? maybeTopData()->frameStrut : QRect(); never executed: return maybeTopData() ? maybeTopData()->frameStrut : QRect();
| 0 | ||||||||||||||||||||||||||||||||||||
11902 | } | - | ||||||||||||||||||||||||||||||||||||
11903 | - | |||||||||||||||||||||||||||||||||||||
11904 | void QWidgetPrivate::updateFrameStrut() | - | ||||||||||||||||||||||||||||||||||||
11905 | { | - | ||||||||||||||||||||||||||||||||||||
11906 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
11907 | if (q->data->fstrut_dirty) {
| 0 | ||||||||||||||||||||||||||||||||||||
11908 | if (QTLWExtra *te = maybeTopData()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11909 | if (te->window && te->window->handle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11910 | const QMargins margins = te->window->frameMargins(); | - | ||||||||||||||||||||||||||||||||||||
11911 | if (!margins.isNull()) {
| 0 | ||||||||||||||||||||||||||||||||||||
11912 | te->frameStrut.setCoords(margins.left(), margins.top(), margins.right(), margins.bottom()); | - | ||||||||||||||||||||||||||||||||||||
11913 | q->data->fstrut_dirty = false; | - | ||||||||||||||||||||||||||||||||||||
11914 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11915 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11916 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11917 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11918 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
11919 | - | |||||||||||||||||||||||||||||||||||||
11920 | #ifdef QT_KEYPAD_NAVIGATION | - | ||||||||||||||||||||||||||||||||||||
11921 | /*! | - | ||||||||||||||||||||||||||||||||||||
11922 | \internal | - | ||||||||||||||||||||||||||||||||||||
11923 | - | |||||||||||||||||||||||||||||||||||||
11924 | Changes the focus from the current focusWidget to a widget in | - | ||||||||||||||||||||||||||||||||||||
11925 | the \a direction. | - | ||||||||||||||||||||||||||||||||||||
11926 | - | |||||||||||||||||||||||||||||||||||||
11927 | Returns \c true, if there was a widget in that direction | - | ||||||||||||||||||||||||||||||||||||
11928 | */ | - | ||||||||||||||||||||||||||||||||||||
11929 | bool QWidgetPrivate::navigateToDirection(Direction direction) | - | ||||||||||||||||||||||||||||||||||||
11930 | { | - | ||||||||||||||||||||||||||||||||||||
11931 | QWidget *targetWidget = widgetInNavigationDirection(direction); | - | ||||||||||||||||||||||||||||||||||||
11932 | if (targetWidget) | - | ||||||||||||||||||||||||||||||||||||
11933 | targetWidget->setFocus(); | - | ||||||||||||||||||||||||||||||||||||
11934 | return (targetWidget != 0); | - | ||||||||||||||||||||||||||||||||||||
11935 | } | - | ||||||||||||||||||||||||||||||||||||
11936 | - | |||||||||||||||||||||||||||||||||||||
11937 | /*! | - | ||||||||||||||||||||||||||||||||||||
11938 | \internal | - | ||||||||||||||||||||||||||||||||||||
11939 | - | |||||||||||||||||||||||||||||||||||||
11940 | Searches for a widget that is positioned in the \a direction, starting | - | ||||||||||||||||||||||||||||||||||||
11941 | from the current focusWidget. | - | ||||||||||||||||||||||||||||||||||||
11942 | - | |||||||||||||||||||||||||||||||||||||
11943 | Returns the pointer to a found widget or 0, if there was no widget in | - | ||||||||||||||||||||||||||||||||||||
11944 | that direction. | - | ||||||||||||||||||||||||||||||||||||
11945 | */ | - | ||||||||||||||||||||||||||||||||||||
11946 | QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction) | - | ||||||||||||||||||||||||||||||||||||
11947 | { | - | ||||||||||||||||||||||||||||||||||||
11948 | const QWidget *sourceWidget = QApplication::focusWidget(); | - | ||||||||||||||||||||||||||||||||||||
11949 | if (!sourceWidget) | - | ||||||||||||||||||||||||||||||||||||
11950 | return 0; | - | ||||||||||||||||||||||||||||||||||||
11951 | const QRect sourceRect = sourceWidget->rect().translated(sourceWidget->mapToGlobal(QPoint())); | - | ||||||||||||||||||||||||||||||||||||
11952 | const int sourceX = | - | ||||||||||||||||||||||||||||||||||||
11953 | (direction == DirectionNorth || direction == DirectionSouth) ? | - | ||||||||||||||||||||||||||||||||||||
11954 | (sourceRect.left() + (sourceRect.right() - sourceRect.left()) / 2) | - | ||||||||||||||||||||||||||||||||||||
11955 | :(direction == DirectionEast ? sourceRect.right() : sourceRect.left()); | - | ||||||||||||||||||||||||||||||||||||
11956 | const int sourceY = | - | ||||||||||||||||||||||||||||||||||||
11957 | (direction == DirectionEast || direction == DirectionWest) ? | - | ||||||||||||||||||||||||||||||||||||
11958 | (sourceRect.top() + (sourceRect.bottom() - sourceRect.top()) / 2) | - | ||||||||||||||||||||||||||||||||||||
11959 | :(direction == DirectionSouth ? sourceRect.bottom() : sourceRect.top()); | - | ||||||||||||||||||||||||||||||||||||
11960 | const QPoint sourcePoint(sourceX, sourceY); | - | ||||||||||||||||||||||||||||||||||||
11961 | const QPoint sourceCenter = sourceRect.center(); | - | ||||||||||||||||||||||||||||||||||||
11962 | const QWidget *sourceWindow = sourceWidget->window(); | - | ||||||||||||||||||||||||||||||||||||
11963 | - | |||||||||||||||||||||||||||||||||||||
11964 | QWidget *targetWidget = 0; | - | ||||||||||||||||||||||||||||||||||||
11965 | int shortestDistance = INT_MAX; | - | ||||||||||||||||||||||||||||||||||||
11966 | foreach(QWidget *targetCandidate, QApplication::allWidgets()) { | - | ||||||||||||||||||||||||||||||||||||
11967 | - | |||||||||||||||||||||||||||||||||||||
11968 | const QRect targetCandidateRect = targetCandidate->rect().translated(targetCandidate->mapToGlobal(QPoint())); | - | ||||||||||||||||||||||||||||||||||||
11969 | - | |||||||||||||||||||||||||||||||||||||
11970 | // For focus proxies, the child widget handling the focus can have keypad navigation focus, | - | ||||||||||||||||||||||||||||||||||||
11971 | // but the owner of the proxy cannot. | - | ||||||||||||||||||||||||||||||||||||
11972 | // Additionally, empty widgets should be ignored. | - | ||||||||||||||||||||||||||||||||||||
11973 | if (targetCandidate->focusProxy() || targetCandidateRect.isEmpty()) | - | ||||||||||||||||||||||||||||||||||||
11974 | continue; | - | ||||||||||||||||||||||||||||||||||||
11975 | - | |||||||||||||||||||||||||||||||||||||
11976 | // Only navigate to a target widget that... | - | ||||||||||||||||||||||||||||||||||||
11977 | if ( targetCandidate != sourceWidget | - | ||||||||||||||||||||||||||||||||||||
11978 | // ...takes the focus, | - | ||||||||||||||||||||||||||||||||||||
11979 | && targetCandidate->focusPolicy() & Qt::TabFocus | - | ||||||||||||||||||||||||||||||||||||
11980 | // ...is above if DirectionNorth, | - | ||||||||||||||||||||||||||||||||||||
11981 | && !(direction == DirectionNorth && targetCandidateRect.bottom() > sourceRect.top()) | - | ||||||||||||||||||||||||||||||||||||
11982 | // ...is on the right if DirectionEast, | - | ||||||||||||||||||||||||||||||||||||
11983 | && !(direction == DirectionEast && targetCandidateRect.left() < sourceRect.right()) | - | ||||||||||||||||||||||||||||||||||||
11984 | // ...is below if DirectionSouth, | - | ||||||||||||||||||||||||||||||||||||
11985 | && !(direction == DirectionSouth && targetCandidateRect.top() < sourceRect.bottom()) | - | ||||||||||||||||||||||||||||||||||||
11986 | // ...is on the left if DirectionWest, | - | ||||||||||||||||||||||||||||||||||||
11987 | && !(direction == DirectionWest && targetCandidateRect.right() > sourceRect.left()) | - | ||||||||||||||||||||||||||||||||||||
11988 | // ...is enabled, | - | ||||||||||||||||||||||||||||||||||||
11989 | && targetCandidate->isEnabled() | - | ||||||||||||||||||||||||||||||||||||
11990 | // ...is visible, | - | ||||||||||||||||||||||||||||||||||||
11991 | && targetCandidate->isVisible() | - | ||||||||||||||||||||||||||||||||||||
11992 | // ...is in the same window, | - | ||||||||||||||||||||||||||||||||||||
11993 | && targetCandidate->window() == sourceWindow) { | - | ||||||||||||||||||||||||||||||||||||
11994 | const int targetCandidateDistance = pointToRect(sourcePoint, targetCandidateRect); | - | ||||||||||||||||||||||||||||||||||||
11995 | if (targetCandidateDistance < shortestDistance) { | - | ||||||||||||||||||||||||||||||||||||
11996 | shortestDistance = targetCandidateDistance; | - | ||||||||||||||||||||||||||||||||||||
11997 | targetWidget = targetCandidate; | - | ||||||||||||||||||||||||||||||||||||
11998 | } | - | ||||||||||||||||||||||||||||||||||||
11999 | } | - | ||||||||||||||||||||||||||||||||||||
12000 | } | - | ||||||||||||||||||||||||||||||||||||
12001 | return targetWidget; | - | ||||||||||||||||||||||||||||||||||||
12002 | } | - | ||||||||||||||||||||||||||||||||||||
12003 | - | |||||||||||||||||||||||||||||||||||||
12004 | /*! | - | ||||||||||||||||||||||||||||||||||||
12005 | \internal | - | ||||||||||||||||||||||||||||||||||||
12006 | - | |||||||||||||||||||||||||||||||||||||
12007 | Tells us if it there is currently a reachable widget by keypad navigation in | - | ||||||||||||||||||||||||||||||||||||
12008 | a certain \a orientation. | - | ||||||||||||||||||||||||||||||||||||
12009 | If no navigation is possible, occurring key events in that \a orientation may | - | ||||||||||||||||||||||||||||||||||||
12010 | be used to interact with the value in the focused widget, even though it | - | ||||||||||||||||||||||||||||||||||||
12011 | currently has not the editFocus. | - | ||||||||||||||||||||||||||||||||||||
12012 | - | |||||||||||||||||||||||||||||||||||||
12013 | \sa QWidgetPrivate::widgetInNavigationDirection(), QWidget::hasEditFocus() | - | ||||||||||||||||||||||||||||||||||||
12014 | */ | - | ||||||||||||||||||||||||||||||||||||
12015 | bool QWidgetPrivate::canKeypadNavigate(Qt::Orientation orientation) | - | ||||||||||||||||||||||||||||||||||||
12016 | { | - | ||||||||||||||||||||||||||||||||||||
12017 | return orientation == Qt::Horizontal? | - | ||||||||||||||||||||||||||||||||||||
12018 | (QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionEast) | - | ||||||||||||||||||||||||||||||||||||
12019 | || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionWest)) | - | ||||||||||||||||||||||||||||||||||||
12020 | :(QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionNorth) | - | ||||||||||||||||||||||||||||||||||||
12021 | || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionSouth)); | - | ||||||||||||||||||||||||||||||||||||
12022 | } | - | ||||||||||||||||||||||||||||||||||||
12023 | /*! | - | ||||||||||||||||||||||||||||||||||||
12024 | \internal | - | ||||||||||||||||||||||||||||||||||||
12025 | - | |||||||||||||||||||||||||||||||||||||
12026 | Checks, if the \a widget is inside a QTabWidget. If is is inside | - | ||||||||||||||||||||||||||||||||||||
12027 | one, left/right key events will be used to switch between tabs in keypad | - | ||||||||||||||||||||||||||||||||||||
12028 | navigation. If there is no QTabWidget, the horizontal key events can be used | - | ||||||||||||||||||||||||||||||||||||
12029 | to | - | ||||||||||||||||||||||||||||||||||||
12030 | interact with the value in the focused widget, even though it currently has | - | ||||||||||||||||||||||||||||||||||||
12031 | not the editFocus. | - | ||||||||||||||||||||||||||||||||||||
12032 | - | |||||||||||||||||||||||||||||||||||||
12033 | \sa QWidget::hasEditFocus() | - | ||||||||||||||||||||||||||||||||||||
12034 | */ | - | ||||||||||||||||||||||||||||||||||||
12035 | bool QWidgetPrivate::inTabWidget(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
12036 | { | - | ||||||||||||||||||||||||||||||||||||
12037 | for (QWidget *tabWidget = widget; tabWidget; tabWidget = tabWidget->parentWidget()) | - | ||||||||||||||||||||||||||||||||||||
12038 | if (qobject_cast<const QTabWidget*>(tabWidget)) | - | ||||||||||||||||||||||||||||||||||||
12039 | return true; | - | ||||||||||||||||||||||||||||||||||||
12040 | return false; | - | ||||||||||||||||||||||||||||||||||||
12041 | } | - | ||||||||||||||||||||||||||||||||||||
12042 | #endif | - | ||||||||||||||||||||||||||||||||||||
12043 | - | |||||||||||||||||||||||||||||||||||||
12044 | /*! | - | ||||||||||||||||||||||||||||||||||||
12045 | \since 5.0 | - | ||||||||||||||||||||||||||||||||||||
12046 | \internal | - | ||||||||||||||||||||||||||||||||||||
12047 | - | |||||||||||||||||||||||||||||||||||||
12048 | Sets the backing store to be the \a store specified. | - | ||||||||||||||||||||||||||||||||||||
12049 | The QWidget will take ownership of the \a store. | - | ||||||||||||||||||||||||||||||||||||
12050 | */ | - | ||||||||||||||||||||||||||||||||||||
12051 | void QWidget::setBackingStore(QBackingStore *store) | - | ||||||||||||||||||||||||||||||||||||
12052 | { | - | ||||||||||||||||||||||||||||||||||||
12053 | // ### createWinId() ?? | - | ||||||||||||||||||||||||||||||||||||
12054 | - | |||||||||||||||||||||||||||||||||||||
12055 | if (!isTopLevel())
| 0 | ||||||||||||||||||||||||||||||||||||
12056 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12057 | - | |||||||||||||||||||||||||||||||||||||
12058 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12059 | - | |||||||||||||||||||||||||||||||||||||
12060 | QTLWExtra *topData = d->topData(); | - | ||||||||||||||||||||||||||||||||||||
12061 | if (topData->backingStore == store)
| 0 | ||||||||||||||||||||||||||||||||||||
12062 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12063 | - | |||||||||||||||||||||||||||||||||||||
12064 | QBackingStore *oldStore = topData->backingStore; | - | ||||||||||||||||||||||||||||||||||||
12065 | deleteBackingStore(d); | - | ||||||||||||||||||||||||||||||||||||
12066 | topData->backingStore = store; | - | ||||||||||||||||||||||||||||||||||||
12067 | - | |||||||||||||||||||||||||||||||||||||
12068 | QWidgetBackingStore *bs = d->maybeBackingStore(); | - | ||||||||||||||||||||||||||||||||||||
12069 | if (!bs)
| 0 | ||||||||||||||||||||||||||||||||||||
12070 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12071 | - | |||||||||||||||||||||||||||||||||||||
12072 | if (isTopLevel()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12073 | if (bs->store != oldStore && bs->store != store)
| 0 | ||||||||||||||||||||||||||||||||||||
12074 | delete bs->store; never executed: delete bs->store; | 0 | ||||||||||||||||||||||||||||||||||||
12075 | bs->store = store; | - | ||||||||||||||||||||||||||||||||||||
12076 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12077 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12078 | - | |||||||||||||||||||||||||||||||||||||
12079 | /*! | - | ||||||||||||||||||||||||||||||||||||
12080 | \since 5.0 | - | ||||||||||||||||||||||||||||||||||||
12081 | - | |||||||||||||||||||||||||||||||||||||
12082 | Returns the QBackingStore this widget will be drawn into. | - | ||||||||||||||||||||||||||||||||||||
12083 | */ | - | ||||||||||||||||||||||||||||||||||||
12084 | QBackingStore *QWidget::backingStore() const | - | ||||||||||||||||||||||||||||||||||||
12085 | { | - | ||||||||||||||||||||||||||||||||||||
12086 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
12087 | QTLWExtra *extra = d->maybeTopData(); | - | ||||||||||||||||||||||||||||||||||||
12088 | if (extra && extra->backingStore)
| 0 | ||||||||||||||||||||||||||||||||||||
12089 | return extra->backingStore; never executed: return extra->backingStore; | 0 | ||||||||||||||||||||||||||||||||||||
12090 | - | |||||||||||||||||||||||||||||||||||||
12091 | QWidgetBackingStore *bs = d->maybeBackingStore(); | - | ||||||||||||||||||||||||||||||||||||
12092 | - | |||||||||||||||||||||||||||||||||||||
12093 | return bs ? bs->store : 0; never executed: return bs ? bs->store : 0;
| 0 | ||||||||||||||||||||||||||||||||||||
12094 | } | - | ||||||||||||||||||||||||||||||||||||
12095 | - | |||||||||||||||||||||||||||||||||||||
12096 | void QWidgetPrivate::getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const | - | ||||||||||||||||||||||||||||||||||||
12097 | { | - | ||||||||||||||||||||||||||||||||||||
12098 | if (left)
| 0 | ||||||||||||||||||||||||||||||||||||
12099 | *left = (int)leftLayoutItemMargin; never executed: *left = (int)leftLayoutItemMargin; | 0 | ||||||||||||||||||||||||||||||||||||
12100 | if (top)
| 0 | ||||||||||||||||||||||||||||||||||||
12101 | *top = (int)topLayoutItemMargin; never executed: *top = (int)topLayoutItemMargin; | 0 | ||||||||||||||||||||||||||||||||||||
12102 | if (right)
| 0 | ||||||||||||||||||||||||||||||||||||
12103 | *right = (int)rightLayoutItemMargin; never executed: *right = (int)rightLayoutItemMargin; | 0 | ||||||||||||||||||||||||||||||||||||
12104 | if (bottom)
| 0 | ||||||||||||||||||||||||||||||||||||
12105 | *bottom = (int)bottomLayoutItemMargin; never executed: *bottom = (int)bottomLayoutItemMargin; | 0 | ||||||||||||||||||||||||||||||||||||
12106 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12107 | - | |||||||||||||||||||||||||||||||||||||
12108 | void QWidgetPrivate::setLayoutItemMargins(int left, int top, int right, int bottom) | - | ||||||||||||||||||||||||||||||||||||
12109 | { | - | ||||||||||||||||||||||||||||||||||||
12110 | if (leftLayoutItemMargin == left
| 0 | ||||||||||||||||||||||||||||||||||||
12111 | && topLayoutItemMargin == top
| 0 | ||||||||||||||||||||||||||||||||||||
12112 | && rightLayoutItemMargin == right
| 0 | ||||||||||||||||||||||||||||||||||||
12113 | && bottomLayoutItemMargin == bottom)
| 0 | ||||||||||||||||||||||||||||||||||||
12114 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12115 | - | |||||||||||||||||||||||||||||||||||||
12116 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12117 | leftLayoutItemMargin = (signed char)left; | - | ||||||||||||||||||||||||||||||||||||
12118 | topLayoutItemMargin = (signed char)top; | - | ||||||||||||||||||||||||||||||||||||
12119 | rightLayoutItemMargin = (signed char)right; | - | ||||||||||||||||||||||||||||||||||||
12120 | bottomLayoutItemMargin = (signed char)bottom; | - | ||||||||||||||||||||||||||||||||||||
12121 | q->updateGeometry(); | - | ||||||||||||||||||||||||||||||||||||
12122 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12123 | - | |||||||||||||||||||||||||||||||||||||
12124 | void QWidgetPrivate::setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt) | - | ||||||||||||||||||||||||||||||||||||
12125 | { | - | ||||||||||||||||||||||||||||||||||||
12126 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12127 | QStyleOption myOpt; | - | ||||||||||||||||||||||||||||||||||||
12128 | if (!opt) {
| 0 | ||||||||||||||||||||||||||||||||||||
12129 | myOpt.initFrom(q); | - | ||||||||||||||||||||||||||||||||||||
12130 | myOpt.rect.setRect(0, 0, 32768, 32768); // arbitrary | - | ||||||||||||||||||||||||||||||||||||
12131 | opt = &myOpt; | - | ||||||||||||||||||||||||||||||||||||
12132 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12133 | - | |||||||||||||||||||||||||||||||||||||
12134 | QRect liRect = q->style()->subElementRect(element, opt, q); | - | ||||||||||||||||||||||||||||||||||||
12135 | if (liRect.isValid()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12136 | leftLayoutItemMargin = (signed char)(opt->rect.left() - liRect.left()); | - | ||||||||||||||||||||||||||||||||||||
12137 | topLayoutItemMargin = (signed char)(opt->rect.top() - liRect.top()); | - | ||||||||||||||||||||||||||||||||||||
12138 | rightLayoutItemMargin = (signed char)(liRect.right() - opt->rect.right()); | - | ||||||||||||||||||||||||||||||||||||
12139 | bottomLayoutItemMargin = (signed char)(liRect.bottom() - opt->rect.bottom()); | - | ||||||||||||||||||||||||||||||||||||
12140 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12141 | leftLayoutItemMargin = 0; | - | ||||||||||||||||||||||||||||||||||||
12142 | topLayoutItemMargin = 0; | - | ||||||||||||||||||||||||||||||||||||
12143 | rightLayoutItemMargin = 0; | - | ||||||||||||||||||||||||||||||||||||
12144 | bottomLayoutItemMargin = 0; | - | ||||||||||||||||||||||||||||||||||||
12145 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12146 | } | - | ||||||||||||||||||||||||||||||||||||
12147 | // resets the Qt::WA_QuitOnClose attribute to the default value for transient widgets. | - | ||||||||||||||||||||||||||||||||||||
12148 | void QWidgetPrivate::adjustQuitOnCloseAttribute() | - | ||||||||||||||||||||||||||||||||||||
12149 | { | - | ||||||||||||||||||||||||||||||||||||
12150 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12151 | - | |||||||||||||||||||||||||||||||||||||
12152 | if (!q->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12153 | Qt::WindowType type = q->windowType(); | - | ||||||||||||||||||||||||||||||||||||
12154 | if (type == Qt::Widget || type == Qt::SubWindow)
| 0 | ||||||||||||||||||||||||||||||||||||
12155 | type = Qt::Window; never executed: type = Qt::Window; | 0 | ||||||||||||||||||||||||||||||||||||
12156 | if (type != Qt::Widget && type != Qt::Window && type != Qt::Dialog)
| 0 | ||||||||||||||||||||||||||||||||||||
12157 | q->setAttribute(Qt::WA_QuitOnClose, false); never executed: q->setAttribute(Qt::WA_QuitOnClose, false); | 0 | ||||||||||||||||||||||||||||||||||||
12158 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12159 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12160 | - | |||||||||||||||||||||||||||||||||||||
12161 | QOpenGLContext *QWidgetPrivate::shareContext() const | - | ||||||||||||||||||||||||||||||||||||
12162 | { | - | ||||||||||||||||||||||||||||||||||||
12163 | #ifdef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
12164 | return 0; | - | ||||||||||||||||||||||||||||||||||||
12165 | #else | - | ||||||||||||||||||||||||||||||||||||
12166 | if (!extra || !extra->topextra || !extra->topextra->window) {
| 0 | ||||||||||||||||||||||||||||||||||||
12167 | qWarning("Asking for share context for widget that does not have a window handle"); | - | ||||||||||||||||||||||||||||||||||||
12168 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
12169 | } | - | ||||||||||||||||||||||||||||||||||||
12170 | QWidgetPrivate *that = const_cast<QWidgetPrivate *>(this); | - | ||||||||||||||||||||||||||||||||||||
12171 | if (!extra->topextra->shareContext) {
| 0 | ||||||||||||||||||||||||||||||||||||
12172 | QOpenGLContext *ctx = new QOpenGLContext; | - | ||||||||||||||||||||||||||||||||||||
12173 | ctx->setShareContext(qt_gl_global_share_context()); | - | ||||||||||||||||||||||||||||||||||||
12174 | ctx->setFormat(extra->topextra->window->format()); | - | ||||||||||||||||||||||||||||||||||||
12175 | ctx->setScreen(extra->topextra->window->screen()); | - | ||||||||||||||||||||||||||||||||||||
12176 | ctx->create(); | - | ||||||||||||||||||||||||||||||||||||
12177 | that->extra->topextra->shareContext = ctx; | - | ||||||||||||||||||||||||||||||||||||
12178 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12179 | return that->extra->topextra->shareContext; never executed: return that->extra->topextra->shareContext; | 0 | ||||||||||||||||||||||||||||||||||||
12180 | #endif // QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
12181 | } | - | ||||||||||||||||||||||||||||||||||||
12182 | - | |||||||||||||||||||||||||||||||||||||
12183 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
12184 | void QWidgetPrivate::sendComposeStatus(QWidget *w, bool end) | - | ||||||||||||||||||||||||||||||||||||
12185 | { | - | ||||||||||||||||||||||||||||||||||||
12186 | QWidgetPrivate *wd = QWidgetPrivate::get(w); | - | ||||||||||||||||||||||||||||||||||||
12187 | if (!wd->textureChildSeen)
| 0 | ||||||||||||||||||||||||||||||||||||
12188 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12189 | if (end)
| 0 | ||||||||||||||||||||||||||||||||||||
12190 | wd->endCompose(); never executed: wd->endCompose(); | 0 | ||||||||||||||||||||||||||||||||||||
12191 | else | - | ||||||||||||||||||||||||||||||||||||
12192 | wd->beginCompose(); never executed: wd->beginCompose(); | 0 | ||||||||||||||||||||||||||||||||||||
12193 | for (int i = 0; i < wd->children.size(); ++i) {
| 0 | ||||||||||||||||||||||||||||||||||||
12194 | w = qobject_cast<QWidget *>(wd->children.at(i)); | - | ||||||||||||||||||||||||||||||||||||
12195 | if (w && !w->isWindow() && !w->isHidden() && QWidgetPrivate::get(w)->textureChildSeen)
| 0 | ||||||||||||||||||||||||||||||||||||
12196 | sendComposeStatus(w, end); never executed: sendComposeStatus(w, end); | 0 | ||||||||||||||||||||||||||||||||||||
12197 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12198 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12199 | #endif // QT_NO_OPENGL | - | ||||||||||||||||||||||||||||||||||||
12200 | - | |||||||||||||||||||||||||||||||||||||
12201 | Q_WIDGETS_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
12202 | { | - | ||||||||||||||||||||||||||||||||||||
12203 | return widget->data; never executed: return widget->data; | 0 | ||||||||||||||||||||||||||||||||||||
12204 | } | - | ||||||||||||||||||||||||||||||||||||
12205 | - | |||||||||||||||||||||||||||||||||||||
12206 | Q_WIDGETS_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
12207 | { | - | ||||||||||||||||||||||||||||||||||||
12208 | return widget->d_func(); never executed: return widget->d_func(); | 0 | ||||||||||||||||||||||||||||||||||||
12209 | } | - | ||||||||||||||||||||||||||||||||||||
12210 | - | |||||||||||||||||||||||||||||||||||||
12211 | - | |||||||||||||||||||||||||||||||||||||
12212 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
12213 | /*! | - | ||||||||||||||||||||||||||||||||||||
12214 | \since 4.5 | - | ||||||||||||||||||||||||||||||||||||
12215 | - | |||||||||||||||||||||||||||||||||||||
12216 | Returns the proxy widget for the corresponding embedded widget in a graphics | - | ||||||||||||||||||||||||||||||||||||
12217 | view; otherwise returns 0. | - | ||||||||||||||||||||||||||||||||||||
12218 | - | |||||||||||||||||||||||||||||||||||||
12219 | \sa QGraphicsProxyWidget::createProxyForChildWidget(), | - | ||||||||||||||||||||||||||||||||||||
12220 | QGraphicsScene::addWidget() | - | ||||||||||||||||||||||||||||||||||||
12221 | */ | - | ||||||||||||||||||||||||||||||||||||
12222 | QGraphicsProxyWidget *QWidget::graphicsProxyWidget() const | - | ||||||||||||||||||||||||||||||||||||
12223 | { | - | ||||||||||||||||||||||||||||||||||||
12224 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
12225 | if (d->extra) {
| 0 | ||||||||||||||||||||||||||||||||||||
12226 | return d->extra->proxyWidget; never executed: return d->extra->proxyWidget; | 0 | ||||||||||||||||||||||||||||||||||||
12227 | } | - | ||||||||||||||||||||||||||||||||||||
12228 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
12229 | } | - | ||||||||||||||||||||||||||||||||||||
12230 | #endif | - | ||||||||||||||||||||||||||||||||||||
12231 | - | |||||||||||||||||||||||||||||||||||||
12232 | #ifndef QT_NO_GESTURES | - | ||||||||||||||||||||||||||||||||||||
12233 | /*! | - | ||||||||||||||||||||||||||||||||||||
12234 | Subscribes the widget to a given \a gesture with specific \a flags. | - | ||||||||||||||||||||||||||||||||||||
12235 | - | |||||||||||||||||||||||||||||||||||||
12236 | \sa ungrabGesture(), QGestureEvent | - | ||||||||||||||||||||||||||||||||||||
12237 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
12238 | */ | - | ||||||||||||||||||||||||||||||||||||
12239 | void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags) | - | ||||||||||||||||||||||||||||||||||||
12240 | { | - | ||||||||||||||||||||||||||||||||||||
12241 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12242 | d->gestureContext.insert(gesture, flags); | - | ||||||||||||||||||||||||||||||||||||
12243 | (void)QGestureManager::instance(); // create a gesture manager | - | ||||||||||||||||||||||||||||||||||||
12244 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12245 | - | |||||||||||||||||||||||||||||||||||||
12246 | /*! | - | ||||||||||||||||||||||||||||||||||||
12247 | Unsubscribes the widget from a given \a gesture type | - | ||||||||||||||||||||||||||||||||||||
12248 | - | |||||||||||||||||||||||||||||||||||||
12249 | \sa grabGesture(), QGestureEvent | - | ||||||||||||||||||||||||||||||||||||
12250 | \since 4.6 | - | ||||||||||||||||||||||||||||||||||||
12251 | */ | - | ||||||||||||||||||||||||||||||||||||
12252 | void QWidget::ungrabGesture(Qt::GestureType gesture) | - | ||||||||||||||||||||||||||||||||||||
12253 | { | - | ||||||||||||||||||||||||||||||||||||
12254 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12255 | if (d->gestureContext.remove(gesture)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12256 | if (QGestureManager *manager = QGestureManager::instance())
| 0 | ||||||||||||||||||||||||||||||||||||
12257 | manager->cleanupCachedGestures(this, gesture); never executed: manager->cleanupCachedGestures(this, gesture); | 0 | ||||||||||||||||||||||||||||||||||||
12258 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12259 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12260 | #endif // QT_NO_GESTURES | - | ||||||||||||||||||||||||||||||||||||
12261 | - | |||||||||||||||||||||||||||||||||||||
12262 | /*! | - | ||||||||||||||||||||||||||||||||||||
12263 | \fn void QWidget::destroy(bool destroyWindow, bool destroySubWindows) | - | ||||||||||||||||||||||||||||||||||||
12264 | - | |||||||||||||||||||||||||||||||||||||
12265 | Frees up window system resources. Destroys the widget window if \a | - | ||||||||||||||||||||||||||||||||||||
12266 | destroyWindow is true. | - | ||||||||||||||||||||||||||||||||||||
12267 | - | |||||||||||||||||||||||||||||||||||||
12268 | destroy() calls itself recursively for all the child widgets, | - | ||||||||||||||||||||||||||||||||||||
12269 | passing \a destroySubWindows for the \a destroyWindow parameter. | - | ||||||||||||||||||||||||||||||||||||
12270 | To have more control over destruction of subwidgets, destroy | - | ||||||||||||||||||||||||||||||||||||
12271 | subwidgets selectively first. | - | ||||||||||||||||||||||||||||||||||||
12272 | - | |||||||||||||||||||||||||||||||||||||
12273 | This function is usually called from the QWidget destructor. | - | ||||||||||||||||||||||||||||||||||||
12274 | */ | - | ||||||||||||||||||||||||||||||||||||
12275 | void QWidget::destroy(bool destroyWindow, bool destroySubWindows) | - | ||||||||||||||||||||||||||||||||||||
12276 | { | - | ||||||||||||||||||||||||||||||||||||
12277 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12278 | - | |||||||||||||||||||||||||||||||||||||
12279 | d->aboutToDestroy(); | - | ||||||||||||||||||||||||||||||||||||
12280 | if (!isWindow() && parentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
12281 | parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry())); never executed: parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry())); | 0 | ||||||||||||||||||||||||||||||||||||
12282 | d->deactivateWidgetCleanup(); | - | ||||||||||||||||||||||||||||||||||||
12283 | - | |||||||||||||||||||||||||||||||||||||
12284 | if ((windowType() == Qt::Popup) && qApp)
| 0 | ||||||||||||||||||||||||||||||||||||
12285 | qApp->d_func()->closePopup(this); never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->closePopup(this); | 0 | ||||||||||||||||||||||||||||||||||||
12286 | - | |||||||||||||||||||||||||||||||||||||
12287 | if (this == QApplicationPrivate::active_window)
| 0 | ||||||||||||||||||||||||||||||||||||
12288 | QApplication::setActiveWindow(0); never executed: QApplication::setActiveWindow(0); | 0 | ||||||||||||||||||||||||||||||||||||
12289 | if (QWidget::mouseGrabber() == this)
| 0 | ||||||||||||||||||||||||||||||||||||
12290 | releaseMouse(); never executed: releaseMouse(); | 0 | ||||||||||||||||||||||||||||||||||||
12291 | if (QWidget::keyboardGrabber() == this)
| 0 | ||||||||||||||||||||||||||||||||||||
12292 | releaseKeyboard(); never executed: releaseKeyboard(); | 0 | ||||||||||||||||||||||||||||||||||||
12293 | - | |||||||||||||||||||||||||||||||||||||
12294 | setAttribute(Qt::WA_WState_Created, false); | - | ||||||||||||||||||||||||||||||||||||
12295 | - | |||||||||||||||||||||||||||||||||||||
12296 | if (windowType() != Qt::Desktop) {
| 0 | ||||||||||||||||||||||||||||||||||||
12297 | if (destroySubWindows) {
| 0 | ||||||||||||||||||||||||||||||||||||
12298 | QObjectList childList(children()); | - | ||||||||||||||||||||||||||||||||||||
12299 | for (int i = 0; i < childList.size(); i++) {
| 0 | ||||||||||||||||||||||||||||||||||||
12300 | QWidget *widget = qobject_cast<QWidget *>(childList.at(i)); | - | ||||||||||||||||||||||||||||||||||||
12301 | if (widget && widget->testAttribute(Qt::WA_NativeWindow)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12302 | if (widget->windowHandle()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12303 | widget->destroy(); | - | ||||||||||||||||||||||||||||||||||||
12304 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12305 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12306 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12307 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12308 | if (destroyWindow) {
| 0 | ||||||||||||||||||||||||||||||||||||
12309 | d->deleteTLSysExtra(); | - | ||||||||||||||||||||||||||||||||||||
12310 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12311 | if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12312 | d->hide_sys(); | - | ||||||||||||||||||||||||||||||||||||
12313 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12314 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12315 | - | |||||||||||||||||||||||||||||||||||||
12316 | d->setWinId(0); | - | ||||||||||||||||||||||||||||||||||||
12317 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12318 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12319 | - | |||||||||||||||||||||||||||||||||||||
12320 | /*! | - | ||||||||||||||||||||||||||||||||||||
12321 | \fn QPaintEngine *QWidget::paintEngine() const | - | ||||||||||||||||||||||||||||||||||||
12322 | - | |||||||||||||||||||||||||||||||||||||
12323 | Returns the widget's paint engine. | - | ||||||||||||||||||||||||||||||||||||
12324 | - | |||||||||||||||||||||||||||||||||||||
12325 | Note that this function should not be called explicitly by the | - | ||||||||||||||||||||||||||||||||||||
12326 | user, since it's meant for reimplementation purposes only. The | - | ||||||||||||||||||||||||||||||||||||
12327 | function is called by Qt internally, and the default | - | ||||||||||||||||||||||||||||||||||||
12328 | implementation may not always return a valid pointer. | - | ||||||||||||||||||||||||||||||||||||
12329 | */ | - | ||||||||||||||||||||||||||||||||||||
12330 | QPaintEngine *QWidget::paintEngine() const | - | ||||||||||||||||||||||||||||||||||||
12331 | { | - | ||||||||||||||||||||||||||||||||||||
12332 | qWarning("QWidget::paintEngine: Should no longer be called"); | - | ||||||||||||||||||||||||||||||||||||
12333 | - | |||||||||||||||||||||||||||||||||||||
12334 | #ifdef Q_OS_WIN | - | ||||||||||||||||||||||||||||||||||||
12335 | // We set this bit which is checked in setAttribute for | - | ||||||||||||||||||||||||||||||||||||
12336 | // Qt::WA_PaintOnScreen. We do this to allow these two scenarios: | - | ||||||||||||||||||||||||||||||||||||
12337 | // | - | ||||||||||||||||||||||||||||||||||||
12338 | // 1. Users accidentally set Qt::WA_PaintOnScreen on X and port to | - | ||||||||||||||||||||||||||||||||||||
12339 | // Windows which would mean suddenly their widgets stop working. | - | ||||||||||||||||||||||||||||||||||||
12340 | // | - | ||||||||||||||||||||||||||||||||||||
12341 | // 2. Users set paint on screen and subclass paintEngine() to | - | ||||||||||||||||||||||||||||||||||||
12342 | // return 0, in which case we have a "hole" in the backingstore | - | ||||||||||||||||||||||||||||||||||||
12343 | // allowing use of GDI or DirectX directly. | - | ||||||||||||||||||||||||||||||||||||
12344 | // | - | ||||||||||||||||||||||||||||||||||||
12345 | // 1 is WRONG, but to minimize silent failures, we have set this | - | ||||||||||||||||||||||||||||||||||||
12346 | // bit to ignore the setAttribute call. 2. needs to be | - | ||||||||||||||||||||||||||||||||||||
12347 | // supported because its our only means of embedding native | - | ||||||||||||||||||||||||||||||||||||
12348 | // graphics stuff. | - | ||||||||||||||||||||||||||||||||||||
12349 | const_cast<QWidgetPrivate *>(d_func())->noPaintOnScreen = 1; | - | ||||||||||||||||||||||||||||||||||||
12350 | #endif | - | ||||||||||||||||||||||||||||||||||||
12351 | - | |||||||||||||||||||||||||||||||||||||
12352 | return 0; //##### @@@ never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
12353 | } | - | ||||||||||||||||||||||||||||||||||||
12354 | - | |||||||||||||||||||||||||||||||||||||
12355 | // Do not call QWindow::mapToGlobal() until QPlatformWindow is properly showing. | - | ||||||||||||||||||||||||||||||||||||
12356 | static inline bool canMapPosition(QWindow *window) | - | ||||||||||||||||||||||||||||||||||||
12357 | { | - | ||||||||||||||||||||||||||||||||||||
12358 | return window->handle() && !qt_window_private(window)->resizeEventPending; never executed: return window->handle() && !qt_window_private(window)->resizeEventPending;
| 0 | ||||||||||||||||||||||||||||||||||||
12359 | } | - | ||||||||||||||||||||||||||||||||||||
12360 | - | |||||||||||||||||||||||||||||||||||||
12361 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
12362 | static inline QGraphicsProxyWidget *graphicsProxyWidget(const QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
12363 | { | - | ||||||||||||||||||||||||||||||||||||
12364 | QGraphicsProxyWidget *result = Q_NULLPTR; | - | ||||||||||||||||||||||||||||||||||||
12365 | const QWidgetPrivate *d = qt_widget_private(const_cast<QWidget *>(w)); | - | ||||||||||||||||||||||||||||||||||||
12366 | if (d->extra)
| 0 | ||||||||||||||||||||||||||||||||||||
12367 | result = d->extra->proxyWidget; never executed: result = d->extra->proxyWidget; | 0 | ||||||||||||||||||||||||||||||||||||
12368 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||||||||||||||
12369 | } | - | ||||||||||||||||||||||||||||||||||||
12370 | #endif // !QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
12371 | - | |||||||||||||||||||||||||||||||||||||
12372 | struct MapToGlobalTransformResult { | - | ||||||||||||||||||||||||||||||||||||
12373 | QTransform transform; | - | ||||||||||||||||||||||||||||||||||||
12374 | QWindow *window; | - | ||||||||||||||||||||||||||||||||||||
12375 | }; | - | ||||||||||||||||||||||||||||||||||||
12376 | - | |||||||||||||||||||||||||||||||||||||
12377 | static MapToGlobalTransformResult mapToGlobalTransform(const QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
12378 | { | - | ||||||||||||||||||||||||||||||||||||
12379 | MapToGlobalTransformResult result; | - | ||||||||||||||||||||||||||||||||||||
12380 | result.window = Q_NULLPTR; | - | ||||||||||||||||||||||||||||||||||||
12381 | for ( ; w ; w = w->parentWidget()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12382 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
12383 | if (QGraphicsProxyWidget *qgpw = graphicsProxyWidget(w)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12384 | if (const QGraphicsScene *scene = qgpw->scene()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12385 | const QList <QGraphicsView *> views = scene->views(); | - | ||||||||||||||||||||||||||||||||||||
12386 | if (!views.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12387 | result.transform *= qgpw->sceneTransform(); | - | ||||||||||||||||||||||||||||||||||||
12388 | result.transform *= views.first()->viewportTransform(); | - | ||||||||||||||||||||||||||||||||||||
12389 | w = views.first()->viewport(); | - | ||||||||||||||||||||||||||||||||||||
12390 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12391 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12392 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12393 | #endif // !QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||||||||||||||
12394 | QWindow *window = w->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
12395 | if (window && canMapPosition(window)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12396 | result.window = window; | - | ||||||||||||||||||||||||||||||||||||
12397 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
12398 | } | - | ||||||||||||||||||||||||||||||||||||
12399 | - | |||||||||||||||||||||||||||||||||||||
12400 | const QPoint topLeft = w->geometry().topLeft(); | - | ||||||||||||||||||||||||||||||||||||
12401 | result.transform.translate(topLeft.x(), topLeft.y()); | - | ||||||||||||||||||||||||||||||||||||
12402 | if (w->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
12403 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
12404 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12405 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||||||||||||||
12406 | } | - | ||||||||||||||||||||||||||||||||||||
12407 | - | |||||||||||||||||||||||||||||||||||||
12408 | /*! | - | ||||||||||||||||||||||||||||||||||||
12409 | \fn QPoint QWidget::mapToGlobal(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
12410 | - | |||||||||||||||||||||||||||||||||||||
12411 | Translates the widget coordinate \a pos to global screen | - | ||||||||||||||||||||||||||||||||||||
12412 | coordinates. For example, \c{mapToGlobal(QPoint(0,0))} would give | - | ||||||||||||||||||||||||||||||||||||
12413 | the global coordinates of the top-left pixel of the widget. | - | ||||||||||||||||||||||||||||||||||||
12414 | - | |||||||||||||||||||||||||||||||||||||
12415 | \sa mapFromGlobal(), mapTo(), mapToParent() | - | ||||||||||||||||||||||||||||||||||||
12416 | */ | - | ||||||||||||||||||||||||||||||||||||
12417 | QPoint QWidget::mapToGlobal(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
12418 | { | - | ||||||||||||||||||||||||||||||||||||
12419 | const MapToGlobalTransformResult t = mapToGlobalTransform(this); | - | ||||||||||||||||||||||||||||||||||||
12420 | const QPoint g = t.transform.map(pos); | - | ||||||||||||||||||||||||||||||||||||
12421 | return t.window ? t.window->mapToGlobal(g) : g; never executed: return t.window ? t.window->mapToGlobal(g) : g;
| 0 | ||||||||||||||||||||||||||||||||||||
12422 | } | - | ||||||||||||||||||||||||||||||||||||
12423 | - | |||||||||||||||||||||||||||||||||||||
12424 | /*! | - | ||||||||||||||||||||||||||||||||||||
12425 | \fn QPoint QWidget::mapFromGlobal(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
12426 | - | |||||||||||||||||||||||||||||||||||||
12427 | Translates the global screen coordinate \a pos to widget | - | ||||||||||||||||||||||||||||||||||||
12428 | coordinates. | - | ||||||||||||||||||||||||||||||||||||
12429 | - | |||||||||||||||||||||||||||||||||||||
12430 | \sa mapToGlobal(), mapFrom(), mapFromParent() | - | ||||||||||||||||||||||||||||||||||||
12431 | */ | - | ||||||||||||||||||||||||||||||||||||
12432 | QPoint QWidget::mapFromGlobal(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
12433 | { | - | ||||||||||||||||||||||||||||||||||||
12434 | const MapToGlobalTransformResult t = mapToGlobalTransform(this); | - | ||||||||||||||||||||||||||||||||||||
12435 | const QPoint windowLocal = t.window ? t.window->mapFromGlobal(pos) : pos;
| 0 | ||||||||||||||||||||||||||||||||||||
12436 | return t.transform.inverted().map(windowLocal); never executed: return t.transform.inverted().map(windowLocal); | 0 | ||||||||||||||||||||||||||||||||||||
12437 | } | - | ||||||||||||||||||||||||||||||||||||
12438 | - | |||||||||||||||||||||||||||||||||||||
12439 | QWidget *qt_pressGrab = 0; | - | ||||||||||||||||||||||||||||||||||||
12440 | QWidget *qt_mouseGrb = 0; | - | ||||||||||||||||||||||||||||||||||||
12441 | static bool mouseGrabWithCursor = false; | - | ||||||||||||||||||||||||||||||||||||
12442 | static QWidget *keyboardGrb = 0; | - | ||||||||||||||||||||||||||||||||||||
12443 | - | |||||||||||||||||||||||||||||||||||||
12444 | static inline QWindow *grabberWindow(const QWidget *w) | - | ||||||||||||||||||||||||||||||||||||
12445 | { | - | ||||||||||||||||||||||||||||||||||||
12446 | QWindow *window = w->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
12447 | if (!window)
| 0 | ||||||||||||||||||||||||||||||||||||
12448 | if (const QWidget *nativeParent = w->nativeParentWidget())
| 0 | ||||||||||||||||||||||||||||||||||||
12449 | window = nativeParent->windowHandle(); never executed: window = nativeParent->windowHandle(); | 0 | ||||||||||||||||||||||||||||||||||||
12450 | return window; never executed: return window; | 0 | ||||||||||||||||||||||||||||||||||||
12451 | } | - | ||||||||||||||||||||||||||||||||||||
12452 | - | |||||||||||||||||||||||||||||||||||||
12453 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
12454 | static void grabMouseForWidget(QWidget *widget, const QCursor *cursor = 0) | - | ||||||||||||||||||||||||||||||||||||
12455 | #else | - | ||||||||||||||||||||||||||||||||||||
12456 | static void grabMouseForWidget(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
12457 | #endif | - | ||||||||||||||||||||||||||||||||||||
12458 | { | - | ||||||||||||||||||||||||||||||||||||
12459 | if (qt_mouseGrb)
| 0 | ||||||||||||||||||||||||||||||||||||
12460 | qt_mouseGrb->releaseMouse(); never executed: qt_mouseGrb->releaseMouse(); | 0 | ||||||||||||||||||||||||||||||||||||
12461 | - | |||||||||||||||||||||||||||||||||||||
12462 | mouseGrabWithCursor = false; | - | ||||||||||||||||||||||||||||||||||||
12463 | if (QWindow *window = grabberWindow(widget)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12464 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
12465 | if (cursor) {
| 0 | ||||||||||||||||||||||||||||||||||||
12466 | mouseGrabWithCursor = true; | - | ||||||||||||||||||||||||||||||||||||
12467 | QGuiApplication::setOverrideCursor(*cursor); | - | ||||||||||||||||||||||||||||||||||||
12468 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12469 | #endif // !QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
12470 | window->setMouseGrabEnabled(true); | - | ||||||||||||||||||||||||||||||||||||
12471 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12472 | - | |||||||||||||||||||||||||||||||||||||
12473 | qt_mouseGrb = widget; | - | ||||||||||||||||||||||||||||||||||||
12474 | qt_pressGrab = 0; | - | ||||||||||||||||||||||||||||||||||||
12475 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12476 | - | |||||||||||||||||||||||||||||||||||||
12477 | static void releaseMouseGrabOfWidget(QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
12478 | { | - | ||||||||||||||||||||||||||||||||||||
12479 | if (qt_mouseGrb == widget) {
| 0 | ||||||||||||||||||||||||||||||||||||
12480 | if (QWindow *window = grabberWindow(widget)) {
| 0 | ||||||||||||||||||||||||||||||||||||
12481 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
12482 | if (mouseGrabWithCursor) {
| 0 | ||||||||||||||||||||||||||||||||||||
12483 | QGuiApplication::restoreOverrideCursor(); | - | ||||||||||||||||||||||||||||||||||||
12484 | mouseGrabWithCursor = false; | - | ||||||||||||||||||||||||||||||||||||
12485 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12486 | #endif // !QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
12487 | window->setMouseGrabEnabled(false); | - | ||||||||||||||||||||||||||||||||||||
12488 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12489 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12490 | qt_mouseGrb = 0; | - | ||||||||||||||||||||||||||||||||||||
12491 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12492 | - | |||||||||||||||||||||||||||||||||||||
12493 | /*! | - | ||||||||||||||||||||||||||||||||||||
12494 | \fn void QWidget::grabMouse() | - | ||||||||||||||||||||||||||||||||||||
12495 | - | |||||||||||||||||||||||||||||||||||||
12496 | Grabs the mouse input. | - | ||||||||||||||||||||||||||||||||||||
12497 | - | |||||||||||||||||||||||||||||||||||||
12498 | This widget receives all mouse events until releaseMouse() is | - | ||||||||||||||||||||||||||||||||||||
12499 | called; other widgets get no mouse events at all. Keyboard | - | ||||||||||||||||||||||||||||||||||||
12500 | events are not affected. Use grabKeyboard() if you want to grab | - | ||||||||||||||||||||||||||||||||||||
12501 | that. | - | ||||||||||||||||||||||||||||||||||||
12502 | - | |||||||||||||||||||||||||||||||||||||
12503 | \warning Bugs in mouse-grabbing applications very often lock the | - | ||||||||||||||||||||||||||||||||||||
12504 | terminal. Use this function with extreme caution, and consider | - | ||||||||||||||||||||||||||||||||||||
12505 | using the \c -nograb command line option while debugging. | - | ||||||||||||||||||||||||||||||||||||
12506 | - | |||||||||||||||||||||||||||||||||||||
12507 | It is almost never necessary to grab the mouse when using Qt, as | - | ||||||||||||||||||||||||||||||||||||
12508 | Qt grabs and releases it sensibly. In particular, Qt grabs the | - | ||||||||||||||||||||||||||||||||||||
12509 | mouse when a mouse button is pressed and keeps it until the last | - | ||||||||||||||||||||||||||||||||||||
12510 | button is released. | - | ||||||||||||||||||||||||||||||||||||
12511 | - | |||||||||||||||||||||||||||||||||||||
12512 | \note Only visible widgets can grab mouse input. If isVisible() | - | ||||||||||||||||||||||||||||||||||||
12513 | returns \c false for a widget, that widget cannot call grabMouse(). | - | ||||||||||||||||||||||||||||||||||||
12514 | - | |||||||||||||||||||||||||||||||||||||
12515 | \note On Windows, grabMouse() only works when the mouse is inside a window | - | ||||||||||||||||||||||||||||||||||||
12516 | owned by the process. | - | ||||||||||||||||||||||||||||||||||||
12517 | On \macos, grabMouse() only works when the mouse is inside the frame of that widget. | - | ||||||||||||||||||||||||||||||||||||
12518 | - | |||||||||||||||||||||||||||||||||||||
12519 | \sa releaseMouse(), grabKeyboard(), releaseKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12520 | */ | - | ||||||||||||||||||||||||||||||||||||
12521 | void QWidget::grabMouse() | - | ||||||||||||||||||||||||||||||||||||
12522 | { | - | ||||||||||||||||||||||||||||||||||||
12523 | grabMouseForWidget(this); | - | ||||||||||||||||||||||||||||||||||||
12524 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12525 | - | |||||||||||||||||||||||||||||||||||||
12526 | /*! | - | ||||||||||||||||||||||||||||||||||||
12527 | \fn void QWidget::grabMouse(const QCursor &cursor) | - | ||||||||||||||||||||||||||||||||||||
12528 | \overload grabMouse() | - | ||||||||||||||||||||||||||||||||||||
12529 | - | |||||||||||||||||||||||||||||||||||||
12530 | Grabs the mouse input and changes the cursor shape. | - | ||||||||||||||||||||||||||||||||||||
12531 | - | |||||||||||||||||||||||||||||||||||||
12532 | The cursor will assume shape \a cursor (for as long as the mouse | - | ||||||||||||||||||||||||||||||||||||
12533 | focus is grabbed) and this widget will be the only one to receive | - | ||||||||||||||||||||||||||||||||||||
12534 | mouse events until releaseMouse() is called(). | - | ||||||||||||||||||||||||||||||||||||
12535 | - | |||||||||||||||||||||||||||||||||||||
12536 | \warning Grabbing the mouse might lock the terminal. | - | ||||||||||||||||||||||||||||||||||||
12537 | - | |||||||||||||||||||||||||||||||||||||
12538 | \note See the note in QWidget::grabMouse(). | - | ||||||||||||||||||||||||||||||||||||
12539 | - | |||||||||||||||||||||||||||||||||||||
12540 | \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor() | - | ||||||||||||||||||||||||||||||||||||
12541 | */ | - | ||||||||||||||||||||||||||||||||||||
12542 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||||||||||||||
12543 | void QWidget::grabMouse(const QCursor &cursor) | - | ||||||||||||||||||||||||||||||||||||
12544 | { | - | ||||||||||||||||||||||||||||||||||||
12545 | grabMouseForWidget(this, &cursor); | - | ||||||||||||||||||||||||||||||||||||
12546 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12547 | #endif | - | ||||||||||||||||||||||||||||||||||||
12548 | - | |||||||||||||||||||||||||||||||||||||
12549 | bool QWidgetPrivate::stealMouseGrab(bool grab) | - | ||||||||||||||||||||||||||||||||||||
12550 | { | - | ||||||||||||||||||||||||||||||||||||
12551 | // This is like a combination of grab/releaseMouse() but with error checking | - | ||||||||||||||||||||||||||||||||||||
12552 | // and it has no effect on the result of mouseGrabber(). | - | ||||||||||||||||||||||||||||||||||||
12553 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12554 | QWindow *window = grabberWindow(q); | - | ||||||||||||||||||||||||||||||||||||
12555 | return window ? window->setMouseGrabEnabled(grab) : false; never executed: return window ? window->setMouseGrabEnabled(grab) : false;
| 0 | ||||||||||||||||||||||||||||||||||||
12556 | } | - | ||||||||||||||||||||||||||||||||||||
12557 | - | |||||||||||||||||||||||||||||||||||||
12558 | /*! | - | ||||||||||||||||||||||||||||||||||||
12559 | \fn void QWidget::releaseMouse() | - | ||||||||||||||||||||||||||||||||||||
12560 | - | |||||||||||||||||||||||||||||||||||||
12561 | Releases the mouse grab. | - | ||||||||||||||||||||||||||||||||||||
12562 | - | |||||||||||||||||||||||||||||||||||||
12563 | \sa grabMouse(), grabKeyboard(), releaseKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12564 | */ | - | ||||||||||||||||||||||||||||||||||||
12565 | void QWidget::releaseMouse() | - | ||||||||||||||||||||||||||||||||||||
12566 | { | - | ||||||||||||||||||||||||||||||||||||
12567 | releaseMouseGrabOfWidget(this); | - | ||||||||||||||||||||||||||||||||||||
12568 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12569 | - | |||||||||||||||||||||||||||||||||||||
12570 | /*! | - | ||||||||||||||||||||||||||||||||||||
12571 | \fn void QWidget::grabKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12572 | - | |||||||||||||||||||||||||||||||||||||
12573 | Grabs the keyboard input. | - | ||||||||||||||||||||||||||||||||||||
12574 | - | |||||||||||||||||||||||||||||||||||||
12575 | This widget receives all keyboard events until releaseKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12576 | is called; other widgets get no keyboard events at all. Mouse | - | ||||||||||||||||||||||||||||||||||||
12577 | events are not affected. Use grabMouse() if you want to grab that. | - | ||||||||||||||||||||||||||||||||||||
12578 | - | |||||||||||||||||||||||||||||||||||||
12579 | The focus widget is not affected, except that it doesn't receive | - | ||||||||||||||||||||||||||||||||||||
12580 | any keyboard events. setFocus() moves the focus as usual, but the | - | ||||||||||||||||||||||||||||||||||||
12581 | new focus widget receives keyboard events only after | - | ||||||||||||||||||||||||||||||||||||
12582 | releaseKeyboard() is called. | - | ||||||||||||||||||||||||||||||||||||
12583 | - | |||||||||||||||||||||||||||||||||||||
12584 | If a different widget is currently grabbing keyboard input, that | - | ||||||||||||||||||||||||||||||||||||
12585 | widget's grab is released first. | - | ||||||||||||||||||||||||||||||||||||
12586 | - | |||||||||||||||||||||||||||||||||||||
12587 | \sa releaseKeyboard(), grabMouse(), releaseMouse(), focusWidget() | - | ||||||||||||||||||||||||||||||||||||
12588 | */ | - | ||||||||||||||||||||||||||||||||||||
12589 | void QWidget::grabKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12590 | { | - | ||||||||||||||||||||||||||||||||||||
12591 | if (keyboardGrb)
| 0 | ||||||||||||||||||||||||||||||||||||
12592 | keyboardGrb->releaseKeyboard(); never executed: keyboardGrb->releaseKeyboard(); | 0 | ||||||||||||||||||||||||||||||||||||
12593 | if (QWindow *window = grabberWindow(this))
| 0 | ||||||||||||||||||||||||||||||||||||
12594 | window->setKeyboardGrabEnabled(true); never executed: window->setKeyboardGrabEnabled(true); | 0 | ||||||||||||||||||||||||||||||||||||
12595 | keyboardGrb = this; | - | ||||||||||||||||||||||||||||||||||||
12596 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12597 | - | |||||||||||||||||||||||||||||||||||||
12598 | bool QWidgetPrivate::stealKeyboardGrab(bool grab) | - | ||||||||||||||||||||||||||||||||||||
12599 | { | - | ||||||||||||||||||||||||||||||||||||
12600 | // This is like a combination of grab/releaseKeyboard() but with error | - | ||||||||||||||||||||||||||||||||||||
12601 | // checking and it has no effect on the result of keyboardGrabber(). | - | ||||||||||||||||||||||||||||||||||||
12602 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12603 | QWindow *window = grabberWindow(q); | - | ||||||||||||||||||||||||||||||||||||
12604 | return window ? window->setKeyboardGrabEnabled(grab) : false; never executed: return window ? window->setKeyboardGrabEnabled(grab) : false;
| 0 | ||||||||||||||||||||||||||||||||||||
12605 | } | - | ||||||||||||||||||||||||||||||||||||
12606 | - | |||||||||||||||||||||||||||||||||||||
12607 | /*! | - | ||||||||||||||||||||||||||||||||||||
12608 | \fn void QWidget::releaseKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12609 | - | |||||||||||||||||||||||||||||||||||||
12610 | Releases the keyboard grab. | - | ||||||||||||||||||||||||||||||||||||
12611 | - | |||||||||||||||||||||||||||||||||||||
12612 | \sa grabKeyboard(), grabMouse(), releaseMouse() | - | ||||||||||||||||||||||||||||||||||||
12613 | */ | - | ||||||||||||||||||||||||||||||||||||
12614 | void QWidget::releaseKeyboard() | - | ||||||||||||||||||||||||||||||||||||
12615 | { | - | ||||||||||||||||||||||||||||||||||||
12616 | if (keyboardGrb == this) {
| 0 | ||||||||||||||||||||||||||||||||||||
12617 | if (QWindow *window = grabberWindow(this))
| 0 | ||||||||||||||||||||||||||||||||||||
12618 | window->setKeyboardGrabEnabled(false); never executed: window->setKeyboardGrabEnabled(false); | 0 | ||||||||||||||||||||||||||||||||||||
12619 | keyboardGrb = 0; | - | ||||||||||||||||||||||||||||||||||||
12620 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12621 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12622 | - | |||||||||||||||||||||||||||||||||||||
12623 | /*! | - | ||||||||||||||||||||||||||||||||||||
12624 | \fn QWidget *QWidget::mouseGrabber() | - | ||||||||||||||||||||||||||||||||||||
12625 | - | |||||||||||||||||||||||||||||||||||||
12626 | Returns the widget that is currently grabbing the mouse input. | - | ||||||||||||||||||||||||||||||||||||
12627 | - | |||||||||||||||||||||||||||||||||||||
12628 | If no widget in this application is currently grabbing the mouse, | - | ||||||||||||||||||||||||||||||||||||
12629 | 0 is returned. | - | ||||||||||||||||||||||||||||||||||||
12630 | - | |||||||||||||||||||||||||||||||||||||
12631 | \sa grabMouse(), keyboardGrabber() | - | ||||||||||||||||||||||||||||||||||||
12632 | */ | - | ||||||||||||||||||||||||||||||||||||
12633 | QWidget *QWidget::mouseGrabber() | - | ||||||||||||||||||||||||||||||||||||
12634 | { | - | ||||||||||||||||||||||||||||||||||||
12635 | if (qt_mouseGrb)
| 0 | ||||||||||||||||||||||||||||||||||||
12636 | return qt_mouseGrb; never executed: return qt_mouseGrb; | 0 | ||||||||||||||||||||||||||||||||||||
12637 | return qt_pressGrab; never executed: return qt_pressGrab; | 0 | ||||||||||||||||||||||||||||||||||||
12638 | } | - | ||||||||||||||||||||||||||||||||||||
12639 | - | |||||||||||||||||||||||||||||||||||||
12640 | /*! | - | ||||||||||||||||||||||||||||||||||||
12641 | \fn QWidget *QWidget::keyboardGrabber() | - | ||||||||||||||||||||||||||||||||||||
12642 | - | |||||||||||||||||||||||||||||||||||||
12643 | Returns the widget that is currently grabbing the keyboard input. | - | ||||||||||||||||||||||||||||||||||||
12644 | - | |||||||||||||||||||||||||||||||||||||
12645 | If no widget in this application is currently grabbing the | - | ||||||||||||||||||||||||||||||||||||
12646 | keyboard, 0 is returned. | - | ||||||||||||||||||||||||||||||||||||
12647 | - | |||||||||||||||||||||||||||||||||||||
12648 | \sa grabMouse(), mouseGrabber() | - | ||||||||||||||||||||||||||||||||||||
12649 | */ | - | ||||||||||||||||||||||||||||||||||||
12650 | QWidget *QWidget::keyboardGrabber() | - | ||||||||||||||||||||||||||||||||||||
12651 | { | - | ||||||||||||||||||||||||||||||||||||
12652 | return keyboardGrb; never executed: return keyboardGrb; | 0 | ||||||||||||||||||||||||||||||||||||
12653 | } | - | ||||||||||||||||||||||||||||||||||||
12654 | - | |||||||||||||||||||||||||||||||||||||
12655 | /*! | - | ||||||||||||||||||||||||||||||||||||
12656 | \fn void QWidget::activateWindow() | - | ||||||||||||||||||||||||||||||||||||
12657 | - | |||||||||||||||||||||||||||||||||||||
12658 | Sets the top-level widget containing this widget to be the active | - | ||||||||||||||||||||||||||||||||||||
12659 | window. | - | ||||||||||||||||||||||||||||||||||||
12660 | - | |||||||||||||||||||||||||||||||||||||
12661 | An active window is a visible top-level window that has the | - | ||||||||||||||||||||||||||||||||||||
12662 | keyboard input focus. | - | ||||||||||||||||||||||||||||||||||||
12663 | - | |||||||||||||||||||||||||||||||||||||
12664 | This function performs the same operation as clicking the mouse on | - | ||||||||||||||||||||||||||||||||||||
12665 | the title bar of a top-level window. On X11, the result depends on | - | ||||||||||||||||||||||||||||||||||||
12666 | the Window Manager. If you want to ensure that the window is | - | ||||||||||||||||||||||||||||||||||||
12667 | stacked on top as well you should also call raise(). Note that the | - | ||||||||||||||||||||||||||||||||||||
12668 | window must be visible, otherwise activateWindow() has no effect. | - | ||||||||||||||||||||||||||||||||||||
12669 | - | |||||||||||||||||||||||||||||||||||||
12670 | On Windows, if you are calling this when the application is not | - | ||||||||||||||||||||||||||||||||||||
12671 | currently the active one then it will not make it the active | - | ||||||||||||||||||||||||||||||||||||
12672 | window. It will change the color of the taskbar entry to indicate | - | ||||||||||||||||||||||||||||||||||||
12673 | that the window has changed in some way. This is because Microsoft | - | ||||||||||||||||||||||||||||||||||||
12674 | does not allow an application to interrupt what the user is currently | - | ||||||||||||||||||||||||||||||||||||
12675 | doing in another application. | - | ||||||||||||||||||||||||||||||||||||
12676 | - | |||||||||||||||||||||||||||||||||||||
12677 | \sa isActiveWindow(), window(), show() | - | ||||||||||||||||||||||||||||||||||||
12678 | */ | - | ||||||||||||||||||||||||||||||||||||
12679 | void QWidget::activateWindow() | - | ||||||||||||||||||||||||||||||||||||
12680 | { | - | ||||||||||||||||||||||||||||||||||||
12681 | QWindow *const wnd = window()->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
12682 | - | |||||||||||||||||||||||||||||||||||||
12683 | if (wnd)
| 0 | ||||||||||||||||||||||||||||||||||||
12684 | wnd->requestActivate(); never executed: wnd->requestActivate(); | 0 | ||||||||||||||||||||||||||||||||||||
12685 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12686 | - | |||||||||||||||||||||||||||||||||||||
12687 | /*! | - | ||||||||||||||||||||||||||||||||||||
12688 | \fn int QWidget::metric(PaintDeviceMetric m) const | - | ||||||||||||||||||||||||||||||||||||
12689 | - | |||||||||||||||||||||||||||||||||||||
12690 | Internal implementation of the virtual QPaintDevice::metric() | - | ||||||||||||||||||||||||||||||||||||
12691 | function. | - | ||||||||||||||||||||||||||||||||||||
12692 | - | |||||||||||||||||||||||||||||||||||||
12693 | \a m is the metric to get. | - | ||||||||||||||||||||||||||||||||||||
12694 | */ | - | ||||||||||||||||||||||||||||||||||||
12695 | int QWidget::metric(PaintDeviceMetric m) const | - | ||||||||||||||||||||||||||||||||||||
12696 | { | - | ||||||||||||||||||||||||||||||||||||
12697 | Q_D(const QWidget); | - | ||||||||||||||||||||||||||||||||||||
12698 | - | |||||||||||||||||||||||||||||||||||||
12699 | QWindow *topLevelWindow = 0; | - | ||||||||||||||||||||||||||||||||||||
12700 | QScreen *screen = 0; | - | ||||||||||||||||||||||||||||||||||||
12701 | if (QWidget *topLevel = window()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12702 | topLevelWindow = topLevel->windowHandle(); | - | ||||||||||||||||||||||||||||||||||||
12703 | if (topLevelWindow)
| 0 | ||||||||||||||||||||||||||||||||||||
12704 | screen = topLevelWindow->screen(); never executed: screen = topLevelWindow->screen(); | 0 | ||||||||||||||||||||||||||||||||||||
12705 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12706 | if (!screen && QGuiApplication::primaryScreen())
| 0 | ||||||||||||||||||||||||||||||||||||
12707 | screen = QGuiApplication::primaryScreen(); never executed: screen = QGuiApplication::primaryScreen(); | 0 | ||||||||||||||||||||||||||||||||||||
12708 | - | |||||||||||||||||||||||||||||||||||||
12709 | if (!screen) {
| 0 | ||||||||||||||||||||||||||||||||||||
12710 | if (m == PdmDpiX || m == PdmDpiY)
| 0 | ||||||||||||||||||||||||||||||||||||
12711 | return 72; never executed: return 72; | 0 | ||||||||||||||||||||||||||||||||||||
12712 | return QPaintDevice::metric(m); never executed: return QPaintDevice::metric(m); | 0 | ||||||||||||||||||||||||||||||||||||
12713 | } | - | ||||||||||||||||||||||||||||||||||||
12714 | int val; | - | ||||||||||||||||||||||||||||||||||||
12715 | if (m == PdmWidth) {
| 0 | ||||||||||||||||||||||||||||||||||||
12716 | val = data->crect.width(); | - | ||||||||||||||||||||||||||||||||||||
12717 | } else if (m == PdmWidthMM) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
12718 | val = data->crect.width() * screen->physicalSize().width() / screen->geometry().width(); | - | ||||||||||||||||||||||||||||||||||||
12719 | } else if (m == PdmHeight) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
12720 | val = data->crect.height(); | - | ||||||||||||||||||||||||||||||||||||
12721 | } else if (m == PdmHeightMM) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
12722 | val = data->crect.height() * screen->physicalSize().height() / screen->geometry().height(); | - | ||||||||||||||||||||||||||||||||||||
12723 | } else if (m == PdmDepth) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||||||||
12724 | return screen->depth(); never executed: return screen->depth(); | 0 | ||||||||||||||||||||||||||||||||||||
12725 | } else if (m == PdmDpiX) {
| 0 | ||||||||||||||||||||||||||||||||||||
12726 | if (d->extra && d->extra->customDpiX)
| 0 | ||||||||||||||||||||||||||||||||||||
12727 | return d->extra->customDpiX; never executed: return d->extra->customDpiX; | 0 | ||||||||||||||||||||||||||||||||||||
12728 | else if (d->parent)
| 0 | ||||||||||||||||||||||||||||||||||||
12729 | return static_cast<QWidget *>(d->parent)->metric(m); never executed: return static_cast<QWidget *>(d->parent)->metric(m); | 0 | ||||||||||||||||||||||||||||||||||||
12730 | return qRound(screen->logicalDotsPerInchX()); never executed: return qRound(screen->logicalDotsPerInchX()); | 0 | ||||||||||||||||||||||||||||||||||||
12731 | } else if (m == PdmDpiY) {
| 0 | ||||||||||||||||||||||||||||||||||||
12732 | if (d->extra && d->extra->customDpiY)
| 0 | ||||||||||||||||||||||||||||||||||||
12733 | return d->extra->customDpiY; never executed: return d->extra->customDpiY; | 0 | ||||||||||||||||||||||||||||||||||||
12734 | else if (d->parent)
| 0 | ||||||||||||||||||||||||||||||||||||
12735 | return static_cast<QWidget *>(d->parent)->metric(m); never executed: return static_cast<QWidget *>(d->parent)->metric(m); | 0 | ||||||||||||||||||||||||||||||||||||
12736 | return qRound(screen->logicalDotsPerInchY()); never executed: return qRound(screen->logicalDotsPerInchY()); | 0 | ||||||||||||||||||||||||||||||||||||
12737 | } else if (m == PdmPhysicalDpiX) {
| 0 | ||||||||||||||||||||||||||||||||||||
12738 | return qRound(screen->physicalDotsPerInchX()); never executed: return qRound(screen->physicalDotsPerInchX()); | 0 | ||||||||||||||||||||||||||||||||||||
12739 | } else if (m == PdmPhysicalDpiY) {
| 0 | ||||||||||||||||||||||||||||||||||||
12740 | return qRound(screen->physicalDotsPerInchY()); never executed: return qRound(screen->physicalDotsPerInchY()); | 0 | ||||||||||||||||||||||||||||||||||||
12741 | } else if (m == PdmDevicePixelRatio) {
| 0 | ||||||||||||||||||||||||||||||||||||
12742 | return topLevelWindow ? topLevelWindow->devicePixelRatio() : qApp->devicePixelRatio(); never executed: return topLevelWindow ? topLevelWindow->devicePixelRatio() : (static_cast<QApplication *>(QCoreApplication::instance()))->devicePixelRatio();
| 0 | ||||||||||||||||||||||||||||||||||||
12743 | } else if (m == PdmDevicePixelRatioScaled) {
| 0 | ||||||||||||||||||||||||||||||||||||
12744 | return (QPaintDevice::devicePixelRatioFScale() * never executed: return (QPaintDevice::devicePixelRatioFScale() * (topLevelWindow ? topLevelWindow->devicePixelRatio() : (static_cast<QApplication *>(QCoreApplication::instance()))->devicePixelRatio())); | 0 | ||||||||||||||||||||||||||||||||||||
12745 | (topLevelWindow ? topLevelWindow->devicePixelRatio() : qApp->devicePixelRatio())); never executed: return (QPaintDevice::devicePixelRatioFScale() * (topLevelWindow ? topLevelWindow->devicePixelRatio() : (static_cast<QApplication *>(QCoreApplication::instance()))->devicePixelRatio())); | 0 | ||||||||||||||||||||||||||||||||||||
12746 | } else { | - | ||||||||||||||||||||||||||||||||||||
12747 | val = QPaintDevice::metric(m);// XXX | - | ||||||||||||||||||||||||||||||||||||
12748 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12749 | return val; never executed: return val; | 0 | ||||||||||||||||||||||||||||||||||||
12750 | } | - | ||||||||||||||||||||||||||||||||||||
12751 | - | |||||||||||||||||||||||||||||||||||||
12752 | /*! | - | ||||||||||||||||||||||||||||||||||||
12753 | Initializes the \a painter pen, background and font to the same as | - | ||||||||||||||||||||||||||||||||||||
12754 | the given widget's. This function is called automatically when the | - | ||||||||||||||||||||||||||||||||||||
12755 | painter is opened on a QWidget. | - | ||||||||||||||||||||||||||||||||||||
12756 | */ | - | ||||||||||||||||||||||||||||||||||||
12757 | void QWidget::initPainter(QPainter *painter) const | - | ||||||||||||||||||||||||||||||||||||
12758 | { | - | ||||||||||||||||||||||||||||||||||||
12759 | const QPalette &pal = palette(); | - | ||||||||||||||||||||||||||||||||||||
12760 | painter->d_func()->state->pen = QPen(pal.brush(foregroundRole()), 1); | - | ||||||||||||||||||||||||||||||||||||
12761 | painter->d_func()->state->bgBrush = pal.brush(backgroundRole()); | - | ||||||||||||||||||||||||||||||||||||
12762 | QFont f(font(), const_cast<QWidget *>(this)); | - | ||||||||||||||||||||||||||||||||||||
12763 | painter->d_func()->state->deviceFont = f; | - | ||||||||||||||||||||||||||||||||||||
12764 | painter->d_func()->state->font = f; | - | ||||||||||||||||||||||||||||||||||||
12765 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12766 | - | |||||||||||||||||||||||||||||||||||||
12767 | /*! | - | ||||||||||||||||||||||||||||||||||||
12768 | \internal | - | ||||||||||||||||||||||||||||||||||||
12769 | - | |||||||||||||||||||||||||||||||||||||
12770 | Do PaintDevice rendering with the specified \a offset. | - | ||||||||||||||||||||||||||||||||||||
12771 | */ | - | ||||||||||||||||||||||||||||||||||||
12772 | QPaintDevice *QWidget::redirected(QPoint *offset) const | - | ||||||||||||||||||||||||||||||||||||
12773 | { | - | ||||||||||||||||||||||||||||||||||||
12774 | return d_func()->redirected(offset); never executed: return d_func()->redirected(offset); | 0 | ||||||||||||||||||||||||||||||||||||
12775 | } | - | ||||||||||||||||||||||||||||||||||||
12776 | - | |||||||||||||||||||||||||||||||||||||
12777 | /*! | - | ||||||||||||||||||||||||||||||||||||
12778 | \internal | - | ||||||||||||||||||||||||||||||||||||
12779 | - | |||||||||||||||||||||||||||||||||||||
12780 | A painter that is shared among other instances of QPainter. | - | ||||||||||||||||||||||||||||||||||||
12781 | */ | - | ||||||||||||||||||||||||||||||||||||
12782 | QPainter *QWidget::sharedPainter() const | - | ||||||||||||||||||||||||||||||||||||
12783 | { | - | ||||||||||||||||||||||||||||||||||||
12784 | // Someone sent a paint event directly to the widget | - | ||||||||||||||||||||||||||||||||||||
12785 | if (!d_func()->redirectDev)
| 0 | ||||||||||||||||||||||||||||||||||||
12786 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
12787 | - | |||||||||||||||||||||||||||||||||||||
12788 | QPainter *sp = d_func()->sharedPainter(); | - | ||||||||||||||||||||||||||||||||||||
12789 | if (!sp || !sp->isActive())
| 0 | ||||||||||||||||||||||||||||||||||||
12790 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
12791 | - | |||||||||||||||||||||||||||||||||||||
12792 | if (sp->paintEngine()->paintDevice() != d_func()->redirectDev)
| 0 | ||||||||||||||||||||||||||||||||||||
12793 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
12794 | - | |||||||||||||||||||||||||||||||||||||
12795 | return sp; never executed: return sp; | 0 | ||||||||||||||||||||||||||||||||||||
12796 | } | - | ||||||||||||||||||||||||||||||||||||
12797 | - | |||||||||||||||||||||||||||||||||||||
12798 | /*! | - | ||||||||||||||||||||||||||||||||||||
12799 | \fn void QWidget::setMask(const QRegion ®ion) | - | ||||||||||||||||||||||||||||||||||||
12800 | \overload | - | ||||||||||||||||||||||||||||||||||||
12801 | - | |||||||||||||||||||||||||||||||||||||
12802 | Causes only the parts of the widget which overlap \a region to be | - | ||||||||||||||||||||||||||||||||||||
12803 | visible. If the region includes pixels outside the rect() of the | - | ||||||||||||||||||||||||||||||||||||
12804 | widget, window system controls in that area may or may not be | - | ||||||||||||||||||||||||||||||||||||
12805 | visible, depending on the platform. | - | ||||||||||||||||||||||||||||||||||||
12806 | - | |||||||||||||||||||||||||||||||||||||
12807 | Note that this effect can be slow if the region is particularly | - | ||||||||||||||||||||||||||||||||||||
12808 | complex. | - | ||||||||||||||||||||||||||||||||||||
12809 | - | |||||||||||||||||||||||||||||||||||||
12810 | \sa windowOpacity | - | ||||||||||||||||||||||||||||||||||||
12811 | */ | - | ||||||||||||||||||||||||||||||||||||
12812 | void QWidget::setMask(const QRegion &newMask) | - | ||||||||||||||||||||||||||||||||||||
12813 | { | - | ||||||||||||||||||||||||||||||||||||
12814 | Q_D(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12815 | - | |||||||||||||||||||||||||||||||||||||
12816 | d->createExtra(); | - | ||||||||||||||||||||||||||||||||||||
12817 | if (newMask == d->extra->mask)
| 0 | ||||||||||||||||||||||||||||||||||||
12818 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12819 | - | |||||||||||||||||||||||||||||||||||||
12820 | #ifndef QT_NO_BACKINGSTORE | - | ||||||||||||||||||||||||||||||||||||
12821 | const QRegion oldMask(d->extra->mask); | - | ||||||||||||||||||||||||||||||||||||
12822 | #endif | - | ||||||||||||||||||||||||||||||||||||
12823 | - | |||||||||||||||||||||||||||||||||||||
12824 | d->extra->mask = newMask; | - | ||||||||||||||||||||||||||||||||||||
12825 | d->extra->hasMask = !newMask.isEmpty(); | - | ||||||||||||||||||||||||||||||||||||
12826 | - | |||||||||||||||||||||||||||||||||||||
12827 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||||||||||||||
12828 | if (!testAttribute(Qt::WA_WState_Created))
| 0 | ||||||||||||||||||||||||||||||||||||
12829 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12830 | #endif | - | ||||||||||||||||||||||||||||||||||||
12831 | - | |||||||||||||||||||||||||||||||||||||
12832 | d->setMask_sys(newMask); | - | ||||||||||||||||||||||||||||||||||||
12833 | - | |||||||||||||||||||||||||||||||||||||
12834 | #ifndef QT_NO_BACKINGSTORE | - | ||||||||||||||||||||||||||||||||||||
12835 | if (!isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
12836 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12837 | - | |||||||||||||||||||||||||||||||||||||
12838 | if (!d->extra->hasMask) {
| 0 | ||||||||||||||||||||||||||||||||||||
12839 | // Mask was cleared; update newly exposed area. | - | ||||||||||||||||||||||||||||||||||||
12840 | QRegion expose(rect()); | - | ||||||||||||||||||||||||||||||||||||
12841 | expose -= oldMask; | - | ||||||||||||||||||||||||||||||||||||
12842 | if (!expose.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12843 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
12844 | update(expose); | - | ||||||||||||||||||||||||||||||||||||
12845 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12846 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12847 | } | - | ||||||||||||||||||||||||||||||||||||
12848 | - | |||||||||||||||||||||||||||||||||||||
12849 | if (!isWindow()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12850 | // Update newly exposed area on the parent widget. | - | ||||||||||||||||||||||||||||||||||||
12851 | QRegion parentExpose(rect()); | - | ||||||||||||||||||||||||||||||||||||
12852 | parentExpose -= newMask; | - | ||||||||||||||||||||||||||||||||||||
12853 | if (!parentExpose.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||||||||
12854 | d->setDirtyOpaqueRegion(); | - | ||||||||||||||||||||||||||||||||||||
12855 | parentExpose.translate(data->crect.topLeft()); | - | ||||||||||||||||||||||||||||||||||||
12856 | parentWidget()->update(parentExpose); | - | ||||||||||||||||||||||||||||||||||||
12857 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12858 | - | |||||||||||||||||||||||||||||||||||||
12859 | // Update newly exposed area on this widget | - | ||||||||||||||||||||||||||||||||||||
12860 | if (!oldMask.isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
12861 | update(newMask - oldMask); never executed: update(newMask - oldMask); | 0 | ||||||||||||||||||||||||||||||||||||
12862 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12863 | #endif | - | ||||||||||||||||||||||||||||||||||||
12864 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12865 | - | |||||||||||||||||||||||||||||||||||||
12866 | void QWidgetPrivate::setMask_sys(const QRegion ®ion) | - | ||||||||||||||||||||||||||||||||||||
12867 | { | - | ||||||||||||||||||||||||||||||||||||
12868 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12869 | if (QWindow *window = q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
12870 | window->setMask(region); never executed: window->setMask(region); | 0 | ||||||||||||||||||||||||||||||||||||
12871 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12872 | - | |||||||||||||||||||||||||||||||||||||
12873 | /*! | - | ||||||||||||||||||||||||||||||||||||
12874 | \fn void QWidget::setMask(const QBitmap &bitmap) | - | ||||||||||||||||||||||||||||||||||||
12875 | - | |||||||||||||||||||||||||||||||||||||
12876 | Causes only the pixels of the widget for which \a bitmap has a | - | ||||||||||||||||||||||||||||||||||||
12877 | corresponding 1 bit to be visible. If the region includes pixels | - | ||||||||||||||||||||||||||||||||||||
12878 | outside the rect() of the widget, window system controls in that | - | ||||||||||||||||||||||||||||||||||||
12879 | area may or may not be visible, depending on the platform. | - | ||||||||||||||||||||||||||||||||||||
12880 | - | |||||||||||||||||||||||||||||||||||||
12881 | Note that this effect can be slow if the region is particularly | - | ||||||||||||||||||||||||||||||||||||
12882 | complex. | - | ||||||||||||||||||||||||||||||||||||
12883 | - | |||||||||||||||||||||||||||||||||||||
12884 | The following code shows how an image with an alpha channel can be | - | ||||||||||||||||||||||||||||||||||||
12885 | used to generate a mask for a widget: | - | ||||||||||||||||||||||||||||||||||||
12886 | - | |||||||||||||||||||||||||||||||||||||
12887 | \snippet widget-mask/main.cpp 0 | - | ||||||||||||||||||||||||||||||||||||
12888 | - | |||||||||||||||||||||||||||||||||||||
12889 | The label shown by this code is masked using the image it contains, | - | ||||||||||||||||||||||||||||||||||||
12890 | giving the appearance that an irregularly-shaped image is being drawn | - | ||||||||||||||||||||||||||||||||||||
12891 | directly onto the screen. | - | ||||||||||||||||||||||||||||||||||||
12892 | - | |||||||||||||||||||||||||||||||||||||
12893 | Masked widgets receive mouse events only on their visible | - | ||||||||||||||||||||||||||||||||||||
12894 | portions. | - | ||||||||||||||||||||||||||||||||||||
12895 | - | |||||||||||||||||||||||||||||||||||||
12896 | \sa clearMask(), windowOpacity(), {Shaped Clock Example} | - | ||||||||||||||||||||||||||||||||||||
12897 | */ | - | ||||||||||||||||||||||||||||||||||||
12898 | void QWidget::setMask(const QBitmap &bitmap) | - | ||||||||||||||||||||||||||||||||||||
12899 | { | - | ||||||||||||||||||||||||||||||||||||
12900 | setMask(QRegion(bitmap)); | - | ||||||||||||||||||||||||||||||||||||
12901 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12902 | - | |||||||||||||||||||||||||||||||||||||
12903 | /*! | - | ||||||||||||||||||||||||||||||||||||
12904 | \fn void QWidget::clearMask() | - | ||||||||||||||||||||||||||||||||||||
12905 | - | |||||||||||||||||||||||||||||||||||||
12906 | Removes any mask set by setMask(). | - | ||||||||||||||||||||||||||||||||||||
12907 | - | |||||||||||||||||||||||||||||||||||||
12908 | \sa setMask() | - | ||||||||||||||||||||||||||||||||||||
12909 | */ | - | ||||||||||||||||||||||||||||||||||||
12910 | void QWidget::clearMask() | - | ||||||||||||||||||||||||||||||||||||
12911 | { | - | ||||||||||||||||||||||||||||||||||||
12912 | setMask(QRegion()); | - | ||||||||||||||||||||||||||||||||||||
12913 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12914 | - | |||||||||||||||||||||||||||||||||||||
12915 | void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *newParent) | - | ||||||||||||||||||||||||||||||||||||
12916 | { | - | ||||||||||||||||||||||||||||||||||||
12917 | Q_ASSERT(widgetAsObject->isWidgetType()); | - | ||||||||||||||||||||||||||||||||||||
12918 | Q_ASSERT(!newParent || newParent->isWidgetType()); | - | ||||||||||||||||||||||||||||||||||||
12919 | QWidget *widget = static_cast<QWidget*>(widgetAsObject); | - | ||||||||||||||||||||||||||||||||||||
12920 | widget->setParent(static_cast<QWidget*>(newParent)); | - | ||||||||||||||||||||||||||||||||||||
12921 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12922 | - | |||||||||||||||||||||||||||||||||||||
12923 | void QWidgetPrivate::setNetWmWindowTypes(bool skipIfMissing) | - | ||||||||||||||||||||||||||||||||||||
12924 | { | - | ||||||||||||||||||||||||||||||||||||
12925 | Q_Q(QWidget); | - | ||||||||||||||||||||||||||||||||||||
12926 | - | |||||||||||||||||||||||||||||||||||||
12927 | if (!q->windowHandle())
| 0 | ||||||||||||||||||||||||||||||||||||
12928 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12929 | - | |||||||||||||||||||||||||||||||||||||
12930 | int wmWindowType = 0; | - | ||||||||||||||||||||||||||||||||||||
12931 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDesktop))
| 0 | ||||||||||||||||||||||||||||||||||||
12932 | wmWindowType |= QXcbWindowFunctions::Desktop; never executed: wmWindowType |= QXcbWindowFunctions::Desktop; | 0 | ||||||||||||||||||||||||||||||||||||
12933 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDock))
| 0 | ||||||||||||||||||||||||||||||||||||
12934 | wmWindowType |= QXcbWindowFunctions::Dock; never executed: wmWindowType |= QXcbWindowFunctions::Dock; | 0 | ||||||||||||||||||||||||||||||||||||
12935 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolBar))
| 0 | ||||||||||||||||||||||||||||||||||||
12936 | wmWindowType |= QXcbWindowFunctions::Toolbar; never executed: wmWindowType |= QXcbWindowFunctions::Toolbar; | 0 | ||||||||||||||||||||||||||||||||||||
12937 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeMenu))
| 0 | ||||||||||||||||||||||||||||||||||||
12938 | wmWindowType |= QXcbWindowFunctions::Menu; never executed: wmWindowType |= QXcbWindowFunctions::Menu; | 0 | ||||||||||||||||||||||||||||||||||||
12939 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeUtility))
| 0 | ||||||||||||||||||||||||||||||||||||
12940 | wmWindowType |= QXcbWindowFunctions::Utility; never executed: wmWindowType |= QXcbWindowFunctions::Utility; | 0 | ||||||||||||||||||||||||||||||||||||
12941 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeSplash))
| 0 | ||||||||||||||||||||||||||||||||||||
12942 | wmWindowType |= QXcbWindowFunctions::Splash; never executed: wmWindowType |= QXcbWindowFunctions::Splash; | 0 | ||||||||||||||||||||||||||||||||||||
12943 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDialog))
| 0 | ||||||||||||||||||||||||||||||||||||
12944 | wmWindowType |= QXcbWindowFunctions::Dialog; never executed: wmWindowType |= QXcbWindowFunctions::Dialog; | 0 | ||||||||||||||||||||||||||||||||||||
12945 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu))
| 0 | ||||||||||||||||||||||||||||||||||||
12946 | wmWindowType |= QXcbWindowFunctions::DropDownMenu; never executed: wmWindowType |= QXcbWindowFunctions::DropDownMenu; | 0 | ||||||||||||||||||||||||||||||||||||
12947 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypePopupMenu))
| 0 | ||||||||||||||||||||||||||||||||||||
12948 | wmWindowType |= QXcbWindowFunctions::PopupMenu; never executed: wmWindowType |= QXcbWindowFunctions::PopupMenu; | 0 | ||||||||||||||||||||||||||||||||||||
12949 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolTip))
| 0 | ||||||||||||||||||||||||||||||||||||
12950 | wmWindowType |= QXcbWindowFunctions::Tooltip; never executed: wmWindowType |= QXcbWindowFunctions::Tooltip; | 0 | ||||||||||||||||||||||||||||||||||||
12951 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeNotification))
| 0 | ||||||||||||||||||||||||||||||||||||
12952 | wmWindowType |= QXcbWindowFunctions::Notification; never executed: wmWindowType |= QXcbWindowFunctions::Notification; | 0 | ||||||||||||||||||||||||||||||||||||
12953 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeCombo))
| 0 | ||||||||||||||||||||||||||||||||||||
12954 | wmWindowType |= QXcbWindowFunctions::Combo; never executed: wmWindowType |= QXcbWindowFunctions::Combo; | 0 | ||||||||||||||||||||||||||||||||||||
12955 | if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDND))
| 0 | ||||||||||||||||||||||||||||||||||||
12956 | wmWindowType |= QXcbWindowFunctions::Dnd; never executed: wmWindowType |= QXcbWindowFunctions::Dnd; | 0 | ||||||||||||||||||||||||||||||||||||
12957 | - | |||||||||||||||||||||||||||||||||||||
12958 | if (wmWindowType == 0 && skipIfMissing)
| 0 | ||||||||||||||||||||||||||||||||||||
12959 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
12960 | - | |||||||||||||||||||||||||||||||||||||
12961 | QXcbWindowFunctions::setWmWindowType(q->windowHandle(), static_cast<QXcbWindowFunctions::WmWindowType>(wmWindowType)); | - | ||||||||||||||||||||||||||||||||||||
12962 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12963 | - | |||||||||||||||||||||||||||||||||||||
12964 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||||||||||||||
12965 | - | |||||||||||||||||||||||||||||||||||||
12966 | static inline void formatWidgetAttributes(QDebug debug, const QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
12967 | { | - | ||||||||||||||||||||||||||||||||||||
12968 | const QMetaObject *qtMo = qt_getEnumMetaObject(Qt::WA_AttributeCount); | - | ||||||||||||||||||||||||||||||||||||
12969 | const QMetaEnum me = qtMo->enumerator(qtMo->indexOfEnumerator("WidgetAttribute")); | - | ||||||||||||||||||||||||||||||||||||
12970 | debug << ", attributes=["; | - | ||||||||||||||||||||||||||||||||||||
12971 | int count = 0; | - | ||||||||||||||||||||||||||||||||||||
12972 | for (int a = 0; a < Qt::WA_AttributeCount; ++a) {
| 0 | ||||||||||||||||||||||||||||||||||||
12973 | if (widget->testAttribute(static_cast<Qt::WidgetAttribute>(a))) {
| 0 | ||||||||||||||||||||||||||||||||||||
12974 | if (count++)
| 0 | ||||||||||||||||||||||||||||||||||||
12975 | debug << ','; never executed: debug << ','; | 0 | ||||||||||||||||||||||||||||||||||||
12976 | debug << me.valueToKey(a); | - | ||||||||||||||||||||||||||||||||||||
12977 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12978 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12979 | debug << ']'; | - | ||||||||||||||||||||||||||||||||||||
12980 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
12981 | - | |||||||||||||||||||||||||||||||||||||
12982 | QDebug operator<<(QDebug debug, const QWidget *widget) | - | ||||||||||||||||||||||||||||||||||||
12983 | { | - | ||||||||||||||||||||||||||||||||||||
12984 | const QDebugStateSaver saver(debug); | - | ||||||||||||||||||||||||||||||||||||
12985 | debug.nospace(); | - | ||||||||||||||||||||||||||||||||||||
12986 | if (widget) {
| 0 | ||||||||||||||||||||||||||||||||||||
12987 | debug << widget->metaObject()->className() << '(' << (const void *)widget; | - | ||||||||||||||||||||||||||||||||||||
12988 | if (!widget->objectName().isEmpty())
| 0 | ||||||||||||||||||||||||||||||||||||
12989 | debug << ", name=" << widget->objectName(); never executed: debug << ", name=" << widget->objectName(); | 0 | ||||||||||||||||||||||||||||||||||||
12990 | if (debug.verbosity() > 2) {
| 0 | ||||||||||||||||||||||||||||||||||||
12991 | const QRect geometry = widget->geometry(); | - | ||||||||||||||||||||||||||||||||||||
12992 | const QRect frameGeometry = widget->frameGeometry(); | - | ||||||||||||||||||||||||||||||||||||
12993 | if (widget->isVisible())
| 0 | ||||||||||||||||||||||||||||||||||||
12994 | debug << ", visible"; never executed: debug << ", visible"; | 0 | ||||||||||||||||||||||||||||||||||||
12995 | if (!widget->isEnabled())
| 0 | ||||||||||||||||||||||||||||||||||||
12996 | debug << ", disabled"; never executed: debug << ", disabled"; | 0 | ||||||||||||||||||||||||||||||||||||
12997 | debug << ", states=" << widget->windowState() | - | ||||||||||||||||||||||||||||||||||||
12998 | << ", type=" << widget->windowType() << ", flags=" << widget->windowFlags(); | - | ||||||||||||||||||||||||||||||||||||
12999 | formatWidgetAttributes(debug, widget); | - | ||||||||||||||||||||||||||||||||||||
13000 | if (widget->isWindow())
| 0 | ||||||||||||||||||||||||||||||||||||
13001 | debug << ", window"; never executed: debug << ", window"; | 0 | ||||||||||||||||||||||||||||||||||||
13002 | debug << ", " << geometry.width() << 'x' << geometry.height() | - | ||||||||||||||||||||||||||||||||||||
13003 | << forcesign << geometry.x() << geometry.y() << noforcesign; | - | ||||||||||||||||||||||||||||||||||||
13004 | if (frameGeometry != geometry) {
| 0 | ||||||||||||||||||||||||||||||||||||
13005 | const QMargins margins(geometry.x() - frameGeometry.x(), | - | ||||||||||||||||||||||||||||||||||||
13006 | geometry.y() - frameGeometry.y(), | - | ||||||||||||||||||||||||||||||||||||
13007 | frameGeometry.right() - geometry.right(), | - | ||||||||||||||||||||||||||||||||||||
13008 | frameGeometry.bottom() - geometry.bottom()); | - | ||||||||||||||||||||||||||||||||||||
13009 | debug << ", margins=" << margins; | - | ||||||||||||||||||||||||||||||||||||
13010 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
13011 | debug << ", devicePixelRatio=" << widget->devicePixelRatioF(); | - | ||||||||||||||||||||||||||||||||||||
13012 | if (const WId wid = widget->internalWinId())
| 0 | ||||||||||||||||||||||||||||||||||||
13013 | debug << ", winId=0x" << hex << wid << dec; never executed: debug << ", winId=0x" << hex << wid << dec; | 0 | ||||||||||||||||||||||||||||||||||||
13014 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
13015 | debug << ')'; | - | ||||||||||||||||||||||||||||||||||||
13016 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
13017 | debug << "QWidget(0x0)"; | - | ||||||||||||||||||||||||||||||||||||
13018 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
13019 | return debug; never executed: return debug; | 0 | ||||||||||||||||||||||||||||||||||||
13020 | } | - | ||||||||||||||||||||||||||||||||||||
13021 | #endif // !QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||||||||||||||
13022 | - | |||||||||||||||||||||||||||||||||||||
13023 | /*! \fn Qt::HANDLE QWidget::macCGHandle() const | - | ||||||||||||||||||||||||||||||||||||
13024 | \internal | - | ||||||||||||||||||||||||||||||||||||
13025 | - | |||||||||||||||||||||||||||||||||||||
13026 | Returns the CoreGraphics handle of the widget. Use of this function is not portable. | - | ||||||||||||||||||||||||||||||||||||
13027 | This function will return 0 if no painter context can be established, or if the handle | - | ||||||||||||||||||||||||||||||||||||
13028 | could not be created. | - | ||||||||||||||||||||||||||||||||||||
13029 | - | |||||||||||||||||||||||||||||||||||||
13030 | \warning This function is only available on \macos. | - | ||||||||||||||||||||||||||||||||||||
13031 | */ | - | ||||||||||||||||||||||||||||||||||||
13032 | /*! \fn Qt::HANDLE QWidget::macQDHandle() const | - | ||||||||||||||||||||||||||||||||||||
13033 | \internal | - | ||||||||||||||||||||||||||||||||||||
13034 | - | |||||||||||||||||||||||||||||||||||||
13035 | Returns the QuickDraw handle of the widget. Use of this function is not portable. | - | ||||||||||||||||||||||||||||||||||||
13036 | This function will return 0 if QuickDraw is not supported, or if the handle could | - | ||||||||||||||||||||||||||||||||||||
13037 | not be created. | - | ||||||||||||||||||||||||||||||||||||
13038 | - | |||||||||||||||||||||||||||||||||||||
13039 | \warning This function is only available on \macos. | - | ||||||||||||||||||||||||||||||||||||
13040 | */ | - | ||||||||||||||||||||||||||||||||||||
13041 | /*! \fn const QX11Info &QWidget::x11Info() const | - | ||||||||||||||||||||||||||||||||||||
13042 | \internal | - | ||||||||||||||||||||||||||||||||||||
13043 | - | |||||||||||||||||||||||||||||||||||||
13044 | Returns information about the configuration of the X display used to display | - | ||||||||||||||||||||||||||||||||||||
13045 | the widget. | - | ||||||||||||||||||||||||||||||||||||
13046 | - | |||||||||||||||||||||||||||||||||||||
13047 | \warning This function is only available on X11. | - | ||||||||||||||||||||||||||||||||||||
13048 | */ | - | ||||||||||||||||||||||||||||||||||||
13049 | - | |||||||||||||||||||||||||||||||||||||
13050 | /*! \fn Qt::HANDLE QWidget::x11PictureHandle() const | - | ||||||||||||||||||||||||||||||||||||
13051 | \internal | - | ||||||||||||||||||||||||||||||||||||
13052 | - | |||||||||||||||||||||||||||||||||||||
13053 | Returns the X11 picture handle of the widget for XRender | - | ||||||||||||||||||||||||||||||||||||
13054 | support. Use of this function is not portable. This function will | - | ||||||||||||||||||||||||||||||||||||
13055 | return 0 if XRender support is not compiled into Qt, if the | - | ||||||||||||||||||||||||||||||||||||
13056 | XRender extension is not supported on the X11 display, or if the | - | ||||||||||||||||||||||||||||||||||||
13057 | handle could not be created. | - | ||||||||||||||||||||||||||||||||||||
13058 | - | |||||||||||||||||||||||||||||||||||||
13059 | \warning This function is only available on X11. | - | ||||||||||||||||||||||||||||||||||||
13060 | - | |||||||||||||||||||||||||||||||||||||
13061 | */ | - | ||||||||||||||||||||||||||||||||||||
13062 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||||||||||||||
13063 | - | |||||||||||||||||||||||||||||||||||||
13064 | #include "moc_qwidget.cpp" | - | ||||||||||||||||||||||||||||||||||||
13065 | - | |||||||||||||||||||||||||||||||||||||
Source code | Switch to Preprocessed file |