diff options
| -rw-r--r-- | src/corelib/tools/qflatmap_p.h | 29 | ||||
| -rw-r--r-- | src/gui/text/qfont.cpp | 2 | ||||
| -rw-r--r-- | src/plugins/platforms/windows/qwindowswindowclassdescription.cpp | 74 | ||||
| -rw-r--r-- | src/plugins/platforms/windows/qwindowswindowclassdescription.h | 12 |
4 files changed, 66 insertions, 51 deletions
diff --git a/src/corelib/tools/qflatmap_p.h b/src/corelib/tools/qflatmap_p.h index 50b7c6bd310..5a827fb4148 100644 --- a/src/corelib/tools/qflatmap_p.h +++ b/src/corelib/tools/qflatmap_p.h @@ -15,6 +15,7 @@ // We mean it. // +#include <QtCore/qcontainertools_impl.h> #include "qlist.h" #include <QtCore/qtclasshelpermacros.h> #include "private/qglobal_p.h" @@ -70,35 +71,11 @@ public: } }; -namespace qflatmap { -namespace detail { -template <class T> -class QFlatMapMockPointer -{ - T ref; -public: - QFlatMapMockPointer(T r) - : ref(r) - { - } - - T *operator->() - { - return &ref; - } -}; -} // namespace detail -} // namespace qflatmap - template<class Key, class T, class Compare = std::less<Key>, class KeyContainer = QList<Key>, class MappedContainer = QList<T>> class QFlatMap : private QFlatMapValueCompare<Key, T, Compare> { static_assert(std::is_nothrow_destructible_v<T>, "Types with throwing destructors are not supported in Qt containers."); - - template<class U> - using mock_pointer = qflatmap::detail::QFlatMapMockPointer<U>; - public: using key_type = Key; using mapped_type = T; @@ -121,7 +98,7 @@ public: using difference_type = ptrdiff_t; using value_type = std::pair<const Key, T>; using reference = std::pair<const Key &, T &>; - using pointer = mock_pointer<reference>; + using pointer = QtPrivate::ArrowProxy<reference>; using iterator_category = std::random_access_iterator_tag; iterator() = default; @@ -253,7 +230,7 @@ public: using difference_type = ptrdiff_t; using value_type = std::pair<const Key, const T>; using reference = std::pair<const Key &, const T &>; - using pointer = mock_pointer<reference>; + using pointer = QtPrivate::ArrowProxy<reference>; using iterator_category = std::random_access_iterator_tag; const_iterator() = default; diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index b60cad34a8d..2b2f2a27fcd 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2201,7 +2201,7 @@ QString QFont::toString() const fontDescription += comma + QString::number(sortedFeatures.size()); for (const auto &[tag, value] : std::as_const(sortedFeatures).asKeyValueRange()) - fontDescription += comma + tag.toString() + u'=' + QString::number(value); + fontDescription += comma + QLatin1StringView{tag.toString()} + u'=' + QString::number(value); return fontDescription; } diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp index abd6f02fb0b..6962d28e7d0 100644 --- a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp +++ b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp @@ -41,43 +41,69 @@ QString QWindowsWindowClassDescription::classNameSuffix(Qt::WindowFlags type, un return suffix; } -QWindowsWindowClassDescription QWindowsWindowClassDescription::fromName(QString name, WNDPROC procedure) +bool QWindowsWindowClassDescription::computeHasIcon(Qt::WindowFlags flags, Qt::WindowFlags type) { - return { std::move(name), procedure }; + 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::fromWindow(const QWindow *window, WNDPROC procedure) +unsigned int QWindowsWindowClassDescription::computeWindowStyles(Qt::WindowFlags flags, Qt::WindowFlags type, WindowStyleOptions options) { - Q_ASSERT(window); + unsigned int style = CS_DBLCLKS; - QWindowsWindowClassDescription description; - description.procedure = procedure; - - const Qt::WindowFlags flags = window->flags(); - const Qt::WindowFlags type = flags & Qt::WindowType_Mask; - // Determine style and icon. - description.style = CS_DBLCLKS; - description.hasIcon = true; // 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)) - description.style |= CS_OWNDC; - if (!(flags & Qt::NoDropShadowWindowHint) - && (type == Qt::Popup || window->property("_q_windowsDropShadow").toBool())) { - description.style |= CS_DROPSHADOW; - } + if (options.testFlag(WindowStyleOption::GLSurface) || (flags & Qt::MSWindowsOwnDC)) + style |= CS_OWNDC; + if (!(flags & Qt::NoDropShadowWindowHint) && (type == Qt::Popup || options.testFlag(WindowStyleOption::DropShadow))) + style |= CS_DROPSHADOW; + switch (type) { case Qt::Tool: 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. + style |= CS_SAVEBITS; // Save/restore background break; } + + return style; +} + +QWindowsWindowClassDescription QWindowsWindowClassDescription::fromName(QString name, WNDPROC procedure) +{ + return { std::move(name), procedure }; +} + +QWindowsWindowClassDescription QWindowsWindowClassDescription::fromWindow(const QWindow *window, WNDPROC procedure) +{ + Q_ASSERT(window); + + const Qt::WindowFlags flags = window->flags(); + const Qt::WindowFlags type = flags & Qt::WindowType_Mask; + + WindowStyleOptions options = WindowStyleOption::None; + if (window->surfaceType() == QSurface::OpenGLSurface) + options |= WindowStyleOption::GLSurface; + if (window->property("_q_windowsDropShadow").toBool()) + options |= WindowStyleOption::DropShadow; + + QWindowsWindowClassDescription description; + description.procedure = procedure; + description.style = computeWindowStyles(flags, type, options); + description.hasIcon = computeHasIcon(flags, type); description.name = "QWindow"_L1 + classNameSuffix(type, description.style, description.hasIcon); return description; diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.h b/src/plugins/platforms/windows/qwindowswindowclassdescription.h index 692bf18e618..f0019f8f3c2 100644 --- a/src/plugins/platforms/windows/qwindowswindowclassdescription.h +++ b/src/plugins/platforms/windows/qwindowswindowclassdescription.h @@ -14,6 +14,14 @@ class QWindow; struct QWindowsWindowClassDescription { + enum class WindowStyleOption + { + None = 0x00, + GLSurface = 0x01, + DropShadow = 0x02 + }; + Q_DECLARE_FLAGS(WindowStyleOptions, WindowStyleOption) + static QWindowsWindowClassDescription fromName(QString name, WNDPROC procedure); static QWindowsWindowClassDescription fromWindow(const QWindow *window, WNDPROC procedure); @@ -26,10 +34,14 @@ struct QWindowsWindowClassDescription private: static QString classNameSuffix(Qt::WindowFlags type, unsigned int style, bool hasIcon); + static bool computeHasIcon(Qt::WindowFlags flags, Qt::WindowFlags type); + static unsigned int computeWindowStyles(Qt::WindowFlags flags, Qt::WindowFlags type, WindowStyleOptions options); friend QDebug operator<<(QDebug dbg, const QWindowsWindowClassDescription &description); }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowsWindowClassDescription::WindowStyleOptions) + QT_END_NAMESPACE #endif // QWINDOWSWINDOWCLASSDESCRIPTION_H |
