*
* This program is free software; you can redistribute it and/or
@@ -18,165 +19,112 @@
*/
import QtQuick 6.6
-import QtQuick.Controls 6.6
-import QtQuick.Window 6.6
+import QtQuick.Controls 6.6 as QQC2
import QtQuick.Layouts 6.6
-import QtQml 6.6
Page {
id: restorePage
-
- ColumnLayout {
- id: mainColumn
- anchors.fill: parent
- spacing: units.gridUnit
-
- Column {
- Label {
- Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
- text: qsTr("Restore Drive %1").arg(mainWindow.lastRestoreable.name)
- wrapMode: Label.Wrap
- width: mainColumn.width
- horizontalAlignment: Label.AlignHCenter
- }
+
+ Column {
+ QQC2.Label {
+ Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
+ text: qsTr("Restore Drive %1").arg(lastRestoreable.name)
+ wrapMode: QQC2.Label.Wrap
+ width: mainWindow.width - (units.gridUnit * 4)
+ horizontalAlignment: QQC2.Label.AlignHCenter
}
-
- Column {
- Label {
- id: warningText
- visible: false
- Layout.alignment: Qt.AlignHCenter
- text: qsTr(" To reclaim all space available on the drive, it has to be restored to its factory settings. The live system and all saved data will be deleted.
You don't need to restore the drive if you want to write another live system to it.
-
Do you want to restore it to factory settings?
" )
- textFormat: Text.RichText
- horizontalAlignment: Text.AlignHCenter
- wrapMode: Label.Wrap
- width: mainColumn.width
- }
-
- ColumnLayout {
- id: progress
- visible: false
-
- Column{
- Label {
- Layout.alignment: Qt.AlignHCenter
- horizontalAlignment: Label.AlignHCenter
- wrapMode: Label.Wrap
- width: warningText.width
- text: qsTr("Please wait while Fedora Media Writer restores your portable drive.
")
- }
- }
-
- ProgressBar {
- id: progressIndicator
- width: units.gridUnit * 14
+ }
+
+ Column {
+ QQC2.Label {
+ id: warningText
+ visible: lastRestoreable.restoreStatus == Units.RestoreStatus.Contains_Live
+ Layout.alignment: Qt.AlignHCenter
+ text: qsTr(" To reclaim all space available on the drive, it has to be restored to its factory settings. The live system and all saved data will be deleted.
You don't need to restore the drive if you want to write another live system to it.
+
Do you want to restore it to factory settings?
" )
+ textFormat: Text.RichText
+ horizontalAlignment: Text.AlignHCenter
+ wrapMode: QQC2.Label.Wrap
+ width: mainWindow.width - (units.gridUnit * 4)
+ }
+
+ ColumnLayout {
+ id: progress
+ visible: lastRestoreable.restoreStatus == Units.RestoreStatus.Restoring
+
+ Column{
+ QQC2.Label {
Layout.alignment: Qt.AlignHCenter
- indeterminate: true
+ horizontalAlignment: QQC2.Label.AlignHCenter
+ wrapMode: QQC2.Label.Wrap
+ width: warningText.width
+ text: qsTr("Please wait while Fedora Media Writer restores your portable drive.
")
}
}
-
- Label {
- id: restoredText
- visible: false
- Layout.alignment: Qt.AlignHCenter
- horizontalAlignment: Text.AlignHCenter
- text: qsTr("Your drive was successfully restored!")
- wrapMode: Label.Wrap
- width: mainColumn.width
- }
-
- Label {
- id: errorText
- visible: false
+
+ QQC2.ProgressBar {
+ id: progressIndicator
+ width: units.gridUnit * 14
Layout.alignment: Qt.AlignHCenter
- horizontalAlignment: Text.AlignHCenter
- text: qsTr("Unfortunately, an error occurred during the process. Please try restoring the drive using your system tools.")
- wrapMode: Label.Wrap
- width: mainColumn.width
+ indeterminate: true
}
}
- }
-
- Connections {
- target: drives
- function onLastRestoreableChanged() {
- if (!drives.selected)
- mainWindow.selectedPage = Units.Page.MainPage
+
+ QQC2.Label {
+ id: restoredText
+ visible: lastRestoreable.restoreStatus == Units.RestoreStatus.Restored
+ Layout.alignment: Qt.AlignHCenter
+ horizontalAlignment: Text.AlignHCenter
+ text: qsTr("Your drive was successfully restored!")
+ wrapMode: QQC2.Label.Wrap
+ width: mainWindow.width - (units.gridUnit * 4)
+ }
+
+ QQC2.Label {
+ id: errorText
+ visible: lastRestoreable.restoreStatus == Units.RestoreStatus.Restore_Error
+ Layout.alignment: Qt.AlignHCenter
+ horizontalAlignment: Text.AlignHCenter
+ text: qsTr("Unfortunately, an error occurred during the process. Please try restoring the drive using your system tools.")
+ wrapMode: QQC2.Label.Wrap
+ width: mainWindow.width - (units.gridUnit * 4)
}
}
Component.onCompleted: {
- mainWindow.lastRestoreable = drives.lastRestoreable
+ lastRestoreable = drives.lastRestoreable
}
states: [
- State {
- name: "contains_live"
- when: mainWindow.lastRestoreable && mainWindow.lastRestoreable.restoreStatus == Units.RestoreStatus.Contains_Live
- PropertyChanges {
- target: warningText;
- visible: true
- }
- },
- State {
- name: "restoring"
- when: mainWindow.lastRestoreable && mainWindow.lastRestoreable.restoreStatus == Units.RestoreStatus.Restoring
- PropertyChanges {
- target: progress;
- visible: true
- }
- PropertyChanges {
- target: prevButton;
- visible: false
- }
- PropertyChanges {
- target: nextButton;
- visible: false
- }
- },
State {
name: "restored"
- when: mainWindow.lastRestoreable && mainWindow.lastRestoreable.restoreStatus == Units.RestoreStatus.Restored
+ when: lastRestoreable.restoreStatus == Units.RestoreStatus.Restored
PropertyChanges {
target: mainWindow;
title: qsTr("Restoring finished")
}
- PropertyChanges {
- target: restoredText;
- visible: true
- }
- PropertyChanges {
- target: nextButton;
- enabled: true
- }
- PropertyChanges {
- target: prevButton;
- visible: false
- }
StateChangeScript {
script: drives.lastRestoreable = null
}
- },
- State {
- name: "restore_error"
- when: mainWindow.lastRestoreable && mainWindow.lastRestoreable.restoreStatus == Units.RestoreStatus.Restore_Error
- PropertyChanges {
- target: errorText;
- visible: true
- }
- PropertyChanges {
- target: prevButton;
- enabled: true
- }
- },
- State {
- name: "Clean"
- when: mainWindow.lastRestoreable && mainWindow.lastRestoreable.restoreStatus == Units.RestoreStatus.Clean
- PropertyChanges {
- target: prevButton;
- enabled: true
- }
}
]
+
+ previousButtonEnabled: lastRestoreable.restoreStatus != Units.RestoreStatus.Restored &&
+ lastRestoreable.restoreStatus != Units.RestoreStatus.Restoring
+ previousButtonVisible: previousButtonEnabled
+ onPreviousButtonClicked: {
+ selectedPage = Units.Page.MainPage
+ }
+
+ nextButtonEnabled: lastRestoreable.restoreStatus == Units.RestoreStatus.Restored ||
+ lastRestoreable.restoreStatus == Units.RestoreStatus.Contains_Live
+ nextButtonVisible: lastRestoreable.restoreStatus != Units.RestoreStatus.Restoring
+ nextButtonText: lastRestoreable.restoreStatus == Units.RestoreStatus.Restored ? qsTr("Finish") : qsTr("Restore")
+ onNextButtonClicked: {
+ if (lastRestoreable.restoreStatus == Units.RestoreStatus.Restored)
+ selectedPage = Units.Page.MainPage
+ else
+ drives.lastRestoreable.restore()
+ }
+
}
diff --git a/src/app/qml/VersionPage.qml b/src/app/qml/VersionPage.qml
index 713d754b..b68b249e 100644
--- a/src/app/qml/VersionPage.qml
+++ b/src/app/qml/VersionPage.qml
@@ -1,5 +1,6 @@
/*
* Fedora Media Writer
+ * Copyright (C) 2024 Jan Grulich
* Copyright (C) 2021-2022 Evžen Gasta
*
* This program is free software; you can redistribute it and/or
@@ -18,73 +19,48 @@
*/
import QtQuick 6.6
-import QtQuick.Controls 6.6
+import QtQuick.Controls 6.6 as QQC2
import QtQuick.Layouts 6.6
-import QtQml 6.6
-
Page {
id: versionPage
property int prevSource: 0
- ColumnLayout {
- anchors.fill: parent
-
- Heading {
- Layout.alignment: Qt.AlignHCenter
- text: qsTr("Select Fedora Release")
- level: 5
- }
-
- ButtonGroup {
- id: radioGroup
- }
-
- ColumnLayout {
- id: radioColumn
- Layout.alignment: Qt.AlignTop
-
- Label {
- text: qsTr("Select from:")
- }
+ text: qsTr("Select Fedora Release")
- RadioButton {
- checked: true
- text: qsTr("Official Editions")
- onClicked: changeFilter(Units.Source.Product)
- ButtonGroup.group: radioGroup
- }
+ QQC2.Label {
+ text: qsTr("Select from:")
+ }
- RadioButton {
- text: qsTr("Atomic Desktops")
- onClicked: changeFilter(Units.Source.Emerging)
- ButtonGroup.group: radioGroup
- }
+ QQC2.RadioButton {
+ checked: true
+ text: qsTr("Official Editions")
+ onClicked: changeFilter(Units.Source.Product)
+ }
- RadioButton {
- text: qsTr("Spins")
- onClicked: changeFilter(Units.Source.Spins)
- ButtonGroup.group: radioGroup
- }
+ QQC2.RadioButton {
+ text: qsTr("Atomic Desktops")
+ onClicked: changeFilter(Units.Source.Emerging)
+ }
- RadioButton {
- text: qsTr("Labs")
- onClicked: changeFilter(Units.Source.Labs)
- ButtonGroup.group: radioGroup
- }
+ QQC2.RadioButton {
+ text: qsTr("Spins")
+ onClicked: changeFilter(Units.Source.Spins)
+ }
- ComboBox {
- id: selectFromComboBox
- Layout.alignment: Qt.AlignHCenter
- Layout.fillWidth: true
- Layout.topMargin: units.gridUnit / 2
- textRole: "name"
- valueRole: "sourceIndex"
- model: releases
- onCurrentValueChanged: updateSelectedIndex()
+ QQC2.RadioButton {
+ text: qsTr("Labs")
+ onClicked: changeFilter(Units.Source.Labs)
+ }
- }
- }
+ QQC2.ComboBox {
+ id: selectFromComboBox
+ Layout.fillWidth: true
+ Layout.topMargin: units.gridUnit / 2
+ textRole: "name"
+ valueRole: "sourceIndex"
+ model: releases
+ onCurrentValueChanged: updateSelectedIndex()
}
function changeFilter(filter) {
@@ -102,4 +78,7 @@ Page {
releases.selectedIndex = parseInt(selectFromComboBox.currentValue)
}
}
+
+ onPreviousButtonClicked: selectedPage -= 1
+ onNextButtonClicked: selectedPage += 1
}
diff --git a/src/app/qml/main.qml b/src/app/qml/main.qml
index 348504c5..cb53bcb6 100644
--- a/src/app/qml/main.qml
+++ b/src/app/qml/main.qml
@@ -19,9 +19,6 @@
import QtQuick 6.6
import QtQuick.Controls 6.6
-import QtQuick.Window 6.6
-import QtQuick.Layouts 6.6
-import QtQml 6.6
ApplicationWindow {
id: mainWindow
@@ -36,74 +33,42 @@ ApplicationWindow {
property int selectedOption: Units.MainSelect.Download
property QtObject lastRestoreable
property bool eraseVariant: false
-
- ColumnLayout {
- id: mainLayout
- anchors.fill: parent
-
- anchors.leftMargin: units.gridUnit * 3
- anchors.rightMargin: units.gridUnit * 3
- anchors.topMargin: units.gridUnit * 2
- anchors.bottomMargin: units.gridUnit * 2
- StackView {
- id: stackView
- initialItem: "MainPage.qml"
-
- Layout.fillHeight: true
- Layout.fillWidth: true
- Layout.leftMargin: parent.width / 8
- Layout.rightMargin: parent.width / 8
- Layout.bottomMargin: units.gridUnit * 2
-
- pushEnter: Transition {
- XAnimator {
- from: mainWindow.width
- to: 0
- duration: 250
- }
- }
- pushExit: Transition {
- XAnimator {
- from: 0
- to: -mainWindow.width
- duration: 250
- }
- }
- popEnter: Transition {
- XAnimator {
- from: -mainWindow.width
- to: 0
- duration: 250
- }
- }
- popExit: Transition {
- XAnimator {
- from: 0
- to: mainWindow.width
- duration: 250
- }
+ StackView {
+ id: stackView
+ initialItem: "MainPage.qml"
+
+ anchors {
+ fill: parent
+ margins: units.gridUnit * 2
+ }
+
+ pushEnter: Transition {
+ XAnimator {
+ from: mainWindow.width
+ to: 0
+ duration: 250
}
}
-
- RowLayout {
- Layout.alignment: Qt.AlignBottom
-
- Button {
- id: prevButton
- visible: true
- text: getPrevButtonText()
+ pushExit: Transition {
+ XAnimator {
+ from: 0
+ to: -mainWindow.width
+ duration: 250
}
-
- Item {
- Layout.fillWidth: true
+ }
+ popEnter: Transition {
+ XAnimator {
+ from: -mainWindow.width
+ to: 0
+ duration: 250
}
-
- Button {
- id: nextButton
- visible: mainLayout.state != "downloadPage"
- enabled: mainLayout.state != "drivePage"
- text: getNextButtonText()
+ }
+ popExit: Transition {
+ XAnimator {
+ from: 0
+ to: mainWindow.width
+ duration: 250
}
}
@@ -115,26 +80,7 @@ ApplicationWindow {
target: mainWindow
title: qsTr("Fedora Media Writer")
}
- //When comming back from restore page, after successfull restoring a USB drive
- PropertyChanges {
- target: prevButton
- text: getPrevButtonText()
- onClicked: aboutDialog.show()
- }
- 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
- }
- }
+
StateChangeScript {
script: {
//reset of source on versionPage
@@ -152,8 +98,6 @@ 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 }
StateChangeScript {
script: {
//state was pushing same page when returing from drivePage
@@ -169,31 +113,6 @@ ApplicationWindow {
target: mainWindow
title: qsTr("Select Drive")
}
- 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)
- }
- }
- }
- PropertyChanges {
- target: prevButton
- visible: true
- onClicked: {
- if (selectedOption == Units.MainSelect.Write)
- selectedPage = Units.Page.MainPage
- else {
- selectedPage -= 1
- stackView.pop()
- }
- }
- }
StateChangeScript {
script: {
stackView.push("DrivePage.qml")
@@ -204,73 +123,36 @@ ApplicationWindow {
State {
name: "downloadPage"
when: selectedPage == Units.Page.DownloadPage
- PropertyChanges {
+ PropertyChanges {
target: mainWindow
title: releases.variant.statusString
}
StateChangeScript {
script: { stackView.push("DownloadPage.qml") }
}
- 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
- }
- }
- }
- 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)
- }
- }
- }
},
State {
name: "restorePage"
when: selectedPage == Units.Page.RestorePage
- PropertyChanges {
- target: mainWindow
- title: qsTr("Restore")
- }
- PropertyChanges {
- target: nextButton
- visible: true
- onClicked: {
- if (lastRestoreable && lastRestoreable.restoreStatus == Units.RestoreStatus.Restored)
- selectedPage = Units.Page.MainPage
- else
- drives.lastRestoreable.restore()
- }
- }
PropertyChanges {
- target: prevButton
- visible: true
- onClicked: selectedPage = Units.Page.MainPage
+ target: mainWindow
+ title: qsTr("Restore")
}
- StateChangeScript {
+ StateChangeScript {
script: { stackView.push("RestorePage.qml") }
}
}
]
}
+ Connections {
+ target: drives
+ function onLastRestoreableChanged() {
+ if (!drives.selected)
+ selectedPage = Units.Page.MainPage
+ }
+ }
+
Units {
id: units
}
@@ -282,38 +164,5 @@ ApplicationWindow {
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")
- }
}