0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-13 19:21:50 +02:00

fix(device_combobox): tuple entries of preview signals are checked in DeviceComboBoxes just for the relevant device

This commit is contained in:
2025-06-04 15:39:45 +02:00
committed by Jan Wyzula
parent 392ddf9d1a
commit 12f5233745

View File

@ -149,6 +149,25 @@ class DeviceComboBox(DeviceInputBase, QComboBox):
self._is_valid_input = False
self.update()
def validate_device(self, device: str) -> bool: # type: ignore[override]
"""
Extend validation so that previewsignal pseudodevices (labels like
``"eiger_preview"``) are accepted as valid choices.
The validation run only on device not on the previewsignal.
Args:
device: The text currently entered/selected.
Returns:
True if the device is a genuine BEC device *or* one of the
whitelisted previewsignal entries.
"""
idx = self.findText(device)
if idx >= 0 and isinstance(self.itemData(idx), tuple):
device = self.itemData(idx)[0] # type: ignore[assignment]
return super().validate_device(device)
if __name__ == "__main__": # pragma: no cover
# pylint: disable=import-outside-toplevel