From 2fa3d365ac60aba43ad09e5239ec61d740c8704d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 11 Mar 2013 15:25:04 +0100 Subject: Windows: Fix class name generation for Qt Quick Controls. New combinations of settings need to be handled (for example, GL + drop shadows for menus). Generate the class name depending on style settings. Introduce new dynamic property for drop shadows. Change-Id: I438f7bdd87f09d3c99076ebf825a12d862948ec1 Reviewed-by: Joerg Bornemann Reviewed-by: Jens Bache-Wiig Reviewed-by: Oliver Wolff Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/windows/qwindowscontext.cpp | 81 +++++++++++------------ 1 file changed, 39 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index f824666a54..7e6b55dead 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -368,56 +368,53 @@ void QWindowsContext::setKeyGrabber(QWindow *w) } // Window class registering code (from qapplication_win.cpp) -// If 0 is passed as the widget pointer, register a window class -// for QWidget as default. This is used in QGLTemporaryContext -// during GL initialization, where we don't want to use temporary -// QWidgets or QGLWidgets, neither do we want to have separate code -// to register window classes. QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL) { - const Qt::WindowFlags flags = w ? w->flags() : (Qt::WindowFlags)0; + Q_ASSERT(w); + const Qt::WindowFlags flags = w->flags(); const Qt::WindowFlags type = flags & Qt::WindowType_Mask; - - uint style = 0; - bool icon = false; - QString cname = QStringLiteral("Qt5"); - if (w && isGL) { - cname += QStringLiteral("QGLWindow"); - style = CS_DBLCLKS|CS_OWNDC; - icon = true; - } else if (w && (flags & Qt::MSWindowsOwnDC)) { - cname += QStringLiteral("QWindowOwnDC"); - style = CS_DBLCLKS|CS_OWNDC; - icon = true; - } else if (w && (type == Qt::Tool || type == Qt::ToolTip)) { - style = CS_DBLCLKS; - if (w->inherits("QTipLabel") || w->inherits("QAlphaWidget")) { - if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP - && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) { - style |= CS_DROPSHADOW; - } - cname += QStringLiteral("QToolTip"); - } else { - cname += QStringLiteral("QTool"); - } - style |= CS_SAVEBITS; - icon = false; - } else if (w && (type == Qt::Popup)) { - cname += QStringLiteral("QPopup"); - style = CS_DBLCLKS|CS_SAVEBITS; - if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP - && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) - style |= CS_DROPSHADOW; + // Determine style and icon. + uint style = CS_DBLCLKS; + bool icon = true; + if (isGL || (flags & Qt::MSWindowsOwnDC)) + style |= CS_OWNDC; + if ((QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) + && (type == Qt::Popup || w->property("_q_windowsDropShadow").toBool())) { + style |= CS_DROPSHADOW; + } + if (type == Qt::Tool || type == Qt::ToolTip || type == Qt::Popup) { + style |= CS_SAVEBITS; // Save/restore background icon = false; - } else { - cname += QStringLiteral("QWindow"); - style = CS_DBLCLKS; - icon = true; } + // Create a unique name for the flag combination + QString cname = QStringLiteral("Qt5QWindow"); + switch (type) { + case Qt::Tool: + cname += QStringLiteral("Tool"); + break; + case Qt::ToolTip: + cname += QStringLiteral("ToolTip"); + break; + case Qt::Popup: + cname += QStringLiteral("Popup"); + break; + default: + break; + } + if (isGL) + cname += QStringLiteral("GL"); + if (style & CS_DROPSHADOW) + cname += QStringLiteral("DropShadow"); + if (style & CS_SAVEBITS) + cname += QStringLiteral("SaveBits"); + if (style & CS_OWNDC) + cname += QStringLiteral("OwnDC"); + if (icon) + cname += QStringLiteral("Icon"); HBRUSH brush = 0; - if (w && !isGL) + if (!isGL) brush = GetSysColorBrush(COLOR_WINDOW); return registerWindowClass(cname, qWindowsWndProc, style, brush, icon); } -- cgit v1.2.3