Optimizations in QrCodePage

This commit is contained in:
Dorian Zedler 2021-06-25 09:41:07 +02:00
parent 5a50ef8cbe
commit cc855bd329
Signed by: dorian
GPG key ID: 989DE36109AFA354
10 changed files with 141 additions and 113 deletions

View file

@ -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

View file

@ -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

View file

@ -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()
}
}

View file

@ -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 <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>."
content: qsTrId("#aboutBluerockDisclaimer")
}
QrCodeScanPopup {
id: qrCodeScanPopup
Material.theme: root.Material.theme
}
}

View file

@ -29,6 +29,6 @@
<file>Components/ColoredItemDelegate.qml</file>
<file>Components/AlignedButton.qml</file>
<file>Components/SharePopup.qml</file>
<file>Components/QrCodeScanPopup.qml</file>
<file>Pages/QrCodeScanPage.qml</file>
</qresource>
</RCC>

Binary file not shown.

View file

@ -4,34 +4,40 @@
<context>
<name></name>
<message id="#scanQrCode">
<location filename="../qml/Components/QrCodeScanPopup.qml" line="27"/>
<location filename="../qml/Pages/QrCodeScanPage.qml" line="19"/>
<location filename="../qml/Pages/StartPage.qml" line="120"/>
<source>Scan QR-Code</source>
<translation>QR-Code scannen</translation>
</message>
<message id="#placeQrCodeInCenter">
<location filename="../qml/Components/QrCodeScanPopup.qml" line="44"/>
<location filename="../qml/Pages/QrCodeScanPage.qml" line="34"/>
<source>Place the Code in the center</source>
<translation>Positioniere den Code in der Mitte</translation>
</message>
<message id="#cameraPermissionDenied">
<location filename="../qml/Components/QrCodeScanPopup.qml" line="208"/>
<source>Camera permission denied!</source>
<location filename="../qml/Pages/QrCodeScanPage.qml" line="207"/>
<source>Camera access required</source>
<oldsource>Camera access denied</oldsource>
<translation type="unfinished"></translation>
</message>
<message id="#cameraPermissionDeniedDetails">
<location filename="../qml/Components/QrCodeScanPopup.qml" line="228"/>
<source>This app requires access to your camera in order to scan QR-Codes. It will never record or store any photos or videos.</source>
<oldsource>This app requires access to your camera in order to scan QR-Codes. It will never record store any photos or videos.</oldsource>
<location filename="../qml/Pages/QrCodeScanPage.qml" line="223"/>
<source>blueROCK needs to access your camera in order to scan QR-Codes. It will never record or store any photos or videos.</source>
<oldsource>This app needs to access your camera in order to scan QR-Codes. It will never record or store any photos or videos.</oldsource>
<translation type="unfinished"></translation>
</message>
<message id="#allowAccess">
<location filename="../qml/Pages/QrCodeScanPage.qml" line="232"/>
<source>Allow access</source>
<translation type="unfinished"></translation>
</message>
<message id="#pleaseWait">
<location filename="../qml/Components/QrCodeScanPopup.qml" line="245"/>
<location filename="../qml/Pages/QrCodeScanPage.qml" line="256"/>
<source>Plase wait</source>
<translation>Bitte warten</translation>
</message>
<message id="#invalidQrCode">
<location filename="../qml/Components/QrCodeScanPopup.qml" line="251"/>
<location filename="../qml/Pages/QrCodeScanPage.qml" line="262"/>
<source>Invalid QR-Code</source>
<translation>Ungültiger QR-Code</translation>
</message>
@ -112,17 +118,17 @@
<translation>Über blueROCK</translation>
</message>
<message id="#ifscDisclaimerTitle">
<location filename="../qml/Pages/StartPage.qml" line="163"/>
<location filename="../qml/Pages/StartPage.qml" line="165"/>
<source>Where are the IFSC results?</source>
<translation>Wo sind die IFSC Ergebnisse?</translation>
</message>
<message id="#ifscDisclaimer">
<location filename="../qml/Pages/StartPage.qml" line="165"/>
<location filename="../qml/Pages/StartPage.qml" line="167"/>
<source>Unfortunately, the IFSC has restricted the access to their data and &lt;b&gt;is not willing to share results with blueROCK anymore&lt;/b&gt;. Because of this, blueROCK is no longer able to access and display IFSC results.&lt;br&gt;&lt;br&gt;You can find current IFSC results &lt;a href=&quot;https://ifsc.results.info&quot;&gt;over here&lt;/a&gt; and on &lt;a href=&quot;https://ifsc-climbing.org&quot;&gt;their website&lt;/a&gt;.</source>
<translation>Leider hat die IFSC den Zugang zu ihren Ergebnissen eingeschränkt&lt;b&gt;und ist nicht mehr bereit, Ergebnisse mit blueROCK zu teilen&lt;/b&gt;. Daher ist blueROCK nicht länger in der Lage auf IFSC Ergebnisse zuzugriefen und diese anzuzeigen.&lt;br&gt;&lt;br&gt;Aktuelle IFSC Ergebnisse finden sich &lt;a href=&quot;https://ifsc.results.info&quot;&gt;hier&lt;/a&gt; und auf der &lt;a href=&quot;https://ifsc-climbing.org&quot;&gt;IFSC Webseite&lt;/a&gt;.</translation>
</message>
<message id="#aboutBluerockDisclaimer">
<location filename="../qml/Pages/StartPage.qml" line="173"/>
<location filename="../qml/Pages/StartPage.qml" line="175"/>
<source>This app was built using the &lt;a href=&apos;https://qt.io&apos;&gt;Qt Framework&lt;/a&gt; licensed under the &lt;a href=&apos;https://www.gnu.org/licenses/lgpl-3.0.en.html&apos;&gt;GNU lgplV3 license&lt;/a&gt;.&lt;br&gt;&lt;br&gt;This app is open source and licensed under the &lt;a href=&apos;https://www.gnu.org/licenses/agpl-3.0.en.html&apos;&gt;GNU agplV3 license&lt;/a&gt;, the source code can be found &lt;a href=&apos;https://itsblue.dev/dorian/blueROCK/&apos;&gt;here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;Resultservice and rankings provided by &lt;a href=&apos;http://www.digitalROCK.de&apos;&gt;digital ROCK&lt;/a&gt;.</source>
<translation type="unfinished">Diese App wurde unter Verwendung des &lt;a href=&apos;https://qt.io&apos;&gt;Qt Frameworks&lt;/a&gt; unter der &lt;a href=&apos;https://www.gnu.org/licenses/lgpl-3.0.en.html&apos;&gt;GNU lgplV3 Lizenz&lt;/a&gt; erstellt.&lt;br&gt;&lt;br&gt;Diese App ist Open-source und lizensiert unter der &lt;a href=&apos;https://www.gnu.org/licenses/agpl-3.0.en.html&apos;&gt;GNU agplV3 Lizenz&lt;/a&gt;. Der Sourcecode findet sich &lt;a href=&apos;https://itsblue.dev/dorian/blueROCK/&apos;&gt;hier&lt;/a&gt;.Die Ergebnisse und Ranglisten werden von &lt;a href=&apos;http://www.digitalROCK.de&apos;&gt;digital ROCK&lt;/a&gt; zur Verfügung gestellt.</translation>
</message>

Binary file not shown.

View file

@ -4,34 +4,40 @@
<context>
<name></name>
<message id="#scanQrCode">
<location filename="../qml/Components/QrCodeScanPopup.qml" line="27"/>
<location filename="../qml/Pages/QrCodeScanPage.qml" line="19"/>
<location filename="../qml/Pages/StartPage.qml" line="120"/>
<source>Scan QR-Code</source>
<translation type="unfinished"></translation>
</message>
<message id="#placeQrCodeInCenter">
<location filename="../qml/Components/QrCodeScanPopup.qml" line="44"/>
<location filename="../qml/Pages/QrCodeScanPage.qml" line="34"/>
<source>Place the Code in the center</source>
<translation type="unfinished"></translation>
</message>
<message id="#cameraPermissionDenied">
<location filename="../qml/Components/QrCodeScanPopup.qml" line="208"/>
<source>Camera permission denied!</source>
<location filename="../qml/Pages/QrCodeScanPage.qml" line="207"/>
<source>Camera access required</source>
<oldsource>Camera access denied</oldsource>
<translation type="unfinished"></translation>
</message>
<message id="#cameraPermissionDeniedDetails">
<location filename="../qml/Components/QrCodeScanPopup.qml" line="228"/>
<source>This app requires access to your camera in order to scan QR-Codes. It will never record or store any photos or videos.</source>
<oldsource>This app requires access to your camera in order to scan QR-Codes. It will never record store any photos or videos.</oldsource>
<location filename="../qml/Pages/QrCodeScanPage.qml" line="223"/>
<source>blueROCK needs to access your camera in order to scan QR-Codes. It will never record or store any photos or videos.</source>
<oldsource>This app needs to access your camera in order to scan QR-Codes. It will never record or store any photos or videos.</oldsource>
<translation type="unfinished"></translation>
</message>
<message id="#allowAccess">
<location filename="../qml/Pages/QrCodeScanPage.qml" line="232"/>
<source>Allow access</source>
<translation type="unfinished"></translation>
</message>
<message id="#pleaseWait">
<location filename="../qml/Components/QrCodeScanPopup.qml" line="245"/>
<location filename="../qml/Pages/QrCodeScanPage.qml" line="256"/>
<source>Plase wait</source>
<translation type="unfinished"></translation>
</message>
<message id="#invalidQrCode">
<location filename="../qml/Components/QrCodeScanPopup.qml" line="251"/>
<location filename="../qml/Pages/QrCodeScanPage.qml" line="262"/>
<source>Invalid QR-Code</source>
<translation type="unfinished"></translation>
</message>
@ -108,17 +114,17 @@
<translation type="unfinished"></translation>
</message>
<message id="#ifscDisclaimerTitle">
<location filename="../qml/Pages/StartPage.qml" line="163"/>
<location filename="../qml/Pages/StartPage.qml" line="165"/>
<source>Where are the IFSC results?</source>
<translation type="unfinished"></translation>
</message>
<message id="#ifscDisclaimer">
<location filename="../qml/Pages/StartPage.qml" line="165"/>
<location filename="../qml/Pages/StartPage.qml" line="167"/>
<source>Unfortunately, the IFSC has restricted the access to their data and &lt;b&gt;is not willing to share results with blueROCK anymore&lt;/b&gt;. Because of this, blueROCK is no longer able to access and display IFSC results.&lt;br&gt;&lt;br&gt;You can find current IFSC results &lt;a href=&quot;https://ifsc.results.info&quot;&gt;over here&lt;/a&gt; and on &lt;a href=&quot;https://ifsc-climbing.org&quot;&gt;their website&lt;/a&gt;.</source>
<translation type="unfinished"></translation>
</message>
<message id="#aboutBluerockDisclaimer">
<location filename="../qml/Pages/StartPage.qml" line="173"/>
<location filename="../qml/Pages/StartPage.qml" line="175"/>
<source>This app was built using the &lt;a href=&apos;https://qt.io&apos;&gt;Qt Framework&lt;/a&gt; licensed under the &lt;a href=&apos;https://www.gnu.org/licenses/lgpl-3.0.en.html&apos;&gt;GNU lgplV3 license&lt;/a&gt;.&lt;br&gt;&lt;br&gt;This app is open source and licensed under the &lt;a href=&apos;https://www.gnu.org/licenses/agpl-3.0.en.html&apos;&gt;GNU agplV3 license&lt;/a&gt;, the source code can be found &lt;a href=&apos;https://itsblue.dev/dorian/blueROCK/&apos;&gt;here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;Resultservice and rankings provided by &lt;a href=&apos;http://www.digitalROCK.de&apos;&gt;digital ROCK&lt;/a&gt;.</source>
<translation type="unfinished"></translation>
</message>

View file

@ -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
}