1
0
mirror of https://github.com/QRouland/UTPass.git synced 2025-01-27 00:56:38 +00:00
UTPass/qml/pages/settings/ImportKeyFile.qml

81 lines
2.2 KiB
QML
Raw Normal View History

2025-01-10 15:28:42 +01:00
import "../../dialogs"
import "../headers"
import Lomiri.Components 1.3
import Lomiri.Components.Popups 1.3
2025-01-10 15:28:42 +01:00
import Lomiri.Content 1.3
2019-09-20 21:29:39 +02:00
import Pass 1.0
2025-01-10 15:28:42 +01:00
import QtQuick 2.4
2019-09-20 21:29:39 +02:00
import Utils 1.0
Page {
id: importKeyFilePage
property var activeTransfer
ContentPeerPicker {
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: {
2025-01-10 15:28:42 +01:00
peer.selectionType = ContentTransfer.Single;
importKeyFilePage.activeTransfer = peer.request();
importKeyFilePage.activeTransfer.stateChanged.connect(function() {
2019-09-20 21:29:39 +02:00
if (importKeyFilePage.activeTransfer.state === ContentTransfer.Charged) {
2025-01-10 15:28:42 +01:00
console.log("Charged");
console.log(importKeyFilePage.activeTransfer.items[0].url);
var status = Pass.gpgImportKeyFromFile(importKeyFilePage.activeTransfer.items[0].url);
Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url);
if (status)
PopupUtils.open(dialogImportKeyPageSucess);
else
PopupUtils.open(dialogImportKeyPageError);
importKeyFilePage.activeTransfer = null;
2019-09-20 21:29:39 +02:00
}
2025-01-10 15:28:42 +01:00
});
2019-09-20 21:29:39 +02:00
}
onCancelPressed: {
2025-01-10 15:28:42 +01:00
pageStack.pop();
2019-09-20 21:29:39 +02:00
}
}
ContentTransferHint {
id: transferHint
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
anchors.fill: parent
activeTransfer: importKeyFilePage.activeTransfer
}
Component {
id: dialogImportKeyPageError
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
ErrorDialog {
textError: i18n.tr("Key import failed !")
}
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
}
Component {
id: dialogImportKeyPageSucess
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
SuccessDialog {
textSuccess: i18n.tr("Key successfully imported !")
onDialogClosed: {
2025-01-10 15:28:42 +01:00
pageStack.pop();
2019-09-20 21:29:39 +02:00
}
}
2025-01-10 15:28:42 +01:00
}
header: StackHeader {
id: importKeyHeader
title: i18n.tr("GPG Key Import")
2019-09-20 21:29:39 +02:00
}
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
}