Some code organisation and recovery procedure fix

This commit is contained in:
2024-12-09 23:23:11 +01:00
parent 5f08435816
commit 3acafaea32
7 changed files with 305 additions and 234 deletions

View File

@@ -75,10 +75,10 @@ GridLayout
Component.onCompleted:
{
config.usernameNotAvailable.connect(usernameNotAvailable)
config.adminNotAvailable.connect(adminNotAvailable)
}
function usernameNotAvailable()
function adminNotAvailable()
{
benutzerName.placeholderText = qsTr ("Benutzername ist bereits vergeben")
benutzerName.clear()

View File

@@ -1,10 +1,13 @@
import QtCore
import QtQuick
import QtQuick.Controls
import QtQuick.Dialogs
import QtQuick.Layouts
Item
{
property string recpass: ""
anchors.fill: parent
ColumnLayout
@@ -133,11 +136,58 @@ Item
Layout.fillHeight: true
}
Dialog
{
id: recoveryPaswordDialog
modal: true
title: qsTr("Wiederherstellung")
anchors.centerIn: parent
standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted:
{
recpass = recoveryPaswordInput.text
getRecoveryDialog.open()
}
ColumnLayout
{
RowLayout
{
Label
{
text: qsTr("Wiederherstellungspasswort eingeben: ")
}
TextField
{
id: recoveryPaswordInput
text: ""
echoMode: TextInput.Password
implicitWidth: 300
placeholderText: qsTr("Hier Wiederherstellungspasswort eingeben")
}
}
}
}
FileDialog
{
id: getRecoveryDialog
title: qsTr("Wiederherstellungsdatei")
fileMode: FileDialog.OpenFile
nameFilters: ["PYQCRM Recovery files (*.pyqrec)"]
currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
onAccepted: config.getRecoveryKey(getRecoveryDialog.currentFile, recpass)
onRejected: quit()
}
}
Component.onCompleted:
{
loggedin_user.loginOkay.connect(loggedin)
config.invalidEncryptionKey.connect(getEncryptionKey)
config.checkEncryptionKey()
}
function loggedin()
@@ -145,4 +195,8 @@ Item
appLoader.source = "Dashboard.qml"
}
function getEncryptionKey()
{
recoveryPaswordDialog.open()
}
}

View File

@@ -11,113 +11,6 @@ Item
{
property string recpass: ""
property bool adminAvailable: true
Component.onCompleted:
{
config.dbConnectionError.connect(onDbConnectionError)
config.adminUserError.connect(onAdminUserError)
config.backupEncryptionKey.connect(onBackupEncryptionKey)
}
function onBackupEncryptionKey()
{
recoveryDialog.open()
}
function onDbConnectionError(msg, success)
{
if (!success)
conErrDialog.open()
}
function onAdminUserError(msg, success)
{
if (success)
{
encryptPwDialog.open()
}
else
{
adminAvailable = false
firstStart.push("AdminUserConfig.qml")
}
}
MessageDialog
{
id: recoveryDialog
text: qsTr("Diesen Wiederherstellungscode musst du sicher aufbewahren!\nMöchtest du das jetzt machen?")
title: qsTr("Wiederherstellen")
buttons: MessageDialog.Yes | MessageDialog.No
onAccepted: saveRecoveryDialog.open()
}
FileDialog
{
id: saveRecoveryDialog
title: qsTr("Wiederherstellungsdatei")
fileMode: adminAvailable? FileDialog.OpenFile: FileDialog.SaveFile
nameFilters: ["PYQCRM Recovery files (*.pyqrec)"]
currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
onAccepted:
{
if (!adminAvailable) config.saveRecoveryKey(saveRecoveryDialog.currentFile, recpass)
else
{
config.getRecoveryKey(saveRecoveryDialog.currentFile, recpass)
}
appLoader.source = "Dashboard.qml"
topBar.visible = true
}
}
MessageDialog
{
id: conErrDialog
text: qsTr("Datenbankverbindung fehlgeschlagen")
title: qsTr("Datenbank Verbindung")
}
Dialog
{
id: encryptPwDialog
modal: true
title: qsTr("Wiederherstellung")
anchors.centerIn: parent
standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted:
{
recpass = encryptPassword.text
saveRecoveryDialog.open()
}
ColumnLayout
{
RowLayout
{
Label
{
text: qsTr("Wiederherstellungspasswort eingeben: ")
}
TextField
{
id: encryptPassword
echoMode: TextInput.Password
implicitWidth: 300
placeholderText: qsTr("Hier Wiederherstellungspasswort eingeben")
}
}
}
}
anchors.fill: parent
StackView
@@ -125,15 +18,14 @@ Item
id: firstStart
anchors.fill: parent
initialItem: "DbConfiguration.qml"
//initialItem: "AdminUserConfig.qml"
}
RowLayout
{
anchors.bottom: parent.bottom
anchors.margins: 9
width: parent.width
Item
{
Layout.fillWidth: true
@@ -164,28 +56,125 @@ Item
if (pyqcrm_conf)
{
config.setConfig(pyqcrm_conf)
}
}
else
{
pyqcrm_conf = Qmldict.firstConf(submitBtn.grids)
if (pyqcrm_conf)
{
admin = config.addAdminUser(pyqcrm_conf)
if (admin)
{
//appLoader.source = "Dashboard.qml"
//topBar.visible = true
}
else
{
console.log("Konfiguration Admin fehlgeschlagen")
}
}
if (pyqcrm_conf) config.addAdminUser(pyqcrm_conf)
}
}
}
}
MessageDialog
{
id: recoveryDialog
text: qsTr("Diesen Wiederherstellungscode musst du sicher aufbewahren!\nMöchtest du das jetzt machen?")
title: qsTr("Wiederherstellen")
buttons: MessageDialog.Yes | MessageDialog.No
onAccepted: recoveryPaswordDialog.open()
onRejected: gotoLogin()
}
MessageDialog
{
id: conErrDialog
text: qsTr("Datenbankverbindung fehlgeschlagen")
title: qsTr("Datenbank Verbindung")
}
Dialog
{
id: recoveryPaswordDialog
modal: true
title: qsTr("Wiederherstellung")
anchors.centerIn: parent
standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted:
{
recpass = recoveryPaswordInput.text
saveRecoveryDialog.open()
}
ColumnLayout
{
RowLayout
{
Label
{
text: qsTr("Wiederherstellungspasswort eingeben: ")
}
TextField
{
id: recoveryPaswordInput
text: ""
echoMode: TextInput.Password
implicitWidth: 300
placeholderText: qsTr("Hier Wiederherstellungspasswort eingeben")
}
}
}
}
FileDialog
{
id: saveRecoveryDialog
title: qsTr("Wiederherstellungsdatei")
fileMode: adminAvailable? FileDialog.OpenFile: FileDialog.SaveFile
nameFilters: ["PYQCRM Recovery files (*.pyqrec)"]
currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
onAccepted:
{
if (!adminAvailable) config.saveRecoveryKey(saveRecoveryDialog.currentFile, recpass)
else config.getRecoveryKey(saveRecoveryDialog.currentFile, recpass)
gotoLogin()
}
onRejected:
{
if (adminAvailable) quit()
}
}
Component.onCompleted:
{
config.dbConnectionError.connect(onDbConnectionError)
config.adminUserError.connect(onAdminUserError)
config.backupEncryptionKey.connect(onBackupEncryptionKey)
}
function gotoLogin()
{
appLoader.source= "LoginScreen.qml"
topBar.visible = true
}
function onBackupEncryptionKey()
{
recoveryDialog.open()
}
function onDbConnectionError(msg, success)
{
if (!success)
conErrDialog.open()
}
function onAdminUserError(msg, success)
{
if (success)
{
recoveryPaswordDialog.open()
}
else
{
adminAvailable = false
firstStart.push("AdminUserConfig.qml")
}
}
}

View File

@@ -47,6 +47,7 @@ ApplicationWindow
property alias window: appWindow
}
Component.onCompleted:
{
if(bad_config)
@@ -54,8 +55,8 @@ ApplicationWindow
importDialog.open()
}
else appLoader.source= "LoginScreen.qml"
}
Dialog
{
id: importDialog
@@ -65,11 +66,10 @@ ApplicationWindow
onAccepted: settingsFiledialog.open()
onRejected: appLoader.source= "firststart.qml"
title: qsTr("Einstellungen importieren")
}
FileDialog
{
id: settingsFiledialog
title: qsTr("PYQCRM Einstellungen")
currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
@@ -77,18 +77,19 @@ ApplicationWindow
nameFilters: [qsTr("PYQCRM Einstellungen (*.pyqcrm)")]
onAccepted:
{
encryptPwDialog.open()
exportFilePassword.open()
confile = selectedFile
}
}
Dialog
{
id: encryptPwDialog
id: exportFilePassword
modal: true
title: qsTr("PYQCRM Einstellungen")
anchors.centerIn: parent
standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: config.importConfig(confile, encryptPassword.text)
onAccepted: config.importConfig(confile, exportPasswordInput.text)
ColumnLayout
{
RowLayout
@@ -100,7 +101,7 @@ ApplicationWindow
TextField
{
id: encryptPassword
id: exportPasswordInput
echoMode: TextInput.Password
implicitWidth: 300
}