on xenial help sign in
Put the branch into shape

- Add a test, even if only manual, so you can try it out. - Refactor Splash API - Fix Splash.backgroundColor binding loop - Fix MainViewStyle background image - Move Application splash properties to ApplicationInfoInterface

commit18c574086d3171e27920dfac648fbe2694c6e104 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateFri 12 Sep 2014, 17:16 (12 years ago) parentb020fe4
14 files changed+197−48
debian/control+2−2 plugins/Unity/Launcher/CMakeLists.txt+1−1 qml/Stages/ApplicationWindow.qml+10−13 qml/Stages/MainViewStyle.qml+3−2 qml/Stages/Splash.qml+53−25 tests/mocks/Unity/Application/ApplicationInfo.h+7 tests/mocks/Unity/Application/CMakeLists.txt+1−1 tests/plugins/Unity/Launcher/CMakeLists.txt+1−1 tests/plugins/Unity/Launcher/launchermodeltest.cpp+6−1 tests/qmltests/CMakeLists.txt+1 tests/qmltests/Components/tst_DragHandle/HorizontalShowable.qml+1−1 tests/qmltests/Components/tst_DragHandle/VerticalShowable.qml+1−1 tests/qmltests/Stages/tst_Splash.qml+110 tests/qmltests/Components/tst_DragHandle/UnityLogo.png → tests/qmltests/UnityLogo.png
debian/control+2−2
@@ -112,7 +112,7 @@ Depends: qml-module-qtquick-layouts,
112112 qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 0.1.49) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 0.1.49),
113113 qtdeclarative5-unity-notifications-plugin (>= 0.1.2) | unity-notifications-impl,
114114 ubuntu-thumbnailer-impl-0,
115− unity-application-impl-3,
115+ unity-application-impl-4,
116116 unity-notifications-impl-3,
117117 unity-plugin-scopes | unity-scopes-impl,
118118 unity-scopes-impl-4,
@@ -159,7 +159,7 @@ Pre-Depends: ${misc:Pre-Depends},
159159Depends: ${misc:Depends},
160160 ${shlibs:Depends},
161161Provides: unity-application-impl,
162− unity-application-impl-3,
162+ unity-application-impl-4,
163163Description: Fake environment for running Unity 8 shell
164164 Provides fake implementations of some QML modules used by Unity 8 shell
165165 (e.g Ubuntu.Application) so that you can run it in a sandboxed environment.
plugins/Unity/Launcher/CMakeLists.txt+1−1
@@ -1,6 +1,6 @@
11include(FindPkgConfig)
22pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
3−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=3)
3+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=4)
44pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
55
66add_definitions(-DSM_BUSNAME=systemBus)
qml/Stages/ApplicationWindow.qml+10−13
@@ -36,6 +36,12 @@ Item {
3636 readonly property string name: root.application ? root.application.name : ""
3737 readonly property url icon: root.application ? root.application.icon : ""
3838 readonly property int applicationState: root.application ? root.application.state : -1
39+ readonly property string splashTitle: root.application ? root.application.splashTitle : ""
40+ readonly property url splashImage: root.application ? root.application.splashImage : ""
41+ readonly property bool splashShowHeader: root.application ? root.application.splashShowHeader : true
42+ readonly property color splashColor: root.application ? root.application.splashColor : "#00000000"
43+ readonly property color splashColorHeader: root.application ? root.application.splashColorHeader : "#00000000"
44+ readonly property color splashColorFooter: root.application ? root.application.splashColorFooter : "#00000000"
3945
4046 // Whether the Application had a surface before but lost it.
4147 property bool hadSurface: sessionContainer.surfaceContainer.hadSurface
@@ -106,20 +112,11 @@ Item {
106112 Splash {
107113 id: splash
108114 title: d.splashTitle ? d.splashTitle : d.name
109− image: d.splashImage
115+ imageSource: d.splashImage
110116 showHeader: d.splashShowHeader
111−
112− Component.onCompleted: {
113− if (d.splashColor.a == 1.0) {
114− splash.backgroundColor = d.splashColor
115− }
116− if (d.splashColorHeader.a == 1.0) {
117− splash.headerColor = d.splashColorHeader
118− }
119− if (d.splashColorFooter.a == 1.0) {
120− splash.footerColor = d.splashColorFooter
121− }
122− }
117+ backgroundColor: d.splashColor
118+ headerColor: d.splashColorHeader
119+ footerColor: d.splashColorFooter
123120 }
124121 }
125122 }
qml/Stages/MainViewStyle.qml+3−2
@@ -27,7 +27,7 @@ Item {
2727 The background texture of the main view. The image will be drawn over the background color,
2828 so if it has (semi-)transparent pixels, in those pixels the background color will be visible.
2929 */
30− property url backgroundSource: "artwork/background_paper.png"
30+ property url backgroundSource: "graphics/background_paper.png"
3131 property var theme
3232
3333 Gradient {
@@ -47,10 +47,11 @@ Item {
4747 Image {
4848 id: backgroundTexture
4949 anchors.fill: parent
50− source: mainViewStyle.backgroundSource
50+ source: mainViewStyle.theme.name === "Ambiance" ? mainViewStyle.backgroundSource : ""
5151 fillMode: Image.Tile
5252 asynchronous: true
5353 cache: false
54+ visible: status === Image.Ready
5455 }
5556
5657 QtObject {
qml/Stages/Splash.qml+53−25
@@ -19,26 +19,57 @@ import Ubuntu.Components 1.1
1919import Ubuntu.Components.Themes 0.1
2020import "../Components"
2121
22−StyledItem {
22+import Ubuntu.Components.Themes.Ambiance 1.1 as Ambiance
23+
24+Item {
2325 id: root
2426
25− property string title: ""
26− property string image: ""
27− property bool showHeader: true
28− // mimic API of toolkit's MainView component required by MainViewStyle
29− property color backgroundColor: theme.palette.normal.background
30− property color headerColor: backgroundColor
31− property color footerColor: backgroundColor
32−
33− // FIXME: fake a Theme object as to expose the Palette corresponding to the backgroundColor (see MainViewStyle.qml)
34− property var theme: QtObject {
35− property string name: "Ambiance"
36− property Palette palette: Qt.createQmlObject("import QtQuick 2.2; import Ubuntu.Components.Themes.%1 1.1; Palette {}".arg(theme.name), root, "dynamicPalette");
27+ property color backgroundColor: d.undefinedColor
28+ property color headerColor: d.undefinedColor
29+ property color footerColor: d.undefinedColor
30+ property alias imageSource: overlaidImage.source
31+ property alias title: header.title
32+ property alias showHeader: header.visible
33+
34+ Ambiance.Palette {
35+ id: ambiancePalette
3736 }
3837
39− // FIXME: should instead use future toolkit API:
40− // style: theme.createStyleComponent("MainViewStyle.qml", root)
41− style: Component { MainViewStyle {theme: root.theme} }
38+ QtObject {
39+ id: d
40+
41+ // As specified in qtmir, it will set the color value to this for fields left undefined
42+ // This is also the default value of a color property in QML.
43+ readonly property color undefinedColor: "#00000000"
44+
45+ readonly property color defaultBackgroundColor: ambiancePalette.normal.background
46+ }
47+
48+ StyledItem {
49+ id: styledItem
50+ anchors.fill: parent
51+
52+ // mimic API of toolkit's MainView component required by MainViewStyle
53+ property color backgroundColor: Qt.colorEqual(root.backgroundColor, d.undefinedColor) ? d.defaultBackgroundColor
54+ : root.backgroundColor
55+ property color headerColor: Qt.colorEqual(root.headerColor, d.undefinedColor) ? styledItem.backgroundColor
56+ : root.headerColor
57+ property color footerColor: Qt.colorEqual(root.footerColor, d.undefinedColor) ? styledItem.backgroundColor
58+ : root.footerColor
59+
60+ // FIXME: fake a Theme object as to expose the Palette corresponding to the backgroundColor (see MainViewStyle.qml)
61+ property var theme: QtObject {
62+ property string name
63+ property Palette palette: Qt.createQmlObject("import QtQuick 2.2;\
64+ import Ubuntu.Components.Themes.%1 1.1;\
65+ Palette {}".arg(styledItem.theme.name),
66+ styledItem, "dynamicPalette");
67+ }
68+
69+ // FIXME: should instead use future toolkit API:
70+ // style: theme.createStyleComponent("MainViewStyle.qml", styledItem)
71+ style: Component { MainViewStyle {theme: styledItem.theme} }
72+ }
4273
4374 StyledItem {
4475 id: header
@@ -47,39 +78,36 @@ StyledItem {
4778 right: parent.right
4879 }
4980
50− visible: root.showHeader
51−
5281 // mimic API of toolkit's AppHeader component required by PageHeadStyle
5382 property Item pageStack
5483 property Item contents
55− property string title: root.title
84+ property string title
5685 property var tabsModel
5786 property var config: QtObject {
58− property color foregroundColor: theme.palette.selected.backgroundText
59− property var sections
87+ property color foregroundColor: styledItem.theme.palette.selected.backgroundText
88+ property var sections: QtObject {}
6089 }
6190
6291 // FIXME: should instead use future toolkit API:
6392 // style: theme.createStyleComponent("PageHeadStyle.qml", header)
64− style: Component { PageHeadStyle {theme: root.theme} }
93+ style: Component { PageHeadStyle {theme: styledItem.theme} }
6594 }
6695
6796 Image {
6897 id: overlaidImage
6998 anchors.centerIn: parent
70− anchors.verticalCenterOffset: root.showHeader ? header.height / 2 : 0
99+ anchors.verticalCenterOffset: header.visible ? header.height / 2 : 0
71100 sourceSize {
72101 width: root.width
73102 height: root.height
74103 }
75− source: root.image
76104 asynchronous: true
77105 cache: false
78106 }
79107
80108 ActivityIndicator {
81109 anchors.centerIn: parent
82− anchors.verticalCenterOffset: root.showHeader ? header.height / 2 : 0
110+ anchors.verticalCenterOffset: header.visible ? header.height / 2 : 0
83111 running: overlaidImage.status == Image.Error || overlaidImage.status == Image.Null
84112 }
85113
tests/mocks/Unity/Application/ApplicationInfo.h+7
@@ -68,6 +68,13 @@ public:
6868 void setFocused(bool value);
6969 bool focused() const override { return m_focused; }
7070
71+ QString splashTitle() const override { return QString(); }
72+ QUrl splashImage() const override { return QUrl(); }
73+ bool splashShowHeader() const override { return true; }
74+ QColor splashColor() const override { return QColor(0,0,0,0); }
75+ QColor splashColorHeader() const override { return QColor(0,0,0,0); }
76+ QColor splashColorFooter() const override { return QColor(0,0,0,0); }
77+
7178 QString screenshot() const { return m_screenshotFileName; }
7279
7380 void setFullscreen(bool value);
tests/mocks/Unity/Application/CMakeLists.txt+1−1
@@ -1,4 +1,4 @@
1−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=3)
1+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=4)
22
33set(FakeUnityApplicationQml_SOURCES
44 plugin.cpp
tests/plugins/Unity/Launcher/CMakeLists.txt+1−1
@@ -1,6 +1,6 @@
11pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
22pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
3−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=3)
3+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=4)
44
55include_directories(
66 ${CMAKE_CURRENT_BINARY_DIR}
tests/plugins/Unity/Launcher/launchermodeltest.cpp+6−1
@@ -39,7 +39,12 @@ public:
3939 ApplicationInfoInterface::Stage stage() const { return ApplicationInfoInterface::MainStage; }
4040 ApplicationInfoInterface::State state() const { return ApplicationInfoInterface::Running; }
4141 bool focused() const { return m_focused; }
42− QUrl screenshot() const { return QUrl(); }
42+ QString splashTitle() const override { return QString(); }
43+ QUrl splashImage() const override { return QUrl(); }
44+ bool splashShowHeader() const override { return true; }
45+ QColor splashColor() const override { return QColor(0,0,0,0); }
46+ QColor splashColorHeader() const override { return QColor(0,0,0,0); }
47+ QColor splashColorFooter() const override { return QColor(0,0,0,0); }
4348
4449 // Methods used for mocking (not in the interface)
4550 void setFocused(bool focused) { m_focused = focused; Q_EMIT focusedChanged(focused); }
tests/qmltests/CMakeLists.txt+1
@@ -87,3 +87,4 @@ add_qml_test(Stages PhoneStage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/
8787add_qml_test(Stages SpreadDelegate ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
8888add_qml_test(Stages SurfaceContainer ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
8989add_qml_test(Stages SessionContainer ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
90+add_qml_test(Stages Splash)
tests/qmltests/Components/tst_DragHandle/HorizontalShowable.qml+1−1
@@ -49,7 +49,7 @@ Showable {
4949 showAnimation: StandardAnimation { property: animatedProp; to: propValueWhenShown }
5050 hideAnimation: StandardAnimation { property: animatedProp; to: propValueWhenHidden }
5151
52− Image { source: "UnityLogo.png"; anchors.fill: parent }
52+ Image { source: "../../UnityLogo.png"; anchors.fill: parent }
5353
5454 DragHandle {
5555 objectName: "leftwardsDragHandle"
tests/qmltests/Components/tst_DragHandle/VerticalShowable.qml+1−1
@@ -49,7 +49,7 @@ Showable {
4949 showAnimation: StandardAnimation { property: animatedProp; to: propValueWhenShown }
5050 hideAnimation: StandardAnimation { property: animatedProp; to: propValueWhenHidden }
5151
52− Image { source: "UnityLogo.png"; anchors.fill: parent }
52+ Image { source: "../../UnityLogo.png"; anchors.fill: parent }
5353
5454 DragHandle {
5555 objectName: "upwardsDragHandle"
tests/qmltests/Stages/tst_Splash.qmlnew file+110
@@ -0,0 +1,110 @@
1+/*
2+ * Copyright 2014 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0
18+import QtTest 1.0
19+import Unity.Test 0.1 as UT
20+import ".."
21+import "../../../qml/Stages"
22+import Ubuntu.Components 0.1
23+import Unity.Application 0.1
24+
25+Rectangle {
26+ color: "black"
27+ id: root
28+ width: units.gu(70)
29+ height: units.gu(70)
30+
31+ Component {
32+ id: splashComponent
33+ Splash {
34+ anchors.fill: parent
35+ title: "Splash Title"
36+ showHeader: showHeaderCheckbox.checked
37+ imageSource: imageSourceCheckbox.checked ? "../UnityLogo.png" : ""
38+ backgroundColor: backgroundColorCheckbox.checked ? "darkorange" : "#00000000"
39+ headerColor: headerColorCheckbox.checked ? "mediumseagreen" : "#00000000"
40+ footerColor: footerColorCheckbox.checked ? "teal" : "#00000000"
41+ }
42+ }
43+ Loader {
44+ id: splashLoader
45+ anchors {
46+ top: parent.top
47+ bottom: parent.bottom
48+ left: parent.left
49+ }
50+ width: units.gu(40)
51+ sourceComponent: splashComponent
52+ }
53+
54+ Rectangle {
55+ color: "white"
56+ anchors {
57+ top: parent.top
58+ bottom: parent.bottom
59+ left: splashLoader.right
60+ right: parent.right
61+ }
62+
63+ Column {
64+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
65+ spacing: units.gu(1)
66+
67+ Row {
68+ anchors { left: parent.left; right: parent.right }
69+ CheckBox {id: showHeaderCheckbox; checked: true; }
70+ Label { text: "showHeader"; anchors.verticalCenter: parent.verticalCenter }
71+ }
72+ Row {
73+ anchors { left: parent.left; right: parent.right }
74+ CheckBox {id: imageSourceCheckbox; checked: false; }
75+ Label { text: "imageSource"; anchors.verticalCenter: parent.verticalCenter }
76+ }
77+ Row {
78+ anchors { left: parent.left; right: parent.right }
79+ CheckBox {id: backgroundColorCheckbox; checked: false; }
80+ Label { text: "custom backgroundColor"; anchors.verticalCenter: parent.verticalCenter }
81+ }
82+ Row {
83+ anchors { left: parent.left; right: parent.right }
84+ CheckBox {id: headerColorCheckbox; checked: false; }
85+ Label { text: "custom headerColor"; anchors.verticalCenter: parent.verticalCenter }
86+ }
87+ Row {
88+ anchors { left: parent.left; right: parent.right }
89+ CheckBox {id: footerColorCheckbox; checked: false; }
90+ Label { text: "custom footerColor"; anchors.verticalCenter: parent.verticalCenter }
91+ }
92+ }
93+ }
94+
95+ UT.UnityTestCase {
96+ id: testCase
97+ name: "Splash"
98+ when: windowShown
99+
100+ function cleanup() {
101+ // reload our test subject to get it in a fresh state once again
102+ splashLoader.active = false;
103+ surfaceCheckbox.checked = false;
104+ splashLoader.active = true;
105+ }
106+
107+ // No automated tests so far. Used only for manual testing at the moment.
108+ }
109+}
110+
tests/qmltests/Components/tst_DragHandle/UnityLogo.png → tests/qmltests/UnityLogo.pngrenamed

Binary file not shown.