1
0
mirror of https://github.com/QRouland/UTPass.git synced 2025-02-04 12:06:40 +00:00
UTPass/qml/pages/settings/ImportZip.qml

100 lines
2.7 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: importZipPage
property var activeTransfer
2025-01-10 15:28:42 +01:00
Component.onCompleted: {
PopupUtils.open(importZipPageImportValidation, importZipPage);
2019-09-20 21:29:39 +02:00
}
ContentPeerPicker {
anchors.top: importZipHeader.bottom
anchors.bottom: parent.bottom
anchors.topMargin: importZipPage.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;
importZipPage.activeTransfer = peer.request();
importZipPage.activeTransfer.stateChanged.connect(function() {
2019-09-20 21:29:39 +02:00
if (importZipPage.activeTransfer.state === ContentTransfer.Charged) {
2025-01-10 15:28:42 +01:00
console.log("Charged");
console.log(importZipPage.activeTransfer.items[0].url);
var status = Utils.unzip(importZipPage.activeTransfer.items[0].url, Pass.getPasswordStore());
Utils.rmFile(importZipPage.activeTransfer.items[0].url);
if (status)
PopupUtils.open(dialogImportZipPageSuccess);
else
PopupUtils.open(dialogImportZipPageError);
importZipPage.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: importZipPage.activeTransfer
}
Component {
id: importZipPageImportValidation
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
SimpleValidationDialog {
2025-01-10 15:28:42 +01:00
text: i18n.tr("Importing a new zip will delete<br>any existing password store!<br>Continue ?")
continueText: i18n.tr("Yes")
continueColor: theme.palette.normal.negative
2019-09-20 21:29:39 +02:00
onCanceled: {
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
2019-09-20 21:29:39 +02:00
}
Component {
id: dialogImportZipPageError
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
ErrorDialog {
textError: i18n.tr("Password store import failed !")
}
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
}
Component {
id: dialogImportZipPageSuccess
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
SuccessDialog {
textSuccess: i18n.tr("Password store sucessfully imported !")
onDialogClosed: {
2025-01-10 15:28:42 +01:00
pageStack.pop();
pageStack.pop();
2019-09-20 21:29:39 +02:00
}
}
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
}
2025-01-10 15:28:42 +01:00
header: StackHeader {
id: importZipHeader
title: i18n.tr("Zip Password Store 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
}