on xenial help sign in
Merge florian's real_header_splashscreen
commitb020fe45459cc78a4f076e911cff321e1846cad7 authorFlorian Boucault <florian.boucault@canonical.com> dateFri 12 Sep 2014, 13:26 (12 years ago) parent6798389ea24632
11 files changed+234−136
qml/Stages/ApplicationWindow.qml+18−1 qml/Stages/Dot.qml−25 qml/Stages/MainViewStyle.qml+78 qml/Stages/PageHeadStyle.qml+76 qml/Stages/PhoneStage.qml+2−2 qml/Stages/Splash.qml+55−32 qml/Stages/WaitingDots.qml−76 qml/Stages/graphics/PageHeaderBaseDividerBottom@18.png qml/Stages/graphics/PageHeaderBaseDividerLight@18.png qml/Stages/graphics/PageHeaderBaseDividerLight@18.sci+5 qml/Stages/graphics/background_paper@27.png
qml/Stages/ApplicationWindow.qml+18−1
@@ -103,7 +103,24 @@ Item {
103103 active: false
104104 anchors.fill: parent
105105 sourceComponent: Component {
106− Splash { name: d.name; image: d.icon }
106+ Splash {
107+ id: splash
108+ title: d.splashTitle ? d.splashTitle : d.name
109+ image: d.splashImage
110+ 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+ }
123+ }
107124 }
108125 }
109126
qml/Stages/Dot.qmldeleted−25
@@ -1,25 +0,0 @@
1−/*
2− * Copyright (C) 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 Ubuntu.Components 0.1
19−
20−Rectangle {
21− radius: width
22− width: units.dp(6)
23− height: width
24− color: UbuntuColors.orange
25−}
qml/Stages/MainViewStyle.qmlnew file+78
@@ -0,0 +1,78 @@
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 Lesser 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 Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+import QtQuick 2.0
17+import Ubuntu.Components 1.1
18+
19+// FIXME: copied with slight modifications from Ubuntu UI Toolkit's Ambiance's theme
20+Item {
21+ // styling properties
22+ anchors.fill: parent
23+ z: -1
24+ id: mainViewStyle
25+
26+ /*!
27+ The background texture of the main view. The image will be drawn over the background color,
28+ so if it has (semi-)transparent pixels, in those pixels the background color will be visible.
29+ */
30+ property url backgroundSource: "artwork/background_paper.png"
31+ property var theme
32+
33+ Gradient {
34+ id: backgroundGradient
35+ GradientStop { position: 0.0; color: styledItem.headerColor }
36+ GradientStop { position: 0.83; color: styledItem.backgroundColor }
37+ GradientStop { position: 1.0; color: styledItem.footerColor }
38+ }
39+
40+ Rectangle {
41+ id: backgroundColor
42+ anchors.fill: parent
43+ color: styledItem.backgroundColor
44+ gradient: internals.isGradient ? backgroundGradient : null
45+ }
46+
47+ Image {
48+ id: backgroundTexture
49+ anchors.fill: parent
50+ source: mainViewStyle.backgroundSource
51+ fillMode: Image.Tile
52+ asynchronous: true
53+ cache: false
54+ }
55+
56+ QtObject {
57+ id: internals
58+ property bool isGradient: styledItem.backgroundColor != styledItem.headerColor ||
59+ styledItem.backgroundColor != styledItem.footerColor
60+ /*
61+ As we don't know the order the property bindings and onXXXChanged signals are evaluated
62+ we should rely only on one property when changing the theme to avoid intermediate
63+ theme changes due to properties being evaluated separately.
64+
65+ Qt bug: https://bugreports.qt-project.org/browse/QTBUG-11712
66+ */
67+ property string theme: (ColorUtils.luminance(styledItem.backgroundColor) >= 0.85) ? "Ambiance" :
68+ (isGradient ? "SuruGradient" : "SuruDark")
69+ }
70+
71+ // automatically select the appropriate theme depending on the background colors
72+ Binding {
73+ target: theme
74+ property: "name"
75+ value: internals.theme
76+ when: internals.theme !== ""
77+ }
78+}
qml/Stages/PageHeadStyle.qmlnew file+76
@@ -0,0 +1,76 @@
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 Lesser 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 Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+import QtQuick 2.2
17+import Ubuntu.Components 1.1
18+import Ubuntu.Components.Styles 1.1 as Style
19+
20+// FIXME: copied with large modifications from Ubuntu UI Toolkit's Ambiance's theme
21+Style.PageHeadStyle {
22+ id: headerStyle
23+
24+ contentHeight: units.gu(7)
25+ separatorSource: "graphics/PageHeaderBaseDividerLight.sci"
26+ separatorBottomSource: "graphics/PageHeaderBaseDividerBottom.png"
27+ fontWeight: Font.Light
28+ fontSize: "x-large"
29+ textColor: styledItem.config.foregroundColor
30+ textLeftMargin: units.gu(2)
31+
32+ implicitHeight: headerStyle.contentHeight
33+
34+ property var theme
35+
36+ Label {
37+ anchors {
38+ left: parent.left
39+ leftMargin: headerStyle.textLeftMargin
40+ right: parent.right
41+ verticalCenter: parent.verticalCenter
42+ }
43+ LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft
44+ text: styledItem.title
45+ font.weight: headerStyle.fontWeight
46+ fontSize: headerStyle.fontSize
47+ color: headerStyle.textColor
48+ elide: Text.ElideRight
49+ }
50+
51+ BorderImage {
52+ id: separator
53+ anchors {
54+ top: parent.bottom
55+ topMargin: separatorBottom.height
56+ left: parent.left
57+ right: parent.right
58+ }
59+ source: headerStyle.separatorSource
60+ height: styledItem.config.sections.model !== undefined ? units.gu(3) : units.gu(2)
61+ asynchronous: true
62+ cache: true
63+ }
64+
65+ Image {
66+ id: separatorBottom
67+ anchors {
68+ top: separator.bottom
69+ left: parent.left
70+ right: parent.right
71+ }
72+ source: headerStyle.separatorBottomSource
73+ asynchronous: true
74+ cache: true
75+ }
76+}
qml/Stages/PhoneStage.qml+2−2
@@ -14,7 +14,7 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−import QtQuick 2.0
17+import QtQuick 2.2
1818import Ubuntu.Components 0.1
1919import Ubuntu.Gestures 0.1
2020import Unity.Application 0.1
@@ -318,7 +318,7 @@ Rectangle {
318318 !snapAnimation.running &&
319319 priv.animateX
320320 UbuntuNumberAnimation {
321− duration: UbuntuAnimation.FastDuration
321+ duration: UbuntuAnimation.BriskDuration
322322 onRunningChanged: {
323323 if (!running && root.inverseProgress == 0) {
324324 spreadView.focusChanging = false;
qml/Stages/Splash.qml+55−32
@@ -14,50 +14,73 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515*/
1616
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
17+import QtQuick 2.2
18+import Ubuntu.Components 1.1
19+import Ubuntu.Components.Themes 0.1
1920import "../Components"
2021
21−Rectangle {
22+StyledItem {
2223 id: root
23− color: "black"
2424
25− property string name: ""
26− property url image: ""
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
2732
28− UbuntuShape {
29− id: iconShape
30− anchors.horizontalCenter: parent.horizontalCenter
31− anchors.verticalCenter: parent.verticalCenter
32− anchors.verticalCenterOffset: -units.gu(4)
33− width: units.gu(8)
34− height: units.gu(7.5)
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");
37+ }
38+
39+ // FIXME: should instead use future toolkit API:
40+ // style: theme.createStyleComponent("MainViewStyle.qml", root)
41+ style: Component { MainViewStyle {theme: root.theme} }
42+
43+ StyledItem {
44+ id: header
45+ anchors {
46+ left: parent.left
47+ right: parent.right
48+ }
3549
36− radius: "medium"
37− borderSource: "none"
50+ visible: root.showHeader
3851
39− image: Image {
40− id: iconImage
41− sourceSize.width: iconShape.width
42− sourceSize.height: iconShape.height
43− source: root.image
44− fillMode: Image.PreserveAspectCrop
52+ // mimic API of toolkit's AppHeader component required by PageHeadStyle
53+ property Item pageStack
54+ property Item contents
55+ property string title: root.title
56+ property var tabsModel
57+ property var config: QtObject {
58+ property color foregroundColor: theme.palette.selected.backgroundText
59+ property var sections
4560 }
61+
62+ // FIXME: should instead use future toolkit API:
63+ // style: theme.createStyleComponent("PageHeadStyle.qml", header)
64+ style: Component { PageHeadStyle {theme: root.theme} }
4665 }
4766
48− Label {
49− text: root.name
50− anchors.horizontalCenter: parent.horizontalCenter
51− anchors.top: iconShape.bottom
52− anchors.topMargin: units.gu(2)
53− fontSize: "large"
67+ Image {
68+ id: overlaidImage
69+ anchors.centerIn: parent
70+ anchors.verticalCenterOffset: root.showHeader ? header.height / 2 : 0
71+ sourceSize {
72+ width: root.width
73+ height: root.height
74+ }
75+ source: root.image
76+ asynchronous: true
77+ cache: false
5478 }
5579
56− WaitingDots {
57− visible: parent.visible
58− anchors.horizontalCenter: parent.horizontalCenter
59− anchors.bottom: parent.bottom
60− anchors.bottomMargin: units.gu(12)
80+ ActivityIndicator {
81+ anchors.centerIn: parent
82+ anchors.verticalCenterOffset: root.showHeader ? header.height / 2 : 0
83+ running: overlaidImage.status == Image.Error || overlaidImage.status == Image.Null
6184 }
6285
6386 MouseArea {
qml/Stages/WaitingDots.qmldeleted−76
@@ -1,76 +0,0 @@
1−/*
2− * Copyright (C) 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.2
18−import Ubuntu.Components 0.1
19−
20−Item {
21− id: waitingDots
22−
23− // center in parent; waitingDots has no size therefore anchors.centerIn cannot be used
24− x: parent.width / 2
25− y: parent.height / 2
26−
27− property var dots: [dot1, dot2, dot3]
28− property var vertices: [[-units.gu(1), -units.gu(1)],
29− [units.gu(1), -units.gu(1)],
30− [0, units.gu(1)]]
31− property int shift: 0
32−
33− function cycle () {
34− var n = vertices.length;
35− shift = (shift + 1) % n;
36−
37− for (var i = 0; i < n; i++) {
38− dots[i].x = vertices[(i+shift) % n][0];
39− dots[i].y = vertices[(i+shift) % n][1];
40− }
41− }
42−
43− Timer {
44− interval: 800
45− running: waitingDots.visible
46− repeat: true
47− triggeredOnStart: true
48− onTriggered: waitingDots.cycle()
49− }
50−
51−
52− Dot {
53− id: dot1
54− x: vertices[0][0]
55− y: vertices[0][1]
56− Behavior on x {XAnimator {duration: UbuntuAnimation.BriskDuration; easing: UbuntuAnimation.StandardEasing}}
57− Behavior on y {YAnimator {duration: UbuntuAnimation.BriskDuration; easing: UbuntuAnimation.StandardEasing}}
58− }
59−
60− Dot {
61− id: dot2
62− x: vertices[1][0]
63− y: vertices[1][1]
64− Behavior on x {XAnimator {duration: UbuntuAnimation.BriskDuration; easing: UbuntuAnimation.StandardEasing}}
65− Behavior on y {YAnimator {duration: UbuntuAnimation.BriskDuration; easing: UbuntuAnimation.StandardEasing}}
66−
67− }
68−
69− Dot {
70− id: dot3
71− x: vertices[2][0]
72− y: vertices[2][1]
73− Behavior on x {XAnimator {duration: UbuntuAnimation.BriskDuration; easing: UbuntuAnimation.StandardEasing}}
74− Behavior on y {YAnimator {duration: UbuntuAnimation.BriskDuration; easing: UbuntuAnimation.StandardEasing}}
75− }
76−}
qml/Stages/graphics/PageHeaderBaseDividerBottom@18.pngnew file

Binary file not shown.

qml/Stages/graphics/PageHeaderBaseDividerLight@18.pngnew file

Binary file not shown.

qml/Stages/graphics/PageHeaderBaseDividerLight@18.scinew file+5
@@ -0,0 +1,5 @@
1+border.top: 4
2+border.bottom: 0
3+border.left: 0
4+border.right: 0
5+source: PageHeaderBaseDividerLight@18.png
qml/Stages/graphics/background_paper@27.pngnew file

Binary file not shown.