Files
pyqcrm/Gui/firststart.qml
2024-12-03 16:30:56 +01:00

146 lines
3.3 KiB
QML

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Dialogs
import "../js/qmldict.js" as Qmldict
Item
{
Component.onCompleted:
{
config.dbConnectionError.connect(onDbConnectionError)
config.adminUserError.connect(onAdminUserError)
}
function onDbConnectionError(msg, success)
{
if (!success)
conErrDialog.open()
}
function onAdminUserError(msg, success)
{
if (success)
{
encryptPwDialog.open()
}
else
firstStart.push("AdminUserConfig.qml")
}
MessageDialog
{
id: conErrDialog
text: qsTr("Datenbankverbindung fehlgeschlagen")
title: qsTr("Datenbank Verbindung")
}
Dialog
{
id: encryptPwDialog
modal: true
title: qsTr("Encryption Key")
anchors.centerIn: parent
standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted:
{
// TODO: signal for EncryptionKey testing
config.setEncyrptKey(encryptPassword.text)
appLoader.source = "Dashboard.qml"
topBar.visible = true
}
ColumnLayout
{
RowLayout
{
Label
{
text: qsTr("Encryption Key eingeben:")
}
TextField
{
id: encryptPassword
echoMode: TextInput.Password
implicitWidth: 300
placeholderText: qsTr("Hier Encryption Key eingeben")
}
}
}
}
anchors.fill: parent
StackView
{
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
}
Button
{
id: cancelBtn
text: qsTr("Abbrechen")
onClicked:
{
Qt.quit()
}
}
Button
{
id: submitBtn
text: qsTr("Speichern")
property var grids: firstStart.currentItem
property var pyqcrm_conf: ({})
property var admin: Boolean
onClicked:
{
if (firstStart.currentItem.name === "database")
{
pyqcrm_conf = Qmldict.func(submitBtn.grids)
if (pyqcrm_conf)
{
config.setConfig(pyqcrm_conf)
}
}
else
{
pyqcrm_conf = Qmldict.func(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")
}
}
}
}
}
}
}