246 lines
6.8 KiB
QML
246 lines
6.8 KiB
QML
|
import QtQuick 2.7 //ApplicationWindow
|
||
|
import QtQuick.Controls 2.1 //Dialog
|
||
|
import QtQuick.Controls 2.12
|
||
|
import QtQuick 2.12
|
||
|
import QtQuick.Dialogs 1.3
|
||
|
import QtQuick.Layouts 1.12
|
||
|
|
||
|
|
||
|
ApplicationWindow {
|
||
|
id: root
|
||
|
visible: true
|
||
|
title: "Open Privacy LockBox"
|
||
|
minimumWidth: 640
|
||
|
minimumHeight: 640
|
||
|
|
||
|
FileDialog {
|
||
|
id: fileDialog
|
||
|
title: "Please choose a file to decrypt"
|
||
|
nameFilters: [ "Dat File (*.dat)", "All files (*)" ]
|
||
|
folder: shortcuts.home
|
||
|
selectFolder: false
|
||
|
selectMultiple: false
|
||
|
onAccepted: {
|
||
|
console.log("You chose: " + fileDialog.fileUrls)
|
||
|
inputFileLabel.text = fileDialog.fileUrls[0]
|
||
|
}
|
||
|
onRejected: {
|
||
|
console.log("Canceled")
|
||
|
}
|
||
|
Component.onCompleted: visible = false
|
||
|
}
|
||
|
|
||
|
Column {
|
||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||
|
width:parent.width
|
||
|
padding:10
|
||
|
|
||
|
Row {
|
||
|
width:parent.width
|
||
|
padding:10
|
||
|
Label {
|
||
|
text: "Decrypt a File"
|
||
|
font.pixelSize: 22
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Row {
|
||
|
width:parent.width
|
||
|
padding:10
|
||
|
TextField {
|
||
|
width:parent.width * 0.50
|
||
|
id:inputFileLabel
|
||
|
placeholderText: "Select an Input File"
|
||
|
}
|
||
|
Button {
|
||
|
Layout.alignment: Qt.AlignRight
|
||
|
text: "Select File To Decrypt"
|
||
|
onClicked: fileDialog.visible = true
|
||
|
}
|
||
|
}
|
||
|
Row {
|
||
|
width:parent.width
|
||
|
padding:10
|
||
|
TextField {
|
||
|
id:outputFileLabel
|
||
|
width:parent.width * 0.50
|
||
|
placeholderText: "Select an Output File"
|
||
|
}
|
||
|
Button {
|
||
|
Layout.alignment: Qt.AlignRight
|
||
|
text: "Select File To Output"
|
||
|
onClicked: outputFileDialog.visible = true
|
||
|
}
|
||
|
}
|
||
|
Row {
|
||
|
width:parent.width
|
||
|
padding:10
|
||
|
TextField {
|
||
|
width:parent.width * 0.50
|
||
|
id:keyFileLabel
|
||
|
placeholderText: "Select a Key File"
|
||
|
}
|
||
|
Button {
|
||
|
Layout.alignment: Qt.AlignRight
|
||
|
text: "Select Private Key"
|
||
|
onClicked: keyFileDialog.visible = true
|
||
|
}
|
||
|
}
|
||
|
Row {
|
||
|
width:parent.width
|
||
|
padding:10
|
||
|
Button {
|
||
|
text: "Decrypt"
|
||
|
onClicked: function() {
|
||
|
lockbox.decryptFile(fileDialog.fileUrls[0],outputFileDialog.fileUrls[0],keyFileDialog.fileUrls[0])
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
Row {
|
||
|
width:parent.width
|
||
|
padding:10
|
||
|
Rectangle {
|
||
|
width: parent.width-20
|
||
|
height: 1
|
||
|
color: "black"
|
||
|
border.color: "black"
|
||
|
border.width: 1
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Row {
|
||
|
width:parent.width
|
||
|
padding:10
|
||
|
Label {
|
||
|
text: "Generate New Encryption Keys"
|
||
|
font.pixelSize: 22
|
||
|
}
|
||
|
}
|
||
|
Row {
|
||
|
width:parent.width
|
||
|
padding:10
|
||
|
TextField {
|
||
|
width:parent.width * 0.50
|
||
|
id:keyFileGenLabel
|
||
|
placeholderText: "Select a Key File"
|
||
|
}
|
||
|
Button {
|
||
|
Layout.alignment: Qt.AlignRight
|
||
|
text: "Select a Folder to Save Keys"
|
||
|
onClicked: function() {
|
||
|
keyFileCreateDialog.visible = true
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Row {
|
||
|
width:parent.width
|
||
|
Button {
|
||
|
text: "Generate a Decryption Key"
|
||
|
onClicked: function() {
|
||
|
lockbox.generateKey(keyFileCreateDialog.fileUrls[0])
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
FileDialog {
|
||
|
id: outputFileDialog
|
||
|
title: "Please choose a file save to"
|
||
|
nameFilters: [ "CSV File (*.csv)", "All files (*)" ]
|
||
|
folder: shortcuts.home
|
||
|
selectFolder: false
|
||
|
selectMultiple: false
|
||
|
selectExisting:false
|
||
|
onAccepted: {
|
||
|
console.log("You chose: " + outputFileDialog.fileUrls)
|
||
|
outputFileLabel.text = outputFileDialog.fileUrls[0]
|
||
|
}
|
||
|
onRejected: {
|
||
|
console.log("Canceled")
|
||
|
}
|
||
|
Component.onCompleted: visible = false
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
FileDialog {
|
||
|
id: keyFileDialog
|
||
|
title: "Please choose an encryption key file"
|
||
|
nameFilters: [ "Key File (*.private)", "All files (*)" ]
|
||
|
folder: shortcuts.home
|
||
|
selectFolder: false
|
||
|
selectMultiple: false
|
||
|
onAccepted: {
|
||
|
console.log("You chose: " + keyFileDialog.fileUrls)
|
||
|
keyFileLabel.text = keyFileDialog.fileUrls[0]
|
||
|
}
|
||
|
onRejected: {
|
||
|
console.log("Canceled")
|
||
|
}
|
||
|
Component.onCompleted: visible = false
|
||
|
}
|
||
|
|
||
|
FileDialog {
|
||
|
id: keyFileCreateDialog
|
||
|
title: "Please choose where to save the encryption key file"
|
||
|
nameFilters: [ "Key File (*.private)", "All files (*)" ]
|
||
|
folder: shortcuts.home
|
||
|
selectFolder: true
|
||
|
selectMultiple: false
|
||
|
onAccepted: {
|
||
|
console.log("You chose: " + keyFileCreateDialog.fileUrls)
|
||
|
keyFileGenLabel.text = keyFileCreateDialog.fileUrls[0]
|
||
|
}
|
||
|
onRejected: {
|
||
|
console.log("Canceled")
|
||
|
}
|
||
|
Component.onCompleted: visible = false
|
||
|
}
|
||
|
|
||
|
Connections { // POPUPS ARE INVOKED BY GO FUNCS
|
||
|
target: lockbox
|
||
|
|
||
|
onDecrypted: function(status, message) {
|
||
|
if (status) {
|
||
|
messageDialog.icon = StandardIcon.Information
|
||
|
messageDialog.title = "Decrypted Successfully"
|
||
|
} else {
|
||
|
messageDialog.icon = StandardIcon.Critical
|
||
|
messageDialog.title = "Error Decrypting"
|
||
|
}
|
||
|
|
||
|
messageDialog.text = message
|
||
|
messageDialog.open()
|
||
|
}
|
||
|
|
||
|
onSaved: function(status, message) {
|
||
|
if (status) {
|
||
|
messageDialog.icon = StandardIcon.Information
|
||
|
messageDialog.title = "Encryption Keys Generating Successfully"
|
||
|
} else {
|
||
|
messageDialog.icon = StandardIcon.Critical
|
||
|
messageDialog.title = "Error Generating Encryption Keys"
|
||
|
}
|
||
|
|
||
|
messageDialog.text = message
|
||
|
messageDialog.open()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
MessageDialog {
|
||
|
id: messageDialog
|
||
|
title: "May I have your attention please"
|
||
|
text: "It's so cool that you are using Qt Quick."
|
||
|
onAccepted: {
|
||
|
messageDialog.close()
|
||
|
}
|
||
|
Component.onCompleted: visible = false
|
||
|
}
|
||
|
|
||
|
}
|