11from __future__ import annotations
22
33from dataclasses import dataclass
4- from typing import TYPE_CHECKING , Literal
4+ from typing import TYPE_CHECKING , Any , Literal
55
66import qtawesome as qta
77from PyQt5 .QtCore import QSize
3636_SEARCH_ICON = "fa.search"
3737_UPLOAD_ICON = "fa.upload"
3838_QUESTION_ICON = "fa5.question-circle"
39+ _BORDER_ICON = "fa5.square"
3940BUTTON_SIZE = QSize (36 , 36 )
4041SMALL_BUTTON_SIZE = QSize (24 , 24 )
4142
@@ -61,6 +62,7 @@ class PresetIcon:
6162 huge_glass = _HUGE_GLASS
6263 skull = _SKULL
6364 easy = _EASY
65+ border = _BORDER_ICON
6466
6567
6668@dataclass
@@ -160,19 +162,28 @@ def set_picture_window_icons(self, w: Ui_PictureWindow):
160162 fa_icon : QIcon = qta .icon (icon , color = self .color .background )
161163 self .set_icon (ui_element , fa_icon , no_text )
162164
163- def generate_icon (self , icon_name : str , color : str , color_active : str | None = None ) -> QIcon :
165+ def generate_icon (self , icon_name : str , color : str , color_active : str | None = None , border : bool = False ) -> QIcon :
164166 """Generate an icon with the given color and size.
165167
166168 Args:
167169 ----
168170 icon_name (str): icon name in qta, e.g. "fa5s.cog"
169171 color (str): given color name in hex, e.g. "#007bff"
170172 color_active (str): given active color name, will use color if None, defaults to None
173+ border (bool): if True, add a border to the icon, defaults to False
171174
172175 """
173- if color_active is None :
174- color_active = color
175- return qta .icon (icon_name , color = color , color_active = color_active )
176+ icon_option : dict [str , Any ] = {
177+ "color" : color ,
178+ "color_active" : color if color_active is None else color_active ,
179+ }
180+ if not border :
181+ return qta .icon (icon_name , options = [icon_option ])
182+ return qta .icon (
183+ icon_name ,
184+ _BORDER_ICON ,
185+ options = [icon_option , {** icon_option , "scale_factor" : 1.3 }],
186+ )
176187
177188 def set_wait_icon (self , button : QPushButton , icon : Literal ["spin" , "time" ] = "time" , primary = False ):
178189 """Set a spinner button to the icon."""
0 commit comments