Changeset 846 for trunk/src/gui/kernel/qwidget.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/kernel/qwidget.cpp
r786 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 68 68 # include "qt_cocoa_helpers_mac_p.h" 69 69 # include "qmainwindow.h" 70 # include "qtoolbar.h" 71 # include <private/qmainwindowlayout_p.h> 70 72 #endif 71 73 #if defined(Q_WS_QWS) … … 127 129 #endif // QT_KEYPAD_NAVIGATION 128 130 131 #ifdef Q_WS_S60 132 #include <aknappui.h> 133 #endif 134 129 135 // widget/widget data creation count 130 136 //#define QWIDGET_EXTRA_DEBUG … … 165 171 extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp 166 172 extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp 173 174 /*! 175 \internal 176 \class QWidgetBackingStoreTracker 177 \brief Class which allows tracking of which widgets are using a given backing store 178 179 QWidgetBackingStoreTracker is a thin wrapper around a QWidgetBackingStore pointer, 180 which maintains a list of the QWidgets which are currently using the backing 181 store. This list is modified via the registerWidget and unregisterWidget functions. 182 */ 183 184 QWidgetBackingStoreTracker::QWidgetBackingStoreTracker() 185 : m_ptr(0) 186 { 187 188 } 189 190 QWidgetBackingStoreTracker::~QWidgetBackingStoreTracker() 191 { 192 delete m_ptr; 193 } 194 195 /*! 196 \internal 197 Destroy the contained QWidgetBackingStore, if not null, and clear the list of 198 widgets using the backing store, then create a new QWidgetBackingStore, providing 199 the QWidget. 200 */ 201 void QWidgetBackingStoreTracker::create(QWidget *widget) 202 { 203 destroy(); 204 m_ptr = new QWidgetBackingStore(widget); 205 } 206 207 /*! 208 \internal 209 Destroy the contained QWidgetBackingStore, if not null, and clear the list of 210 widgets using the backing store. 211 */ 212 void QWidgetBackingStoreTracker::destroy() 213 { 214 delete m_ptr; 215 m_ptr = 0; 216 m_widgets.clear(); 217 } 218 219 /*! 220 \internal 221 Add the widget to the list of widgets currently using the backing store. 222 If the widget was already in the list, this function is a no-op. 223 */ 224 void QWidgetBackingStoreTracker::registerWidget(QWidget *w) 225 { 226 Q_ASSERT(m_ptr); 227 Q_ASSERT(w->internalWinId()); 228 Q_ASSERT(qt_widget_private(w)->maybeBackingStore() == m_ptr); 229 m_widgets.insert(w); 230 } 231 232 /*! 233 \internal 234 Remove the widget from the list of widgets currently using the backing store. 235 If the widget was in the list, and removing it causes the list to be empty, 236 the backing store is deleted. 237 If the widget was not in the list, this function is a no-op. 238 */ 239 void QWidgetBackingStoreTracker::unregisterWidget(QWidget *w) 240 { 241 if (m_widgets.remove(w) && m_widgets.isEmpty()) { 242 delete m_ptr; 243 m_ptr = 0; 244 } 245 } 246 247 /*! 248 \internal 249 Recursively remove widget and all of its descendents. 250 */ 251 void QWidgetBackingStoreTracker::unregisterWidgetSubtree(QWidget *widget) 252 { 253 unregisterWidget(widget); 254 foreach (QObject *child, widget->children()) 255 if (QWidget *childWidget = qobject_cast<QWidget *>(child)) 256 unregisterWidgetSubtree(childWidget); 257 } 167 258 168 259 QWidgetPrivate::QWidgetPrivate(int version) … … 203 294 , isGLWidget(0) 204 295 , usesDoubleBufferedGLContext(0) 296 #ifndef QT_NO_IM 297 , inheritsInputMethodHints(0) 298 #endif 205 299 #if defined(Q_WS_X11) 206 300 , picture(0) … … 209 303 #elif defined(Q_WS_WIN) 210 304 , noPaintOnScreen(0) 305 #ifndef QT_NO_GESTURES 211 306 , nativeGesturePanEnabled(0) 307 #endif 212 308 #elif defined(Q_WS_MAC) 213 309 , needWindowChange(0) 310 , hasAlienChildren(0) 214 311 , window_event(0) 215 312 , qd_hd(0) … … 226 323 isWidget = true; 227 324 memset(high_attributes, 0, sizeof(high_attributes)); 325 #if QT_MAC_USE_COCOA 326 drawRectOriginalAdded = false; 327 originalDrawMethod = true; 328 changeMethods = false; 329 #endif // QT_MAC_USE_COCOA 228 330 #ifdef QWIDGET_EXTRA_DEBUG 229 331 static int count = 0; … … 246 348 } 247 349 350 class QDummyWindowSurface : public QWindowSurface 351 { 352 public: 353 QDummyWindowSurface(QWidget *window) : QWindowSurface(window) {} 354 QPaintDevice *paintDevice() { return window(); } 355 void flush(QWidget *, const QRegion &, const QPoint &) {} 356 }; 357 248 358 QWindowSurface *QWidgetPrivate::createDefaultWindowSurface() 249 359 { 250 360 Q_Q(QWidget); 251 if (QApplicationPrivate::graphicsSystem()) 252 return QApplicationPrivate::graphicsSystem()->createWindowSurface(q); 253 return createDefaultWindowSurface_sys(); 361 362 QWindowSurface *surface; 363 if (q->property("_q_DummyWindowSurface").toBool()) { 364 surface = new QDummyWindowSurface(q); 365 } else { 366 if (QApplicationPrivate::graphicsSystem()) 367 surface = QApplicationPrivate::graphicsSystem()->createWindowSurface(q); 368 else 369 surface = createDefaultWindowSurface_sys(); 370 } 371 372 return surface; 254 373 } 255 374 … … 286 405 if (ic) 287 406 return ic; 288 #endif289 407 return qApp->inputContext(); 408 #else 409 return 0; 410 #endif 290 411 } 291 412 … … 312 433 This function sets the input context \a context 313 434 on this widget. 435 436 Qt takes ownership of the given input \a context. 314 437 315 438 \sa inputContext() … … 321 444 if (!testAttribute(Qt::WA_InputMethodEnabled)) 322 445 return; 446 if (context == d->ic) 447 return; 323 448 if (d->ic) 324 449 delete d->ic; 325 450 d->ic = context; 451 if (d->ic) 452 d->ic->setParent(this); 326 453 #endif 327 454 } … … 639 766 \i mouseMoveEvent() is called whenever the mouse moves while a mouse 640 767 button is held down. This can be useful during drag and drop 641 operations. If you call setMouseTracking(true), you get mouse move642 events even when no buttons are held down. (See also the \l{Drag643 and Drop} guide.)768 operations. If you call \l{setMouseTracking()}{setMouseTracking}(true), 769 you get mouse move events even when no buttons are held down. 770 (See also the \l{Drag and Drop} guide.) 644 771 \i keyReleaseEvent() is called whenever a key is released and while it 645 772 is held down (if the key is auto-repeating). In that case, the … … 671 798 one of the more specialized handlers above. 672 799 673 Events and the mechanism used to deliver them are covered in the674 \l{ Events and Event Filters} document.800 Events and the mechanism used to deliver them are covered in 801 \l{The Event System}. 675 802 676 803 \section1 Groups of Functions and Properties … … 1011 1138 \sa windowFlags 1012 1139 */ 1013 1014 1140 QWidget::QWidget(QWidget *parent, Qt::WindowFlags f) 1015 1141 : QObject(*new QWidgetPrivate, 0), QPaintDevice() … … 1106 1232 } 1107 1233 if (customize) 1108 ; // don't modify window flags if the user explicit ely set them.1234 ; // don't modify window flags if the user explicitly set them. 1109 1235 else if (type == Qt::Dialog || type == Qt::Sheet) 1110 1236 #ifndef Q_WS_WINCE … … 1128 1254 1129 1255 Q_ASSERT(allWidgets); 1130 allWidgets->insert(q); 1256 if (allWidgets) 1257 allWidgets->insert(q); 1131 1258 1132 1259 QWidget *desktopWidget = 0; … … 1175 1302 q->setAttribute(Qt::WA_NativeWindow); 1176 1303 1304 #ifdef Q_WS_MAC 1305 q->setAttribute(Qt::WA_NativeWindow); 1306 #endif 1307 1177 1308 q->setAttribute(Qt::WA_QuitOnClose); // might be cleared in adjustQuitOnCloseAttribute() 1178 1309 adjustQuitOnCloseAttribute(); … … 1181 1312 1182 1313 //give potential windows a bigger "pre-initial" size; create_sys() will give them a new size later 1314 #ifdef Q_OS_SYMBIAN 1315 if (isGLWidget) { 1316 // Don't waste GPU mem for unnecessary large egl surface 1317 data.crect = QRect(0,0,2,2); 1318 } else { 1319 data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,360,640); 1320 } 1321 #else 1183 1322 data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480); 1323 #endif 1184 1324 1185 1325 focus_next = focus_prev = q; … … 1270 1410 1271 1411 if (QWidget *parent = parentWidget()) { 1412 #ifdef Q_WS_MAC 1413 if (testAttribute(Qt::WA_NativeWindow) == false) 1414 parent->d_func()->hasAlienChildren = true; 1415 #endif 1272 1416 if (type & Qt::Window) { 1273 1417 if (!parent->testAttribute(Qt::WA_WState_Created)) … … 1331 1475 // a real toplevel window needs a backing store 1332 1476 if (isWindow() && windowType() != Qt::Desktop) { 1333 delete d->topData()->backingStore; 1334 // QWidgetBackingStore will check this variable, hence it must be 0 1335 d->topData()->backingStore = 0; 1477 d->topData()->backingStore.destroy(); 1336 1478 if (hasBackingStoreSupport()) 1337 d->topData()->backingStore = new QWidgetBackingStore(this);1479 d->topData()->backingStore.create(this); 1338 1480 } 1339 1481 … … 1378 1520 if (paintingActive()) 1379 1521 qWarning("QWidget: %s (%s) deleted while being painted", className(), name()); 1522 #endif 1523 1524 #ifndef QT_NO_GESTURES 1525 foreach (Qt::GestureType type, d->gestureContext.keys()) 1526 ungrabGesture(type); 1380 1527 #endif 1381 1528 … … 1440 1587 } 1441 1588 1442 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_ PM)1589 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM) 1443 1590 else if (!internalWinId() && isVisible()) { 1444 1591 qApp->d_func()->sendSyntheticEnterLeave(this); … … 1458 1605 // not have a reference to this widget that will be used later to 1459 1606 // notify the window it no longer has a surface. 1460 delete d->extra->topextra->backingStore; 1461 d->extra->topextra->backingStore = 0; 1607 d->extra->topextra->backingStore.destroy(); 1462 1608 } 1463 1609 #endif … … 1475 1621 1476 1622 if (d->declarativeData) { 1477 d->declarativeData->destroyed(this);1623 QAbstractDeclarativeData::destroyed(d->declarativeData, this); 1478 1624 d->declarativeData = 0; // don't activate again in ~QObject 1479 1625 } 1626 1627 #ifdef QT_MAC_USE_COCOA 1628 // QCocoaView holds a pointer back to this widget. Clear it now 1629 // to make sure it's not followed later on. The lifetime of the 1630 // QCocoaView might exceed the lifetime of this widget in cases 1631 // where Cocoa itself holds references to it. 1632 extern void qt_mac_clearCocoaViewQWidgetPointers(QWidget *); 1633 qt_mac_clearCocoaViewQWidgetPointers(this); 1634 #endif 1480 1635 1481 1636 if (!d->children.isEmpty()) … … 1529 1684 1530 1685 if(oldWinId != id) { 1531 // Do not emit an event when the old winId is destroyed. This only 1532 // happens (a) during widget destruction, and (b) immediately prior 1533 // to creation of a new winId, for example as a result of re-parenting. 1534 if(id != 0) { 1535 QEvent e(QEvent::WinIdChange); 1536 QCoreApplication::sendEvent(q, &e); 1537 } 1686 QEvent e(QEvent::WinIdChange); 1687 QCoreApplication::sendEvent(q, &e); 1538 1688 } 1539 1689 } … … 1547 1697 x->icon = 0; 1548 1698 x->iconPixmap = 0; 1549 x->backingStore = 0;1550 1699 x->windowSurface = 0; 1551 1700 x->sharedPainter = 0; … … 1561 1710 x->inRepaint = false; 1562 1711 x->embedded = 0; 1712 #ifdef Q_WS_MAC 1713 #ifdef QT_MAC_USE_COCOA 1714 x->wasMaximized = false; 1715 #endif // QT_MAC_USE_COCOA 1716 #endif // Q_WS_MAC 1563 1717 createTLSysExtra(); 1564 1718 #ifdef QWIDGET_EXTRA_DEBUG … … 1626 1780 if (extra->topextra) { 1627 1781 deleteTLSysExtra(); 1628 delete extra->topextra->backingStore;1782 extra->topextra->backingStore.destroy(); 1629 1783 delete extra->topextra->icon; 1630 1784 delete extra->topextra->iconPixmap; … … 2308 2462 { 2309 2463 if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { 2464 #ifdef ALIEN_DEBUG 2465 qDebug() << "QWidget::winId: creating native window for" << this; 2466 #endif 2310 2467 QWidget *that = const_cast<QWidget*>(this); 2311 2468 that->setAttribute(Qt::WA_NativeWindow); … … 2320 2477 { 2321 2478 Q_Q(QWidget); 2479 2480 #ifdef ALIEN_DEBUG 2481 qDebug() << "QWidgetPrivate::createWinId for" << q << winid; 2482 #endif 2322 2483 const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow); 2323 2484 if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) { … … 2362 2523 { 2363 2524 Q_D(QWidget); 2525 #ifdef ALIEN_DEBUG 2526 qDebug() << "QWidget::createWinId" << this; 2527 #endif 2364 2528 // qWarning("QWidget::createWinId is obsolete, please fix your code."); 2365 2529 d->createWinId(); … … 2508 2672 QStyle *oldStyle = q->style(); 2509 2673 #ifndef QT_NO_STYLE_STYLESHEET 2510 Q Style *origStyle = 0;2674 QWeakPointer<QStyle> origStyle; 2511 2675 #endif 2512 2676 … … 2522 2686 2523 2687 #ifndef QT_NO_STYLE_STYLESHEET 2524 origStyle = extra->style ;2688 origStyle = extra->style.data(); 2525 2689 #endif 2526 2690 extra->style = newStyle; … … 2551 2715 } 2552 2716 2717 #ifndef QT_NO_STYLE_STYLESHEET 2718 if (!qobject_cast<QStyleSheetStyle*>(newStyle)) { 2719 if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle.data())) { 2720 cssStyle->clearWidgetFont(q); 2721 } 2722 } 2723 #endif 2724 2553 2725 QEvent e(QEvent::StyleChange); 2554 2726 QApplication::sendEvent(q, &e); … … 2558 2730 2559 2731 #ifndef QT_NO_STYLE_STYLESHEET 2560 if (!qobject_cast<QStyleSheetStyle*>(newStyle)) {2561 if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle)) {2562 cssStyle->clearWidgetFont(q);2563 }2564 }2565 #endif2566 2567 #ifndef QT_NO_STYLE_STYLESHEET2568 2732 // dereference the old stylesheet style 2569 if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle ))2733 if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle.data())) 2570 2734 proxy->deref(); 2571 2735 #endif … … 2868 3032 void QWidget::showFullScreen() 2869 3033 { 3034 #ifdef Q_WS_MAC 3035 // If the unified toolbar is enabled, we have to disable it before going fullscreen. 3036 QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); 3037 if (mainWindow && mainWindow->unifiedTitleAndToolBarOnMac()) { 3038 mainWindow->setUnifiedTitleAndToolBarOnMac(false); 3039 QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); 3040 mainLayout->activateUnifiedToolbarAfterFullScreen = true; 3041 } 3042 #endif // Q_WS_MAC 2870 3043 ensurePolished(); 2871 3044 #ifdef QT3_SUPPORT … … 2900 3073 setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen)) 2901 3074 | Qt::WindowMaximized); 3075 #ifdef Q_WS_MAC 3076 // If the unified toolbar was enabled before going fullscreen, we have to enable it back. 3077 QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); 3078 if (mainWindow) 3079 { 3080 QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); 3081 if (mainLayout->activateUnifiedToolbarAfterFullScreen) { 3082 mainWindow->setUnifiedTitleAndToolBarOnMac(true); 3083 mainLayout->activateUnifiedToolbarAfterFullScreen = false; 3084 } 3085 } 3086 #endif // Q_WS_MAC 2902 3087 show(); 2903 3088 } … … 2921 3106 | Qt::WindowMaximized 2922 3107 | Qt::WindowFullScreen)); 3108 #ifdef Q_WS_MAC 3109 // If the unified toolbar was enabled before going fullscreen, we have to enable it back. 3110 QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); 3111 if (mainWindow) 3112 { 3113 QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); 3114 if (mainLayout->activateUnifiedToolbarAfterFullScreen) { 3115 mainWindow->setUnifiedTitleAndToolBarOnMac(true); 3116 mainLayout->activateUnifiedToolbarAfterFullScreen = false; 3117 } 3118 } 3119 #endif // Q_WS_MAC 2923 3120 show(); 2924 3121 } … … 4733 4930 direction. 4734 4931 4932 This method no longer affects text layout direction since Qt 4.7. 4933 4735 4934 \sa QApplication::layoutDirection 4736 4935 */ … … 4738 4937 { 4739 4938 Q_D(QWidget); 4939 4940 if (direction == Qt::LayoutDirectionAuto) { 4941 unsetLayoutDirection(); 4942 return; 4943 } 4740 4944 4741 4945 setAttribute(Qt::WA_SetLayoutDirection); … … 4891 5095 const QRegion &sourceRegion, RenderFlags renderFlags) 4892 5096 { 4893 Q_D(QWidget); 4894 if (!target) { 4895 qWarning("QWidget::render: null pointer to paint device"); 4896 return; 4897 } 4898 4899 const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter; 4900 QRegion paintRegion = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags) 4901 : sourceRegion; 4902 if (paintRegion.isEmpty()) 4903 return; 4904 4905 #ifndef Q_WS_MAC 4906 QPainter *oldSharedPainter = inRenderWithPainter ? d->sharedPainter() : 0; 4907 4908 // Use the target's shared painter if set (typically set when doing 4909 // "other->render(widget);" in the widget's paintEvent. 4910 if (target->devType() == QInternal::Widget) { 4911 QWidgetPrivate *targetPrivate = static_cast<QWidget *>(target)->d_func(); 4912 if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) { 4913 QPainter *targetPainter = targetPrivate->sharedPainter(); 4914 if (targetPainter && targetPainter->isActive()) 4915 d->setSharedPainter(targetPainter); 4916 } 4917 } 4918 #endif 4919 4920 // Use the target's redirected device if set and adjust offset and paint 4921 // region accordingly. This is typically the case when people call render 4922 // from the paintEvent. 4923 QPoint offset = targetOffset; 4924 offset -= paintRegion.boundingRect().topLeft(); 4925 QPoint redirectionOffset; 4926 QPaintDevice *redirected = 0; 4927 4928 if (target->devType() == QInternal::Widget) 4929 redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset); 4930 if (!redirected) 4931 redirected = QPainter::redirected(target, &redirectionOffset); 4932 4933 if (redirected) { 4934 target = redirected; 4935 offset -= redirectionOffset; 4936 } 4937 4938 if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp). 4939 if (QPaintEngine *targetEngine = target->paintEngine()) { 4940 const QRegion targetSystemClip = targetEngine->systemClip(); 4941 if (!targetSystemClip.isEmpty()) 4942 paintRegion &= targetSystemClip.translated(-offset); 4943 } 4944 } 4945 4946 // Set backingstore flags. 4947 int flags = QWidgetPrivate::DrawPaintOnScreen | QWidgetPrivate::DrawInvisible; 4948 if (renderFlags & DrawWindowBackground) 4949 flags |= QWidgetPrivate::DrawAsRoot; 4950 4951 if (renderFlags & DrawChildren) 4952 flags |= QWidgetPrivate::DrawRecursive; 4953 else 4954 flags |= QWidgetPrivate::DontSubtractOpaqueChildren; 4955 4956 #ifdef Q_WS_QWS 4957 flags |= QWidgetPrivate::DontSetCompositionMode; 4958 #endif 4959 4960 if (target->devType() == QInternal::Printer) { 4961 QPainter p(target); 4962 d->render_helper(&p, targetOffset, paintRegion, renderFlags); 4963 return; 4964 } 4965 4966 #ifndef Q_WS_MAC 4967 // Render via backingstore. 4968 d->drawWidget(target, paintRegion, offset, flags, d->sharedPainter()); 4969 4970 // Restore shared painter. 4971 if (oldSharedPainter) 4972 d->setSharedPainter(oldSharedPainter); 4973 #else 4974 // Render via backingstore (no shared painter). 4975 d->drawWidget(target, paintRegion, offset, flags, 0); 4976 #endif 5097 d_func()->render(target, targetOffset, sourceRegion, renderFlags, false); 4977 5098 } 4978 5099 … … 5334 5455 if (paintEngine) { 5335 5456 setRedirected(pdev, -offset); 5336 5457 #ifdef Q_WS_MAC 5458 // (Alien support) Special case for Mac when redirecting: If the paint device 5459 // is of the Widget type we need to set WA_WState_InPaintEvent since painting 5460 // outside the paint event is not supported on QWidgets. The attributeis 5461 // restored further down. 5462 if (pdev->devType() == QInternal::Widget) 5463 static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent); 5464 5465 #endif 5337 5466 if (sharedPainter) 5338 5467 paintEngine->d_func()->systemClip = toBePainted; … … 5375 5504 //restore 5376 5505 if (paintEngine) { 5506 #ifdef Q_WS_MAC 5507 if (pdev->devType() == QInternal::Widget) 5508 static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent, false); 5509 #endif 5377 5510 restoreRedirected(); 5378 5511 if (!sharedPainter) … … 5418 5551 , sharedPainter, backingStore); 5419 5552 } 5553 } 5554 5555 void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, 5556 const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, 5557 bool readyToRender) 5558 { 5559 if (!target) { 5560 qWarning("QWidget::render: null pointer to paint device"); 5561 return; 5562 } 5563 5564 const bool inRenderWithPainter = extra && extra->inRenderWithPainter; 5565 QRegion paintRegion = !inRenderWithPainter && !readyToRender 5566 ? prepareToRender(sourceRegion, renderFlags) 5567 : sourceRegion; 5568 if (paintRegion.isEmpty()) 5569 return; 5570 5571 #ifndef Q_WS_MAC 5572 QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : 0; 5573 5574 // Use the target's shared painter if set (typically set when doing 5575 // "other->render(widget);" in the widget's paintEvent. 5576 if (target->devType() == QInternal::Widget) { 5577 QWidgetPrivate *targetPrivate = static_cast<QWidget *>(target)->d_func(); 5578 if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) { 5579 QPainter *targetPainter = targetPrivate->sharedPainter(); 5580 if (targetPainter && targetPainter->isActive()) 5581 setSharedPainter(targetPainter); 5582 } 5583 } 5584 #endif 5585 5586 // Use the target's redirected device if set and adjust offset and paint 5587 // region accordingly. This is typically the case when people call render 5588 // from the paintEvent. 5589 QPoint offset = targetOffset; 5590 offset -= paintRegion.boundingRect().topLeft(); 5591 QPoint redirectionOffset; 5592 QPaintDevice *redirected = 0; 5593 5594 if (target->devType() == QInternal::Widget) 5595 redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset); 5596 if (!redirected) 5597 redirected = QPainter::redirected(target, &redirectionOffset); 5598 5599 if (redirected) { 5600 target = redirected; 5601 offset -= redirectionOffset; 5602 } 5603 5604 if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp). 5605 if (QPaintEngine *targetEngine = target->paintEngine()) { 5606 const QRegion targetSystemClip = targetEngine->systemClip(); 5607 if (!targetSystemClip.isEmpty()) 5608 paintRegion &= targetSystemClip.translated(-offset); 5609 } 5610 } 5611 5612 // Set backingstore flags. 5613 int flags = DrawPaintOnScreen | DrawInvisible; 5614 if (renderFlags & QWidget::DrawWindowBackground) 5615 flags |= DrawAsRoot; 5616 5617 if (renderFlags & QWidget::DrawChildren) 5618 flags |= DrawRecursive; 5619 else 5620 flags |= DontSubtractOpaqueChildren; 5621 5622 #ifdef Q_WS_QWS 5623 flags |= DontSetCompositionMode; 5624 #endif 5625 5626 if (target->devType() == QInternal::Printer) { 5627 QPainter p(target); 5628 render_helper(&p, targetOffset, paintRegion, renderFlags); 5629 return; 5630 } 5631 5632 #ifndef Q_WS_MAC 5633 // Render via backingstore. 5634 drawWidget(target, paintRegion, offset, flags, sharedPainter()); 5635 5636 // Restore shared painter. 5637 if (oldSharedPainter) 5638 setSharedPainter(oldSharedPainter); 5639 #else 5640 // Render via backingstore (no shared painter). 5641 drawWidget(target, paintRegion, offset, flags, 0); 5642 #endif 5420 5643 } 5421 5644 … … 5537 5760 } 5538 5761 5539 5540 5762 QRect effectRect; 5541 5763 5542 if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {5764 if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) 5543 5765 effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); 5544 5545 } else if (mode == QGraphicsEffect::PadToTransparentBorder) { 5766 else if (mode == QGraphicsEffect::PadToTransparentBorder) 5546 5767 effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); 5547 5548 } else { 5768 else 5549 5769 effectRect = sourceRect.toAlignedRect(); 5550 5551 }5552 5770 5553 5771 if (offset) 5554 5772 *offset = effectRect.topLeft(); 5555 5773 5556 if (deviceCoordinates) {5557 // Clip to device rect.5558 int left, top, right, bottom;5559 effectRect.getCoords(&left, &top, &right, &bottom);5560 if (left < 0) {5561 if (offset)5562 offset->rx() += -left;5563 effectRect.setX(0);5564 }5565 if (top < 0) {5566 if (offset)5567 offset->ry() += -top;5568 effectRect.setY(0);5569 }5570 // NB! We use +-1 for historical reasons (see QRect documentation).5571 QPaintDevice *device = context->painter->device();5572 const int deviceWidth = device->width();5573 const int deviceHeight = device->height();5574 if (right + 1 > deviceWidth)5575 effectRect.setRight(deviceWidth - 1);5576 if (bottom + 1 > deviceHeight)5577 effectRect.setBottom(deviceHeight -1);5578 }5579 5580 5774 pixmapOffset -= effectRect.topLeft(); 5581 5775 5582 5776 QPixmap pixmap(effectRect.size()); 5583 5777 pixmap.fill(Qt::transparent); 5584 m_widget->render(&pixmap, pixmapOffset );5778 m_widget->render(&pixmap, pixmapOffset, QRegion(), QWidget::DrawChildren); 5585 5779 return pixmap; 5586 5780 } … … 6186 6380 } 6187 6381 if (!isHidden()) { 6382 #ifndef QT_NO_GRAPHICSVIEW 6383 // Update proxy state 6384 if (QWExtra *topData = window()->d_func()->extra) 6385 if (topData->proxyWidget && topData->proxyWidget->hasFocus()) 6386 topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget(); 6387 #endif 6188 6388 // Send event to self 6189 6389 QFocusEvent event(QEvent::FocusIn, reason); … … 6465 6665 QWidget *fn = first->d_func()->focus_next; 6466 6666 6467 if (fn == second )6667 if (fn == second || first == second) 6468 6668 return; 6469 6669 … … 6694 6894 QByteArray QWidget::saveGeometry() const 6695 6895 { 6896 #ifdef QT_MAC_USE_COCOA 6897 // We check if the window was maximized during this invocation. If so, we need to record the 6898 // starting position as 0,0. 6899 Q_D(const QWidget); 6900 QRect newFramePosition = frameGeometry(); 6901 QRect newNormalPosition = normalGeometry(); 6902 if(d->topData()->wasMaximized && !(windowState() & Qt::WindowMaximized)) { 6903 // Change the starting position 6904 newFramePosition.moveTo(0, 0); 6905 newNormalPosition.moveTo(0, 0); 6906 } 6907 #endif // QT_MAC_USE_COCOA 6696 6908 QByteArray array; 6697 6909 QDataStream stream(&array, QIODevice::WriteOnly); … … 6703 6915 << majorVersion 6704 6916 << minorVersion 6917 #ifdef QT_MAC_USE_COCOA 6918 << newFramePosition 6919 << newNormalPosition 6920 #else 6705 6921 << frameGeometry() 6706 6922 << normalGeometry() 6923 #endif // QT_MAC_USE_COCOA 6707 6924 << qint32(QApplication::desktop()->screenNumber(this)) 6708 6925 << quint8(windowState() & Qt::WindowMaximized) … … 7281 7498 bool isEmbedded = false; 7282 7499 #if !defined QT_NO_GRAPHICSVIEW 7283 isEmbedded = q->isWindow() && nearestGraphicsProxyWidget(q->parentWidget()) != 0;7500 isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != 0; 7284 7501 #else 7285 7502 Q_UNUSED(isEmbedded); … … 7318 7535 // hidden. 7319 7536 if (wasVisible) { 7320 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_ PM)7537 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM) 7321 7538 qApp->d_func()->sendSyntheticEnterLeave(q); 7322 7539 #endif … … 7349 7566 it. It will not be automatically shown when the parent is shown. 7350 7567 7351 To check visib lity, use !isVisible() instead (notice the exclamation mark).7568 To check visibility, use !isVisible() instead (notice the exclamation mark). 7352 7569 7353 7570 isHidden() implies !isVisible(), but a widget can be not visible … … 7450 7667 d->show_helper(); 7451 7668 7452 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_ PM)7669 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM) 7453 7670 qApp->d_func()->sendSyntheticEnterLeave(this); 7454 7671 #endif … … 7582 7799 } 7583 7800 } 7584 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_ PM)7801 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM) 7585 7802 qApp->d_func()->sendSyntheticEnterLeave(widget); 7586 7803 #endif … … 7626 7843 QApplication::quit(); 7627 7844 #endif 7628 // Attempt to close the application only if this widget has the 7629 // WA_QuitOnClose flag set set and has a non-visible parent 7630 quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible() || parentWidget->testAttribute(Qt::WA_DontShowOnScreen)); 7845 // Attempt to close the application only if this has WA_QuitOnClose set and a non-visible parent 7846 quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible()); 7631 7847 7632 7848 if (quitOnClose) { 7633 / / If there is no non-withdrawn primary window left (except7634 // the ones without QuitOnClose or with WA_DontShowOnScreen),7635 // we emit the lastWindowClosed signal7849 /* if there is no non-withdrawn primary window left (except 7850 the ones without QuitOnClose), we emit the lastWindowClosed 7851 signal */ 7636 7852 QWidgetList list = QApplication::topLevelWidgets(); 7637 7853 bool lastWindowClosed = true; 7638 7854 for (int i = 0; i < list.size(); ++i) { 7639 7855 QWidget *w = list.at(i); 7640 if ((w->isVisible() && !w->testAttribute(Qt::WA_DontShowOnScreen)) 7641 && !w->parentWidget() && w->testAttribute(Qt::WA_QuitOnClose)) { 7642 lastWindowClosed = false; 7643 break; 7644 } 7856 if (!w->isVisible() || w->parentWidget() || !w->testAttribute(Qt::WA_QuitOnClose)) 7857 continue; 7858 lastWindowClosed = false; 7859 break; 7645 7860 } 7646 7861 if (lastWindowClosed) … … 8484 8699 break; 8485 8700 } 8701 #ifndef QT_NO_GESTURES 8486 8702 case QEvent::Gesture: 8487 8703 event->ignore(); 8488 8704 break; 8705 #endif 8489 8706 #ifndef QT_NO_PROPERTIES 8490 8707 case QEvent::DynamicPropertyChange: { … … 8513 8730 This event handler can be reimplemented to handle state changes. 8514 8731 8515 The state being changed in this event can be retrieved through event \a8516 event.8732 The state being changed in this event can be retrieved through the \a event 8733 supplied. 8517 8734 8518 8735 Change events include: QEvent::ToolBarChange, … … 8625 8842 while ((w = QApplication::activePopupWidget()) && w != this){ 8626 8843 w->close(); 8627 if (QApplication::activePopupWidget() == w) // widget does not want to dis sappear8844 if (QApplication::activePopupWidget() == w) // widget does not want to disappear 8628 8845 w->hide(); // hide at least 8629 8846 } … … 9078 9295 { 9079 9296 #ifndef QT_NO_IM 9080 Q_D(const QWidget); 9081 return d->imHints; 9297 const QWidgetPrivate *priv = d_func(); 9298 while (priv->inheritsInputMethodHints) { 9299 priv = priv->q_func()->parentWidget()->d_func(); 9300 Q_ASSERT(priv); 9301 } 9302 return priv->imHints; 9082 9303 #else //QT_NO_IM 9083 9304 return 0; … … 9090 9311 Q_D(QWidget); 9091 9312 d->imHints = hints; 9092 // Optimi sation to update input context only it has already been created.9313 // Optimization to update input context only it has already been created. 9093 9314 if (d->ic || qApp->d_func()->inputContext) { 9094 9315 QInputContext *ic = inputContext(); … … 9634 9855 QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const 9635 9856 { 9857 if (children.isEmpty()) 9858 return 0; 9859 9860 #ifdef Q_WS_MAC 9636 9861 Q_Q(const QWidget); 9637 #ifdef Q_WS_MAC 9862 // Unified tool bars on the Mac require special handling since they live outside 9863 // QMainWindow's geometry(). See commit: 35667fd45ada49269a5987c235fdedfc43e92bb8 9638 9864 bool includeFrame = q->isWindow() && qobject_cast<const QMainWindow *>(q) 9639 9865 && static_cast<const QMainWindow *>(q)->unifiedTitleAndToolBarOnMac(); 9640 #endif 9641 9642 if ( 9866 if (includeFrame) 9867 return childAtRecursiveHelper(p, ignoreChildrenInDestructor, includeFrame); 9868 #endif 9869 9870 if (!pointInsideRectAndMask(p)) 9871 return 0; 9872 return childAtRecursiveHelper(p, ignoreChildrenInDestructor); 9873 } 9874 9875 QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor, bool includeFrame) const 9876 { 9877 #ifndef Q_WS_MAC 9878 Q_UNUSED(includeFrame); 9879 #endif 9880 for (int i = children.size() - 1; i >= 0; --i) { 9881 QWidget *child = qobject_cast<QWidget *>(children.at(i)); 9882 if (!child || child->isWindow() || child->isHidden() || child->testAttribute(Qt::WA_TransparentForMouseEvents) 9883 || (ignoreChildrenInDestructor && child->data->in_destructor)) { 9884 continue; 9885 } 9886 9887 // Map the point 'p' from parent coordinates to child coordinates. 9888 QPoint childPoint = p; 9643 9889 #ifdef Q_WS_MAC 9644 !includeFrame && 9645 #endif 9646 !q->rect().contains(p)) 9647 return 0; 9648 9649 for (int i = children.size(); i > 0 ;) { 9650 --i; 9651 QWidget *w = qobject_cast<QWidget *>(children.at(i)); 9652 if (w && !w->isWindow() && !w->isHidden() 9653 && (w->geometry().contains(p) 9654 #ifdef Q_WS_MAC 9655 || (includeFrame && w->geometry().contains(qt_mac_nativeMapFromParent(w, p))) 9656 #endif 9657 )) { 9658 if (ignoreChildrenInDestructor && w->data->in_destructor) 9659 continue; 9660 if (w->testAttribute(Qt::WA_TransparentForMouseEvents)) 9661 continue; 9662 QPoint childPoint = w->mapFromParent(p); 9663 #ifdef Q_WS_MAC 9664 if (includeFrame && !w->geometry().contains(p)) 9665 childPoint = qt_mac_nativeMapFromParent(w, p); 9666 #endif 9667 if (QWidget *t = w->d_func()->childAt_helper(childPoint, ignoreChildrenInDestructor)) 9668 return t; 9669 // if WMouseNoMask is set the widget mask is ignored, if 9670 // the widget has no mask then the WMouseNoMask flag has no 9671 // effect 9672 if (w->testAttribute(Qt::WA_MouseNoMask) || w->mask().contains(childPoint) 9673 || w->mask().isEmpty()) 9674 return w; 9675 } 9890 // 'includeFrame' is true if the child's parent is a top-level QMainWindow with an unified tool bar. 9891 // An unified tool bar on the Mac lives outside QMainWindow's geometry(), so a normal 9892 // QWidget::mapFromParent won't do the trick. 9893 if (includeFrame && qobject_cast<QToolBar *>(child)) 9894 childPoint = qt_mac_nativeMapFromParent(child, p); 9895 else 9896 #endif 9897 childPoint -= child->data->crect.topLeft(); 9898 9899 // Check if the point hits the child. 9900 if (!child->d_func()->pointInsideRectAndMask(childPoint)) 9901 continue; 9902 9903 // Do the same for the child's descendants. 9904 if (QWidget *w = child->d_func()->childAtRecursiveHelper(childPoint, ignoreChildrenInDestructor)) 9905 return w; 9906 9907 // We have found our target; namely the child at position 'p'. 9908 return child; 9676 9909 } 9677 9910 return 0; … … 9830 10063 bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget; 9831 10064 9832 #if defined(Q_WS_X11) || defined(Q_WS_WIN) 10065 #if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) 9833 10066 if (newParent && parent && !desktopWidget) { 9834 10067 if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) … … 9852 10085 focusWidget()->clearFocus(); 9853 10086 10087 QTLWExtra *oldTopExtra = window()->d_func()->maybeTopData(); 10088 QWidgetBackingStoreTracker *oldBsTracker = oldTopExtra ? &oldTopExtra->backingStore : 0; 10089 9854 10090 d->setParent_sys(parent, f); 10091 10092 QTLWExtra *topExtra = window()->d_func()->maybeTopData(); 10093 QWidgetBackingStoreTracker *bsTracker = topExtra ? &topExtra->backingStore : 0; 10094 if (oldBsTracker && oldBsTracker != bsTracker) 10095 oldBsTracker->unregisterWidgetSubtree(this); 10096 9855 10097 if (desktopWidget) 9856 10098 parent = 0; … … 10315 10557 #endif // QT3_SUPPORT 10316 10558 10317 /*! 10318 Sets the attribute \a attribute on this widget if \a on is true; 10319 otherwise clears the attribute. 10320 10321 \sa testAttribute() 10322 */ 10323 void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) 10324 { 10325 if (testAttribute(attribute) == on) 10326 return; 10327 10328 Q_D(QWidget); 10329 Q_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8), 10330 "QWidget::setAttribute(WidgetAttribute, bool)", 10331 "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute"); 10332 10333 #if defined(Q_WS_WIN) || defined(Q_WS_PM) 10334 // ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0 10335 if (attribute == Qt::WA_PaintOnScreen && on && !inherits("QGLWidget")) { 10336 // see qwidget_[win|pm].cpp, ::paintEngine for details 10337 paintEngine(); 10338 if (d->noPaintOnScreen) 10339 return; 10340 } 10341 #endif 10342 10559 /*! 10560 \internal 10561 10562 This just sets the corresponding attribute bit to 1 or 0 10563 */ 10564 static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidgetData *data, 10565 QWidgetPrivate *d) 10566 { 10343 10567 if (attribute < int(8*sizeof(uint))) { 10344 10568 if (on) … … 10354 10578 d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint)))); 10355 10579 } 10580 } 10581 10582 /*! 10583 Sets the attribute \a attribute on this widget if \a on is true; 10584 otherwise clears the attribute. 10585 10586 \sa testAttribute() 10587 */ 10588 void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) 10589 { 10590 if (testAttribute(attribute) == on) 10591 return; 10592 10593 Q_D(QWidget); 10594 Q_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8), 10595 "QWidget::setAttribute(WidgetAttribute, bool)", 10596 "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute"); 10597 10598 #if defined(Q_WS_WIN) || defined(Q_WS_PM) 10599 // ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0 10600 if (attribute == Qt::WA_PaintOnScreen && on && !inherits("QGLWidget")) { 10601 // see qwidget_[win|pm].cpp, ::paintEngine for details 10602 paintEngine(); 10603 if (d->noPaintOnScreen) 10604 return; 10605 } 10606 #endif 10607 10608 setAttribute_internal(attribute, on, data, d); 10356 10609 10357 10610 switch (attribute) { … … 10412 10665 { 10413 10666 // We can only have one of these set at a time 10414 static const int MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize, 10415 Qt::WA_MacMiniSize, 0 }; 10416 for (int i = 0; MacSizes[i] != 0; ++i) { 10417 if (MacSizes[i] == attribute) 10418 continue; 10419 int macsize_x = MacSizes[i] - 8*sizeof(uint); 10420 int macsize_int_off = macsize_x / (8*sizeof(uint)); 10421 d->high_attributes[macsize_int_off] &= ~(1<<(macsize_x-(macsize_int_off*8*sizeof(uint)))); 10667 const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize, 10668 Qt::WA_MacMiniSize }; 10669 for (int i = 0; i < 3; ++i) { 10670 if (MacSizes[i] != attribute) 10671 setAttribute_internal(MacSizes[i], false, data, d); 10422 10672 } 10423 10673 d->macUpdateSizeAttribute(); … … 10486 10736 case Qt::WA_PaintOnScreen: 10487 10737 d->updateIsOpaque(); 10488 #if defined(Q_WS_WIN) || defined(Q_WS_X11) 10738 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) 10489 10739 // Recreate the widget if it's already created as an alien widget and 10490 10740 // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id. … … 10542 10792 d->updateIsOpaque(); 10543 10793 break; 10794 case Qt::WA_X11DoNotAcceptFocus: 10795 if (testAttribute(Qt::WA_WState_Created)) 10796 d->updateX11AcceptFocus(); 10797 break; 10544 10798 #endif 10545 10799 case Qt::WA_DontShowOnScreen: { … … 10597 10851 break; 10598 10852 case Qt::WA_AcceptTouchEvents: 10599 #if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_ WS_S60)10853 #if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) 10600 10854 if (on) 10601 10855 d->registerTouchWindow(); 10602 10856 #endif 10603 10857 break; 10858 case Qt::WA_LockPortraitOrientation: 10859 case Qt::WA_LockLandscapeOrientation: 10860 case Qt::WA_AutoOrientation: { 10861 const Qt::WidgetAttribute orientations[3] = { 10862 Qt::WA_LockPortraitOrientation, 10863 Qt::WA_LockLandscapeOrientation, 10864 Qt::WA_AutoOrientation 10865 }; 10866 10867 if (on) { 10868 // We can only have one of these set at a time 10869 for (int i = 0; i < 3; ++i) { 10870 if (orientations[i] != attribute) 10871 setAttribute_internal(orientations[i], false, data, d); 10872 } 10873 } 10874 10875 #ifdef Q_WS_S60 10876 CAknAppUiBase* appUi = static_cast<CAknAppUiBase*>(CEikonEnv::Static()->EikAppUi()); 10877 const CAknAppUiBase::TAppUiOrientation s60orientations[] = { 10878 CAknAppUiBase::EAppUiOrientationPortrait, 10879 CAknAppUiBase::EAppUiOrientationLandscape, 10880 CAknAppUiBase::EAppUiOrientationAutomatic 10881 }; 10882 CAknAppUiBase::TAppUiOrientation s60orientation = CAknAppUiBase::EAppUiOrientationUnspecified; 10883 for (int i = 0; i < 3; ++i) { 10884 if (testAttribute(orientations[i])) { 10885 s60orientation = s60orientations[i]; 10886 break; 10887 } 10888 } 10889 QT_TRAP_THROWING(appUi->SetOrientationL(s60orientation)); 10890 S60->orientationSet = true; 10891 #endif 10892 break; 10893 } 10604 10894 default: 10605 10895 break; … … 10959 11249 #if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) 10960 11250 Q_D(QWidget); 10961 // and optimi sation to update input context only it has already been created.11251 // and optimization to update input context only it has already been created. 10962 11252 if (d->ic || qApp->d_func()->inputContext) { 10963 11253 QInputContext *ic = inputContext(); … … 11785 12075 Tells us if it there is currently a reachable widget by keypad navigation in 11786 12076 a certain \a orientation. 11787 If no navigation is possible, occur ing key events in that \a orientation may11788 be used to interact with the value in the focus sed widget, even though it12077 If no navigation is possible, occurring key events in that \a orientation may 12078 be used to interact with the value in the focused widget, even though it 11789 12079 currently has not the editFocus. 11790 12080 … … 11806 12096 navigation. If there is no QTabWidget, the horizontal key events can be used 11807 12097 to 11808 interact with the value in the focus sed widget, even though it currently has12098 interact with the value in the focused widget, even though it currently has 11809 12099 not the editFocus. 11810 12100 … … 12006 12296 */ 12007 12297 12298 #ifndef QT_NO_GESTURES 12008 12299 /*! 12009 12300 Subscribes the widget to a given \a gesture with specific \a flags. … … 12029 12320 Q_D(QWidget); 12030 12321 if (d->gestureContext.remove(gesture)) { 12031 QGestureManager *manager = QGestureManager::instance();12032 manager->cleanupCachedGestures(this, gesture);12033 } 12034 } 12035 12322 if (QGestureManager *manager = QGestureManager::instance()) 12323 manager->cleanupCachedGestures(this, gesture); 12324 } 12325 } 12326 #endif // QT_NO_GESTURES 12036 12327 12037 12328 /*! … … 12357 12648 #endif 12358 12649 12650 #if QT_MAC_USE_COCOA 12651 void QWidgetPrivate::syncUnifiedMode() { 12652 // The whole purpose of this method is to keep the unifiedToolbar in sync. 12653 // That means making sure we either exchange the drawing methods or we let 12654 // the toolbar know that it does not require to draw the baseline. 12655 Q_Q(QWidget); 12656 // This function makes sense only if this is a top level 12657 if(!q->isWindow()) 12658 return; 12659 OSWindowRef window = qt_mac_window_for(q); 12660 if(changeMethods) { 12661 // Ok, we are in documentMode. 12662 if(originalDrawMethod) 12663 qt_mac_replaceDrawRect(window, this); 12664 } else { 12665 if(!originalDrawMethod) 12666 qt_mac_replaceDrawRectOriginal(window, this); 12667 } 12668 } 12669 12670 #endif // QT_MAC_USE_COCOA 12671 12359 12672 QT_END_NAMESPACE 12360 12673
Note:
See TracChangeset
for help on using the changeset viewer.