Compare commits

...

5 Commits

Author SHA256 Message Date
6bf38abc53 lala 2024-10-24 16:25:29 +02:00
ad9e60dec0 lala 2024-10-24 16:23:56 +02:00
44ebbee802 Reapply "GUI und config"
This reverts commit f36973a307.
2024-10-24 16:10:21 +02:00
f36973a307 Revert "GUI und config"
This reverts commit 7b2c0ef149.
2024-10-24 16:06:50 +02:00
7b2c0ef149 GUI und config 2024-10-24 16:02:09 +02:00
5 changed files with 146 additions and 2 deletions

2
.gitignore vendored
View File

@@ -195,6 +195,8 @@ venv.bak/
# mkdocs documentation # mkdocs documentation
/site /site
.qtcreator/
# mypy # mypy
.mypy_cache/ .mypy_cache/
.dmypy.json .dmypy.json

77
Programmeinstellungen.qml Normal file
View File

@@ -0,0 +1,77 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
// Item {
// benutzername
// passwort
// server
// port
// benutzername(db)
// passwort(db)
// DbName
// type
// }
Window
{
width: 640
height: 480
visible: true
GridLayout
{
id: settingsGrid
columns: 2
anchors.fill: parent
Label
{
text: qsTr("Benutzername:")
}
TextField
{
id: benutzerName
placeholderText: qsTr("Hier Benutzername eingeben")
}
Label
{
text: qsTr("Passwort:")
}
TextField
{
id: passWort
placeholderText: qsTr("Hier Passwort eingeben")
}
Label
{
text: qsTr("DB-Host:")
}
TextField
{
id: dbHost
placeholderText: qsTr("Hier Host eingeben")
}
Label
{
text: qsTr("DB-Name:")
}
TextField
{
id: dbName
placeholderText: qsTr("Hier DB-Name eingeben")
}
}
}

67
main.py
View File

@@ -4,13 +4,76 @@ from pathlib import Path
from PySide6.QtGui import QGuiApplication from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine from PySide6.QtQml import QQmlApplicationEngine
from platformdirs import *
import toml
# [pyqcrm]
# program-name=""
# version=
# [database]
# server=""
# port=
# user=""
# password=""
# name=""
# type=""
class ConfigLoader:
__config = None
def __init__(self):
self.config_dir = user_config_dir() + '/pyqcrm' #user_config_dir = Funktion platformdirs
config_dir = Path(self.config_dir)
config_dir.mkdir(0o027, True, True)
self.__configLoad()
def __configLoad(self):
try:
with open (self.config_dir + '/pyqcrm.toml', 'r') as f:
self.__config = toml.load(f)
except FileNotFoundError:
print("Konnte die Konfiguration nicht laden.")
def getConfig(self):
return self.__config
def createConfig(self):
with open(self.config_dir + '/pyqcrm.toml', "w") as datei:
datei.write("[pyqcrm]")
if __name__ == "__main__": if __name__ == "__main__":
app = QGuiApplication(sys.argv) app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine() engine = QQmlApplicationEngine()
qml_file = Path(__file__).resolve().parent / "main.qml"
engine.load(qml_file) # qml_file = Path(__file__).resolve().parent / "main.qml"
# engine.load(qml_file)
config = ConfigLoader()
if config.getConfig():
try:
print (config.getConfig()['database']['server'])
qml_file = Path(__file__).resolve().parent / "main.qml"
engine.load(qml_file)
except:
print("Ausnahme")
qml_file = Path(__file__).resolve().parent / "Programmeinstellungen.qml"
engine.load(qml_file)
else:
config.createConfig()
if not engine.rootObjects(): if not engine.rootObjects():
sys.exit(-1) sys.exit(-1)
sys.exit(app.exec()) sys.exit(app.exec())

View File

@@ -1,5 +1,6 @@
{ {
"files": [ "files": [
"Programmeinstellungen.qml",
"main.py", "main.py",
"main.qml" "main.qml"
] ]

1
pyqcrm.toml Normal file
View File

@@ -0,0 +1 @@
[pyqcrm]