Skip to content

Commit

Permalink
Add mnemonics for better experience
Browse files Browse the repository at this point in the history
  • Loading branch information
gastoner committed Oct 7, 2023
1 parent e713a46 commit eb35f02
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 77 deletions.
6 changes: 6 additions & 0 deletions src/app/qml/AboutDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ApplicationWindow {
anchors.fill: parent
anchors.margins: units.gridUnit
spacing: units.gridUnit
focus: true

Column {
leftPadding: units.gridUnit
Expand Down Expand Up @@ -95,5 +96,10 @@ ApplicationWindow {
text: qsTr("Close")
}
}

Keys.onPressed: (event)=> {
if (event.key == Qt.Key_I)
aboutDialog.close()
}
}
}
49 changes: 33 additions & 16 deletions src/app/qml/CancelDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ApplicationWindow {
anchors.fill: parent
anchors.margins: units.gridUnit
spacing: units.gridUnit
focus: true

Column {
leftPadding: units.gridUnit
Expand Down Expand Up @@ -90,22 +91,7 @@ ApplicationWindow {

Button {
id: cancelButton
onClicked: {
cancelDialog.close()
// Store release state locally as drives.selected.cancel() makes
// it go to failed state if we cancel the writing process
var releaseState = releases.variant.status
if (drives.selected)
drives.selected.cancel()
if (mainWindow.selectedPage == Units.Page.DownloadPage &&
(releaseState === Units.DownloadStatus.Writing || releaseState === Units.DownloadStatus.Write_Verifying || releaseState === Units.DownloadStatus.Writing_Not_Possible)) {
drives.lastRestoreable = drivesSelected
drives.lastRestoreable.setRestoreStatus(Units.RestoreStatus.Contains_Live)
}
releases.variant.resetStatus()
downloadManager.cancel()
selectedPage = Units.Page.MainPage
}
onClicked: cancelWrite()
text: {
if (releases.variant.status == Units.DownloadStatus.Downloading || releases.variant.status === Units.DownloadStatus.Download_Verifying)
qsTr("Cancel Download")
Expand All @@ -118,6 +104,37 @@ ApplicationWindow {
}
}
}
Keys.onPressed: (event)=> {
switch (event.key) {
case (Qt.Key_Escape):
cancelDialog.close()
break
case (Qt.Key_Return):
case (Qt.Key_Enter):
if (cancelDialog.visible)
cancelWrite()
else
cancelDialog.show()
break
}
}
}

function cancelWrite() {
cancelDialog.close()
// Store release state locally as drives.selected.cancel() makes
// it go to failed state if we cancel the writing process
var releaseState = releases.variant.status
if (drives.selected)
drives.selected.cancel()
if (mainWindow.selectedPage == Units.Page.DownloadPage &&
(releaseState === Units.DownloadStatus.Writing || releaseState === Units.DownloadStatus.Write_Verifying || releaseState === Units.DownloadStatus.Writing_Not_Possible)) {
drives.lastRestoreable = drivesSelected
drives.lastRestoreable.setRestoreStatus(Units.RestoreStatus.Contains_Live)
}
releases.variant.resetStatus()
downloadManager.cancel()
selectedPage = Units.Page.MainPage
}
}

65 changes: 65 additions & 0 deletions src/app/qml/DrivePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ Page {
}

CheckBox {
id: deleteCheck
text: qsTr("Delete download after writing")
onCheckedChanged: mainWindow.eraseVariant = !mainWindow.eraseVariant
}
Expand All @@ -181,4 +182,68 @@ Page {
PropertyChanges { target: nextButton; enabled: driveCombo.enabled && releases.localFile.iso }
}
]

Keys.onPressed: (event)=> {
if (drivePage.state == "Downloading") {
switch (event.key) {
case (Qt.Key_1):
closePopups()
if (!versionCombo.down)
versionCombo.popup.open()
break
case (Qt.Key_2):
closePopups()
if (!hwArchCombo.down)
hwArchCombo.popup.open()
break
case (Qt.Key_3):
closePopups()
if (!driveCombo.down && driveCombo.count)
driveCombo.popup.open()
break
case (Qt.Key_D):
case (Qt.Key_4):
deleteCheck.checked = !deleteCheck.checked
break
case (Qt.Key_Return):
case (Qt.Key_Enter):
closePopups()
break
case (Qt.Key_Up):
if (versionCombo.down && versionCombo.currentIndex > 0)
versionCombo.currentIndex -= 1
else if (hwArchCombo.down && hwArchCombo.currentIndex > 0)
hwArchCombo.currentIndex -= 1
else if (driveCombo.down && driveCombo.currentIndex > 0)
driveCombo.currentIndex -= 1
break
case (Qt.Key_Down):
if (versionCombo.down && versionCombo.currentIndex < versionCombo.count - 1)
versionCombo.currentIndex += 1
else if (hwArchCombo.down && hwArchCombo.currentIndex < hwArchCombo.count - 1)
hwArchCombo.currentIndex += 1
else if (driveCombo.down && driveCombo.currentIndex < driveCombo.count - 1)
driveCombo.currentIndex += 1
break
}
} else {
switch (event.key) {
case (Qt.Key_1):
if (portalFileDialog.isAvailable)
portalFileDialog.open()
else
fileDialog.open()
break
case (Qt.Key_2):
driveCombo.focus = true
break
}
}
}

function closePopups() {
versionCombo.popup.close()
hwArchCombo.popup.close()
driveCombo.popup.close()
}
}
17 changes: 17 additions & 0 deletions src/app/qml/MainPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Page {
}

RadioButton {
checked: mainWindow.selectedOption == Units.MainSelect.Write
text: qsTr("Select .iso file")
onClicked: {
selectedOption = Units.MainSelect.Write
Expand All @@ -73,6 +74,7 @@ Page {
RadioButton {
id: restoreRadio
visible: drives.lastRestoreable
checked: mainWindow.selectedOption == Units.MainSelect.Restore
text: drives.lastRestoreable ? qsTr("Restore <b>%1</b>").arg(drives.lastRestoreable.name) : ""
onClicked: {
selectedOption = Units.MainSelect.Restore
Expand All @@ -91,4 +93,19 @@ Page {
}
}
}

Keys.onPressed: (event)=> {
switch (event.key) {
case (Qt.Key_1):
mainWindow.selectedOption = Units.MainSelect.Download
break
case (Qt.Key_2):
mainWindow.selectedOption = Units.MainSelect.Write
break
case (Qt.Key_3):
if (restoreRadio.visible)
mainWindow.selectedOption = Units.MainSelect.Restore
break
}
}
}
40 changes: 39 additions & 1 deletion src/app/qml/VersionPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import QtQml 6.2
Page {
id: versionPage
property int prevSource: 0
property int prevIndex: 0

ColumnLayout {
anchors.fill: parent
Expand All @@ -49,25 +50,28 @@ Page {
}

RadioButton {
checked: true
checked: releases.filterSource == Units.Source.Product
text: qsTr("Official Editions")
onClicked: changeFilter(Units.Source.Product)
ButtonGroup.group: radioGroup
}

RadioButton {
checked: releases.filterSource == Units.Source.Emerging
text: qsTr("Emerging Editions")
onClicked: changeFilter(Units.Source.Emerging)
ButtonGroup.group: radioGroup
}

RadioButton {
checked: releases.filterSource == Units.Source.Spins
text: qsTr("Spins")
onClicked: changeFilter(Units.Source.Spins)
ButtonGroup.group: radioGroup
}

RadioButton {
checked: releases.filterSource == Units.Source.Labs
text: qsTr("Labs")
onClicked: changeFilter(Units.Source.Labs)
ButtonGroup.group: radioGroup
Expand Down Expand Up @@ -102,4 +106,38 @@ Page {
releases.selectedIndex = parseInt(selectFromComboBox.currentValue)
}
}

Keys.onPressed: (event)=> {
switch (event.key) {
case (Qt.Key_1):
changeFilter(Units.Source.Product)
break
case (Qt.Key_2):
changeFilter(Units.Source.Emerging)
break
case (Qt.Key_3):
changeFilter(Units.Source.Spins)
break
case (Qt.Key_4):
changeFilter(Units.Source.Labs)
break
case (Qt.Key_Return):
case (Qt.Key_Enter):
if (selectFromComboBox.down)
selectFromComboBox.popup.close()
else
selectFromComboBox.popup.open()
break
case (Qt.Key_Up):
if (selectFromComboBox.down)
if (releases.firstSource < releases.selectedIndex)
selectFromComboBox.currentIndex -= 1
break
case (Qt.Key_Down):
if (selectFromComboBox.down)
if (selectFromComboBox.count > selectFromComboBox.currentIndex + 1)
selectFromComboBox.currentIndex += 1
break
}
}
}
Loading

0 comments on commit eb35f02

Please sign in to comment.