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 <joerg.bornemann@digia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> Reviewed-by: Oliver Wolff <oliver.wolff@digia.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
parent
8d720bff2d
commit
2fa3d365ac
@ -368,56 +368,53 @@ void QWindowsContext::setKeyGrabber(QWindow *w)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Window class registering code (from qapplication_win.cpp)
|
// 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)
|
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;
|
const Qt::WindowFlags type = flags & Qt::WindowType_Mask;
|
||||||
|
// Determine style and icon.
|
||||||
uint style = 0;
|
uint style = CS_DBLCLKS;
|
||||||
bool icon = false;
|
bool icon = true;
|
||||||
QString cname = QStringLiteral("Qt5");
|
if (isGL || (flags & Qt::MSWindowsOwnDC))
|
||||||
if (w && isGL) {
|
style |= CS_OWNDC;
|
||||||
cname += QStringLiteral("QGLWindow");
|
if ((QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)
|
||||||
style = CS_DBLCLKS|CS_OWNDC;
|
&& (type == Qt::Popup || w->property("_q_windowsDropShadow").toBool())) {
|
||||||
icon = true;
|
style |= CS_DROPSHADOW;
|
||||||
} 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;
|
|
||||||
icon = false;
|
|
||||||
} else {
|
|
||||||
cname += QStringLiteral("QWindow");
|
|
||||||
style = CS_DBLCLKS;
|
|
||||||
icon = true;
|
|
||||||
}
|
}
|
||||||
|
if (type == Qt::Tool || type == Qt::ToolTip || type == Qt::Popup) {
|
||||||
|
style |= CS_SAVEBITS; // Save/restore background
|
||||||
|
icon = false;
|
||||||
|
}
|
||||||
|
// 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;
|
HBRUSH brush = 0;
|
||||||
if (w && !isGL)
|
if (!isGL)
|
||||||
brush = GetSysColorBrush(COLOR_WINDOW);
|
brush = GetSysColorBrush(COLOR_WINDOW);
|
||||||
return registerWindowClass(cname, qWindowsWndProc, style, brush, icon);
|
return registerWindowClass(cname, qWindowsWndProc, style, brush, icon);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user