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. Pick-to: 6.9 6.8 Task-number: QTBUG-135340 Change-Id: I90ebb2323f21c2f5f9dd65bd7b1beeb32f1a91cc Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
This commit is contained in:
parent
101427957b
commit
7fdf7ad7e5
@ -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>
|
||||
@ -978,7 +979,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);
|
||||
@ -1853,8 +1854,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
|
||||
@ -2197,7 +2197,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