mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-08-10 04:00:36 +02:00
fix(scan_control): preserve configured default scan and label filter button
This commit is contained in:
@@ -93,7 +93,8 @@ class ScanControl(BECWidget, QWidget):
|
||||
self.previous_scan = None
|
||||
|
||||
# Widget Default Parameters
|
||||
self.config.default_scan = default_scan
|
||||
if default_scan is not None:
|
||||
self.config.default_scan = default_scan
|
||||
if allowed_scans is not None:
|
||||
self.config.allowed_scans = allowed_scans
|
||||
|
||||
@@ -140,6 +141,7 @@ class ScanControl(BECWidget, QWidget):
|
||||
material_icon("filter_list", size=(20, 20), convert_to_pixmap=False)
|
||||
)
|
||||
self.scan_selector_settings_button.setToolTip("Choose scans shown in the selector")
|
||||
self.scan_selector_settings_button.setAccessibleName("Scan selector settings")
|
||||
scan_selection_layout.addWidget(self.comboBox_scan_selection_label, 0)
|
||||
scan_selection_layout.addWidget(self.comboBox_scan_selection, 1)
|
||||
scan_selection_layout.addWidget(self.scan_info_button, 0)
|
||||
@@ -170,10 +172,6 @@ class ScanControl(BECWidget, QWidget):
|
||||
self.button_layout.addWidget(self.button_stop_scan)
|
||||
self.layout.addWidget(self.scan_control_group)
|
||||
|
||||
# Default scan from config
|
||||
if self.config.default_scan is not None:
|
||||
self.comboBox_scan_selection.setCurrentText(self.config.default_scan)
|
||||
|
||||
# Connect signals
|
||||
self.comboBox_scan_selection.view().pressed.connect(self.save_current_scan_parameters)
|
||||
self.comboBox_scan_selection.currentIndexChanged.connect(self.on_scan_selection_changed)
|
||||
@@ -186,6 +184,10 @@ class ScanControl(BECWidget, QWidget):
|
||||
# Initialize scan selection
|
||||
self.populate_scans()
|
||||
|
||||
# Default scan from config; applied after population so the entry exists
|
||||
if self.config.default_scan is not None:
|
||||
self.comboBox_scan_selection.setCurrentText(self.config.default_scan)
|
||||
|
||||
# Append metadata form
|
||||
self._add_metadata_form()
|
||||
|
||||
|
||||
@@ -411,6 +411,23 @@ def test_configured_allowed_scans_are_preserved(qtbot, mocked_client):
|
||||
assert widget.comboBox_scan_selection.currentText() == "grid_scan"
|
||||
|
||||
|
||||
def test_configured_default_scan_is_preserved_and_applied(qtbot, mocked_client):
|
||||
mocked_client.connector.set_and_publish(
|
||||
MessageEndpoints.available_scans(), available_scans_message
|
||||
)
|
||||
|
||||
widget = ScanControl(client=mocked_client, default_scan="grid_scan")
|
||||
qtbot.addWidget(widget)
|
||||
assert widget.comboBox_scan_selection.currentText() == "grid_scan"
|
||||
|
||||
# A default_scan from a passed-in config must not be wiped by the ctor default None
|
||||
config = ScanControlConfig(widget_class="ScanControl", default_scan="grid_scan")
|
||||
widget_from_config = ScanControl(client=mocked_client, config=config)
|
||||
qtbot.addWidget(widget_from_config)
|
||||
assert widget_from_config.config.default_scan == "grid_scan"
|
||||
assert widget_from_config.comboBox_scan_selection.currentText() == "grid_scan"
|
||||
|
||||
|
||||
def test_scan_selector_settings_dialog_applies_checked_scans(scan_control, monkeypatch, qtbot):
|
||||
def select_line_scan(dialog):
|
||||
labels = [dialog.checkbox_for_scan(name).text() for name in ("line_scan", "grid_scan")]
|
||||
|
||||
Reference in New Issue
Block a user