This commit is contained in:
Kovid Goyal 2025-01-25 17:31:50 +05:30
commit c78cfdd926
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -708,7 +708,7 @@ class TagsView(QTreeView): # {{{
# global_vars=None, all_functions=None, builtin_functions=None, # global_vars=None, all_functions=None, builtin_functions=None,
# python_context_object=None, dialog_number=None, # python_context_object=None, dialog_number=None,
formatter=EvalFormatter, icon_dir='tb_icons/template_icons') formatter=EvalFormatter, icon_dir='tb_icons/template_icons')
if d.exec(): if d.exec() == QDialog.DialogCode.Accepted:
self._model.set_value_icon(key, TEMPLATE_ICON_INDICATOR, d.rule[2], False) self._model.set_value_icon(key, TEMPLATE_ICON_INDICATOR, d.rule[2], False)
self.recount() self.recount()
return return
@ -722,16 +722,18 @@ class TagsView(QTreeView): # {{{
_('Change icon for: %s')%key, filters=[ _('Change icon for: %s')%key, filters=[
('Images', ['png', 'gif', 'jpg', 'jpeg'])], ('Images', ['png', 'gif', 'jpg', 'jpeg'])],
all_files=False, select_only_single_file=True) all_files=False, select_only_single_file=True)
if path: if not path:
path = path[0] return
p = QIcon(path).pixmap(QSize(128, 128)) path = path[0]
d = os.path.join(config_dir, 'tb_icons') p = QIcon(path).pixmap(QSize(128, 128))
if not os.path.exists(d): d = os.path.join(config_dir, 'tb_icons')
os.makedirs(d) if not os.path.exists(d):
with open(os.path.join(d, icon_file_name), 'wb') as f: os.makedirs(d)
f.write(pixmap_to_data(p, format='PNG')) with open(os.path.join(d, icon_file_name), 'wb') as f:
f.write(pixmap_to_data(p, format='PNG'))
except: except:
traceback.print_exc() traceback.print_exc()
return
else: else:
# Already have an icon. User wants to change whether it applies to children # Already have an icon. User wants to change whether it applies to children
icon_file_name = desired_file_name icon_file_name = desired_file_name