def detail_toolbar(wnd): toolbar = QToolBar(wnd) wnd.action_approve = QAction(QIcon(pixlib["qc_approved"]), "Approve", wnd) wnd.action_approve.setShortcut("Y") wnd.action_approve.triggered.connect(functools.partial(wnd.on_set_qc, 4)) wnd.action_approve.setEnabled(False) toolbar.addAction(wnd.action_approve) wnd.action_qc_reset = QAction(QIcon(pixlib["qc_new"]), "QC Reset", wnd) wnd.action_qc_reset.setShortcut("T") wnd.action_qc_reset.triggered.connect(functools.partial(wnd.on_set_qc, 0)) wnd.action_qc_reset.setEnabled(False) toolbar.addAction(wnd.action_qc_reset) wnd.action_reject = QAction(QIcon(pixlib["qc_rejected"]), "Reject", wnd) wnd.action_reject.setShortcut("U") wnd.action_reject.triggered.connect(functools.partial(wnd.on_set_qc, 3)) wnd.action_reject.setEnabled(False) toolbar.addAction(wnd.action_reject) toolbar.addWidget(ToolBarStretcher(wnd)) wnd.action_revert = QAction(QIcon(pixlib["cancel"]), "&Revert changes", wnd) wnd.action_revert.setStatusTip("Revert changes") wnd.action_revert.triggered.connect(wnd.on_revert) toolbar.addAction(wnd.action_revert) wnd.action_apply = QAction(QIcon(pixlib["accept"]), "&Apply changes", wnd) wnd.action_apply.setShortcut("Ctrl+S") wnd.action_apply.setStatusTip("Apply changes") wnd.action_apply.triggered.connect(wnd.on_apply) toolbar.addAction(wnd.action_apply) return toolbar
def __init__(self, parent, **kwargs): super(BrowserTab, self).__init__(parent) self._parent = parent self.loading = False self.title = False # Search query self.search_query = { "id_view": kwargs.get("id_view", min(config["views"])), "fulltext": kwargs.get("fulltext", ""), "order": kwargs.get("order", "ctime desc"), "conds": kwargs.get("conds", []), } # Layout self.search_box = SearchWidget(self) if self.search_query.get("fulltext"): self.search_box.setText(self.search_query["fulltext"]) self.first_load = True self.view = FireflyBrowserView(self) self.view.horizontalHeader().sectionResized.connect(self.on_section_resize) self.view.horizontalHeader().sortIndicatorChanged.connect( self.on_section_resize ) action_clear = QAction(QIcon(pixlib["cancel"]), "&Clear search query", parent) action_clear.triggered.connect(self.on_clear) self.action_search = QMenu("Views") self.action_search.setStyleSheet(app_skin) self.action_search.menuAction().setIcon(QIcon(pixlib["search"])) self.action_search.menuAction().triggered.connect(self.load) self.load_view_menu() action_copy = QAction("Copy result", self) action_copy.setShortcut("CTRL+SHIFT+C") action_copy.triggered.connect(self.on_copy_result) self.addAction(action_copy) toolbar = QToolBar(self) toolbar.addAction(action_clear) toolbar.addAction(self.action_search.menuAction()) search_layout = QHBoxLayout() search_layout.setContentsMargins(0, 0, 0, 0) search_layout.addWidget(self.search_box) search_layout.addWidget(toolbar) self.pager = Pager(self) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addLayout(search_layout, 0) layout.addWidget(self.view, 1) layout.addWidget(self.pager, 0) self.setLayout(layout)
def key_menu(self, key, position): menu = QMenu() section = QAction("Search in...") section.setEnabled(False) menu.addAction(section) for id_view in sorted(config["views"].keys(), key=lambda k: config["views"][k]["position"]): view = config["views"][id_view] if view.get("separator", False): menu.addSeparator() action = QAction(view["title"], self) action.triggered.connect( functools.partial(self._parent.search_by_key, key, id_view)) menu.addAction(action) menu.exec_(self.labels[key].mapToGlobal(position))
def contextMenuEvent(self, event): menu = QMenu(self.parent()) menu.setStyleSheet(app_skin) action_open_rundown = QAction("Open rundown", self) action_open_rundown.triggered.connect(self.on_open_rundown) menu.addAction(action_open_rundown) action_import_template = QAction("Import template", self) action_import_template.triggered.connect( functools.partial(self.parent().parent().import_template, self.dow)) menu.addAction(action_import_template) menu.exec_(event.globalPos())
def contextMenuEvent(self, event): if not self.cursor_event: return menu = QMenu(self.parent()) menu.setStyleSheet(app_skin) self.calendar.selected_event = self.cursor_event action_open_rundown = QAction("Open rundown", self) action_open_rundown.triggered.connect(self.on_open_rundown) menu.addAction(action_open_rundown) action_edit_event = QAction("Event details", self) action_edit_event.triggered.connect(self.on_edit_event) menu.addAction(action_edit_event) if has_right("scheduler_edit", self.calendar.id_channel): menu.addSeparator() action_delete_event = QAction("Delete event", self) action_delete_event.triggered.connect(self.on_delete_event) menu.addAction(action_delete_event) menu.exec_(event.globalPos())
def load_view_menu(self): i = 1 for id_view in sorted( config["views"].keys(), key=lambda k: config["views"][k]["position"] ): view = config["views"][id_view] if view.get("separator", False): self.action_search.addSeparator() action = QAction(view["title"], self) action.setCheckable(True) if i < 10: action.setShortcut(f"ALT+{i}") action.id_view = id_view action.triggered.connect(functools.partial(self.set_view, id_view)) self.action_search.addAction(action) i += 1
def contextMenuEvent(self, event): obj_set = list(set([itm.object_type for itm in self.selected_objects])) menu = QMenu(self) if len(obj_set) == 1: if len(self.selected_objects) == 1: if self.selected_objects[0]["item_role"] == "placeholder": solvers = self.playout_config.get("solvers", []) if solvers: solver_menu = menu.addMenu("Solve using...") for solver in solvers: action_solve = QAction(solver.capitalize(), self) action_solve.setStatusTip( "Solve this placeholder using {}".format( solver)) action_solve.triggered.connect( functools.partial(self.on_solve, solver)) solver_menu.addAction(action_solve) if obj_set[0] == "item" and self.selected_objects[0][ "id_asset"]: action_trim = QAction("Trim", self) action_trim.setStatusTip("Trim selected item") action_trim.triggered.connect(self.on_trim) menu.addAction(action_trim) if obj_set[0] == "item" and ( self.selected_objects[0]["id_asset"] or self.selected_objects[0]["item_role"] == "live"): mode_menu = menu.addMenu("Run mode") action_mode_auto = QAction("&Auto", self) action_mode_auto.setStatusTip("Set run mode to auto") action_mode_auto.setCheckable(True) action_mode_auto.setChecked( self.selected_objects[0]["run_mode"] == RunMode.RUN_AUTO) action_mode_auto.triggered.connect( functools.partial(self.on_set_mode, RunMode.RUN_AUTO)) mode_menu.addAction(action_mode_auto) action_mode_manual = QAction("&Manual", self) action_mode_manual.setStatusTip("Set run mode to manual") action_mode_manual.setCheckable(True) action_mode_manual.setChecked( self.selected_objects[0]["run_mode"] == RunMode.RUN_MANUAL) action_mode_manual.triggered.connect( functools.partial(self.on_set_mode, RunMode.RUN_MANUAL)) mode_menu.addAction(action_mode_manual) action_mode_skip = QAction("&Skip", self) action_mode_skip.setStatusTip("Set run mode to skip") action_mode_skip.setCheckable(True) action_mode_skip.setChecked( self.selected_objects[0]["run_mode"] == RunMode.RUN_SKIP) action_mode_skip.triggered.connect( functools.partial(self.on_set_mode, RunMode.RUN_SKIP)) mode_menu.addAction(action_mode_skip) if self.selected_objects[0]["id_asset"]: mode_menu.addSeparator() action_mode_loop = QAction("&Loop", self) action_mode_loop.setStatusTip("Loop item") action_mode_loop.setCheckable(True) action_mode_loop.setChecked( bool(self.selected_objects[0]["loop"])) action_mode_loop.triggered.connect(self.on_set_loop) mode_menu.addAction(action_mode_loop) elif obj_set[0] == "event" and len(self.selected_objects) == 1: mode_menu = menu.addMenu("Run mode") action_mode_auto = QAction("&Auto", self) action_mode_auto.setStatusTip("Set run mode to auto") action_mode_auto.setCheckable(True) action_mode_auto.setChecked( self.selected_objects[0]["run_mode"] == RunMode.RUN_AUTO) action_mode_auto.triggered.connect( functools.partial(self.on_set_mode, RunMode.RUN_AUTO)) mode_menu.addAction(action_mode_auto) action_mode_manual = QAction("&Manual", self) action_mode_manual.setStatusTip("Set run mode to manual") action_mode_manual.setCheckable(True) action_mode_manual.setChecked( self.selected_objects[0]["run_mode"] == RunMode.RUN_MANUAL) action_mode_manual.triggered.connect( functools.partial(self.on_set_mode, RunMode.RUN_MANUAL)) mode_menu.addAction(action_mode_manual) action_mode_soft = QAction("&Soft", self) action_mode_soft.setStatusTip("Set run mode to soft") action_mode_soft.setCheckable(True) action_mode_soft.setChecked( self.selected_objects[0]["run_mode"] == RunMode.RUN_SOFT) action_mode_soft.triggered.connect( functools.partial(self.on_set_mode, RunMode.RUN_SOFT)) mode_menu.addAction(action_mode_soft) action_mode_hard = QAction("&Hard", self) action_mode_hard.setStatusTip("Set run mode to hard") action_mode_hard.setCheckable(True) action_mode_hard.setChecked( self.selected_objects[0]["run_mode"] == RunMode.RUN_HARD) action_mode_hard.triggered.connect( functools.partial(self.on_set_mode, RunMode.RUN_HARD)) mode_menu.addAction(action_mode_hard) if "item" in obj_set: if len(self.selected_objects ) == 1 and self.selected_objects[0]["item_role"] in [ "placeholder", "lead_in", "lead_out", "live" ]: pass else: action_send_to = QAction("&Send to...", self) action_send_to.setStatusTip( "Create action for selected asset(s)") action_send_to.triggered.connect(self.on_send_to) menu.addAction(action_send_to) if "event" in obj_set: pass if len(obj_set) > 0: menu.addSeparator() action_delete = QAction("&Delete", self) action_delete.setStatusTip("Delete selected object") action_delete.triggered.connect(self.on_delete) menu.addAction(action_delete) if len(self.selected_objects) == 1: if "event" in obj_set: action_edit = QAction("Edit", self) action_edit.triggered.connect(self.on_edit_event) menu.addAction(action_edit) elif self.selected_objects[0]["item_role"] in [ "placeholder", "live" ]: action_edit = QAction("Edit", self) action_edit.triggered.connect(self.on_edit_item) menu.addAction(action_edit) menu.exec_(event.globalPos())
def create_menu(wnd): menubar = wnd.menuBar() menu_file = menubar.addMenu("&File") action_new_asset = QAction("&New asset", wnd) action_new_asset.setShortcut("Ctrl+N") action_new_asset.setStatusTip("Create new asset from template") action_new_asset.triggered.connect(wnd.new_asset) action_new_asset.setEnabled( has_right("asset_create") and config.get("ui_asset_create", True) ) menu_file.addAction(action_new_asset) action_clone_asset = QAction("&Clone asset", wnd) action_clone_asset.setShortcut("Ctrl+Shift+N") action_clone_asset.setStatusTip("Clone current asset") action_clone_asset.triggered.connect(wnd.clone_asset) action_clone_asset.setEnabled( has_right("asset_create") and config.get("ui_asset_create", True) ) menu_file.addAction(action_clone_asset) menu_file.addSeparator() action_refresh = QAction("&Refresh", wnd) action_refresh.setShortcut("F5") action_refresh.setStatusTip("Refresh views") action_refresh.triggered.connect(wnd.refresh) menu_file.addAction(action_refresh) action_load_settings = QAction("&Reload settings", wnd) action_load_settings.setShortcut("Shift+F5") action_load_settings.setStatusTip("Reload system settings") action_load_settings.triggered.connect(wnd.load_settings) menu_file.addAction(action_load_settings) menu_file.addSeparator() action_logout = QAction("L&ogout", wnd) action_logout.setStatusTip("Log out user") action_logout.triggered.connect(wnd.logout) menu_file.addAction(action_logout) action_exit = QAction("E&xit", wnd) action_exit.setShortcut("Alt+F4") action_exit.setStatusTip("Quit Firefly") action_exit.triggered.connect(wnd.exit) menu_file.addAction(action_exit) # # Browser # menu_browser = menubar.addMenu("Browser") action_detail = QAction("Asset &detail", wnd) action_detail.setShortcut("F2") action_detail.setStatusTip("Focus asset search bar") action_detail.triggered.connect(wnd.show_detail) menu_browser.addAction(action_detail) action_search = QAction("&Search assets", wnd) action_search.setShortcut("ESC") action_search.setStatusTip("Focus asset search bar") action_search.triggered.connect(wnd.search_assets) menu_browser.addAction(action_search) menu_browser.addSeparator() action_new_tab = QAction("&New tab", wnd) action_new_tab.setShortcut("CTRL+T") action_new_tab.setStatusTip("Open new browser tab") action_new_tab.triggered.connect(wnd.new_tab) menu_browser.addAction(action_new_tab) action_close_tab = QAction("&Close tab", wnd) action_close_tab.setShortcut("CTRL+W") action_close_tab.setStatusTip("Close current browser tab") action_close_tab.triggered.connect(wnd.close_tab) menu_browser.addAction(action_close_tab) action_prev_tab = QAction("&Previous tab", wnd) action_prev_tab.setShortcut("CTRL+PgUp") action_prev_tab.triggered.connect(wnd.prev_tab) menu_browser.addAction(action_prev_tab) action_next_tab = QAction("&Next tab", wnd) action_next_tab.setShortcut("CTRL+PgDown") action_next_tab.triggered.connect(wnd.next_tab) menu_browser.addAction(action_next_tab) # # Scheduling # if config["playout_channels"]: wnd.menu_scheduler = menubar.addMenu("&Scheduler") ag = QActionGroup(wnd) ag.setExclusive(True) for id_channel in sorted(config["playout_channels"]): a = ag.addAction( QAction( config["playout_channels"][id_channel]["title"], wnd, checkable=True ) ) a.id_channel = id_channel a.triggered.connect(partial(wnd.set_channel, id_channel)) if ( has_right("rundown_view", a.id_channel) or has_right("rundown_edit", a.id_channel) or has_right("scheduler_view", a.id_channel) or has_right("scheduler_edit", a.id_channel) ): a.setEnabled(True) else: a.setEnabled(False) wnd.menu_scheduler.addAction(a) wnd.menu_scheduler.addSeparator() action_import_template = QAction("Import", wnd) action_import_template.setStatusTip("Import week template") action_import_template.triggered.connect(wnd.import_template) wnd.menu_scheduler.addAction(action_import_template) action_export_template = QAction("Export", wnd) action_export_template.setStatusTip("Export current week as template") action_export_template.triggered.connect(wnd.export_template) wnd.menu_scheduler.addAction(action_export_template) # # Rundown # menu_rundown = menubar.addMenu("&Rundown") action_now = QAction("Now", wnd) action_now.setShortcut("F1") action_now.setStatusTip("Open current position in rundown") action_now.setEnabled(has_right("rundown_view")) action_now.triggered.connect(wnd.now) menu_rundown.addAction(action_now) wnd.action_rundown_edit = QAction("Rundown edit mode", wnd) wnd.action_rundown_edit.setShortcut("Ctrl+R") wnd.action_rundown_edit.setStatusTip("Toggle rundown edit mode") wnd.action_rundown_edit.setCheckable(True) wnd.action_rundown_edit.setEnabled(has_right("rundown_edit")) wnd.action_rundown_edit.triggered.connect(wnd.toggle_rundown_edit) menu_rundown.addAction(wnd.action_rundown_edit) menu_rundown.addSeparator() action_refresh_plugins = QAction("Refresh plugins", wnd) action_refresh_plugins.setStatusTip("Refresh rundown plugins") action_refresh_plugins.triggered.connect(wnd.refresh_plugins) menu_rundown.addAction(action_refresh_plugins) # # HELP # menu_help = menubar.addMenu("Help") wnd.action_debug = QAction("Debug mode", wnd) wnd.action_debug.setStatusTip("Toggle debug mode") wnd.action_debug.setCheckable(True) wnd.action_debug.setChecked(config.get("debug", False)) wnd.action_debug.triggered.connect(wnd.toggle_debug_mode) menu_help.addAction(wnd.action_debug) menu_help.addSeparator() action_about = QAction("&About", wnd) action_about.setStatusTip("About Firefly") action_about.triggered.connect(partial(show_about_dialog, wnd)) menu_help.addAction(action_about)
def preview_toolbar(wnd): toolbar = QToolBar(wnd) action_poster = QMenu("Set poster", wnd) action_poster.menuAction().setIcon(QIcon(pixlib["set-poster"])) action_poster.menuAction().triggered.connect(wnd.set_poster) action_poster.menuAction().setStatusTip("Set poster frame") action_poster_set = QAction("Set poster", wnd) action_poster_set.triggered.connect(wnd.set_poster) action_poster.addAction(action_poster_set) action_poster_goto = QAction("Go to poster", wnd) action_poster_goto.triggered.connect(wnd.go_to_poster) action_poster.addAction(action_poster_goto) toolbar.addAction(action_poster.menuAction()) action_save_marks = QAction(QIcon(pixlib["save-marks"]), "Save marks", wnd) action_save_marks.setStatusTip("Save marks") action_save_marks.triggered.connect(wnd.save_marks) toolbar.addAction(action_save_marks) # TODO # action_restore_marks = QAction(QIcon(pix_lib["restore-marks"]), 'Restore', wnd) # action_restore_marks.setStatusTip('Restore marks') # action_restore_marks.triggered.connect(wnd.restore_marks) # toolbar.addAction(action_restore_marks) action_create_subclip = QAction( QIcon(pixlib["create-subclip"]), "Create subclip", wnd ) action_create_subclip.setStatusTip("Create subclip") action_create_subclip.triggered.connect(wnd.create_subclip) toolbar.addAction(action_create_subclip) action_manage_subclips = QAction( QIcon(pixlib["manage-subclips"]), "Manage subclips", wnd ) action_manage_subclips.setStatusTip("Manage subclips") action_manage_subclips.triggered.connect(wnd.manage_subclips) toolbar.addAction(action_manage_subclips) return toolbar
def scheduler_toolbar(wnd): toolbar = QToolBar(wnd) action_week_prev = QAction(QIcon(pixlib["previous"]), "&Previous week", wnd) action_week_prev.setShortcut("Alt+Left") action_week_prev.setStatusTip("Go to previous week") action_week_prev.triggered.connect(wnd.on_week_prev) toolbar.addAction(action_week_prev) action_refresh = QAction(QIcon(pixlib["refresh"]), "&Refresh", wnd) action_refresh.setStatusTip("Refresh scheduler") action_refresh.triggered.connect(wnd.load) toolbar.addAction(action_refresh) action_week_next = QAction(QIcon(pixlib["next"]), "&Next week", wnd) action_week_next.setShortcut("Alt+Right") action_week_next.setStatusTip("Go to next week") action_week_next.triggered.connect(wnd.on_week_next) toolbar.addAction(action_week_next) # TODO # toolbar.addSeparator() # # wnd.action_show_runs = QAction(QIcon(pixlib["show-runs"]), '&Show runs', wnd) # wnd.action_show_runs.setStatusTip('Show runs') # wnd.action_show_runs.setCheckable(True) # toolbar.addAction(wnd.action_show_runs) toolbar.addSeparator() toolbar.addWidget(EmptyEventButton(wnd)) toolbar.addWidget(ToolBarStretcher(wnd)) wnd.channel_display = ChannelDisplay() toolbar.addWidget(wnd.channel_display) return toolbar
def rundown_toolbar(wnd): action_find = QAction("Search rundown", wnd) action_find.setShortcut("Ctrl+F") action_find.triggered.connect(wnd.find) wnd.addAction(action_find) action_find_next = QAction("Search rundown", wnd) action_find_next.setShortcut("F3") action_find_next.triggered.connect(wnd.find_next) wnd.addAction(action_find_next) toolbar = QToolBar(wnd) action_day_prev = QAction(QIcon(pixlib["previous"]), "&Previous day", wnd) action_day_prev.setShortcut("Alt+Left") action_day_prev.setStatusTip("Go to previous day") action_day_prev.triggered.connect(wnd.go_day_prev) toolbar.addAction(action_day_prev) action_now = QAction(QIcon(pixlib["now"]), "&Now", wnd) action_now.setStatusTip("Go to now") action_now.triggered.connect(wnd.go_now) toolbar.addAction(action_now) action_calendar = QAction(QIcon(pixlib["calendar"]), "&Calendar", wnd) action_calendar.setShortcut("Ctrl+D") action_calendar.setStatusTip("Open calendar") action_calendar.triggered.connect(wnd.show_calendar) toolbar.addAction(action_calendar) action_refresh = QAction(QIcon(pixlib["refresh"]), "&Refresh", wnd) action_refresh.setStatusTip("Refresh rundown") action_refresh.triggered.connect(wnd.load) toolbar.addAction(action_refresh) action_day_next = QAction(QIcon(pixlib["next"]), "&Next day", wnd) action_day_next.setShortcut("Alt+Right") action_day_next.setStatusTip("Go to next day") action_day_next.triggered.connect(wnd.go_day_next) toolbar.addAction(action_day_next) if has_right("rundown_edit", anyval=True): toolbar.addSeparator() for btn_config in ITEM_BUTTONS: toolbar.addWidget(ItemButton(wnd, btn_config)) toolbar.addSeparator() action_toggle_mcr = QAction(QIcon(pixlib["mcr"]), "&Playout controls", wnd) action_toggle_mcr.setStatusTip("Toggle playout controls") action_toggle_mcr.triggered.connect(wnd.toggle_mcr) toolbar.addAction(action_toggle_mcr) action_toggle_plugins = QAction(QIcon(pixlib["plugins"]), "&Plugins controls", wnd) action_toggle_plugins.setShortcut("F4") action_toggle_plugins.setStatusTip("Toggle plugins controls") action_toggle_plugins.triggered.connect(wnd.toggle_plugins) toolbar.addAction(action_toggle_plugins) toolbar.addWidget(ToolBarStretcher(wnd)) wnd.channel_display = ChannelDisplay() toolbar.addWidget(wnd.channel_display) return toolbar
def contextMenuEvent(self, event): if not self.view.selected_objects: return menu = QMenu(self) objs = self.view.selected_objects states = set([obj["status"] for obj in objs]) if states == set([ObjectStatus.TRASHED]): action_untrash = QAction("Untrash", self) action_untrash.setStatusTip("Take selected asset(s) from trash") action_untrash.triggered.connect(self.on_untrash) menu.addAction(action_untrash) if states == set([ObjectStatus.ARCHIVED]): action_unarchive = QAction("Unarchive", self) action_unarchive.setStatusTip("Take selected asset(s) from archive") action_unarchive.triggered.connect(self.on_unarchive) menu.addAction(action_unarchive) elif states.issubset( [ObjectStatus.ONLINE, ObjectStatus.CREATING, ObjectStatus.OFFLINE] ): action_move_to_trash = QAction("Move to trash", self) action_move_to_trash.setStatusTip("Move selected asset(s) to trash") action_move_to_trash.triggered.connect(self.on_trash) menu.addAction(action_move_to_trash) action_move_to_archive = QAction("Move to archive", self) action_move_to_archive.setStatusTip("Move selected asset(s) to archive") action_move_to_archive.triggered.connect(self.on_archive) menu.addAction(action_move_to_archive) action_reset = QAction("Reset", self) action_reset.setStatusTip("Reload asset metadata") action_reset.triggered.connect(self.on_reset) menu.addAction(action_reset) action_batch_ops = QAction("&Batch ops...", self) action_batch_ops.setStatusTip("Batch operations") action_batch_ops.triggered.connect(self.on_batch_ops) menu.addAction(action_batch_ops) if len(objs) == 1: menu.addSeparator() for link in config["folders"][objs[0]["id_folder"]].get("links", []): action_link = QAction(link["title"]) action_link.triggered.connect( functools.partial(self.link_exec, objs[0], **link) ) menu.addAction(action_link) menu.addSeparator() action_send_to = QAction("&Send to...", self) action_send_to.setStatusTip("Create action for selected asset(s)") action_send_to.triggered.connect(self.on_send_to) menu.addAction(action_send_to) menu.exec_(event.globalPos())