Windows11Style: replace QObject::inherits() with qobject_cast<>
Use qobject_cast<QComboBoxPrivateContainer *> instead QObject::inherits() as this should be slightly faster and we have access to the type so no need to use error-prone string comparison. Task-number: QTBUG-135340 Change-Id: I90ebb2323f21c2f5f9dd65bd7b1beeb32f1a91cc Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io> (cherry picked from commit 7fdf7ad7e578675b32deb399b51ec6392c66cb2d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 7d04246b95d21f38a92522747bbb73db98330537)
This commit is contained in:
parent
4ca3bcd1d2
commit
cbb7ad824b
@ -7,6 +7,7 @@
|
||||
#include <private/qstyle_p.h>
|
||||
#include <private/qstylehelper_p.h>
|
||||
#include <private/qapplication_p.h>
|
||||
#include <private/qcombobox_p.h>
|
||||
#include <qstyleoption.h>
|
||||
#include <qpainter.h>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
@ -975,7 +976,7 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
|
||||
if (frame->frameShape == QFrame::NoFrame)
|
||||
break;
|
||||
QRectF rect = option->rect.adjusted(1,1,-1,-1);
|
||||
if (widget && widget->inherits("QComboBoxPrivateContainer")) {
|
||||
if (qobject_cast<const QComboBoxPrivateContainer *>(widget)) {
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(WINUI3Colors[colorSchemeIndex][menuPanelFill]);
|
||||
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||
@ -1811,8 +1812,7 @@ QRect QWindows11Style::subElementRect(QStyle::SubElement element, const QStyleOp
|
||||
if (const auto *item = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
|
||||
const int decorationOffset = item->features.testFlag(QStyleOptionViewItem::HasDecoration) ? item->decorationSize.width() : 0;
|
||||
const int checkboxOffset = item->features.testFlag(QStyleOptionViewItem::HasCheckIndicator) ? 16 : 0;
|
||||
if (widget && widget->parentWidget()
|
||||
&& widget->parentWidget()->inherits("QComboBoxPrivateContainer")) {
|
||||
if (widget && qobject_cast<QComboBoxPrivateContainer *>(widget->parentWidget())) {
|
||||
if (option->direction == Qt::LeftToRight)
|
||||
ret = option->rect.adjusted(decorationOffset + checkboxOffset + 5, 0, -5, 0);
|
||||
else
|
||||
@ -2155,7 +2155,8 @@ void QWindows11Style::polish(QWidget* widget)
|
||||
if (!qobject_cast<QCommandLinkButton *>(widget))
|
||||
QWindowsVistaStyle::polish(widget);
|
||||
const bool isScrollBar = qobject_cast<QScrollBar *>(widget);
|
||||
if (isScrollBar || qobject_cast<QMenu *>(widget) || widget->inherits("QComboBoxPrivateContainer")) {
|
||||
const auto comboBoxContainer = qobject_cast<const QComboBoxPrivateContainer *>(widget);
|
||||
if (isScrollBar || qobject_cast<QMenu *>(widget) || comboBoxContainer) {
|
||||
bool wasCreated = widget->testAttribute(Qt::WA_WState_Created);
|
||||
bool layoutDirection = widget->testAttribute(Qt::WA_RightToLeft);
|
||||
widget->setAttribute(Qt::WA_OpaquePaintEvent,false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user