mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 07:55:21 +01:00
ughhhh
This commit is contained in:
parent
f5aa8a7f89
commit
b997b6d2b3
1 changed files with 31 additions and 7 deletions
38
src/main.qml
38
src/main.qml
|
@ -540,11 +540,35 @@ ApplicationWindow {
|
||||||
height: 1
|
height: 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to load JSON data
|
||||||
|
function loadJSON() {
|
||||||
|
var request = new XMLHttpRequest();
|
||||||
|
request.open("GET", "os_list.json", false); // Synchronous request
|
||||||
|
request.send();
|
||||||
|
|
||||||
|
if (request.status === 200) {
|
||||||
|
return JSON.parse(request.responseText);
|
||||||
|
} else {
|
||||||
|
console.error("Failed to load JSON: " + request.status);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
jsonData = loadJSON();
|
||||||
|
if (jsonData) {
|
||||||
|
loadDevices(); // Call loadDevices() after JSON is loaded
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
property var jsonData: {} // Empty object to hold the loaded JSON
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: hwlist
|
id: hwlist
|
||||||
clip: true
|
clip: true
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
id: deviceModel
|
id: deviceModel
|
||||||
|
// Default element if you want to show "All" as a choice
|
||||||
ListElement {
|
ListElement {
|
||||||
name: qsTr("[ All ]")
|
name: qsTr("[ All ]")
|
||||||
tags: "[]"
|
tags: "[]"
|
||||||
|
@ -555,14 +579,15 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to populate the model
|
// Function to populate the model
|
||||||
Component.onCompleted: {
|
|
||||||
loadDevices();
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadDevices() {
|
function loadDevices() {
|
||||||
deviceModel.clear(); // Clear existing entries if any
|
deviceModel.clear(); // Clear existing entries if any
|
||||||
|
|
||||||
// Sample structure for accessing JSON data. Assuming jsonData is your loaded JSON.
|
if (!jsonData || !jsonData.imager || !jsonData.imager.manufacturers) {
|
||||||
|
console.error("Invalid JSON structure.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sample structure for accessing JSON data.
|
||||||
var manufacturers = jsonData.imager.manufacturers;
|
var manufacturers = jsonData.imager.manufacturers;
|
||||||
|
|
||||||
// Iterate through each manufacturer and add its devices
|
// Iterate through each manufacturer and add its devices
|
||||||
|
@ -582,7 +607,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
currentIndex: -1
|
currentIndex: -1
|
||||||
delegate: hwdelegate
|
delegate: hwdelegate
|
||||||
anchors.top: hwpopup_title_separator.bottom
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
@ -603,7 +628,6 @@ ApplicationWindow {
|
||||||
Keys.onEnterPressed: Keys.onSpacePressed(event)
|
Keys.onEnterPressed: Keys.onSpacePressed(event)
|
||||||
Keys.onReturnPressed: Keys.onSpacePressed(event)
|
Keys.onReturnPressed: Keys.onSpacePressed(event)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Popup for OS selection
|
Popup for OS selection
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue