From 34f54ba015fde1c7ec4753edfe4bf9ef0678d1b1 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Sat, 21 Mar 2020 14:09:09 -0700 Subject: [PATCH] bugfixes and style --- api/api.go | 10 ++++++++-- lockbox.go | 2 +- qml/main.qml | 53 +++++++++++++++++++++++++++++++--------------------- 3 files changed, 41 insertions(+), 24 deletions(-) diff --git a/api/api.go b/api/api.go index 66a7a40..2c76487 100644 --- a/api/api.go +++ b/api/api.go @@ -73,8 +73,14 @@ func (lapi *LockBoxAPI) decryptFile(inputFilename string, outputFilename string, sort.Strings(schema) for _, k := range schema { - str := strings.SplitN(k, "_", 1) - outputLine += fmt.Sprintf(`"%v",`, strings.ReplaceAll(str[1], "\"", "\\\"")) + parts := strings.SplitN(k, "_", 2) + var str string + if len(parts) > 1 { + str = parts[1] + } else { + str = k + } + outputLine += fmt.Sprintf(`"%v",`, strings.ReplaceAll(str, "\"", "\\\"")) } outputfile = append(outputfile, outputLine) diff --git a/lockbox.go b/lockbox.go index 301382a..ff7f373 100644 --- a/lockbox.go +++ b/lockbox.go @@ -17,7 +17,7 @@ func main() { app := widgets.NewQApplication(len(os.Args), os.Args) app.SetAttribute(core.Qt__AA_EnableHighDpiScaling, true) - quickcontrols2.QQuickStyle_SetStyle("Default") + quickcontrols2.QQuickStyle_SetStyle("Material") engine := qml.NewQQmlApplicationEngine(nil) lockapi := api.NewLockBoxAPI(nil) diff --git a/qml/main.qml b/qml/main.qml index 41734e1..a924b56 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -13,22 +13,11 @@ ApplicationWindow { 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 - } + property string keyfilegentxt + property string outfiletxt + property string keyfiletxt + property string inputfiletxt + TabView { anchors.fill: parent @@ -71,6 +60,7 @@ ApplicationWindow { width:parent.width * 0.50 id:keyFileGenLabel placeholderText: "Folder to save keys into" + text: root.keyfilegentxt } Button { Layout.alignment: Qt.AlignRight @@ -87,7 +77,7 @@ ApplicationWindow { Button { text: "Generate!" onClicked: function() { - lockbox.generateKey(keyFileCreateDialog.fileUrls[0]) + lockbox.generateKey(root.keyfilegentxt) } } } @@ -119,6 +109,7 @@ ApplicationWindow { width:parent.width * 0.75 id:inputFileLabel placeholderText: "Encrypted submissions file (.dat)" + text: root.inputfiletxt } Button { Layout.alignment: Qt.AlignRight @@ -133,6 +124,7 @@ ApplicationWindow { id:outputFileLabel width:parent.width * 0.75 placeholderText: "Location for decrypted file (.csv)" + text: root.outfiletxt } Button { Layout.alignment: Qt.AlignRight @@ -147,6 +139,7 @@ ApplicationWindow { width:parent.width * 0.75 id:keyFileLabel placeholderText: "Decryption key file (.private)" + text: root.keyfiletxt } Button { Layout.alignment: Qt.AlignRight @@ -160,7 +153,7 @@ ApplicationWindow { Button { text: "Decrypt!" onClicked: function() { - lockbox.decryptFile(fileDialog.fileUrls[0],outputFileDialog.fileUrls[0],keyFileDialog.fileUrls[0]) + lockbox.decryptFile(root.inputfiletxt,root.outfiletxt,root.keyfiletxt) } } } @@ -178,7 +171,7 @@ ApplicationWindow { selectExisting:false onAccepted: { console.log("You chose: " + outputFileDialog.fileUrls) - outputFileLabel.text = outputFileDialog.fileUrls[0] + root.outfiletxt = outputFileDialog.fileUrls[0] } onRejected: { console.log("Canceled") @@ -198,7 +191,7 @@ ApplicationWindow { selectMultiple: false onAccepted: { console.log("You chose: " + keyFileDialog.fileUrls) - keyFileLabel.text = keyFileDialog.fileUrls[0] + root.keyfiletxt = keyFileDialog.fileUrls[0] } onRejected: { console.log("Canceled") @@ -215,7 +208,7 @@ ApplicationWindow { selectMultiple: false onAccepted: { console.log("You chose: " + keyFileCreateDialog.fileUrls) - keyFileGenLabel.text = keyFileCreateDialog.fileUrls[0] + root.keyfilegentxt = keyFileCreateDialog.fileUrls[0] } onRejected: { console.log("Canceled") @@ -254,6 +247,24 @@ ApplicationWindow { } + 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) + root.inputfiletxt = fileDialog.fileUrls[0] + } + onRejected: { + console.log("Canceled") + } + Component.onCompleted: visible = false + } + + MessageDialog { id: messageDialog title: "May I have your attention please"