Programm-Einstellungen anlegen
This commit is contained in:
@@ -213,6 +213,10 @@ Item
|
||||
{
|
||||
id: cancelBtn
|
||||
text: qsTr("Abbrechen")
|
||||
onClicked:
|
||||
{
|
||||
Qt.quit()
|
||||
}
|
||||
}
|
||||
|
||||
Button
|
||||
@@ -220,7 +224,7 @@ Item
|
||||
id: submitBtn
|
||||
text: qsTr("Weiter")
|
||||
property var grids: [createUserGrid, dbGrid]
|
||||
property var dict: ({})
|
||||
property var pyqcrm_conf: ({})
|
||||
onClicked:
|
||||
{
|
||||
if (bar.itemAt(bar.currentIndex) !== dbTab)
|
||||
@@ -232,17 +236,17 @@ Item
|
||||
|
||||
else
|
||||
{
|
||||
dict = Qmldict.func(submitBtn.grids)
|
||||
console.log(dict)
|
||||
if (dict)
|
||||
config.setConfig(dict)
|
||||
|
||||
pyqcrm_conf = Qmldict.func(submitBtn.grids)
|
||||
if (pyqcrm_conf)
|
||||
{
|
||||
config.setConfig(pyqcrm_conf)
|
||||
appLoader.source = "start.qml"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted:
|
||||
{
|
||||
|
||||
@@ -9,8 +9,8 @@ Item
|
||||
Component.onCompleted:
|
||||
{
|
||||
appLoader.window.title = "pyqcrm"
|
||||
appLoader.window.height = Screen.height
|
||||
appLoader.window.width = Screen.width
|
||||
appLoader.window.height = Screen.height * .5
|
||||
appLoader.window.width = Screen.width * .5
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +1,27 @@
|
||||
.pragma library
|
||||
|
||||
var dict = new Object()
|
||||
|
||||
function func(createUserGrid)
|
||||
function func(tabs)
|
||||
{
|
||||
let pyqcrm_conf = {};
|
||||
|
||||
for (var j = 0; j < createUserGrid.length; j++)
|
||||
for (var j = 0; j < tabs.length; j++)
|
||||
{
|
||||
|
||||
for (var i = 0; i < createUserGrid[j].children.length; i++)
|
||||
for (var i = 0; i < tabs[j].children.length; i++)
|
||||
{
|
||||
|
||||
|
||||
if (createUserGrid[j].children[i].name)
|
||||
if (tabs[j].children[i].name)
|
||||
{
|
||||
if (!createUserGrid[j].children[i].text.trim())
|
||||
if (!tabs[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
|
||||
|
||||
|
||||
pyqcrm_conf[tabs[j].children[i].name] = tabs[j].children[i].text
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return dict
|
||||
|
||||
return pyqcrm_conf
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,13 +13,39 @@ class ConfigLoader(QObject):
|
||||
self.config_dir = user_config_dir() + '/pyqcrm' #user_config_dir = Funktion platformdirs
|
||||
config_dir = Path(self.config_dir)
|
||||
|
||||
config_dir.mkdir(0o750, True, True)
|
||||
if config_dir.exists():
|
||||
self.__configLoad()
|
||||
else:
|
||||
config_dir.mkdir(0o750, True, True)
|
||||
|
||||
@Slot(str)
|
||||
@Slot(dict)
|
||||
def setConfig(self, app_config):
|
||||
pyqcrm = '[pyqcrm]\n'
|
||||
db = '[database]\n'
|
||||
for k, v in app_config.items():
|
||||
if k == 'username':
|
||||
pyqcrm = pyqcrm + f"PYQCRM_ADMIN = \"{v}\"\n"
|
||||
elif k == 'password':
|
||||
pyqcrm = pyqcrm + f"PYQCRM_ADMIN_PASS = \"{v}\"\n"
|
||||
elif k == 'db-host':
|
||||
db = db + f"DB_HOST = \"{v}\"\n"
|
||||
elif k == 'db-name':
|
||||
db = db + f"DB_PORT = \"{v}\"\n"
|
||||
elif k == 'db-port':
|
||||
db = db + f"DB_NAME = \"{v}\"\n"
|
||||
elif k == 'db-username':
|
||||
db = db + f"DB_USER = \"{v}\"\n"
|
||||
elif k == 'db-password':
|
||||
db = db + f"DB_PASS = \"{v}\"\n"
|
||||
|
||||
appconf = pyqcrm + '\n' + db + '\n'
|
||||
|
||||
try:
|
||||
with open (self.config_dir + '/pyqcrm.toml', 'w') as f:
|
||||
f.write(appconf)
|
||||
except FileNotFoundError:
|
||||
print("Konnte die Konfiguration nicht speichern.")
|
||||
|
||||
print (type(app_config))
|
||||
|
||||
def __configLoad(self):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user