summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/io/qdirlisting.h10
-rw-r--r--src/corelib/kernel/qassociativeiterable.cpp6
-rw-r--r--src/corelib/kernel/qiterable.cpp13
-rw-r--r--src/corelib/kernel/qiterable.h20
-rw-r--r--src/corelib/kernel/qiterable_impl.h4
-rw-r--r--src/corelib/kernel/qmetaassociation.h10
-rw-r--r--src/corelib/kernel/qmetasequence.h8
-rw-r--r--src/corelib/kernel/qmetatype.cpp16
-rw-r--r--src/corelib/kernel/qsequentialiterable.cpp2
-rw-r--r--src/plugins/styles/modernwindows/CMakeLists.txt1
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style.cpp111
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style_p.h8
-rw-r--r--src/plugins/styles/modernwindows/qwindowsvistastyle.cpp5
-rw-r--r--src/plugins/styles/modernwindows/qwindowsvistastyle_p.h1
14 files changed, 168 insertions, 47 deletions
diff --git a/src/corelib/io/qdirlisting.h b/src/corelib/io/qdirlisting.h
index 73a13ed611f..94aec0934fb 100644
--- a/src/corelib/io/qdirlisting.h
+++ b/src/corelib/io/qdirlisting.h
@@ -20,6 +20,7 @@ QT_BEGIN_NAMESPACE
class QDirListingPrivate;
class QFileInfo;
+class QDebug;
class QDir;
class QTimeZone;
@@ -150,6 +151,10 @@ public:
const_iterator constBegin() const { return begin(); }
sentinel constEnd() const { return end(); }
+#ifndef QT_NO_DEBUG_STREAM
+ Q_CORE_EXPORT friend QDebug operator<<(QDebug debug, QDirListing::IteratorFlags flags);
+#endif
+
private:
Q_DISABLE_COPY(QDirListing)
@@ -160,11 +165,6 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QDirListing::IteratorFlags)
-#ifndef QT_NO_DEBUG_STREAM
-class QDebug;
-Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDirListing::IteratorFlags flags);
-#endif
-
QT_END_NAMESPACE
#endif // QDIRLISTING_H
diff --git a/src/corelib/kernel/qassociativeiterable.cpp b/src/corelib/kernel/qassociativeiterable.cpp
index 8a2fc63c441..bca9d43901d 100644
--- a/src/corelib/kernel/qassociativeiterable.cpp
+++ b/src/corelib/kernel/qassociativeiterable.cpp
@@ -21,7 +21,7 @@ QT_WARNING_DISABLE_DEPRECATED
*/
QVariant QAssociativeIterator::key() const
{
- return QIterablePrivate::retrieveElement(
+ return QtIterablePrivate::retrieveElement(
metaContainer().keyMetaType(), [this](void *dataPtr) {
metaContainer().keyAtIterator(constIterator(), dataPtr);
});
@@ -67,7 +67,7 @@ QVariantPointer<QAssociativeIterator> QAssociativeIterator::operator->() const
*/
QVariant QAssociativeConstIterator::key() const
{
- return QIterablePrivate::retrieveElement(
+ return QtIterablePrivate::retrieveElement(
metaContainer().keyMetaType(), [this](void *dataPtr) {
metaContainer().keyAtConstIterator(constIterator(), dataPtr);
});
@@ -79,7 +79,7 @@ QVariant QAssociativeConstIterator::key() const
*/
QVariant QAssociativeConstIterator::value() const
{
- return QIterablePrivate::retrieveElement(
+ return QtIterablePrivate::retrieveElement(
metaContainer().mappedMetaType(), [this](void *dataPtr) {
metaContainer().mappedAtConstIterator(constIterator(), dataPtr);
});
diff --git a/src/corelib/kernel/qiterable.cpp b/src/corelib/kernel/qiterable.cpp
index ca2893e1090..b0b772d18e0 100644
--- a/src/corelib/kernel/qiterable.cpp
+++ b/src/corelib/kernel/qiterable.cpp
@@ -626,9 +626,18 @@ Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized"
/*!
\internal
*/
-void QtPrivate::warnSynthesizedAccess(const char *text)
+void QtPrivate::warnSynthesizedIterableAccess(QtPrivate::SynthesizedAccessFunction function)
{
- qCWarning(lcSynthesizedIterableAccess, "%s", text);
+ switch (function) {
+ case QtPrivate::SynthesizedAccessFunction::IterableSize:
+ qCWarning(lcSynthesizedIterableAccess,
+ "size() called on an iterable without native size accessor. This is slow");
+ break;
+ case QtPrivate::SynthesizedAccessFunction::SequenceAt:
+ qCWarning(lcSynthesizedIterableAccess,
+ "at() called on an iterable without native indexed accessors. This is slow");
+ break;
+ }
}
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qiterable.h b/src/corelib/kernel/qiterable.h
index 494cec73a3f..a5a5b35924a 100644
--- a/src/corelib/kernel/qiterable.h
+++ b/src/corelib/kernel/qiterable.h
@@ -8,10 +8,6 @@
#include <QtCore/qtypeinfo.h>
#include <QtCore/qtaggedpointer.h>
-#if !defined(QT_LEAN_HEADERS) || QT_LEAN_HEADERS < 1
-# include <QtCore/qmetacontainer.h>
-#endif
-
QT_BEGIN_NAMESPACE
namespace QtPrivate {
@@ -65,7 +61,13 @@ namespace QtPrivate {
}
};
- Q_CORE_EXPORT void warnSynthesizedAccess(const char *text);
+ enum class SynthesizedAccessFunction: quint8
+ {
+ IterableSize,
+ SequenceAt
+ };
+
+ Q_CORE_EXPORT void warnSynthesizedIterableAccess(SynthesizedAccessFunction function);
}
template<class Iterator, typename IteratorCategory>
@@ -75,7 +77,7 @@ public:
using iterator_category = IteratorCategory;
QTaggedIterator(Iterator &&it) : Iterator(std::move(it))
{
- const auto metaContainer = this->metaContainer();
+ [[maybe_unused]] const auto metaContainer = this->metaContainer();
if constexpr (std::is_base_of_v<std::random_access_iterator_tag, IteratorCategory>) {
if (!metaContainer.hasRandomAccessIterator()) {
qFatal("You cannot use this iterator as a random access iterator");
@@ -103,8 +105,6 @@ public:
this->clearIterator();
}
}
-
- Q_UNUSED(metaContainer); // in case none of the above apply
}
bool operator==(const QTaggedIterator &o) const { return Iterator::operator==(o); }
@@ -506,8 +506,8 @@ public:
// We shouldn't second-guess the underlying container, so we're not synthesizing a size.
return -1;
#else
- QtPrivate::warnSynthesizedAccess(
- "size() called on an iterable without native size accessor. This is slow");
+ QtPrivate::warnSynthesizedIterableAccess(
+ QtPrivate::SynthesizedAccessFunction::IterableSize);
if (!m_metaContainer.hasConstIterator())
return -1;
diff --git a/src/corelib/kernel/qiterable_impl.h b/src/corelib/kernel/qiterable_impl.h
index 7bc06ccde15..419595a3f2c 100644
--- a/src/corelib/kernel/qiterable_impl.h
+++ b/src/corelib/kernel/qiterable_impl.h
@@ -9,7 +9,7 @@
QT_BEGIN_NAMESPACE
-namespace QIterablePrivate {
+namespace QtIterablePrivate {
template<typename Callback>
static QVariant retrieveElement(QMetaType type, Callback callback)
@@ -24,7 +24,7 @@ static QVariant retrieveElement(QMetaType type, Callback callback)
return v;
}
-} // namespace QIterablePrivate
+} // namespace QtIterablePrivate
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qmetaassociation.h b/src/corelib/kernel/qmetaassociation.h
index d481ae91079..d94b5191a7b 100644
--- a/src/corelib/kernel/qmetaassociation.h
+++ b/src/corelib/kernel/qmetaassociation.h
@@ -33,7 +33,7 @@ public:
key_type key() const
{
const QMetaAssociation meta = metaContainer();
- return QIterablePrivate::retrieveElement(meta.keyMetaType(), [&](void *dataPtr) {
+ return QtIterablePrivate::retrieveElement(meta.keyMetaType(), [&](void *dataPtr) {
meta.keyAtIterator(constIterator(), dataPtr);
});
}
@@ -58,7 +58,7 @@ public:
key_type key() const
{
const QMetaAssociation meta = metaContainer();
- return QIterablePrivate::retrieveElement(meta.keyMetaType(), [&](void *dataPtr) {
+ return QtIterablePrivate::retrieveElement(meta.keyMetaType(), [&](void *dataPtr) {
meta.keyAtConstIterator(constIterator(), dataPtr);
});
}
@@ -79,12 +79,12 @@ QVariant associativeIteratorToVariant(const Referred &referred)
const auto metaAssociation = referred.metaContainer();
const QMetaType metaType(metaAssociation.mappedMetaType());
if (metaType.isValid(QT6_CALL_NEW_OVERLOAD)) {
- return QIterablePrivate::retrieveElement(metaType, [&](void *dataPtr) {
+ return QtIterablePrivate::retrieveElement(metaType, [&](void *dataPtr) {
metaAssociation.mappedAtConstIterator(referred.constIterator(), dataPtr);
});
}
- return QIterablePrivate::retrieveElement(metaType, [&](void *dataPtr) {
+ return QtIterablePrivate::retrieveElement(metaType, [&](void *dataPtr) {
metaAssociation.keyAtConstIterator(referred.constIterator(), dataPtr);
});
}
@@ -243,7 +243,7 @@ public:
QVariant value(const QVariant &key) const
{
const QMetaAssociation meta = metaContainer();
- return QIterablePrivate::retrieveElement(meta.mappedMetaType(), [&](void *dataPtr) {
+ return QtIterablePrivate::retrieveElement(meta.mappedMetaType(), [&](void *dataPtr) {
QtPrivate::QVariantTypeCoercer coercer;
meta.mappedAtKey(constIterable(), coercer.coerce(key, meta.keyMetaType()), dataPtr);
});
diff --git a/src/corelib/kernel/qmetasequence.h b/src/corelib/kernel/qmetasequence.h
index f8052476d79..792202301e3 100644
--- a/src/corelib/kernel/qmetasequence.h
+++ b/src/corelib/kernel/qmetasequence.h
@@ -57,7 +57,7 @@ template<typename Referred>
QVariant sequentialIteratorToVariant(const Referred &referred)
{
const auto metaSequence = referred.metaContainer();
- return QIterablePrivate::retrieveElement(metaSequence.valueMetaType(), [&](void *dataPtr) {
+ return QtIterablePrivate::retrieveElement(metaSequence.valueMetaType(), [&](void *dataPtr) {
metaSequence.valueAtConstIterator(referred.constIterator(), dataPtr);
});
}
@@ -178,7 +178,7 @@ public:
QVariant at(qsizetype idx) const
{
const QMetaSequence meta = metaContainer();
- return QIterablePrivate::retrieveElement(meta.valueMetaType(), [&](void *dataPtr) {
+ return QtIterablePrivate::retrieveElement(meta.valueMetaType(), [&](void *dataPtr) {
if (meta.canGetValueAtIndex()) {
meta.valueAtIndex(constIterable(), idx, dataPtr);
return;
@@ -186,8 +186,8 @@ public:
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
// We shouldn't second-guess the underlying container.
- QtPrivate::warnSynthesizedAccess(
- "at() called on an iterable without native indexed accessors. This is slow");
+ QtPrivate::warnSynthesizedIterableAccess(
+ QtPrivate::SynthesizedAccessFunction::SequenceAt);
void *it = meta.constBegin(m_iterable.constPointer());
meta.advanceConstIterator(it, idx);
meta.valueAtConstIterator(it, dataPtr);
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 565f9182e68..580e830782e 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -2524,7 +2524,7 @@ bool QMetaType::convert(QMetaType fromType, const void *from, QMetaType toType,
if (toTypeId == qMetaTypeId<QMetaAssociation::Iterable>())
return convertToAssociativeIterable<QMetaAssociation::Iterable>(fromType, from, to);
-#if QT_DEPRECATED_SINCE(6, 13)
+#if QT_DEPRECATED_SINCE(6, 15)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
@@ -2550,7 +2550,7 @@ bool QMetaType::convert(QMetaType fromType, const void *from, QMetaType toType,
return convertToAssociativeIterable<QAssociativeIterable>(fromType, from, to);
QT_WARNING_POP
-#endif // QT_DEPRECATED_SINCE(6, 13)
+#endif // QT_DEPRECATED_SINCE(6, 15)
return convertMetaObject(fromType, from, toType, to);
}
@@ -2578,7 +2578,7 @@ bool QMetaType::view(QMetaType fromType, void *from, QMetaType toType, void *to)
if (toTypeId == qMetaTypeId<QMetaAssociation::Iterable>())
return viewAsAssociativeIterable<QMetaAssociation::Iterable>(fromType, from, to);
-#if QT_DEPRECATED_SINCE(6, 13)
+#if QT_DEPRECATED_SINCE(6, 15)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
@@ -2589,7 +2589,7 @@ bool QMetaType::view(QMetaType fromType, void *from, QMetaType toType, void *to)
return viewAsAssociativeIterable<QAssociativeIterable>(fromType, from, to);
QT_WARNING_POP
-#endif // QT_DEPRECATED_SINCE(6, 13)
+#endif // QT_DEPRECATED_SINCE(6, 15)
return convertMetaObject(fromType, from, toType, to);
}
@@ -2629,7 +2629,7 @@ bool QMetaType::canView(QMetaType fromType, QMetaType toType)
if (toTypeId == qMetaTypeId<QMetaAssociation::Iterable>())
return canImplicitlyViewAsAssociativeIterable(fromType);
-#if QT_DEPRECATED_SINCE(6, 13)
+#if QT_DEPRECATED_SINCE(6, 15)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
@@ -2640,7 +2640,7 @@ bool QMetaType::canView(QMetaType fromType, QMetaType toType)
return canImplicitlyViewAsAssociativeIterable(fromType);
QT_WARNING_POP
-#endif
+#endif // QT_DEPRECATED_SINCE(6, 15)
if (canConvertMetaObject(fromType, toType))
return true;
@@ -2768,7 +2768,7 @@ bool QMetaType::canConvert(QMetaType fromType, QMetaType toType)
return true;
}
-#if QT_DEPRECATED_SINCE(6, 13)
+#if QT_DEPRECATED_SINCE(6, 15)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
@@ -2789,7 +2789,7 @@ bool QMetaType::canConvert(QMetaType fromType, QMetaType toType)
}
QT_WARNING_POP
-#endif // QT_DEPRECATED_SINCE(6, 13)
+#endif // QT_DEPRECATED_SINCE(6, 15)
if (toTypeId == QVariantPair && hasRegisteredConverterFunction(
fromType, QMetaType::fromType<QtMetaTypePrivate::QPairVariantInterfaceImpl>()))
diff --git a/src/corelib/kernel/qsequentialiterable.cpp b/src/corelib/kernel/qsequentialiterable.cpp
index b256b129d2c..cf9c38c5338 100644
--- a/src/corelib/kernel/qsequentialiterable.cpp
+++ b/src/corelib/kernel/qsequentialiterable.cpp
@@ -211,7 +211,7 @@ QVariantPointer<QSequentialIterator> QSequentialIterator::operator->() const
*/
QVariant QSequentialConstIterator::operator*() const
{
- return QIterablePrivate::retrieveElement(metaContainer().valueMetaType(), [this](void *dataPtr) {
+ return QtIterablePrivate::retrieveElement(metaContainer().valueMetaType(), [this](void *dataPtr) {
metaContainer().valueAtConstIterator(constIterator(), dataPtr);
});
}
diff --git a/src/plugins/styles/modernwindows/CMakeLists.txt b/src/plugins/styles/modernwindows/CMakeLists.txt
index 985bce3a2d6..41d2797f2a2 100644
--- a/src/plugins/styles/modernwindows/CMakeLists.txt
+++ b/src/plugins/styles/modernwindows/CMakeLists.txt
@@ -17,6 +17,7 @@ qt_internal_add_plugin(QModernWindowsStylePlugin
qwindowsthemedata.cpp qwindowsthemedata_p.h
LIBRARIES
+ dwmapi
gdi32
user32
uxtheme
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp
index 98e51397c17..5e5b764311b 100644
--- a/src/plugins/styles/modernwindows/qwindows11style.cpp
+++ b/src/plugins/styles/modernwindows/qwindows11style.cpp
@@ -14,6 +14,7 @@
#include <qpainterstateguard.h>
#include <QGraphicsDropShadowEffect>
#include <QLatin1StringView>
+#include <QtCore/qoperatingsystemversion.h>
#include <QtWidgets/qcombobox.h>
#if QT_CONFIG(commandlinkbutton)
#include <QtWidgets/qcommandlinkbutton.h>
@@ -36,8 +37,12 @@
#if QT_CONFIG(menubar)
# include <QtWidgets/qmenubar.h>
#endif
+#if QT_CONFIG(tooltip)
+#include "private/qtooltip_p.h"
+#endif
#include "qdrawutil.h"
#include <chrono>
+#include <dwmapi.h>
QT_BEGIN_NAMESPACE
@@ -47,6 +52,8 @@ static constexpr int topLevelRoundingRadius = 8; //Radius for toplevel items
static constexpr int secondLevelRoundingRadius = 4; //Radius for second level items like hovered menu item round corners
static constexpr int contentItemHMargin = 4; // margin between content items (e.g. text and icon)
static constexpr int contentHMargin = 2 * 3; // margin between rounded border and content (= rounded border margin * 3)
+
+
namespace StyleOptionHelper
{
inline bool isChecked(const QStyleOption *option)
@@ -281,6 +288,11 @@ static qreal sliderInnerRadius(QStyle::State state, bool insideHandle)
\sa QWindows11Style QWindowsVistaStyle, QMacStyle, QFusionStyle
*/
+QWindows11StylePrivate::QWindows11StylePrivate()
+{
+ nativeRoundedTopLevelWindows =
+ QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows11_21H2;
+}
/*!
Constructs a QWindows11Style object.
@@ -991,11 +1003,13 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
case PE_FrameMenu:
break;
case PE_PanelMenu: {
- const QRect rect = option->rect.marginsRemoved(QMargins(2, 2, 2, 2));
- painter->setPen(highContrastTheme ? QPen(option->palette.windowText().color(), 2)
- : winUI3Color(frameColorLight));
- painter->setBrush(winUI3Color(menuPanelFill));
- painter->drawRoundedRect(rect, topLevelRoundingRadius, topLevelRoundingRadius);
+ if (!d->nativeRoundedTopLevelWindows) {
+ const QRect rect = option->rect.marginsRemoved(QMargins(2, 2, 2, 2));
+ painter->setPen(highContrastTheme ? QPen(option->palette.windowText().color(), 2)
+ : winUI3Color(frameColorLight));
+ painter->setBrush(winUI3Color(menuPanelFill));
+ painter->drawRoundedRect(rect, topLevelRoundingRadius, topLevelRoundingRadius);
+ }
break;
}
case PE_PanelLineEdit:
@@ -1027,6 +1041,8 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
if (const auto *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
const auto rect = QRectF(option->rect).marginsRemoved(QMarginsF(1.5, 1.5, 1.5, 1.5));
if (qobject_cast<const QComboBoxPrivateContainer *>(widget)) {
+ if (d->nativeRoundedTopLevelWindows)
+ break;
QPen pen;
if (highContrastTheme)
pen = QPen(option->palette.windowText().color(), 2);
@@ -2412,6 +2428,8 @@ int QWindows11Style::pixelMetric(PixelMetric metric, const QStyleOption *option,
void QWindows11Style::polish(QWidget* widget)
{
+ Q_D(QWindows11Style);
+
#if QT_CONFIG(commandlinkbutton)
if (!qobject_cast<QCommandLinkButton *>(widget))
#endif // QT_CONFIG(commandlinkbutton)
@@ -2419,6 +2437,9 @@ void QWindows11Style::polish(QWidget* widget)
const bool isScrollBar = qobject_cast<QScrollBar *>(widget);
const auto comboBoxContainer = qobject_cast<const QComboBoxPrivateContainer *>(widget);
+ const auto isComboBoxContainer = !d->nativeRoundedTopLevelWindows && comboBoxContainer != nullptr;
+ const auto isMenu = !d->nativeRoundedTopLevelWindows && qobject_cast<QMenu *>(widget) != nullptr;
+
#if QT_CONFIG(menubar)
if (qobject_cast<QMenuBar *>(widget)) {
constexpr int itemHeight = 32;
@@ -2428,7 +2449,12 @@ void QWindows11Style::polish(QWidget* widget)
}
}
#endif
- if (isScrollBar || qobject_cast<QMenu *>(widget) || comboBoxContainer) {
+ if (comboBoxContainer && d->nativeRoundedTopLevelWindows) {
+ auto view = comboBoxContainer->itemView();
+ if (view && view->viewport())
+ view->viewport()->setAutoFillBackground(false);
+ }
+ if (isScrollBar || isMenu || isComboBoxContainer) {
bool wasCreated = widget->testAttribute(Qt::WA_WState_Created);
bool layoutDirection = widget->testAttribute(Qt::WA_RightToLeft);
widget->setAttribute(Qt::WA_OpaquePaintEvent,false);
@@ -2479,6 +2505,7 @@ void QWindows11Style::polish(QWidget* widget)
void QWindows11Style::unpolish(QWidget *widget)
{
+ Q_D(QWindows11Style);
#if QT_CONFIG(commandlinkbutton)
if (!qobject_cast<QCommandLinkButton *>(widget))
#endif // QT_CONFIG(commandlinkbutton)
@@ -2490,8 +2517,18 @@ void QWindows11Style::unpolish(QWidget *widget)
widget->setProperty("_q_original_menubar_maxheight", QVariant());
}
#endif
+ const bool isScrollBar = qobject_cast<QScrollBar *>(widget);
const auto comboBoxContainer = qobject_cast<const QComboBoxPrivateContainer *>(widget);
- if (comboBoxContainer) {
+ const auto isComboBoxContainer = !d->nativeRoundedTopLevelWindows && comboBoxContainer != nullptr;
+ const auto isMenu = !d->nativeRoundedTopLevelWindows && qobject_cast<QMenu *>(widget) != nullptr;
+
+ if (comboBoxContainer && d->nativeRoundedTopLevelWindows) {
+ auto view = comboBoxContainer->itemView();
+ // see QAbstractScrollAreaPrivate::init()
+ if (view && view->viewport())
+ view->viewport()->setAutoFillBackground(true);
+ }
+ if (isScrollBar || isMenu || isComboBoxContainer) {
widget->setAttribute(Qt::WA_OpaquePaintEvent, true);
widget->setAttribute(Qt::WA_TranslucentBackground, false);
widget->setWindowFlag(Qt::FramelessWindowHint, false);
@@ -2512,6 +2549,66 @@ void QWindows11Style::unpolish(QWidget *widget)
vp->setAttribute(Qt::WA_StyledBackground, origStyledBackground);
vp->setProperty("_q_original_styled_background", QVariant());
}
+ dwmSetWindowCornerPreference(widget, false);
+}
+
+void QWindows11Style::polish(QApplication *app)
+{
+ Q_D(const QWindows11Style);
+ if (d->nativeRoundedTopLevelWindows)
+ app->installEventFilter(this);
+ QWindowsVistaStyle::polish(app);
+}
+
+void QWindows11Style::unpolish(QApplication *app)
+{
+ Q_D(const QWindows11Style);
+ if (d->nativeRoundedTopLevelWindows)
+ app->removeEventFilter(this);
+ QWindowsVistaStyle::unpolish(app);
+}
+
+bool QWindows11Style::eventFilter(QObject *obj, QEvent *event)
+{
+ // QEvent::WinIdChange is to early so we have to wait for QEvent::Show
+ if (event->type() == QEvent::Show)
+ dwmSetWindowCornerPreference(qobject_cast<QWidget *>(obj), true);
+ return QWindowsVistaStyle::eventFilter(obj, event);
+}
+
+void QWindows11Style::dwmSetWindowCornerPreference(const QWidget *widget, bool bSet) const
+{
+ Q_D(const QWindows11Style);
+ if (!d->nativeRoundedTopLevelWindows)
+ return;
+#ifdef Q_CC_MSVC
+ static constexpr auto dmwmaWindowCornerPreference = DWMWA_WINDOW_CORNER_PREFERENCE;
+ static constexpr auto dwmcpRound = DWMWCP_ROUND;
+ static constexpr auto dwmcpRoundSmall = DWMWCP_ROUNDSMALL;
+ static constexpr auto dwmcpDefault = DWMWCP_DEFAULT;
+#else
+ // MinGW 13.1.0 does not provide this
+ static constexpr auto dmwmaWindowCornerPreference = 33;
+ static constexpr auto dwmcpRound = 2;
+ static constexpr auto dwmcpRoundSmall = 3;
+ static constexpr auto dwmcpDefault = 0;
+#endif
+ if (widget && widget->isWindow() && widget->testAttribute(Qt::WA_WState_Created)) {
+ const auto window = widget->windowHandle();
+ if (window && window->handle()) {
+ const auto wId = reinterpret_cast<HWND>(widget->winId());
+ if (wId != 0) {
+ const bool isToolTip =
+#if QT_CONFIG(tooltip)
+ qobject_cast<const QTipLabel *>(widget) != nullptr;
+#else
+ false;
+#endif
+ uint32_t pref = bSet ? (isToolTip ? dwmcpRoundSmall : dwmcpRound) : dwmcpDefault;
+ DwmSetWindowAttribute(wId, dmwmaWindowCornerPreference, &pref, sizeof(pref));
+ }
+ }
+ }
}
/*
diff --git a/src/plugins/styles/modernwindows/qwindows11style_p.h b/src/plugins/styles/modernwindows/qwindows11style_p.h
index 43a344a6ac9..cbe3a252946 100644
--- a/src/plugins/styles/modernwindows/qwindows11style_p.h
+++ b/src/plugins/styles/modernwindows/qwindows11style_p.h
@@ -90,10 +90,15 @@ public:
const QWidget *widget = nullptr) const override;
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr,
const QWidget *widget = nullptr) const override;
+ void polish(QApplication *app) override;
+ void unpolish(QApplication *app) override;
+ bool eventFilter(QObject *obj, QEvent *event) override;
+
protected:
QWindows11Style(QWindows11StylePrivate &dd);
private:
+ void dwmSetWindowCornerPreference(const QWidget *widget, bool bSet) const;
QColor calculateAccentColor(const QStyleOption *option) const;
QPen borderPenControlAlt(const QStyleOption *option) const;
enum class ControlType
@@ -122,10 +127,13 @@ private:
class QWindows11StylePrivate : public QWindowsVistaStylePrivate {
Q_DECLARE_PUBLIC(QWindows11Style)
+ QWindows11StylePrivate();
+
protected:
QIcon m_toolbarExtensionButton;
QIcon m_lineEditClearButton;
QIcon m_tabCloseButton;
+ bool nativeRoundedTopLevelWindows;
};
QT_END_NAMESPACE
diff --git a/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp b/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp
index 36b5d0f0143..9330106f541 100644
--- a/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp
+++ b/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp
@@ -4860,6 +4860,11 @@ void QWindowsVistaStyle::polish(QApplication *app)
QWindowsStyle::polish(app);
}
+void QWindowsVistaStyle::unpolish(QApplication *app)
+{
+ QWindowsStyle::unpolish(app);
+}
+
/*!
\internal
*/
diff --git a/src/plugins/styles/modernwindows/qwindowsvistastyle_p.h b/src/plugins/styles/modernwindows/qwindowsvistastyle_p.h
index da58e0b0fec..6f9e87307fb 100644
--- a/src/plugins/styles/modernwindows/qwindowsvistastyle_p.h
+++ b/src/plugins/styles/modernwindows/qwindowsvistastyle_p.h
@@ -60,6 +60,7 @@ public:
void unpolish(QWidget *widget) override;
void polish(QPalette &pal) override;
void polish(QApplication *app) override;
+ void unpolish(QApplication *app) override;
protected:
QWindowsVistaStyle(QWindowsVistaStylePrivate &dd);
private: