diff --git a/corrscope/corrscope.py b/corrscope/corrscope.py index 8205dca..a8f5d5c 100644 --- a/corrscope/corrscope.py +++ b/corrscope/corrscope.py @@ -90,7 +90,7 @@ class Config( master_audio: Optional[str] begin_time: float = with_units("s", default=0) - end_time: Optional[float] = None + end_time: Optional[float] = with_units("s", default=None) fps: int diff --git a/corrscope/gui/model_bind.py b/corrscope/gui/model_bind.py index 9ad952f..342013f 100644 --- a/corrscope/gui/model_bind.py +++ b/corrscope/gui/model_bind.py @@ -278,6 +278,26 @@ class BoundDoubleSpinBox(qw.QDoubleSpinBox, BoundWidget): set_model = model_setter(float) +class BoundDoubleOrNone(qw.QDoubleSpinBox, BoundWidget): + bind_widget = BoundSpinBox.bind_widget + + def set_gui(self, value): + self.setValue(value or 0.0) + + gui_changed = alias("valueChanged") + + @Slot(float) + def set_model(self: BoundWidget, value: float): + value = value or None + try: + self.pmodel[self.path] = value + except CorrError: + self.setPalette(self.error_palette) + else: + BoundWidget.set_model(self, value) + self.setPalette(self.default_palette) + + # CheckState inherits from int on PyQt5 and Enum on PyQt6. To compare integers with # CheckState on both PyQt5 and 6, we have to call CheckState(int). CheckState = qc.Qt.CheckState diff --git a/corrscope/gui/view_mainwindow.py b/corrscope/gui/view_mainwindow.py index 307018e..86436b3 100644 --- a/corrscope/gui/view_mainwindow.py +++ b/corrscope/gui/view_mainwindow.py @@ -115,8 +115,18 @@ class MainWindow(QWidget): with add_row(s, "", BoundDoubleSpinBox) as self.amplification: self.amplification.setSingleStep(0.1) - with add_row(s, "", BoundDoubleSpinBox) as self.begin_time: - self.begin_time.setMaximum(9999.0) + with add_row(s, tr("Time"), QHBoxLayout) as self.layout_time: + with append_widget(s, BoundDoubleSpinBox) as self.begin_time: + self.begin_time.setMaximum(9999.0) + self.begin_time.setDecimals(1) + + with append_widget(s, QLabel) as dash: + dash.setText(tr("–")) + + with append_widget(s, BoundDoubleOrNone) as self.end_time: + self.end_time.setMaximum(9999.0) + self.end_time.setDecimals(1) + self.end_time.setSpecialValueText(NBSP) with append_widget( s, QGroupBox, title=tr("Performance (Preview Only)"), layout=QFormLayout @@ -535,7 +545,6 @@ class MainWindow(QWidget): self.trigger_msL.setText(tr("Trigger Width")) self.render_msL.setText(tr("Render Width")) self.amplificationL.setText(tr("Amplification")) - self.begin_timeL.setText(tr("Begin Time")) self.render_resolutionL.setText(tr("Resolution")) self.render__bg_colorL.setText(tr("Background")) self.render__init_line_colorL.setText(tr("Line Color")) @@ -582,6 +591,7 @@ from corrscope.gui.model_bind import ( BoundColorWidget, OptionalColorWidget, BoundFontButton, + BoundDoubleOrNone, ) # Delete unbound widgets, so they cannot accidentally be used.