summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qmainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/qmainwindow.cpp')
-rw-r--r--src/gui/widgets/qmainwindow.cpp71
1 files changed, 66 insertions, 5 deletions
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index 44483ea..1183be6 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -39,6 +39,8 @@
**
****************************************************************************/
+//#define QT_EXPERIMENTAL_CLIENT_DECORATIONS
+
#include "qmainwindow.h"
#include "qmainwindowlayout_p.h"
@@ -99,12 +101,70 @@ public:
uint hasOldCursor : 1;
uint cursorAdjusted : 1;
#endif
+
+ static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow)
+ {
+ return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(0);
+ }
};
+QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow)
+{
+ return QMainWindowPrivate::mainWindowLayout(mainWindow);
+}
+
+#ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS
+Q_GUI_EXPORT void qt_setMainWindowTitleWidget(QMainWindow *mainWindow, Qt::DockWidgetArea area, QWidget *widget)
+{
+ QGridLayout *topLayout = qobject_cast<QGridLayout *>(mainWindow->layout());
+ Q_ASSERT(topLayout);
+
+ int row = 0;
+ int column = 0;
+
+ switch (area) {
+ case Qt::LeftDockWidgetArea:
+ row = 1;
+ column = 0;
+ break;
+ case Qt::TopDockWidgetArea:
+ row = 0;
+ column = 1;
+ break;
+ case Qt::BottomDockWidgetArea:
+ row = 2;
+ column = 1;
+ break;
+ case Qt::RightDockWidgetArea:
+ row = 1;
+ column = 2;
+ break;
+ default:
+ Q_ASSERT_X(false, "qt_setMainWindowTitleWidget", "Unknown area");
+ return;
+ }
+
+ if (QLayoutItem *oldItem = topLayout->itemAtPosition(row, column))
+ delete oldItem->widget();
+ topLayout->addWidget(widget, row, column);
+}
+#endif
+
void QMainWindowPrivate::init()
{
Q_Q(QMainWindow);
- layout = new QMainWindowLayout(q);
+
+#ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS
+ QGridLayout *topLayout = new QGridLayout(q);
+ topLayout->setContentsMargins(0, 0, 0, 0);
+
+ layout = new QMainWindowLayout(q, topLayout);
+
+ topLayout->addItem(layout, 1, 1);
+#else
+ layout = new QMainWindowLayout(q, 0);
+#endif
+
const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);
iconSize = QSize(metric, metric);
q->setAttribute(Qt::WA_Hover);
@@ -461,10 +521,11 @@ QMenuBar *QMainWindow::menuBar() const
*/
void QMainWindow::setMenuBar(QMenuBar *menuBar)
{
- Q_D(QMainWindow);
- if (d->layout->menuBar() && d->layout->menuBar() != menuBar) {
+ QLayout *topLayout = layout();
+
+ if (topLayout->menuBar() && topLayout->menuBar() != menuBar) {
// Reparent corner widgets before we delete the old menu bar.
- QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(d->layout->menuBar());
+ QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(topLayout->menuBar());
if (menuBar) {
// TopLeftCorner widget.
QWidget *cornerWidget = oldMenuBar->cornerWidget(Qt::TopLeftCorner);
@@ -478,7 +539,7 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar)
oldMenuBar->hide();
oldMenuBar->deleteLater();
}
- d->layout->setMenuBar(menuBar);
+ topLayout->setMenuBar(menuBar);
}
/*!