From 083750f4290163ae8833d264e1f8bafccce0bc75 Mon Sep 17 00:00:00 2001 From: Quentin Rouland Date: Tue, 6 Jan 2026 15:38:58 +0100 Subject: [PATCH] Fix an UI GPG key import popup not showing up --- qml/components/ImportFile.qml | 24 ----- qml/pages/settings/ImportKeyFile.qml | 142 +++++++++++++++++++-------- qml/pages/settings/ImportSSHkey.qml | 2 + 3 files changed, 103 insertions(+), 65 deletions(-) diff --git a/qml/components/ImportFile.qml b/qml/components/ImportFile.qml index e625aa7..54a3d97 100644 --- a/qml/components/ImportFile.qml +++ b/qml/components/ImportFile.qml @@ -1,4 +1,3 @@ -import "../dialogs" import "../pages/headers" import Lomiri.Components 1.3 import Lomiri.Components.Popups 1.3 @@ -12,8 +11,6 @@ Page { property var activeTransfer property alias contentPicker : contentPicker - property alias dialogImportKeyPageError : dialogImportKeyPageError - property alias dialogImportKeyPageSucess : dialogImportKeyPageSucess property string headerTitle : i18n.tr("Import succeeded !") property string dialogErrorTxt : i18n.tr("Import failed !") @@ -42,27 +39,6 @@ Page { activeTransfer: importKeyFilePage.activeTransfer } - Component { - id: dialogImportKeyPageError - - ErrorDialog { - textError: importKeyFilePage.dialogErrorTxt - textErrorDescription: importKeyFilePage.dialogErrorDescriptionTxt - } - - } - - Component { - id: dialogImportKeyPageSucess - - SuccessDialog { - textSuccess: importKeyFilePage.dialogSuccessTxt - onDialogClosed: { - pageStack.pop(); - } - } - - } header: StackHeader { id: importKeyHeader diff --git a/qml/pages/settings/ImportKeyFile.qml b/qml/pages/settings/ImportKeyFile.qml index f4ec2ab..d2c9dce 100644 --- a/qml/pages/settings/ImportKeyFile.qml +++ b/qml/pages/settings/ImportKeyFile.qml @@ -1,48 +1,108 @@ -import "../../components" -import Pass 1.0 - +import "../../dialogs" +import "../headers" +import Lomiri.Components 1.3 +import Lomiri.Components.Popups 1.3 import Lomiri.Content 1.3 +import Pass 1.0 +import QtQuick 2.4 +import Utils 1.0 -ImportFile { + + +Page { id: importKeyFilePage - headerTitle: i18n.tr("GPG Key Import") - dialogSuccessTxt : i18n.tr("Key successfully imported !") - dialogErrorTxt : i18n.tr("Key import failed !") + property var activeTransfer + property alias contentPicker : contentPicker + + property string __text_error_description : null + + + ContentPeerPicker { + id: contentPicker + anchors.top: importKeyHeader.bottom + anchors.bottom: parent.bottom + anchors.topMargin: importKeyFilePage.header.height + width: parent.width + visible: parent.visible + showTitle: false + contentType: ContentType.Text + handler: ContentHandler.Source + + onPeerSelected: { + { + importKeyFilePage.contentPicker.peer.selectionType = ContentTransfer.Single; + importKeyFilePage.activeTransfer = importKeyFilePage.contentPicker.peer.request(); + importKeyFilePage.activeTransfer.stateChanged.connect(function() { + if (importKeyFilePage.activeTransfer.state === ContentTransfer.Charged) { + console.log("Charged"); + console.log(importKeyFilePage.activeTransfer.items[0].url); + Pass.importGPGKey(importKeyFilePage.activeTransfer.items[0].url); + Pass.importGPGKeySucceed.connect(function() { + Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url); + importKeyFilePage.activeTransfer = null; + PopupUtils.open(dialogImportKeyPageSucess); + }); + Pass.importGPGKeyFailed.connect(function(err, message) { + Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url); + importKeyFilePage.activeTransfer = null; + switch (code) { + case 1: // UnexceptedError -> use the default (not translate) rnp error + __text_error_description = message; + break; + case 2: // BadFormat + __text_error_description = i18n.tr("The file is not in a valid key format"); + break; + default: + console.warn("Unhandled error code"); + __text_error_description = message; + break; + } + PopupUtils.open(dialogImportKeyPageError); + }); + } + }); + } + } + + onCancelPressed: { + pageStack.pop(); + } + } + + ContentTransferHint { + id: transferHint + + anchors.fill: parent + activeTransfer: importKeyFilePage.activeTransfer + } + + + header: StackHeader { + id: importKeyHeader + + title: i18n.tr("GPG Key Import") + } + + Component { + id: dialogImportKeyPageError + + ErrorDialog { + textError: i18n.tr("Key import failed !") + textErrorDescription: __text_error_description + } + + } + + Component { + id: dialogImportKeyPageSucess + + SuccessDialog { + textSuccess: i18n.tr("Key successfully imported !") + onDialogClosed: { + pageStack.pop(); + } + } - contentPicker.onPeerSelected: { - { - importKeyFilePage.contentPicker.peer.selectionType = ContentTransfer.Single; - importKeyFilePage.activeTransfer = importKeyFilePage.contentPicker.peer.request(); - importKeyFilePage.activeTransfer.stateChanged.connect(function() { - if (importKeyFilePage.activeTransfer.state === ContentTransfer.Charged) { - console.log("Charged"); - console.log(importKeyFilePage.activeTransfer.items[0].url); - Pass.importGPGKey(importKeyFilePage.activeTransfer.items[0].url); - Pass.importGPGKeySucceed.connect(function() { - Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url); - importKeyFilePage.activeTransfer = null; - PopupUtils.open(importKeyFilePage.dialogImportKeyPageSucess); - }); - Pass.importGPGKeyFailed.connect(function(err, message) { - Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url); - importKeyFilePage.activeTransfer = null; - switch (code) { - case 1: // UnexceptedError -> use the default (not translate) rnp error - __text_error_description = message; - break; - case 2: // BadFormat - __text_error_description = i18n.tr("The file is not in a valid key format"); - break; - default: - console.warn("Unhandled error code"); - __text_error_description = message; - break; - } - PopupUtils.open(importKeyFilePage.dialogImportKeyPageError); - }); - } - }); - } } } diff --git a/qml/pages/settings/ImportSSHkey.qml b/qml/pages/settings/ImportSSHkey.qml index 25dc697..8e42741 100644 --- a/qml/pages/settings/ImportSSHkey.qml +++ b/qml/pages/settings/ImportSSHkey.qml @@ -2,6 +2,8 @@ import "../../components" import Utils 1.0 import Git 1.0 +import Lomiri.Components 1.3 +import Lomiri.Components.Popups 1.3 import Lomiri.Content 1.3 ImportFile {