def _update_duration(self, duration): if duration > 0 or self.show_zero_duration: # Display as disabled if duration < 0 self.setEnabled(duration > 0) self.setTextVisible(True) self.setFormat(strtime(duration, accurate=self.accurate_time)) # Avoid settings min and max to 0, or the the bar go in busy state self.setRange(0 if duration > 0 else -1, duration) else: self.setTextVisible(False)
def _time_updated(self, time): if not self.visibleRegion().isEmpty(): # If the given value is the duration or < 0 set the time to 0 if time == self.cue.media.duration or time < 0: time = 0 # Set the value the seek slider self.seekSlider.setValue(time) # Show the time in the widget self.timeDisplay.display( strtime(self.cue.media.duration - time, accurate=self._accurate_time))
def _update_time(self, time, ignore_visibility=False): if ignore_visibility or not self.visibleRegion().isEmpty(): # If the given value is the duration or < 0 set the time to 0 if time == self.cue.duration or time < 0: time = 0 # Set the value the seek slider self.seekSlider.setValue(time) # If in count-down mode the widget will show the remaining time if self._countdown_mode: time = self.cue.duration - time # Set the value of the timer progress-bar if self.cue.duration > 0: self.timeBar.setValue(time) # Show the time in the widget self.timeDisplay.display( strtime(time, accurate=self._accurate_timing))
def _update_time(self, time): self.setValue(time) self.setFormat(strtime(time, accurate=self.accurate_time))
def __init__(self, cue, **kwargs): super().__init__(**kwargs) self.setGeometry(0, 0, self.parent().viewport().width(), 80) self.setFocusPolicy(Qt.NoFocus) self.setLayout(QHBoxLayout(self)) self.layout().setContentsMargins(0, 0, 0, 1) self._accurate_time = False self.cue = cue self.cue_time = CueTime(cue) self.cue_time.notify.connect(self._time_updated, Connection.QtQueued) # Use this to avoid transparent background self.gridLayoutWidget = QWidget(self) self.gridLayout = QGridLayout(self.gridLayoutWidget) self.gridLayout.setContentsMargins(3, 3, 3, 3) self.gridLayout.setSpacing(2) self.layout().addWidget(self.gridLayoutWidget) self.nameLabel = QLabel(self.gridLayoutWidget) self.nameLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) self.nameLabel.setText(cue.name) self.nameLabel.setToolTip(cue.name) self.gridLayout.addWidget(self.nameLabel, 0, 0, 1, 2) self.controlButtons = CueControlButtons(parent=self.gridLayoutWidget) self.gridLayout.addWidget(self.controlButtons, 1, 0) if CueAction.Stop in cue.CueActions: self.controlButtons.stopButton.clicked.connect(self._stop) else: self.controlButtons.stopButton.setEnabled(False) if CueAction.Pause in cue.CueActions: self.controlButtons.pauseButton.clicked.connect(self._pause) self.controlButtons.startButton.clicked.connect(self._resume) else: self.controlButtons.pauseButton.setEnabled(False) self.controlButtons.startButton.setEnabled(False) if CueAction.FadeIn in cue.CueActions: self.controlButtons.fadeInButton.clicked.connect(self._fadein) else: self.controlButtons.fadeInButton.setEnabled(False) if CueAction.FadeOut in cue.CueActions: self.controlButtons.fadeOutButton.clicked.connect(self._fadeout) else: self.controlButtons.fadeOutButton.setEnabled(False) if CueAction.Interrupt in cue.CueActions: self.controlButtons.interruptButton.clicked.connect( self._interrupt) else: self.controlButtons.interruptButton.setEnabled(False) self.timeDisplay = QLCDNumber(self.gridLayoutWidget) self.timeDisplay.setStyleSheet('background-color: transparent') self.timeDisplay.setSegmentStyle(QLCDNumber.Flat) self.timeDisplay.setDigitCount(8) self.timeDisplay.display(strtime(cue.duration)) self.gridLayout.addWidget(self.timeDisplay, 1, 1) self.gridLayout.setRowStretch(0, 1) self.gridLayout.setRowStretch(1, 3) self.gridLayout.setColumnStretch(0, 7) self.gridLayout.setColumnStretch(1, 5) cue.changed('name').connect(self.name_changed, Connection.QtQueued) cue.started.connect(self.controlButtons.pauseMode, Connection.QtQueued) cue.paused.connect(self.controlButtons.startMode, Connection.QtQueued) # Fade enter/exit cue.fadein_start.connect(self.enter_fadein, Connection.QtQueued) cue.fadein_end.connect(self.exit_fade, Connection.QtQueued) cue.fadeout_start.connect(self.enter_fadeout, Connection.QtQueued) cue.fadeout_end.connect(self.exit_fade, Connection.QtQueued)
def _update_timers(self, time): self.timeDisplay.display( strtime(self.cue.duration - time, accurate=self._accurate_time))
def __init__(self, cue, **kwargs): super().__init__(**kwargs) self.setFocusPolicy(Qt.NoFocus) self.setGeometry(0, 0, self.parent().viewport().width(), 110) self.cue = cue self.cue_time = CueTime(cue) self.cue_time.notify.connect(self._time_updated, Connection.QtQueued) self._dbmeter_element = None self._accurate_time = False self.gridLayoutWidget = QWidget(self) self.gridLayoutWidget.setGeometry(self.geometry()) self.gridLayout = QGridLayout(self.gridLayoutWidget) self.gridLayout.setContentsMargins(3, 3, 3, 3) self.gridLayout.setSpacing(2) self.nameLabel = QLabel(self.gridLayoutWidget) self.nameLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) self.nameLabel.setText(cue.name) self.nameLabel.setToolTip(cue.name) self.gridLayout.addWidget(self.nameLabel, 0, 0, 1, 2) self.controlButtons = CueControlButtons(parent=self.gridLayoutWidget) self.controlButtons.stopButton.clicked.connect(self._stop) self.controlButtons.pauseButton.clicked.connect(self._pause) self.controlButtons.startButton.clicked.connect(self._start) self.controlButtons.fadeInButton.clicked.connect(self._fadein) self.controlButtons.fadeOutButton.clicked.connect(self._fadeout) self.controlButtons.interruptButton.clicked.connect(self._interrupt) self.gridLayout.addWidget(self.controlButtons, 1, 0) self.timeDisplay = QLCDNumber(self.gridLayoutWidget) self.timeDisplay.setStyleSheet('background-color: transparent') self.timeDisplay.setSegmentStyle(QLCDNumber.Flat) self.timeDisplay.setDigitCount(8) self.timeDisplay.display(strtime(cue.media.duration)) self.gridLayout.addWidget(self.timeDisplay, 1, 1) self.seekSlider = QClickSlider(self.gridLayoutWidget) self.seekSlider.setOrientation(Qt.Horizontal) self.seekSlider.setRange(0, cue.media.duration) self.seekSlider.setFocusPolicy(Qt.NoFocus) self.seekSlider.sliderMoved.connect(self._seek) self.seekSlider.sliderJumped.connect(self._seek) self.seekSlider.setVisible(False) self.dbmeter = QDbMeter(self.gridLayoutWidget) self.dbmeter.setVisible(False) self.gridLayout.setRowStretch(0, 1) self.gridLayout.setRowStretch(1, 3) self.gridLayout.setColumnStretch(0, 7) self.gridLayout.setColumnStretch(1, 5) cue.changed('name').connect(self.name_changed) cue.changed('duration').connect(self.update_duration) cue.started.connect(self.controlButtons.pauseMode) cue.paused.connect(self.controlButtons.startMode) # Fade enter/exit cue.fadein_start.connect(self.enter_fadein, Connection.QtQueued) cue.fadein_end.connect(self.exit_fade, Connection.QtQueued) cue.fadeout_start.connect(self.enter_fadeout, Connection.QtQueued) cue.fadeout_end.connect(self.exit_fade, Connection.QtQueued)