diff --git a/src/app/qml/AboutDialog.qml b/src/app/qml/AboutDialog.qml index 8a717b79..963e4b49 100644 --- a/src/app/qml/AboutDialog.qml +++ b/src/app/qml/AboutDialog.qml @@ -39,6 +39,7 @@ ApplicationWindow { anchors.fill: parent anchors.margins: units.gridUnit spacing: units.gridUnit + focus: true Column { leftPadding: units.gridUnit @@ -95,5 +96,16 @@ ApplicationWindow { text: qsTr("Close") } } + + Keys.onPressed: (event)=> { + switch (event.key) { + case (Qt.Key_Escape): + case (Qt.Key_Enter): + case (Qt.Key_Return): + case (Qt.Key_I): + aboutDialog.close() + break + } + } } } diff --git a/src/app/qml/CancelDialog.qml b/src/app/qml/CancelDialog.qml index 933c8a82..050a1845 100644 --- a/src/app/qml/CancelDialog.qml +++ b/src/app/qml/CancelDialog.qml @@ -43,6 +43,7 @@ ApplicationWindow { anchors.fill: parent anchors.margins: units.gridUnit spacing: units.gridUnit + focus: true Column { leftPadding: units.gridUnit @@ -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") @@ -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 } } diff --git a/src/app/qml/DownloadPage.qml b/src/app/qml/DownloadPage.qml index d1439b40..631fd3f2 100644 --- a/src/app/qml/DownloadPage.qml +++ b/src/app/qml/DownloadPage.qml @@ -338,6 +338,18 @@ Page { } } + StackView.onActivated: { + prevButton.text = qsTr("Cancel") + 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) + nextButton.text = qsTr("Cancel") + else if (releases.variant.status == Units.DownloadStatus.Ready) + nextButton.text = qsTr("Write") + else if (releases.variant.status === Units.DownloadStatus.Finished) + nextButton.text = qsTr("Finish") + else + nextButton.text = qsTr("Retry") + } + function getPrevButtonState() { // There will be only [Finish] button on the right side so [Cancel] button // is not necessary @@ -357,5 +369,49 @@ Page { return false } + + function setNextPage() { + if (releases.variant.status === Units.DownloadStatus.Finished) { + drives.lastRestoreable = drives.selected + drives.lastRestoreable.setRestoreStatus(Units.RestoreStatus.Contains_Live) + releases.variant.resetStatus() + downloadManager.cancel() + selectedPage = Units.Page.MainPage + } 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) { + if (selectedOption != Units.MainSelect.Write) + releases.variant.download() + drives.selected.setImage(releases.variant) + drives.selected.write(releases.variant) + } + } + + function setPreviousPage() { + 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) { + cancelDialog.show() + } else { + releases.variant.resetStatus() + downloadManager.cancel() + mainWindow.selectedPage = Units.Page.MainPage + } + } + + Keys.onPressed: (event)=> { + switch (event.key) { + case (Qt.Key_Right): + case (Qt.Key_N): + setNextPage() + break + case (Qt.Key_Left): + case (Qt.Key_P): + setPreviousPage() + break + case (Qt.Key_Enter): + case (Qt.Key_Return): + case (Qt.Key_A): + if (releases.variant.status != Units.DownloadStatus.Finished) + cancelDialog.show() + break + } + } } diff --git a/src/app/qml/DrivePage.qml b/src/app/qml/DrivePage.qml index 8fade12a..c21c3651 100644 --- a/src/app/qml/DrivePage.qml +++ b/src/app/qml/DrivePage.qml @@ -157,6 +157,7 @@ Page { } CheckBox { + id: deleteCheck text: qsTr("Delete download after writing") onCheckedChanged: mainWindow.eraseVariant = !mainWindow.eraseVariant } @@ -181,4 +182,112 @@ Page { PropertyChanges { target: nextButton; enabled: driveCombo.enabled && releases.localFile.iso } } ] + + Keys.onPressed: (event)=> { + switch (event.key) { + case (Qt.Key_Right): + case (Qt.Key_N): + if (selectedOption == Units.MainSelect.Write) { + if (drives.length && releases.localFile.iso) + setNextPage() + } else + setNextPage() + break + case (Qt.Key_Left): + case (Qt.Key_P): + setPreviousPage() + break + } + + 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 + } + } + } + + StackView.onActivated: { + prevButton.text = qsTr("Previous") + if (selectedOption == Units.MainSelect.Write || downloadManager.isDownloaded(releases.selected.version.variant.url)) + nextButton.text = qsTr("Write") + else if (Qt.platform.os === "windows" || Qt.platform.os === "osx") + nextButton.text = qsTr("Download && Write") + else + nextButton.text = qsTr("Download & Write") + } + + function setNextPage() { + selectedPage = Units.Page.DownloadPage + if (selectedOption != Units.MainSelect.Write) + releases.variant.download() + if (drives.length) { + drives.selected.setImage(releases.variant) + drives.selected.write(releases.variant) + } + } + + function setPreviousPage() { + if (selectedOption == Units.MainSelect.Write) + selectedPage = Units.Page.MainPage + else { + selectedPage -= 1 + stackView.pop() + } + } + + function closePopups() { + versionCombo.popup.close() + hwArchCombo.popup.close() + driveCombo.popup.close() + } } diff --git a/src/app/qml/MainPage.qml b/src/app/qml/MainPage.qml index b880e993..4b3dd3e8 100644 --- a/src/app/qml/MainPage.qml +++ b/src/app/qml/MainPage.qml @@ -62,6 +62,7 @@ Page { } RadioButton { + checked: mainWindow.selectedOption == Units.MainSelect.Write text: qsTr("Select .iso file") onClicked: { selectedOption = Units.MainSelect.Write @@ -73,6 +74,7 @@ Page { RadioButton { id: restoreRadio visible: drives.lastRestoreable + checked: mainWindow.selectedOption == Units.MainSelect.Restore text: drives.lastRestoreable ? qsTr("Restore %1").arg(drives.lastRestoreable.name) : "" onClicked: { selectedOption = Units.MainSelect.Restore @@ -91,4 +93,50 @@ Page { } } } + + StackView.onActivated: { + prevButton.text = qsTr("About") + nextButton.text = qsTr("Next") + } + + function setNextPage() { + if (mainWindow.selectedOption == Units.MainSelect.Write) { + if (releases.localFile.iso) + releases.selectLocalFile() + mainWindow.selectedPage = Units.Page.DrivePage + } else if (selectedOption == Units.MainSelect.Restore) + mainWindow.selectedPage = Units.Page.RestorePage + else + mainWindow.selectedPage = Units.Page.VersionPage + } + + function setPreviousPage() { + aboutDialog.show() + } + + 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 + case (Qt.Key_I): + aboutDialog.show() + break + case (Qt.Key_Right): + case (Qt.Key_N): + setNextPage() + break + case (Qt.Key_Left): + case (Qt.Key_P): + setPreviousPage() + break + } + } } diff --git a/src/app/qml/RestorePage.qml b/src/app/qml/RestorePage.qml index e2e44cbf..4e1bd669 100644 --- a/src/app/qml/RestorePage.qml +++ b/src/app/qml/RestorePage.qml @@ -179,4 +179,40 @@ Page { } } ] + + StackView.onActivated: { + prevButton.text = qsTr("Previous") + if (lastRestoreable && lastRestoreable.restoreStatus == Units.RestoreStatus.Restored) + nextButton.text = qsTr("Finish") + else + nextButton.text = qsTr("Restore") + } + + function setNextPage() { + if (lastRestoreable && lastRestoreable.restoreStatus == Units.RestoreStatus.Restored) + selectedPage = Units.Page.MainPage + else + drives.lastRestoreable.restore() + } + + function setPreviousPage() { + selectedPage = Units.Page.MainPage + } + + Keys.onPressed: (event)=> { + switch (event.key) { + case (Qt.Key_I): + aboutDialog.show() + break + case (Qt.Key_Right): + case (Qt.Key_N): + setNextPage() + break + case (Qt.Key_Left): + case (Qt.Key_P): + if (!(lastRestoreable && lastRestoreable.restoreStatus == Units.RestoreStatus.Restoring)) + setPreviousPage() + break + } + } } diff --git a/src/app/qml/VersionPage.qml b/src/app/qml/VersionPage.qml index 9e8c5c34..104f68c2 100644 --- a/src/app/qml/VersionPage.qml +++ b/src/app/qml/VersionPage.qml @@ -26,6 +26,7 @@ import QtQml 6.2 Page { id: versionPage property int prevSource: 0 + property int prevIndex: 0 ColumnLayout { anchors.fill: parent @@ -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 @@ -102,4 +106,62 @@ Page { releases.selectedIndex = parseInt(selectFromComboBox.currentValue) } } + + StackView.onActivated: { + prevButton.text = qsTr("Previous") + nextButton.text = qsTr("Next") + } + + function setNextPage() { + mainWindow.selectedPage += 1 + } + + function setPreviousPage() { + selectedPage -= 1 + } + + 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 + case (Qt.Key_I): + aboutDialog.show() + break + case (Qt.Key_Right): + case (Qt.Key_N): + setNextPage() + break + case (Qt.Key_Left): + case (Qt.Key_P): + setPreviousPage() + break + } + } } diff --git a/src/app/qml/main.qml b/src/app/qml/main.qml index 5a2e228d..3eb37596 100644 --- a/src/app/qml/main.qml +++ b/src/app/qml/main.qml @@ -49,6 +49,7 @@ ApplicationWindow { StackView { id: stackView initialItem: "MainPage.qml" + focus: true Layout.fillHeight: true Layout.fillWidth: true @@ -87,12 +88,13 @@ ApplicationWindow { } RowLayout { + id: buttonRow Layout.alignment: Qt.AlignBottom Button { id: prevButton visible: true - text: getPrevButtonText() + // text: getPrevButtonText() } Item { @@ -118,22 +120,13 @@ ApplicationWindow { //When comming back from restore page, after successfull restoring a USB drive PropertyChanges { target: prevButton - text: getPrevButtonText() - onClicked: aboutDialog.show() + // text: getPrevButtonText() + onClicked: stackView.currentItem.setPreviousPage() } PropertyChanges { target: nextButton visible: true - onClicked: { - if (selectedOption == Units.MainSelect.Write) { - if (releases.localFile.iso) - releases.selectLocalFile() - selectedPage = Units.Page.DrivePage - } else if (selectedOption == Units.MainSelect.Restore) - selectedPage = Units.Page.RestorePage - else - selectedPage = Units.Page.VersionPage - } + onClicked: stackView.currentItem.setNextPage() } StateChangeScript { script: { @@ -152,8 +145,8 @@ ApplicationWindow { name: "versionPage" when: selectedPage == Units.Page.VersionPage PropertyChanges { target: mainWindow; title: qsTr("Select Fedora Version") } - PropertyChanges { target: nextButton; visible: true; onClicked: selectedPage += 1 } - PropertyChanges { target: prevButton; visible: true; onClicked: selectedPage -= 1 } + PropertyChanges { target: nextButton; visible: true; onClicked: stackView.currentItem.setNextPage() } + PropertyChanges { target: prevButton; visible: true; onClicked: stackView.currentItem.setPreviousPage() } StateChangeScript { script: { //state was pushing same page when returing from drivePage @@ -172,27 +165,12 @@ ApplicationWindow { PropertyChanges { target: nextButton; visible: true - onClicked: { - selectedPage = Units.Page.DownloadPage - if (selectedOption != Units.MainSelect.Write) - releases.variant.download() - if (drives.length) { - drives.selected.setImage(releases.variant) - drives.selected.write(releases.variant) - } - } + onClicked: stackView.currentItem.setNextPage() } PropertyChanges { target: prevButton visible: true - onClicked: { - if (selectedOption == Units.MainSelect.Write) - selectedPage = Units.Page.MainPage - else { - selectedPage -= 1 - stackView.pop() - } - } + onClicked: stackView.currentItem.setPreviousPage() } StateChangeScript { script: { @@ -214,32 +192,11 @@ ApplicationWindow { PropertyChanges { target: prevButton visible: true - onClicked: { - 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) { - cancelDialog.show() - } else { - releases.variant.resetStatus() - downloadManager.cancel() - mainWindow.selectedPage = Units.Page.MainPage - } - } + onClicked: stackView.currentItem.setPreviousPage() } PropertyChanges { target: nextButton - onClicked: { - if (releases.variant.status === Units.DownloadStatus.Finished) { - drives.lastRestoreable = drives.selected - drives.lastRestoreable.setRestoreStatus(Units.RestoreStatus.Contains_Live) - releases.variant.resetStatus() - downloadManager.cancel() - selectedPage = Units.Page.MainPage - } 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) { - if (selectedOption != Units.MainSelect.Write) - releases.variant.download() - drives.selected.setImage(releases.variant) - drives.selected.write(releases.variant) - } - } + onClicked: stackView.currentItem.setNextPage() } }, State { @@ -252,17 +209,12 @@ ApplicationWindow { PropertyChanges { target: nextButton visible: true - onClicked: { - if (lastRestoreable && lastRestoreable.restoreStatus == Units.RestoreStatus.Restored) - selectedPage = Units.Page.MainPage - else - drives.lastRestoreable.restore() - } + onClicked: stackView.currentItem.setNextPage() } PropertyChanges { target: prevButton visible: true - onClicked: selectedPage = Units.Page.MainPage + onClicked: stackView.currentItem.setPreviousPage() } StateChangeScript { script: { stackView.push("RestorePage.qml") } @@ -278,42 +230,9 @@ ApplicationWindow { AboutDialog { id: aboutDialog } - + CancelDialog { id: cancelDialog } - - - function getNextButtonText() { - if (mainLayout.state == "restorePage") { - if (lastRestoreable && lastRestoreable.restoreStatus == Units.RestoreStatus.Restored) - return qsTr("Finish") - return qsTr("Restore") - } else if (mainLayout.state == "drivePage") { - if (selectedOption == Units.MainSelect.Write || downloadManager.isDownloaded(releases.selected.version.variant.url)) - return qsTr("Write") - if (Qt.platform.os === "windows" || Qt.platform.os === "osx") - return qsTr("Download && Write") - return qsTr("Download & Write") - } else if (mainLayout.state == "downloadPage") { - 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) - return qsTr("Cancel") - else if (releases.variant.status == Units.DownloadStatus.Ready) - return qsTr("Write") - else if (releases.variant.status === Units.DownloadStatus.Finished) - return qsTr("Finish") - else - return qsTr("Retry") - } - return qsTr("Next") - } - - function getPrevButtonText() { - if (mainLayout.state == "mainPage") - return qsTr("About") - else if (mainLayout.state == "downloadPage") - return qsTr("Cancel") - return qsTr("Previous") - } }