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

Proposed by Zsombor Egri
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 1675
Merged at revision: 1676
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/fixThemingFallback
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 110 lines (+8/-36)
3 files modified
src/Ubuntu/Components/plugin/ucstyleditembase.cpp (+5/-8)
src/Ubuntu/Components/plugin/ucstyleditembase_p.h (+1/-0)
tests/unit_x11/tst_subtheming/tst_subtheming.cpp (+2/-28)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/fixThemingFallback
Reviewer Review Type Date Requested Status
Zoltan Balogh Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+273497@code.launchpad.net

Commit message

StyledItem does no longer fall back to 1.2 style loading on mixed import versions.

Description of the change

StyledItem does no longer fall back to 1.2 style loading on mixed import versions.

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

Solves the problem

Revision history for this message
Zoltan Balogh (bzoltan) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Ubuntu/Components/plugin/ucstyleditembase.cpp'
--- src/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-09-28 07:06:36 +0000
+++ src/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-10-06 07:18:45 +0000
@@ -28,6 +28,7 @@
28UCStyledItemBasePrivate::UCStyledItemBasePrivate()28UCStyledItemBasePrivate::UCStyledItemBasePrivate()
29 : styleComponent(Q_NULLPTR)29 : styleComponent(Q_NULLPTR)
30 , styleItem(Q_NULLPTR)30 , styleItem(Q_NULLPTR)
31 , styleVersion(LATEST_UITK_VERSION)
31 , activeFocusOnPress(false)32 , activeFocusOnPress(false)
32 , wasStyleLoaded(false)33 , wasStyleLoaded(false)
33{34{
@@ -307,7 +308,7 @@
307 // either styleComponent or styleName is valid308 // either styleComponent or styleName is valid
308 QQmlComponent *component = styleComponent;309 QQmlComponent *component = styleComponent;
309 if (!component) {310 if (!component) {
310 component = getTheme()->createStyleComponent(styleDocument + ".qml", q);311 component = getTheme()->createStyleComponent(styleDocument + ".qml", q, styleVersion);
311 }312 }
312 if (!component) {313 if (!component) {
313 return false;314 return false;
@@ -473,13 +474,9 @@
473 QQmlPropertyData *pdata = QQmlPropertyCache::property(qmlEngine(this), this, QStringLiteral("theme"), cdata, l);474 QQmlPropertyData *pdata = QQmlPropertyCache::property(qmlEngine(this), this, QStringLiteral("theme"), cdata, l);
474 // FIXME MainView internal styler uses theme property, meaning imports13 will be true,475 // FIXME MainView internal styler uses theme property, meaning imports13 will be true,
475 // therefore we must check the type of the property as well in case anyone else overrides it476 // therefore we must check the type of the property as well in case anyone else overrides it
476 bool imports13 = data->propertyCache->isAllowedInRevision(pdata) && (property("theme").type() != QVariant::String);477 d->styleVersion = data->propertyCache->isAllowedInRevision(pdata) && (property("theme").type() != QVariant::String)
477 if (!imports13) {478 ? BUILD_VERSION(1, 3)
478 // load 1.2 theme479 : BUILD_VERSION(1, 2);
479 UCTheme *theme = d->getTheme();
480 // FIXME: override the global theme version to be used when creating new themes!
481 theme->setVersion(BUILD_VERSION(1, 2));
482 }
483 // no animation at this time480 // no animation at this time
484 // prepare style context if not been done yet481 // prepare style context if not been done yet
485 d->postStyleChanged();482 d->postStyleChanged();
486483
=== modified file 'src/Ubuntu/Components/plugin/ucstyleditembase_p.h'
--- src/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-09-21 11:40:22 +0000
+++ src/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-10-06 07:18:45 +0000
@@ -64,6 +64,7 @@
64 QString styleDocument;64 QString styleDocument;
65 QQmlComponent *styleComponent;65 QQmlComponent *styleComponent;
66 QQuickItem *styleItem;66 QQuickItem *styleItem;
67 quint16 styleVersion;
67 bool activeFocusOnPress:1;68 bool activeFocusOnPress:1;
68 bool wasStyleLoaded:1;69 bool wasStyleLoaded:1;
6970
7071
=== modified file 'tests/unit_x11/tst_subtheming/tst_subtheming.cpp'
--- tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-09-22 13:40:32 +0000
+++ tests/unit_x11/tst_subtheming/tst_subtheming.cpp 2015-10-06 07:18:45 +0000
@@ -636,44 +636,21 @@
636 {636 {
637 QTest::addColumn<QString>("document");637 QTest::addColumn<QString>("document");
638 QTest::addColumn<QString>("testValue");638 QTest::addColumn<QString>("testValue");
639 QTest::addColumn<int>("row");
640 QTest::addColumn<int>("column");
641 QTest::addColumn<QString>("warning");
642639
643 QTest::newRow("Theming version 1.2")
644 << "StyledItemV12.qml"
645 << ""
646 << 0 << 0 << "";
647 QTest::newRow("Theming version 1.3")640 QTest::newRow("Theming version 1.3")
648 << "StyledItemV13.qml"641 << "StyledItemV13.qml"
649 << "version1.3"642 << "version1.3";
650 << 0 << 0 << "";
651 QTest::newRow("Fall back to 1.3")
652 << "StyledItemFallback.qml"
653 << "version1.3"
654 << 19 << 1 << "QML StyledItem: Theme 'TestModule.TestTheme' has no 'TestStyle.qml' style for version 1.0, fall back to version 1.3.";
655 QTest::newRow("App theme versioned")643 QTest::newRow("App theme versioned")
656 << "StyledItemAppThemeVersioned.qml"644 << "StyledItemAppThemeVersioned.qml"
657 << "version1.3"645 << "version1.3";
658 << 0 << 0 << "";
659 QTest::newRow("App theme fallback to non-versioned")
660 << "StyledItemAppThemeFallback.qml"
661 << ""
662 << 0 << 0 << "";
663 }646 }
664 void test_theme_versions()647 void test_theme_versions()
665 {648 {
666 QFETCH(QString, document);649 QFETCH(QString, document);
667 QFETCH(QString, testValue);650 QFETCH(QString, testValue);
668 QFETCH(int, row);
669 QFETCH(int, column);
670 QFETCH(QString, warning);
671651
672 qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "");652 qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "");
673 qputenv("XDG_DATA_DIRS", "./themes:./themes/TestModule");653 qputenv("XDG_DATA_DIRS", "./themes:./themes/TestModule");
674 if (!warning.isEmpty()) {
675 ThemeTestCase::ignoreWarning(document, row, column, warning);
676 }
677 QScopedPointer<ThemeTestCase> view(new ThemeTestCase(document));654 QScopedPointer<ThemeTestCase> view(new ThemeTestCase(document));
678 UCStyledItemBase *styledItem = qobject_cast<UCStyledItemBase*>(view->rootObject());655 UCStyledItemBase *styledItem = qobject_cast<UCStyledItemBase*>(view->rootObject());
679 QVERIFY(UCStyledItemBasePrivate::get(styledItem)->styleItem);656 QVERIFY(UCStyledItemBasePrivate::get(styledItem)->styleItem);
@@ -689,9 +666,6 @@
689 qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "");666 qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "");
690 qputenv("XDG_DATA_DIRS", "./themes:./themes/TestModule:" + m_themesPath.toLatin1());667 qputenv("XDG_DATA_DIRS", "./themes:./themes/TestModule:" + m_themesPath.toLatin1());
691 QScopedPointer<ThemeTestCase> view(new ThemeTestCase("DeprecatedTheme.qml"));668 QScopedPointer<ThemeTestCase> view(new ThemeTestCase("DeprecatedTheme.qml"));
692 // NOTE TestTheme resets the theme therefore the theming will look for the tested style version under Ambiance theme
693 // which will cause a warning; therefore we mark the warning to be ignored
694 ThemeTestCase::ignoreWarning("DeprecatedTheme.qml", 19, 1, "QML StyledItem: Theme 'Ubuntu.Components.Themes.Ambiance' has no 'OptionSelectorStyle.qml' style for version 1.0, fall back to version 1.3.");
695 }669 }
696670
697 void test_style_change_has_precedence()671 void test_style_change_has_precedence()

Subscribers

People subscribed via source and target branches