From d3b99320dda8c5d7255507ec999a0530a6325edefdc29354dd69e56dec526db2 Mon Sep 17 00:00:00 2001 From: Marco Gatzen Date: Wed, 30 Oct 2024 16:27:41 +0100 Subject: [PATCH] dictionary --- gui/firststart.qml | 42 ++++++++++++++++++++++++++++++++---------- gui/start.qml | 9 +++++++-- js/qmldict.js | 34 ++++++++++++++++++++++++++++++++++ lib/ConfigLoader.py | 5 +++-- pyqcrm.pyproject | 3 ++- 5 files changed, 78 insertions(+), 15 deletions(-) create mode 100644 js/qmldict.js diff --git a/gui/firststart.qml b/gui/firststart.qml index a38cfef..59b59a8 100644 --- a/gui/firststart.qml +++ b/gui/firststart.qml @@ -2,6 +2,7 @@ import QtQuick import QtQuick.Layouts import QtQuick.Controls import QtQuick.Controls.Material +import "../js/qmldict.js" as Qmldict @@ -34,8 +35,15 @@ Item } TabButton + { + id: dbTab text: qsTr("Datenbank einrichten") + + } + onCurrentIndexChanged: + { + submitBtn.text = currentIndex === 0? "Weiter" : "Speichern" } } @@ -45,6 +53,7 @@ Item Layout.fillHeight: true currentIndex: bar.currentIndex Layout.margins: 9 + id: stackl Item { @@ -109,10 +118,12 @@ Item rowSpacing: 9 anchors.fill: parent + Label { text: qsTr("DB-Host:") Layout.alignment: Qt.AlignRight + } TextField @@ -120,6 +131,7 @@ Item id: dbHost placeholderText: qsTr("Hier Host eingeben") Layout.fillWidth: true + property string name: "db-host" } Label @@ -133,6 +145,7 @@ Item id: dbPort placeholderText: qsTr("Hier DB-Port eingeben") Layout.fillWidth: true + property string name: "db-port" } Label @@ -146,6 +159,7 @@ Item id: dbName placeholderText: qsTr("Hier DB-Name eingeben") Layout.fillWidth: true + property string name: "db-name" } Label @@ -159,6 +173,7 @@ Item id: dbUserName placeholderText: qsTr("Hier DB-Benutzername eingeben") Layout.fillWidth: true + property string name: "db-username" } @@ -174,6 +189,7 @@ Item echoMode: TextInput.Password placeholderText: qsTr("Hier DB-Passwort eingeben") Layout.fillWidth: true + property string name: "db-password" } Item @@ -202,22 +218,27 @@ Item Button { id: submitBtn - text: qsTr("Speichern") + text: qsTr("Weiter") + property var grids: [createUserGrid, dbGrid] + property var dict: ({}) onClicked: { - config.createUser(benutzerName.text) - for (var i = 0; i < createUserGrid.children.length; i++) + if (bar.itemAt(bar.currentIndex) !== dbTab) { - // console.log(createUserGrid.children[i].name) - // console.log(createUserGrid.children[i].text) - if (createUserGrid.children[i].name) - { - console.log(createUserGrid.children[i].name); - console.log(createUserGrid.children[i].text); - } + bar.currentIndex = 1 + } + else + { + dict = Qmldict.func(submitBtn.grids) + console.log(dict) + if (dict) + config.setConfig(dict) + + appLoader.source = "start.qml" + } } } } @@ -226,5 +247,6 @@ Item Component.onCompleted: { appLoader.window.title = "PYQCRM - Einstellungen" + } } diff --git a/gui/start.qml b/gui/start.qml index e06f032..1398fd1 100644 --- a/gui/start.qml +++ b/gui/start.qml @@ -1,13 +1,18 @@ import QtQuick +import QtQuick.Controls Item { anchors.fill: parent + Component.onCompleted: + { + appLoader.window.title = "pyqcrm" + appLoader.window.height = Screen.height + appLoader.window.width = Screen.width - parent.width: 1080 - parent.height: 1920 + } } diff --git a/js/qmldict.js b/js/qmldict.js new file mode 100644 index 0000000..2634b71 --- /dev/null +++ b/js/qmldict.js @@ -0,0 +1,34 @@ +.pragma library + +var dict = new Object() + +function func(createUserGrid) +{ + + for (var j = 0; j < createUserGrid.length; j++) + { + + for (var i = 0; i < createUserGrid[j].children.length; i++) + { + + + if (createUserGrid[j].children[i].name) + { + if (!createUserGrid[j].children[i].text.trim()) + return false + + // dict.set(createUserGrid[j].children[i].name , createUserGrid[j].children[i].text) + dict[createUserGrid[j].children[i].name] = createUserGrid[j].children[i].text + + + } + } + + } + return dict +} + + + + + diff --git a/lib/ConfigLoader.py b/lib/ConfigLoader.py index 1bc5d8c..e700466 100644 --- a/lib/ConfigLoader.py +++ b/lib/ConfigLoader.py @@ -17,8 +17,9 @@ class ConfigLoader(QObject): self.__configLoad() @Slot(str) - def createUser(self, username): - pass + def setConfig(self, app_config): + + print (type(app_config)) def __configLoad(self): diff --git a/pyqcrm.pyproject b/pyqcrm.pyproject index 99d9a73..d16df7a 100644 --- a/pyqcrm.pyproject +++ b/pyqcrm.pyproject @@ -5,6 +5,7 @@ "lib/__init__.py", "main.py", "gui/main.qml", - "gui/start.qml" + "gui/start.qml", + "js/qmldict.js" ] }