def setup_store_checks(self): first_run = self.config.get('first_run', True) # Add check boxes for each store so the user # can disable searching specific stores on a # per search basis. existing = {} for n in self.store_checks: existing[n] = self.store_checks[n].isChecked() self.store_checks = {} stores_check_widget = QWidget() store_list_layout = QGridLayout() stores_check_widget.setLayout(store_list_layout) icon = QIcon(I('donate.png')) for i, x in enumerate( sorted(self.gui.istores.keys(), key=lambda x: x.lower())): cbox = QCheckBox(x) cbox.setChecked(existing.get(x, first_run)) store_list_layout.addWidget(cbox, i, 0, 1, 1) if self.gui.istores[x].base_plugin.affiliate: iw = QLabel(self) iw.setToolTip('<p>' + _( 'Buying from this store supports the calibre developer: %s</p>' ) % self.gui.istores[x].base_plugin.author + '</p>') iw.setPixmap(icon.pixmap(16, 16)) store_list_layout.addWidget(iw, i, 1, 1, 1) self.store_checks[x] = cbox store_list_layout.setRowStretch(store_list_layout.rowCount(), 10) self.store_list.setWidget(stores_check_widget) self.config['first_run'] = False
def __init__(self, title, msg='\u00a0', min=0, max=99, parent=None, cancelable=True, icon=None): QDialog.__init__(self, parent) if icon is None: self.l = l = QVBoxLayout(self) else: self.h = h = QHBoxLayout(self) self.icon = i = QLabel(self) if not isinstance(icon, QIcon): icon = QIcon(I(icon)) i.setPixmap(icon.pixmap(64)) h.addWidget(i, alignment=Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignHCenter) self.l = l = QVBoxLayout() h.addLayout(l) self.setWindowIcon(icon) self.title_label = t = QLabel(title) self.setWindowTitle(title) t.setStyleSheet('QLabel { font-weight: bold }'), t.setAlignment( Qt.AlignmentFlag.AlignCenter), t.setTextFormat( Qt.TextFormat.PlainText) l.addWidget(t) self.bar = b = QProgressBar(self) b.setMinimum(min), b.setMaximum(max), b.setValue(min) l.addWidget(b) self.message = m = QLabel(self) fm = QFontMetrics(self.font()) m.setAlignment(Qt.AlignmentFlag.AlignCenter), m.setMinimumWidth( fm.averageCharWidth() * 80), m.setTextFormat( Qt.TextFormat.PlainText) l.addWidget(m) self.msg = msg self.button_box = bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Abort, self) bb.rejected.connect(self._canceled) l.addWidget(bb) self.setWindowModality(Qt.WindowModality.ApplicationModal) self.canceled = False if not cancelable: bb.setVisible(False) self.cancelable = cancelable self.resize(self.sizeHint())
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
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)