hydraveil-gui/gui/v2/infrastructure/take_plumbing_action.py

28 lines
854 B
Python

from core.infrastructure.plumbing import ThreadPlumbing
from core.models.Result import ResultError
from gui.v2.infrastructure.action_registry import ENUM_MAP
from gui.v2.infrastructure.ThreadSafetyTool import ThreadSafetyTool
from gui.v2.ui.popups.error_popup import ErrorPopup
from typing import Callable
AUTO_NAVIGATE_REGISTRY = {
ResultError.WRONG_LOCATION: "settings"
}
def take_action(action: Callable, ui_caller: Callable, *args, **kwargs):
"""PyQt6 GUI implementation of plumbing"""
controller = ThreadPlumbing(
action=action,
ui_dispatcher=ThreadSafetyTool(), # PyQt6 as mainthread
error_implementation=ErrorPopup, # PyQt6 ErrorPopup
ENUM_MAP=ENUM_MAP,
auto_navigate_dict=AUTO_NAVIGATE_REGISTRY,
ui_caller=ui_caller,
*args,
**kwargs
)
controller.execute()