Skip to content

Commit

Permalink
fix: use p icon
Browse files Browse the repository at this point in the history
  • Loading branch information
fdrgsp committed Nov 7, 2024
1 parent 233b775 commit 11b11b0
Showing 1 changed file with 5 additions and 73 deletions.
78 changes: 5 additions & 73 deletions src/pymmcore_widgets/device_properties/_device_property_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from pymmcore_plus import CMMCorePlus, DeviceProperty, DeviceType
from qtpy.QtCore import Qt
from qtpy.QtGui import QPalette
from qtpy.QtGui import QColor
from qtpy.QtWidgets import QAbstractScrollArea, QTableWidget, QTableWidgetItem, QWidget
from superqt.fonticon import icon

Expand Down Expand Up @@ -124,18 +124,11 @@ def _rebuild_table(self) -> None:
props = list(self._mmc.iterProperties(as_object=True))
self.setRowCount(len(props))

# Retrieve the palette
palette = self.palette() # This pulls the current theme colors

read_only_color = palette.color(QPalette.ColorRole.Dark)
pre_init_color = palette.color(QPalette.ColorRole.Dark).darker(130)

for i, prop in enumerate(props):
extra = " 🅿" if prop.isPreInit() else ""
item = QTableWidgetItem(f"{prop.device}-{prop.name}{extra}")
item.setData(self.PROP_ROLE, prop)
icon_string = ICONS.get(prop.deviceType())
if icon_string:
if icon_string := ICONS.get(prop.deviceType()):
item.setIcon(icon(icon_string, color="Gray"))
self.setItem(i, 0, item)

Expand All @@ -157,75 +150,14 @@ def _rebuild_table(self) -> None:
wdg.setEnabled(False)

if prop.isReadOnly():
item.setBackground(read_only_color)
wdg.setStyleSheet(
f"QLabel {{ background-color : {read_only_color.name()} }}"
)

if prop.isPreInit():
item.setBackground(pre_init_color)
# set a placeholder item to then color the cell background
placeholder_item = QTableWidgetItem()
placeholder_item.setBackground(pre_init_color)
self.setItem(i, 1, placeholder_item)
# color the widget background
wdg.setStyleSheet(
f"QWidget {{ background-color : {pre_init_color.name()} }}"
)
# TODO: make this more theme aware
item.setBackground(QColor("#AAA"))
wdg.setStyleSheet("QLabel { background-color : #AAA }")

self.resizeColumnsToContents()
self.setRowsCheckable(self._rows_checkable)
# TODO: install eventFilter to prevent mouse wheel from scrolling sliders

# def _rebuild_table(self) -> None:
# self.clearContents()
# props = list(self._mmc.iterProperties(as_object=True))
# self.setRowCount(len(props))
# for i, prop in enumerate(props):
# extra = " (pre-init)" if prop.isPreInit() else ""
# item = QTableWidgetItem(f"{prop.device}-{prop.name}{extra}")
# item.setData(self.PROP_ROLE, prop)
# icon_string = ICONS.get(prop.deviceType())
# if icon_string:
# item.setIcon(icon(icon_string, color="Gray"))
# self.setItem(i, 0, item)

# try:
# wdg = PropertyWidget(
# prop.device,
# prop.name,
# mmcore=self._mmc,
# connect_core=self._connect_core,
# )
# except Exception as e:
# logger.error(
# f"Error creating widget for {prop.device}-{prop.name}: {e}"
# )
# continue

# self.setCellWidget(i, 1, wdg)
# if not self._prop_widgets_enabled:
# wdg.setEnabled(False)

# if prop.isReadOnly():
# # TODO: make this more theme aware
# item.setBackground(QColor("#AAA"))
# wdg.setStyleSheet("QLabel { background-color : #AAA }")

# if prop.isPreInit():
# # TODO: make this more theme aware
# item.setBackground(QColor("#dbdbdb"))
# # set a placeholder item to then color the cell background
# placeholder_item = QTableWidgetItem()
# placeholder_item.setBackground(QColor("#dbdbdb"))
# self.setItem(i, 1, placeholder_item)
# # color the widget background
# wdg.setStyleSheet("QWidget { background-color : #dbdbdb }")

# self.resizeColumnsToContents()
# self.setRowsCheckable(self._rows_checkable)
# # TODO: install eventFilter to prevent mouse wheel from scrolling sliders

def setReadOnlyDevicesVisible(self, visible: bool = True) -> None:
"""Set whether read-only devices are visible."""
for row in range(self.rowCount()):
Expand Down

0 comments on commit 11b11b0

Please sign in to comment.