feat(main): implement def _unwrap_qvariant

This commit is contained in:
dev 2026-02-23 14:29:20 +00:00
parent ded74f065c
commit 051413472b

View file

@ -19,3 +19,27 @@ from .ui_builders import ScanSlicerUiBuilderMixin
# _unwrap_qvariant: function definition for ScanSlicer behavior.
def _unwrap_qvariant(value):
unwrapped = value
for _ in range(4):
if hasattr(unwrapped, "variant"):
try:
candidate = unwrapped.variant()
except Exception:
candidate = unwrapped
if candidate is not unwrapped:
unwrapped = candidate
continue
if hasattr(unwrapped, "value"):
try:
candidate = unwrapped.value()
except TypeError:
candidate = unwrapped.value
except Exception:
candidate = unwrapped
if candidate is not unwrapped:
unwrapped = candidate
continue
break
return unwrapped