Changeset View
Standalone View
plugin/kquickstyleitem.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
49 | #include <qapplication.h> | 49 | #include <qapplication.h> | ||
50 | #include <qquickwindow.h> | 50 | #include <qquickwindow.h> | ||
51 | #if QT_VERSION >= QT_VERSION_CHECK(5,8,0) | 51 | #if QT_VERSION >= QT_VERSION_CHECK(5,8,0) | ||
52 | #include <QtQuick/qsgninepatchnode.h> | 52 | #include <QtQuick/qsgninepatchnode.h> | ||
53 | #else | 53 | #else | ||
54 | #include "qsgdefaultninepatchnode_p.h" | 54 | #include "qsgdefaultninepatchnode_p.h" | ||
55 | #endif | 55 | #endif | ||
56 | 56 | | |||
57 | #include <Kirigami2/PlatformTheme> | ||||
57 | 58 | | |||
58 | KQuickStyleItem::KQuickStyleItem(QQuickItem *parent) | 59 | KQuickStyleItem::KQuickStyleItem(QQuickItem *parent) | ||
59 | : QQuickItem(parent), | 60 | : QQuickItem(parent), | ||
60 | m_styleoption(0), | 61 | m_styleoption(0), | ||
61 | m_itemType(Undefined), | 62 | m_itemType(Undefined), | ||
62 | m_sunken(false), | 63 | m_sunken(false), | ||
63 | m_raised(false), | 64 | m_raised(false), | ||
64 | m_active(true), | 65 | m_active(true), | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | 125 | { | |||
155 | else | 156 | else | ||
156 | delete m_styleoption; | 157 | delete m_styleoption; | ||
157 | 158 | | |||
158 | m_styleoption = 0; | 159 | m_styleoption = 0; | ||
159 | } | 160 | } | ||
160 | 161 | | |||
161 | void KQuickStyleItem::initStyleOption() | 162 | void KQuickStyleItem::initStyleOption() | ||
162 | { | 163 | { | ||
164 | if (!m_theme) { | ||||
165 | m_theme = static_cast<Kirigami::PlatformTheme *>(qmlAttachedPropertiesObject<Kirigami::PlatformTheme>(this, true)); | ||||
166 | Q_ASSERT(m_theme); | ||||
167 | | ||||
davidedmundson: I don't understand what this is doing? It looks wrong?
| |||||
it's getting (and eventually creating if didn't exist yet) the attached property Kirigami.Theme, which is a subclass of the public symbol PlatformTheme, which is guaranteed to exist at that point mart: it's getting (and eventually creating if didn't exist yet) the attached property Kirigami.Theme… | |||||
I meant specifically the setInherit that's also exposed in QML and you have that being explicitly set there. davidedmundson: I meant specifically the setInherit
that's also exposed in QML and you have that being… | |||||
mart: ouch yeah, that's actually a leftover :) | |||||
168 | connect(m_theme, &Kirigami::PlatformTheme::colorsChanged, this, [this]() { | ||||
169 | //we need to reset the palette event if Qt::AA_SetPalette attribute has been set | ||||
170 | m_styleoption->palette = m_theme->palette(); | ||||
171 | updateItem(); | ||||
172 | }); | ||||
173 | } | ||||
174 | Q_ASSERT(m_theme); | ||||
175 | | ||||
163 | if (m_styleoption) | 176 | if (m_styleoption) | ||
164 | m_styleoption->state = 0; | 177 | m_styleoption->state = 0; | ||
165 | 178 | | |||
166 | QString sizeHint = m_hints.value(QStringLiteral("size")).toString(); | 179 | QString sizeHint = m_hints.value(QStringLiteral("size")).toString(); | ||
167 | 180 | | |||
168 | bool needsResolvePalette = true; | 181 | bool needsResolvePalette = true; | ||
169 | 182 | | |||
170 | switch (m_itemType) { | 183 | switch (m_itemType) { | ||
▲ Show 20 Lines • Show All 518 Lines • ▼ Show 20 Line(s) | 664 | { | |||
689 | Q_UNREACHABLE(); | 702 | Q_UNREACHABLE(); | ||
690 | } | 703 | } | ||
691 | 704 | | |||
692 | void KQuickStyleItem::resolvePalette() | 705 | void KQuickStyleItem::resolvePalette() | ||
693 | { | 706 | { | ||
694 | if (QCoreApplication::testAttribute(Qt::AA_SetPalette)) | 707 | if (QCoreApplication::testAttribute(Qt::AA_SetPalette)) | ||
695 | return; | 708 | return; | ||
696 | 709 | | |||
697 | m_styleoption->palette = QApplication::palette(classNameForItem()); | 710 | m_styleoption->palette = m_theme->palette(); | ||
This area needs some tidying. Also we need this line if the palette isn't explicitly set to something else. davidedmundson: This area needs some tidying.
Also we need this line if the palette isn't explicitly set to… | |||||
definitely a mess, yeah :) mart: definitely a mess, yeah :)
Anyways, the idea is not to use anymore the qapplication's palette… | |||||
698 | } | 711 | } | ||
699 | 712 | | |||
700 | /* | 713 | /* | ||
701 | * Property style | 714 | * Property style | ||
702 | * | 715 | * | ||
703 | * Returns a simplified style name. | 716 | * Returns a simplified style name. | ||
704 | * | 717 | * | ||
705 | * QMacStyle = "mac" | 718 | * QMacStyle = "mac" | ||
▲ Show 20 Lines • Show All 942 Lines • Show Last 20 Lines |
I don't understand what this is doing? It looks wrong?