Compare commits
5 Commits
4e3e8db16d
...
6bf38abc53
| Author | SHA256 | Date | |
|---|---|---|---|
| 6bf38abc53 | |||
| ad9e60dec0 | |||
| 44ebbee802 | |||
| f36973a307 | |||
| 7b2c0ef149 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -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
77
Programmeinstellungen.qml
Normal 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
63
main.py
63
main.py
@@ -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)
|
||||||
|
|
||||||
|
config = ConfigLoader()
|
||||||
|
|
||||||
|
|
||||||
|
if config.getConfig():
|
||||||
|
try:
|
||||||
|
print (config.getConfig()['database']['server'])
|
||||||
qml_file = Path(__file__).resolve().parent / "main.qml"
|
qml_file = Path(__file__).resolve().parent / "main.qml"
|
||||||
engine.load(qml_file)
|
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())
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"files": [
|
"files": [
|
||||||
|
"Programmeinstellungen.qml",
|
||||||
"main.py",
|
"main.py",
|
||||||
"main.qml"
|
"main.qml"
|
||||||
]
|
]
|
||||||
|
|||||||
1
pyqcrm.toml
Normal file
1
pyqcrm.toml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
[pyqcrm]
|
||||||
Reference in New Issue
Block a user