def __init__(self, parent): QDialog.__init__(self, parent) self.setWindowTitle(self.tr("Connect")) # Create inputs self._hostLine = QLineEdit(self) self._hostLine.setText(DEFAULT_HOST) self._portLine = QLineEdit(self) self._portLine.setText(DEFAULT_PORT) self._databaseLine = QLineEdit(self) self._databaseLine.setText(DEFAULT_DATABASE) self._userLine = QLineEdit(self) self._userLine.setText(DEFAULT_USER) self._passwordLine = QLineEdit(self) self._passwordLine.setText(DEFAULT_PASSWORD) validateButton = QPushButton(self.tr("Ok"), self) self.connect(validateButton, SIGNAL("clicked()"), self.validate) # Set a form layout layout = QFormLayout(self) layout.addRow(self.tr("Host : "), self._hostLine) layout.addRow(self.tr("Port : "), self._portLine) layout.addRow(self.tr("Database : "), self._databaseLine) layout.addRow(self.tr("User : "******"Password : "), self._passwordLine) layout.addWidget(validateButton) self.setLayout(layout) self.show()
def setup_ui(self): self.l = l = QFormLayout(self) self.setLayout(l) self.search_name = n = QLineEdit(self.search.get('name', ''), self) n.setPlaceholderText(_('The name with which to save this search')) l.addRow(_('&Name:'), n) self.find = f = QLineEdit(self.search.get('find', ''), self) f.setPlaceholderText(_('The expression to search for')) l.addRow(_('&Find:'), f) self.replace = r = QLineEdit(self.search.get('replace', ''), self) r.setPlaceholderText(_('The replace expression')) l.addRow(_('&Replace:'), r) self.case_sensitive = c = QCheckBox(_('Case sensitive')) c.setChecked( self.search.get('case_sensitive', SearchWidget.DEFAULT_STATE['case_sensitive'])) l.addRow(c) self.dot_all = d = QCheckBox(_('Dot matches all')) d.setChecked( self.search.get('dot_all', SearchWidget.DEFAULT_STATE['dot_all'])) l.addRow(d) self.mode_box = m = ModeBox(self) self.mode_box.mode = self.search.get('mode', 'regex') l.addRow(_('&Mode:'), m) l.addRow(self.bb)
def setup_ui(self): self.l = l = QFormLayout(self) self.setLayout(l) self.title = t = QLineEdit(self) l.addRow(_('&Title:'), t) t.setFocus(Qt.OtherFocusReason) self.authors = a = QLineEdit(self) l.addRow(_('&Authors:'), a) a.setText(tprefs.get('previous_new_book_authors', '')) self.languages = la = LanguagesEdit(self) l.addRow(_('&Language:'), la) la.lang_codes = (tprefs.get('previous_new_book_lang', canonicalize_lang(get_lang())), ) bb = self.bb l.addRow(bb) bb.clear() bb.addButton(bb.Cancel) b = bb.addButton('&EPUB', bb.AcceptRole) b.clicked.connect(partial(self.set_fmt, 'epub')) b = bb.addButton('&AZW3', bb.AcceptRole) b.clicked.connect(partial(self.set_fmt, 'azw3'))
def __init__(self): QWidget.__init__(self) self.l = QGridLayout() self.setLayout(self.l) self.newFormatCheckboxLabel = QLabel('Generate new format data (SQLite3)') self.l.addWidget(self.newFormatCheckboxLabel, 0, 0, 1, 1) self.newFormatCheckbox = QCheckBox(self) self.l.addWidget(self.newFormatCheckbox, 0, 1, 1, 1) self.newFormatCheckbox.setChecked(prefs['newFormat']) # ARTTBD Maybe should be a native directory picker? Works for now.. self.cacheDirLabel = QLabel("Caching directory (optional, useful if re-running for a given book)") self.l.addWidget(self.cacheDirLabel, 1, 0, 1, 1) self.cacheDirEdit = QLineEdit(self) self.l.addWidget(self.cacheDirEdit, 1, 1, 1, 1) self.cacheDirEdit.setText(prefs['cacheDir']) self.autoExpandAliasesLabel = QLabel('Auto-generate aliases from character names') self.l.addWidget(self.autoExpandAliasesLabel, 2, 0, 1, 1) self.autoExpandAliasesCheckbox = QCheckBox(self) self.l.addWidget(self.autoExpandAliasesCheckbox, 2, 1, 1, 1) self.autoExpandAliasesCheckbox.setChecked(prefs['autoExpandAliases']) self.logfileLabel = QLabel('Log file (optional)') self.l.addWidget(self.logfileLabel, 3, 0, 1, 1) self.logfileEdit = QLineEdit(self) self.l.addWidget(self.logfileEdit, 3, 1, 1, 1) self.logfileEdit.setText(prefs['logfile'])
def setup_ui(self): self.l = l = QFormLayout(self) self.setLayout(l) la = self.la = QLabel(_( 'You can import an HTML or DOCX file directly as an EPUB and edit it. The EPUB' ' will be generated with minimal changes from the source, unlike doing a full' ' conversion in calibre.')) la.setWordWrap(True) l.addRow(la) self.h1 = h1 = QHBoxLayout() self.src = src = QLineEdit(self) src.setPlaceholderText(_('Choose the file to import')) h1.addWidget(src) self.b1 = b = QToolButton(self) b.setIcon(QIcon(I('document_open.png'))) b.setText(_('Choose file')) h1.addWidget(b) l.addRow(_('Source file'), h1) b.clicked.connect(self.choose_source) b.setFocus(Qt.OtherFocusReason) self.h2 = h1 = QHBoxLayout() self.dest = src = QLineEdit(self) src.setPlaceholderText(_('Choose the location for the newly created EPUB')) h1.addWidget(src) self.b2 = b = QToolButton(self) b.setIcon(QIcon(I('document_open.png'))) b.setText(_('Choose file')) h1.addWidget(b) l.addRow(_('Destination file'), h1) b.clicked.connect(self.choose_destination) l.addRow(self.bb)
def __init__(self): QWidget.__init__(self) self.l = QVBoxLayout() self.setLayout(self.l) self.url_label = QLabel('Casanova server:') self.l.addWidget(self.url_label) self.url_msg = QLineEdit(self) self.url_msg.setText(prefs['base_url']) self.l.addWidget(self.url_msg) self.url_label.setBuddy(self.url_msg) self.username_label = QLabel('Username:'******'username']) self.l.addWidget(self.username_msg) self.username_label.setBuddy(self.username_msg) self.password_label = QLabel('password:'******'password']) self.l.addWidget(self.password_msg) self.password_label.setBuddy(self.password_msg)
def ask_link(self): d = QDialog(self) d.setWindowTitle(_('Create link')) l = QFormLayout() d.setLayout(l) d.url = QLineEdit(d) d.name = QLineEdit(d) d.treat_as_image = QCheckBox(d) d.setMinimumWidth(600) d.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) d.br = b = QPushButton(_('&Browse')) b.setIcon(QIcon(I('document_open.png'))) def cf(): files = choose_files(d, 'select link file', _('Choose file'), select_only_single_file=True) if files: path = files[0] d.url.setText(path) if path and os.path.exists(path): with lopen(path, 'rb') as f: q = what(f) is_image = q in {'jpeg', 'png', 'gif'} d.treat_as_image.setChecked(is_image) b.clicked.connect(cf) d.la = la = QLabel( _('Enter a URL. If you check the "Treat the URL as an image" box ' 'then the URL will be added as an image reference instead of as ' 'a link. You can also choose to create a link to a file on ' 'your computer. ' 'Note that if you create a link to a file on your computer, it ' 'will stop working if the file is moved.')) la.setWordWrap(True) la.setStyleSheet('QLabel { margin-bottom: 1.5ex }') l.setWidget(0, l.SpanningRole, la) l.addRow(_('Enter &URL:'), d.url) l.addRow(_('Treat the URL as an &image'), d.treat_as_image) l.addRow(_('Enter &name (optional):'), d.name) l.addRow(_('Choose a file on your computer:'), d.br) l.addRow(d.bb) d.bb.accepted.connect(d.accept) d.bb.rejected.connect(d.reject) d.resize(d.sizeHint()) link, name, is_image = None, None, False if d.exec_() == d.Accepted: link, name = unicode(d.url.text()).strip(), unicode( d.name.text()).strip() is_image = d.treat_as_image.isChecked() return link, name, is_image
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 setup_ui(self): self.l = l = QGridLayout() self.setLayout(l) self.la = la = QLabel( _('Arrange the files in this book into sub-folders based on their types.' ' If you leave a folder blank, the files will be placed in the root.' )) la.setWordWrap(True) l.addWidget(la, 0, 0, 1, -1) folders = tprefs['folders_for_types'] for i, (typ, text) in enumerate(self.TYPE_MAP): la = QLabel('&' + text) setattr(self, '%s_label' % typ, la) le = QLineEdit(self) setattr(self, '%s_folder' % typ, le) val = folders.get(typ, '') if val and not val.endswith('/'): val += '/' le.setText(val) la.setBuddy(le) l.addWidget(la, i + 1, 0) l.addWidget(le, i + 1, 1) self.la2 = la = QLabel( _('Note that this will only arrange files inside the book,' ' it will not affect how they are displayed in the Files Browser' )) la.setWordWrap(True) l.addWidget(la, i + 2, 0, 1, -1) l.addWidget(self.bb, i + 3, 0, 1, -1)
def setup_ui(self): self.l = l = QVBoxLayout(self) self.setLayout(l) self.text = t = QLineEdit(self) t.textEdited.connect(self.update_matches) l.addWidget(t, alignment=Qt.AlignTop) example = '<pre>{0}i{1}mages/{0}c{1}hapter1/{0}s{1}cene{0}3{1}.jpg</pre>'.format( '<span style="%s">' % Results.EMPH, '</span>') chars = '<pre style="%s">ics3</pre>' % Results.EMPH self.help_label = hl = QLabel( _('''<p>Quickly choose a file by typing in just a few characters from the file name into the field above. For example, if want to choose the file: {example} Simply type in the characters: {chars} and press Enter.''').format(example=example, chars=chars)) hl.setMargin(50), hl.setAlignment(Qt.AlignTop | Qt.AlignHCenter) l.addWidget(hl) self.results = Results(self) self.results.setVisible(False) self.results.item_selected.connect(self.accept) l.addWidget(self.results) l.addWidget(self.bb, alignment=Qt.AlignBottom)
def __init__( self, parent=None, ): QDialog.__init__(self, parent) self.parent = parent self.setWindowTitle(u"{0} {1}: Add New Mobipocket PID".format( PLUGIN_NAME, PLUGIN_VERSION)) layout = QVBoxLayout(self) self.setLayout(layout) data_group_box = QGroupBox(u"", self) layout.addWidget(data_group_box) data_group_box_layout = QVBoxLayout() data_group_box.setLayout(data_group_box_layout) key_group = QHBoxLayout() data_group_box_layout.addLayout(key_group) key_group.addWidget(QLabel(u"PID:", self)) self.key_ledit = QLineEdit("", self) self.key_ledit.setToolTip( u"Enter a Mobipocket PID. Mobipocket PIDs are 8 or 10 characters long. Mobipocket PIDs are case-sensitive, so be sure to enter the upper and lower case letters unchanged." ) key_group.addWidget(self.key_ledit) key_label = QLabel(_(''), self) key_label.setAlignment(Qt.AlignHCenter) data_group_box_layout.addWidget(key_label) self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) self.resize(self.sizeHint())
def __init__( self, parent=None, ): print repr(self), repr(parent) QDialog.__init__(self, parent) self.parent = parent self.setWindowTitle("{0} {1}: Rename {0}".format( PLUGIN_NAME, PLUGIN_VERSION, parent.key_type_name)) layout = QVBoxLayout(self) self.setLayout(layout) data_group_box = QGroupBox('', self) layout.addWidget(data_group_box) data_group_box_layout = QVBoxLayout() data_group_box.setLayout(data_group_box_layout) data_group_box_layout.addWidget(QLabel('New Key Name:', self)) self.key_ledit = QLineEdit(self.parent.listy.currentItem().text(), self) self.key_ledit.setToolTip( u"Enter a new name for this existing {0}.".format( parent.key_type_name)) data_group_box_layout.addWidget(self.key_ledit) layout.addSpacing(20) self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) layout.addWidget(self.button_box) self.resize(self.sizeHint())
def create_widgets(self, opt): val = self.plugin.prefs[opt.name] if opt.type == 'number': c = QSpinBox if isinstance(opt.default, int) else QDoubleSpinBox widget = c(self) widget.setValue(val) elif opt.type == 'string': widget = QLineEdit(self) widget.setText(val if val else '') elif opt.type == 'bool': widget = QCheckBox(opt.label, self) widget.setChecked(bool(val)) elif opt.type == 'choices': widget = QComboBox(self) for key, label in opt.choices.iteritems(): widget.addItem(label, QVariant(key)) idx = widget.findData(QVariant(val)) widget.setCurrentIndex(idx) widget.opt = opt widget.setToolTip(textwrap.fill(opt.desc)) self.widgets.append(widget) r = self.l.rowCount() if opt.type == 'bool': self.l.addWidget(widget, r, 0, 1, self.l.columnCount()) else: l = QLabel(opt.label) l.setToolTip(widget.toolTip()) self.memory.append(l) l.setBuddy(widget) self.l.addWidget(l, r, 0, 1, 1) self.l.addWidget(widget, r, 1, 1, 1)
def __init__(self, *args): QWidget.__init__(self, *args) lo = QHBoxLayout(self) lo.setContentsMargins(0, 0, 0, 0) lo.setSpacing(5) # type selector self.wtypesel = QComboBox(self) for i, tp in enumerate(self.ValueTypes): self.wtypesel.addItem(tp.__name__) QObject.connect(self.wtypesel, SIGNAL("activated(int)"), self._selectTypeNum) typesel_lab = QLabel("&Type:", self) typesel_lab.setBuddy(self.wtypesel) lo.addWidget(typesel_lab, 0) lo.addWidget(self.wtypesel, 0) self.wvalue = QLineEdit(self) self.wvalue_lab = QLabel("&Value:", self) self.wvalue_lab.setBuddy(self.wvalue) self.wbool = QComboBox(self) self.wbool.addItems(["false", "true"]) self.wbool.setCurrentIndex(1) lo.addWidget(self.wvalue_lab, 0) lo.addWidget(self.wvalue, 1) lo.addWidget(self.wbool, 1) self.wvalue.hide() # make input validators self._validators = { int: QIntValidator(self), float: QDoubleValidator(self) } # select bool type initially self._selectTypeNum(0)
def get_bulk_rename_settings(parent, number, msg=None, sanitize=sanitize_file_name_unicode, leading_zeros=True): # {{{ d = QDialog(parent) d.l = l = QFormLayout(d) d.setLayout(l) d.prefix = p = QLineEdit(d) p.setText(_('Chapter-')) p.selectAll() d.la = la = QLabel( msg or _('All selected files will be renamed to the form prefix-number')) l.addRow(la) l.addRow(_('&Prefix:'), p) d.num = num = QSpinBox(d) num.setMinimum(0), num.setValue(1), num.setMaximum(1000) l.addRow(_('Starting &number:'), num) d.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) bb.accepted.connect(d.accept), bb.rejected.connect(d.reject) l.addRow(bb) if d.exec_() == d.Accepted: prefix = sanitize(unicode(d.prefix.text())) num = d.num.value() fmt = '%d' if leading_zeros: largest = num + number - 1 fmt = '%0{0}d'.format(len(str(largest))) return prefix + fmt, num return None, None
def __init__(self, parent, label, filename=None, dialog_label=None, file_types=None, default_suffix=None, file_mode=QFileDialog.AnyFile): QWidget.__init__(self, parent) lo = QHBoxLayout(self) lo.setContentsMargins(0, 0, 0, 0) lo.setSpacing(5) # label lab = QLabel(label, self) lo.addWidget(lab, 0) # text field self.wfname = QLineEdit(self) self.wfname.setReadOnly(True) self.setFilename(filename) lo.addWidget(self.wfname, 1) # selector wsel = QToolButton(self) wsel.setText("Choose...") QObject.connect(wsel, SIGNAL("clicked()"), self._chooseFile) lo.addWidget(wsel, 0) # other init self._file_dialog = None self._dialog_label = dialog_label or label self._file_types = file_types or "All files (*)" self._file_mode = file_mode self._default_suffix = default_suffix self._dir = None
def __init__(self): QtGui.QMainWindow.__init__(self) ##Creating and new window self.win1 = QtGui.QWidget() self.win1.setGeometry(10, 20, 300, 100) self.win1.setWindowTitle("Data_LOG Plotter") self.win1.setFixedWidth(300) ## Setting for the vertical layout## layout1 = QVBoxLayout() ## Adding buttons and stuffs## ## In Layout format button.resize and button.move won't work self.line_edit = QLineEdit() button = QPushButton("Browse") button2 = QPushButton("Read") button3 = QPushButton("Exit Application") ##Adding widgets in layout structure## layout1.addWidget(self.line_edit) layout1.addWidget(button) layout1.addWidget(button2) layout1.addWidget(button3) ##Showing layout items self.win1.setLayout(layout1) ##Showing the the current window self.win1.show() button.clicked.connect(self.browse) button2.clicked.connect(self.read_file) button3.clicked.connect(self.win1.close)
def __init__(self, initial_choice='html', parent=None): QDialog.__init__(self, parent) self.l = l = QVBoxLayout() self.setLayout(l) self.la = la = QLabel(_('Choose a name for the new file')) self.setWindowTitle(_('Choose file')) l.addWidget(la) self.name = n = QLineEdit(self) n.textChanged.connect(self.update_ok) l.addWidget(n) self.err_label = la = QLabel('') la.setWordWrap(True) l.addWidget(la) self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) l.addWidget(bb) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) self.imp_button = b = bb.addButton( _('Import resource file (image/font/etc.)'), bb.ActionRole) b.setIcon(QIcon(I('view-image.png'))) b.clicked.connect(self.import_file) self.ok_button = bb.button(bb.Ok) self.file_data = '' self.using_template = False
def exclude_source_field_changed(self, new_index): ''' Process changes in the exclude_source_field combo box Currently using QLineEdit for all field types Possible to modify to switch QWidget type ''' new_source = str(self.exclude_source_field.currentText()) self.exclude_source_field_name = new_source if new_source > '': exclude_source_spec = self.exclude_source_fields[unicode( new_source)] self.exclude_source_field_name = exclude_source_spec['field'] self.exclude_pattern.setEnabled(True) # Change pattern input widget to match the source field datatype if exclude_source_spec['datatype'] in [ 'bool', 'composite', 'datetime', 'text' ]: if not isinstance(self.exclude_pattern, QLineEdit): self.exclude_spec_hl.removeWidget(self.exclude_pattern) dw = QLineEdit(self) dw.setObjectName('exclude_pattern') dw.setToolTip('Exclusion pattern') self.exclude_pattern = dw self.exclude_spec_hl.addWidget(dw) else: self.exclude_pattern.setEnabled(False)
def __init__(self, parent=None): QDialog.__init__(self, parent) self.l = l = QVBoxLayout() self.setLayout(l) self.la = la = QLabel( _('Choose a name for the new (blank) file. To place the file in a' ' specific folder in the book, include the folder name, for example: <i>text/chapter1.html' )) la.setWordWrap(True) self.setWindowTitle(_('Choose file')) l.addWidget(la) self.name = n = QLineEdit(self) n.textChanged.connect(self.update_ok) l.addWidget(n) self.err_label = la = QLabel('') la.setWordWrap(True) l.addWidget(la) self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) l.addWidget(bb) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) self.imp_button = b = bb.addButton( _('Import resource file (image/font/etc.)'), bb.ActionRole) b.setIcon(QIcon(I('view-image.png'))) b.setToolTip( _('Import a file from your computer as a new' ' file into the book.')) b.clicked.connect(self.import_file) self.ok_button = bb.button(bb.Ok) self.file_data = b'' self.using_template = False self.setMinimumWidth(350)
def __init__(self, stats, location, parent=None): QDialog.__init__(self, parent) self.setWindowTitle(_('No library found')) self._l = l = QGridLayout(self) self.setLayout(l) self.stats, self.location = stats, location loc = self.oldloc = location.replace('/', os.sep) self.header = QLabel( _('No existing calibre library was found at %s. ' 'If the library was moved, select its new location below. ' 'Otherwise calibre will forget this library.') % loc) self.header.setWordWrap(True) ncols = 2 l.addWidget(self.header, 0, 0, 1, ncols) self.cl = QLabel('<br><b>' + _('New location of this library:')) l.addWidget(self.cl, 1, 0, 1, ncols) self.loc = QLineEdit(loc, self) l.addWidget(self.loc, 2, 0, 1, 1) self.cd = QToolButton(self) self.cd.setIcon(QIcon(I('document_open.png'))) self.cd.clicked.connect(self.choose_dir) l.addWidget(self.cd, 2, 1, 1, 1) self.bb = QDialogButtonBox(QDialogButtonBox.Abort) b = self.bb.addButton(_('Library moved'), self.bb.AcceptRole) b.setIcon(QIcon(I('ok.png'))) b = self.bb.addButton(_('Forget library'), self.bb.RejectRole) b.setIcon(QIcon(I('edit-clear.png'))) b.clicked.connect(self.forget_library) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) l.addWidget(self.bb, 3, 0, 1, ncols) self.resize(self.sizeHint() + QSize(100, 50))
def __init__(self, parent): QDialog.__init__(self, parent) self.setWindowTitle("Import data from database") layout = QFormLayout(self) layout.addRow( QLabel("Database : " + self.parent().controller().databaseName())) layout.addRow(QLabel("Tables : ")) self._tables = self.parent().controller().databaseTables() self._tablesItem = [] for t in self._tables: cb = QCheckBox(t) self._tablesItem.append(cb) layout.addRow(cb) self._subset = QLineEdit(self) layout.addRow("Subset : ", self._subset) # TODO add More option (geom column, ...) validateButton = QPushButton("Ok", self) self.connect(validateButton, SIGNAL("clicked()"), self.validate) layout.addRow(validateButton) self.setLayout(layout) self.show()
def setup_ui(self): self.l = l = QVBoxLayout(self) self.setLayout(l) self.h = h = QHBoxLayout() l.addLayout(h) names = [n for n, linear in self.container.spine_names] fn, f = create_filterable_names_list(names, filter_text=_('Filter files'), parent=self) self.file_names, self.file_names_filter = fn, f fn.selectionModel().selectionChanged.connect( self.selected_file_changed) self.fnl = fnl = QVBoxLayout() self.la1 = la = QLabel(_('Choose a &file to link to:')) la.setBuddy(fn) fnl.addWidget(la), fnl.addWidget(f), fnl.addWidget(fn) h.addLayout(fnl), h.setStretch(0, 2) fn, f = create_filterable_names_list([], filter_text=_('Filter locations'), parent=self, model=AnchorsModel) fn.setSpacing(5) self.anchor_names, self.anchor_names_filter = fn, f fn.selectionModel().selectionChanged.connect(self.update_target) fn.doubleClicked.connect(self.accept, type=Qt.QueuedConnection) self.anl = fnl = QVBoxLayout() self.la2 = la = QLabel(_('Choose a &location (anchor) in the file:')) la.setBuddy(fn) fnl.addWidget(la), fnl.addWidget(f), fnl.addWidget(fn) h.addLayout(fnl), h.setStretch(1, 1) self.tl = tl = QFormLayout() self.target = t = QLineEdit(self) t.setPlaceholderText(_('The destination (href) for the link')) tl.addRow(_('&Target:'), t) l.addLayout(tl) self.text_edit = t = QLineEdit(self) la.setBuddy(t) tl.addRow(_('Te&xt:'), t) t.setText(self.initial_text or '') t.setPlaceholderText(_('The (optional) text for the link')) l.addWidget(self.bb)
def setup_ui(self): self.l = l = QGridLayout(self) self.setLayout(l) self.la1 = la = QLabel(_('&Existing images in the book')) la.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) l.addWidget(la, 0, 0, 1, 2) if self.for_browsing: la.setVisible(False) self.view = v = QListView(self) v.setViewMode(v.IconMode) v.setFlow(v.LeftToRight) v.setSpacing(4) v.setResizeMode(v.Adjust) v.setUniformItemSizes(True) pi = plugins['progress_indicator'][0] if hasattr(pi, 'set_no_activate_on_click'): pi.set_no_activate_on_click(v) v.activated.connect(self.activated) v.doubleClicked.connect(self.activated) self.d = ImageDelegate(v) v.setItemDelegate(self.d) self.model = Images(self.view) self.fm = fm = QSortFilterProxyModel(self.view) self.fm.setDynamicSortFilter(self.for_browsing) fm.setSourceModel(self.model) fm.setFilterCaseSensitivity(False) v.setModel(fm) l.addWidget(v, 1, 0, 1, 2) v.pressed.connect(self.pressed) la.setBuddy(v) self.filter = f = QLineEdit(self) f.setPlaceholderText(_('Search for image by file name')) l.addWidget(f, 2, 0) self.cb = b = QToolButton(self) b.setIcon(QIcon(I('clear_left.png'))) b.clicked.connect(f.clear) l.addWidget(b, 2, 1) f.textChanged.connect(self.filter_changed) l.addWidget(self.bb, 3, 0, 1, 2) if self.for_browsing: self.bb.clear() self.bb.addButton(self.bb.Close) b = self.refresh_button = self.bb.addButton( _('&Refresh'), self.bb.ActionRole) b.clicked.connect(self.refresh) b.setIcon(QIcon(I('view-refresh.png'))) b.setToolTip(_('Refresh the displayed images')) self.setAttribute(Qt.WA_DeleteOnClose, False) else: b = self.import_button = self.bb.addButton(_('&Import image'), self.bb.ActionRole) b.clicked.connect(self.import_image) b.setIcon(QIcon(I('view-image.png'))) b.setToolTip(_('Import an image from elsewhere in your computer'))
def ask_link(self): d = QDialog(self) d.setWindowTitle(_('Create link')) l = QFormLayout() d.setLayout(l) d.url = QLineEdit(d) d.name = QLineEdit(d) d.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) l.addRow(_('Enter &URL:'), d.url) l.addRow(_('Enter name (optional):'), d.name) l.addRow(d.bb) d.bb.accepted.connect(d.accept) d.bb.rejected.connect(d.reject) link, name = None, None if d.exec_() == d.Accepted: link, name = unicode(d.url.text()).strip(), unicode( d.name.text()).strip() return link, name
def __init__(self): QWidget.__init__(self) self.l = QVBoxLayout() self.setLayout(self.l) self.l5 = QHBoxLayout() self.server_prefix_label = QLabel('Server prefix:') self.l5.addWidget(self.server_prefix_label) self.server_prefix = QLineEdit(self) self.server_prefix.setText(prefs['server_prefix']) self.l5.addWidget(self.server_prefix) self.server_prefix_label.setBuddy(self.server_prefix) self.l.addLayout(self.l5) self.ll = QHBoxLayout() self.server_label = QLabel('Server:') self.ll.addWidget(self.server_label) self.lsb_server = QLineEdit(self) self.lsb_server.setText(prefs['lsb_server']) self.ll.addWidget(self.lsb_server) self.server_label.setBuddy(self.lsb_server) self.l.addLayout(self.ll) self.lll = QHBoxLayout() self.librarian_label = QLabel('Librarian:') self.lll.addWidget(self.librarian_label) self.librarian = QLineEdit(self) self.librarian.setText(prefs['librarian']) self.lll.addWidget(self.librarian) self.librarian_label.setBuddy(self.librarian) self.l.addLayout(self.lll) self.llll = QHBoxLayout() self.library_uuid_label = QLabel('Library ID:') self.llll.addWidget(self.library_uuid_label) self.library_uuid = QLabel(self) self.library_uuid.setText(prefs['library_uuid']) self.llll.addWidget(self.library_uuid) self.library_uuid_label.setBuddy(self.library_uuid) self.l.addLayout(self.llll)
def do_user_config(self, parent=None): ''' This method shows a configuration dialog for this plugin. It returns True if the user clicks OK, False otherwise. The changes are automatically applied. ''' from PyQt4.Qt import (QDialog, QDialogButtonBox, QVBoxLayout, QLabel, Qt, QLineEdit, QCheckBox) config_dialog = QDialog(parent) button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) v = QVBoxLayout(config_dialog) def size_dialog(): config_dialog.resize(config_dialog.sizeHint()) button_box.accepted.connect(config_dialog.accept) button_box.rejected.connect(config_dialog.reject) config_dialog.setWindowTitle(_('Customize') + ' ' + self.name) from calibre.customize.ui import (plugin_customization, customize_plugin) help_text = self.customization_help(gui=True) help_text = QLabel(help_text, config_dialog) help_text.setWordWrap(True) help_text.setTextInteractionFlags(Qt.LinksAccessibleByMouse | Qt.LinksAccessibleByKeyboard) help_text.setOpenExternalLinks(True) v.addWidget(help_text) bf = QCheckBox(_('Add linked files in breadth first order')) bf.setToolTip( _('Normally, when following links in HTML files' ' calibre does it depth first, i.e. if file A links to B and ' ' C, but B links to D, the files are added in the order A, B, D, C. ' ' With this option, they will instead be added as A, B, C, D')) sc = plugin_customization(self) if not sc: sc = '' sc = sc.strip() enc = sc.partition('|')[0] bfs = sc.partition('|')[-1] bf.setChecked(bfs == 'bf') sc = QLineEdit(enc, config_dialog) v.addWidget(sc) v.addWidget(bf) v.addWidget(button_box) size_dialog() config_dialog.exec_() if config_dialog.result() == QDialog.Accepted: sc = unicode(sc.text()).strip() if bf.isChecked(): sc += '|bf' customize_plugin(self, sc) return config_dialog.result()
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, 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)