Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/imagewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2351,6 +2351,7 @@ void ImageWriter::onSelectedDeviceRemoved(const QString &device)

// If we're currently writing to this device, cancel the write immediately
if (_writeState == WriteState::Preparing || _writeState == WriteState::Writing || _writeState == WriteState::Verifying || _writeState == WriteState::Finalizing) {
_selectedDeviceValid = false;
qDebug() << "Cancelling write operation due to device removal";
_cancelledDueToDeviceRemoval = true;
cancelWrite();
Expand All @@ -2360,6 +2361,7 @@ void ImageWriter::onSelectedDeviceRemoved(const QString &device)
qDebug() << "Device removed after successful write - ignoring (likely ejected)";
// Don't notify UI - this is expected behavior after successful write
} else {
_selectedDeviceValid = false;
// Normal case - device removed when not writing
emit selectedDeviceRemoved();
}
Expand Down
42 changes: 30 additions & 12 deletions src/wizard/WritingStep.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ WizardStepBase {

property bool isWriting: false
property bool isVerifying: false
property bool cancelPending: false
property bool isFinalising: false
property bool isComplete: false
property bool confirmOpen: false
readonly property bool anyCustomizationsApplied: (
Expand All @@ -53,7 +55,7 @@ WizardStepBase {
)

// Disable back while writing
backButtonEnabled: !root.isWriting
backButtonEnabled: !root.isWriting && !root.cancelPending && !root.isFinalising

// Content
content: [
Expand All @@ -72,7 +74,7 @@ WizardStepBase {
Layout.maximumWidth: Style.sectionMaxWidth
Layout.alignment: Qt.AlignHCenter
spacing: Style.spacingMedium
visible: !root.isWriting
visible: !root.isWriting && !root.cancelPending && !root.isFinalising

Text {
text: qsTr("Summary")
Expand Down Expand Up @@ -157,7 +159,7 @@ WizardStepBase {
Layout.maximumWidth: Style.sectionMaxWidth
Layout.alignment: Qt.AlignHCenter
spacing: Style.spacingMedium
visible: !root.isWriting && root.anyCustomizationsApplied
visible: !root.isWriting && !root.cancelPending && !root.isFinalising && root.anyCustomizationsApplied

Text {
text: qsTr("Customisations to apply:")
Expand Down Expand Up @@ -224,7 +226,7 @@ WizardStepBase {
Layout.maximumWidth: Style.sectionMaxWidth
Layout.alignment: Qt.AlignHCenter
spacing: Style.spacingMedium
visible: root.isWriting || root.isComplete
visible: root.isWriting || root.cancelPending || root.isFinalising || root.isComplete

Text {
id: progressText
Expand All @@ -247,7 +249,7 @@ WizardStepBase {

Material.accent: Style.progressBarVerifyForegroundColor
Material.background: Style.progressBarBackgroundColor
visible: root.isWriting
visible: (root.isWriting || root.isFinalising)
}
}

Expand All @@ -259,11 +261,12 @@ WizardStepBase {
// Handle next button clicks based on current state
onNextClicked: {
if (root.isWriting) {
// Cancel the write
root.cancelPending = true
root.isVerifying = false
root.isFinalising = true
progressBar.value = 100
progressText.text = qsTr("Finalising…")
imageWriter.cancelWrite()
root.isWriting = false
wizardContainer.isWriting = false
progressText.text = qsTr("Write cancelled")
} else if (!root.isComplete) {
// If warnings are disabled, skip the confirmation dialog
if (wizardContainer.disableWarnings) {
Expand Down Expand Up @@ -430,6 +433,8 @@ WizardStepBase {
function onSuccess() {
root.isWriting = false
wizardContainer.isWriting = false
root.cancelPending = false
root.isFinalising = false
root.isComplete = true
progressText.text = qsTr("Write completed successfully!")

Expand All @@ -439,12 +444,25 @@ WizardStepBase {
function onError(msg) {
root.isWriting = false
wizardContainer.isWriting = false
progressText.text = qsTr("Write failed: %1").arg(msg)
if (root.cancelPending) {
// Treat verify-cancel as a benign finish
root.cancelPending = false
root.isFinalising = false
root.isComplete = true
progressText.text = qsTr("Verification cancelled")
wizardContainer.nextStep()
} else {
root.isFinalising = false
progressText.text = qsTr("Write failed: %1").arg(msg)
}
}

function onFinalizing() {
if (root.isWriting) {
root.onFinalizing()
if (root.isWriting || root.cancelPending) {
root.isVerifying = false
root.isFinalising = true
progressText.text = qsTr("Finalising…")
progressBar.value = 100
}
}
}
Expand Down