Skip to content

Commit

Permalink
change with palette
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Oct 10, 2023
1 parent d27c283 commit 62daa67
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/magicgui/backends/_qtpy/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,13 +1222,21 @@ class ToolBar(QBaseWidget):

def __init__(self, **kwargs: Any) -> None:
super().__init__(QtW.QToolBar, **kwargs)
self._qwidget.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextUnderIcon)
self._event_filter.paletteChanged.connect(self._on_palette_change)

Check warning on line 1226 in src/magicgui/backends/_qtpy/widgets.py

View check run for this annotation

Codecov / codecov/patch

src/magicgui/backends/_qtpy/widgets.py#L1224-L1226

Added lines #L1224 - L1226 were not covered by tests

def _on_palette_change(self):
for action in self._qwidget.actions():
if icon := action.data():
if qicon := _get_qicon(icon, None, palette=self._qwidget.palette()):
action.setIcon(qicon)

Check warning on line 1232 in src/magicgui/backends/_qtpy/widgets.py

View check run for this annotation

Codecov / codecov/patch

src/magicgui/backends/_qtpy/widgets.py#L1229-L1232

Added lines #L1229 - L1232 were not covered by tests

def _mgui_add_button(self, text: str, icon: str, callback: Callable) -> None:
"""Add an action to the toolbar."""
act = self._qwidget.addAction(text, callback)
if qicon := _get_qicon(icon, None, palette=self._qwidget.palette()):
self._qwidget.addAction(qicon, text, callback)
else:
self._qwidget.addAction(text, callback)
act.setIcon(qicon)
act.setData(icon)

Check warning on line 1239 in src/magicgui/backends/_qtpy/widgets.py

View check run for this annotation

Codecov / codecov/patch

src/magicgui/backends/_qtpy/widgets.py#L1236-L1239

Added lines #L1236 - L1239 were not covered by tests

def _mgui_add_separator(self) -> None:
"""Add a separator line to the toolbar."""
Expand Down

0 comments on commit 62daa67

Please sign in to comment.