Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/model/filter_data/cues/cue_filter_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,21 @@ def __init__(self, parameters: dict[str, str] | None = None) -> None:
self.cues: list[Cue] = []
self.channels: list[tuple[str, DataType]] = [] # name, data type
self.global_restart_on_end: bool = False
self._persistence_enabled: bool = False
self._default_cue: int = -1

if parameters is not None:
self.load_from_configuration(parameters)

@property
def persistence_enabled(self) -> bool:
"""If true, the filter will recall its configuration after returning to the scene."""
return self._persistence_enabled

@persistence_enabled.setter
def persistence_enabled(self, value: bool) -> None:
self._persistence_enabled = value

@property
def default_cue(self) -> int:
"""Default cue of filter.
Expand All @@ -48,7 +58,8 @@ def get_as_configuration(self) -> dict[str, str]:
else:
mapping_str = ""
return {"end_handling": "start_again" if self.global_restart_on_end else "hold", "mapping": mapping_str,
"cuelist": "$".join([c.format_cue() for c in self.cues]), "default_cue": str(self.default_cue)}
"cuelist": "$".join([c.format_cue() for c in self.cues]), "default_cue": str(self.default_cue),
"persistence": "true" if self.persistence_enabled else "false"}

def append_cue(self, c: Cue) -> None:
"""Add a cue to the model."""
Expand Down Expand Up @@ -76,6 +87,7 @@ def remove_channel(self, c: tuple[str, DataType]) -> None:

def load_from_configuration(self, parameters: dict[str, str]) -> None:
"""Deserialize configuration from filter configuration."""
self.persistence_enabled = parameters.get("persistence", "false") == "true"
self.global_restart_on_end = parameters.get("end_handling") == "start_again"

mapping_str = parameters.get("mapping")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ def _load_configuration(self, parameters: dict[str, str]) -> None:
if self._bankset:
self._bankset.update()
BankSet.push_messages_now()
self._persistence_enabled_cb.setChecked(self._model.persistence_enabled)

def _get_configuration(self) -> dict[str, str]:
self._model.default_cue = self._default_cue_combo_box.currentIndex() - 1
self._model.persistence_enabled = self._persistence_enabled_cb.isChecked()
return self._model.get_as_configuration()

def __init__(self, parent: QWidget = None, f: Filter | None = None) -> None:
Expand Down Expand Up @@ -112,6 +114,8 @@ def __init__(self, parent: QWidget = None, f: Filter | None = None) -> None:
self._current_cue_another_play_pressed_checkbox.clicked.connect(self._cue_play_pressed_restart_changed)
self._current_cue_another_play_pressed_checkbox.setEnabled(False)
cue_settings_container_layout.addRow("", self._current_cue_another_play_pressed_checkbox)
self._persistence_enabled_cb = QCheckBox("Enable Persistence", self._parent_widget)
cue_settings_container_layout.addWidget(self._persistence_enabled_cb)

cue_settings_container_layout.addRow("Zoom", self.zoom_panel)
cue_settings_container.setLayout(cue_settings_container_layout)
Expand Down
Loading