93 lines
2.4 KiB
Python
93 lines
2.4 KiB
Python
# This Python file uses the following encoding: utf-8
|
|
import sys
|
|
import logging
|
|
from PySide6.QtGui import QGuiApplication
|
|
from PySide6.QtQml import QQmlApplicationEngine
|
|
#from PySide6.QtCore import QResource
|
|
from lib.ConfigLoader import ConfigLoader
|
|
from lib.DB.BusinessModel import BusinessModel
|
|
import rc_pyqcrm
|
|
import rc_qml
|
|
from lib.DB.DbManager import DbManager
|
|
from lib.DB.UserManager import UserManager
|
|
from lib.DB.AddressModel import AddressModel
|
|
from lib.DB.BTypeModel import BTypeModel
|
|
from lib.DB.ContactModel import ContactModel
|
|
|
|
|
|
# [pyqcrm]
|
|
# program-name=""
|
|
# version=
|
|
|
|
# [database]
|
|
# server=""
|
|
# port=
|
|
# user=""
|
|
# password=""
|
|
# name=""
|
|
# type=""
|
|
logger = logging.getLogger(__name__)
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
bad_config = False
|
|
am = None
|
|
bm = None
|
|
btm = None
|
|
contact_model = None
|
|
user = None
|
|
|
|
def initializeProgram():
|
|
# print(f"In {__file__} file, initializeProgram()")
|
|
global am, bad_config, bm, user, btm, contact_model
|
|
if not bad_config:
|
|
dbconf = config.getConfig()['database']
|
|
DbManager(dbconf)
|
|
bad_config = False
|
|
bm = BusinessModel()
|
|
user = UserManager()
|
|
am = AddressModel()
|
|
btm = BTypeModel()
|
|
contact_model = ContactModel()
|
|
|
|
publishContext()
|
|
|
|
def publishContext():
|
|
# print(f"In {__file__} file, publishContext()")
|
|
global engine, am, bad_config, bm, user, btm, contact_model
|
|
engine.rootContext().setContextProperty("loggedin_user", user)
|
|
engine.rootContext().setContextProperty("bm", bm)
|
|
engine.rootContext().setContextProperty("am", am)
|
|
engine.rootContext().setContextProperty("btm", btm)
|
|
engine.rootContext().setContextProperty("contact_model", contact_model)
|
|
|
|
if __name__ == "__main__":
|
|
#QResource.registerResource("rc_qml.py")
|
|
app = QGuiApplication(sys.argv)
|
|
engine = QQmlApplicationEngine()
|
|
|
|
engine.addImportPath("qrc:/");
|
|
|
|
# qml_file = Path(__file__).resolve().parent / "Gui/main.qml"
|
|
|
|
qml_file = "qrc:/Gui/main.qml"
|
|
|
|
config = ConfigLoader()
|
|
|
|
|
|
if not config.getConfig():
|
|
bad_config = True
|
|
config.configurationReady.connect(initializeProgram)
|
|
else:
|
|
initializeProgram()
|
|
|
|
|
|
engine.rootContext().setContextProperty("bad_config", bad_config) # print(f"Fehler: {i}")
|
|
engine.rootContext().setContextProperty("config", config)
|
|
|
|
engine.load(qml_file)
|
|
|
|
|
|
if not engine.rootObjects():
|
|
sys.exit(-1)
|
|
sys.exit(app.exec())
|