dictionary

This commit is contained in:
2024-10-30 16:27:41 +01:00
parent e14e1a4d42
commit d3b99320dd
5 changed files with 78 additions and 15 deletions

View File

@@ -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"
}
}

View File

@@ -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
}
}

34
js/qmldict.js Normal file
View File

@@ -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
}

View File

@@ -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):

View File

@@ -5,6 +5,7 @@
"lib/__init__.py",
"main.py",
"gui/main.qml",
"gui/start.qml"
"gui/start.qml",
"js/qmldict.js"
]
}