Example #1
0
    def __init__(self, parent):
        super(SchedulerModule, self).__init__(parent)
        toolbar = scheduler_toolbar(self)
        self.calendar = SchedulerCalendar(self)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(2)
        layout.addWidget(toolbar, 0)
        layout.addWidget(self.calendar, 1)

        self.setLayout(layout)
Example #2
0
    def __init__(self, parent):
        super(RundownModule, self).__init__(parent)
        self.start_time = 0
        self.current_item = False
        self.cued_item = False
        self.last_search = ""
        self.first_load = True

        self.edit_wanted = self.app_state.get("edit_enabled", True)
        self.edit_enabled = False

        self.toolbar = rundown_toolbar(self)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(2)
        layout.addWidget(self.toolbar, 0)

        self.view = RundownView(self)

        self.mcr = self.plugins = False

        if has_right("mcr", anyval=True):
            self.mcr = MCR(self)
            self.plugins = PlayoutPlugins(self)
            if self.app_state.get("show_mcr", False):
                self.mcr.show()
            else:
                self.mcr.hide()

            if self.app_state.get("show_plugins", False):
                self.plugins.show()
            else:
                self.plugins.hide()
            layout.addWidget(self.mcr)
            layout.addWidget(self.plugins)

        layout.addWidget(self.view, 1)
        self.setLayout(layout)
Example #3
0
class BrowserModule(BaseModule):
    def __init__(self, parent):
        super(BrowserModule, self).__init__(parent)
        self.tabs = QTabWidget(self)
        self.tabs.setTabsClosable(True)
        self.tabs.tabCloseRequested.connect(self.close_tab)
        self.tabs.currentChanged.connect(self.on_tab_switch)

        self.layout = QVBoxLayout(self)
        self.layout.setSpacing(0)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.addWidget(self.tabs)

        self.setLayout(self.layout)

        tabscfg = self.app_state.get("browser_tabs", [])
        created_tabs = 0
        current_index = 0
        for tabcfg in tabscfg:
            try:
                if tabcfg["id_view"] not in config["views"]:
                    continue
                if tabcfg.get("active"):
                    current_index = self.tabs.count()
                try:
                    del tabcfg["active"]
                except KeyError:
                    pass
                title = False
                if tabcfg.get("title"):
                    title = tabcfg.get("title")
                try:
                    del tabcfg["title"]
                except KeyError:
                    pass

                self.new_tab(title, **tabcfg)
                created_tabs += 1
            except Exception:
                log_traceback()
                logging.warning("Unable to restore tab")
        if not created_tabs:
            self.new_tab()

        self.tabs.setCurrentIndex(current_index)

    def new_tab(self, title=False, **kwargs):
        if "id_view" not in kwargs:
            try:
                id_view = self.tabs.currentWidget().id_view
            except AttributeError:
                pass
            else:
                kwargs["id_view"] = id_view
        tab = BrowserTab(self, **kwargs)
        self.tabs.addTab(tab, "New tab")
        self.tabs.setCurrentIndex(self.tabs.indexOf(tab))
        tab.title = title
        tab.load()
        return tab

    @property
    def browsers(self):
        r = []
        for i in range(0, self.tabs.count()):
            r.append(self.tabs.widget(i))
        return r

    def close_tab(self, idx=False):
        if self.tabs.count() == 1:
            return
        if not idx:
            idx = self.tabs.currentIndex()
        w = self.tabs.widget(idx)
        w.deleteLater()
        self.tabs.removeTab(idx)
        self.redraw_tabs()

    def prev_tab(self):
        cur = self.tabs.currentIndex()
        if cur == 0:
            n = self.tabs.count() - 1
        else:
            n = cur - 1
        self.tabs.setCurrentIndex(n)

    def next_tab(self):
        cur = self.tabs.currentIndex()
        if cur == self.tabs.count() - 1:
            n = 0
        else:
            n = cur + 1
        self.tabs.setCurrentIndex(n)

    def on_tab_switch(self):
        browser = self.browsers[self.tabs.currentIndex()]
        sel = browser.view.selected_objects
        if sel:
            self.main_window.focus(sel[0])
        browser.search_box.setFocus()
        self.redraw_tabs()

    def load(self):
        for b in self.browsers:
            b.load()

    def redraw_tabs(self, *args, **kwargs):
        QApplication.processEvents()
        views = []
        for i, b in enumerate(self.browsers):
            id_view = b.id_view
            self.tabs.setTabText(i, b.title or config["views"][id_view]["title"])
            sq = copy.copy(b.search_query)
            if self.tabs.currentIndex() == i:
                sq["active"] = True
            if b.title:
                sq["title"] = b.title
            views.append(sq)
        self.app_state["browser_tabs"] = views

    def seismic_handler(self, message):
        for b in self.browsers:
            b.seismic_handler(message)

    def refresh_assets(self, *objects, request_data=False):
        for b in self.browsers:
            b.refresh_assets(*objects, request_data=request_data)