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:
parent
db8167c224
commit
f4ffe2a243
@ -412,9 +412,17 @@ QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL)
|
|||||||
&& (type == Qt::Popup || w->property("_q_windowsDropShadow").toBool())) {
|
&& (type == Qt::Popup || w->property("_q_windowsDropShadow").toBool())) {
|
||||||
style |= CS_DROPSHADOW;
|
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
|
style |= CS_SAVEBITS; // Save/restore background
|
||||||
icon = false;
|
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
|
// Create a unique name for the flag combination
|
||||||
QString cname = QStringLiteral("Qt5QWindow");
|
QString cname = QStringLiteral("Qt5QWindow");
|
||||||
|
@ -110,6 +110,8 @@ static QByteArray debugWinExStyle(DWORD exStyle)
|
|||||||
rc += " WS_EX_CONTEXTHELP";
|
rc += " WS_EX_CONTEXTHELP";
|
||||||
if (exStyle & WS_EX_LAYERED)
|
if (exStyle & WS_EX_LAYERED)
|
||||||
rc += " WS_EX_LAYERED";
|
rc += " WS_EX_LAYERED";
|
||||||
|
if (exStyle & WS_EX_DLGMODALFRAME)
|
||||||
|
rc += " WS_EX_DLGMODALFRAME";
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,6 +515,10 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
|
|||||||
}
|
}
|
||||||
if (flags & Qt::WindowSystemMenuHint)
|
if (flags & Qt::WindowSystemMenuHint)
|
||||||
style |= WS_SYSMENU;
|
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)
|
if (flags & Qt::WindowMinimizeButtonHint)
|
||||||
style |= WS_MINIMIZEBOX;
|
style |= WS_MINIMIZEBOX;
|
||||||
if (shouldShowMaximizeButton(w, flags))
|
if (shouldShowMaximizeButton(w, flags))
|
||||||
|
@ -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
|
// interpret WindowSystemMenuHint as a close button and we can't change that behavior
|
||||||
// we can't just add this in.
|
// we can't just add this in.
|
||||||
#ifndef Q_WS_MAC
|
#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;
|
flags |= Qt::WindowSystemMenuHint;
|
||||||
#else
|
#else
|
||||||
if (flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint
|
if (flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint
|
||||||
|
Loading…
Reference in New Issue
Block a user