Enable menuless dialogs on Windows.

Handle the flags combination Qt::Dialog && !Qt::WindowSystemMenuHint
such that it results in exStyle = WS_EX_DLGMODALFRAME and style =
WS_POPUP | WS_BORDER | WS_SYSMENU and a window class without icon.

Do not set !Qt::WindowSystemMenuHint in QWidgetPrivate::adjustFlags()
for dialogs on Windows.

[ChangeLog][QtWidgets][QDialog][Windows] Dialogs can now be menuless.

Task-number: QTBUG-2027

Change-Id: Ieb86985e8a5291d826c103fe478ecde43971f08e
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
Friedemann Kleint 2014-02-27 12:28:48 +01:00 committed by The Qt Project
parent db8167c224
commit f4ffe2a243
3 changed files with 20 additions and 2 deletions

View File

@ -412,9 +412,17 @@ QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL)
&& (type == Qt::Popup || w->property("_q_windowsDropShadow").toBool())) {
style |= CS_DROPSHADOW;
}
if (type == Qt::Tool || type == Qt::ToolTip || type == Qt::Popup) {
switch (type) {
case Qt::Tool:
case Qt::ToolTip:
case Qt::Popup:
style |= CS_SAVEBITS; // Save/restore background
icon = false;
break;
case Qt::Dialog:
if (!(flags & Qt::WindowSystemMenuHint))
icon = false; // QTBUG-2027, dialogs without system menu.
break;
}
// Create a unique name for the flag combination
QString cname = QStringLiteral("Qt5QWindow");

View File

@ -110,6 +110,8 @@ static QByteArray debugWinExStyle(DWORD exStyle)
rc += " WS_EX_CONTEXTHELP";
if (exStyle & WS_EX_LAYERED)
rc += " WS_EX_LAYERED";
if (exStyle & WS_EX_DLGMODALFRAME)
rc += " WS_EX_DLGMODALFRAME";
return rc;
}
@ -513,6 +515,10 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
}
if (flags & Qt::WindowSystemMenuHint)
style |= WS_SYSMENU;
else if (dialog) {
style |= WS_SYSMENU | WS_BORDER; // QTBUG-2027, dialogs without system menu.
exStyle |= WS_EX_DLGMODALFRAME;
}
if (flags & Qt::WindowMinimizeButtonHint)
style |= WS_MINIMIZEBOX;
if (shouldShowMaximizeButton(w, flags))

View File

@ -1064,7 +1064,11 @@ void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w)
// interpret WindowSystemMenuHint as a close button and we can't change that behavior
// we can't just add this in.
#ifndef Q_WS_MAC
if (flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowContextHelpButtonHint)) {
if ((flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowContextHelpButtonHint))
# ifdef Q_OS_WIN
&& type != Qt::Dialog // QTBUG-2027, allow for menu-less dialogs.
# endif
) {
flags |= Qt::WindowSystemMenuHint;
#else
if (flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint