diff options
author | Bastiaan Veelo <Bastiaan@SARC.nl> | 2013-11-16 01:02:22 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-01 15:50:26 +0100 |
commit | 5e99b07a072bedee239ed6980a44719da9ffa7c9 (patch) | |
tree | bb429bcaf50aaa5dc6e41c5c23e8a8ccfb8962d5 /src/widgets | |
parent | dd987a9ef08933b970387dac1f9bdd930ca9656c (diff) |
Fix setWindowFlags() for QMdiSubWindow.
It was impossible to hide/show the close button after a QMdiSubWindow
was created.
Task-number: QTBUG-9933
Task-number: QTBUG-27274
[ChangeLog][QtWidgets][QMdiSubWindow] Fixed setWindowFlags() for QMdiSubWindow.
Change-Id: I7db9a1bef5ba8a8ace729acb85682c8b3de9c33c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 33 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget_p.h | 1 | ||||
-rw-r--r-- | src/widgets/widgets/qmdisubwindow.cpp | 6 |
3 files changed, 25 insertions, 15 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 6b2f88ce58..596b92e06b 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -9479,27 +9479,36 @@ void QWidget::updateGeometry() */ void QWidget::setWindowFlags(Qt::WindowFlags flags) { - if (data->window_flags == flags) - return; - Q_D(QWidget); + d->setWindowFlags(flags); +} + +/*! \internal + + Implemented in QWidgetPrivate so that QMdiSubWindowPrivate can reimplement it. +*/ +void QWidgetPrivate::setWindowFlags(Qt::WindowFlags flags) +{ + Q_Q(QWidget); + if (q->data->window_flags == flags) + return; - if ((data->window_flags | flags) & Qt::Window) { + if ((q->data->window_flags | flags) & Qt::Window) { // the old type was a window and/or the new type is a window - QPoint oldPos = pos(); - bool visible = isVisible(); - setParent(parentWidget(), flags); + QPoint oldPos = q->pos(); + bool visible = q->isVisible(); + q->setParent(q->parentWidget(), flags); // if both types are windows or neither of them are, we restore // the old position - if (!((data->window_flags ^ flags) & Qt::Window) - && (visible || testAttribute(Qt::WA_Moved))) { - move(oldPos); + if (!((q->data->window_flags ^ flags) & Qt::Window) + && (visible || q->testAttribute(Qt::WA_Moved))) { + q->move(oldPos); } // for backward-compatibility we change Qt::WA_QuitOnClose attribute value only when the window was recreated. - d->adjustQuitOnCloseAttribute(); + adjustQuitOnCloseAttribute(); } else { - data->window_flags = flags; + q->data->window_flags = flags; } } diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 943b7057b5..5387341a75 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -489,6 +489,7 @@ public: void setWindowTitle_helper(const QString &cap); void setWindowFilePath_helper(const QString &filePath); void setWindowModified_helper(); + virtual void setWindowFlags(Qt::WindowFlags windowFlags); bool setMinimumSize_helper(int &minw, int &minh); bool setMaximumSize_helper(int &maxw, int &maxh); diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 8e1dcbee18..94674319bc 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -2057,13 +2057,13 @@ void QMdiSubWindowPrivate::restoreFocus() /*! \internal - ### Please add QEvent::WindowFlagsChange event */ void QMdiSubWindowPrivate::setWindowFlags(Qt::WindowFlags windowFlags) { Q_Q(QMdiSubWindow); + if (!parent) { - q->setWindowFlags(windowFlags); + QWidgetPrivate::setWindowFlags(windowFlags); return; } @@ -2097,7 +2097,7 @@ void QMdiSubWindowPrivate::setWindowFlags(Qt::WindowFlags windowFlags) delete sizeGrip; #endif - q->setWindowFlags(windowFlags); + QWidgetPrivate::setWindowFlags(windowFlags); updateGeometryConstraints(); updateActions(); QSize currentSize = q->size(); |