chore: fixed qr code display
This commit is contained in:
parent
c128ba981c
commit
a5254ac238
3 changed files with 17 additions and 12 deletions
|
@ -99,8 +99,7 @@ void ApiConfigsController::prepareVpnKeyExport()
|
|||
|
||||
auto vpnKey = apiConfigObject.value(apiDefs::key::vpnKey).toString();
|
||||
|
||||
auto qr = qrCodeUtils::generateQrCode(vpnKey.toUtf8());
|
||||
m_qrCodes << qrCodeUtils::svgToBase64(QString::fromStdString(toSvgString(qr, 1)));
|
||||
m_qrCodes = qrCodeUtils::generateQrCodeImageSeries(vpnKey.toUtf8());
|
||||
|
||||
emit vpnKeyExportReady();
|
||||
}
|
||||
|
@ -214,6 +213,7 @@ bool ApiConfigsController::updateServiceFromGateway(const int serverIndex, const
|
|||
newApiConfig.insert(configKey::userCountryCode, apiConfig.value(configKey::userCountryCode));
|
||||
newApiConfig.insert(configKey::serviceType, apiConfig.value(configKey::serviceType));
|
||||
newApiConfig.insert(configKey::serviceProtocol, apiConfig.value(configKey::serviceProtocol));
|
||||
newApiConfig.insert(apiDefs::key::vpnKey, apiConfig.value(apiDefs::key::vpnKey));
|
||||
|
||||
newServerConfig.insert(configKey::apiConfig, newApiConfig);
|
||||
newServerConfig.insert(configKey::authData, authData);
|
||||
|
|
|
@ -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\"")
|
||||
|
|
|
@ -163,7 +163,7 @@ PageType {
|
|||
shareConnectionDrawer.headerText = qsTr("Amnezia Premium subscription key")
|
||||
|
||||
shareConnectionDrawer.openTriggered()
|
||||
shareConnectionDrawer.showSettingsButtonVisible = false;
|
||||
shareConnectionDrawer.isSelfHostedConfig = false;
|
||||
shareConnectionDrawer.shareButtonText = qsTr("Save VPN key to file")
|
||||
shareConnectionDrawer.copyButtonText = qsTr("Copy VPN key")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue