1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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()
|