コード例 #1
0
 def __init__(self, parent, **kwargs):
     super(FireflyRadio, self).__init__(parent)
     self.cdata = []
     self.current_index = -1
     self.buttons = []
     self.layout = QHBoxLayout()
     self.layout.setContentsMargins(0, 0, 0, 0)
     self.setLayout(self.layout)
     if kwargs.get("data", []):
         self.set_data(kwargs["data"])
     self.default = self.get_value()
コード例 #2
0
    def __init__(self, parent):
        super(DetailModule, self).__init__(parent)
        self.asset = self._is_loading = self._load_queue = False
        toolbar_layout = QHBoxLayout()

        fdata = []
        for id_folder in sorted(config["folders"].keys()):
            fdata.append({
                "value": id_folder,
                "alias": config["folders"][id_folder]["title"],
                "role": "option",
            })

        self.folder_select = FireflySelect(self, data=fdata)
        for i, fd in enumerate(fdata):
            self.folder_select.setItemIcon(
                i, QIcon(pixlib["folder_" + str(fd["value"])]))
        self.folder_select.currentIndexChanged.connect(self.on_folder_changed)
        self.folder_select.setEnabled(False)
        toolbar_layout.addWidget(self.folder_select, 0)

        self.duration = FireflyTimecode(self)
        toolbar_layout.addWidget(self.duration, 0)

        self.toolbar = detail_toolbar(self)
        toolbar_layout.addWidget(self.toolbar)
        self.detail_tabs = DetailTabs(self)
        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addLayout(toolbar_layout, 1)
        layout.addWidget(self.detail_tabs)
        self.setLayout(layout)
コード例 #3
0
ファイル: browser.py プロジェクト: nebulabroadcast/firefly
    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)
コード例 #4
0
    def __init__(self, parent, data):
        super(PlayoutPlugin, self).__init__(parent)

        self.id_channel = parent.id_channel
        self.id_plugin = data["id"]
        self.title = data["title"]
        self.slots = {}

        self.buttons = []
        button_layout = QHBoxLayout()
        layout = QFormLayout()

        for i, slot in enumerate(data.get("slots", [])):
            slot_type = slot["type"]
            slot_name = slot["name"]

            if slot_type == "action":
                self.buttons.append(QPushButton(slot["title"]))
                self.buttons[-1].clicked.connect(
                    functools.partial(self.execute, slot_name))
                button_layout.addWidget(self.buttons[-1])
                continue

            if slot_type == "text":
                self.slots[slot_name] = FireflyString(self)
            elif slot_type == "select":
                if not slot["values"]:
                    continue
                values = [{
                    "value": val,
                    "alias": ali,
                    "role": "option"
                } for val, ali in slot["values"]]
                self.slots[slot_name] = FireflySelect(self, data=values)
                self.slots[slot_name].set_value(
                    min([r["value"] for r in values]))
            else:
                continue
            layout.addRow(slot["title"], self.slots[slot_name])

        if self.buttons:
            layout.addRow("", button_layout)
        self.setLayout(layout)
コード例 #5
0
ファイル: browser.py プロジェクト: nebulabroadcast/firefly
    def __init__(self, parent):
        layout = QHBoxLayout()
        super(Pager, self).__init__(parent)
        self._parent = parent

        self.btn_prev = PagerButton()
        self.btn_prev.setIcon(QIcon(pixlib["previous"]))
        self.btn_prev.clicked.connect(self.on_prev)
        layout.addWidget(self.btn_prev, 0)

        self.info = QLabel("Page 1")
        self.info.setAlignment(Qt.AlignCenter)
        layout.addWidget(self.info, 1)

        self.btn_next = PagerButton()
        self.btn_next.setIcon(QIcon(pixlib["next"]))
        self.btn_next.clicked.connect(self.on_next)
        layout.addWidget(self.btn_next, 0)

        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)
コード例 #6
0
    def __init__(self, parent):
        super(MCR, self).__init__(parent)

        self.progress_bar = QProgressBar(self)
        self.progress_bar.setTextVisible(False)
        self.progress_bar.setValue(0)
        self.progress_bar.setMaximum(PROGRESS_BAR_RESOLUTION)

        self.btn_take = MCRButton("Take", self, self.on_take)
        self.btn_freeze = MCRButton("Freeze", self, self.on_freeze)
        self.btn_retake = MCRButton("Retake", self, self.on_retake)
        self.btn_abort = MCRButton("Abort", self, self.on_abort)
        self.btn_loop = MCRButton("Loop", self, self.on_loop, checkable=True)
        self.btn_cue_backward = MCRButton("<", self, self.on_cue_backward)
        self.btn_cue_forward = MCRButton(">", self, self.on_cue_forward)

        self.btn_cue_backward.setShortcut("Ctrl+J")
        self.btn_take.setShortcut("Ctrl+K")
        self.btn_cue_forward.setShortcut("Ctrl+L")
        self.btn_retake.setShortcut("Alt+J")
        self.btn_freeze.setShortcut("Alt+K")
        self.btn_abort.setShortcut("Alt+L")

        btns_layout = QHBoxLayout()

        btns_layout.addStretch(1)
        btns_layout.addWidget(self.btn_take, 0)
        btns_layout.addWidget(self.btn_freeze, 0)
        btns_layout.addWidget(self.btn_retake, 0)
        btns_layout.addWidget(self.btn_abort, 0)
        btns_layout.addWidget(self.btn_loop, 0)
        btns_layout.addWidget(self.btn_cue_backward, 0)
        btns_layout.addWidget(self.btn_cue_forward, 0)
        btns_layout.addStretch(1)

        self.display_clock = MCRLabel("CLK", "--:--:--:--")
        self.display_pos = MCRLabel("POS", "--:--:--:--")

        self.display_current = MCRLabel("CUR", "(no clip)", tcolor="#cc0000")
        self.display_cued = MCRLabel("NXT", "(no clip)", tcolor="#00cc00")

        self.display_rem = MCRLabel("REM", "(unknown)")
        self.display_dur = MCRLabel("DUR", "--:--:--:--")

        info_layout = QGridLayout()
        info_layout.setContentsMargins(0, 0, 0, 0)
        info_layout.setSpacing(2)

        info_layout.addWidget(self.display_clock, 0, 0)
        info_layout.addWidget(self.display_pos, 1, 0)

        info_layout.addWidget(self.display_current, 0, 1)
        info_layout.addWidget(self.display_cued, 1, 1)

        info_layout.addWidget(self.display_rem, 0, 2)
        info_layout.addWidget(self.display_dur, 1, 2)

        info_layout.setColumnStretch(1, 1)

        layout = QVBoxLayout()
        layout.addLayout(info_layout, 0)
        layout.addWidget(self.progress_bar, 0)
        layout.addLayout(btns_layout, 0)
        self.setLayout(layout)

        self.on_channel_changed()

        self.display_timer = QTimer(self)
        self.display_timer.timeout.connect(self.update_display)
コード例 #7
0
    def __init__(self, parent):
        super(SchedulerCalendar, self).__init__(parent)
        self.week_start_time = self.week_end_time = 0
        self.events = []
        self.focus_data = []
        self.dragging = False
        self.drag_offset = 0
        self.drag_source = False
        self.append_condition = False
        self.selected_event = False

        header_layout = QHBoxLayout()
        header_layout.addSpacing(CLOCKBAR_WIDTH + 15)

        cols_layout = QHBoxLayout()
        self.clock_bar = SchedulerClockBar(self)
        cols_layout.addWidget(self.clock_bar, 0)

        self.headers = []
        self.days = []
        for i in range(7):
            self.headers.append(SchedulerDayHeaderWidget(self, i))
            self.days.append(SchedulerDayWidget(self))
            header_layout.addWidget(self.headers[-1])
            cols_layout.addWidget(self.days[-1], 1)

        header_layout.addSpacing(20)

        self.scroll_widget = QWidget()
        self.scroll_widget.setLayout(cols_layout)
        self.scroll_widget.setSizePolicy(QSizePolicy.Preferred,
                                         QSizePolicy.Preferred)

        self.scroll_area = QScrollArea(self)
        self.scroll_area.setFrameStyle(QFrame.NoFrame)
        self.scroll_area.setWidgetResizable(True)
        self.scroll_area.setWidget(self.scroll_widget)
        self.scroll_area.setContentsMargins(0, 0, 0, 0)
        self.scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)

        zoomlevel = self.parent().app_state.get("scheduler_zoom", 0)
        self.zoom = QSlider(Qt.Horizontal)
        self.zoom.setMinimum(0)
        self.zoom.setMaximum(10000)
        self.zoom.valueChanged.connect(self.on_zoom)
        logging.debug("Setting scheduler zoom level to", zoomlevel)
        self.zoom.setValue(zoomlevel)

        layout = QVBoxLayout()
        layout.addLayout(header_layout)
        layout.addWidget(self.scroll_area, 1)
        layout.addWidget(self.zoom, 0)
        self.setLayout(layout)
        self.setMinimumHeight(450)
コード例 #8
0
class FireflyRadio(QWidget):
    def __init__(self, parent, **kwargs):
        super(FireflyRadio, self).__init__(parent)
        self.cdata = []
        self.current_index = -1
        self.buttons = []
        self.layout = QHBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(self.layout)
        if kwargs.get("data", []):
            self.set_data(kwargs["data"])
        self.default = self.get_value()

    def clear(self):
        for i, button in enumerate(self.buttons):
            button.deleteLater()
            self.layout.removeWidget(button)
        self.current_index = -1
        self.buttons = []

    def auto_data(self, key, id_folder=0):
        data = format_select(key, None, result="full", id_folder=id_folder)
        self.set_data(data)

    def set_data(self, data):
        self.clear()
        self.current_index = -1
        i = 0
        for row in data:
            alias = row.get("alias", row["value"])
            description = row.get("description") or alias or "(No value)"
            if not row.get("value"):
                continue
            if row["role"] == "hidden":
                continue
            self.cdata.append(row["value"])

            self.buttons.append(QPushButton(alias))
            self.buttons[-1].setToolTip(f"<p>{description}</p>")
            self.buttons[-1].setCheckable(row["role"] in ["option", "header"])
            self.buttons[-1].setAutoExclusive(True)
            self.buttons[-1].clicked.connect(functools.partial(self.switch, i))
            self.layout.addWidget(self.buttons[-1])
            i += 1

    def switch(self, index):
        self.current_index = index

    def set_value(self, value):
        value = str(value)

        if not value and self.cdata and self.cdata[0] == "0":
            value = "0"

        for i, val in enumerate(self.cdata):
            if val == value:
                self.buttons[i].setChecked(True)
                self.current_index = i
                break
        else:
            self.current_index = -1
            for button in self.buttons:
                button.setAutoExclusive(False)
                button.setChecked(False)
                button.setAutoExclusive(True)
        self.default = self.get_value()

    def get_value(self):
        if self.current_index == -1:
            return ""
        return str(self.cdata[self.current_index])

    def setReadOnly(self, val):
        for w in self.buttons:
            w.setEnabled(not val)