summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorPavel Dubsky <[email protected]>2025-11-20 18:34:11 +0100
committerPavel Dubsky <[email protected]>2025-11-29 01:36:36 +0100
commit1bd59107e35b972348c84ea428a5716ec8b5eacd (patch)
tree6993352e10f5226d75c89b38891dc901aca562f9 /src/plugins
parentfa851e768872c08c177db019931a2df0b8f74c65 (diff)
Move hasIcon logic into computeHasIcon helper
Introduced computeHasIcon to centralize logic determining whether a window class should include an icon, based on window type and flags. Change-Id: I4702bbb0833e90163382fb318f990c79fc0f93f5 Reviewed-by: Volker Hilsheimer <[email protected]>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassdescription.cpp26
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassdescription.h1
2 files changed, 21 insertions, 6 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
index abd6f02fb0b..55e36b4587a 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
+++ b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
@@ -41,6 +41,25 @@ QString QWindowsWindowClassDescription::classNameSuffix(Qt::WindowFlags type, un
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 };
@@ -57,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))
@@ -71,11 +90,6 @@ 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;
}
description.name = "QWindow"_L1 + classNameSuffix(type, description.style, description.hasIcon);
diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.h b/src/plugins/platforms/windows/qwindowswindowclassdescription.h
index 692bf18e618..78d99b4c525 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassdescription.h
+++ b/src/plugins/platforms/windows/qwindowswindowclassdescription.h
@@ -26,6 +26,7 @@ struct QWindowsWindowClassDescription
private:
static QString classNameSuffix(Qt::WindowFlags type, unsigned int style, bool hasIcon);
+ static bool computeHasIcon(Qt::WindowFlags flags, Qt::WindowFlags type);
friend QDebug operator<<(QDebug dbg, const QWindowsWindowClassDescription &description);
};