on bb09f86 help sign in
unity8/qml/Stage/Splash.qml
150 lines 5.4 kB history raw
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*/
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19import Ubuntu.Components.Themes 1.3
20import "../Components"
22import Ubuntu.Components.Themes.Ambiance 1.3 as Ambiance
24Item {
25 id: root
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 url icon
32 property alias title: header.title
33 property alias showHeader: header.visible
35 Ambiance.Palette {
36 id: ambiancePalette
37 }
39 QtObject {
40 id: d
42 // As specified in qtmir, it will set the color value to this for fields left undefined
43 // This is also the default value of a color property in QML.
44 readonly property color undefinedColor: "#00000000"
46 readonly property color defaultBackgroundColor: header.visible ? ambiancePalette.normal.background : "black"
48 // Splash screen that shows the application icon and splashTitle
49 readonly property bool showIcon: overlaidImage.status == Image.Null && !root.showHeader
50 }
52 StyledItem {
53 id: styledItem
54 anchors.fill: parent
56 // mimic API of toolkit's MainView component required by MainViewStyle
57 property color backgroundColor: Qt.colorEqual(root.backgroundColor, d.undefinedColor) ? d.defaultBackgroundColor
58 : root.backgroundColor
59 property color headerColor: Qt.colorEqual(root.headerColor, d.undefinedColor) ? styledItem.backgroundColor
60 : root.headerColor
61 property color footerColor: Qt.colorEqual(root.footerColor, d.undefinedColor) ? styledItem.backgroundColor
62 : root.footerColor
64 // FIXME: fake a Theme object as to expose the Palette corresponding to the backgroundColor (see MainViewStyle.qml)
65 readonly property var fakeTheme: QtObject {
66 property string name
67 property Palette palette: Qt.createQmlObject("import QtQuick 2.4;\
68 import Ubuntu.Components.Themes.%1 1.3;\
69 Palette {}".arg(styledItem.fakeTheme.name),
70 styledItem, "dynamicPalette");
71 }
73 // FIXME: should instead use future toolkit API:
74 // style: theme.createStyleComponent("MainViewStyle.qml", styledItem)
75 style: Component { MainViewStyle {theme: styledItem.fakeTheme} }
76 }
78 PageHeader {
79 id: header
80 anchors { left: parent.left; right: parent.right }
81 StyleHints {
82 foregroundColor: styledItem.fakeTheme.palette.normal.backgroundText
83 backgroundColor: "transparent"
84 dividerColor: styledItem.fakeTheme.palette.normal.base
85 }
86 }
88 Image {
89 id: overlaidImage
90 anchors.centerIn: parent
91 anchors.verticalCenterOffset: header.visible ? header.height / 2 : 0
92 sourceSize {
93 width: root.width
94 height: root.height
95 }
96 asynchronous: true
97 cache: false
98 }
100 UbuntuShape {
101 id: iconShape
102 anchors.horizontalCenter: parent.horizontalCenter
103 anchors.verticalCenter: parent.verticalCenter
104 anchors.verticalCenterOffset: -units.gu(4)
105 width: units.gu(8)
106 height: units.gu(7.5)
108 visible: d.showIcon
110 radius: "medium"
111 aspect: UbuntuShape.Flat
112 sourceFillMode: Image.PreserveAspectCrop
113 source: Image {
114 id: iconImage
115 sourceSize.width: iconShape.width
116 sourceSize.height: iconShape.height
117 source: d.showIcon ? root.icon : ""
118 }
119 }
121 Label {
122 id: titleLabel
123 text: root.title
124 anchors.horizontalCenter: parent.horizontalCenter
125 anchors.top: iconShape.bottom
126 anchors.topMargin: units.gu(2)
127 fontSize: "large"
129 color: styledItem.fakeTheme.palette.normal.backgroundText
130 visible: d.showIcon
131 }
133 Timer {
134 interval: 2000
135 onTriggered: spinner.running = true
136 running: true
137 }
139 ActivityIndicator {
140 id: spinner
141 anchors.centerIn: parent
142 anchors.verticalCenterOffset: header.visible ? header.height / 2 : Math.max(titleLabel.y / 2, units.gu(8))
143 }
145 MouseArea {
146 anchors.fill: parent
147 enabled: parent.visible
148 // absorb all mouse events
149 }