From d5a26c5a0eb3fd5e0d050d6906d906a534724871 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Wed, 3 Aug 2022 09:09:31 +0200 Subject: [PATCH] Feat: Add info dialog --- LedDisplayController/LedDisplayController.pro | 5 +- LedDisplayController/main.cpp | 3 +- .../ressources/qml/DisclaimerDialog.qml | 59 +++++++++++++++++++ LedDisplayController/ressources/qml/main.qml | 34 ++++++++++- LedDisplayController/ressources/qml/qml.qrc | 1 + 5 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 LedDisplayController/ressources/qml/DisclaimerDialog.qml diff --git a/LedDisplayController/LedDisplayController.pro b/LedDisplayController/LedDisplayController.pro index 1f6144e..e7fe2c6 100644 --- a/LedDisplayController/LedDisplayController.pro +++ b/LedDisplayController/LedDisplayController.pro @@ -2,7 +2,10 @@ QT += gui quick bluetooth quickcontrols2 CONFIG += c++11 TARGET = ItsblueLedDisplayController -VERSION = 1.2.0 +VERSION = 1.3.0 + +# Add version to define +DEFINES += APP_VERSION=\"\\\"$${VERSION}\\\"\" TEMPLATE = app diff --git a/LedDisplayController/main.cpp b/LedDisplayController/main.cpp index a253153..d883c8a 100644 --- a/LedDisplayController/main.cpp +++ b/LedDisplayController/main.cpp @@ -4,13 +4,13 @@ #include #include #include +#include #ifdef Q_OS_ANDROID #include #endif #include "leddisplaybackend.h" -#include "leddisplaytextmodel.h" /*void permissionCallback(const QtAndroid::PermissionResultMap& results) { for(QtAndroid::PermissionResult result : results) { @@ -38,6 +38,7 @@ int main(int argc, char *argv[]) QQuickStyle::setStyle("Material"); QQmlApplicationEngine engine; + engine.rootContext()->setContextProperty("APP_VERSION", APP_VERSION); const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { diff --git a/LedDisplayController/ressources/qml/DisclaimerDialog.qml b/LedDisplayController/ressources/qml/DisclaimerDialog.qml new file mode 100644 index 0000000..f658dde --- /dev/null +++ b/LedDisplayController/ressources/qml/DisclaimerDialog.qml @@ -0,0 +1,59 @@ +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Controls.Material 2.15 + +Dialog { + id: control + + title: "Disclaimer" + property string content: "" + + parent: Overlay.overlay + + x: (parent.width - width) * 0.5 + y: (parent.height - height) * 0.5 + + implicitWidth: parent.width * 0.9 + + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + contentHeight + topPadding + bottomPadding + + (implicitHeaderHeight > 0 ? implicitHeaderHeight + spacing : 0) + + (implicitFooterHeight > 0 ? implicitFooterHeight + spacing : 0)) + + //width: app.width * 0.8 + //height: implicitHeight + + modal: true + + standardButtons: Dialog.Close + + header: Label { + text: control.title + visible: control.title + elide: Label.ElideRight + padding: 24 + bottomPadding: 0 + font.bold: true + font.pixelSize: 16 + background: Rectangle { + radius: 2 + color: control.Material.dialogColor + clip: true + } + onLinkActivated: { + Qt.openUrlExternally(link) + } + } + + contentItem: Label { + wrapMode: Text.Wrap + + width: control.parent * 0.8 + + text: control.content + + onLinkActivated: { + Qt.openUrlExternally(link) + } + } +} diff --git a/LedDisplayController/ressources/qml/main.qml b/LedDisplayController/ressources/qml/main.qml index 4977a57..af6e7f7 100644 --- a/LedDisplayController/ressources/qml/main.qml +++ b/LedDisplayController/ressources/qml/main.qml @@ -59,6 +59,12 @@ ApplicationWindow { onClicked: mainStack.currentItem.backButtonClicked() } + ToolButton { + visible: mainStack.currentItem.actionButtonVisible + opacity: 0 + enabled: false + } + Label { Layout.fillHeight: true Layout.fillWidth: true @@ -71,13 +77,31 @@ ApplicationWindow { text: mainStack.currentItem.title } + ToolButton { + id: infoToolButton + + Layout.fillHeight: true + Layout.preferredWidth: height + + font.family: fontAwesome.name + font.pixelSize: height * 0.4 + Material.foreground: "black" + + flat: true + + text: "\uf05a" + + onClicked: infoDisclaimerDialog.open() + + } + ToolButton { id: actionToolButton Layout.fillHeight: true Layout.preferredWidth: height - opacity: mainStack.currentItem.actionButtonVisible ? 1:0 + visible: mainStack.currentItem.actionButtonVisible font.family: fontAwesome.name font.pixelSize: height * 0.4 @@ -270,5 +294,13 @@ ApplicationWindow { } } ] + + DisclaimerDialog { + id: infoDisclaimerDialog + + title: "LedDisplayController v" + APP_VERSION + "
By Itsblue Development, " + qsTr("privacy policy") + "" + content: qsTr("This app was built using the Qt Framework licensed under the GNU lgplV3 license.

This app is open source and licensed under the GNU agplV3 license, the source code can be found here.") + } + } } diff --git a/LedDisplayController/ressources/qml/qml.qrc b/LedDisplayController/ressources/qml/qml.qrc index 40ec2cd..e280279 100644 --- a/LedDisplayController/ressources/qml/qml.qrc +++ b/LedDisplayController/ressources/qml/qml.qrc @@ -14,5 +14,6 @@ Chip.qml DisplayEditDialog.qml PasswordInputDelegate.qml + DisclaimerDialog.qml