From cc855bd3292a20da577b79eba0b45ace455ef166 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Fri, 25 Jun 2021 09:41:07 +0200 Subject: [PATCH] Optimizations in QrCodePage --- resources/qml/Components/DataListView.qml | 15 -- resources/qml/Components/DisclaimerDialog.qml | 14 +- .../QrCodeScanPage.qml} | 149 +++++++++++------- resources/qml/Pages/StartPage.qml | 10 +- resources/qml/qml.qrc | 2 +- resources/translations/de.qm | Bin 5716 -> 5769 bytes resources/translations/de.ts | 30 ++-- resources/translations/en.qm | Bin 5320 -> 5373 bytes resources/translations/en.ts | 30 ++-- sources/bluerockbackend.cpp | 4 +- 10 files changed, 141 insertions(+), 113 deletions(-) rename resources/qml/{Components/QrCodeScanPopup.qml => Pages/QrCodeScanPage.qml} (67%) diff --git a/resources/qml/Components/DataListView.qml b/resources/qml/Components/DataListView.qml index 38f7c7a..edc4270 100644 --- a/resources/qml/Components/DataListView.qml +++ b/resources/qml/Components/DataListView.qml @@ -64,21 +64,6 @@ ListView { } } - InfoArea { - id: infoArea - - anchors { - left: control.left - right: control.right - top: control.top - margins: app.landscape() ? control.width * 0.4:control.width * 0.3 - topMargin: control.height*( status === 901 ? 0.6:0.5) - height * 0.8 - } - - excludedCodes: [200, 902, 905] - errorCode: control.status - } - PullRefresher { target: control diff --git a/resources/qml/Components/DisclaimerDialog.qml b/resources/qml/Components/DisclaimerDialog.qml index c96c3cf..71b172c 100644 --- a/resources/qml/Components/DisclaimerDialog.qml +++ b/resources/qml/Components/DisclaimerDialog.qml @@ -13,8 +13,15 @@ Dialog { x: (parent.width - width) * 0.5 y: (parent.height - height) * 0.5 - width: parent.width * 0.8 - height: implicitHeight + 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 @@ -41,8 +48,7 @@ Dialog { contentItem: Label { wrapMode: Text.Wrap - width: control.width * 0.8 - height: implicitHeight + width: control.parent * 0.8 text: control.content diff --git a/resources/qml/Components/QrCodeScanPopup.qml b/resources/qml/Pages/QrCodeScanPage.qml similarity index 67% rename from resources/qml/Components/QrCodeScanPopup.qml rename to resources/qml/Pages/QrCodeScanPage.qml index 1ebc2ca..7474d1c 100644 --- a/resources/qml/Components/QrCodeScanPopup.qml +++ b/resources/qml/Pages/QrCodeScanPage.qml @@ -6,30 +6,23 @@ import QtMultimedia 5.12 import QtQuick.Shapes 1.12 import QtQuick.Controls.Material 2.12 +import "../Components" -Dialog { +Page { id: control property string _statusText: "" property string _statusColor: Material.primaryTextColor property bool _freezeScanning: false + signal headerComponentChanged() - parent: Overlay.overlay - - x: (parent.width - width) * 0.5 - y: (parent.height - height) * 0.5 - - height: app.height * 0.8 - width: app.width * 0.8 - - modal: true //% "Scan QR-Code" title: qsTrId("#scanQrCode") - standardButtons: Dialog.Cancel + onFocusChanged: focus ? open() : close() - onOpened: { - setDefaultStatusText() + function open() { + _setDefaultStatusText() control._freezeScanning = false if(serverConn.isCameraPermissionGranted()) cameraLoader.sourceComponent = cameraComponent @@ -37,18 +30,49 @@ Dialog { cameraLoader.sourceComponent = noPermissionComponent } - onClosed: cameraLoader.sourceComponent = null + function close() { + cameraLoader.sourceComponent = null + } - function setDefaultStatusText() { + function _setDefaultStatusText() { //% "Place the Code in the center" _statusText = qsTrId("#placeQrCodeInCenter") _statusColor = Material.primaryTextColor } + function _handleTag(tag) { + if(control._freezeScanning) + return + + control._freezeScanning = true + + //% "Plase wait" + control._statusText = qsTrId("#pleaseWait") + "..." + + if(app.openWidgetFromUrl(tag)) + control.close() + else { + //% "Invalid QR-Code" + control._statusText = qsTrId("#invalidQrCode") + control._statusColor = Material.color(Material.Red) + statusTextResetTimer.start() + control._freezeScanning = false + } + } + + function _requestCameraPermission() { + var permissionGranted = serverConn.requestCameraPermission() + + if(permissionGranted) + cameraLoader.sourceComponent = cameraComponent + } + contentItem: Loader { id: cameraLoader - asynchronous: true + anchors.fill: parent + + //asynchronous: true sourceComponent: null } @@ -68,6 +92,10 @@ Dialog { } } + FancyBusyIndicator { + anchors.centerIn: parent + } + VideoOutput { id: videoOutput x: 0 @@ -116,7 +144,7 @@ Dialog { border.width: width * 0.1 border.color: "#000000" - opacity: 0.3 + opacity: 0.5 color: "transparent" } @@ -173,50 +201,53 @@ Dialog { Component { id: noPermissionComponent - Item { - anchors.fill: parent + ColumnLayout { + //anchors.fill: parent + //anchors.margins: app.landscape() ? app.height * 0.1 : app.width * 0.1 + + property int columnWidth: control.width * 0.9 + + spacing: height * 0.02 + + Item { + Layout.fillHeight: true + } Label { id: noPermissionIcon - anchors { - top: parent.top - topMargin: parent.height * 0 - horizontalCenter: parent.horizontalCenter - } - font.pixelSize: parent.height * 0.3 + + Layout.preferredWidth: parent.columnWidth + Layout.alignment: Layout.Center + + font.pixelSize: app.landscape() ? parent.height * 0.25:parent.height * 0.15 font.family: fa5solid.name + + horizontalAlignment: Text.AlignHCenter + text: "\uf3ed" } Label { id: noPermissionText - anchors { - top: noPermissionIcon.bottom - topMargin: noPermissionIcon.height * 0.15 - horizontalCenter: parent.horizontalCenter - } - width: parent.width * 0.9 + Layout.preferredWidth: parent.columnWidth + Layout.alignment: Layout.Center font.bold: true - font.pixelSize: noPermissionIcon.height * 0.15 + font.pixelSize: noPermissionIcon.height * 0.2 horizontalAlignment: Text.AlignHCenter wrapMode: Text.Wrap - //% "Camera permission denied!" + //% "Camera access required" text: qsTrId("#cameraPermissionDenied") } Label { id: noPermissionDetailText - anchors { - top: noPermissionText.bottom - topMargin: noPermissionText.height * 0.15 - horizontalCenter: parent.horizontalCenter - } - width: parent.width * 0.9 + Layout.preferredWidth: parent.columnWidth + Layout.alignment: Layout.Center font.pixelSize: noPermissionText.font.pixelSize * 0.7 @@ -224,10 +255,26 @@ Dialog { wrapMode: Text.Wrap - //% "This app requires access to your camera in order to scan QR-Codes. It will never record or store any photos or videos." + //% "blueROCK needs to access your camera in order to scan QR-Codes. It will never record or store any photos or videos." text: qsTrId("#cameraPermissionDeniedDetails") } + Button { + id: grantPermissionButton + + Layout.alignment: Layout.Center + + //% "Allow access" + text: qsTrId("#allowAccess") + + onClicked: control._requestCameraPermission() + } + + + Item { + Layout.fillHeight: true + } + } } @@ -235,25 +282,7 @@ Dialog { id: zxingFilter decoder { - onTagFound: { - if(control._freezeScanning) - return - - control._freezeScanning = true - - //% "Plase wait" - control._statusText = qsTrId("#pleaseWait") + "..." - - if(app.openWidgetFromUrl(tag)) - control.close() - else { - //% "Invalid QR-Code" - control._statusText = qsTrId("#invalidQrCode") - control._statusColor = Material.color(Material.Red) - statusTextResetTimer.start() - control._freezeScanning = false - } - } + onTagFound: control._handleTag(tag) enabledDecoders: QZXing.DecoderFormat_QR_CODE } @@ -264,6 +293,6 @@ Dialog { running: false repeat: false interval: 3000 - onTriggered: setDefaultStatusText() + onTriggered: _setDefaultStatusText() } } diff --git a/resources/qml/Pages/StartPage.qml b/resources/qml/Pages/StartPage.qml index ebc6a09..eb8b0db 100644 --- a/resources/qml/Pages/StartPage.qml +++ b/resources/qml/Pages/StartPage.qml @@ -117,7 +117,9 @@ Page { ], //% "About blueROCK" ["\uf05a", qsTrId("#aboutBluerock"), aboutBluerockDisclaimerDialog.open], - ["\uf029", qsTrId("#scanQrCode"), qrCodeScanPopup.open], + ["\uf029", qsTrId("#scanQrCode"), function(){ + mainStack.push("qrc:/Pages/QrCodeScanPage.qml") + }], ] model: buttons @@ -172,10 +174,4 @@ Page { //% "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.

Resultservice and rankings provided by digital ROCK." content: qsTrId("#aboutBluerockDisclaimer") } - - QrCodeScanPopup { - id: qrCodeScanPopup - Material.theme: root.Material.theme - } - } diff --git a/resources/qml/qml.qrc b/resources/qml/qml.qrc index 5fe014c..4393e01 100644 --- a/resources/qml/qml.qrc +++ b/resources/qml/qml.qrc @@ -29,6 +29,6 @@ Components/ColoredItemDelegate.qml Components/AlignedButton.qml Components/SharePopup.qml - Components/QrCodeScanPopup.qml + Pages/QrCodeScanPage.qml diff --git a/resources/translations/de.qm b/resources/translations/de.qm index 0fa4d501ea2ac771a397ab35fe01665f7aa41a51..91dae98cbedded9ac2175a9d642b070084e334b3 100644 GIT binary patch delta 556 zcmY*VT}V@57=CvCw{vz*a~9QBnaiL&mKl-+LQ4oj5(G_(AZ$B@ZOwF!nKzSusID~D zilRT2vWqCkyfFH?FoLjzqAcqwBMgE<0xznY9=nr|kMDcG_xXFjclP;;{y^p&gv(Qa zl)#2t4*}(_>+u!`SYo)o?%4^LhG2!(0rECsECjy45oRi@0e@a>x&ICDHj4XWrNq^X z2QK~sjKku+U>R|{#c}sI``yyUgO5mrlya5=YNON}y~6%k=}(k(#y=;Aiwl5nncT3W zi9&PoNY5ak1?ABXLnOSGe_nr1;k;5iL1F8Os^zDF;z2dBDM#K9wY%>m>lXFe34uPf z>W#Gw;(MwNeBa8TnpQq}o4k}}M~XOzTkE%F>aNg6?u;S>b4>d^^o2>M+@H$kX|%>Y z^WYitUhtHfX8?Vdr=}rGVxOnEhl2XBUj5=F4RZRaBMj=>X9TXE28z18v3j2RtT%S4 zjs`cqe}|i?yV7i0PnBct*XGhkHpp1p`#=!ui7}q$HIUsCv9Gi zFydV8NTUR;h;TVbBB?F>rNV85TI2EdbT|@mlF6*Cq$_OH5qXTbPM(WctUCGLffU;Q g-=f*~O1Wz`+u`xAO0eS~O7#+S(Qy&8P@@K|e|2<)DF6Tf delta 526 zcmW+yUr1AN6#jPq?02{8y|=6O5F0Ud3hIhdqcH?xJgKE^VaiVPfkc zdT6pNivF*^AYsgh#2!KkA`t?UA|I>>qOc;NhYF%^avsk4zH`oZzTfZcw%4JYFEa}1 z(lVeVP=9j>l)GZp zfVoxfzOW9I?U5(_wVdMsMZhc8%D<`zaZ-L5`NNk?~>}O*5{1|bAxH=;7 zPOG?HMI-jOxb?LeC|}VU7w>ZKpcd*ar;S%yE~N6IYuePkX=GrY(|#8|(&+=wyV_rX zzV59y&oFQC?(WC~YPYvDO(8w4x4c-OaKC=Kj|S~fneR%L2M!pqc4mFXh+S->;X&i? z{Z1PGW`^rHr;MAXfq`ON_^tm^)PI!# diff --git a/resources/translations/de.ts b/resources/translations/de.ts index 7028d3e..577a7d5 100644 --- a/resources/translations/de.ts +++ b/resources/translations/de.ts @@ -4,34 +4,40 @@ - + Scan QR-Code QR-Code scannen - + Place the Code in the center Positioniere den Code in der Mitte - - Camera permission denied! + + Camera access required + Camera access denied - - This app requires access to your camera in order to scan QR-Codes. It will never record or store any photos or videos. - This app requires access to your camera in order to scan QR-Codes. It will never record store any photos or videos. + + blueROCK needs to access your camera in order to scan QR-Codes. It will never record or store any photos or videos. + This app needs to access your camera in order to scan QR-Codes. It will never record or store any photos or videos. + + + + + Allow access - + Plase wait Bitte warten - + Invalid QR-Code Ungültiger QR-Code @@ -112,17 +118,17 @@ Über blueROCK - + Where are the IFSC results? Wo sind die IFSC Ergebnisse? - + Unfortunately, the IFSC has restricted the access to their data and <b>is not willing to share results with blueROCK anymore</b>. Because of this, blueROCK is no longer able to access and display IFSC results.<br><br>You can find current IFSC results <a href="https://ifsc.results.info">over here</a> and on <a href="https://ifsc-climbing.org">their website</a>. Leider hat die IFSC den Zugang zu ihren Ergebnissen eingeschränkt<b>und ist nicht mehr bereit, Ergebnisse mit blueROCK zu teilen</b>. Daher ist blueROCK nicht länger in der Lage auf IFSC Ergebnisse zuzugriefen und diese anzuzeigen.<br><br>Aktuelle IFSC Ergebnisse finden sich <a href="https://ifsc.results.info">hier</a> und auf der <a href="https://ifsc-climbing.org">IFSC Webseite</a>. - + This app was built using the <a href='https://qt.io'>Qt Framework</a> licensed under the <a href='https://www.gnu.org/licenses/lgpl-3.0.en.html'>GNU lgplV3 license</a>.<br><br>This app is open source and licensed under the <a href='https://www.gnu.org/licenses/agpl-3.0.en.html'>GNU agplV3 license</a>, the source code can be found <a href='https://itsblue.dev/dorian/blueROCK/'>here</a>.<br><br>Resultservice and rankings provided by <a href='http://www.digitalROCK.de'>digital ROCK</a>. Diese App wurde unter Verwendung des <a href='https://qt.io'>Qt Frameworks</a> unter der <a href='https://www.gnu.org/licenses/lgpl-3.0.en.html'>GNU lgplV3 Lizenz</a> erstellt.<br><br>Diese App ist Open-source und lizensiert unter der <a href='https://www.gnu.org/licenses/agpl-3.0.en.html'>GNU agplV3 Lizenz</a>. Der Sourcecode findet sich <a href='https://itsblue.dev/dorian/blueROCK/'>hier</a>.Die Ergebnisse und Ranglisten werden von <a href='http://www.digitalROCK.de'>digital ROCK</a> zur Verfügung gestellt. diff --git a/resources/translations/en.qm b/resources/translations/en.qm index eb94bc00ad448e5b13229611a89b96bc2510d9d3..cd69813e4c4d9f22829c7f3d71336e3bdd616a14 100644 GIT binary patch delta 570 zcmY*VT}YE*7(M&`_if*|xeNlkST2L*EG>+Jg)MIaNg7FVFit&w0){&pQ_^1V@Tfmm%DI z4@hAI?>+~Vla3cvHsH}6UymLJjIiJdY-j(MFdYEvIbor)8t~PK$De!$+}FhBSSfLR z;)&6pfa{U?cxxGP5pl*j!~V3ivo*&-NJ)D$`3usy=q>gKr9V;TDc@N+Qk-F7Nv=QC z2$+gIHFO_PC*|z?1Y?)HbZ3^t%gVvmBsOPN?b!!llV9!Gbsg~L)HB29Y3P%Bdr+WG zjXJ)KM!Z+mdq4I9MOm#p|A2ETEoAv<i-q)^z1)iJvE8L=C+ zG=9MN`>=^W&}=sDAWj-J?fm)zN6b^7-x0s&*;BGwM1n<6dlv_lE1g`cB{Sw|m3D7I z1aY2T48V^zSUffoNNDSSsqnf3ZSi>TK*X}_L?XQ`cUOc^OJp~3{frx?nDw*Xha@`x nzoO}3rM&7J+NqIb=NK9|T}NCGGaFHA`Ei>18+bA+%DnLp%~Xo< delta 510 zcmW-bTS!v@7{~uRmz~RY&RJ{X!+e-7g{4UdJG!*~0C|L^xdv=mDFQiBlgtpid6 zLQ~HHXT9TPg$U?5O%W;28Iv9DuLrA@L9{ty(!RQ0-Pe|KQ_9^cv`Is-u!5g{tXqZNy zW%0DOG(m3aAT&A&kUs0caB*1SaQGN&Tj4Id1hS<+5<9!1E98o3< z3F3(;)8DIreK*z8)j8gsR?9lP#7L{@GMOM#>cXQ%q+race`mjvbW__X{=-LgdXaep z(7W{7)(jvQ=xzNp($`$oODi<4aSdN4pa*XM!x28PjCc#POEcnkn+WVS{ylD^-yt(x zLY>rZ+N-@WtO_&B&eGrygmGn072sWx5uk&OF7$G`TlHk7wft;Id2j3h D9wm8Q diff --git a/resources/translations/en.ts b/resources/translations/en.ts index 6689a06..883332c 100644 --- a/resources/translations/en.ts +++ b/resources/translations/en.ts @@ -4,34 +4,40 @@ - + Scan QR-Code - + Place the Code in the center - - Camera permission denied! + + Camera access required + Camera access denied - - This app requires access to your camera in order to scan QR-Codes. It will never record or store any photos or videos. - This app requires access to your camera in order to scan QR-Codes. It will never record store any photos or videos. + + blueROCK needs to access your camera in order to scan QR-Codes. It will never record or store any photos or videos. + This app needs to access your camera in order to scan QR-Codes. It will never record or store any photos or videos. + + + + + Allow access - + Plase wait - + Invalid QR-Code @@ -108,17 +114,17 @@ - + Where are the IFSC results? - + Unfortunately, the IFSC has restricted the access to their data and <b>is not willing to share results with blueROCK anymore</b>. Because of this, blueROCK is no longer able to access and display IFSC results.<br><br>You can find current IFSC results <a href="https://ifsc.results.info">over here</a> and on <a href="https://ifsc-climbing.org">their website</a>. - + This app was built using the <a href='https://qt.io'>Qt Framework</a> licensed under the <a href='https://www.gnu.org/licenses/lgpl-3.0.en.html'>GNU lgplV3 license</a>.<br><br>This app is open source and licensed under the <a href='https://www.gnu.org/licenses/agpl-3.0.en.html'>GNU agplV3 license</a>, the source code can be found <a href='https://itsblue.dev/dorian/blueROCK/'>here</a>.<br><br>Resultservice and rankings provided by <a href='http://www.digitalROCK.de'>digital ROCK</a>. diff --git a/sources/bluerockbackend.cpp b/sources/bluerockbackend.cpp index 6438387..9ebbd46 100644 --- a/sources/bluerockbackend.cpp +++ b/sources/bluerockbackend.cpp @@ -147,7 +147,7 @@ bool BlueRockBackend::isCameraPermissionGranted() { QtAndroid::PermissionResult cameraAccess = QtAndroid::checkPermission("android.permission.CAMERA"); return cameraAccess == QtAndroid::PermissionResult::Granted; #else - return false; + return true; #endif } @@ -204,7 +204,7 @@ bool BlueRockBackend::requestCameraPermission() { return true; #else - return false; + return true; #endif }