add fallback icons
This commit is contained in:
@@ -80,8 +80,8 @@ class RAction():
|
||||
action.setText(self.label)
|
||||
self._action = action
|
||||
if self.icon_from_theme:
|
||||
action.setIcon(Icon.fromTheme(self.icon_from_theme))
|
||||
if self.icon_file:
|
||||
action.setIcon(Icon.fromTheme(self.icon_from_theme, self.icon_file))
|
||||
elif self.icon_file:
|
||||
action.setIcon(Icon(self.icon_file))
|
||||
if self.shortcut:
|
||||
action.setShortcut(self.shortcut)
|
||||
|
||||
@@ -23,6 +23,7 @@ class OpenFilePlugin(PluginBase):
|
||||
|
||||
def _action_open_file(self) -> RAction:
|
||||
open_file = RAction(_("&Open..."), self._open_file_dialog, shortcut='Ctrl+O',
|
||||
icon_from_theme="fileopen",
|
||||
icon_file="icons/myicons/select-file.svg")
|
||||
return open_file
|
||||
|
||||
|
||||
@@ -26,19 +26,19 @@ class NewHighlightingDialog(QDialog):
|
||||
self.layout = QGridLayout(self)
|
||||
|
||||
row = 0
|
||||
btn_new = QPushButton(Icon("icons/myicons/list-add.svg"), _("New"))
|
||||
btn_new = QPushButton(Icon.fromTheme("list-add", "icons/myicons/list-add.svg"), _("New"))
|
||||
btn_new.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed))
|
||||
btn_new.pressed.connect(self._new_highlighter)
|
||||
|
||||
self.btn_delete = QPushButton(Icon("icons/myicons/list-remove.svg"), _("Remove"))
|
||||
self.btn_delete = QPushButton(Icon.fromTheme("list-remove", "icons/myicons/list-remove.svg"), _("Remove"))
|
||||
self.btn_delete.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed))
|
||||
self.btn_delete.pressed.connect(self._delete_selected_items)
|
||||
|
||||
self.btn_move_up = QPushButton(Icon("icons/myicons/go-up.svg"), _("Up"))
|
||||
self.btn_move_up = QPushButton(Icon.fromTheme("go-up", "icons/myicons/go-up.svg"), _("Up"))
|
||||
self.btn_move_up.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed))
|
||||
self.btn_move_up.pressed.connect(self._move_up)
|
||||
|
||||
self.btn_move_down = QPushButton(Icon("icons/myicons/go-down.svg"), _("Down"))
|
||||
self.btn_move_down = QPushButton(Icon.fromTheme("go-down", "icons/myicons/go-down.svg"), _("Down"))
|
||||
self.btn_move_down.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed))
|
||||
self.btn_move_down.pressed.connect(self._move_down)
|
||||
|
||||
|
||||
@@ -6,5 +6,8 @@ class Icon(QIcon):
|
||||
def __init__(self, file_name: str):
|
||||
super(Icon, self).__init__("%s" % Path(__file__).parent.parent.parent.joinpath(file_name).absolute())
|
||||
|
||||
def fromTheme(icon_from_theme: str) -> QIcon:
|
||||
@staticmethod
|
||||
def fromTheme(icon_from_theme: str, fallback: str = None) -> QIcon:
|
||||
if fallback:
|
||||
return QIcon.fromTheme(icon_from_theme, Icon(fallback))
|
||||
return QIcon.fromTheme(icon_from_theme)
|
||||
|
||||
Reference in New Issue
Block a user