Skip to content

Commit

Permalink
Show the warning dialog with erase confirmation everytime (#750)
Browse files Browse the repository at this point in the history
Make the dialog to appear all the time and not only for drives
bigger than 32GB.
  • Loading branch information
grulja committed Oct 29, 2024
1 parent f3529ef commit 3365c81
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
18 changes: 17 additions & 1 deletion src/app/qml/DeviceWarningDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ApplicationWindow {

Label {
Layout.fillWidth: true
text: qsTr("The device you have selected appears to be larger than 32GB. Are you sure you want to completely erase all the data on it?")
text: qsTr("The entire device (all of %1) will be erased and the selected image will be written to it. Do you want to continue?").arg(formatSize(drives.selected.size))
wrapMode: Label.Wrap
}

Expand Down Expand Up @@ -87,5 +87,21 @@ ApplicationWindow {
}
}
}

function formatSize(bytes) {
const kb = 1024;
const mb = kb * 1024;
const gb = mb * 1024;

if (bytes >= gb) {
return (bytes / gb).toFixed(2) + " " + qsTr("GB");
} else if (bytes >= mb) {
return (bytes / mb).toFixed(2) + " " + qsTr("MB");
} else if (bytes >= kb) {
return (bytes / kb).toFixed(2) + " " + qsTr("KB");
} else {
return bytes + " " + qsTr("Bytes");
}
}
}

10 changes: 1 addition & 9 deletions src/app/qml/DrivePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,6 @@ Page {
return;
}

// Better check for > 33GB as the device size is not exactly 32GB for "32GB" USB drive
if (drives.selected.size > 33000000000) {
deviceWarningDialog.show();
return
}

selectedPage = Units.Page.DownloadPage
drives.selected.setImage(releases.variant)
drives.selected.write(releases.variant)
deviceWarningDialog.show();
}
}

0 comments on commit 3365c81

Please sign in to comment.