Skip to content

Commit e2fa856

Browse files
authored
feat: add QConfigGroupsModel, a QAbstractItemModel to manage configs and presets (#447)
* pull in just the model * pull in tests * feat: QConfigGroupsModel * better insertrows * better insert * use model tester * public export
1 parent f96a776 commit e2fa856

File tree

5 files changed

+797
-6
lines changed

5 files changed

+797
-6
lines changed

src/pymmcore_widgets/_icons.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
11
from __future__ import annotations
22

3-
from pymmcore_plus import DeviceType
3+
from pymmcore_plus import CMMCorePlus, DeviceType
4+
from superqt import QIconifyIcon
45

56
ICONS: dict[DeviceType, str] = {
67
DeviceType.Any: "mdi:devices",
7-
DeviceType.AutoFocus: "mdi:auto-upload",
8+
DeviceType.AutoFocus: "mdi:focus-auto",
89
DeviceType.Camera: "mdi:camera",
9-
DeviceType.Core: "mdi:checkbox-blank-circle-outline",
10+
DeviceType.Core: "mdi:heart-cog-outline",
1011
DeviceType.Galvo: "mdi:mirror-variant",
1112
DeviceType.Generic: "mdi:dev-to",
1213
DeviceType.Hub: "mdi:hubspot",
1314
DeviceType.ImageProcessor: "mdi:image-auto-adjust",
14-
DeviceType.Magnifier: "mdi:magnify-plus",
15+
DeviceType.Magnifier: "mdi:magnify",
1516
DeviceType.Shutter: "mdi:camera-iris",
16-
DeviceType.SignalIO: "mdi:signal",
17+
DeviceType.SignalIO: "fa6-solid:wave-square",
1718
DeviceType.SLM: "mdi:view-comfy",
1819
DeviceType.Stage: "mdi:arrow-up-down",
1920
DeviceType.State: "mdi:state-machine",
20-
DeviceType.Unknown: "mdi:dev-to",
21+
DeviceType.Unknown: "mdi:question-mark-rhombus",
2122
DeviceType.XYStage: "mdi:arrow-all",
2223
DeviceType.Serial: "mdi:serial-port",
2324
}
25+
26+
27+
def get_device_icon(
28+
device_type_or_name: DeviceType | str, color: str = "gray"
29+
) -> QIconifyIcon | None:
30+
if isinstance(device_type_or_name, str):
31+
try:
32+
device_type = CMMCorePlus.instance().getDeviceType(device_type_or_name)
33+
except Exception:
34+
device_type = DeviceType.Unknown
35+
else:
36+
device_type = device_type_or_name
37+
if icon_string := ICONS.get(device_type):
38+
return QIconifyIcon(icon_string, color=color)
39+
return None

src/pymmcore_widgets/config_presets/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
from ._group_preset_widget._group_preset_table_widget import GroupPresetTableWidget
44
from ._objectives_pixel_configuration_widget import ObjectivesPixelConfigurationWidget
55
from ._pixel_configuration_widget import PixelConfigurationWidget
6+
from ._qmodel._config_model import QConfigGroupsModel
67

78
__all__ = [
89
"GroupPresetTableWidget",
910
"ObjectivesPixelConfigurationWidget",
1011
"PixelConfigurationWidget",
12+
"QConfigGroupsModel",
1113
]

src/pymmcore_widgets/config_presets/_qmodel/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)