Esempio n. 1
0
 def set_library_icon(self):
     icon = QIcon(library_icon_path())
     has_icon = not icon.isNull() and len(icon.availableSizes()) > 0
     if not has_icon:
         icon = self.original_library_icon
     self.qaction.setIcon(icon)
     self.gui.setWindowIcon(icon)
     self.remove_library_icon_action.setEnabled(has_icon)
Esempio n. 2
0
 def finalize_entry(entry):
     icon_path = entry.get('Icon')
     if icon_path:
         ic = QIcon(icon_path)
         if not ic.isNull():
             pmap = ic.pixmap(48, 48)
             if not pmap.isNull():
                 entry['icon_data'] = pixmap_to_data(pmap)
     try:
         entry['MimeType'] = tuple(entry['MimeType'])
     except KeyError:
         entry['MimeType'] = ()
     return entry
Esempio n. 3
0
 def cached_emblem(self, cache, name, raw_icon=None):
     ans = cache.get(name, False)
     if ans is not False:
         return ans
     sz = self.emblem_size
     ans = None
     if raw_icon is not None:
         ans = raw_icon.pixmap(sz, sz)
     elif name == ':ondevice':
         ans = QIcon(I('ok.png')).pixmap(sz, sz)
     elif name:
         pmap = QIcon(os.path.join(config_dir, 'cc_icons', name)).pixmap(sz, sz)
         if not pmap.isNull():
             ans = pmap
     cache[name] = ans
     return ans
Esempio n. 4
0
 def change_icon(self):
     ci = self.plist.currentItem()
     if ci is None:
         return error_dialog(self, _('No selection'), _(
             'No application selected'), show=True)
     paths = choose_images(self, 'choose-new-icon-for-open-with-program', _(
         'Choose new icon'))
     if paths:
         ic = QIcon(paths[0])
         if ic.isNull():
             return error_dialog(self, _('Invalid icon'), _(
                 'Could not load image from %s') % paths[0], show=True)
         pmap = ic.pixmap(48, 48)
         if not pmap.isNull():
             entry = ci.data(ENTRY_ROLE)
             entry['icon_data'] = pixmap_to_data(pmap)
             ci.setData(ENTRY_ROLE, entry)
             self.update_stored_config()
             ci.setIcon(ic)