diff --git a/.gitignore b/.gitignore index 08475ff..50a15a8 100644 --- a/.gitignore +++ b/.gitignore @@ -208,6 +208,7 @@ dmypy.json # pytype static type analyzer .pytype/ .qtcreator/ +pyqcrm.pyproject.user # Cython debug symbols cython_debug/ diff --git a/Programmeinstellungen.qml b/Programmeinstellungen.qml deleted file mode 100644 index 28f34a4..0000000 --- a/Programmeinstellungen.qml +++ /dev/null @@ -1,77 +0,0 @@ -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/gui/Programmeinstellungen.qml b/gui/Programmeinstellungen.qml new file mode 100644 index 0000000..27f0b9b --- /dev/null +++ b/gui/Programmeinstellungen.qml @@ -0,0 +1,176 @@ +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import QtQuick.Controls.Material + + + +// Item { + +// benutzername +// passwort +// server +// port +// benutzername(db) +// passwort(db) +// DbName +// type + + +// } + +ApplicationWindow +{ + width: 640 + height: 480 + visible: true + // Material.theme: Material.Dark + // Material.accent: Material.Purple + ColumnLayout + { + anchors.fill: parent + TabBar + { + id: bar + anchors.fill: parent + TabButton + { + text: qsTr("Benutzer erstellen") + } + + TabButton + { + text: qsTr("Datenbank einrichten") + } + } + + StackLayout + { + anchors.fill: parent + currentIndex: bar.currentIndex + + Item + { + id: createUser + + GridLayout + { + id: createUserGrid + columns: 2 + anchors.fill: parent + + Label + { + text: qsTr("Benutzername:") + } + + TextField + { + id: benutzerName + placeholderText: qsTr("Hier Benutzername eingeben") + } + + Label + { + text: qsTr("Passwort:") + } + + TextField + { + id: password + echoMode: TextInput.Password + placeholderText: qsTr("Hier Passwort eingeben") + } + } + } + + Item + { + id: settingsDB + + + GridLayout + { + id: dbGrid + columns: 2 + + + + Label + { + text: qsTr("DB-Host:") + } + + TextField + { + id: dbHost + placeholderText: qsTr("Hier Host eingeben") + } + + Label + { + text: qsTr("DB-Port:") + } + + TextField + { + id: dbPort + placeholderText: qsTr("Hier DB-Port eingeben") + } + + Label + { + text: qsTr("DB-Name:") + } + + TextField + { + id: dbName + placeholderText: qsTr("Hier DB-Name eingeben") + } + + Label + { + text: qsTr("DB-Benutzername:") + } + + TextField + { + id: dbUserName + placeholderText: qsTr("Hier DB-Benutzername eingeben") + } + + Label + { + text: qsTr("DB-Passwort:") + } + + TextField + { + id: dbPassword + echoMode: TextInput.Password + placeholderText: qsTr("Hier DB-Passwort eingeben") + } + } + } + } + RowLayout + { + Button + { + id: cancelBtn + text: qsTr("Abbrechen") + } + + Button + { + id: submitBtn + text: qsTr("Speichern") + onClicked: + { + config.createUser(benutzerName.text) + } + } + } + } +} diff --git a/main.qml b/gui/main.qml similarity index 100% rename from main.qml rename to gui/main.qml diff --git a/main.py b/main.py index 71f1c43..2976baa 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,9 @@ # This Python file uses the following encoding: utf-8 import sys from pathlib import Path - from PySide6.QtGui import QGuiApplication from PySide6.QtQml import QQmlApplicationEngine -from platformdirs import * -import toml +from lib.ConfigLoader import ConfigLoader # [pyqcrm] @@ -21,58 +19,27 @@ import toml # 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) - 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 config.getConfig(): + try: + print (config.getConfig()['database']['server']) + qml_file = Path(__file__).resolve().parent / "gui/main.qml" + engine.load(qml_file) + except: + print("Ausnahme") + qml_file = Path(__file__).resolve().parent / "gui/Programmeinstellungen.qml" + engine.rootContext().setContextProperty("config", config) + engine.load(qml_file) + # else: + # config.createConfig() if not engine.rootObjects(): sys.exit(-1) diff --git a/pyqcrm.pyproject b/pyqcrm.pyproject index 8b6f5e8..3b5a040 100644 --- a/pyqcrm.pyproject +++ b/pyqcrm.pyproject @@ -1,7 +1,9 @@ { "files": [ - "Programmeinstellungen.qml", + "gui/Programmeinstellungen.qml", + "lib/ConfigLoader.py", + "lib/__init__.py", "main.py", - "main.qml" + "gui/main.qml" ] } diff --git a/pyqcrm.pyproject.user b/pyqcrm.pyproject.user new file mode 100644 index 0000000..67f88d4 --- /dev/null +++ b/pyqcrm.pyproject.user @@ -0,0 +1,406 @@ + + + + + + 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 + Kopie von Python 3.12.7(anaconda3) + Kopie von Python 3.12.7(anaconda3) + {9836806b-a4af-40e8-8200-3e0deb30396b} + 0 + 0 + 0 + + /home/dstoppek/Coden/Projekte/pyqcrm + + + true + Python.PysideBuildStep + /home/dstoppek/anaconda3/envs/pyqcrm/bin/pyside6-project + /home/dstoppek/anaconda3/envs/pyqcrm/bin/pyside6-uic + + 1 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + 0 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Python 3.12.7(anaconda3) + Python.PySideBuildConfiguration + /home/dstoppek/anaconda3/envs/pyqcrm/bin/python3 + + + /home/dstoppek/Coden/Projekte/pyqcrm/.qtcreator/Python_3_12_7_anaconda3_venv + + + true + Python.PysideBuildStep + + 1 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + 0 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Python 3.12.7(anaconda3) virtuelle Umgebung + Python.PySideBuildConfiguration + /home/dstoppek/Coden/Projekte/pyqcrm/.qtcreator/Python_3_12_7_anaconda3_venv/bin/python + /home/dstoppek/Coden/Projekte/pyqcrm/.qtcreator/Python_3_12_7_anaconda3_venv + + 2 + + + 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/main.py + /home/dstoppek/Coden/Projekte/pyqcrm/main.py + true + /home/dstoppek/Coden/Projekte/pyqcrm/main.py + true + true + /home/dstoppek/Coden/Projekte/pyqcrm + :0 + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop + Python 3.12.7(anaconda3) + Python 3.12.7(anaconda3) + {23302c74-4cf1-493d-9702-a00b743f63e1} + 0 + 0 + 0 + + /home/dstoppek/Coden/Projekte/pyqcrm/.qtcreator/Python_3_12_7_anaconda3_venv_3 + + + true + Python.PysideBuildStep + + 1 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + 0 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Python 3.12.7(anaconda3) virtuelle Umgebung + Python.PySideBuildConfiguration + /home/dstoppek/Coden/Projekte/pyqcrm/.qtcreator/Python_3_12_7_anaconda3_venv_3/bin/python + /home/dstoppek/Coden/Projekte/pyqcrm/.qtcreator/Python_3_12_7_anaconda3_venv_3 + + + /home/dstoppek/Coden/Projekte/pyqcrm/.qtcreator/Python_3_12_7_anaconda3_venv + + + true + Python.PysideBuildStep + + 1 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + 0 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Python 3.12.7(anaconda3) virtuelle Umgebung2 + Python.PySideBuildConfiguration + /home/dstoppek/Coden/Projekte/pyqcrm/.qtcreator/Python_3_12_7_anaconda3_venv/bin/python + /home/dstoppek/Coden/Projekte/pyqcrm/.qtcreator/Python_3_12_7_anaconda3_venv + + 2 + + + 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/main.py + /home/dstoppek/Coden/Projekte/pyqcrm/main.py + true + /home/dstoppek/Coden/Projekte/pyqcrm/main.py + true + true + /home/dstoppek/Coden/Projekte/pyqcrm + :0 + + 1 + + + + ProjectExplorer.Project.Target.2 + + Desktop + Python 3.12.7 + Python 3.12.7 + {bdea9678-212b-477e-b193-9ce30dcf3aba} + 0 + 0 + 0 + + /home/dstoppek/Coden/Projekte/pyqcrm + + + true + Python.PysideBuildStep + + 1 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + 0 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Python 3.12.7 + Python.PySideBuildConfiguration + /usr/bin/python3.12 + + + /home/dstoppek/Coden/Projekte/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/.qtcreator/Python_3_12_7venv/bin/python + /home/dstoppek/Coden/Projekte/pyqcrm/.qtcreator/Python_3_12_7venv + + 2 + + + 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 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 3 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + +