Add default stereo right color to GUI

pull/491/head
nyanpasu64 2024-11-10 20:20:33 -08:00
rodzic c7b9c8a64b
commit b0d95658fb
2 zmienionych plików z 11 dodań i 4 usunięć

Wyświetl plik

@ -463,7 +463,7 @@ class BoundColorWidget(BoundWidget, qw.QWidget):
# Setup checkbox # Setup checkbox
if self.optional: if self.optional:
self.check = _ColorCheckBox(self, self.text) self.check = _ColorCheckBox(self, self.text, "#ffffff")
self.check.setToolTip("Enable/Disable Color") self.check.setToolTip("Enable/Disable Color")
layout.addWidget(self.check) layout.addWidget(self.check)
@ -492,6 +492,12 @@ class BoundColorWidget(BoundWidget, qw.QWidget):
"BoundColorWidget.gui_changed -> set_model should not be called" "BoundColorWidget.gui_changed -> set_model should not be called"
) )
def set_default_color(self, color: str):
assert hasattr(
self, "check"
), "cannot set default color of non-optional color widget"
self.check.default_color = color
class OptionalColorWidget(BoundColorWidget): class OptionalColorWidget(BoundColorWidget):
optional = True optional = True
@ -590,11 +596,12 @@ class _ColorButton(qw.QPushButton):
class _ColorCheckBox(qw.QCheckBox): class _ColorCheckBox(qw.QCheckBox):
def __init__(self, parent: QWidget, text: "_ColorText"): def __init__(self, parent: QWidget, text: "_ColorText", default_color: str):
qw.QCheckBox.__init__(self, parent) qw.QCheckBox.__init__(self, parent)
self.stateChanged.connect(self.on_check) self.stateChanged.connect(self.on_check)
self.color_text = text self.color_text = text
self.default_color = default_color
text.hex_color.connect(self.set_color) text.hex_color.connect(self.set_color)
@Slot(str) @Slot(str)
@ -612,7 +619,7 @@ class _ColorCheckBox(qw.QCheckBox):
CheckState.Checked, CheckState.Checked,
] ]
if value != CheckState.Unchecked: if value != CheckState.Unchecked:
self.color_text.setText("#ffffff") self.color_text.setText(self.default_color)
else: else:
self.color_text.setText("") self.color_text.setText("")

Wyświetl plik

@ -294,7 +294,7 @@ class MainWindow(QWidget):
with add_row( with add_row(
s, tr("Right Color"), OptionalColorWidget s, tr("Right Color"), OptionalColorWidget
) as self.render__stereo_bar_right_color: ) as self.render__stereo_bar_right_color:
pass self.render__stereo_bar_right_color.set_default_color("#ff9999")
with add_row( with add_row(
s, s,