mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 16:05:21 +01:00
Allow specifying default OS selection and destination
Allows specifying a default OS and destination (the last for Imager embedded only) in the repository json. Like: == "imager": { "latest_version": "1.6", "url": "https://www.raspberrypi.org/software/", "default_os": "Raspberry Pi OS (32-bit)", "embedded_default_destination": "/dev/mmcblk0p1" }, ==
This commit is contained in:
parent
cde6d1eaa0
commit
f5390c821a
1 changed files with 51 additions and 0 deletions
51
main.qml
51
main.qml
|
@ -1055,6 +1055,21 @@ ApplicationWindow {
|
||||||
return o["os_list"]
|
return o["os_list"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectNamedOS(name, collection)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < collection.count; i++) {
|
||||||
|
var os = collection.get(i)
|
||||||
|
|
||||||
|
if (typeof(os.subitems) !== "undefined") {
|
||||||
|
selectNamedOS(name, os.subitems)
|
||||||
|
}
|
||||||
|
else if (typeof(os.url) !== "undefined" && name === os.name) {
|
||||||
|
selectOSitem(os, false)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function fetchOSlist() {
|
function fetchOSlist() {
|
||||||
httpRequest(imageWriter.constantOsListUrl(), function (x) {
|
httpRequest(imageWriter.constantOsListUrl(), function (x) {
|
||||||
var o = JSON.parse(x.responseText)
|
var o = JSON.parse(x.responseText)
|
||||||
|
@ -1073,10 +1088,46 @@ ApplicationWindow {
|
||||||
updatepopup.openPopup()
|
updatepopup.openPopup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ("default_os" in imager) {
|
||||||
|
selectNamedOS(imager["default_os"], osmodel)
|
||||||
|
}
|
||||||
|
if (imageWriter.isEmbeddedMode()) {
|
||||||
|
if ("embedded_default_os" in imager) {
|
||||||
|
selectNamedOS(imager["embedded_default_os"], osmodel)
|
||||||
|
}
|
||||||
|
if ("embedded_default_destination" in imager) {
|
||||||
|
imageWriter.startDriveListPolling()
|
||||||
|
setDefaultDest.drive = imager["embedded_default_destination"]
|
||||||
|
setDefaultDest.start()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
/* Verify if default drive is in our list after 100 ms */
|
||||||
|
id: setDefaultDest
|
||||||
|
property string drive : ""
|
||||||
|
interval: 100
|
||||||
|
onTriggered: {
|
||||||
|
for (var i = 0; i < driveListModel.rowCount(); i++)
|
||||||
|
{
|
||||||
|
/* FIXME: there should be a better way to iterate drivelist than
|
||||||
|
fetch data by numeric role number */
|
||||||
|
if (driveListModel.data(driveListModel.index(i,0), 0x101) === drive) {
|
||||||
|
selectDstItem({
|
||||||
|
device: drive,
|
||||||
|
description: driveListModel.data(driveListModel.index(i,0), 0x102),
|
||||||
|
size: driveListModel.data(driveListModel.index(i,0), 0x103),
|
||||||
|
readonly: false
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function newSublist() {
|
function newSublist() {
|
||||||
if (osswipeview.currentIndex == (osswipeview.count-1))
|
if (osswipeview.currentIndex == (osswipeview.count-1))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue