diff --git a/app/app.pri b/app/app.pri index af71e021727b9d5a1f4a34d14f08d87177ee8187..0a0cd1ec320382fbc250d00a5ba1f6bf139b5be3 100644 --- a/app/app.pri +++ b/app/app.pri @@ -16,6 +16,7 @@ SOURCES += \ RESOURCES += \ $${PWD}/configs/configs.qrc \ + $${PWD}/images/images.qrc \ $${PWD}/qml/qml.qrc INCLUDEPATH += $${PWD}/src diff --git a/app/images/icons/dialog-information.svg b/app/images/icons/dialog-information.svg new file mode 100644 index 0000000000000000000000000000000000000000..308bd4effd3bf6645e3d32ece1ba870ae9407643 --- /dev/null +++ b/app/images/icons/dialog-information.svg @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="128" height="128" viewBox="0, 0, 128, 128"> + <g id="icon"> + <path d="M64,8 C33.072,8 8,33.072 8,64 C8,94.928 33.072,120 64,120 C94.928,120 120,94.928 120,64 C120,33.072 94.928,8 64,8 z M64,24 C68.418,24 72,27.582 72,32 C72,36.418 68.418,40 64,40 C59.582,40 56,36.418 56,32 C56,27.582 59.582,24 64,24 z M48,48 L72,48 L72,96 L80,96 L80,104 L48,104 L48,96 L56,96 L56,56 L48,56 L48,48 z" fill="#000000" id="dialog-information"/> + </g> +</svg> diff --git a/app/images/icons/dialog-warning.svg b/app/images/icons/dialog-warning.svg new file mode 100644 index 0000000000000000000000000000000000000000..3227b79aea5172ed3c13f5497f1ff5d3097c1349 --- /dev/null +++ b/app/images/icons/dialog-warning.svg @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="128" height="128" viewBox="0, 0, 128, 128"> + <g id="icon"> + <path d="M64,16 L8,112 L120,112 L64,16 z M56,48 L72,48 L72,80 L56,80 L56,48 z M64,88 C68.418,88 72,91.582 72,96 C72,100.418 68.418,104 64,104 C59.582,104 56,100.418 56,96 C56,91.582 59.582,88 64,88 z" fill="#000000" id="dialog-warning"/> + </g> +</svg> diff --git a/app/images/icons/emblem-default.svg b/app/images/icons/emblem-default.svg new file mode 100644 index 0000000000000000000000000000000000000000..0c29d9a675fbdad3873a7c5c5cbeb379c7c91d86 --- /dev/null +++ b/app/images/icons/emblem-default.svg @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="128" height="128" viewBox="0, 0, 128, 128"> + <g id="icon"> + <path d="M64,8 C33.072,8 8,33.072 8,64 C8,94.928 33.072,120 64,120 C94.928,120 120,94.928 120,64 C120,33.072 94.928,8 64,8 z M80,32 L104,32 L56,104 L32,80 L32,56 L56,80 L80,32 z" fill="#000000" id="emblem-default"/> + </g> +</svg> diff --git a/app/images/icons/emblem-downloads.svg b/app/images/icons/emblem-downloads.svg new file mode 100644 index 0000000000000000000000000000000000000000..dafc2dbce4da6d8f48b0273fefd9769130f6779f --- /dev/null +++ b/app/images/icons/emblem-downloads.svg @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="128" height="128" viewBox="0, 0, 128, 128"> + <g id="icon"> + <path d="M40,8 L40,48 L16,48 L64,96 L112,48 L88,48 L88,8 L40,8 z M8,72 L8,120 L120,120 L120,72 L104,72 L104,104 L24,104 L24,72 L8,72 z" fill="#000000" id="emblem-downloads"/> + </g> +</svg> diff --git a/app/images/images.qrc b/app/images/images.qrc new file mode 100644 index 0000000000000000000000000000000000000000..892ca1d82a513bc32268d6e6f70d06a6f062b61f --- /dev/null +++ b/app/images/images.qrc @@ -0,0 +1,8 @@ +<RCC> + <qresource prefix="/images"> + <file>icons/dialog-information.svg</file> + <file>icons/dialog-warning.svg</file> + <file>icons/emblem-default.svg</file> + <file>icons/emblem-downloads.svg</file> + </qresource> +</RCC> diff --git a/app/qml/main.qml b/app/qml/main.qml index 810065b1cb15ec99185155581907f6ac7a5399ea..6e0e388f0c656dec2176e1d9b74e9fc4613ec66b 100644 --- a/app/qml/main.qml +++ b/app/qml/main.qml @@ -1,106 +1,28 @@ -import QtQuick 2.3 -import QtQuick.Window 2.0 -import QtQuick.Controls 1.2 -import QtQuick.Dialogs 1.2 +// Still support Qt 5.2 +import QtQuick 2.0 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 1.0 + +import "ui" as Ui import "scripts/Utility.js" as Utility -Window { +ApplicationWindow { id: app - title: Qt.application.name + + title: configHandler.getAppConfigApplication().name + + visible: true width: 400 - height: 200 minimumWidth: 400 + maximumWidth: 400 + height: 200 minimumHeight: 200 - maximumWidth: 800 maximumHeight: 400 - MessageDialog { - id: confirmDialog - title: app.title - icon: StandardIcon.Question - text: "" - informativeText: "" - detailedText: "" - standardButtons: StandardButton.Ok | StandardButton.Cancel - onAccepted: ocsUrlHandler.process() - onRejected: Qt.quit() - } - - MessageDialog { - id: infoDialog - title: app.title - icon: StandardIcon.Information - text: "" - informativeText: "" - detailedText: "" - standardButtons: StandardButton.Open | StandardButton.Close - onAccepted: { - ocsUrlHandler.openDestination(); - Qt.quit(); - } - onRejected: Qt.quit() - } - - MessageDialog { - id: errorDialog - title: app.title - icon: StandardIcon.Warning - text: "" - informativeText: "" - detailedText: "" - standardButtons: StandardButton.Close - onRejected: Qt.quit() - } - - Dialog { - id: progressDialog - title: app.title - property alias primaryLabel: primaryLabel - property alias informativeLabel: informativeLabel - property alias progressBar: progressBar - property alias progressLabel: progressLabel - contentItem: Item { - implicitWidth: 400 - implicitHeight: 150 - Column { - anchors.fill: parent - anchors.margins: 12 - spacing: 8 - Label { - id: primaryLabel - text: " " - font.bold: true - } - Label { - id: informativeLabel - text: " " - } - ProgressBar { - id: progressBar - maximumValue: 1 - minimumValue: 0 - value: 0 - anchors.left: parent.left - anchors.right: parent.right - } - Label { - id: progressLabel - text: " " - anchors.right: parent.right - } - Button { - id: cancelButton - text: qsTr("Cancel") - anchors.right: parent.right - onClicked: Qt.quit() - } - } - } - } - - Component.onCompleted: { + function init() { var metadata = ocsUrlHandler.metadata(); + var primaryMessages = { "success_download": qsTr("Download successfull"), "success_install": qsTr("Installation successfull"), @@ -116,7 +38,7 @@ Window { ocsUrlHandler.finishedWithSuccess.connect(function(result) { progressDialog.close(); - infoDialog.text = primaryMessages[result.status]; + infoDialog.primaryText = primaryMessages[result.status]; infoDialog.informativeText = metadata.filename; infoDialog.detailedText = result.message; infoDialog.open(); @@ -124,37 +46,112 @@ Window { ocsUrlHandler.finishedWithError.connect(function(result) { progressDialog.close(); - errorDialog.text = primaryMessages[result.status]; + errorDialog.primaryText = primaryMessages[result.status]; errorDialog.informativeText = metadata.filename; errorDialog.detailedText = result.message; errorDialog.open(); }); ocsUrlHandler.downloadProgress.connect(function(id, bytesReceived, bytesTotal) { - progressDialog.primaryLabel.text = qsTr("Downloading"); - progressDialog.informativeLabel.text = metadata.filename; - progressDialog.progressBar.value = bytesReceived / bytesTotal; - progressDialog.progressLabel.text = Utility.convertByteToHumanReadable(bytesReceived) - + " / " + Utility.convertByteToHumanReadable(bytesTotal) + progressDialog.primaryText = qsTr("Downloading"); + progressDialog.informativeText = metadata.filename; + progressDialog.progress = bytesReceived / bytesTotal; + progressDialog.progressText + = Utility.convertByteToHumanReadable(bytesReceived) + + " / " + Utility.convertByteToHumanReadable(bytesTotal); }); if (ocsUrlHandler.isValid()) { if (metadata.command === "download") { - confirmDialog.text = qsTr("Do you want to download?"); + confirmDialog.primaryText = qsTr("Do you want to download?"); } else if (metadata.command === "install") { - confirmDialog.text = qsTr("Do you want to install?"); + confirmDialog.primaryText = qsTr("Do you want to install?"); } confirmDialog.informativeText = metadata.filename; - confirmDialog.detailedText = qsTr("URL") + ": " + metadata.url + "\n\n" - + qsTr("File") + ": " + metadata.filename + "\n\n" - + qsTr("Type") + ": " + metadata.type; + confirmDialog.detailedText + = qsTr("URL") + ": " + metadata.url + "\n" + + qsTr("File") + ": " + metadata.filename + "\n" + + qsTr("Type") + ": " + configHandler.getAppConfigInstallTypes()[metadata.type].name; confirmDialog.open(); } else { - errorDialog.text = qsTr("Validation error"); + errorDialog.primaryText = primaryMessages["error_validation"]; errorDialog.detailedText = qsTr("Invalid OCS-URL"); errorDialog.open(); } } + + Ui.Dialog { + id: confirmDialog + icon: "qrc:/images/icons/dialog-information.svg" + acceptButton.text: qsTr("OK") + acceptButton.onClicked: { + close(); + ocsUrlHandler.process(); + } + rejectButton.text: qsTr("Cancel") + rejectButton.onClicked: { + close(); + Qt.quit(); + } + } + + Ui.Dialog { + id: infoDialog + icon: "qrc:/images/icons/emblem-default.svg" + acceptButton.text: qsTr("Open") + acceptButton.onClicked: { + close(); + ocsUrlHandler.openDestination(); + Qt.quit(); + } + rejectButton.text: qsTr("Close") + rejectButton.onClicked: { + close(); + Qt.quit(); + } + } + + Ui.Dialog { + id: errorDialog + icon: "qrc:/images/icons/dialog-warning.svg" + rejectButton.text: qsTr("Close") + rejectButton.onClicked: { + close(); + Qt.quit(); + } + } + + Ui.Dialog { + id: progressDialog + icon: "qrc:/images/icons/emblem-downloads.svg" + property alias progress: progressBar.value + property alias progressText: progressText.text + content: ColumnLayout { + anchors.fill: parent + spacing: 4 + ProgressBar { + id: progressBar + minimumValue: 0 + maximumValue: 1 + value: 0 + Layout.fillWidth: true + } + Label { + id: progressText + text: "" + Layout.alignment: Qt.AlignRight + } + } + rejectButton.text: qsTr("Cancel") + rejectButton.onClicked: { + close(); + Qt.quit(); + } + } + + Component.onCompleted: { + app.init(); + } } diff --git a/app/qml/qml.qrc b/app/qml/qml.qrc index 640e9f07108d13e701a9470cb50262b1ce40e70b..f0579e64390605af3ebc388c11d1887e1286a54c 100644 --- a/app/qml/qml.qrc +++ b/app/qml/qml.qrc @@ -1,6 +1,7 @@ <RCC> <qresource prefix="/qml"> <file>main.qml</file> + <file>ui/Dialog.qml</file> <file>scripts/Utility.js</file> </qresource> </RCC> diff --git a/app/qml/ui/Dialog.qml b/app/qml/ui/Dialog.qml new file mode 100644 index 0000000000000000000000000000000000000000..cb316c2134b836d05315a373023f141800c508b0 --- /dev/null +++ b/app/qml/ui/Dialog.qml @@ -0,0 +1,95 @@ +import QtQuick 2.0 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 1.0 + +ColumnLayout { + id: dialog + + visible: false + anchors.fill: parent + anchors.margins: 12 + spacing: 12 + + property alias icon: icon.source + property alias primaryText: primaryText.text + property alias informativeText: informativeText.text + property alias detailedText: detailedText.text + property alias content: content.children + property alias acceptButton: acceptButton + property alias rejectButton: rejectButton + + function open() { + dialog.visible = true; + } + + function close() { + dialog.visible = false; + } + + RowLayout { + Layout.fillWidth: true + spacing: 12 + Image { + id: icon + source: "" + visible: source.toString() ? true : false + Layout.preferredWidth: 48 + Layout.preferredHeight: 48 + } + ColumnLayout { + Layout.fillWidth: true + spacing: 4 + Label { + id: primaryText + text: "" + visible: text ? true : false + Layout.fillWidth: true + wrapMode: Text.WrapAnywhere + font.bold: true + } + Label { + id: informativeText + text: "" + visible: text ? true : false + Layout.fillWidth: true + wrapMode: Text.WrapAnywhere + } + } + } + + Label { + id: detailedText + text: "" + visible: text ? true : false + Layout.fillWidth: true + wrapMode: Text.WrapAnywhere + color: "#444444" + } + + Item { + id: content + Layout.fillWidth: true + } + + Item { + Layout.fillHeight: true + } + + RowLayout { + Layout.fillWidth: true + spacing: 4 + Item { + Layout.fillWidth: true + } + Button { + id: acceptButton + text: "" + visible: text ? true : false + } + Button { + id: rejectButton + text: "" + visible: text ? true : false + } + } +}