This repository has been archived by the owner on Jan 28, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Softwareupdate.qml
executable file
Β·169 lines (149 loc) Β· 5.65 KB
/
Softwareupdate.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import QtQuick 2.11
import QtQuick.Controls 2.5
import "qrc:/scripts/helper.js" as JSHelper
import "qrc:/scripts/softwareupdate.js" as JSUpdate
import "qrc:/basic_ui" as BasicUI
Item {
width: parent.width
height: header.height + section.height + 20
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DISPLAY
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Text {
id: header
color: colorText
text: qsTr("Software update") + translateHandler.emptyString
anchors.left: parent.left
font.family: "Open Sans"
font.weight: Font.Normal
font.pixelSize: 27
lineHeight: 1
}
Rectangle {
id: section
width: parent.width
height: childrenRect.height + 50 //softwareUpdateText.height + smallText.height + 60
radius: cornerRadius
color: colorDark
anchors.top: header.bottom
anchors.topMargin: 20
Text {
id: softwareUpdateText
color: colorText
text: qsTr("Auto update") + translateHandler.emptyString
anchors.left: parent.left
anchors.leftMargin: 20
anchors.top: parent.top
anchors.topMargin: 20
font.family: "Open Sans"
font.weight: Font.Normal
font.pixelSize: 27
lineHeight: 1
}
BasicUI.CustomSwitch {
id: softwareUpdateButton
anchors.right: parent.right
anchors.rightMargin: 20
anchors.verticalCenter: softwareUpdateText.verticalCenter
checked: config.settings.softwareupdate
mouseArea.onClicked: {
var tmp = config.config
tmp.settings.softwareupdate = !tmp.settings.softwareupdate
config.config = tmp
config.writeConfig();
}
}
Text {
id: smallText
color: colorText
opacity: 0.5
text: qsTr("Automatically look for updates and update when a new software version is available.\nUpdates are installed between 03.00 am and 05.00 am.") + translateHandler.emptyString
wrapMode: Text.WordWrap
width: parent.width - 40 - softwareUpdateButton.width
anchors.left: parent.left
anchors.leftMargin: 20
anchors.top: softwareUpdateButton.bottom
anchors.topMargin: 10
font.family: "Open Sans"
font.weight: Font.Normal
font.pixelSize: 20
lineHeight: 1
}
Rectangle {
id: line
width: parent.width
height: 2
color: colorBackground
anchors.top: smallText.bottom
anchors.topMargin: 20
}
Text {
id: uptodateText
color: colorText
text: updateAvailable ? qsTr("New software is available.\nYIO remote ") + _new_version + translateHandler.emptyString : qsTr("Your software is up to date.") + translateHandler.emptyString
wrapMode: Text.WordWrap
width: parent.width-40
anchors.left: parent.left
anchors.leftMargin: 20
anchors.top: line.bottom
anchors.topMargin: 20
font.family: "Open Sans"
font.weight: Font.Normal
font.pixelSize: 27
lineHeight: 1
}
Text {
id: uptodateTextsmall
color: colorText
opacity: 0.5
text: updateAvailable? qsTr("Installed version: YIO Remote ") + _current_version + translateHandler.emptyString : qsTr("YIO Remote ") + _current_version
wrapMode: Text.WordWrap
width: parent.width - 40
anchors.left: parent.left
anchors.leftMargin: 20
anchors.top: uptodateText.bottom
anchors.topMargin: 10
font.family: "Open Sans"
font.weight: Font.Normal
font.pixelSize: 20
lineHeight: 1
}
BasicUI.CustomButton {
id: updateButton
buttonText: qsTr("Update") + translateHandler.emptyString
anchors.top: uptodateTextsmall.bottom
anchors.topMargin: 30
anchors.left: parent.left
anchors.leftMargin: 20
visible: updateAvailable
mouseArea.onClicked: {
if (updateAvailable) {
console.debug("Updating the app")
// TODO create a update servcie class instead of launching hard coded shell scripts from QML
fileio.write("/usr/bin/updateURL", updateURL);
mainLauncher.launch("systemctl restart update.service");
}
Qt.quit();
}
}
Rectangle {
id: line2
width: parent.width
height: 2
color: colorBackground
anchors.top: updateAvailable ? updateButton.bottom : uptodateTextsmall.bottom
anchors.topMargin: 30
}
BasicUI.CustomButton {
id: checkforUpdateButton
buttonText: qsTr("Check for update") + translateHandler.emptyString
anchors.top: line2.bottom
anchors.topMargin: 30
anchors.left: parent.left
anchors.leftMargin: 20
mouseArea.onClicked: {
JSUpdate.checkForUpdate();
}
}
}
}