From 8f28effda9e9fe1349b9b5f3fb50824fb4fe6145 Mon Sep 17 00:00:00 2001 From: jlre249 Date: Fri, 24 May 2024 20:01:25 -0400 Subject: [PATCH] Cleanup (#27) misc updates: * shrink help/info icons + add text * hyperlink urls in about popup *adjust text in about popup *adjust wording of formatting text *adjust wording of custom img select *limit custom img select to zip files *adjust wording of invalid guid text *add text for missing guid --- src/MsgPopup.qml | 1 + src/UnraidOptionsPopup.qml | 6 -- src/downloadextractthread.cpp | 18 +--- src/imagewriter.cpp | 13 ++- src/imagewriter.h | 1 + src/main.qml | 196 ++++++++++++++++++++++------------ 6 files changed, 141 insertions(+), 94 deletions(-) diff --git a/src/MsgPopup.qml b/src/MsgPopup.qml index b678b842b..af2c3d9d9 100644 --- a/src/MsgPopup.qml +++ b/src/MsgPopup.qml @@ -20,6 +20,7 @@ Popup { property alias title: msgpopupheader.text property alias text: msgpopupbody.text + property alias body: msgpopupbody property bool continueButton: true property bool quitButton: false property bool yesButton: false diff --git a/src/UnraidOptionsPopup.qml b/src/UnraidOptionsPopup.qml index f5f6a0b09..c94ac477b 100644 --- a/src/UnraidOptionsPopup.qml +++ b/src/UnraidOptionsPopup.qml @@ -101,7 +101,6 @@ Popup { spacing: -10 RowLayout { - Layout.fillWidth: True Text { text : "Server Name:" color: !fieldServername.acceptableInput ? "red" : "white" @@ -114,10 +113,6 @@ Popup { maximumLength: 15 validator: RegExpValidator { regExp: /^[A-Za-z0-9]([A-Za-z0-9\-\.]{0,13}[A-Za-z0-9])?$/ } } - ImCheckBox { - id: checkboxLegacyBoot - text: "Enable Legacy Boot" - } } RowLayout { @@ -283,7 +278,6 @@ Popup { settings.dns = dnsField.fullAddress settings.netmask = fieldNetmask.currentText settings.servername = fieldServername.text - settings.legacyboot = checkboxLegacyBoot.checked imageWriter.setSavedCustomizationSettings(settings) diff --git a/src/downloadextractthread.cpp b/src/downloadextractthread.cpp index 84e27bf5a..ee11d3d38 100644 --- a/src/downloadextractthread.cpp +++ b/src/downloadextractthread.cpp @@ -417,23 +417,13 @@ void DownloadExtractThread::extractMultiFileRun() QFile::copy(":/unraid/syslinux/syslinux.exe", folder + "/syslinux/syslinux.exe"); } - QString permitUEFI{"Y"}; - if(_imgWriterSettings.contains("legacyboot") && _imgWriterSettings["legacyboot"].toBool()) { - // if legacy boot is enabled, tell make bootable script not to permite uefi - permitUEFI = "N"; - } - #ifdef Q_OS_WIN QString makeBootableScriptName{"make_bootable.bat"}; QString program{"cmd.exe"}; QStringList args; - args << "/C" << "echo " + permitUEFI + " | make_bootable.bat"; + args << "/C" << "echo Y | make_bootable.bat"; #elif defined(Q_OS_DARWIN) - QString makeBootableScriptName{"make_bootable_mac"); - QString program{"echo " + permitUEFI + " | ./" + makeBootableScriptName}; #elif defined(Q_OS_LINUX) - QString makeBootableScriptName{"make_bootable_linux"); - QString program{"echo " + permitUEFI + " | ./" + makeBootableScriptName}; #else throw runtime_error(tr("Formatting not implemented for this platform")); #endif @@ -450,10 +440,10 @@ void DownloadExtractThread::extractMultiFileRun() proc.waitForFinished(); QByteArray output = proc.readAllStandardOutput(); - qDebug() << output; + std::cout << output.toStdString() << std::endl; output = proc.readAllStandardError(); - qDebug() << output; - qDebug() << "Done running make_bootable script. Exit status code =" << proc.exitCode(); + std::cout << output.toStdString() << std::endl; + std::cout << "Done running make_bootable script. Exit status code =" << proc.exitCode() << std::endl; if (proc.exitCode()) { diff --git a/src/imagewriter.cpp b/src/imagewriter.cpp index eb3e2d631..4fbee1b1e 100644 --- a/src/imagewriter.cpp +++ b/src/imagewriter.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #ifndef QT_NO_WIDGETS #include #include @@ -218,7 +219,7 @@ void ImageWriter::setSrc(const QUrl &url, quint64 downloadLen, quint64 extrLen, } if (url.isLocalFile()) { - _initFormat = "auto"; + _initFormat = "UNRAID"; } } @@ -615,14 +616,14 @@ QByteArray ImageWriter::getFilteredOSlist() { reference_os_list_array.append(QJsonObject({ {"name", QApplication::translate("main", "Erase")}, - {"description", QApplication::translate("main", "Format card as FAT32")}, + {"description", QApplication::translate("main", "Format USB Drive as FAT32")}, {"icon", "icons/erase.png"}, {"url", "internal://format"}, })); reference_os_list_array.append(QJsonObject({ {"name", QApplication::translate("main", "Use custom")}, - {"description", QApplication::translate("main", "Select a custom .img from your computer")}, + {"description", QApplication::translate("main", "Select an Unraid .zip file from your computer")}, {"icon", "icons/use_custom.png"}, {"url", ""}, })); @@ -807,7 +808,7 @@ void ImageWriter::openFileDialog() QFileDialog *fd = new QFileDialog(nullptr, tr("Select image"), path, - "Image files (*.img *.zip *.iso *.gz *.xz *.zst);;All files (*)"); + "Unraid Image files (*.zip)"); connect(fd, SIGNAL(fileSelected(QString)), SLOT(onFileSelected(QString))); if (_engine) @@ -1498,3 +1499,7 @@ bool ImageWriter::getDstGuidValid() return _guidValid; } +bool ImageWriter::openUrl(const QString& url) +{ + return QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode)); +} diff --git a/src/imagewriter.h b/src/imagewriter.h index 8f7f57455..82825a70c 100644 --- a/src/imagewriter.h +++ b/src/imagewriter.h @@ -148,6 +148,7 @@ class ImageWriter : public QObject Q_INVOKABLE QString getInitFormat(); Q_INVOKABLE QString getDstDevice(); Q_INVOKABLE bool getDstGuidValid(); + Q_INVOKABLE bool openUrl(const QString& url); signals: /* We are emiting signals with QVariant as parameters because QML likes it that way */ diff --git a/src/main.qml b/src/main.qml index 61e3d058f..08623aec0 100644 --- a/src/main.qml +++ b/src/main.qml @@ -16,9 +16,9 @@ ApplicationWindow { visible: true width: imageWriter.isEmbeddedMode() ? -1 : 680 - height: imageWriter.isEmbeddedMode() ? -1 : 450 + height: imageWriter.isEmbeddedMode() ? -1 : 465 minimumWidth: imageWriter.isEmbeddedMode() ? -1 : 680 - minimumHeight: imageWriter.isEmbeddedMode() ? -1 : 420 + minimumHeight: imageWriter.isEmbeddedMode() ? -1 : 465 color: UnColors.darkGray @@ -53,7 +53,7 @@ ApplicationWindow { Layout.fillWidth: true Rectangle { id: logoContainer - implicitHeight: window.height/6 + implicitHeight: (window.height - 15)/6 Image { id: image @@ -61,7 +61,7 @@ ApplicationWindow { // Specify the maximum size of the image width: window.width * 0.45 - height: window.height / 3 + height: (window.height - 15) / 3 // Within the image's specified size rectangle, resize the // image to fit within the rectangle while keeping its aspect @@ -80,25 +80,45 @@ ApplicationWindow { // Equal padding above and below the image anchors.top: logoContainer.top anchors.bottom: logoContainer.bottom - anchors.topMargin: window.height / 25 - anchors.bottomMargin: window.height / 25 + anchors.topMargin: (window.height - 15) / 25 + anchors.bottomMargin: (window.height - 15) / 25 } } Item { Layout.fillWidth: true } + Text { + color: UnColors.orange + text: qsTr("Help") + font.pixelSize: 12 + font.family: robotoBold.name + font.bold: true + anchors.right: helpImage.left + anchors.rightMargin: 5 + anchors.top: parent.top + anchors.topMargin: 10 + MouseArea { + anchors.fill: parent + onClicked: imageWriter.openUrl("https://docs.unraid.net/unraid-os/getting-started/quick-install-guide/") + } + } + Image { id: helpImage source: "icons/help.png" MouseArea { anchors.fill: parent - onClicked: Qt.openUrlExternally("https://docs.unraid.net/unraid-os/getting-started/quick-install-guide/") + onClicked: imageWriter.openUrl("https://docs.unraid.net/unraid-os/getting-started/quick-install-guide/") } - Layout.preferredHeight: image.height - Layout.preferredWidth: image.height - sourceSize.width: image.height - sourceSize.height: image.height + Layout.preferredHeight: 15 + Layout.preferredWidth: 15 + sourceSize.width: 15 + sourceSize.height: 15 + anchors.right: parent.right + anchors.rightMargin: 10 + anchors.top: parent.top + anchors.topMargin: 10 fillMode: Image.PreserveAspectFit } ColorOverlay { @@ -117,7 +137,7 @@ ApplicationWindow { Rectangle { color: UnColors.darkGray implicitWidth: window.width - implicitHeight: window.height * (1 - 1/6) + implicitHeight: (window.height - 15) * (1 - 1/6) GridLayout { id: gridLayout @@ -128,7 +148,7 @@ ApplicationWindow { anchors.rightMargin: 50 anchors.leftMargin: 50 - rows: 6 + rows: 5 columns: 3 columnSpacing: 15 @@ -495,6 +515,22 @@ ApplicationWindow { } } + DropArea { + anchors.fill: parent + onEntered: { + if (drag.active && mimeData.hasUrls()) { + drag.acceptProposedAction() + } + } + onDropped: { + if (drop.urls && drop.urls.length > 0) { + onFileSelected(drop.urls[0].toString()) + } + } + } + + } + RowLayout { Image { id: infoImage source: "icons/info.png" @@ -502,10 +538,10 @@ ApplicationWindow { anchors.fill: parent onClicked: infopopup.openPopup() } - Layout.preferredHeight: image.height - Layout.preferredWidth: image.height - sourceSize.width: image.height - sourceSize.height: image.height + Layout.preferredHeight: 15 + Layout.preferredWidth: 15 + sourceSize.width: 15 + sourceSize.height: 15 fillMode: Image.PreserveAspectFit anchors.left: parent.left anchors.leftMargin: 10 @@ -517,23 +553,22 @@ ApplicationWindow { source: infoImage color: UnColors.orange } - - DropArea { - anchors.fill: parent - onEntered: { - if (drag.active && mimeData.hasUrls()) { - drag.acceptProposedAction() - } - } - onDropped: { - if (drop.urls && drop.urls.length > 0) { - onFileSelected(drop.urls[0].toString()) - } + Text { + color: UnColors.orange + text: qsTr("Info") + font.pixelSize: 12 + font.family: robotoBold.name + font.bold: true + anchors.left: infoImage.right + anchors.leftMargin: 5 + anchors.bottom: parent.bottom + anchors.bottomMargin: 10 + MouseArea { + anchors.fill: parent + onClicked: infopopup.openPopup() } } - } - } Popup { @@ -1005,7 +1040,7 @@ ApplicationWindow { visible: typeof(website) == "string" && website MouseArea { anchors.fill: parent - onClicked: Qt.openUrlExternally(website) + onClicked: imageWriter.openUrl(website) } } Item { @@ -1181,13 +1216,9 @@ ApplicationWindow { width: window.width-100 height: 60 Accessible.name: { - var txt = description+" - "+(size/1000000000).toFixed(1)+" gigabytes" + var txt = description+" - "+(size/1000000000).toFixed(1)+" GB" if (mountpoints.length > 0) { - txt += qsTr("Mounted as %1").arg(mountpoints.join(", ")) - if(guid != "") { - txt += "GUID: %1".arg(guid) - if(!guidValid) txt += " [INVALID]" - } + txt += qsTr(" Mounted as %1").arg(mountpoints.join(", ")) } return txt; } @@ -1232,40 +1263,62 @@ ApplicationWindow { } Column { width: parent.parent.width-64 - - Text { - textFormat: Text.StyledText - height: parent.parent.parent.height - verticalAlignment: Text.AlignVCenter - font.family: roboto.name - text: { - var sizeStr = (size/1000000000).toFixed(1)+" GB"; - var txt; - if (isReadOnly) { - txt = "

"+description+" - "+sizeStr+"

" + ColumnLayout { + spacing: 1 + Text { + textFormat: Text.StyledText + height: parent.parent.parent.parent.height / 3 + //verticalAlignment: Text.AlignVCenter + font.family: roboto.name + font.pixelSize: 14 + text: { + var sizeStr = (size/1000000000).toFixed(1) + " GB"; + var txt = description + " - " + sizeStr + return txt + } + color: dstbgrect.mouseOver ? UnColors.darkGray : "white" + opacity: enabled ? 1.0 : 0.3 + Layout.topMargin: 5 + } + Text { + textFormat: Text.StyledText + height: parent.parent.parent.parent.height / 3 + //verticalAlignment: Text.AlignVCenter + font.family: roboto.name + font.pixelSize: 12 + text: { + var txt = "" if (mountpoints.length > 0) { - txt += qsTr("Mounted as %1").arg(mountpoints.join(", "))+"
" - if(guid != "") { - txt += "GUID: %1".arg(guid) - if(!guidValid) txt += " [INVALID]" - } + txt += qsTr("Mounted as %1 ").arg(mountpoints.join(", ")) } - txt += qsTr("[WRITE PROTECTED]")+"" - } else { - txt = "

"+description+" - "+sizeStr+"

" - if (mountpoints.length > 0) { - txt += qsTr("Mounted as %1").arg(mountpoints.join(", "))+"
" - if(guid != "") { - txt += "GUID: %1".arg(guid) - if(!guidValid) txt += " [INVALID]" - } + if (isReadOnly) { + txt += qsTr("[WRITE PROTECTED]") + } + return txt + } + color: dstbgrect.mouseOver ? UnColors.darkGray : "white" + opacity: enabled ? 1.0 : 0.3 + anchors.topMargin: 10 + } + Text { + textFormat: Text.StyledText + height: parent.parent.parent.parent.height / 3 + //verticalAlignment: Text.AlignVCenter + font.family: roboto.name + font.pixelSize: 12 + text: { + var txt = "" + if(guid != "") { + txt += "GUID: %1".arg(guid) + if(!guidValid) txt += " [BLACKLISTED - Choose Another Flash Device]" + } else { + txt += "[MISSING GUID - Choose Another Flash Device]" } - txt += "" + return txt; } - return txt; + color: dstbgrect.mouseOver ? UnColors.darkGray : "white" + opacity: enabled ? 1.0 : 0.3 } - color: dstbgrect.mouseOver ? UnColors.darkGray : "white" - opacity: enabled ? 1.0 : 0.3 } } } @@ -1299,11 +1352,14 @@ ApplicationWindow { MsgPopup { id: infopopup + x: 50 + width: parent.width - 100 continueButton: false yesButton: false noButton: false title: qsTr("About") - text: qsTr("For license, credits and history, please read:
https://github.com/unraid/usb-creator-next

To report issues with this tool, please email:
general@support.unraid.net") + body.onLinkActivated: imageWriter.openUrl(body.link) + text: qsTr("License, Credits, and History: ") + "https://github.com/unraid/usb-creator-next

" + qsTr("Help / Feedback: ") + "https://unraid.net/contact" } MsgPopup { @@ -1364,7 +1420,7 @@ ApplicationWindow { title: qsTr("Update available") text: qsTr("There is a newer version of Imager available.
Would you like to visit the website to download it?") onYes: { - Qt.openUrlExternally(url) + imageWriter.openUrl(url) } } @@ -1463,7 +1519,7 @@ ApplicationWindow { } msgpopup.openPopup() - imageWriter.setDst("") + imageWriter.setDst("", false) dstbutton.text = qsTr("CHOOSE STORAGE") resetWriteButton() }