Lomiri
79-system-update.qml
1 /*
2  * Copyright (C) 2016 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.12
18 import QtQuick.Layouts 1.1
19 import Lomiri.Components 1.3
20 import Lomiri.SystemSettings.Update 1.0
21 import Wizard 0.1
22 import ".." as LocalComponents
23 
24 LocalComponents.Page {
25  id: systemUpdatePage
26  objectName: "systemUpdatePage"
27 
28  title: i18n.tr("Update Device")
29  forwardButtonSourceComponent: forwardButton
30 
31  skip: !root.updateDownloaded // skip the page when the system update is not ready to install
32 
33  Column {
34  id: column
35  anchors {
36  fill: content
37  leftMargin: systemUpdatePage.leftMargin
38  rightMargin: systemUpdatePage.rightMargin
39  topMargin: systemUpdatePage.customMargin
40  }
41  spacing: units.gu(3)
42  opacity: spinner.running ? 0.5 : 1
43  Behavior on opacity {
44  LomiriNumberAnimation {}
45  }
46 
47  Label {
48  anchors.left: parent.left
49  anchors.right: parent.right
50  anchors.leftMargin: column.anchors.leftMargin == 0 ? staticMargin : 0
51  font.weight: Font.Light
52  color: textColor
53  wrapMode: Text.Wrap
54  fontSize: "small"
55  text: i18n.tr("There is a system update available and ready to install. Afterwards, the device will automatically restart.")
56  }
57 
58  GridLayout {
59  rows: 3
60  columns: 2
61  rowSpacing: units.gu(1)
62  columnSpacing: units.gu(2)
63 
64  Image {
65  Layout.rowSpan: 3
66  Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
67  sourceSize: Qt.size(units.gu(3), units.gu(3))
68  fillMode: Image.PreserveAspectFit
69  source: "image://theme/distributor-logo"
70  }
71 
72  Label {
73  color: textColor
74  font.weight: Font.Normal
75  fontSize: "small"
76  text: i18n.ctr("string identifying name of the update", "Ubuntu Touch system")
77  }
78 
79  Label {
80  font.weight: Font.Light
81  fontSize: "small"
82  color: textColor
83  text: i18n.ctr("version of the system update", "Version %1").arg(SystemImage.targetBuildNumber)
84  }
85  }
86 
87  Label {
88  anchors.left: parent.left
89  anchors.right: parent.right
90  anchors.leftMargin: column.anchors.leftMargin == 0 ? staticMargin : 0
91  font.weight: Font.Light
92  color: textColor
93  wrapMode: Text.Wrap
94  fontSize: "small"
95  text: i18n.tr("This could take a few minutes...")
96  }
97 
98  Rectangle {
99  anchors.left: parent.left
100  anchors.leftMargin: column.anchors.leftMargin == 0 ? staticMargin : 0
101  color: theme.palette.normal.foreground
102  radius: units.dp(4)
103  width: buttonLabel.paintedWidth + units.gu(3)
104  height: buttonLabel.paintedHeight + units.gu(1.8)
105 
106  Label {
107  id: buttonLabel
108  color: textColor
109  text: i18n.tr("Install and restart now")
110  font.weight: Font.Light
111  anchors.centerIn: parent
112  }
113 
114  AbstractButton {
115  id: button
116  objectName: "installButton"
117  anchors.fill: parent
118  onClicked: {
119  System.skipUntilFinishedPage();
120  SystemImage.applyUpdate();
121  }
122  }
123 
124  transformOrigin: Item.Top
125  scale: button.pressed ? 0.98 : 1.0
126  Behavior on scale {
127  ScaleAnimator {
128  duration: LomiriAnimation.SnapDuration
129  easing.type: Easing.Linear
130  }
131  }
132  }
133  }
134 
135  ActivityIndicator {
136  id: spinner
137  anchors.centerIn: systemUpdatePage
138  visible: running
139  }
140 
141  Component {
142  id: forwardButton
143  LocalComponents.StackButton {
144  text: i18n.tr("Skip")
145  onClicked: pageStack.next()
146  }
147  }
148 }