diff --git a/plugin/kquickstyleitem.cpp b/plugin/kquickstyleitem.cpp --- a/plugin/kquickstyleitem.cpp +++ b/plugin/kquickstyleitem.cpp @@ -89,7 +89,10 @@ m_textureHeight(0), m_lastFocusReason(Qt::NoFocusReason) { - if (!qApp->style()) { + // There is no styleChanged signal and QApplication sends QEvent::StyleChange only to all QWidgets + if (qApp->style()) { + connect(qApp->style(), &QObject::destroyed, this, &KQuickStyleItem::styleChanged); + } else { KSharedConfig::Ptr kdeglobals = KSharedConfig::openConfig(); KConfigGroup cg(kdeglobals, "KDE"); auto style = s_style; @@ -1686,9 +1689,6 @@ polish(); } return true; - } else if (ev->type() == QEvent::StyleChange) { - if (m_itemType == ScrollBar) - initStyleOption(); } return QQuickItem::event(ev); } @@ -1818,6 +1818,20 @@ return QQuickItem::eventFilter(watched, event); } +void KQuickStyleItem::styleChanged() +{ + Q_ASSERT(qApp->style() != sender()); + + if (!qApp->style() || QApplication::closingDown()) { + return; + } + + connect(qApp->style(), &QObject::destroyed, this, &KQuickStyleItem::styleChanged); + + updateSizeHint(); + updateItem(); +} + QPixmap QQuickTableRowImageProvider1::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) { Q_UNUSED (requestedSize); diff --git a/plugin/kquickstyleitem_p.h b/plugin/kquickstyleitem_p.h --- a/plugin/kquickstyleitem_p.h +++ b/plugin/kquickstyleitem_p.h @@ -83,7 +83,7 @@ Q_PROPERTY( QString elementType READ elementType WRITE setElementType NOTIFY elementTypeChanged) Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY( QString activeControl READ activeControl WRITE setActiveControl NOTIFY activeControlChanged) - Q_PROPERTY( QString styleName READ styleName NOTIFY styleChanged) + Q_PROPERTY( QString styleName READ styleName NOTIFY styleNameChanged) Q_PROPERTY( QVariantMap hints READ hints WRITE setHints NOTIFY hintChanged RESET resetHints) Q_PROPERTY( QVariantMap properties READ properties WRITE setProperties NOTIFY propertiesChanged) Q_PROPERTY( QFont font READ font NOTIFY fontChanged) @@ -262,7 +262,7 @@ void valueChanged(); void activeControlChanged(); void infoChanged(); - void styleChanged(); + void styleNameChanged(); void paintMarginsChanged(); void hintChanged(); void propertiesChanged(); @@ -290,6 +290,7 @@ const char* classNameForItem() const; QSize sizeFromContents(int width, int height); qreal baselineOffset(); + void styleChanged(); protected: Kirigami::PlatformTheme *m_theme = nullptr;