From 26ae24e20b47d327508cae77751f677248cb4a32 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@digia.com> Date: Thu, 23 May 2013 12:00:58 +0200 Subject: [PATCH] Windows: Fix toplevel window flags for Qt::Dialogs/Qt::Tool. Task-number: QTBUG-31111 Change-Id: I58dcf8101077f18c7867cae914026c692735fc15 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> --- .../platforms/windows/qwindowswindow.cpp | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 403d709dba7..73c78f00903 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -332,6 +332,25 @@ QDebug operator<<(QDebug debug, const WindowCreationData &d) return debug; } +// Fix top level window flags in case only the type flags are passed. +static inline void fixTopLevelWindowFlags(Qt::WindowFlags &flags) +{ + switch (flags) { + case Qt::Window: + flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint + |Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint; + break; + case Qt::Dialog: + flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint; + break; + case Qt::Tool: + flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; + break; + default: + break; + } +} + void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flagsIn, unsigned creationFlags) { @@ -358,10 +377,8 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag topLevel = (creationFlags & ForceTopLevel) ? true : w->isTopLevel(); } - if (topLevel && flags == 1) { - flags |= Qt::WindowTitleHint|Qt::WindowSystemMenuHint|Qt::WindowMinimizeButtonHint - |Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint; - } + if (topLevel) + fixTopLevelWindowFlags(flags); type = static_cast<Qt::WindowType>(int(flags) & Qt::WindowType_Mask); switch (type) { -- GitLab