diff options
Diffstat (limited to 'src/plugins/platforms/windows/qwindowswindowclassdescription.cpp')
| -rw-r--r-- | src/plugins/platforms/windows/qwindowswindowclassdescription.cpp | 80 |
1 files changed, 51 insertions, 29 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp index e2e46a7b215..55e36b4587a 100644 --- a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp +++ b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp @@ -11,6 +11,55 @@ QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; +QString QWindowsWindowClassDescription::classNameSuffix(Qt::WindowFlags type, unsigned int style, bool hasIcon) +{ + QString suffix; + + switch (type) { + case Qt::Popup: + suffix += "Popup"_L1; + break; + case Qt::Tool: + suffix += "Tool"_L1; + break; + case Qt::ToolTip: + suffix += "ToolTip"_L1; + break; + default: + break; + } + + if (style & CS_DROPSHADOW) + suffix += "DropShadow"_L1; + if (style & CS_SAVEBITS) + suffix += "SaveBits"_L1; + if (style & CS_OWNDC) + suffix += "OwnDC"_L1; + if (hasIcon) + suffix += "Icon"_L1; + + return suffix; +} + +bool QWindowsWindowClassDescription::computeHasIcon(Qt::WindowFlags flags, Qt::WindowFlags type) +{ + bool hasIcon = true; + + switch (type) { + case Qt::Tool: + case Qt::ToolTip: + case Qt::Popup: + hasIcon = false; + break; + case Qt::Dialog: + if (!(flags & Qt::WindowSystemMenuHint)) + hasIcon = false; // QTBUG-2027, dialogs without system menu. + break; + } + + return hasIcon; +} + QWindowsWindowClassDescription QWindowsWindowClassDescription::fromName(QString name, WNDPROC procedure) { return { std::move(name), procedure }; @@ -27,7 +76,7 @@ QWindowsWindowClassDescription QWindowsWindowClassDescription::fromWindow(const const Qt::WindowFlags type = flags & Qt::WindowType_Mask; // Determine style and icon. description.style = CS_DBLCLKS; - description.hasIcon = true; + description.hasIcon = computeHasIcon(flags, type); // The following will not set CS_OWNDC for any widget window, even if it contains a // QOpenGLWidget or QQuickWidget later on. That cannot be detected at this stage. if (window->surfaceType() == QSurface::OpenGLSurface || (flags & Qt::MSWindowsOwnDC)) @@ -41,36 +90,9 @@ QWindowsWindowClassDescription QWindowsWindowClassDescription::fromWindow(const case Qt::ToolTip: case Qt::Popup: description.style |= CS_SAVEBITS; // Save/restore background - description.hasIcon = false; - break; - case Qt::Dialog: - if (!(flags & Qt::WindowSystemMenuHint)) - description.hasIcon = false; // QTBUG-2027, dialogs without system menu. - break; - } - // Create a unique name for the flag combination - description.name = "QWindow"_L1; - switch (type) { - case Qt::Tool: - description.name += "Tool"_L1; - break; - case Qt::ToolTip: - description.name += "ToolTip"_L1; - break; - case Qt::Popup: - description.name += "Popup"_L1; - break; - default: break; } - if (description.style & CS_DROPSHADOW) - description.name += "DropShadow"_L1; - if (description.style & CS_SAVEBITS) - description.name += "SaveBits"_L1; - if (description.style & CS_OWNDC) - description.name += "OwnDC"_L1; - if (description.hasIcon) - description.name += "Icon"_L1; + description.name = "QWindow"_L1 + classNameSuffix(type, description.style, description.hasIcon); return description; } |
