mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
more QIcon.ic() usage
This commit is contained in:
parent
7ce05e3097
commit
35aba136ee
@ -236,7 +236,7 @@ class ITALICA(EB600):
|
||||
|
||||
name = 'Italica Device Interface'
|
||||
gui_name = 'Italica'
|
||||
icon = I('devices/italica.png')
|
||||
icon = 'devices/italica.png'
|
||||
|
||||
FORMATS = ['epub', 'rtf', 'fb2', 'html', 'prc', 'mobi', 'pdf', 'txt']
|
||||
|
||||
|
@ -49,7 +49,7 @@ class FOLDER_DEVICE(USBMS):
|
||||
SUPPORTS_SUB_DIRS = True
|
||||
|
||||
#: Icon for this device
|
||||
icon = I('devices/folder.png')
|
||||
icon = 'devices/folder.png'
|
||||
METADATA_CACHE = '.metadata.calibre'
|
||||
DRIVEINFO = '.driveinfo.calibre'
|
||||
|
||||
|
@ -73,7 +73,7 @@ class DevicePlugin(Plugin):
|
||||
path_sep = os.sep
|
||||
|
||||
#: Icon for this device
|
||||
icon = I('reader.png')
|
||||
icon = 'reader.png'
|
||||
|
||||
# Encapsulates an annotation fetched from the device
|
||||
UserAnnotation = namedtuple('Annotation','type, value')
|
||||
|
@ -28,7 +28,7 @@ def synchronous(func):
|
||||
class MTPDeviceBase(DevicePlugin):
|
||||
name = 'MTP Device Interface'
|
||||
gui_name = _('MTP device')
|
||||
icon = I('devices/tablet.png')
|
||||
icon = 'devices/tablet.png'
|
||||
description = _('Communicate with MTP devices')
|
||||
author = 'Kovid Goyal'
|
||||
version = (1, 0, 0)
|
||||
|
@ -184,7 +184,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
gui_name = _('Wireless device')
|
||||
gui_name_template = '%s: %s'
|
||||
|
||||
icon = I('devices/tablet.png')
|
||||
icon = 'devices/tablet.png'
|
||||
description = _('Communicate with Smart Device apps')
|
||||
supported_platforms = ['windows', 'osx', 'linux']
|
||||
author = 'Charles Haley'
|
||||
|
@ -47,7 +47,11 @@ except AttributeError:
|
||||
|
||||
|
||||
def load_qicon(name):
|
||||
return QIcon(I(name))
|
||||
if isinstance(name, QIcon):
|
||||
return name
|
||||
if not os.path.isabs(name):
|
||||
name = I(name)
|
||||
return QIcon(name)
|
||||
|
||||
|
||||
QIcon.ic = load_qicon
|
||||
|
@ -392,7 +392,7 @@ class ChooseLibraryAction(InterfaceAction):
|
||||
traceback.print_exc()
|
||||
|
||||
def set_library_icon(self):
|
||||
icon = QIcon(library_icon_path())
|
||||
icon = QIcon.ic(library_icon_path())
|
||||
has_icon = not icon.isNull() and len(icon.availableSizes()) > 0
|
||||
if not has_icon:
|
||||
icon = self.original_library_icon
|
||||
|
@ -19,7 +19,7 @@ class QuickviewButton(LayoutButton): # {{{
|
||||
def __init__(self, gui, quickview_manager):
|
||||
self.qv = quickview_manager
|
||||
qaction = quickview_manager.qaction
|
||||
LayoutButton.__init__(self, I('quickview.png'), _('Quickview'),
|
||||
LayoutButton.__init__(self, 'quickview.png', _('Quickview'),
|
||||
parent=gui, shortcut=qaction.shortcut().toString())
|
||||
self.toggled.connect(self.update_state)
|
||||
self.action_toggle = qaction
|
||||
|
@ -132,9 +132,9 @@ def get_icon_path(f, prefix):
|
||||
if ci:
|
||||
icon_path = os.path.join(config_dir, 'tb_icons', ci)
|
||||
elif prefix:
|
||||
icon_path = I(category_icon_map['gst'])
|
||||
icon_path = category_icon_map['gst']
|
||||
else:
|
||||
icon_path = I(category_icon_map.get(f, 'search.png'))
|
||||
icon_path = category_icon_map.get(f, 'search.png')
|
||||
return icon_path
|
||||
|
||||
|
||||
@ -157,13 +157,13 @@ def init_find_in_grouped_search(menu, field, value, book_info):
|
||||
m = QMenu((_('Search calibre for %s') + '...')%escape_for_menu(value), menu)
|
||||
m.setIcon(QIcon.ic('search.png'))
|
||||
menu.addMenu(m)
|
||||
m.addAction(QIcon(get_icon_path(field, '')),
|
||||
m.addAction(QIcon.ic(get_icon_path(field, '')),
|
||||
_('in category %s')%escape_for_menu(field_name),
|
||||
lambda g=field: book_info.search_requested(
|
||||
'{}:"={}"'.format(g, value.replace('"', r'\"')), ''))
|
||||
for gst in gsts_to_show:
|
||||
icon_path = get_icon_path(gst, '@')
|
||||
m.addAction(QIcon(icon_path),
|
||||
m.addAction(QIcon.ic(icon_path),
|
||||
_('in grouped search %s')%gst,
|
||||
lambda g=gst: book_info.search_requested(
|
||||
'{}:"={}"'.format(g, value.replace('"', r'\"')), ''))
|
||||
|
@ -258,7 +258,7 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
|
||||
self.comments_pat = re.compile(r'<!--.*?-->', re.DOTALL)
|
||||
|
||||
def r(name, icon, text, checkable=False, shortcut=None):
|
||||
ac = QAction(QIcon(I(icon + '.png')), text, self)
|
||||
ac = QAction(QIcon.ic(icon + '.png'), text, self)
|
||||
ac.setShortcutContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
|
||||
if checkable:
|
||||
ac.setCheckable(checkable)
|
||||
|
@ -49,7 +49,7 @@ def bulk_defaults_for_input_format(fmt):
|
||||
class Widget(QWidget):
|
||||
|
||||
TITLE = _('Unknown')
|
||||
ICON = I('config.png')
|
||||
ICON = 'config.png'
|
||||
HELP = ''
|
||||
COMMIT_NAME = None
|
||||
# If True, leading and trailing spaces are removed from line and text edit
|
||||
@ -66,7 +66,7 @@ class Widget(QWidget):
|
||||
self._options = options
|
||||
self._name = self.commit_name = self.COMMIT_NAME
|
||||
assert self._name is not None
|
||||
self._icon = QIcon(self.ICON)
|
||||
self._icon = QIcon.ic(self.ICON)
|
||||
for name in self._options:
|
||||
if not hasattr(self, 'opt_'+name):
|
||||
raise Exception('Option %s missing in %s'%(name,
|
||||
|
@ -212,12 +212,12 @@ class Bool(Base):
|
||||
|
||||
w = self.combobox
|
||||
items = [_('Yes'), _('No'), _('Undefined')]
|
||||
icons = [I('ok.png'), I('list_remove.png'), I('blank.png')]
|
||||
icons = ['ok.png', 'list_remove.png', 'blank.png']
|
||||
if not self.db.new_api.pref('bools_are_tristate'):
|
||||
items = items[:-1]
|
||||
icons = icons[:-1]
|
||||
for icon, text in zip(icons, items):
|
||||
w.addItem(QIcon(icon), text)
|
||||
w.addItem(QIcon.ic(icon), text)
|
||||
|
||||
def setter(self, val):
|
||||
val = {None: 2, False: 1, True: 0}[val]
|
||||
@ -1019,10 +1019,10 @@ class BulkBool(BulkBase, Bool):
|
||||
items.append('')
|
||||
else:
|
||||
items.append(_('Undefined'))
|
||||
icons = [I('ok.png'), I('list_remove.png'), I('blank.png')]
|
||||
icons = ['ok.png', 'list_remove.png', 'blank.png']
|
||||
self.main_widget.blockSignals(True)
|
||||
for icon, text in zip(icons, items):
|
||||
self.main_widget.addItem(QIcon(icon), text)
|
||||
self.main_widget.addItem(QIcon.ic(icon), text)
|
||||
self.main_widget.blockSignals(False)
|
||||
self.finish_ui_setup(parent, is_bool=True)
|
||||
|
||||
|
@ -736,7 +736,7 @@ class DeviceAction(QAction): # {{{
|
||||
a_s = pyqtSignal(object)
|
||||
|
||||
def __init__(self, dest, delete, specific, icon_path, text, parent=None):
|
||||
QAction.__init__(self, QIcon(icon_path), text, parent)
|
||||
QAction.__init__(self, QIcon.ic(icon_path), text, parent)
|
||||
self.dest = dest
|
||||
self.delete = delete
|
||||
self.specific = specific
|
||||
@ -767,29 +767,29 @@ class DeviceMenu(QMenu): # {{{
|
||||
self.set_default_menu.setIcon(QIcon.ic('config.png'))
|
||||
|
||||
basic_actions = [
|
||||
('main:', False, False, I('reader.png'),
|
||||
('main:', False, False, 'reader.png',
|
||||
_('Send to main memory')),
|
||||
('carda:0', False, False, I('sd.png'),
|
||||
('carda:0', False, False, 'sd.png',
|
||||
_('Send to storage card A')),
|
||||
('cardb:0', False, False, I('sd.png'),
|
||||
('cardb:0', False, False, 'sd.png',
|
||||
_('Send to storage card B')),
|
||||
]
|
||||
|
||||
delete_actions = [
|
||||
('main:', True, False, I('reader.png'),
|
||||
('main:', True, False, 'reader.png',
|
||||
_('Main memory')),
|
||||
('carda:0', True, False, I('sd.png'),
|
||||
('carda:0', True, False, 'sd.png',
|
||||
_('Storage card A')),
|
||||
('cardb:0', True, False, I('sd.png'),
|
||||
('cardb:0', True, False, 'sd.png',
|
||||
_('Storage card B')),
|
||||
]
|
||||
|
||||
specific_actions = [
|
||||
('main:', False, True, I('reader.png'),
|
||||
('main:', False, True, 'reader.png',
|
||||
_('Main memory')),
|
||||
('carda:0', False, True, I('sd.png'),
|
||||
('carda:0', False, True, 'sd.png',
|
||||
_('Storage card A')),
|
||||
('cardb:0', False, True, I('sd.png'),
|
||||
('cardb:0', False, True, 'sd.png',
|
||||
_('Storage card B')),
|
||||
]
|
||||
|
||||
@ -945,7 +945,7 @@ class DeviceMixin: # {{{
|
||||
return question_dialog(self, _('Manage the %s?')%name,
|
||||
_('Detected the <b>%s</b>. Do you want calibre to manage it?')%
|
||||
name, show_copy_button=False,
|
||||
override_icon=QIcon(icon))
|
||||
override_icon=QIcon.ic(icon))
|
||||
|
||||
def after_callback_feedback(self, feedback):
|
||||
title, msg, det_msg = feedback
|
||||
|
@ -45,7 +45,7 @@ class NameTableWidgetItem(QTableWidgetItem):
|
||||
if to_what:
|
||||
self.setIcon(QIcon.ic('trash.png'))
|
||||
else:
|
||||
self.setIcon(QIcon(None))
|
||||
self.setIcon(QIcon())
|
||||
self.current_value = self.initial_value
|
||||
self.is_deleted = to_what
|
||||
|
||||
|
@ -190,7 +190,7 @@ class Stack(QStackedWidget): # {{{
|
||||
parent.cb_splitter = LibraryWidget(parent)
|
||||
self.tb_widget = TagBrowserWidget(parent)
|
||||
parent.tb_splitter = Splitter('tag_browser_splitter',
|
||||
_('Tag browser'), I('tags.png'),
|
||||
_('Tag browser'), 'tags.png',
|
||||
parent=parent, side_index=0, initial_side_size=200,
|
||||
shortcut='Shift+Alt+T')
|
||||
parent.tb_splitter.state_changed.connect(
|
||||
@ -332,7 +332,7 @@ class GridViewButton(LayoutButton): # {{{
|
||||
|
||||
def __init__(self, gui):
|
||||
sc = 'Alt+Shift+G'
|
||||
LayoutButton.__init__(self, I('grid.png'), _('Cover grid'), parent=gui, shortcut=sc)
|
||||
LayoutButton.__init__(self, 'grid.png', _('Cover grid'), parent=gui, shortcut=sc)
|
||||
self.set_state_to_show()
|
||||
self.action_toggle = QAction(self.icon(), _('Toggle') + ' ' + self.label, self)
|
||||
gui.addAction(self.action_toggle)
|
||||
@ -362,7 +362,7 @@ class SearchBarButton(LayoutButton): # {{{
|
||||
|
||||
def __init__(self, gui):
|
||||
sc = 'Alt+Shift+F'
|
||||
LayoutButton.__init__(self, I('search.png'), _('Search bar'), parent=gui, shortcut=sc)
|
||||
LayoutButton.__init__(self, 'search.png', _('Search bar'), parent=gui, shortcut=sc)
|
||||
self.set_state_to_hide()
|
||||
self.action_toggle = QAction(self.icon(), _('Toggle') + ' ' + self.label, self)
|
||||
gui.addAction(self.action_toggle)
|
||||
@ -567,7 +567,7 @@ class LayoutMixin: # {{{
|
||||
self.book_details = BookDetails(False, self)
|
||||
self.stack = Stack(self)
|
||||
self.bd_splitter = Splitter('book_details_splitter',
|
||||
_('Book details'), I('book.png'),
|
||||
_('Book details'), 'book.png',
|
||||
orientation=Qt.Orientation.Vertical, parent=self, side_index=1,
|
||||
shortcut='Shift+Alt+D')
|
||||
self.bd_splitter.addWidget(self.stack)
|
||||
@ -578,7 +578,7 @@ class LayoutMixin: # {{{
|
||||
# }}}
|
||||
else: # wide {{{
|
||||
self.bd_splitter = Splitter('book_details_splitter',
|
||||
_('Book details'), I('book.png'), initial_side_size=200,
|
||||
_('Book details'), 'book.png', initial_side_size=200,
|
||||
orientation=Qt.Orientation.Horizontal, parent=self, side_index=1,
|
||||
shortcut='Shift+Alt+D')
|
||||
self.stack = Stack(self)
|
||||
|
@ -121,9 +121,7 @@ class LocationManager(QObject): # {{{
|
||||
self.configure_device.emit()
|
||||
|
||||
def update_devices(self, cp=(None, None), fs=[-1, -1, -1], icon=None):
|
||||
if icon is None:
|
||||
icon = I('reader.png')
|
||||
self.location_main.setIcon(QIcon(icon))
|
||||
self.location_main.setIcon(QIcon.ic(icon or 'reader.png'))
|
||||
had_device = self.has_device
|
||||
if cp is None:
|
||||
cp = (None, None)
|
||||
|
@ -90,7 +90,7 @@ class LayoutMenu(QMenu):
|
||||
self.items = []
|
||||
if parent is None:
|
||||
buttons = [
|
||||
QPushButton(QIcon(I(i + '.png')), i, self)
|
||||
QPushButton(QIcon.ic(i + '.png'), i, self)
|
||||
for i in 'search tags cover_flow grid book'.split()]
|
||||
for b in buttons:
|
||||
b.setVisible(False), b.setCheckable(True), b.setChecked(b.text() in 'tags grid')
|
||||
|
@ -717,13 +717,13 @@ class CcBoolDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
||||
def createEditor(self, parent, option, index):
|
||||
editor = DelegateCB(parent)
|
||||
items = [_('Yes'), _('No'), _('Undefined')]
|
||||
icons = [I('ok.png'), I('list_remove.png'), I('blank.png')]
|
||||
icons = ['ok.png', 'list_remove.png', 'blank.png']
|
||||
if not index.model().db.new_api.pref('bools_are_tristate'):
|
||||
items = items[:-1]
|
||||
icons = icons[:-1]
|
||||
self.longest_text = ''
|
||||
for icon, text in zip(icons, items):
|
||||
editor.addItem(QIcon(icon), text)
|
||||
editor.addItem(QIcon.ic(icon), text)
|
||||
if len(text) > len(self.longest_text):
|
||||
self.longest_text = text
|
||||
return editor
|
||||
|
@ -672,7 +672,7 @@ class CompareMany(QDialog):
|
||||
if self.total > 1:
|
||||
b.setToolTip(_('Move to next [%s]') % self.next_action.shortcut().toString(QKeySequence.SequenceFormat.NativeText))
|
||||
self.next_action.triggered.connect(b.click)
|
||||
b.setIcon(QIcon(I('forward.png' if self.total > 1 else 'ok.png')))
|
||||
b.setIcon(QIcon.ic('forward.png' if self.total > 1 else 'ok.png'))
|
||||
connect_lambda(b.clicked, self, lambda self: self.next_item(True))
|
||||
b.setDefault(True), b.setAutoDefault(True)
|
||||
self.bbh = h = QHBoxLayout()
|
||||
|
@ -35,7 +35,7 @@ class Model(QStringListModel):
|
||||
if role == Qt.ItemDataRole.DecorationRole:
|
||||
w = self.widgets[index.row()]
|
||||
if w.ICON:
|
||||
return (QIcon(w.ICON))
|
||||
return QIcon.ic(w.ICON)
|
||||
return QStringListModel.data(self, index, role)
|
||||
|
||||
|
||||
|
@ -95,7 +95,7 @@ class TitleBar(QWidget):
|
||||
self.show_msg()
|
||||
|
||||
def show_plugin(self, plugin=None):
|
||||
self.icon.set_icon(QIcon(I('lt.png') if plugin is None else plugin.icon))
|
||||
self.icon.set_icon(QIcon.ic('lt.png' if plugin is None else plugin.icon))
|
||||
self.title.setText('<h1>' + (_('Preferences') if plugin is None else plugin.gui_name))
|
||||
|
||||
def show_msg(self, msg=None):
|
||||
@ -136,7 +136,7 @@ class Category(QWidget): # {{{
|
||||
self.actions = []
|
||||
for p in plugins:
|
||||
target = partial(self.triggered, p)
|
||||
ac = self.bar.addAction(QIcon(p.icon), p.gui_name.replace('&', '&&'), target)
|
||||
ac = self.bar.addAction(QIcon.ic(p.icon), p.gui_name.replace('&', '&&'), target)
|
||||
ac.setToolTip(textwrap.fill(p.description))
|
||||
ac.setWhatsThis(textwrap.fill(p.description))
|
||||
ac.setStatusTip(p.description)
|
||||
@ -327,7 +327,7 @@ class Preferences(QDialog):
|
||||
self.setWindowTitle(__appname__ + ' - ' + _('Preferences') + ' - ' + plugin.gui_name)
|
||||
self.showing_widget.restart_now.connect(self.restart_now)
|
||||
self.title_bar.show_plugin(plugin)
|
||||
self.setWindowIcon(QIcon(plugin.icon))
|
||||
self.setWindowIcon(QIcon.ic(plugin.icon))
|
||||
|
||||
self.bb.button(QDialogButtonBox.StandardButton.Close).setVisible(False)
|
||||
self.wizard_button.setVisible(False)
|
||||
|
@ -39,7 +39,7 @@ class PluginModel(QAbstractItemModel, AdaptSQP): # {{{
|
||||
SearchQueryParser.__init__(self, ['all'])
|
||||
self.show_only_user_plugins = show_only_user_plugins
|
||||
self.icon = QIcon.ic('plugins.png')
|
||||
p = QIcon(self.icon).pixmap(64, 64, QIcon.Mode.Disabled, QIcon.State.On)
|
||||
p = self.icon.pixmap(64, 64, QIcon.Mode.Disabled, QIcon.State.On)
|
||||
self.disabled_icon = QIcon(p)
|
||||
self._p = p
|
||||
self.populate()
|
||||
|
@ -455,9 +455,9 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
tt = _('The lookup/search name is "{0}"{1}').format(key, cust_desc)
|
||||
|
||||
if self.category_custom_icons.get(key, None) is None:
|
||||
self.category_custom_icons[key] = QIcon(I(
|
||||
self.category_custom_icons[key] = QIcon.ic(
|
||||
category_icon_map['gst'] if is_gst else category_icon_map.get(
|
||||
key, (category_icon_map['user:'] if key.startswith('@') else category_icon_map['custom:']))))
|
||||
key, (category_icon_map['user:'] if key.startswith('@') else category_icon_map['custom:'])))
|
||||
|
||||
if key.startswith('@'):
|
||||
path_parts = [p for p in key.split('.')]
|
||||
|
@ -711,7 +711,7 @@ class TagsView(QTreeView): # {{{
|
||||
partial(self.context_menu_handler, action='show', category=col))
|
||||
ic = self.model().category_custom_icons.get(col)
|
||||
if ic:
|
||||
ac.setIcon(QIcon(ic))
|
||||
ac.setIcon(QIcon.ic(ic))
|
||||
m.addSeparator()
|
||||
m.addAction(_('All categories'),
|
||||
partial(self.context_menu_handler, action='defaults')).setIcon(QIcon.ic('plusplus.png'))
|
||||
@ -948,7 +948,7 @@ class TagsView(QTreeView): # {{{
|
||||
key=key))
|
||||
ic = self.model().category_custom_icons.get(key)
|
||||
if ic:
|
||||
ac.setIcon(QIcon(ic))
|
||||
ac.setIcon(QIcon.ic(ic))
|
||||
if fm['datatype'] == 'enumeration':
|
||||
self.context_menu.addAction(_('Edit permissible values for %s')%category,
|
||||
partial(self.context_menu_handler, action='edit_enum',
|
||||
@ -968,7 +968,7 @@ class TagsView(QTreeView): # {{{
|
||||
index=tag.id))
|
||||
ic = self.model().category_custom_icons.get(key)
|
||||
if ic:
|
||||
ac.setIcon(QIcon(ic))
|
||||
ac.setIcon(QIcon.ic(ic))
|
||||
elif key == 'search':
|
||||
self.context_menu.addAction(_('Manage Saved searches'),
|
||||
partial(self.context_menu_handler, action='manage_searches',
|
||||
|
@ -1007,7 +1007,7 @@ class LayoutButton(QToolButton):
|
||||
def __init__(self, icon, text, splitter=None, parent=None, shortcut=None):
|
||||
QToolButton.__init__(self, parent)
|
||||
self.label = text
|
||||
self.setIcon(QIcon(icon))
|
||||
self.setIcon(QIcon.ic(icon))
|
||||
self.setCheckable(True)
|
||||
self.icname = os.path.basename(icon).rpartition('.')[0]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user