chore: fixed qr code display

This commit is contained in:
vladimir.kuznetsov 2025-02-19 14:56:53 +07:00
parent c128ba981c
commit a5254ac238
3 changed files with 17 additions and 12 deletions

View file

@ -24,7 +24,7 @@ DrawerType2 {
property string configContentHeaderText
property string shareButtonText: qsTr("Share")
property string copyButtonText: qsTr("Copy")
property bool showSettingsButtonVisible: true
property bool isSelfHostedConfig: true
property string configExtension: ".vpn"
property string configCaption: qsTr("Save AmneziaVPN config")
@ -153,7 +153,7 @@ DrawerType2 {
Layout.leftMargin: 16
Layout.rightMargin: 16
visible: root.showSettingsButtonVisible
visible: root.isSelfHostedConfig
defaultColor: AmneziaStyle.color.transparent
hoveredColor: AmneziaStyle.color.translucentWhite
@ -285,6 +285,8 @@ DrawerType2 {
delegate: ColumnLayout {
width: listView.width
property bool isQrCodeVisible: root.isSelfHostedConfig ? ExportController.qrCodesCount > 0 : ApiConfigsController.qrCodesCount > 0
Rectangle {
id: qrCodeContainer
@ -294,7 +296,7 @@ DrawerType2 {
Layout.leftMargin: 16
Layout.rightMargin: 16
visible: ExportController.qrCodesCount > 0
visible: isQrCodeVisible
color: "white"
@ -302,7 +304,8 @@ DrawerType2 {
anchors.fill: parent
smooth: false
source: ExportController.qrCodesCount ? ExportController.qrCodes[0] : ""
source: root.isSelfHostedConfig ? (isQrCodeVisible ? ExportController.qrCodes[0] : "") :
(isQrCodeVisible ? ApiConfigsController.qrCodes[0] : "")
property bool isFocusable: true
@ -333,15 +336,17 @@ DrawerType2 {
Timer {
property int index: 0
interval: 1000
running: ExportController.qrCodesCount > 0
running: isQrCodeVisible
repeat: true
onTriggered: {
if (ExportController.qrCodesCount > 0) {
if (isQrCodeVisible) {
index++
if (index >= ExportController.qrCodesCount) {
let qrCodesCount = root.isSelfHostedConfig ? ExportController.qrCodesCount : ApiConfigsController.qrCodesCount
if (index >= qrCodesCount) {
index = 0
}
parent.source = ExportController.qrCodes[index]
parent.source = root.isSelfHostedConfig ? ExportController.qrCodes[index] : ApiConfigsController.qrCodes[index]
}
}
}
@ -359,7 +364,7 @@ DrawerType2 {
Layout.leftMargin: 16
Layout.rightMargin: 16
visible: ExportController.qrCodesCount > 0
visible: isQrCodeVisible
horizontalAlignment: Text.AlignHCenter
text: qsTr("To read the QR code in the Amnezia app, select \"Add server\" → \"I have data to connect\" → \"QR code, key or settings file\"")