Skip to content

Commit c7af1e9

Browse files
committed
Add mnemonics for better experience
Fixes #643
1 parent e713a46 commit c7af1e9

File tree

8 files changed

+326
-113
lines changed

8 files changed

+326
-113
lines changed

src/app/qml/AboutDialog.qml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ ApplicationWindow {
3939
anchors.fill: parent
4040
anchors.margins: units.gridUnit
4141
spacing: units.gridUnit
42+
focus: true
4243

4344
Column {
4445
leftPadding: units.gridUnit
@@ -95,5 +96,16 @@ ApplicationWindow {
9596
text: qsTr("Close")
9697
}
9798
}
99+
100+
Keys.onPressed: (event)=> {
101+
switch (event.key) {
102+
case (Qt.Key_Escape):
103+
case (Qt.Key_Enter):
104+
case (Qt.Key_Return):
105+
case (Qt.Key_I):
106+
aboutDialog.close()
107+
break
108+
}
109+
}
98110
}
99111
}

src/app/qml/CancelDialog.qml

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ ApplicationWindow {
4343
anchors.fill: parent
4444
anchors.margins: units.gridUnit
4545
spacing: units.gridUnit
46+
focus: true
4647

4748
Column {
4849
leftPadding: units.gridUnit
@@ -90,22 +91,7 @@ ApplicationWindow {
9091

9192
Button {
9293
id: cancelButton
93-
onClicked: {
94-
cancelDialog.close()
95-
// Store release state locally as drives.selected.cancel() makes
96-
// it go to failed state if we cancel the writing process
97-
var releaseState = releases.variant.status
98-
if (drives.selected)
99-
drives.selected.cancel()
100-
if (mainWindow.selectedPage == Units.Page.DownloadPage &&
101-
(releaseState === Units.DownloadStatus.Writing || releaseState === Units.DownloadStatus.Write_Verifying || releaseState === Units.DownloadStatus.Writing_Not_Possible)) {
102-
drives.lastRestoreable = drivesSelected
103-
drives.lastRestoreable.setRestoreStatus(Units.RestoreStatus.Contains_Live)
104-
}
105-
releases.variant.resetStatus()
106-
downloadManager.cancel()
107-
selectedPage = Units.Page.MainPage
108-
}
94+
onClicked: cancelWrite()
10995
text: {
11096
if (releases.variant.status == Units.DownloadStatus.Downloading || releases.variant.status === Units.DownloadStatus.Download_Verifying)
11197
qsTr("Cancel Download")
@@ -118,6 +104,37 @@ ApplicationWindow {
118104
}
119105
}
120106
}
107+
Keys.onPressed: (event)=> {
108+
switch (event.key) {
109+
case (Qt.Key_Escape):
110+
cancelDialog.close()
111+
break
112+
case (Qt.Key_Return):
113+
case (Qt.Key_Enter):
114+
if (cancelDialog.visible)
115+
cancelWrite()
116+
else
117+
cancelDialog.show()
118+
break
119+
}
120+
}
121+
}
122+
123+
function cancelWrite() {
124+
cancelDialog.close()
125+
// Store release state locally as drives.selected.cancel() makes
126+
// it go to failed state if we cancel the writing process
127+
var releaseState = releases.variant.status
128+
if (drives.selected)
129+
drives.selected.cancel()
130+
if (mainWindow.selectedPage == Units.Page.DownloadPage &&
131+
(releaseState === Units.DownloadStatus.Writing || releaseState === Units.DownloadStatus.Write_Verifying || releaseState === Units.DownloadStatus.Writing_Not_Possible)) {
132+
drives.lastRestoreable = drivesSelected
133+
drives.lastRestoreable.setRestoreStatus(Units.RestoreStatus.Contains_Live)
134+
}
135+
releases.variant.resetStatus()
136+
downloadManager.cancel()
137+
selectedPage = Units.Page.MainPage
121138
}
122139
}
123140

src/app/qml/DownloadPage.qml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,18 @@ Page {
338338
}
339339
}
340340

341+
StackView.onActivated: {
342+
prevButton.text = qsTr("Cancel")
343+
if (releases.variant.status === Units.DownloadStatus.Write_Verifying || releases.variant.status === Units.DownloadStatus.Writing || releases.variant.status === Units.DownloadStatus.Downloading || releases.variant.status === Units.DownloadStatus.Download_Verifying)
344+
nextButton.text = qsTr("Cancel")
345+
else if (releases.variant.status == Units.DownloadStatus.Ready)
346+
nextButton.text = qsTr("Write")
347+
else if (releases.variant.status === Units.DownloadStatus.Finished)
348+
nextButton.text = qsTr("Finish")
349+
else
350+
nextButton.text = qsTr("Retry")
351+
}
352+
341353
function getPrevButtonState() {
342354
// There will be only [Finish] button on the right side so [Cancel] button
343355
// is not necessary
@@ -357,5 +369,30 @@ Page {
357369

358370
return false
359371
}
372+
373+
function setNextPage() {
374+
if (releases.variant.status === Units.DownloadStatus.Finished) {
375+
drives.lastRestoreable = drives.selected
376+
drives.lastRestoreable.setRestoreStatus(Units.RestoreStatus.Contains_Live)
377+
releases.variant.resetStatus()
378+
downloadManager.cancel()
379+
selectedPage = Units.Page.MainPage
380+
} else if ((releases.variant.status === Units.DownloadStatus.Failed && drives.length) || releases.variant.status === Units.DownloadStatus.Failed_Download || (releases.variant.status === Units.DownloadStatus.Failed_Verification && drives.length) || releases.variant.status === Units.DownloadStatus.Ready) {
381+
if (selectedOption != Units.MainSelect.Write)
382+
releases.variant.download()
383+
drives.selected.setImage(releases.variant)
384+
drives.selected.write(releases.variant)
385+
}
386+
}
387+
388+
function setPreviousPage() {
389+
if (releases.variant.status === Units.DownloadStatus.Write_Verifying || releases.variant.status === Units.DownloadStatus.Writing || releases.variant.status === Units.DownloadStatus.Downloading || releases.variant.status === Units.DownloadStatus.Download_Verifying) {
390+
cancelDialog.show()
391+
} else {
392+
releases.variant.resetStatus()
393+
downloadManager.cancel()
394+
mainWindow.selectedPage = Units.Page.MainPage
395+
}
396+
}
360397
}
361398

src/app/qml/DrivePage.qml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ Page {
157157
}
158158

159159
CheckBox {
160+
id: deleteCheck
160161
text: qsTr("Delete download after writing")
161162
onCheckedChanged: mainWindow.eraseVariant = !mainWindow.eraseVariant
162163
}
@@ -181,4 +182,97 @@ Page {
181182
PropertyChanges { target: nextButton; enabled: driveCombo.enabled && releases.localFile.iso }
182183
}
183184
]
185+
186+
Keys.onPressed: (event)=> {
187+
if (drivePage.state == "Downloading") {
188+
switch (event.key) {
189+
case (Qt.Key_1):
190+
closePopups()
191+
if (!versionCombo.down)
192+
versionCombo.popup.open()
193+
break
194+
case (Qt.Key_2):
195+
closePopups()
196+
if (!hwArchCombo.down)
197+
hwArchCombo.popup.open()
198+
break
199+
case (Qt.Key_3):
200+
closePopups()
201+
if (!driveCombo.down && driveCombo.count)
202+
driveCombo.popup.open()
203+
break
204+
case (Qt.Key_D):
205+
case (Qt.Key_4):
206+
deleteCheck.checked = !deleteCheck.checked
207+
break
208+
case (Qt.Key_Return):
209+
case (Qt.Key_Enter):
210+
closePopups()
211+
break
212+
case (Qt.Key_Up):
213+
if (versionCombo.down && versionCombo.currentIndex > 0)
214+
versionCombo.currentIndex -= 1
215+
else if (hwArchCombo.down && hwArchCombo.currentIndex > 0)
216+
hwArchCombo.currentIndex -= 1
217+
else if (driveCombo.down && driveCombo.currentIndex > 0)
218+
driveCombo.currentIndex -= 1
219+
break
220+
case (Qt.Key_Down):
221+
if (versionCombo.down && versionCombo.currentIndex < versionCombo.count - 1)
222+
versionCombo.currentIndex += 1
223+
else if (hwArchCombo.down && hwArchCombo.currentIndex < hwArchCombo.count - 1)
224+
hwArchCombo.currentIndex += 1
225+
else if (driveCombo.down && driveCombo.currentIndex < driveCombo.count - 1)
226+
driveCombo.currentIndex += 1
227+
break
228+
}
229+
} else {
230+
switch (event.key) {
231+
case (Qt.Key_1):
232+
if (portalFileDialog.isAvailable)
233+
portalFileDialog.open()
234+
else
235+
fileDialog.open()
236+
break
237+
case (Qt.Key_2):
238+
driveCombo.focus = true
239+
break
240+
}
241+
}
242+
}
243+
244+
StackView.onActivated: {
245+
prevButton.text = qsTr("Previous")
246+
if (selectedOption == Units.MainSelect.Write || downloadManager.isDownloaded(releases.selected.version.variant.url))
247+
nextButton.text = qsTr("Write")
248+
else if (Qt.platform.os === "windows" || Qt.platform.os === "osx")
249+
nextButton.text = qsTr("Download && Write")
250+
else
251+
nextButton.text = qsTr("Download & Write")
252+
}
253+
254+
function setNextPage() {
255+
selectedPage = Units.Page.DownloadPage
256+
if (selectedOption != Units.MainSelect.Write)
257+
releases.variant.download()
258+
if (drives.length) {
259+
drives.selected.setImage(releases.variant)
260+
drives.selected.write(releases.variant)
261+
}
262+
}
263+
264+
function setPreviousPage() {
265+
if (selectedOption == Units.MainSelect.Write)
266+
selectedPage = Units.Page.MainPage
267+
else {
268+
selectedPage -= 1
269+
stackView.pop()
270+
}
271+
}
272+
273+
function closePopups() {
274+
versionCombo.popup.close()
275+
hwArchCombo.popup.close()
276+
driveCombo.popup.close()
277+
}
184278
}

src/app/qml/MainPage.qml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Page {
6262
}
6363

6464
RadioButton {
65+
checked: mainWindow.selectedOption == Units.MainSelect.Write
6566
text: qsTr("Select .iso file")
6667
onClicked: {
6768
selectedOption = Units.MainSelect.Write
@@ -73,6 +74,7 @@ Page {
7374
RadioButton {
7475
id: restoreRadio
7576
visible: drives.lastRestoreable
77+
checked: mainWindow.selectedOption == Units.MainSelect.Restore
7678
text: drives.lastRestoreable ? qsTr("Restore <b>%1</b>").arg(drives.lastRestoreable.name) : ""
7779
onClicked: {
7880
selectedOption = Units.MainSelect.Restore
@@ -91,4 +93,39 @@ Page {
9193
}
9294
}
9395
}
96+
97+
StackView.onActivated: {
98+
prevButton.text = qsTr("About")
99+
nextButton.text = qsTr("Next")
100+
}
101+
102+
function setNextPage() {
103+
if (mainWindow.selectedOption == Units.MainSelect.Write) {
104+
if (releases.localFile.iso)
105+
releases.selectLocalFile()
106+
mainWindow.selectedPage = Units.Page.DrivePage
107+
} else if (selectedOption == Units.MainSelect.Restore)
108+
mainWindow.selectedPage = Units.Page.RestorePage
109+
else
110+
mainWindow.selectedPage = Units.Page.VersionPage
111+
}
112+
113+
function setPreviousPage() {
114+
aboutDialog.show()
115+
}
116+
117+
Keys.onPressed: (event)=> {
118+
switch (event.key) {
119+
case (Qt.Key_1):
120+
mainWindow.selectedOption = Units.MainSelect.Download
121+
break
122+
case (Qt.Key_2):
123+
mainWindow.selectedOption = Units.MainSelect.Write
124+
break
125+
case (Qt.Key_3):
126+
if (restoreRadio.visible)
127+
mainWindow.selectedOption = Units.MainSelect.Restore
128+
break
129+
}
130+
}
94131
}

src/app/qml/RestorePage.qml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,23 @@ Page {
179179
}
180180
}
181181
]
182+
183+
StackView.onActivated: {
184+
prevButton.text = qsTr("Previous")
185+
if (lastRestoreable && lastRestoreable.restoreStatus == Units.RestoreStatus.Restored)
186+
nextButton.text = qsTr("Finish")
187+
else
188+
nextButton.text = qsTr("Restore")
189+
}
190+
191+
function setNextPage() {
192+
if (lastRestoreable && lastRestoreable.restoreStatus == Units.RestoreStatus.Restored)
193+
selectedPage = Units.Page.MainPage
194+
else
195+
drives.lastRestoreable.restore()
196+
}
197+
198+
function setPreviousPage() {
199+
selectedPage = Units.Page.MainPage
200+
}
182201
}

0 commit comments

Comments
 (0)