Merge lp:~zsombi/ubuntu-ui-toolkit/themingWithItemChangeListener into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri
Status: Merged
Approved by: Cris Dywan
Approved revision: 1685
Merged at revision: 1693
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/themingWithItemChangeListener
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 1026 lines (+220/-283)
13 files modified
components.api (+0/-1)
src/Ubuntu/Components/plugin/plugin.cpp (+0/-1)
src/Ubuntu/Components/plugin/uclabel.cpp (+1/-8)
src/Ubuntu/Components/plugin/uclabel.h (+1/-2)
src/Ubuntu/Components/plugin/uclistitem.cpp (+11/-8)
src/Ubuntu/Components/plugin/ucstyleditembase.cpp (+13/-24)
src/Ubuntu/Components/plugin/ucstyleditembase.h (+8/-4)
src/Ubuntu/Components/plugin/ucstyleditembase_p.h (+2/-4)
src/Ubuntu/Components/plugin/uctheme.cpp (+14/-8)
src/Ubuntu/Components/plugin/uctheme.h (+4/-0)
src/Ubuntu/Components/plugin/ucthemingextension.cpp (+122/-135)
src/Ubuntu/Components/plugin/ucthemingextension.h (+11/-56)
tests/unit_x11/tst_subtheming/tst_subtheming.cpp (+33/-32)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/themingWithItemChangeListener
Reviewer Review Type Date Requested Status
Cris Dywan Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+274898@code.launchpad.net

Commit message

Use QQuickItemChangeListener to listen parent changes, skipping the meta object model. Convert UCThemingExtension into a Q_INTERFACE so object_cast<> can work with it saving the need to memorise on an item whether it is an extended item or not.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1682. By Zsombor Egri

no more connect in themes, use PODVector to store attached themed items and call venet handling straight to update the theme

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1683. By Zsombor Egri

parent changes are no longer QObjects, nor attached objects; thus no more need for initTheme() and qml data to be present when initializing it

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1684. By Zsombor Egri

remove event handling as there's no need for that, anyone interested in theme changes should be derived from UCThemingExtension

1685. By Zsombor Egri

fixing API file

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

For branches like this I very much appreciate that bzr culture favors leaving history intact so I can go through some of the development steps and retrace the reasoning.
I'm wondering if there's any additional tests that should be done to ensure letting go of the custom event and catching inherited changes doesn't cause surprised, but I can't think of any.. we might just see that in upcoming branches if they hit it.
So, as far as I can find, it looks sensible.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2015-10-15 14:17:25 +0000
3+++ components.api 2015-10-20 10:21:28 +0000
4@@ -1400,7 +1400,6 @@
5 Ubuntu.Components.UCFontUtils 1.0 0.1: QtObject
6 function double sizeToPixels(string size)
7 function double modularScale(string size)
8-UCItemAttached: QtObject
9 UCListItemDivider: Item
10 property color colorFrom
11 property color colorTo
12
13=== modified file 'src/Ubuntu/Components/plugin/plugin.cpp'
14--- src/Ubuntu/Components/plugin/plugin.cpp 2015-10-01 12:34:29 +0000
15+++ src/Ubuntu/Components/plugin/plugin.cpp 2015-10-20 10:21:28 +0000
16@@ -230,7 +230,6 @@
17 qmlRegisterType<UCUbuntuShapeOverlay>(uri, 1, 2, "UbuntuShapeOverlay");
18
19 // register 1.3 API
20- qmlRegisterType<UCItemAttached>();
21 qmlRegisterType<UCListItem, 1>(uri, 1, 3, "ListItem");
22 qmlRegisterType<UCListItemExpansion>();
23 qmlRegisterType<UCTheme>(uri, 1, 3, "ThemeSettings");
24
25=== modified file 'src/Ubuntu/Components/plugin/uclabel.cpp'
26--- src/Ubuntu/Components/plugin/uclabel.cpp 2015-09-28 16:18:19 +0000
27+++ src/Ubuntu/Components/plugin/uclabel.cpp 2015-10-20 10:21:28 +0000
28@@ -78,6 +78,7 @@
29 */
30 UCLabel::UCLabel(QQuickItem* parent)
31 : QQuickText(parent)
32+ , UCThemingExtension(this)
33 , m_textSize(Medium)
34 , m_flags(0)
35 {
36@@ -91,7 +92,6 @@
37
38 void UCLabel::init()
39 {
40- initTheming(this);
41 postThemeChanged();
42 updatePixelSize();
43 m_defaultFont = font();
44@@ -103,13 +103,6 @@
45 connect(this, &UCLabel::colorChanged, this, &UCLabel::_q_customColor, Qt::DirectConnection);
46 }
47
48-void UCLabel::customEvent(QEvent *event)
49-{
50- if (UCThemeEvent::isThemeEvent(event)) {
51- handleThemeEvent(static_cast<UCThemeEvent*>(event));
52- }
53-}
54-
55 void UCLabel::postThemeChanged()
56 {
57 if (m_flags & ColorSet) {
58
59=== modified file 'src/Ubuntu/Components/plugin/uclabel.h'
60--- src/Ubuntu/Components/plugin/uclabel.h 2015-10-01 12:34:29 +0000
61+++ src/Ubuntu/Components/plugin/uclabel.h 2015-10-20 10:21:28 +0000
62@@ -23,7 +23,7 @@
63 class UCLabel : public QQuickText, public UCThemingExtension
64 {
65 Q_OBJECT
66-
67+ Q_INTERFACES(UCThemingExtension)
68 Q_ENUMS(TextSize)
69 Q_PROPERTY(TextSize textSize MEMBER m_textSize WRITE setTextSize NOTIFY textSizeChanged FINAL)
70
71@@ -61,7 +61,6 @@
72 protected:
73 // from QQuickItem
74 void classBegin();
75- void customEvent(QEvent *event);
76
77 // from UCItemExtension
78 void preThemeChanged(){}
79
80=== modified file 'src/Ubuntu/Components/plugin/uclistitem.cpp'
81--- src/Ubuntu/Components/plugin/uclistitem.cpp 2015-10-12 14:32:17 +0000
82+++ src/Ubuntu/Components/plugin/uclistitem.cpp 2015-10-20 10:21:28 +0000
83@@ -61,7 +61,7 @@
84 QColor colorFrom;
85 QColor colorTo;
86 QGradientStops gradient;
87- UCListItemPrivate *listItem;
88+ UCListItem *listItem;
89 };
90
91 UCListItemDivider::UCListItemDivider(UCListItem *parent)
92@@ -77,14 +77,16 @@
93 {
94 Q_D(UCListItemDivider);
95 QQml_setParent_noEvent(this, listItem);
96- d->listItem = UCListItemPrivate::get(listItem);
97+ d->listItem = listItem;
98 setParentItem(listItem);
99 // anchor to left/right/bottom of the ListItem
100 QQuickAnchors *anchors = d->anchors();
101- anchors->setLeft(d->listItem->left());
102- anchors->setRight(d->listItem->right());
103- anchors->setBottom(d->listItem->bottom());
104+ UCListItemPrivate *pListItem = UCListItemPrivate::get(listItem);
105+ anchors->setLeft(pListItem->left());
106+ anchors->setRight(pListItem->right());
107+ anchors->setBottom(pListItem->bottom());
108 // connect visible change so we relayout contentItem
109+ // FIXME: do this with itemChange!!!
110 connect(this, SIGNAL(visibleChanged()), listItem, SLOT(_q_relayout()));
111 }
112
113@@ -132,7 +134,8 @@
114 dividerNode = d->sceneGraphContext()->createRectangleNode();
115 }
116
117- bool lastItem = d->listItem->countOwner ? (d->listItem->index() == (d->listItem->countOwner->property("count").toInt() - 1)): false;
118+ UCListItemPrivate *pListItem = UCListItemPrivate::get(d->listItem);
119+ bool lastItem = pListItem->countOwner ? (pListItem->index() == (pListItem->countOwner->property("count").toInt() - 1)): false;
120 if (!lastItem && (d->gradient.size() > 0) && ((d->colorFrom.alphaF() >= (1.0f / 255.0f)) || (d->colorTo.alphaF() >= (1.0f / 255.0f)))) {
121 dividerNode->setRect(boundingRect());
122 dividerNode->setGradientStops(d->gradient);
123@@ -1174,7 +1177,7 @@
124 {
125 Q_Q(UCListItem);
126 // themes 1.2 and below should not have context menu support, so leave
127- quint16 version(getTheme()->version());
128+ quint16 version(q->getTheme()->version());
129 if (version <= BUILD_VERSION(1, 2)) {
130 return;
131 }
132@@ -1643,7 +1646,7 @@
133 {
134 Q_D(UCListItem);
135 d->customColor = false;
136- d->highlightColor = d->getTheme()->getPaletteColor("selected", "background");
137+ d->highlightColor = getTheme()->getPaletteColor("selected", "background");
138 update();
139 Q_EMIT highlightColorChanged();
140 }
141
142=== modified file 'src/Ubuntu/Components/plugin/ucstyleditembase.cpp'
143--- src/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-10-06 07:16:37 +0000
144+++ src/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-10-20 10:21:28 +0000
145@@ -108,6 +108,7 @@
146 */
147 UCStyledItemBase::UCStyledItemBase(QQuickItem *parent)
148 : QQuickItem(*(new UCStyledItemBasePrivate), parent)
149+ , UCThemingExtension(this)
150 {
151 Q_D(UCStyledItemBase);
152 d->init();
153@@ -115,6 +116,7 @@
154
155 UCStyledItemBase::UCStyledItemBase(UCStyledItemBasePrivate &dd, QQuickItem *parent)
156 : QQuickItem(dd, parent)
157+ , UCThemingExtension(this)
158 {
159 Q_D(UCStyledItemBase);
160 d->init();
161@@ -308,7 +310,7 @@
162 // either styleComponent or styleName is valid
163 QQmlComponent *component = styleComponent;
164 if (!component) {
165- component = getTheme()->createStyleComponent(styleDocument + ".qml", q, styleVersion);
166+ component = q->getTheme()->createStyleComponent(styleDocument + ".qml", q, styleVersion);
167 }
168 if (!component) {
169 return false;
170@@ -442,25 +444,21 @@
171 * if any, or to the system default theme.
172 */
173
174-void UCStyledItemBasePrivate::preThemeChanged()
175+void UCStyledItemBase::preThemeChanged()
176 {
177- wasStyleLoaded = (styleItem != Q_NULLPTR);
178- preStyleChanged();
179+ Q_D(UCStyledItemBase);
180+ d->wasStyleLoaded = (d->styleItem != Q_NULLPTR);
181+ d->preStyleChanged();
182 }
183-void UCStyledItemBasePrivate::postThemeChanged()
184+void UCStyledItemBase::postThemeChanged()
185 {
186- Q_EMIT q_func()->themeChanged();
187- if (!wasStyleLoaded) {
188+ Q_EMIT themeChanged();
189+ Q_D(UCStyledItemBase);
190+ if (!d->wasStyleLoaded) {
191 return;
192 }
193- postStyleChanged();
194- loadStyleItem();
195-}
196-
197-void UCStyledItemBase::classBegin()
198-{
199- QQuickItem::classBegin();
200- d_func()->initTheming(this);
201+ d->postStyleChanged();
202+ d->loadStyleItem();
203 }
204
205 void UCStyledItemBase::componentComplete()
206@@ -509,13 +507,4 @@
207 return QQuickItem::childMouseEventFilter(child, event);
208 }
209
210-// catch UCThemeEvent
211-void UCStyledItemBase::customEvent(QEvent *event)
212-{
213- Q_D(UCStyledItemBase);
214- if (UCThemeEvent::isThemeEvent(event)) {
215- d->handleThemeEvent(static_cast<UCThemeEvent*>(event));
216- }
217-}
218-
219 #include "moc_ucstyleditembase.cpp"
220
221=== modified file 'src/Ubuntu/Components/plugin/ucstyleditembase.h'
222--- src/Ubuntu/Components/plugin/ucstyleditembase.h 2015-09-14 11:26:44 +0000
223+++ src/Ubuntu/Components/plugin/ucstyleditembase.h 2015-10-20 10:21:28 +0000
224@@ -20,20 +20,22 @@
225 #define UCSTYLEDITEMBASE_H
226
227 #include <QtQuick/QQuickItem>
228+#include "ucthemingextension.h"
229
230 class UCStyledItemBasePrivate;
231 class UCTheme;
232 class UCStyleHints;
233-class UCStyledItemBase : public QQuickItem
234+class UCStyledItemBase : public QQuickItem, public UCThemingExtension
235 {
236 Q_OBJECT
237+ Q_INTERFACES(UCThemingExtension)
238 Q_PROPERTY(bool activeFocusOnPress
239 READ activefocusOnPress WRITE setActiveFocusOnPress
240 NOTIFY activeFocusOnPressChanged REVISION 1)
241 Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QQmlComponent *style READ style WRITE setStyle RESET resetStyle NOTIFY styleChanged FINAL DESIGNABLE false)
242 Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QQuickItem *__styleInstance READ styleInstance NOTIFY styleInstanceChanged FINAL DESIGNABLE false)
243 Q_PRIVATE_PROPERTY(UCStyledItemBase::d_func(), QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged FINAL REVISION 2)
244- Q_PRIVATE_PROPERTY(d_func(), UCTheme *theme READ getTheme WRITE setTheme RESET resetTheme NOTIFY themeChanged FINAL REVISION 2)
245+ Q_PROPERTY(UCTheme *theme READ getTheme WRITE setTheme RESET resetTheme NOTIFY themeChanged FINAL REVISION 2)
246 public:
247 explicit UCStyledItemBase(QQuickItem *parent = 0);
248
249@@ -53,11 +55,13 @@
250 protected:
251 UCStyledItemBase(UCStyledItemBasePrivate &, QQuickItem *parent);
252
253- void classBegin();
254+ // from UCThemingExtension interface
255+ virtual void preThemeChanged();
256+ virtual void postThemeChanged();
257+
258 void componentComplete();
259 void mousePressEvent(QMouseEvent *event);
260 bool childMouseEventFilter(QQuickItem *child, QEvent *event);
261- void customEvent(QEvent *event);
262
263 private:
264 Q_DECLARE_PRIVATE(UCStyledItemBase)
265
266=== modified file 'src/Ubuntu/Components/plugin/ucstyleditembase_p.h'
267--- src/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-10-06 07:16:37 +0000
268+++ src/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-10-20 10:21:28 +0000
269@@ -25,8 +25,9 @@
270
271 class QQuickMouseArea;
272 class UCStyledItemBase;
273-class UCStyledItemBasePrivate : public QQuickItemPrivate, public UCThemingExtension
274+class UCStyledItemBasePrivate : public QQuickItemPrivate
275 {
276+ Q_INTERFACES(UCThemingExtension)
277 Q_DECLARE_PUBLIC(UCStyledItemBase)
278 public:
279
280@@ -55,9 +56,6 @@
281 virtual void postStyleChanged() {}
282 virtual bool loadStyleItem(bool animated = true);
283
284- virtual void preThemeChanged();
285- virtual void postThemeChanged();
286-
287 public:
288
289 QPointer<QQmlContext> styleItemContext;
290
291=== modified file 'src/Ubuntu/Components/plugin/uctheme.cpp'
292--- src/Ubuntu/Components/plugin/uctheme.cpp 2015-09-21 13:29:17 +0000
293+++ src/Ubuntu/Components/plugin/uctheme.cpp 2015-10-20 10:21:28 +0000
294@@ -460,6 +460,7 @@
295 }
296 loadPalette();
297 Q_EMIT nameChanged();
298+ updateThemedItems();
299 }
300 void UCTheme::resetName()
301 {
302@@ -625,16 +626,20 @@
303
304 void UCTheme::attachItem(QQuickItem *item, bool attach)
305 {
306- UCItemAttached *theming = static_cast<UCItemAttached*>(qmlAttachedPropertiesObject<UCItemAttached>(item, false));
307- if (!theming) {
308- return;
309- }
310 if (attach) {
311- connect(this, SIGNAL(nameChanged()), theming, SLOT(reloadTheme()), Qt::DirectConnection);
312- connect(this, SIGNAL(versionChanged()), theming, SLOT(reloadTheme()), Qt::DirectConnection);
313+ m_attachedItems.append(item);
314 } else {
315- disconnect(this, SIGNAL(nameChanged()), theming, SLOT(reloadTheme()));
316- disconnect(this, SIGNAL(versionChanged()), theming, SLOT(reloadTheme()));
317+ m_attachedItems.removeOne(item);
318+ }
319+}
320+
321+void UCTheme::updateThemedItems()
322+{
323+ for (int i = 0; i < m_attachedItems.count(); i++) {
324+ UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(m_attachedItems[i]);
325+ if (extension) {
326+ extension->itemThemeReloaded(this);
327+ }
328 }
329 }
330
331@@ -671,6 +676,7 @@
332 }
333 m_version = version;
334 Q_EMIT versionChanged();
335+ updateThemedItems();
336 }
337
338 /*
339
340=== modified file 'src/Ubuntu/Components/plugin/uctheme.h'
341--- src/Ubuntu/Components/plugin/uctheme.h 2015-09-21 07:21:36 +0000
342+++ src/Ubuntu/Components/plugin/uctheme.h 2015-10-20 10:21:28 +0000
343@@ -28,6 +28,8 @@
344 #include <QtQml/QQmlParserStatus>
345 #include <QtQml/QQmlProperty>
346
347+#include <QtQml/private/qpodvector_p.h>
348+
349 #include "ucdefaulttheme.h"
350
351 class UCStyledItemBase;
352@@ -110,6 +112,7 @@
353 void updateThemePaths();
354 QUrl styleUrl(const QString& styleName, quint16 version, bool *isFallback = NULL);
355 void loadPalette(bool notify = true);
356+ void updateThemedItems();
357
358 class PaletteConfig
359 {
360@@ -161,6 +164,7 @@
361 QPointer<QObject> m_palette; // the palette might be from the default style if the theme doesn't define palette
362 QList<ThemeRecord> m_themePaths;
363 UCDefaultTheme m_defaultTheme;
364+ QPODVector<QQuickItem*, 4> m_attachedItems;
365 QQmlEngine *m_engine;
366 quint16 m_version;
367 bool m_defaultStyle:1;
368
369=== modified file 'src/Ubuntu/Components/plugin/ucthemingextension.cpp'
370--- src/Ubuntu/Components/plugin/ucthemingextension.cpp 2015-09-21 14:24:05 +0000
371+++ src/Ubuntu/Components/plugin/ucthemingextension.cpp 2015-10-20 10:21:28 +0000
372@@ -23,103 +23,85 @@
373 #include <QtGui/QGuiApplication>
374
375 /*
376- * The UCThemingExtension class provides theme handling on Items extending an existing
377+ * The UCThemingExtension interface provides theme handling on Items extending an existing
378 * QQuickItem derivate class. Items subject fo theming should derive from this class
379- * and implement the virtual methods, as well as add the following two methods:
380- * 1) classBegin(item) should be called from the QQuickItem::classBegin() method
381- * 2) handleThemeEvent() should be called from QQuickItem::customEvent() method
382+ * and implement the pure virtual methods.
383 * The item can expose the theme property and use the getters defined by the
384 * class.
385- * Iin case the item exposes the theme property, it can use the getters from the
386+ * In case the item exposes the theme property, it can use the getters from the
387 * extension and declare the themeChanged signal.
388 */
389
390-static int themeUpdatedId = QEvent::registerEventType();
391-static int themeReloadedId = QEvent::registerEventType();
392-
393-UCThemeEvent::UCThemeEvent(UCTheme *reloadedTheme)
394- : QEvent((QEvent::Type)themeReloadedId)
395- , m_oldTheme(Q_NULLPTR)
396- , m_newTheme(reloadedTheme)
397-{
398- setAccepted(false);
399-}
400-
401-UCThemeEvent::UCThemeEvent(UCTheme *oldTheme, UCTheme *newTheme)
402- : QEvent((QEvent::Type)themeUpdatedId)
403- , m_oldTheme(oldTheme)
404- , m_newTheme(newTheme)
405-{
406- setAccepted(false);
407-}
408-
409-UCThemeEvent::UCThemeEvent(const UCThemeEvent &other)
410- : QEvent(other.type())
411- , m_oldTheme(other.m_oldTheme)
412- , m_newTheme(other.m_newTheme)
413-{
414- setAccepted(false);
415-}
416-
417-bool UCThemeEvent::isThemeEvent(const QEvent *event)
418-{
419- return ((int)event->type() == themeUpdatedId) || ((int)event->type() == themeReloadedId);
420-}
421-
422-void UCThemingExtension::forwardEvent(QQuickItem *item, UCThemeEvent *event)
423-{
424- Q_FOREACH(QQuickItem *child, item->childItems()) {
425- QGuiApplication::sendEvent(child, event);
426- // StyledItem will handle the broadcast itself depending on whether the theme change was appropriate or not
427- // and will complete the ascendantStyled/theme itself
428- if (child->childItems().size() > 0 && !UCItemAttached::isThemed(child)) {
429- forwardEvent(child, event);
430- }
431- }
432-}
433-
434-void UCThemingExtension::broadcastThemeChange(QQuickItem *item, UCTheme *oldTheme, UCTheme *newTheme)
435-{
436- UCThemeEvent event(oldTheme, newTheme);
437- forwardEvent(item, &event);
438-}
439-
440-void UCThemingExtension::broadcastThemeReloaded(QQuickItem *item, UCTheme *theme)
441-{
442- UCThemeEvent event(theme);
443- forwardEvent(item, &event);
444+void notifyThemeChange(QQuickItem *item, UCTheme *oldTheme, UCTheme *newTheme)
445+{
446+ Q_FOREACH(QQuickItem *child, item->childItems()) {
447+ UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(child);
448+ if (extension) {
449+ extension->itemThemeChanged(oldTheme, newTheme);
450+ }
451+ // StyledItem will handle the broadcast itself depending on whether the theme change was appropriate or not
452+ // and will complete the ascendantStyled/theme itself
453+ if (!extension) {
454+ notifyThemeChange(child, oldTheme, newTheme);
455+ }
456+ }
457+}
458+
459+void notifyThemeReloaded(QQuickItem *item, UCTheme *theme)
460+{
461+ Q_FOREACH(QQuickItem *child, item->childItems()) {
462+ UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(child);
463+ if (extension) {
464+ extension->itemThemeReloaded(theme);
465+ }
466+ // StyledItem will handle the broadcast itself depending on whether the theme change was appropriate or not
467+ // and will complete the ascendantStyled/theme itself
468+ if (!extension) {
469+ notifyThemeReloaded(child, theme);
470+ }
471+ }
472 }
473
474 /*************************************************************************
475 * Attached to every Item in the system
476 */
477-UCItemAttached::UCItemAttached(QObject *owner)
478- : QObject(owner)
479- , m_item(static_cast<QQuickItem*>(owner))
480+static uint xdata = QObject::registerUserData();
481+class UCItemAttached : public QObjectUserData, public QQuickItemChangeListener
482+{
483+public:
484+ explicit UCItemAttached(QQuickItem *owner = 0);
485+ ~UCItemAttached();
486+
487+ QQuickItem *m_item;
488+ QQuickItem *m_prevParent;
489+
490+ void itemParentChanged(QQuickItem *item, QQuickItem *newParent);
491+
492+private:
493+
494+ friend class UCThemingExtension;
495+};
496+
497+UCItemAttached::UCItemAttached(QQuickItem *owner)
498+ : m_item(owner)
499 , m_prevParent(Q_NULLPTR)
500- , m_extension(Q_NULLPTR)
501 {
502- // get parent item changes
503- connect(m_item, &QQuickItem::parentChanged, this, &UCItemAttached::handleParentChanged);
504+ QQuickItemPrivate::get(m_item)->addItemChangeListener(this, QQuickItemPrivate::Parent);
505 }
506
507 UCItemAttached::~UCItemAttached()
508 {
509-}
510-
511-UCItemAttached *UCItemAttached::qmlAttachedProperties(QObject *owner)
512-{
513- return new UCItemAttached(owner);
514-}
515-
516-bool UCItemAttached::isThemed(QQuickItem *item)
517-{
518- UCItemAttached *attached = static_cast<UCItemAttached*>(qmlAttachedPropertiesObject<UCItemAttached>(item, false));
519- return attached && (attached->m_extension != Q_NULLPTR);
520+ QQuickItemPrivate::get(m_item)->removeItemChangeListener(this, QQuickItemPrivate::Parent);
521+}
522+
523+bool UCThemingExtension::isThemed(QQuickItem *item)
524+{
525+ UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(item);
526+ return extension != Q_NULLPTR;
527 }
528
529 // handle parent changes
530-void UCItemAttached::handleParentChanged(QQuickItem *newParent)
531+void UCItemAttached::itemParentChanged(QQuickItem *, QQuickItem *newParent)
532 {
533 if (newParent == m_prevParent || QQuickItemPrivate::get(m_item)->wasDeleted) {
534 return;
535@@ -128,41 +110,43 @@
536 // make sure we have these handlers attached to each intermediate item
537 QQuickItem *oldThemedAscendant = UCThemingExtension::ascendantThemed(m_prevParent);
538 QQuickItem *newThemedAscendant = UCThemingExtension::ascendantThemed(newParent);
539- UCTheme *oldTheme = oldThemedAscendant ? oldThemedAscendant->property("theme").value<UCTheme*>() : &UCTheme::defaultTheme();
540- UCTheme *newTheme = newThemedAscendant ? newThemedAscendant->property("theme").value<UCTheme*>() : &UCTheme::defaultTheme();
541+ UCThemingExtension *oldExtension = qobject_cast<UCThemingExtension*>(oldThemedAscendant);
542+ UCThemingExtension *newExtension = qobject_cast<UCThemingExtension*>(newThemedAscendant);
543+ UCTheme *oldTheme = oldExtension ? oldExtension->getTheme() : &UCTheme::defaultTheme();
544+ UCTheme *newTheme = newExtension ? newExtension->getTheme() : &UCTheme::defaultTheme();
545
546 if (oldTheme != newTheme) {
547+ UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(m_item);
548 // send the event to m_item first
549- UCThemeEvent event(oldTheme, newTheme);
550- if (m_extension) {
551+ if (extension) {
552 // only items with extensions should get this event
553- m_extension->handleThemeEvent(&event);
554+ extension->itemThemeChanged(oldTheme, newTheme);
555 }
556 // then broadcast to children, but only if the item is not a styled one
557- if (!m_extension) {
558- UCThemingExtension::forwardEvent(m_item, &event);
559+ if (!extension) {
560+ notifyThemeChange(m_item, oldTheme, newTheme);
561 }
562 }
563 m_prevParent = newParent;
564 }
565
566-void UCItemAttached::reloadTheme()
567-{
568- Q_ASSERT(m_extension);
569- m_extension->preThemeChanged();
570- m_extension->postThemeChanged();
571- UCThemingExtension::broadcastThemeReloaded(m_item, static_cast<UCTheme*>(sender()));
572-}
573-
574 /*************************************************************************
575 *
576 */
577-UCThemingExtension::UCThemingExtension()
578- : themedItem(Q_NULLPTR)
579- , attachedThemer(Q_NULLPTR)
580- , theme(&UCTheme::defaultTheme())
581+UCThemingExtension::UCThemingExtension(QQuickItem *extendedItem)
582+ : theme(&UCTheme::defaultTheme())
583+ , themedItem(extendedItem)
584 , themeType(Inherited)
585 {
586+ theme->attachItem(themedItem, true);
587+ themedItem->setUserData(xdata, new UCItemAttached(themedItem));
588+}
589+
590+UCThemingExtension::~UCThemingExtension()
591+{
592+ if (theme) {
593+ theme->attachItem(themedItem, false);
594+ }
595 }
596
597 // set the parent of the theme if the themeType is Custom
598@@ -172,47 +156,50 @@
599 return;
600 }
601 QQuickItem *upperThemed = ascendantThemed(QQuickItemPrivate::get(themedItem)->parentItem);
602- UCItemAttached *attached = static_cast<UCItemAttached*>(qmlAttachedPropertiesObject<UCItemAttached>(upperThemed));
603- UCTheme *parentTheme = (attached && attached->m_extension) ? attached->m_extension->getTheme() : &UCTheme::defaultTheme();
604+ UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(upperThemed);
605+ UCTheme *parentTheme = extension ? extension->getTheme() : &UCTheme::defaultTheme();
606 if (parentTheme != theme) {
607 theme->setParentTheme(parentTheme);
608 }
609 }
610
611-void UCThemingExtension::initTheming(QQuickItem *item)
612+void UCThemingExtension::itemThemeChanged(UCTheme*, UCTheme *newTheme)
613 {
614- themedItem = item;
615- attachedThemer = static_cast<UCItemAttached*>(qmlAttachedPropertiesObject<UCItemAttached>(themedItem));
616- Q_ASSERT(attachedThemer);
617- attachedThemer->m_extension = this;
618- theme->attachItem(item, true);
619+ switch (themeType) {
620+ case Inherited: {
621+ setTheme(newTheme, Inherited);
622+ return;
623+ }
624+ case Custom: {
625+ // set the theme's parent
626+ theme->setParentTheme(newTheme);
627+ return;
628+ }
629+ default: break;
630+ }
631 }
632
633-void UCThemingExtension::handleThemeEvent(UCThemeEvent *event)
634+void UCThemingExtension::itemThemeReloaded(UCTheme *theme)
635 {
636- if ((int)event->type() == themeUpdatedId) {
637- switch (themeType) {
638- case Inherited: {
639- setTheme(event->newTheme(), Inherited);
640- return;
641- }
642- case Custom: {
643- // set the theme's parent
644- theme->setParentTheme(event->newTheme());
645- return;
646- }
647- default: break;
648- }
649- } else if ((int)event->type() == themeReloadedId) {
650- // no need to handle Inherited case, those items are all attached to the theme changes
651- switch (themeType) {
652- case Custom: {
653+ switch (themeType) {
654+ case Inherited: {
655+ preThemeChanged();
656+ postThemeChanged();
657+ return;
658+ }
659+ case Custom: {
660+ if (theme == this->theme) {
661+ preThemeChanged();
662+ postThemeChanged();
663+ // forward to children
664+ notifyThemeReloaded(themedItem, theme);
665+ } else {
666 // emit theme's parentThemeChanged()
667- Q_EMIT theme->parentThemeChanged();
668- return;
669- }
670- default: break;
671- }
672+ Q_EMIT this->theme->parentThemeChanged();
673+ }
674+ return;
675+ }
676+ default: break;
677 }
678 }
679
680@@ -250,26 +237,26 @@
681 postThemeChanged();
682
683 // broadcast to the children
684- broadcastThemeChange(themedItem, oldTheme, theme);
685+ notifyThemeChange(themedItem, oldTheme, theme);
686 }
687
688 void UCThemingExtension::resetTheme()
689 {
690 QQuickItem *upperThemed = ascendantThemed(QQuickItemPrivate::get(themedItem)->parentItem);
691- UCItemAttached *attached = static_cast<UCItemAttached*>(qmlAttachedPropertiesObject<UCItemAttached>(upperThemed));
692- UCTheme *theme = (attached && attached->m_extension) ? attached->m_extension->getTheme() : &UCTheme::defaultTheme();
693+ UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(upperThemed);
694+ UCTheme *theme = extension ? extension->getTheme() : &UCTheme::defaultTheme();
695 setTheme(theme, Inherited);
696 }
697
698 // returns the closest themed ascendant
699 QQuickItem *UCThemingExtension::ascendantThemed(QQuickItem *item)
700 {
701- while (item && !UCItemAttached::isThemed(item)) {
702- // make sure it also has the theming attached
703- qmlAttachedPropertiesObject<UCItemAttached>(item);
704+ while (item && !isThemed(item)) {
705+ // if the item has no xdata set, means we haven't been here yet
706+ if (!item->userData(xdata)) {
707+ item->setUserData(xdata, new UCItemAttached(item));
708+ }
709 item = item->parentItem();
710 }
711 return item;
712 }
713-
714-#include "moc_ucthemingextension.cpp"
715
716=== modified file 'src/Ubuntu/Components/plugin/ucthemingextension.h'
717--- src/Ubuntu/Components/plugin/ucthemingextension.h 2015-09-21 14:24:05 +0000
718+++ src/Ubuntu/Components/plugin/ucthemingextension.h 2015-10-20 10:21:28 +0000
719@@ -24,54 +24,10 @@
720 #include <QtCore/QPointer>
721 #include <QtQml>
722
723+#include <QtQuick/private/qquickitem_p.h>
724+
725 class QQuickItem;
726-class UCStyledItemBase;
727 class UCTheme;
728-class UCThemingExtension;
729-class UCItemAttached : public QObject
730-{
731- Q_OBJECT
732-public:
733- explicit UCItemAttached(QObject *owner = 0);
734- ~UCItemAttached();
735- static bool isThemed(QQuickItem *item);
736- static UCItemAttached *qmlAttachedProperties(QObject *owner);
737-
738- QQuickItem *m_item;
739- QQuickItem *m_prevParent;
740- UCThemingExtension *m_extension;
741-
742-private:
743- Q_SLOT void handleParentChanged(QQuickItem *newParent);
744- Q_SLOT void reloadTheme();
745-
746- friend class UCThemingExtension;
747-};
748-QML_DECLARE_TYPEINFO(UCItemAttached, QML_HAS_ATTACHED_PROPERTIES)
749-
750-class UCThemeEvent : public QEvent
751-{
752-public: // statics
753- static bool isThemeEvent(const QEvent *event);
754-
755-public:
756- explicit UCThemeEvent(UCTheme *reloadedTheme);
757- UCThemeEvent(UCTheme *oldTheme, UCTheme *newTheme);
758- UCThemeEvent(const UCThemeEvent &other);
759-
760- UCTheme *oldTheme() const
761- {
762- return m_oldTheme;
763- }
764- UCTheme *newTheme() const
765- {
766- return m_newTheme;
767- }
768-private:
769- UCTheme *m_oldTheme;
770- UCTheme *m_newTheme;
771-};
772-
773 class UCThemingExtension
774 {
775 public:
776@@ -80,31 +36,30 @@
777 Custom
778 };
779
780- explicit UCThemingExtension();
781+ explicit UCThemingExtension(QQuickItem *extendedItem);
782+ virtual ~UCThemingExtension();
783
784 virtual void preThemeChanged() = 0;
785 virtual void postThemeChanged() = 0;
786-
787- virtual void initTheming(QQuickItem *item);
788- virtual void handleThemeEvent(UCThemeEvent *event);
789+ virtual void itemThemeChanged(UCTheme *, UCTheme*);
790+ virtual void itemThemeReloaded(UCTheme *);
791
792 UCTheme *getTheme() const;
793 void setTheme(UCTheme *newTheme, ThemeType type = Custom);
794 void resetTheme();
795
796+ static bool isThemed(QQuickItem *item);
797 static QQuickItem *ascendantThemed(QQuickItem *item);
798
799- static void forwardEvent(QQuickItem *item, UCThemeEvent *event);
800- static void broadcastThemeChange(QQuickItem *item, UCTheme *oldTheme, UCTheme *newTheme);
801- static void broadcastThemeReloaded(QQuickItem *item, UCTheme *theme);
802-
803 protected:
804+ QPointer<UCTheme> theme;
805 QQuickItem *themedItem;
806- UCItemAttached *attachedThemer;
807- QPointer<UCTheme> theme;
808 ThemeType themeType;
809
810 void setParentTheme();
811 };
812
813+#define UCThemingExtension_iid "org.qt-project.Qt.UCThemingExtension"
814+Q_DECLARE_INTERFACE(UCThemingExtension, UCThemingExtension_iid)
815+
816 #endif // UCITEMEXTENSION_H
817
818=== modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.cpp'
819--- tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-10-06 07:16:37 +0000
820+++ tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-10-20 10:21:28 +0000
821@@ -55,6 +55,7 @@
822 UCTheme *rootTheme = globalTheme();
823 QVERIFY(rootTheme);
824 rootTheme->setName(theme);
825+
826 }
827
828 void setTheme(const QString &theme, QQuickItem *watchedItem)
829@@ -282,11 +283,11 @@
830 UCStyledItemBase *mainItem = qobject_cast<UCStyledItemBase*>(view->rootObject());
831
832 QSignalSpy parentChangeSpy(testSet, SIGNAL(parentThemeChanged()));
833- UCStyledItemBasePrivate::get(testItem)->setTheme(testSet);
834+ testItem->setTheme(testSet);
835 parentChangeSpy.wait(200);
836 QCOMPARE(parentChangeSpy.count(), 1);
837 // test if the parent is correct
838- QCOMPARE(testSet->parentTheme(), UCStyledItemBasePrivate::get(mainItem)->getTheme());
839+ QCOMPARE(testSet->parentTheme(), mainItem->getTheme());
840 }
841
842 void test_parent_set_reset_triggers_parent_change()
843@@ -299,11 +300,11 @@
844
845 // reset mainItem's theme should trigger parentChanged on testSet
846 QSignalSpy parentChangeSpy(testSet, SIGNAL(parentThemeChanged()));
847- UCStyledItemBasePrivate::get(mainItem)->resetTheme();
848+ mainItem->resetTheme();
849 parentChangeSpy.wait(200);
850 QCOMPARE(parentChangeSpy.count(), 1);
851- QCOMPARE(UCStyledItemBasePrivate::get(mainItem)->getTheme(), &UCTheme::defaultTheme());
852- QCOMPARE(testSet->parentTheme(), UCStyledItemBasePrivate::get(mainItem)->getTheme());
853+ QCOMPARE(mainItem->getTheme(), &UCTheme::defaultTheme());
854+ QCOMPARE(testSet->parentTheme(), mainItem->getTheme());
855 }
856
857 void test_parent_set_namechange_triggers_parent_change()
858@@ -315,11 +316,11 @@
859 // change mainItem.theme.name should trigger parentChanged on testSet
860 QSignalSpy parentChangeSpy(testSet, SIGNAL(parentThemeChanged()));
861 QSignalSpy themeChangeSpy(mainItem, SIGNAL(themeChanged()));
862- UCStyledItemBasePrivate::get(mainItem)->getTheme()->setName("Ubuntu.Components.Themes.SuruDark");
863+ mainItem->getTheme()->setName("Ubuntu.Components.Themes.SuruDark");
864 UbuntuTestCase::waitForSignal(&themeChangeSpy);
865 parentChangeSpy.wait(200);
866 QCOMPARE(parentChangeSpy.count(), 1);
867- QCOMPARE(testSet->parentTheme(), UCStyledItemBasePrivate::get(mainItem)->getTheme());
868+ QCOMPARE(testSet->parentTheme(), mainItem->getTheme());
869 }
870
871
872@@ -333,10 +334,10 @@
873 // verify theme changes
874 UCStyledItemBase *styled = qobject_cast<UCStyledItemBase*>(view->rootObject());
875 QVERIFY(styled);
876- QCOMPARE(UCStyledItemBasePrivate::get(styled)->getTheme()->name(), QString("Ubuntu.Components.Themes.SuruDark"));
877+ QCOMPARE(styled->getTheme()->name(), QString("Ubuntu.Components.Themes.SuruDark"));
878 // a deeper item's style name
879 styled = view->findItem<UCStyledItemBase*>("secondLevelStyled");
880- QCOMPARE(UCStyledItemBasePrivate::get(styled)->getTheme()->name(), QString("Ubuntu.Components.Themes.SuruDark"));
881+ QCOMPARE(styled->getTheme()->name(), QString("Ubuntu.Components.Themes.SuruDark"));
882 }
883
884 // changing StyledItem.theme.name for different items within a tree where
885@@ -355,7 +356,7 @@
886 // change theme name (theme)
887 UCStyledItemBase *styled = view->findItem<UCStyledItemBase*>(itemName);
888 QSignalSpy themeChangeSpy(styled, SIGNAL(themeChanged()));
889- UCStyledItemBasePrivate::get(styled)->getTheme()->setName("Ubuntu.Components.Themes.SuruDark");
890+ styled->getTheme()->setName("Ubuntu.Components.Themes.SuruDark");
891 UbuntuTestCase::waitForSignal(&themeChangeSpy);
892 UCTheme *theme = view->globalTheme();
893 QCOMPARE(theme->name(), QString("Ubuntu.Components.Themes.SuruDark"));
894@@ -401,11 +402,11 @@
895 view->findItem<UCStyledItemBase*>(applyOnItem);
896 QVERIFY(styledItem);
897 // the theme is declared, but should not be set yet!!!
898- QVERIFY2(UCStyledItemBasePrivate::get(styledItem)->getTheme() != theme, "ThemeSettings should not be set yet!");
899+ QVERIFY2(styledItem->getTheme() != theme, "ThemeSettings should not be set yet!");
900 theme->setName(themeName);
901 // set the style on the item
902 QSignalSpy themeChangeSpy(styledItem, SIGNAL(themeChanged()));
903- UCStyledItemBasePrivate::get(styledItem)->setTheme(theme);
904+ styledItem->setTheme(theme);
905 UbuntuTestCase::waitForSignal(&themeChangeSpy);
906 // test on the items
907 for (int i = 0; i < testItems.count(); i++) {
908@@ -413,8 +414,8 @@
909 QString themeName = expectedStyleNames[i];
910 bool success = sameTheme[i];
911 styledItem = view->findItem<UCStyledItemBase*>(itemName);
912- QCOMPARE(UCStyledItemBasePrivate::get(styledItem)->getTheme() == theme, success);
913- QCOMPARE(UCStyledItemBasePrivate::get(styledItem)->getTheme()->name(), themeName);
914+ QCOMPARE(styledItem->getTheme() == theme, success);
915+ QCOMPARE(styledItem->getTheme()->name(), themeName);
916 }
917 }
918
919@@ -451,15 +452,15 @@
920
921 QScopedPointer<ThemeTestCase> view(new ThemeTestCase("TestStyleChange.qml"));
922 UCStyledItemBase *testItem = view->findItem<UCStyledItemBase*>(testStyledItem);
923- QCOMPARE(UCStyledItemBasePrivate::get(testItem)->getTheme()->name(), testStyledItemThemes[0]);
924+ QCOMPARE(testItem->getTheme()->name(), testStyledItemThemes[0]);
925
926 UCTheme *theme = view->findItem<UCTheme*>("Theme");
927 theme->setName("Ubuntu.Components.Themes.SuruDark");
928 UCStyledItemBase *suruItem = view->findItem<UCStyledItemBase*>(suruStyledItem);
929 QSignalSpy themeChangeSpy(suruItem, SIGNAL(themeChanged()));
930- UCStyledItemBasePrivate::get(suruItem)->setTheme(theme);
931+ suruItem->setTheme(theme);
932 UbuntuTestCase::waitForSignal(&themeChangeSpy);
933- QCOMPARE(UCStyledItemBasePrivate::get(testItem)->getTheme()->name(), testStyledItemThemes[1]);
934+ QCOMPARE(testItem->getTheme()->name(), testStyledItemThemes[1]);
935
936 // get items and reparent
937 QQuickItem *sourceItem = view->findItem<QQuickItem*>(sourceItemName);
938@@ -470,7 +471,7 @@
939 QSignalSpy themeSpy(testItem, SIGNAL(themeChanged()));
940 sourceItem->setParentItem(newParentItem);
941 themeSpy.wait(200);
942- QCOMPARE(UCStyledItemBasePrivate::get(testItem)->getTheme()->name(), testStyledItemThemes[2]);
943+ QCOMPARE(testItem->getTheme()->name(), testStyledItemThemes[2]);
944 QCOMPARE(themeSpy.count(), 1);
945 }
946
947@@ -480,8 +481,8 @@
948 UCStyledItemBase *main = qobject_cast<UCStyledItemBase*>(view->rootObject());
949 QVERIFY(main);
950 UCStyledItemBase *test = view->findItem<UCStyledItemBase*>("firstLevelStyled");
951- QCOMPARE(UCStyledItemBasePrivate::get(main)->getTheme()->name(),
952- UCStyledItemBasePrivate::get(test)->getTheme()->name());
953+ QCOMPARE(main->getTheme()->name(),
954+ test->getTheme()->name());
955 }
956
957 void test_no_change_in_other_suru_dark()
958@@ -510,7 +511,7 @@
959 QScopedPointer<ThemeTestCase> view(new ThemeTestCase("ChangeDefaultPaletteInChildren.qml"));
960 QQuickItem *loader = view->findItem<QQuickItem*>("loader");
961 UCStyledItemBase *main = qobject_cast<UCStyledItemBase*>(view->rootObject());
962- UCTheme *mainSet = UCStyledItemBasePrivate::get(main)->getTheme();
963+ UCTheme *mainSet = main->getTheme();
964 QQuickItem *item = loader->property("item").value<QQuickItem*>();
965 QVERIFY(item);
966
967@@ -590,20 +591,20 @@
968 UCStyledItemBase *movableItem = view->findItem<UCStyledItemBase*>("movable");
969
970 // verify movableItem's theme
971- QCOMPARE(UCStyledItemBasePrivate::get(root)->getTheme(), UCStyledItemBasePrivate::get(movableItem)->getTheme());
972+ QCOMPARE(root->getTheme(), movableItem->getTheme());
973
974 // set the theme for root
975 QSignalSpy themeChangeSpy(root, SIGNAL(themeChanged()));
976- UCStyledItemBasePrivate::get(root)->setTheme(suruTheme);
977+ root->setTheme(suruTheme);
978 UbuntuTestCase::waitForSignal(&themeChangeSpy);
979- QCOMPARE(UCStyledItemBasePrivate::get(root)->getTheme(), UCStyledItemBasePrivate::get(movableItem)->getTheme());
980+ QCOMPARE(root->getTheme(), movableItem->getTheme());
981
982 // set the parent item of the test item to 0
983 QSignalSpy spy(movableItem, SIGNAL(themeChanged()));
984 movableItem->setParentItem(Q_NULLPTR);
985 spy.wait(500);
986 QCOMPARE(spy.count(), 1);
987- QCOMPARE(UCStyledItemBasePrivate::get(movableItem)->getTheme(), &UCTheme::defaultTheme());
988+ QCOMPARE(movableItem->getTheme(), &UCTheme::defaultTheme());
989 }
990
991 void test_reparented_styleditem_special_case()
992@@ -617,19 +618,19 @@
993 UCStyledItemBase *movableItem = view->findItem<UCStyledItemBase*>("movable");
994
995 // check the themes
996- QCOMPARE(UCStyledItemBasePrivate::get(root)->getTheme()->name(), QString("Ubuntu.Components.Themes.Ambiance"));
997- QCOMPARE(UCStyledItemBasePrivate::get(customThemedItem)->getTheme()->name(), QString("CustomTheme"));
998- QCOMPARE(UCStyledItemBasePrivate::get(movableItem)->getTheme()->name(), QString("Ubuntu.Components.Themes.Ambiance"));
999+ QCOMPARE(root->getTheme()->name(), QString("Ubuntu.Components.Themes.Ambiance"));
1000+ QCOMPARE(customThemedItem->getTheme()->name(), QString("CustomTheme"));
1001+ QCOMPARE(movableItem->getTheme()->name(), QString("Ubuntu.Components.Themes.Ambiance"));
1002
1003 // move the movableItem under customThemedItem
1004 movableItem->setParentItem(customThemedItem);
1005- QCOMPARE(UCStyledItemBasePrivate::get(movableItem)->getTheme()->name(), QString("CustomTheme"));
1006+ QCOMPARE(movableItem->getTheme()->name(), QString("CustomTheme"));
1007
1008 // set a new theme for the root, and make sure our theme stays the same
1009 QSignalSpy themeChangeSpy(root, SIGNAL(themeChanged()));
1010- UCStyledItemBasePrivate::get(root)->setTheme(suruTheme);
1011+ root->setTheme(suruTheme);
1012 UbuntuTestCase::waitForSignal(&themeChangeSpy);
1013- QCOMPARE(UCStyledItemBasePrivate::get(movableItem)->getTheme()->name(), QString("CustomTheme"));
1014+ QCOMPARE(movableItem->getTheme()->name(), QString("CustomTheme"));
1015 }
1016
1017 void test_theme_versions_data()
1018@@ -710,7 +711,7 @@
1019 {
1020 QScopedPointer<ThemeTestCase> view(new ThemeTestCase("StyleKept.qml"));
1021 UCStyledItemBase *button = view->findItem<UCStyledItemBase*>("TestButton");
1022- UCTheme *theme = UCStyledItemBasePrivate::get(button)->getTheme();
1023+ UCTheme *theme = button->getTheme();
1024 QVERIFY(theme);
1025
1026 QVERIFY(button->findChild<QQuickItem*>("TestStyle"));

Subscribers

People subscribed via source and target branches