Bread_Editor/bread_editor/main.py

55 lines
1.3 KiB
Python
Executable file

#!/usr/bin/python3
import sys
from PyQt6.QtCore import QTimer
from wobbl_tools.data_file import load_dataclass_json
from bread_editor.utils import Utils
from bread_editor.file import File, FileActions
from bread_editor.ui import GUI
from bread_editor.settings import Settings
from bread_editor.ipc import IPC
class BreadEditor:
def __init__(self):
self.utils = Utils(self)
self.settings = load_dataclass_json(Settings, f"{self.utils.editor_path}/settings.json")
self.file_actions = FileActions(self)
self.ipc = IPC(self)
if not self.ipc.first_instance:
return
self.gui = GUI(self)
self.open_files: dict[str, File] = {}
self.open_files_queue = []
self.files_queue_timer = QTimer(self.gui.QTMainWindow)
self.files_queue_timer.timeout.connect(self.utils.check_file_queue)
self.files_queue_timer.start(500)
def run(self):
if not self.ipc.first_instance:
return
self.gui.post_setup()
self.utils.popup_init()
self.utils.on_start()
self.gui.QTMainWindow.show()
sys.exit(self.gui.qt_app.exec())
def start_from_command_line():
editor = BreadEditor()
editor.run()
if __name__ == "__main__":
editor = BreadEditor()
editor.run()