diff options
Diffstat (limited to 'kodereviewer/app.py')
-rw-r--r-- | kodereviewer/app.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/kodereviewer/app.py b/kodereviewer/app.py new file mode 100644 index 0000000..a2eb5f4 --- /dev/null +++ b/kodereviewer/app.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 + +import os +import sys +import signal + +from KI18n import KLocalizedContext, KLocalizedString +from PySide6.QtGui import QGuiApplication +from PySide6.QtCore import QUrl, QByteArray +from PySide6.QtQml import QQmlApplicationEngine, qmlRegisterType + +from kodereviewer.mdconverter import MdConverter +from kodereviewer.project_model import ProjectModel +from kodereviewer.pull_request_model import PullRequestModel +from kodereviewer.network_manager import NetworkManager + + +def main(): + """Initializes and manages the application execution""" + app = QGuiApplication(sys.argv) + engine = QQmlApplicationEngine() + # KLocalizedString::setApplicationDomain("tutorial"); + KLocalizedString.setApplicationDomain(QByteArray(b"kodereviewer")) + + app.setOrganizationName("Deprecated") + app.setOrganizationDomain("deprecated.org") + app.setApplicationName("Kode Reviewer") + app.setDesktopFileName("kodereviewer") + + """Needed to close the app with Ctrl+C""" + signal.signal(signal.SIGINT, signal.SIG_DFL) + + """Needed to get proper KDE style outside of Plasma""" + if not os.environ.get("QT_QUICK_CONTROLS_STYLE"): + os.environ["QT_QUICK_CONTROLS_STYLE"] = "org.kde.desktop" + + qmlRegisterType(MdConverter, "org.deprecated.kodereviewer", 1, 0, "MdConverter") + qmlRegisterType(ProjectModel, "org.deprecated.kodereviewer", 1, 0, "ProjectModel") + qmlRegisterType(PullRequestModel, "org.deprecated.kodereviewer", 1, 0, "PullRequestModel") + qmlRegisterType(NetworkManager, "org.deprecated.kodereviewer", 1, 0, "NetworkManager") + + localized_context = KLocalizedContext() + engine.rootContext().setContextObject(localized_context) + base_path = os.path.abspath(os.path.dirname(__file__)) + engine.addImportPath(f"file://{base_path}/qml") + url = QUrl(f"file://{base_path}/qml/Main.qml") + engine.load(url) + + if len(engine.rootObjects()) == 0: + quit() + + app.exec() + + +if __name__ == "__main__": + main() |