Changeset 846 for trunk/src/gui/widgets/qmainwindow.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/widgets/qmainwindow.cpp
r769 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) … … 40 40 ****************************************************************************/ 41 41 42 //#define QT_EXPERIMENTAL_CLIENT_DECORATIONS 43 42 44 #include "qmainwindow.h" 43 45 #include "qmainwindowlayout_p.h" … … 77 79 #ifdef Q_WS_MAC 78 80 , useHIToolBar(false) 81 , activateUnifiedToolbarAfterFullScreen(false) 79 82 #endif 80 83 #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) … … 88 91 #ifdef Q_WS_MAC 89 92 bool useHIToolBar; 93 bool activateUnifiedToolbarAfterFullScreen; 90 94 #endif 91 95 void init(); … … 100 104 uint cursorAdjusted : 1; 101 105 #endif 106 107 static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow) 108 { 109 return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(0); 110 } 102 111 }; 103 112 113 QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow) 114 { 115 return QMainWindowPrivate::mainWindowLayout(mainWindow); 116 } 117 118 #ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS 119 Q_GUI_EXPORT void qt_setMainWindowTitleWidget(QMainWindow *mainWindow, Qt::DockWidgetArea area, QWidget *widget) 120 { 121 QGridLayout *topLayout = qobject_cast<QGridLayout *>(mainWindow->layout()); 122 Q_ASSERT(topLayout); 123 124 int row = 0; 125 int column = 0; 126 127 switch (area) { 128 case Qt::LeftDockWidgetArea: 129 row = 1; 130 column = 0; 131 break; 132 case Qt::TopDockWidgetArea: 133 row = 0; 134 column = 1; 135 break; 136 case Qt::BottomDockWidgetArea: 137 row = 2; 138 column = 1; 139 break; 140 case Qt::RightDockWidgetArea: 141 row = 1; 142 column = 2; 143 break; 144 default: 145 Q_ASSERT_X(false, "qt_setMainWindowTitleWidget", "Unknown area"); 146 return; 147 } 148 149 if (QLayoutItem *oldItem = topLayout->itemAtPosition(row, column)) 150 delete oldItem->widget(); 151 topLayout->addWidget(widget, row, column); 152 } 153 #endif 154 104 155 void QMainWindowPrivate::init() 105 156 { 106 157 Q_Q(QMainWindow); 107 layout = new QMainWindowLayout(q); 158 159 #ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS 160 QGridLayout *topLayout = new QGridLayout(q); 161 topLayout->setContentsMargins(0, 0, 0, 0); 162 163 layout = new QMainWindowLayout(q, topLayout); 164 165 topLayout->addItem(layout, 1, 1); 166 #else 167 layout = new QMainWindowLayout(q, 0); 168 #endif 169 108 170 const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); 109 171 iconSize = QSize(metric, metric); … … 443 505 QMenuBar *QMainWindow::menuBar() const 444 506 { 445 QMenuBar *menuBar = qobject_cast<QMenuBar *>( d_func()->layout->menuBar());507 QMenuBar *menuBar = qobject_cast<QMenuBar *>(layout()->menuBar()); 446 508 if (!menuBar) { 447 509 QMainWindow *self = const_cast<QMainWindow *>(this); … … 462 524 void QMainWindow::setMenuBar(QMenuBar *menuBar) 463 525 { 464 Q_D(QMainWindow); 465 if (d->layout->menuBar() && d->layout->menuBar() != menuBar) { 526 QLayout *topLayout = layout(); 527 528 if (topLayout->menuBar() && topLayout->menuBar() != menuBar) { 466 529 // Reparent corner widgets before we delete the old menu bar. 467 QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>( d->layout->menuBar());530 QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(topLayout->menuBar()); 468 531 if (menuBar) { 469 532 // TopLeftCorner widget. … … 479 542 oldMenuBar->deleteLater(); 480 543 } 481 d->layout->setMenuBar(menuBar);544 topLayout->setMenuBar(menuBar); 482 545 } 483 546 … … 1375 1438 1376 1439 case QEvent::StyleChange: 1440 #ifndef QT_NO_DOCKWIDGET 1441 d->layout->layoutState.dockAreaLayout.styleChangedEvent(); 1442 #endif 1377 1443 if (!d->explicitIconSize) 1378 1444 setIconSize(QSize()); … … 1438 1504 disappear since it is considered to be part of the title bar. Qt 4.5 and up will now work around this by pulling 1439 1505 the toolbars out and back into the regular toolbar and vice versa when you swap out. 1440 However, a good practice would be that turning off the unified toolbar before you call1441 showFullScreen() and restoring it after you call showNormal().1442 1506 \endlist 1443 1507 … … 1454 1518 1455 1519 // ### Disable the unified toolbar when using anything but the native graphics system. 1456 if (windowSurface()) 1520 // ### Disable when using alien widgets as well 1521 if (windowSurface() || testAttribute(Qt::WA_NativeWindow) == false) 1457 1522 return; 1458 1523 … … 1536 1601 #ifndef QT_NO_MENU 1537 1602 QMenu *popup = createPopupMenu(); 1538 if (popup && !popup->isEmpty()) { 1539 popup->exec(event->globalPos()); 1540 event->accept(); 1541 } 1542 delete popup; 1603 if (popup) { 1604 if (!popup->isEmpty()) { 1605 popup->setAttribute(Qt::WA_DeleteOnClose); 1606 popup->popup(event->globalPos()); 1607 event->accept(); 1608 } else { 1609 delete popup; 1610 } 1611 } 1543 1612 #endif 1544 1613 }
Note:
See TracChangeset
for help on using the changeset viewer.