160 #endif |
160 #endif |
161 |
161 |
162 extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp |
162 extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp |
163 extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp |
163 extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp |
164 |
164 |
165 QRefCountedWidgetBackingStore::QRefCountedWidgetBackingStore() |
165 /*! |
|
166 \internal |
|
167 \class QWidgetBackingStoreTracker |
|
168 \brief Class which allows tracking of which widgets are using a given backing store |
|
169 |
|
170 QWidgetBackingStoreTracker is a thin wrapper around a QWidgetBackingStore pointer, |
|
171 which maintains a list of the QWidgets which are currently using the backing |
|
172 store. This list is modified via the registerWidget and unregisterWidget functions. |
|
173 */ |
|
174 |
|
175 QWidgetBackingStoreTracker::QWidgetBackingStoreTracker() |
166 : m_ptr(0) |
176 : m_ptr(0) |
167 { |
177 { |
168 |
178 |
169 } |
179 } |
170 |
180 |
171 QRefCountedWidgetBackingStore::~QRefCountedWidgetBackingStore() |
181 QWidgetBackingStoreTracker::~QWidgetBackingStoreTracker() |
172 { |
182 { |
173 delete m_ptr; |
183 delete m_ptr; |
174 } |
184 } |
175 |
185 |
176 void QRefCountedWidgetBackingStore::create(QWidget *widget) |
186 /*! |
|
187 \internal |
|
188 Destroy the contained QWidgetBackingStore, if not null, and clear the list of |
|
189 widgets using the backing store, then create a new QWidgetBackingStore, providing |
|
190 the QWidget. |
|
191 */ |
|
192 void QWidgetBackingStoreTracker::create(QWidget *widget) |
177 { |
193 { |
178 destroy(); |
194 destroy(); |
179 m_ptr = new QWidgetBackingStore(widget); |
195 m_ptr = new QWidgetBackingStore(widget); |
180 } |
196 } |
181 |
197 |
182 void QRefCountedWidgetBackingStore::destroy() |
198 /*! |
|
199 \internal |
|
200 Destroy the contained QWidgetBackingStore, if not null, and clear the list of |
|
201 widgets using the backing store. |
|
202 */ |
|
203 void QWidgetBackingStoreTracker::destroy() |
183 { |
204 { |
184 delete m_ptr; |
205 delete m_ptr; |
185 m_ptr = 0; |
206 m_ptr = 0; |
186 m_visibleWidgets.clear(); |
207 m_widgets.clear(); |
187 } |
208 } |
188 |
209 |
189 void QRefCountedWidgetBackingStore::widgetShown(QWidget *w) |
210 /*! |
|
211 \internal |
|
212 Add the widget to the list of widgets currently using the backing store. |
|
213 If the widget was already in the list, this function is a no-op. |
|
214 */ |
|
215 void QWidgetBackingStoreTracker::registerWidget(QWidget *w) |
190 { |
216 { |
191 Q_ASSERT(m_ptr); |
217 Q_ASSERT(m_ptr); |
192 Q_ASSERT(w->internalWinId()); |
218 Q_ASSERT(w->internalWinId()); |
193 Q_ASSERT(qt_widget_private(w)->maybeBackingStore() == m_ptr); |
219 Q_ASSERT(qt_widget_private(w)->maybeBackingStore() == m_ptr); |
194 m_visibleWidgets.insert(w); |
220 m_widgets.insert(w); |
195 } |
221 } |
196 |
222 |
197 void QRefCountedWidgetBackingStore::widgetHidden(QWidget *w) |
223 /*! |
198 { |
224 \internal |
199 if (m_visibleWidgets.remove(w) && m_visibleWidgets.isEmpty()) { |
225 Remove the widget from the list of widgets currently using the backing store. |
|
226 If the widget was in the list, and removing it causes the list to be empty, |
|
227 the backing store is deleted. |
|
228 If the widget was not in the list, this function is a no-op. |
|
229 */ |
|
230 void QWidgetBackingStoreTracker::unregisterWidget(QWidget *w) |
|
231 { |
|
232 if (m_widgets.remove(w) && m_widgets.isEmpty()) { |
200 delete m_ptr; |
233 delete m_ptr; |
201 m_ptr = 0; |
234 m_ptr = 0; |
202 } |
235 } |
203 } |
236 } |
204 |
237 |
1239 adjustQuitOnCloseAttribute(); |
1272 adjustQuitOnCloseAttribute(); |
1240 |
1273 |
1241 q->setAttribute(Qt::WA_WState_Hidden); |
1274 q->setAttribute(Qt::WA_WState_Hidden); |
1242 |
1275 |
1243 //give potential windows a bigger "pre-initial" size; create_sys() will give them a new size later |
1276 //give potential windows a bigger "pre-initial" size; create_sys() will give them a new size later |
|
1277 #ifdef Q_OS_SYMBIAN |
|
1278 if (isGLWidget) { |
|
1279 // Don't waste GPU mem for unnecessary large egl surface |
|
1280 data.crect = QRect(0,0,2,2); |
|
1281 } else { |
|
1282 data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,360,640); |
|
1283 } |
|
1284 #else |
1244 data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480); |
1285 data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480); |
|
1286 #endif |
1245 |
1287 |
1246 focus_next = focus_prev = q; |
1288 focus_next = focus_prev = q; |
1247 |
1289 |
1248 if ((f & Qt::WindowType_Mask) == Qt::Desktop) |
1290 if ((f & Qt::WindowType_Mask) == Qt::Desktop) |
1249 q->create(); |
1291 q->create(); |
4820 to a child for which setLayoutDirection() has been explicitly |
4862 to a child for which setLayoutDirection() has been explicitly |
4821 called. Also, child widgets added \e after setLayoutDirection() |
4863 called. Also, child widgets added \e after setLayoutDirection() |
4822 has been called for the parent do not inherit the parent's layout |
4864 has been called for the parent do not inherit the parent's layout |
4823 direction. |
4865 direction. |
4824 |
4866 |
|
4867 This method no longer affects text layout direction since Qt 4.7. |
|
4868 |
4825 \sa QApplication::layoutDirection |
4869 \sa QApplication::layoutDirection |
4826 */ |
4870 */ |
4827 void QWidget::setLayoutDirection(Qt::LayoutDirection direction) |
4871 void QWidget::setLayoutDirection(Qt::LayoutDirection direction) |
4828 { |
4872 { |
4829 Q_D(QWidget); |
4873 Q_D(QWidget); |
9922 QWidget *desktopWidget = 0; |
9966 QWidget *desktopWidget = 0; |
9923 if (parent && parent->windowType() == Qt::Desktop) |
9967 if (parent && parent->windowType() == Qt::Desktop) |
9924 desktopWidget = parent; |
9968 desktopWidget = parent; |
9925 bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget; |
9969 bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget; |
9926 |
9970 |
9927 #if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) |
9971 #if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) |
9928 if (newParent && parent && !desktopWidget) { |
9972 if (newParent && parent && !desktopWidget) { |
9929 if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) |
9973 if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) |
9930 parent->d_func()->enforceNativeChildren(); |
9974 parent->d_func()->enforceNativeChildren(); |
9931 else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen)) |
9975 else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen)) |
9932 setAttribute(Qt::WA_NativeWindow); |
9976 setAttribute(Qt::WA_NativeWindow); |
10576 #endif //QT_NO_IM |
10620 #endif //QT_NO_IM |
10577 break; |
10621 break; |
10578 } |
10622 } |
10579 case Qt::WA_PaintOnScreen: |
10623 case Qt::WA_PaintOnScreen: |
10580 d->updateIsOpaque(); |
10624 d->updateIsOpaque(); |
10581 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) |
10625 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) |
10582 // Recreate the widget if it's already created as an alien widget and |
10626 // Recreate the widget if it's already created as an alien widget and |
10583 // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id. |
10627 // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id. |
10584 // So must their children. |
10628 // So must their children. |
10585 if (on) { |
10629 if (on) { |
10586 setAttribute(Qt::WA_NativeWindow); |
10630 setAttribute(Qt::WA_NativeWindow); |
12043 */ |
12087 */ |
12044 void QWidget::ungrabGesture(Qt::GestureType gesture) |
12088 void QWidget::ungrabGesture(Qt::GestureType gesture) |
12045 { |
12089 { |
12046 Q_D(QWidget); |
12090 Q_D(QWidget); |
12047 if (d->gestureContext.remove(gesture)) { |
12091 if (d->gestureContext.remove(gesture)) { |
12048 QGestureManager *manager = QGestureManager::instance(); |
12092 if (QGestureManager *manager = QGestureManager::instance()) |
12049 manager->cleanupCachedGestures(this, gesture); |
12093 manager->cleanupCachedGestures(this, gesture); |
12050 } |
12094 } |
12051 } |
12095 } |
12052 #endif // QT_NO_GESTURES |
12096 #endif // QT_NO_GESTURES |
12053 |
12097 |
12054 /*! |
12098 /*! |