def __init__(self, win): self.xmlfile = os.path.join(_sponsordir, 'sponsors.xml') self.win = win self.needToAsk = False self.downloadSponsors = False threading.Thread.__init__(self) if not self.refreshWanted(): return if env.prefs[sponsor_permanent_permission_prefs_key]: # We have a permanent answer so no need for a dialog if env.prefs[sponsor_download_permission_prefs_key]: self.downloadSponsors = True return self.needToAsk = True QDialog.__init__(self, None) self.setObjectName("Permission") self.setModal(True) #This fixes bug 2296. Mitigates bug 2297 layout = QGridLayout() self.setLayout(layout) layout.setMargin(0) layout.setSpacing(0) layout.setObjectName("PermissionLayout") self.text_browser = QTextBrowser(self) self.text_browser.setObjectName("text_browser") layout.addWidget(self.text_browser, 0, 0, 1, 4) self.text_browser.setMinimumSize(400, 80) self.setWindowTitle('May we use your network connection?') self.setWindowIcon(geticon('ui/border/MainWindow.png')) self.text_browser.setPlainText(self.text) self.accept_button = QPushButton(self) self.accept_button.setObjectName("accept_button") self.accept_button.setText("Always OK") self.accept_once_button = QPushButton(self) self.accept_once_button.setObjectName("accept_once_button") self.accept_once_button.setText("OK now") self.decline_once_button = QPushButton(self) self.decline_once_button.setObjectName("decline_once_button") self.decline_once_button.setText("Not now") self.decline_always_button = QPushButton(self) self.decline_always_button.setObjectName("decline_always_button") self.decline_always_button.setText("Never") layout.addWidget(self.accept_button, 1, 0) layout.addWidget(self.accept_once_button, 1, 1) layout.addWidget(self.decline_once_button, 1, 2) layout.addWidget(self.decline_always_button, 1, 3) self.connect(self.accept_button, SIGNAL("clicked()"), self.acceptAlways) self.connect(self.accept_once_button, SIGNAL("clicked()"), self.acceptJustOnce) self.connect(self.decline_once_button, SIGNAL("clicked()"), self.declineJustOnce) self.connect(self.decline_always_button, SIGNAL("clicked()"), self.declineAlways)
def setup_ui(self): self.l = l = QGridLayout(self) self.setLayout(l) self.bb.setStandardButtons(self.bb.Close) self.rearrange_button = b = self.bb.addButton( _('Re-arrange favorites'), self.bb.ActionRole) b.setCheckable(True) b.setChecked(False) b.setVisible(False) b.setDefault(True) self.splitter = s = QSplitter(self) s.setChildrenCollapsible(False) self.search = h = HistoryLineEdit2(self) h.setToolTip( textwrap.fill( _('Search for unicode characters by using the English names or nicknames.' ' You can also search directly using a character code. For example, the following' ' searches will all yield the no-break space character: U+A0, nbsp, no-break' ))) h.initialize('charmap_search') h.setPlaceholderText(_('Search by name, nickname or character code')) self.search_button = b = QPushButton(_('&Search')) h.returnPressed.connect(self.do_search) b.clicked.connect(self.do_search) self.clear_button = cb = QToolButton(self) cb.setIcon(QIcon(I('clear_left.png'))) cb.setText(_('Clear search')) cb.clicked.connect(self.clear_search) l.addWidget(h), l.addWidget(b, 0, 1), l.addWidget(cb, 0, 2) self.category_view = CategoryView(self) l.addWidget(s, 1, 0, 1, 3) self.char_view = CharView(self) self.rearrange_button.toggled[bool].connect( self.set_allow_drag_and_drop) self.category_view.category_selected.connect(self.show_chars) self.char_view.show_name.connect(self.show_char_info) self.char_view.char_selected.connect(self.char_selected) s.addWidget(self.category_view), s.addWidget(self.char_view) self.char_info = la = QLabel('\xa0') la.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) l.addWidget(la, 2, 0, 1, 3) self.rearrange_msg = la = QLabel( _('Drag and drop characters to re-arrange them. Click the re-arrange button again when you are done.' )) la.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) la.setVisible(False) l.addWidget(la, 3, 0, 1, 3) l.addWidget(self.bb, 4, 0, 1, 3) self.char_view.setFocus(Qt.OtherFocusReason)
def __init__(self, parent, db, author, series=None): QDialog.__init__(self, parent) self.db = db self.setWindowTitle(_('How many empty books?')) self._layout = QGridLayout(self) self.setLayout(self._layout) self.qty_label = QLabel(_('How many empty books should be added?')) self._layout.addWidget(self.qty_label, 0, 0, 1, 2) self.qty_spinbox = QSpinBox(self) self.qty_spinbox.setRange(1, 10000) self.qty_spinbox.setValue(1) self._layout.addWidget(self.qty_spinbox, 1, 0, 1, 2) self.author_label = QLabel(_('Set the author of the new books to:')) self._layout.addWidget(self.author_label, 2, 0, 1, 2) self.authors_combo = EditWithComplete(self) self.authors_combo.setSizeAdjustPolicy( self.authors_combo.AdjustToMinimumContentsLengthWithIcon) self.authors_combo.setEditable(True) self._layout.addWidget(self.authors_combo, 3, 0, 1, 1) self.initialize_authors(db, author) self.clear_button = QToolButton(self) self.clear_button.setIcon(QIcon(I('trash.png'))) self.clear_button.setToolTip(_('Reset author to Unknown')) self.clear_button.clicked.connect(self.reset_author) self._layout.addWidget(self.clear_button, 3, 1, 1, 1) self.series_label = QLabel(_('Set the series of the new books to:')) self._layout.addWidget(self.series_label, 4, 0, 1, 2) self.series_combo = EditWithComplete(self) self.authors_combo.setSizeAdjustPolicy( self.authors_combo.AdjustToMinimumContentsLengthWithIcon) self.series_combo.setEditable(True) self._layout.addWidget(self.series_combo, 5, 0, 1, 1) self.initialize_series(db, series) self.sclear_button = QToolButton(self) self.sclear_button.setIcon(QIcon(I('trash.png'))) self.sclear_button.setToolTip(_('Reset series')) self.sclear_button.clicked.connect(self.reset_series) self._layout.addWidget(self.sclear_button, 5, 1, 1, 1) button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) self._layout.addWidget(button_box) self.resize(self.sizeHint())
def __init__(self, parent=None): QWidget.__init__(self, parent) self.setLayout(QGridLayout(self)) self.file_list = FileList(self) self.layout().addWidget(self.file_list) self.layout().setContentsMargins(0, 0, 0, 0) for x in ('delete_requested', 'reorder_spine', 'rename_requested', 'edit_file', 'merge_requested', 'mark_requested'): getattr(self.file_list, x).connect(getattr(self, x)) for x in ('delete_done', 'select_name'): setattr(self, x, getattr(self.file_list, x))
def __init__(self, current_family, parent=None): QDialog.__init__(self, parent) self.setWindowTitle(_('Choose font family')) self.setWindowIcon(QIcon(I('font.png'))) from calibre.utils.fonts.scanner import font_scanner self.font_scanner = font_scanner self.m = QStringListModel(self) self.build_font_list() self.l = l = QGridLayout() self.setLayout(l) self.view = FontsView(self) self.view.setModel(self.m) self.view.setCurrentIndex(self.m.index(0)) if current_family: for i, val in enumerate(self.families): if icu_lower(val) == icu_lower(current_family): self.view.setCurrentIndex(self.m.index(i)) break self.view.doubleClicked.connect(self.accept, type=Qt.QueuedConnection) self.view.changed.connect(self.current_changed, type=Qt.QueuedConnection) self.faces = Typefaces(self) self.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) self.add_fonts_button = afb = self.bb.addButton( _('Add &fonts'), self.bb.ActionRole) afb.setIcon(QIcon(I('plus.png'))) afb.clicked.connect(self.add_fonts) self.ml = QLabel(_('Choose a font family from the list below:')) self.search = QLineEdit(self) self.search.setPlaceholderText(_('Search')) self.search.returnPressed.connect(self.find) self.nb = QToolButton(self) self.nb.setIcon(QIcon(I('arrow-down.png'))) self.nb.setToolTip(_('Find Next')) self.pb = QToolButton(self) self.pb.setIcon(QIcon(I('arrow-up.png'))) self.pb.setToolTip(_('Find Previous')) self.nb.clicked.connect(self.find_next) self.pb.clicked.connect(self.find_previous) l.addWidget(self.ml, 0, 0, 1, 4) l.addWidget(self.search, 1, 0, 1, 1) l.addWidget(self.nb, 1, 1, 1, 1) l.addWidget(self.pb, 1, 2, 1, 1) l.addWidget(self.view, 2, 0, 1, 3) l.addWidget(self.faces, 1, 3, 2, 1) l.addWidget(self.bb, 3, 0, 1, 4) l.setAlignment(self.faces, Qt.AlignTop) self.resize(800, 600)
def __init__(self, log, parent=None): QWidget.__init__(self, parent) self.log = log self.abort = Event() self.caches = {} self.l = l = QGridLayout() self.setLayout(l) names = [ '<b>' + p.name + '</b>' for p in metadata_plugins(['identify']) if p.is_configured() ] self.top = QLabel('<p>' + _('calibre is downloading metadata from: ') + ', '.join(names)) self.top.setWordWrap(True) l.addWidget(self.top, 0, 0) self.results_view = ResultsView(self) self.results_view.book_selected.connect(self.emit_book_selected) self.get_result = self.results_view.get_result l.addWidget(self.results_view, 1, 0) self.comments_view = Comments(self) l.addWidget(self.comments_view, 1, 1) self.results_view.show_details_signal.connect( self.comments_view.show_data) self.query = QLabel('download starting...') f = self.query.font() f.setPointSize(f.pointSize() - 2) self.query.setFont(f) self.query.setWordWrap(True) l.addWidget(self.query, 2, 0, 1, 2) self.comments_view.show_data('<h2>' + _('Please wait') + '<br><span id="dots">.</span></h2>' + ''' <script type="text/javascript"> window.onload=function(){ var dotspan = document.getElementById('dots'); window.setInterval(function(){ if(dotspan.textContent == '............'){ dotspan.textContent = '.'; } else{ dotspan.textContent += '.'; } }, 400); } </script> ''')
def create_custom_column_editors(self): w = self.central_widget.widget(1) layout = QGridLayout() self.custom_column_widgets, self.__cc_spacers = \ populate_metadata_page(layout, self.db, self.ids, parent=w, two_column=False, bulk=True) w.setLayout(layout) self.__custom_col_layouts = [layout] ans = self.custom_column_widgets for i in range(len(ans)-1): w.setTabOrder(ans[i].widgets[-1], ans[i+1].widgets[1]) for c in range(2, len(ans[i].widgets), 2): w.setTabOrder(ans[i].widgets[c-1], ans[i].widgets[c+1])
def makeControlWidgets(self, parent): """Creates control widgets for the colormap's internal parameters. "parent" is a parent widget. Returns None if no controls are required""" top = QWidget(parent) layout = QGridLayout(top) layout.setContentsMargins(0, 0, 0, 0) for irow, icol, control in ((0, 0, self.gamma), (0, 1, self.color), (1, 0, self.cycles), (1, 1, self.hue)): control.makeControlWidgets(top, layout, irow, icol) QObject.connect(control, SIGNAL("valueChanged"), self.emitChange) QObject.connect(control, SIGNAL("valueMoved"), self.emitPreview) return top
def __init__(self, parent): QDialog.__init__(self, parent) self.setAttribute(Qt.WA_DeleteOnClose, False) self.setWindowIcon(QIcon(I('dialog_question.png'))) self.questions = [] self._l = l = QGridLayout(self) self.setLayout(l) self.icon_label = ic = QLabel(self) ic.setPixmap(QPixmap(I('dialog_question.png'))) self.msg_label = msg = QLabel('some random filler text') msg.setWordWrap(True) ic.setMaximumWidth(110) ic.setMaximumHeight(100) ic.setScaledContents(True) ic.setStyleSheet('QLabel { margin-right: 10px }') self.bb = QDialogButtonBox() self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) self.log_button = self.bb.addButton(_('View log'), self.bb.ActionRole) self.log_button.setIcon(QIcon(I('debug.png'))) self.log_button.clicked.connect(self.show_log) self.copy_button = self.bb.addButton(_('&Copy to clipboard'), self.bb.ActionRole) self.copy_button.clicked.connect(self.copy_to_clipboard) self.action_button = self.bb.addButton('', self.bb.ActionRole) self.action_button.clicked.connect(self.action_clicked) self.show_det_msg = _('Show &details') self.hide_det_msg = _('Hide &details') self.det_msg_toggle = self.bb.addButton(self.show_det_msg, self.bb.ActionRole) self.det_msg_toggle.clicked.connect(self.toggle_det_msg) self.det_msg_toggle.setToolTip( _('Show detailed information about this error')) self.det_msg = QPlainTextEdit(self) self.det_msg.setReadOnly(True) self.bb.setStandardButtons(self.bb.Yes | self.bb.No) self.bb.button(self.bb.Yes).setDefault(True) self.checkbox = QCheckBox('', self) l.addWidget(ic, 0, 0, 1, 1) l.addWidget(msg, 0, 1, 1, 1) l.addWidget(self.checkbox, 1, 0, 1, 2) l.addWidget(self.det_msg, 2, 0, 1, 2) l.addWidget(self.bb, 3, 0, 1, 2) self.ask_question.connect(self.do_ask_question, type=Qt.QueuedConnection)
def __init__(self, parent, copy_fmt): QWidget.__init__(self, parent) self.dialog = parent self.copy_fmt = copy_fmt self.changed = False self.l = l = QGridLayout() self.setLayout(l) self.cover_from_format_button = QToolButton(self) self.cover_from_format_button.setToolTip( _('Set the cover for the book from the selected format')) self.cover_from_format_button.setIcon(QIcon(I('book.png'))) self.cover_from_format_button.setIconSize(QSize(32, 32)) self.metadata_from_format_button = QToolButton(self) self.metadata_from_format_button.setIcon(QIcon(I('edit_input.png'))) self.metadata_from_format_button.setIconSize(QSize(32, 32)) self.metadata_from_format_button.setToolTip( _('Set metadata for the book from the selected format')) self.add_format_button = QToolButton(self) self.add_format_button.setIcon(QIcon(I('add_book.png'))) self.add_format_button.setIconSize(QSize(32, 32)) self.add_format_button.clicked.connect(self.add_format) self.add_format_button.setToolTip(_('Add a format to this book')) self.remove_format_button = QToolButton(self) self.remove_format_button.setIcon(QIcon(I('trash.png'))) self.remove_format_button.setIconSize(QSize(32, 32)) self.remove_format_button.clicked.connect(self.remove_format) self.remove_format_button.setToolTip( _('Remove the selected format from this book')) self.formats = FormatList(self) self.formats.setAcceptDrops(True) self.formats.formats_dropped.connect(self.formats_dropped) self.formats.restore_fmt.connect(self.restore_fmt) self.formats.delete_format.connect(self.remove_format) self.formats.itemDoubleClicked.connect(self.show_format) self.formats.setDragDropMode(self.formats.DropOnly) self.formats.setIconSize(QSize(32, 32)) self.formats.setMaximumWidth(200) l.addWidget(self.cover_from_format_button, 0, 0, 1, 1) l.addWidget(self.metadata_from_format_button, 2, 0, 1, 1) l.addWidget(self.add_format_button, 0, 2, 1, 1) l.addWidget(self.remove_format_button, 2, 2, 1, 1) l.addWidget(self.formats, 0, 1, 3, 1) self.temp_files = []
def __init__(self, ids, parent): QDialog.__init__(self, parent) self.setWindowTitle(_('Schedule download?')) self.setWindowIcon(QIcon(I('dialog_question.png'))) l = self.l = QGridLayout() self.setLayout(l) i = QLabel(self) i.setPixmap(QPixmap(I('dialog_question.png'))) l.addWidget(i, 0, 0) t = QLabel( '<p>'+_('The download of metadata for the <b>%d selected book(s)</b> will' ' run in the background. Proceed?')%len(ids) + '<p>'+_('You can monitor the progress of the download ' 'by clicking the rotating spinner in the bottom right ' 'corner.') + '<p>'+_('When the download completes you will be asked for' ' confirmation before calibre applies the downloaded metadata.') ) t.setWordWrap(True) l.addWidget(t, 0, 1) l.setColumnStretch(0, 1) l.setColumnStretch(1, 100) self.identify = self.covers = True self.bb = QDialogButtonBox(QDialogButtonBox.Cancel) self.bb.rejected.connect(self.reject) b = self.bb.addButton(_('Download only &metadata'), self.bb.AcceptRole) b.clicked.connect(self.only_metadata) b.setIcon(QIcon(I('edit_input.png'))) b = self.bb.addButton(_('Download only &covers'), self.bb.AcceptRole) b.clicked.connect(self.only_covers) b.setIcon(QIcon(I('default_cover.png'))) b = self.b = self.bb.addButton(_('&Configure download'), self.bb.ActionRole) b.setIcon(QIcon(I('config.png'))) b.clicked.connect(partial(show_config, parent, self)) l.addWidget(self.bb, 1, 0, 1, 2) b = self.bb.addButton(_('Download &both'), self.bb.AcceptRole) b.clicked.connect(self.accept) b.setDefault(True) b.setAutoDefault(True) b.setIcon(QIcon(I('ok.png'))) self.resize(self.sizeHint()) b.setFocus(Qt.OtherFocusReason)
def __init__(self, service, parent): QDialog.__init__(self, parent) self.l = l = QGridLayout() self.setLayout(l) self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) self.tl = QLabel(('<p>' + _( 'Setup sending email using' ) + ' <b>{name}</b><p>' + _( 'If you don\'t have an account, you can sign up for a free {name} email ' 'account at <a href="http://{url}">http://{url}</a>. {extra}') ).format(**service)) l.addWidget(self.tl, 0, 0, 3, 0) self.tl.setWordWrap(True) self.tl.setOpenExternalLinks(True) for name, label in ( ['from_', _('Your %s &email address:')], ['username', _('Your %s &username:'******'password', _('Your %s &password:'******'name']) le = QLineEdit(self) setattr(self, name, le) setattr(self, name + '_label', la) r = l.rowCount() l.addWidget(la, r, 0) l.addWidget(le, r, 1) la.setBuddy(le) if name == 'password': self.ptoggle = QCheckBox(_('&Show password'), self) l.addWidget(self.ptoggle, r, 2) self.ptoggle.stateChanged.connect( lambda s: self.password.setEchoMode( self.password.Normal if s == Qt.Checked else self.password.Password)) self.username.setText(service['username']) self.password.setEchoMode(self.password.Password) self.bl = QLabel('<p>' + _( 'If you plan to use email to send books to your Kindle, remember to' ' add the your %s email address to the allowed email addresses in your ' 'Amazon.com Kindle management page.') % service['name']) self.bl.setWordWrap(True) l.addWidget(self.bl, l.rowCount(), 0, 3, 0) l.addWidget(bb, l.rowCount(), 0, 3, 0) self.setWindowTitle(_('Setup') + ' ' + service['name']) self.resize(self.sizeHint()) self.service = service
def __init__(self, parent=None): QWidget.__init__(self, parent) self.setLayout(QGridLayout(self)) self.file_list = FileList(self) self.layout().addWidget(self.file_list) self.layout().setContentsMargins(0, 0, 0, 0) self.forwarded_signals = { k for k, o in vars(self.file_list.__class__).iteritems() if isinstance(o, pyqtSignal) and '_' in k and not hasattr(self, k) } for x in ('delete_done', 'select_name', 'request_edit', 'mark_name_as_current', 'clear_currently_edited_name'): setattr(self, x, getattr(self.file_list, x))
def __init__(self, parent, modal=True, flags=Qt.WindowFlags()): QDialog.__init__(self, parent, flags) self.setModal(modal) self.setWindowTitle("Add FITS brick") lo = QVBoxLayout(self) lo.setMargin(10) lo.setSpacing(5) # file selector self.wfile = FileSelector(self, label="FITS filename:", dialog_label="FITS file", default_suffix="fits", file_types="FITS files (*.fits *.FITS)", file_mode=QFileDialog.ExistingFile) lo.addWidget(self.wfile) # overwrite or add mode lo1 = QGridLayout() lo.addLayout(lo1) lo1.setContentsMargins(0, 0, 0, 0) lo1.addWidget(QLabel("Padding factor:", self), 0, 0) self.wpad = QLineEdit("2", self) self.wpad.setValidator(QDoubleValidator(self)) lo1.addWidget(self.wpad, 0, 1) lo1.addWidget(QLabel("Assign source name:", self), 1, 0) self.wname = QLineEdit(self) lo1.addWidget(self.wname, 1, 1) # OK/cancel buttons lo.addSpacing(10) lo2 = QHBoxLayout() lo.addLayout(lo2) lo2.setContentsMargins(0, 0, 0, 0) lo2.setMargin(5) self.wokbtn = QPushButton("OK", self) self.wokbtn.setMinimumWidth(128) QObject.connect(self.wokbtn, SIGNAL("clicked()"), self.accept) self.wokbtn.setEnabled(False) cancelbtn = QPushButton("Cancel", self) cancelbtn.setMinimumWidth(128) QObject.connect(cancelbtn, SIGNAL("clicked()"), self.reject) lo2.addWidget(self.wokbtn) lo2.addStretch(1) lo2.addWidget(cancelbtn) self.setMinimumWidth(384) # signals QObject.connect(self.wfile, SIGNAL("filenameSelected"), self._fileSelected) # internal state self.qerrmsg = QErrorMessage(self)
def __init__(self, fm, parent=None): QWidget.__init__(self, parent) self.fm = fm self.action_map = self.ACTION_MAP self.l = l = QGridLayout(self) self.setLayout(l) texts = _('If the ___ column ___ values') try: one, two, three = texts.split('___') except: one, two, three = 'If the ', ' column ', ' value ' self.l1 = l1 = QLabel(one) l.addWidget(l1, 0, 0) self.column_box = QComboBox(self) l.addWidget(self.column_box, 0, 1) self.l2 = l2 = QLabel(two) l.addWidget(l2, 0, 2) self.action_box = QComboBox(self) l.addWidget(self.action_box, 0, 3) self.l3 = l3 = QLabel(three) l.addWidget(l3, 0, 4) self.value_box = QLineEdit(self) l.addWidget(self.value_box, 0, 5) self.column_box.addItem('', '') for key in sorted( conditionable_columns(fm), key=sort_key): self.column_box.addItem(key, key) self.column_box.setCurrentIndex(0) self.column_box.currentIndexChanged.connect(self.init_action_box) self.action_box.currentIndexChanged.connect(self.init_value_box) for b in (self.column_box, self.action_box): b.setSizeAdjustPolicy(b.AdjustToMinimumContentsLengthWithIcon) b.setMinimumContentsLength(15)
def __init__(self): QWidget.__init__(self, ctx.mainScreen) self.setObjectName("InformationWindow") self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.setFixedHeight(50) self.setMaximumWidth(800) self.setStyleSheet(""" QFrame#frame { border: 1px solid rgba(255,255,255,30); /*border-radius: 4px;*/ background-color: rgba(0,0,0,100);} QLabel { border:none; color:#FFFFFF;} QProgressBar { border: 1px solid white;} QProgressBar::chunk { background-color: #F1610D; width: 0.5px;} """) self.gridlayout = QGridLayout(self) self.frame = QFrame(self) self.frame.setObjectName("frame") self.horizontalLayout = QHBoxLayout(self.frame) self.horizontalLayout.setContentsMargins(10, 0, 10, 0) # Spinner self.spinner = QLabel(self.frame) self.spinner.setMinimumSize(QSize(16, 16)) self.spinner.setMaximumSize(QSize(16, 16)) self.spinner.setIndent(6) self.movie = QMovie(':/images/working.mng') self.spinner.setMovie(self.movie) self.movie.start() self.horizontalLayout.addWidget(self.spinner) # Message self.label = QLabel(self.frame) self.label.setAlignment(Qt.AlignCenter) self.label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.icon = QLabel(self.frame) self.icon.setFixedWidth(16) self.icon.setFixedHeight(16) self.horizontalLayout.setSpacing(10) self.horizontalLayout.addWidget(self.icon) self.horizontalLayout.addWidget(self.label) self.gridlayout.addWidget(self.frame, 0, 0, 1, 1)
def __init__(self, log, current_cover, parent=None): QWidget.__init__(self, parent) self.log = log self.abort = Event() self.l = l = QGridLayout() self.setLayout(l) self.msg = QLabel() self.msg.setWordWrap(True) l.addWidget(self.msg, 0, 0) self.covers_view = CoversView(current_cover, self) self.covers_view.chosen.connect(self.chosen) l.addWidget(self.covers_view, 1, 0) self.continue_processing = True
def __init__(self, parent=None): QDialog.__init__(self, parent) self._layout = l = QGridLayout(self) self.setLayout(l) self.setWindowIcon(QIcon(I('mail.png'))) self.setWindowTitle(_('Select recipients')) self.recipients = r = QListWidget(self) l.addWidget(r, 0, 0, 1, -1) self.la = la = QLabel(_('Add a new recipient:')) la.setStyleSheet('QLabel { font-weight: bold }') l.addWidget(la, l.rowCount(), 0, 1, -1) self.labels = tuple( map(QLabel, (_('&Address'), _('A&lias'), _('&Formats'), _('&Subject')))) tooltips = ( _('The email address of the recipient'), _('The optional alias (simple name) of the recipient'), _('Formats to email. The first matching one will be sent (comma separated list)' ), _('The optional subject for email sent to this recipient')) for i, name in enumerate(('address', 'alias', 'formats', 'subject')): c = i % 2 row = l.rowCount() - c self.labels[i].setText(unicode(self.labels[i].text()) + ':') l.addWidget(self.labels[i], row, (2 * c)) le = QLineEdit(self) le.setToolTip(tooltips[i]) setattr(self, name, le) self.labels[i].setBuddy(le) l.addWidget(le, row, (2 * c) + 1) self.formats.setText(prefs['output_format'].upper()) self.add_button = b = QPushButton(QIcon(I('plus.png')), _('&Add recipient'), self) b.clicked.connect(self.add_recipient) l.addWidget(b, l.rowCount(), 0, 1, -1) self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) l.addWidget(bb, l.rowCount(), 0, 1, -1) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) self.setMinimumWidth(500) self.setMinimumHeight(400) self.resize(self.sizeHint()) self.init_list()
def __init__(self, db, duplicates, parent=None): QDialog.__init__(self, parent) self.l = l = QGridLayout() self.setLayout(l) t = ngettext('Duplicate found', 'Duplicates found', len(duplicates)) if len(duplicates) > 1: t = '%d %s' % (len(duplicates), t) self.setWindowTitle(t) self.i = i = QIcon(I('dialog_question.png')) self.setWindowIcon(i) self.l1 = l1 = QLabel() self.l2 = l2 = QLabel( _('Books with the same titles as the following already ' 'exist in calibre. Select which books you want added anyway.')) l2.setWordWrap(True) l1.setPixmap(i.pixmap(128, 128)) l.addWidget(l1, 0, 0) l.addWidget(l2, 0, 1) self.dup_list = dl = QTreeWidget(self) l.addWidget(dl, 1, 0, 1, 2) dl.setHeaderHidden(True) dl.addTopLevelItems(list(self.process_duplicates(db, duplicates))) dl.expandAll() dl.setIndentation(30) self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) l.addWidget(bb, 2, 0, 1, 2) l.setColumnStretch(1, 10) self.ab = ab = bb.addButton(_('Select &all'), bb.ActionRole) ab.clicked.connect(self.select_all), ab.setIcon(QIcon(I('plus.png'))) self.nb = ab = bb.addButton(_('Select &none'), bb.ActionRole) ab.clicked.connect(self.select_none), ab.setIcon(QIcon(I('minus.png'))) self.cb = cb = bb.addButton(_('&Copy to clipboard'), bb.ActionRole) cb.setIcon(QIcon(I('edit-copy.png'))) cb.clicked.connect(self.copy_to_clipboard) self.resize(self.sizeHint()) geom = gprefs.get('duplicates-question-dialog-geometry', None) if geom is not None: self.restoreGeometry(geom) self.exec_()
def __init__(self, parent=None): QFrame.__init__(self, parent) self.setFocusPolicy(Qt.StrongFocus) self.setAutoFillBackground(True) self.capture = 0 self.setFrameShape(self.StyledPanel) self.setFrameShadow(self.Raised) self._layout = l = QGridLayout(self) self.setLayout(l) self.header = QLabel('') l.addWidget(self.header, 0, 0, 1, 2) self.use_default = QRadioButton('') self.use_custom = QRadioButton(_('Custom')) l.addWidget(self.use_default, 1, 0, 1, 3) l.addWidget(self.use_custom, 2, 0, 1, 3) self.use_custom.toggled.connect(self.custom_toggled) off = 2 for which in (1, 2): text = _('&Shortcut:') if which == 1 else _('&Alternate shortcut:') la = QLabel(text) la.setStyleSheet('QLabel { margin-left: 1.5em }') l.addWidget(la, off + which, 0, 1, 3) setattr(self, 'label%d' % which, la) button = QPushButton(_('None'), self) button.clicked.connect(partial(self.capture_clicked, which=which)) button.keyPressEvent = partial(self.key_press_event, which=which) setattr(self, 'button%d' % which, button) clear = QToolButton(self) clear.setIcon(QIcon(I('clear_left.png'))) clear.clicked.connect(partial(self.clear_clicked, which=which)) setattr(self, 'clear%d' % which, clear) l.addWidget(button, off + which, 1, 1, 1) l.addWidget(clear, off + which, 2, 1, 1) la.setBuddy(button) self.done_button = doneb = QPushButton(_('Done'), self) l.addWidget(doneb, 0, 2, 1, 1) doneb.clicked.connect(lambda: self.editing_done.emit(self)) l.setColumnStretch(0, 100) self.custom_toggled(False)
def __init__(self, parent): QDialog.__init__(self, parent) self.setAttribute(Qt.WA_DeleteOnClose, False) self.queue = [] self.do_pop.connect(self.pop, type=Qt.QueuedConnection) self._layout = l = QGridLayout() self.setLayout(l) self.icon = QIcon(I('dialog_error.png')) self.setWindowIcon(self.icon) self.icon_label = QLabel() self.icon_label.setPixmap(self.icon.pixmap(68, 68)) self.icon_label.setMaximumSize(QSize(68, 68)) self.msg_label = QLabel('<p> ') self.msg_label.setStyleSheet('QLabel { margin-top: 1ex; }') self.msg_label.setWordWrap(True) self.msg_label.setTextFormat(Qt.RichText) self.det_msg = QPlainTextEdit(self) self.det_msg.setVisible(False) self.bb = QDialogButtonBox(QDialogButtonBox.Close, parent=self) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) self.ctc_button = self.bb.addButton(_('&Copy to clipboard'), self.bb.ActionRole) self.ctc_button.clicked.connect(self.copy_to_clipboard) self.show_det_msg = _('Show &details') self.hide_det_msg = _('Hide &details') self.det_msg_toggle = self.bb.addButton(self.show_det_msg, self.bb.ActionRole) self.det_msg_toggle.clicked.connect(self.toggle_det_msg) self.det_msg_toggle.setToolTip( _('Show detailed information about this error')) self.suppress = QCheckBox(self) l.addWidget(self.icon_label, 0, 0, 1, 1) l.addWidget(self.msg_label, 0, 1, 1, 1) l.addWidget(self.det_msg, 1, 0, 1, 2) l.addWidget(self.suppress, 2, 0, 1, 2, Qt.AlignLeft | Qt.AlignBottom) l.addWidget(self.bb, 3, 0, 1, 2, Qt.AlignRight | Qt.AlignBottom) l.setColumnStretch(1, 100) self.setModal(False) self.suppress.setVisible(False) self.do_resize()
def __init__(self, val): QWidget.__init__(self) self.t = t = QLineEdit(self) t.setText(val or '') t.setCursorPosition(0) self.setMinimumWidth(400) self.l = l = QGridLayout(self) self.setLayout(l) self.m = m = QLabel( '<p>' + _('''<b>Save &template</b> to control the filename and location of files sent to the device:''')) m.setWordWrap(True) m.setBuddy(t) l.addWidget(m, 0, 0, 1, 2) l.addWidget(t, 1, 0, 1, 1) b = self.b = QPushButton(_('&Template editor')) l.addWidget(b, 1, 1, 1, 1) b.clicked.connect(self.edit_template)
def __init__(self, all_authors, current_authors, parent=None): QDialog.__init__(self, parent) self.l = l = QGridLayout() self.setLayout(l) self.setWindowTitle(_('Edit authors')) self.la = QLabel( _('Edit the authors for this book. You can drag and drop to re-arrange authors' )) self.la.setWordWrap(True) l.addWidget(self.la, 0, 0, 1, 3) self.al = al = List(all_authors, self) al.addItems(current_authors) l.addWidget(al, 1, 0, 1, 3) self.author = a = Edit(self) init_line_edit(a, all_authors) a.lineEdit().setPlaceholderText(_('Enter an author to add')) a.returnPressed.connect(self.add_author) l.addWidget(a, 2, 0) self.ab = b = QPushButton(_('&Add')) b.setIcon(QIcon(I('plus.png'))) l.addWidget(b, 2, 1) b.clicked.connect(self.add_author) self.db = b = QPushButton(_('&Remove selected')) l.addWidget(b, 2, 2) b.setIcon(QIcon(I('minus.png'))) b.clicked.connect(self.al.delete_selected) self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) l.addWidget(bb, 3, 0, 1, 3) l.setColumnStretch(0, 10) self.resize(self.sizeHint() + QSize(150, 100)) geom = gprefs.get('authors-edit-geometry', None) if geom is not None: self.restoreGeometry(geom) self.author.setFocus(Qt.OtherFocusReason)
def __init__(self): QWidget.__init__(self) self.layout = QGridLayout() self.layout.setSpacing(10) self.setLayout(self.layout) self.key_label = QLabel('&api key:') self.key_msg = QLineEdit(self) self.key_msg.setText(PREFS['api_key']) self.layout.addWidget(self.key_label, 1, 0) self.layout.addWidget(self.key_msg, 1, 1) self.key_label.setBuddy(self.key_msg) self.threads_label = QLabel('&worker_threads:') self.threads_msg = QLineEdit(self) self.threads_msg.setText(unicode(PREFS['worker_threads'])) self.layout.addWidget(self.threads_label, 2, 0) self.layout.addWidget(self.threads_msg, 2, 1) self.threads_label.setBuddy(self.threads_msg)
def __init__(self, plugin_action, prefs): QWidget.__init__(self) self.plugin_action = plugin_action self.prefs = prefs self.layout = QGridLayout() self.setLayout(self.layout) accounts = self.prefs[self.prefs.ACCOUNTS] # Copy any data necessary into the prefs object # The primary account, as configured in the GUI above account = accounts.get('0', {}) self.labelUrlBase = QLabel(_('URL')) self.layout.addWidget(self.labelUrlBase, 0, 0) self.urlbase = QLabel() if prefs[prefs.URLBASE] is not None: self.urlbase.setText(prefs[prefs.URLBASE]) self.layout.addWidget(self.urlbase, 0, 1) self.labelUrlBase.setBuddy(self.urlbase) self.labelUserName = QLabel(_('Username')) self.layout.addWidget(self.labelUserName, 1, 0) self.username = QLineEdit(self) if account.get(prefs.USERNAME) is not None: self.username.setText(account[prefs.USERNAME]) self.layout.addWidget(self.username, 1, 1) self.labelUserName.setBuddy(self.username) self.labelPassword = QLabel(_('Password')) self.layout.addWidget(self.labelPassword, 2, 0) self.password = QLineEdit(self) if account.get(prefs.OBFUSCATED_PASSWORD) is not None: decrypted = prefs.decrypt_password( account[prefs.OBFUSCATED_PASSWORD]) self.password.setText(decrypted) self.layout.addWidget(self.password, 2, 1) self.labelPassword.setBuddy(self.password)
def __init__(self, calibre_version, plugin_updates, parent=None): QDialog.__init__(self, parent) self.setAttribute(Qt.WA_QuitOnClose, False) self.resize(400, 250) self.l = QGridLayout() self.setLayout(self.l) self.logo = QLabel() self.logo.setMaximumWidth(110) self.logo.setPixmap( QPixmap(I('lt.png')).scaled(100, 100, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)) ver = calibre_version if ver.endswith('.0'): ver = ver[:-2] self.label = QLabel(('<p>' + _( 'New version <b>%(ver)s</b> of %(app)s is available for download. ' 'See the <a href="http://calibre-ebook.com/whats-new' '">new features</a>.')) % dict(app=__appname__, ver=ver)) self.label.setOpenExternalLinks(True) self.label.setWordWrap(True) self.setWindowTitle(_('Update available!')) self.setWindowIcon(QIcon(I('lt.png'))) self.l.addWidget(self.logo, 0, 0) self.l.addWidget(self.label, 0, 1) self.cb = QCheckBox(_('Show this notification for future updates'), self) self.l.addWidget(self.cb, 1, 0, 1, -1) self.cb.setChecked(config.get('new_version_notification')) self.cb.stateChanged.connect(self.show_future) self.bb = QDialogButtonBox(self) b = self.bb.addButton(_('&Get update'), self.bb.AcceptRole) b.setDefault(True) b.setIcon(QIcon(I('arrow-down.png'))) if plugin_updates > 0: b = self.bb.addButton(_('Update &plugins'), self.bb.ActionRole) b.setIcon(QIcon(I('plugins/plugin_updater.png'))) b.clicked.connect(self.get_plugins, type=Qt.QueuedConnection) self.bb.addButton(self.bb.Cancel) self.l.addWidget(self.bb, 2, 0, 1, -1) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) dynamic.set('update to version %s' % calibre_version, False)
def _createSponsorButton(self): """ Creates the Property Manager sponsor button, which contains a QPushButton inside of a QGridLayout inside of a QFrame. The sponsor logo image is not loaded here. """ # Sponsor button (inside a frame) self.sponsor_frame = QFrame(self) self.sponsor_frame.setFrameShape(QFrame.NoFrame) self.sponsor_frame.setFrameShadow(QFrame.Plain) SponsorFrameGrid = QGridLayout(self.sponsor_frame) SponsorFrameGrid.setMargin(PM_SPONSOR_FRAME_MARGIN) SponsorFrameGrid.setSpacing(PM_SPONSOR_FRAME_SPACING) # Has no effect. self.sponsor_btn = QPushButton(self.sponsor_frame) self.sponsor_btn.setAutoDefault(False) self.sponsor_btn.setFlat(True) self.connect(self.sponsor_btn, SIGNAL("clicked()"), self.open_sponsor_homepage) SponsorFrameGrid.addWidget(self.sponsor_btn, 0, 0, 1, 1) self.vBoxLayout.addWidget(self.sponsor_frame) button_whatsthis_widget = self.sponsor_btn #bruce 070615 bugfix -- put tooltip & whatsthis on self.sponsor_btn, # not self. # [self.sponsor_frame might be another possible place to put them.] button_whatsthis_widget.setWhatsThis("""<b>Sponsor Button</b> <p>When clicked, this sponsor logo will display a short description about a NanoEngineer-1 sponsor. This can be an official sponsor or credit given to a contributor that has helped code part or all of this command. A link is provided in the description to learn more about this sponsor.</p>""") button_whatsthis_widget.setToolTip("NanoEngineer-1 Sponsor Button") return
def __init__(self, gui): QDialog.__init__(self, gui) self.setAttribute(Qt.WA_DeleteOnClose, False) self.gui = gui self.queue = [] self._layout = l = QGridLayout() self.setLayout(l) self.icon = QIcon(I('dialog_error.png')) self.setWindowIcon(self.icon) self.icon_label = QLabel() self.icon_label.setPixmap(self.icon.pixmap(128, 128)) self.icon_label.setMaximumSize(QSize(128, 128)) self.msg_label = QLabel('<p> ') self.msg_label.setWordWrap(True) self.msg_label.setTextFormat(Qt.RichText) self.det_msg = QPlainTextEdit(self) self.det_msg.setVisible(False) self.bb = QDialogButtonBox(QDialogButtonBox.Close, parent=self) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) self.ctc_button = self.bb.addButton(_('&Copy to clipboard'), self.bb.ActionRole) self.ctc_button.clicked.connect(self.copy_to_clipboard) self.show_det_msg = _('Show &details') self.hide_det_msg = _('Hide &details') self.det_msg_toggle = self.bb.addButton(self.show_det_msg, self.bb.ActionRole) self.det_msg_toggle.clicked.connect(self.toggle_det_msg) self.det_msg_toggle.setToolTip( _('Show detailed information about this error')) l.addWidget(self.icon_label, 0, 0, 1, 1) l.addWidget(self.msg_label, 0, 1, 1, 1, Qt.AlignLeft | Qt.AlignTop) l.addWidget(self.det_msg, 1, 0, 1, 2) l.addWidget(self.bb, 2, 0, 1, 2, Qt.AlignRight | Qt.AlignBottom) self.setModal(False) self.base_height = max(200, self.sizeHint().height() + 20) self.do_resize()
def __init__(self, val, device): QWidget.__init__(self) self.t = t = QLineEdit(self) t.setText(', '.join(val or [])) t.setCursorPosition(0) self.l = l = QGridLayout(self) self.setLayout(l) self.m = m = QLabel('<p>' + _('''A <b>list of &folders</b> on the device to which to send ebooks. The first one that exists will be used:''')) m.setWordWrap(True) m.setBuddy(t) l.addWidget(m, 0, 0, 1, 2) l.addWidget(t, 1, 0) self.b = b = QToolButton() l.addWidget(b, 1, 1) b.setIcon(QIcon(I('document_open.png'))) b.clicked.connect(self.browse) b.setToolTip(_('Browse for a folder on the device')) self._device = weakref.ref(device)
def settings_dialog(self): get_label = lambda: self.wallet.get_client().features.label update_label = lambda: current_label_label.setText("Label: %s" % get_label()) d = QDialog() layout = QGridLayout(d) layout.addWidget(QLabel("Trezor Options"), 0, 0) layout.addWidget(QLabel("ID:"), 1, 0) layout.addWidget( QLabel(" %s" % self.wallet.get_client().get_device_id()), 1, 1) def modify_label(): response = QInputDialog().getText( None, "Set New Trezor Label", "New Trezor Label: (upon submission confirm on Trezor)") if not response[1]: return new_label = str(response[0]) twd.start("Please confirm label change on Trezor") status = self.wallet.get_client().apply_settings(label=new_label) twd.stop() update_label() current_label_label = QLabel() update_label() change_label_button = QPushButton("Modify") change_label_button.clicked.connect(modify_label) layout.addWidget(current_label_label, 3, 0) layout.addWidget(change_label_button, 3, 1) def remove_pin(): # twd.start("Please confirm pin removal on Trezor") try: status = self.wallet.get_client().change_pin(True) print_error(status) self.show_message(status) except Exception, e: give_error(e) finally: