Skip to content

Commit f355462

Browse files
3.0.1
1 parent 0da659a commit f355462

9 files changed

Lines changed: 225 additions & 104 deletions

File tree

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ OPTION (ENABLE_TELEMETRY "Enable sending telemetry" ON)
1212
project(OpenHDImageWriter LANGUAGES CXX C)
1313
set(IMAGER_VERSION_MAJOR 3)
1414
set(IMAGER_VERSION_MINOR 0)
15-
set(IMAGER_VERSION_PATCH 0)
15+
set(IMAGER_VERSION_PATCH 1)
1616
set(IMAGER_VERSION_STR "${IMAGER_VERSION_MAJOR}.${IMAGER_VERSION_MINOR}.${IMAGER_VERSION_PATCH}")
1717
set(IMAGER_VERSION_CSV "${IMAGER_VERSION_MAJOR},${IMAGER_VERSION_MINOR},${IMAGER_VERSION_PATCH},0")
1818
add_definitions(-DIMAGER_VERSION_STR="${IMAGER_VERSION_STR}")
@@ -414,4 +414,4 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
414414
${OPENSSL_LIBRARIES}
415415
${ATOMIC_LIBRARY}
416416
${EXTRALIBS})
417-
endif()
417+
endif()

src/OptionsPopup.qml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Popup {
5858
}
5959

6060
ColumnLayout {
61-
spacing: 20
61+
spacing: 10
6262
anchors.fill: parent
6363

6464
Text {
@@ -340,8 +340,8 @@ Popup {
340340

341341
RowLayout {
342342
Layout.alignment: Qt.AlignCenter | Qt.AlignBottom
343-
Layout.bottomMargin: 10
344-
spacing: 20
343+
Layout.bottomMargin: 6
344+
spacing: 16
345345

346346
ImButton {
347347
text: qsTr("SAVE")
@@ -363,7 +363,20 @@ Popup {
363363
nameFilters: [qsTr("QOpenHD.conf (*.conf)"), qsTr("All files (*)")]
364364
selectExisting: true
365365
onAccepted: {
366-
qopenhdConfPath = qopenhdConfDialog.fileUrl.toLocalFile()
366+
var selectedUrl = qopenhdConfDialog.fileUrl
367+
if (!selectedUrl || selectedUrl.toString().length === 0) {
368+
if (qopenhdConfDialog.fileUrls && qopenhdConfDialog.fileUrls.length > 0) {
369+
selectedUrl = qopenhdConfDialog.fileUrls[0]
370+
}
371+
}
372+
if (selectedUrl && selectedUrl.toString) {
373+
var selectedStr = selectedUrl.toString()
374+
if (selectedStr.startsWith("file:")) {
375+
qopenhdConfPath = normalizeLocalFilePath(selectedUrl.toLocalFile ? selectedUrl.toLocalFile() : selectedStr)
376+
} else {
377+
qopenhdConfPath = normalizeLocalFilePath(selectedStr)
378+
}
379+
}
367380
}
368381
}
369382

@@ -385,7 +398,7 @@ Popup {
385398
hotSpot = imageWriter.getValue("hotSpot")
386399
beep = imageWriter.getBoolSetting("beep")
387400
eject = imageWriter.getBoolSetting("eject")
388-
qopenhdConfPath = imageWriter.getValue("qopenhdConfPath")
401+
qopenhdConfPath = normalizeLocalFilePath(imageWriter.getValue("qopenhdConfPath"))
389402

390403
// set session settings
391404
if (mode) {
@@ -457,6 +470,7 @@ Popup {
457470

458471
function applySettings()
459472
{
473+
qopenhdConfPath = normalizeLocalFilePath(qopenhdConfPath)
460474

461475
imageWriter.setSetting("bootType", bootType)
462476
imageWriter.setSetting("camera", camera)
@@ -485,4 +499,18 @@ Popup {
485499
console.log("Failed to load OpenHD settings map: " + e)
486500
}
487501
}
502+
503+
function normalizeLocalFilePath(value) {
504+
if (!value)
505+
return ""
506+
if (typeof value !== "string" && value.toString)
507+
value = value.toString()
508+
if (value.startsWith("file:")) {
509+
value = decodeURIComponent(value.replace(/^file:\/\//, ""))
510+
if (value.startsWith("/") && value.length > 2 && value[2] === ":") {
511+
value = value.substring(1)
512+
}
513+
}
514+
return value
515+
}
488516
}

src/configure.qml

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ Rectangle {
3939
property string beep: ""
4040
property string eject: ""
4141
property bool useSettings: true
42-
property string qopenhdConfPath: imageWriter.getValue("qopenhdConfPath")
42+
property string qopenhdConfPath: ""
4343
property bool qopenhdConfPresent: false
4444

45-
Component.onCompleted: loadSettingsMap()
45+
Component.onCompleted: {
46+
qopenhdConfPath = normalizeLocalFilePath(imageWriter.getValue("qopenhdConfPath"))
47+
loadSettingsMap()
48+
}
4649

4750
function navigateBack() {
4851
if (mainWindow && mainWindow.showHome) {
@@ -130,7 +133,9 @@ ImButton {
130133

131134
ColumnLayout {
132135
anchors.fill: parent
133-
anchors.margins: driveSelected ? 16 : 32
136+
anchors.topMargin: -100
137+
anchors.leftMargin: 50
138+
anchors.rightMargin: 50
134139
spacing: 12
135140

136141
RowLayout {
@@ -142,19 +147,6 @@ ImButton {
142147
spacing: 4
143148
Layout.fillWidth: true
144149

145-
Text {
146-
id: storageHeader
147-
text: qsTr("Storage")
148-
color: "#fff"
149-
Layout.fillWidth: true
150-
Layout.preferredHeight: 17
151-
Layout.preferredWidth: 100
152-
font.pixelSize: 12
153-
font.family: robotoBold.name
154-
font.bold: true
155-
horizontalAlignment: Text.AlignHCenter
156-
}
157-
158150
ImButton {
159151
id: dstbutton
160152
text: driveSelected ? selectedDevice : qsTr("CHOOSE STORAGE")
@@ -493,6 +485,7 @@ ImButton {
493485
spacing: 10
494486

495487
Text {
488+
//not this
496489
text: qsTr("Storage")
497490
horizontalAlignment: Text.AlignHCenter
498491
verticalAlignment: Text.AlignVCenter
@@ -648,8 +641,35 @@ ImButton {
648641
nameFilters: [qsTr("QOpenHD.conf (*.conf)"), qsTr("All files (*)")]
649642
selectExisting: true
650643
onAccepted: {
651-
qopenhdConfPath = qopenhdConfDialog.fileUrl.toLocalFile()
644+
var selectedUrl = qopenhdConfDialog.fileUrl
645+
if (!selectedUrl || selectedUrl.toString().length === 0) {
646+
if (qopenhdConfDialog.fileUrls && qopenhdConfDialog.fileUrls.length > 0) {
647+
selectedUrl = qopenhdConfDialog.fileUrls[0]
648+
}
649+
}
650+
if (selectedUrl && selectedUrl.toString) {
651+
var selectedStr = selectedUrl.toString()
652+
if (selectedStr.startsWith("file:")) {
653+
qopenhdConfPath = normalizeLocalFilePath(selectedUrl.toLocalFile ? selectedUrl.toLocalFile() : selectedStr)
654+
} else {
655+
qopenhdConfPath = normalizeLocalFilePath(selectedStr)
656+
}
657+
}
658+
}
659+
}
660+
661+
function normalizeLocalFilePath(value) {
662+
if (!value)
663+
return ""
664+
if (typeof value !== "string" && value.toString)
665+
value = value.toString()
666+
if (value.startsWith("file:")) {
667+
value = decodeURIComponent(value.replace(/^file:\/\//, ""))
668+
if (value.startsWith("/") && value.length > 2 && value[2] === ":") {
669+
value = value.substring(1)
670+
}
652671
}
672+
return value
653673
}
654674

655675
function selectDstItem(d) {
@@ -908,6 +928,7 @@ ImButton {
908928
return
909929
}
910930

931+
qopenhdConfPath = normalizeLocalFilePath(qopenhdConfPath)
911932
if (qopenhdConfPath && qopenhdConfPath.length > 0) {
912933
var qopenhdTarget = drivePath(qopenhdConfRelativePath())
913934
if (!imageWriter.copyFile(qopenhdConfPath, qopenhdTarget)) {

src/downloadthread.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,9 @@ bool DownloadThread::_customizeImage()
13141314
}
13151315

13161316
if (!qopenhdConfPath.isEmpty()) {
1317+
if (qopenhdConfPath.startsWith("file:")) {
1318+
qopenhdConfPath = QUrl(qopenhdConfPath).toLocalFile();
1319+
}
13171320
QFileInfo confInfo(qopenhdConfPath);
13181321
if (!confInfo.exists() || !confInfo.isFile()) {
13191322
emit error(tr("QOpenHD.conf not found at the selected path."));

src/flash.qml

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -314,19 +314,7 @@ Rectangle {
314314
id: columnLayout
315315
spacing: 0
316316
Layout.fillWidth: true
317-
318-
Text {
319-
id: text1
320-
color: "#ffffff"
321-
text: qsTr("Operating System")
322-
Layout.fillWidth: true
323-
Layout.preferredHeight: 17
324-
Layout.preferredWidth: 100
325-
font.pixelSize: 12
326-
font.family: robotoBold.name
327-
font.bold: true
328-
horizontalAlignment: Text.AlignHCenter
329-
}
317+
Layout.alignment: Qt.AlignTop
330318

331319
ImButton {
332320
id: osbutton
@@ -359,19 +347,7 @@ Rectangle {
359347
id: columnLayout2
360348
spacing: 0
361349
Layout.fillWidth: true
362-
363-
Text {
364-
id: text2
365-
text: qsTr("Storage")
366-
color: "#fff"
367-
Layout.fillWidth: true
368-
Layout.preferredHeight: 17
369-
Layout.preferredWidth: 100
370-
font.pixelSize: 12
371-
font.family: robotoBold.name
372-
font.bold: true
373-
horizontalAlignment: Text.AlignHCenter
374-
}
350+
Layout.alignment: Qt.AlignTop
375351

376352
ImButton {
377353
id: dstbutton
@@ -392,12 +368,7 @@ Rectangle {
392368
ColumnLayout {
393369
spacing: 0
394370
Layout.fillWidth: true
395-
396-
Text {
397-
text: " "
398-
Layout.preferredHeight: 17
399-
Layout.preferredWidth: 100
400-
}
371+
Layout.alignment: Qt.AlignTop
401372

402373
ImButton {
403374
id: writebutton
@@ -1404,7 +1375,13 @@ Rectangle {
14041375
}
14051376

14061377
function onFileSelected(file) {
1407-
imageWriter.setSrc(file)
1378+
var normalized = file
1379+
if (typeof file === "string") {
1380+
if (file.indexOf("file:") !== 0) {
1381+
normalized = "file:///" + file.replace(/\\/g, "/")
1382+
}
1383+
}
1384+
imageWriter.setSrc(normalized)
14081385
osbutton.text = imageWriter.srcFileName()
14091386
ospopup.close()
14101387
if (imageWriter.readyToWrite()) {

src/imagewriter.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,60 @@ bool ImageWriter::removeFile(const QString &filePath) const
416416
return true;
417417
}
418418

419+
bool ImageWriter::hasOpenHdSettingsCard() const
420+
{
421+
auto devices = Drivelist::ListStorageDevices();
422+
bool filterSystemDrives = DRIVELIST_FILTER_SYSTEM_DRIVES;
423+
424+
for (auto &d : devices)
425+
{
426+
if (filterSystemDrives && d.isSystem)
427+
continue;
428+
429+
if (d.size == 0)
430+
continue;
431+
432+
#ifdef Q_OS_DARWIN
433+
if (d.isVirtual)
434+
continue;
435+
#endif
436+
437+
for (auto &mp : d.mountpoints)
438+
{
439+
QString mount = QString::fromStdString(mp);
440+
if (mount.isEmpty())
441+
continue;
442+
443+
if (mount.endsWith("/") || mount.endsWith("\\"))
444+
mount.chop(1);
445+
446+
QString mountLower = mount.toLower();
447+
if (mountLower == "/" || mountLower.startsWith("c:\\") || mountLower.startsWith("c:/"))
448+
continue;
449+
450+
QStorageInfo storage(mount);
451+
if (!storage.isValid() || !storage.isReady())
452+
continue;
453+
454+
QString fsType = QString::fromLatin1(storage.fileSystemType()).toLower();
455+
if (fsType.contains("exfat"))
456+
continue;
457+
458+
if (!fsType.contains("fat") && !fsType.contains("msdos"))
459+
continue;
460+
461+
QString settingsPath = QDir(mount).filePath("openhd/settings.json");
462+
if (QFileInfo::exists(settingsPath))
463+
{
464+
qDebug() << "[ImageWriter] OpenHD settings detected at" << settingsPath;
465+
return true;
466+
}
467+
}
468+
}
469+
470+
return false;
471+
}
472+
419473
/* Returns true if src and dst are set */
420474
bool ImageWriter::readyToWrite()
421475
{

src/imagewriter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class ImageWriter : public QObject
115115
Q_INVOKABLE bool fileExists(const QString &filePath) const;
116116
Q_INVOKABLE bool copyFile(const QString &sourcePath, const QString &destinationPath) const;
117117
Q_INVOKABLE bool removeFile(const QString &filePath) const;
118+
Q_INVOKABLE bool hasOpenHdSettingsCard() const;
118119

119120
Q_INVOKABLE bool getBoolSetting(const QString &key);
120121
Q_INVOKABLE QString getValue(const QString &key);

0 commit comments

Comments
 (0)