diff --git a/.gitignore b/.gitignore index e180c1d..77ad946 100644 --- a/.gitignore +++ b/.gitignore @@ -195,6 +195,8 @@ venv.bak/ # mkdocs documentation /site +.qtcreator/ + # mypy .mypy_cache/ .dmypy.json diff --git a/Programmeinstellungen.qml b/Programmeinstellungen.qml new file mode 100644 index 0000000..28f34a4 --- /dev/null +++ b/Programmeinstellungen.qml @@ -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") + } + + + + } + + +} diff --git a/main.py b/main.py index 6712e7f..71f1c43 100644 --- a/main.py +++ b/main.py @@ -4,13 +4,76 @@ from pathlib import Path from PySide6.QtGui import QGuiApplication 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__": app = QGuiApplication(sys.argv) 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(): sys.exit(-1) sys.exit(app.exec()) diff --git a/pyqcrm.pyproject b/pyqcrm.pyproject index ab91695..8b6f5e8 100644 --- a/pyqcrm.pyproject +++ b/pyqcrm.pyproject @@ -1,5 +1,6 @@ { "files": [ + "Programmeinstellungen.qml", "main.py", "main.qml" ] diff --git a/pyqcrm.pyproject.user b/pyqcrm.pyproject.user index 5488a4e..813fbfc 100644 --- a/pyqcrm.pyproject.user +++ b/pyqcrm.pyproject.user @@ -1,10 +1,10 @@ - + EnvironmentId - {ef26fdb1-82c6-45b3-a374-8052d24e0ffb} + {39e37ca7-c3e2-4c38-a716-3e864b0bb4d2} ProjectExplorer.Project.ActiveTarget @@ -69,14 +69,16 @@ true true + false + 0 true true true Builtin.DefaultTidyAndClazy - 8 + 6 true @@ -89,18 +91,20 @@ ProjectExplorer.Project.Target.0 Desktop - Python 3.12.7 - Python 3.12.7 - {bdea9678-212b-477e-b193-9ce30dcf3aba} + Python 3.12.6 + Python 3.12.6 + {2db3a2fc-21bd-4c08-acba-70fdc903d42a} 0 0 0 - /home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm/.qtcreator/Python_3_12_7venv + C:\Users\gatze\Desktop\pyqcrm\.qtcreator\Python_3_12_6venv true Python.PysideBuildStep + C:\Users\gatze\Desktop\pyqcrm\.qtcreator\Python_3_12_6venv\Scripts\pyside6-project.exe + C:\Users\gatze\Desktop\pyqcrm\.qtcreator\Python_3_12_6venv\Scripts\pyside6-uic.exe 1 Erstellen @@ -118,10 +122,10 @@ false - Python 3.12.7 virtuelle Umgebung + Python 3.12.6 virtuelle Umgebung Python.PySideBuildConfiguration - /home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm/.qtcreator/Python_3_12_7venv/bin/python - /home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm/.qtcreator/Python_3_12_7venv + C:/Users/gatze/Desktop/pyqcrm/.qtcreator/Python_3_12_6venv/Scripts/python.exe + C:/Users/gatze/Desktop/pyqcrm/.qtcreator/Python_3_12_6venv 1 @@ -146,16 +150,15 @@ 2 false - -e cpu-cycles --call-graph dwarf,4096 -F 250 + -e cpu-cycles --call-graph "dwarf,4096" -F 250 main.py - PythonEditor.RunConfiguration./home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm/main.py - /home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm/main.py - false - /home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm/main.py + PythonEditor.RunConfiguration.C:/Users/gatze/Desktop/pyqcrm/main.py + C:/Users/gatze/Desktop/pyqcrm/main.py + true + C:\Users\gatze\Desktop\pyqcrm\main.py true true - /home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm - :0 + C:/Users/gatze/Desktop/pyqcrm 1 diff --git a/pyqcrm.pyproject.user.ef26fdb b/pyqcrm.pyproject.user.ef26fdb new file mode 100644 index 0000000..5488a4e --- /dev/null +++ b/pyqcrm.pyproject.user.ef26fdb @@ -0,0 +1,175 @@ + + + + + + EnvironmentId + {ef26fdb1-82c6-45b3-a374-8052d24e0ffb} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + 0 + false + true + false + 2 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 8 + true + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Python 3.12.7 + Python 3.12.7 + {bdea9678-212b-477e-b193-9ce30dcf3aba} + 0 + 0 + 0 + + /home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm/.qtcreator/Python_3_12_7venv + + + true + Python.PysideBuildStep + + 1 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + 0 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Python 3.12.7 virtuelle Umgebung + Python.PySideBuildConfiguration + /home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm/.qtcreator/Python_3_12_7venv/bin/python + /home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm/.qtcreator/Python_3_12_7venv + + 1 + + + 0 + Deployment + Deployment + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + 0 + true + + 2 + + false + -e cpu-cycles --call-graph dwarf,4096 -F 250 + main.py + PythonEditor.RunConfiguration./home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm/main.py + /home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm/main.py + false + /home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm/main.py + true + true + /home/dstoppek/Coden/Projekte/pyqcrm/pyqcrm + :0 + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/pyqcrm.toml b/pyqcrm.toml new file mode 100644 index 0000000..3d40a83 --- /dev/null +++ b/pyqcrm.toml @@ -0,0 +1 @@ +[pyqcrm] \ No newline at end of file