mirror of
https://github.com/pyapp-kit/superqt.git
synced 2026-01-04 19:31:24 +01:00
feat: icon.name() (#213)
This commit is contained in:
@@ -71,5 +71,13 @@ class QIconifyIcon(QIcon):
|
|||||||
"Please install it with `pip install pyconify` or use the "
|
"Please install it with `pip install pyconify` or use the "
|
||||||
"`pip install superqt[iconify]` extra."
|
"`pip install superqt[iconify]` extra."
|
||||||
) from e
|
) from e
|
||||||
|
if len(key) == 1:
|
||||||
|
self._name = key[0]
|
||||||
|
else:
|
||||||
|
self._name = ":".join(key)
|
||||||
self.path = svg_path(*key, color=color, flip=flip, rotate=rotate, dir=dir)
|
self.path = svg_path(*key, color=color, flip=flip, rotate=rotate, dir=dir)
|
||||||
super().__init__(str(self.path))
|
super().__init__(str(self.path))
|
||||||
|
|
||||||
|
def name(self) -> str:
|
||||||
|
"""Return the iconify `prefix:icon` represented by this QIcon."""
|
||||||
|
return self._name
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ def test_qiconify(qtbot: "QtBot", monkeypatch: "pytest.MonkeyPatch") -> None:
|
|||||||
|
|
||||||
icon = QIconifyIcon("bi:alarm-fill", color="red", rotate=90)
|
icon = QIconifyIcon("bi:alarm-fill", color="red", rotate=90)
|
||||||
assert icon.path.name.endswith(".svg")
|
assert icon.path.name.endswith(".svg")
|
||||||
|
assert icon.name() == "bi:alarm-fill"
|
||||||
|
|
||||||
btn = QPushButton()
|
btn = QPushButton()
|
||||||
qtbot.addWidget(btn)
|
qtbot.addWidget(btn)
|
||||||
|
|||||||
Reference in New Issue
Block a user