From 5b2adfef9aa11d1f0debecb8753130424bfece41 Mon Sep 17 00:00:00 2001 From: Martastain Date: Mon, 8 May 2023 20:49:49 +0200 Subject: [PATCH] fix: marking, rundown primary asset --- firefly/components/input_datetime.py | 5 ++++- firefly/modules/rundown/__init__.py | 3 ++- firefly/modules/rundown/model.py | 2 ++ firefly/modules/rundown/view.py | 21 +++++++++++++++++++++ firefly/modules/scheduler/__init__.py | 2 ++ firefly/objects/format.py | 3 +++ 6 files changed, 34 insertions(+), 2 deletions(-) diff --git a/firefly/components/input_datetime.py b/firefly/components/input_datetime.py index 48f4449..9577cd2 100644 --- a/firefly/components/input_datetime.py +++ b/firefly/components/input_datetime.py @@ -53,6 +53,8 @@ def __init__(self, parent, value=None, **kwargs): self.clear_button.setText("Clear") self.clear_button.clicked.connect(self.clear_value) layout.addWidget(self.clear_button, 0) + else: + self.clear_button = None self.setLayout(layout) self.set_value(value) @@ -91,4 +93,5 @@ def get_value(self): def setReadOnly(self, value): self._read_only = value self.end_edit() - self.clear_button.setEnabled(not value) + if self.clear_button: + self.clear_button.setEnabled(not value) diff --git a/firefly/modules/rundown/__init__.py b/firefly/modules/rundown/__init__.py index 08650c0..e85453f 100644 --- a/firefly/modules/rundown/__init__.py +++ b/firefly/modules/rundown/__init__.py @@ -178,7 +178,8 @@ def set_channel(self, id_channel): def on_channel_changed(self): self.load(do_update_header=True) - self.plugins.load() + if self.plugins: + self.plugins.load() if self.mcr: self.mcr.on_channel_changed() diff --git a/firefly/modules/rundown/model.py b/firefly/modules/rundown/model.py index e36cc9a..f021cbc 100644 --- a/firefly/modules/rundown/model.py +++ b/firefly/modules/rundown/model.py @@ -105,6 +105,8 @@ def load_callback(self, response): item.id_channel = self.id_channel if row.get("id_asset"): item._asset = asset_cache.get(row["id_asset"]) + item._asset.meta.pop("mark_in", None) + item._asset.meta.pop("mark_out", None) required_assets.append([row["id_asset"], row["asset_mtime"]]) else: item._asset = None diff --git a/firefly/modules/rundown/view.py b/firefly/modules/rundown/view.py index e093257..9132a41 100644 --- a/firefly/modules/rundown/view.py +++ b/firefly/modules/rundown/view.py @@ -125,6 +125,11 @@ def contextMenuEvent(self, event): action_split.triggered.connect(self.on_split) menu.addAction(action_split) + action_set_primary = QAction("Set as primary", self) + action_set_primary.setStatusTip("Set selected item as primary") + action_set_primary.triggered.connect(self.on_set_primary) + menu.addAction(action_set_primary) + if obj_set[0] == "item" and ( self.selected_objects[0]["id_asset"] or self.selected_objects[0]["item_role"] == "live" @@ -331,6 +336,22 @@ def on_split(self): ) self.model().load() + def on_set_primary(self): + item = self.selected_objects[0] + asset = item._asset + if not asset: + return + + emeta = {} + for field in self.playout_config.fields: + key = field.name + if key in asset.meta: + emeta[key] = asset.meta[key] + emeta["id_asset"] = asset.id + + api.set(object_type="event", id=item["id_event"], data=emeta) + self.model().load() + def on_solve(self, solver): QApplication.processEvents() QApplication.setOverrideCursor(Qt.CursorShape.WaitCursor) diff --git a/firefly/modules/scheduler/__init__.py b/firefly/modules/scheduler/__init__.py index 464a2d7..b974c24 100644 --- a/firefly/modules/scheduler/__init__.py +++ b/firefly/modules/scheduler/__init__.py @@ -59,6 +59,8 @@ def focus(self, objects): # self.calendar.update() def open_rundown(self, ts, event=False): + if not self.main_window.main_widget.rundown: + return self.main_window.main_widget.rundown.load(start_time=ts, event=event) self.main_window.main_widget.switch_tab( self.main_window.main_widget.rundown, perform_on_switch_tab=False diff --git a/firefly/objects/format.py b/firefly/objects/format.py index 5407bdc..a72bed4 100644 --- a/firefly/objects/format.py +++ b/firefly/objects/format.py @@ -300,6 +300,9 @@ def foreground(self, obj, **kwargs): def font(self, obj, **kwargs): if obj.object_type == "event": return "bold" + elif obj.object_type == "item": + if obj.get("is_primary"): + return "bold" format_helpers_list = [