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

186 lines
4.9 KiB
QML
Raw Normal View History

2025-01-10 15:28:42 +01:00
import "../../components"
import "../../dialogs"
import "../headers"
import Lomiri.Components 1.3
import Lomiri.Components.Popups 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
Page {
id: infoKeysPage
2025-01-20 11:23:40 +01:00
property QtObject currentKey
2019-09-20 21:29:39 +02:00
2025-01-15 23:40:35 +01:00
Component.onCompleted: {
2025-01-20 14:46:47 +01:00
Pass.getAllGPGKeysSucceed.connect(function(keys_info) {
2025-01-15 23:40:35 +01:00
infoKeysListView.model = keys_info;
});
Pass.getAllGPGKeysFailed.connect(function(message) {
PopupUtils.open(infoKeysPageGetAllError);
});
2025-01-20 11:23:40 +01:00
Pass.deleteGPGKeySucceed.connect(function(keys_info) {
PopupUtils.open(infoKeysPageDeleteSuccess);
});
Pass.deleteGPGKeyFailed.connect(function(message) {
PopupUtils.open(infoKeysPageDeleteError);
});
2025-01-15 23:40:35 +01:00
Pass.getAllGPGKeys();
}
2019-09-20 21:29:39 +02:00
ListView {
id: infoKeysListView
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
anchors.top: infoKeysHeader.bottom
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.left: parent.left
2025-01-20 14:46:47 +01:00
anchors.leftMargin: units.gu(2)
anchors.rightMargin: units.gu(2)
2019-09-20 21:29:39 +02:00
delegate: Grid {
columns: 1
width: parent.width
horizontalItemAlignment: Grid.AlignHCenter
verticalItemAlignment: Grid.AlignVCenter
Rectangle {
width: parent.width
height: units.gu(1)
color: theme.palette.normal.background
2019-09-20 21:29:39 +02:00
}
Text {
2025-01-14 12:20:55 +01:00
width: parent.width
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: i18n.tr('Key ID :')
color: theme.palette.normal.backgroundText
}
2025-01-10 15:28:42 +01:00
2025-01-14 12:20:55 +01:00
Text {
2019-09-20 21:29:39 +02:00
width: parent.width
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
2025-01-14 12:20:55 +01:00
text: model.modelData.uid
color: theme.palette.normal.backgroundText
}
2025-01-14 12:20:55 +01:00
Rectangle {
width: parent.width
height: units.gu(1)
color: theme.palette.normal.background
}
ListModel {
id: userIdsModel
Component.onCompleted: {
2025-01-14 13:05:09 +01:00
for (var i = 0; i < model.modelData.userIds.length; ++i) {
userIdsModel.append({
"model": model.modelData.userIds[i]
});
2025-01-14 12:20:55 +01:00
}
}
}
Text {
width: parent.width
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: i18n.tr('Users IDs : ')
color: theme.palette.normal.backgroundText
}
Repeater {
model: userIdsModel
2025-01-14 13:05:09 +01:00
2025-01-14 12:20:55 +01:00
Text {
width: parent.width
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: modelData.uid
color: theme.palette.normal.backgroundText
}
2025-01-14 13:05:09 +01:00
2025-01-14 12:20:55 +01:00
}
Rectangle {
width: parent.width
height: units.gu(1)
color: theme.palette.normal.background
2019-09-20 21:29:39 +02:00
}
Button {
id: buttonDeleteKey
2025-01-10 15:28:42 +01:00
2025-01-20 14:46:47 +01:00
width: parent.width
2019-09-20 21:29:39 +02:00
text: i18n.tr("Delete this key")
color: theme.palette.normal.negative
2019-09-20 21:29:39 +02:00
onClicked: {
2025-01-20 11:23:40 +01:00
infoKeysPage.currentKey = model.modelData;
2025-01-10 15:28:42 +01:00
PopupUtils.open(infoKeysPageDeleteValidation, infoKeysPage);
2019-09-20 21:29:39 +02:00
}
}
Rectangle {
width: parent.width
height: units.gu(1)
color: theme.palette.normal.background
2019-09-20 21:29:39 +02:00
}
2025-01-14 13:05:09 +01:00
2019-09-20 21:29:39 +02:00
}
2025-01-14 13:05:09 +01:00
2019-09-20 21:29:39 +02:00
}
Component {
id: infoKeysPageDeleteValidation
2025-01-10 15:28:42 +01:00
SimpleValidationDialog {
2025-01-20 14:46:47 +01:00
text: i18n.tr("You're are about to delete<br>%1<br>.Continue ?").arg(infoKeysPage.currentKey.uid)
continueText: i18n.tr("Yes")
continueColor: theme.palette.normal.negative
onValidated: {
2025-01-14 08:15:03 +01:00
var status = Pass.deleteGPGKey(infoKeysPage.currentKey);
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: infoKeysPageDeleteError
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
ErrorDialog {
textError: i18n.tr("Key removal failed !")
}
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
}
Component {
id: infoKeysPageDeleteSuccess
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
SuccessDialog {
textSuccess: i18n.tr("Key successfully deleted !")
onDialogClosed: {
2025-01-14 08:15:03 +01:00
infoKeysListView.model = Pass.getAllGPGKeys();
2019-09-20 21:29:39 +02:00
}
}
2025-01-10 15:28:42 +01:00
}
2025-01-15 23:40:35 +01:00
Component {
id: infoKeysPageGetAllError
ErrorDialog {
2025-01-20 14:46:47 +01:00
textError: i18n.tr("An Error occured getting GPG keys !")
2025-01-15 23:40:35 +01:00
}
}
2025-01-10 15:28:42 +01:00
header: StackHeader {
id: infoKeysHeader
title: i18n.tr('Info Keys')
2019-09-20 21:29:39 +02:00
}
2025-01-10 15:28:42 +01:00
2019-09-20 21:29:39 +02:00
}