Esempio n. 1
0
    def __init__(self, username, restriction, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle(_('Change library access permissions for {}').format(username))
        self.username = username
        self._items = []
        self.l = l = QFormLayout(self)
        l.setFieldGrowthPolicy(l.AllNonFixedFieldsGrow)

        self.libraries = t = QWidget(self)
        t.setObjectName('libraries')
        t.l = QVBoxLayout(self.libraries)
        self.atype = a = QComboBox(self)
        a.addItems([_('All libraries'), _('Only the specified libraries'), _('All except the specified libraries')])
        self.library_restrictions = restriction['library_restrictions'].copy()
        if restriction['allowed_library_names']:
            a.setCurrentIndex(1)
            self.items = restriction['allowed_library_names']
        elif restriction['blocked_library_names']:
            a.setCurrentIndex(2)
            self.items = restriction['blocked_library_names']
        else:
            a.setCurrentIndex(0)
        a.currentIndexChanged.connect(self.atype_changed)
        l.addRow(_('Allow access to:'), a)

        self.msg = la = QLabel(self)
        la.setWordWrap(True)
        l.addRow(la)
        self.la = la = QLabel(_('Specify the libraries below:'))
        la.setWordWrap(True)
        self.sa = sa = QScrollArea(self)
        sa.setWidget(t), sa.setWidgetResizable(True)
        l.addRow(la), l.addRow(sa)
        self.atype_changed()

        self.bb = bb = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel
        )
        bb.accepted.connect(self.accept), bb.rejected.connect(self.reject)
        l.addWidget(bb)
        self.items = self.items
Esempio n. 2
0
    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)
Esempio n. 3
0
def get_bulk_rename_settings(parent,
                             number,
                             msg=None,
                             sanitize=sanitize_file_name_unicode,
                             leading_zeros=True,
                             prefix=None,
                             category='text'):  # {{{
    d = QDialog(parent)
    d.setWindowTitle(_('Bulk rename items'))
    d.l = l = QFormLayout(d)
    d.setLayout(l)
    d.prefix = p = QLineEdit(d)
    default_prefix = {k: v
                      for k, __, v in CATEGORIES}.get(category, _('Chapter-'))
    previous = tprefs.get('file-list-bulk-rename-prefix', {})
    prefix = prefix or previous.get(category, default_prefix)
    p.setText(prefix)
    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()))
        previous[category] = prefix
        tprefs.set('file-list-bulk-rename-prefix', previous)
        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
Esempio n. 4
0
 def __init__(self, as_dict, parent=None):
     QWidget.__init__(self, parent)
     self.changed_signal.connect(parent.changed_signal)
     self.l = l = QFormLayout(self)
     self.type_widget = t = QComboBox(self)
     l.setFieldGrowthPolicy(l.ExpandingFieldsGrow)
     t.addItems([_('Book'), _('Author')])
     l.addRow(_('URL type:'), t)
     self.name_widget = n = QLineEdit(self)
     n.setClearButtonEnabled(True)
     l.addRow(_('Name:'), n)
     self.url_widget = w = QLineEdit(self)
     w.setClearButtonEnabled(True)
     l.addRow(_('URL:'), w)
     if as_dict:
         self.name = as_dict['name']
         self.url = as_dict['url']
         self.url_type = as_dict['type']
     self.type_widget.currentIndexChanged.connect(self.changed_signal)
     self.name_widget.textChanged.connect(self.changed_signal)
     self.url_widget.textChanged.connect(self.changed_signal)
Esempio n. 5
0
 def setup_ui(self):
     self.l = l = QFormLayout(self)
     self.export_format = ef = QComboBox(self)
     ef.addItem(_('Plain text'), 'txt')
     ef.addItem(*self.file_type_data())
     idx = ef.findData(self.prefs[self.pref_name])
     if idx > -1:
         ef.setCurrentIndex(idx)
     ef.currentIndexChanged.connect(self.save_format_pref)
     l.addRow(_('Format to export in:'), ef)
     l.addRow(self.bb)
     self.bb.clear()
     self.bb.addButton(QDialogButtonBox.StandardButton.Cancel)
     b = self.bb.addButton(_('Copy to clipboard'),
                           QDialogButtonBox.ButtonRole.ActionRole)
     b.clicked.connect(self.copy_to_clipboard)
     b.setIcon(QIcon(I('edit-copy.png')))
     b = self.bb.addButton(_('Save to file'),
                           QDialogButtonBox.ButtonRole.ActionRole)
     b.clicked.connect(self.save_to_file)
     b.setIcon(QIcon(I('save.png')))
Esempio n. 6
0
    def __init__(self, tts_client, initial_backend_settings, parent=None):
        QWidget.__init__(self, parent)
        self.l = l = QFormLayout(self)
        self.tts_client = tts_client

        self.output_modules = om = QComboBox(self)
        with BusyCursor():
            self.voice_data = self.tts_client.get_voice_data()
            self.system_default_output_module = self.tts_client.system_default_output_module
        om.addItem(_('System default'), self.system_default_output_module)
        l.addRow(_('Speech synthesizer:'), om)

        self.voices = v = QTableView(self)
        self.voices_model = VoicesModel(self.voice_data,
                                        self.system_default_output_module,
                                        parent=v)
        v.setModel(self.voices_model)
        v.horizontalHeader().resizeSection(
            0,
            QFontMetrics(self.font()).averageCharWidth() * 30)
        l.addRow(v)
Esempio n. 7
0
 def setup_ui(self):
     self.l = l = QFormLayout(self)
     self.name_edit = n = QLineEdit(self)
     n.setPlaceholderText(_('The name of the source'))
     n.setMinimumWidth(450)
     l.addRow(_('&Name:'), n)
     if self.initial_name:
         n.setText(self.initial_name)
         n.setReadOnly(True)
     self.url_edit = u = QLineEdit(self)
     u.setPlaceholderText(_('The URL template of the source'))
     u.setMinimumWidth(n.minimumWidth())
     u.setToolTip(
         textwrap.fill(
             _('The URL template must starts with https:// and have {word} in it which will be replaced by the actual query'
               )))
     l.addRow(_('&URL:'), u)
     if self.initial_url:
         u.setText(self.initial_url)
     l.addRow(self.bb)
     if self.initial_name:
         u.setFocus(Qt.OtherFocusReason)
Esempio n. 8
0
    def __init__(self, parent=None):
        BasicSettings.__init__(self, parent)
        self.l = l = QFormLayout(self)
        self.setLayout(l)

        nd = self('nestable_dock_widgets')
        nd.setText(
            _('Allow dockable windows to be nested inside the dock areas'))
        nd.setToolTip('<p>' + _(
            'By default, you can have only a single row or column of windows in the dock'
            ' areas (the areas around the central editors). This option allows'
            ' for more flexible window layout, but is a little more complex to use.'
        ))
        l.addRow(nd)

        l.addRow(
            QLabel(
                _('Choose which windows will occupy the corners of the dockable areas'
                  )))
        for v, h in product(('top', 'bottom'), ('left', 'right')):
            choices = {
                'vertical': {
                    'left': _('Left'),
                    'right': _('Right')
                }[h],
                'horizontal': {
                    'top': _('Top'),
                    'bottom': _('Bottom')
                }[v]
            }
            name = 'dock_%s_%s' % (v, h)
            w = self.choices_widget(name, choices, 'horizontal', 'horizontal')
            cn = {
                ('top', 'left'): _('The top-left corner'),
                ('top', 'right'): _('The top-right corner'),
                ('bottom', 'left'): _('The bottom-left corner'),
                ('bottom', 'right'): _('The bottom-right corner')
            }[(v, h)]
            l.addRow(cn + ':', w)
Esempio n. 9
0
 def setupUi(self, *a):
     self.l = l = QFormLayout(self)
     self.opt_docx_page_size = QComboBox(self)
     l.addRow(_('Paper si&ze:'), self.opt_docx_page_size)
     self.opt_docx_custom_page_size = w = QLineEdit(self)
     w.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
     l.addRow(_('&Custom size:'), w)
     for i, text in enumerate(
         (_('Page &left margin'), _('Page &top margin'),
          _('Page &right margin'), _('Page &bottom margin'))):
         m = 'left top right bottom'.split()[i]
         w = QDoubleSpinBox(self)
         w.setRange(-100, 500), w.setSuffix(' pt'), w.setDecimals(1)
         setattr(self, 'opt_docx_page_margin_' + m, w)
         l.addRow(text + ':', w)
     self.opt_docx_no_toc = QCheckBox(
         _('Do not insert the &Table of Contents as a page at the start of the document'
           ))
     l.addRow(self.opt_docx_no_toc)
     self.opt_docx_no_cover = QCheckBox(
         _('Do not insert &cover as image at start of document'))
     l.addRow(self.opt_docx_no_cover)
Esempio n. 10
0
    def setup_ui(self):
        from calibre.gui2.tweak_book.templates import DEFAULT_TEMPLATES
        from calibre.gui2.tweak_book.editor.text import TextEdit
        self.l = l = QFormLayout(self)
        self.setLayout(l)

        self.syntaxes = s = QComboBox(self)
        s.addItems(sorted(DEFAULT_TEMPLATES.iterkeys()))
        s.setCurrentIndex(s.findText('html'))
        l.addRow(_('Choose the &type of template to edit:'), s)
        s.currentIndexChanged.connect(self.show_template)

        self.helpl = la = QLabel(
            _('The variables {0} and {1} will be replaced with the title and author of the book. {2}'
              ' is where the cursor will be positioned. If you want to include braces in your template,'
              ' for example for CSS rules, you have to escape them, like this: {3}'
              ).format(*[
                  '<code>%s</code>' % x for x in
                  ['{TITLE}', '{AUTHOR}', '%CURSOR%', 'body {{ color: red }}']
              ]))
        la.setWordWrap(True)
        l.addRow(la)

        self.save_timer = t = QTimer(self)
        t.setSingleShot(True), t.setInterval(100)
        t.timeout.connect(self._save_syntax)

        self.editor = e = TextEdit(self)
        l.addRow(e)
        e.textChanged.connect(self.save_syntax)

        self.show_template()

        self.bb.clear()
        self.bb.addButton(self.bb.Close)
        self.rd = b = self.bb.addButton(self.bb.RestoreDefaults)
        b.clicked.connect(self.restore_defaults)
        l.addRow(self.bb)
Esempio n. 11
0
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     l = QVBoxLayout(parent)
     l.addWidget(self)
     l.setContentsMargins(0, 0, 0, 0)
     l = QFormLayout(self)
     l.setContentsMargins(0, 0, 0, 0)
     l.setFieldGrowthPolicy(
         QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow)
     self.choices = c = QComboBox()
     c.setMinimumContentsLength(30)
     for text, data in [
         (_('Search for the author on Goodreads'), 'search-goodreads'),
         (_('Search for the author on Amazon'), 'search-amzn'),
         (_('Search for the author in your calibre library'),
          'search-calibre'),
         (_('Search for the author on Wikipedia'), 'search-wikipedia'),
         (_('Search for the author on Google Books'), 'search-google'),
         (_('Search for the book on Goodreads'), 'search-goodreads-book'),
         (_('Search for the book on Amazon'), 'search-amzn-book'),
         (_('Search for the book on Google Books'), 'search-google-book'),
         (_('Use a custom search URL'), 'url'),
     ]:
         c.addItem(text, data)
     l.addRow(_('Clicking on &author names should:'), c)
     self.custom_url = u = QLineEdit(self)
     u.setToolTip(
         _('Enter the URL to search. It should contain the string {0}'
           '\nwhich will be replaced by the author name. For example,'
           '\n{1}').format(
               '{author}',
               'https://en.wikipedia.org/w/index.php?search={author}'))
     u.textChanged.connect(self.changed_signal)
     u.setPlaceholderText(_('Enter the URL'))
     c.currentIndexChanged.connect(self.current_changed)
     l.addRow(u)
     self.current_changed()
     c.currentIndexChanged.connect(self.changed_signal)
Esempio n. 12
0
    def __init__(self, parent=None):
        BasicSettings.__init__(self, parent)
        self.l = l = QFormLayout(self)
        self.setLayout(l)

        def family_getter(w):
            return unicode(w.currentFont().family())

        def family_setter(w, val):
            w.setCurrentFont(QFont(val))

        families = {
            'serif': _('Serif text'),
            'sans': _('Sans-serif text'),
            'mono': _('Monospaced text')
        }
        for fam in sorted(families):
            text = families[fam]
            w = QFontComboBox(self)
            self('preview_%s_family' % fam,
                 widget=w,
                 getter=family_getter,
                 setter=family_setter)
            l.addRow(_('Font family for &%s:') % text, w)

        w = self.choices_widget('preview_standard_font_family', families,
                                'serif', 'serif')
        l.addRow(_('Style for standard &text:'), w)

        w = self('preview_base_font_size')
        w.setMinimum(8), w.setMaximum(100), w.setSuffix(' px')
        l.addRow(_('&Default font size:'), w)
        w = self('preview_mono_font_size')
        w.setMinimum(8), w.setMaximum(100), w.setSuffix(' px')
        l.addRow(_('&Monospace font size:'), w)
        w = self('preview_minimum_font_size')
        w.setMinimum(4), w.setMaximum(100), w.setSuffix(' px')
        l.addRow(_('Mi&nimum font size:'), w)
Esempio n. 13
0
    def setup_ui(self):
        self.l = l = QFormLayout(self)
        l.setFieldGrowthPolicy(
            QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow)
        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.FocusReason.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)
Esempio n. 14
0
    def setup_ui(self):
        self.splitter = QSplitter(self)
        self.l = l = QVBoxLayout(self)
        l.addWidget(self.splitter)
        l.addWidget(self.bb)
        self.w = w = QGroupBox(_('Theme Metadata'), self)
        self.splitter.addWidget(w)
        l = w.l = QFormLayout(w)
        l.setFieldGrowthPolicy(
            QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow)
        self.missing_icons_group = mg = QGroupBox(self)
        self.mising_icons = mi = QListWidget(mg)
        mi.setSelectionMode(QAbstractItemView.SelectionMode.NoSelection)
        mg.l = QVBoxLayout(mg)
        mg.l.addWidget(mi)
        self.splitter.addWidget(mg)
        self.title = QLineEdit(self)
        l.addRow(_('&Title:'), self.title)
        self.author = QLineEdit(self)
        l.addRow(_('&Author:'), self.author)
        self.version = v = QSpinBox(self)
        v.setMinimum(1), v.setMaximum(1000000)
        l.addRow(_('&Version:'), v)
        self.license = lc = QLineEdit(self)
        l.addRow(_('&License:'), lc)
        self.url = QLineEdit(self)
        l.addRow(_('&URL:'), self.url)
        lc.setText(
            _('The license for the icons in this theme. Common choices are'
              ' Creative Commons or Public Domain.'))
        self.description = QTextEdit(self)
        l.addRow(self.description)
        self.refresh_button = rb = self.bb.addButton(
            _('&Refresh'), QDialogButtonBox.ButtonRole.ActionRole)
        rb.setIcon(QIcon(I('view-refresh.png')))
        rb.clicked.connect(self.refresh)

        self.apply_report()
Esempio n. 15
0
 def __init__(self, parent):
     QDialog.__init__(self, parent)
     self.setWindowTitle(_('Add a dictionary website'))
     self.l = l = QFormLayout(self)
     self.la = la = QLabel('<p>' + _(
         'Choose a language and enter the website address (URL) for it below.'
         ' The URL must have the placeholder <b>%s</b> in it, which will be replaced by the actual word being'
         ' looked up') % '{word}')
     la.setWordWrap(True)
     l.addRow(la)
     self.le = LanguagesEdit(self)
     l.addRow(_('&Language:'), self.le)
     self.url = u = QLineEdit(self)
     u.setMinimumWidth(350)
     u.setPlaceholderText(
         _('For example: %s') % 'http://dictionary.com/{word}')
     l.addRow(_('&URL:'), u)
     self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok
                                     | QDialogButtonBox.Cancel)
     l.addRow(bb)
     bb.accepted.connect(self.accept), bb.rejected.connect(
         self.reject)
     self.resize(self.sizeHint())
Esempio n. 16
0
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self.l = l = QFormLayout(self)
     l.setFieldGrowthPolicy(l.AllNonFixedFieldsGrow)
     self.widgets = []
     self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
     for name in sorted(options, key=lambda n: options[n].shortdoc.lower()):
         if name in ('auth', 'port', 'allow_socket_preallocation', 'userdb'):
             continue
         opt = options[name]
         if opt.choices:
             w = Choices
         elif isinstance(opt.default, bool):
             w = Bool
         elif isinstance(opt.default, int):
             w = Int
         elif isinstance(opt.default, float):
             w = Float
         else:
             w = Text
         w = w(name, l)
         setattr(self, 'opt_' + name, w)
         self.widgets.append(w)
Esempio n. 17
0
 def setup_ui(self):
     self.l = l = QFormLayout(self)
     l.setFieldGrowthPolicy(l.AllNonFixedFieldsGrow)
     l.addRow(
         QLabel(
             _('The key of the identifier, for example, in isbn:XXX, the key is ISBN'
               )))
     self.key = k = QLineEdit(self)
     l.addRow(_('&Key:'), k)
     l.addRow(
         QLabel(_('The name that will appear in the Book details panel')))
     self.nw = n = QLineEdit(self)
     l.addRow(_('&Name:'), n)
     la = QLabel(
         _('The template used to create the link. The placeholder {id} in the template will be replaced with the actual identifier value.'
           ))
     la.setWordWrap(True)
     l.addRow(la)
     self.template = t = QLineEdit(self)
     l.addRow(_('&Template:'), t)
     t.selectAll()
     t.setFocus(Qt.OtherFocusReason)
     l.addWidget(self.bb)
Esempio n. 18
0
    def __init__(self, parent=None):
        BasicSettings.__init__(self, parent)
        self.l = l = QFormLayout(self)
        self.setLayout(l)

        um = self('update_metadata_from_calibre')
        um.setText(_('Update metadata embedded in the book when opening'))
        um.setToolTip('<p>' + _(
            'When the file is opened, update the metadata embedded in the book file to the current metadata'
            ' in the calibre library.'))
        l.addRow(um)

        ask = self('choose_tweak_fmt')
        ask.setText(
            _('Ask which format to edit if more than one format is available for the book'
              ))
        l.addRow(ask)

        order = self.order_widget('tweak_fmt_order')
        order.setToolTip(
            _('When auto-selecting the format to edit for a book with'
              ' multiple formats, this is the preference order.'))
        l.addRow(_('Preferred format order (drag and drop to change)'), order)
Esempio n. 19
0
    def setup_ui(self):
        self.l = l = QFormLayout(self)
        l.setFieldGrowthPolicy(l.AllNonFixedFieldsGrow)

        self.la = la = QLabel(self.label or _(
            'You can create a <i>Saved search</i>, for frequently used searches here.'
            ' The search will be visible under <i>Saved searches</i> in the Tag browser,'
            ' using the name that you specify here.'))
        la.setWordWrap(True)
        l.addRow(la)

        self.sname = n = QLineEdit(self)
        l.addRow(_('&Name:'), n)
        n.setPlaceholderText(_('The Saved search name'))

        self.search = s = QLineEdit(self)
        s.setMinimumWidth(400)
        l.addRow(_('&Search:'), s)
        s.setPlaceholderText(_('The search expression'))
        if self.initial_search:
            s.setText(self.initial_search)
        n.setFocus(Qt.OtherFocusReason)
        l.addRow(self.bb)
Esempio n. 20
0
    def __init__(self, tts_client, initial_backend_settings=None, parent=None):
        QWidget.__init__(self, parent)
        self.l = l = QFormLayout(self)
        self.tts_client = tts_client

        with BusyCursor():
            self.voice_data = self.tts_client.get_voice_data()
            self.default_system_rate = self.tts_client.default_system_rate

        self.speed = s = QSlider(Qt.Orientation.Horizontal, self)
        s.setMinimumWidth(200)
        l.addRow(_('&Speed of speech (words per minute):'), s)
        delta = self.default_system_rate - 50
        s.setRange(self.default_system_rate - delta,
                   self.default_system_rate + delta)
        s.setSingleStep(10)

        self.voices = v = QTableView(self)
        self.voices_model = VoicesModel(self.voice_data, parent=v)
        self.proxy_model = p = QSortFilterProxyModel(self)
        p.setFilterCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive)
        p.setSourceModel(self.voices_model)
        v.setModel(p)
        v.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
        v.setSortingEnabled(True)
        v.horizontalHeader().resizeSection(
            0,
            QFontMetrics(self.font()).averageCharWidth() * 20)
        v.horizontalHeader().resizeSection(
            1,
            QFontMetrics(self.font()).averageCharWidth() * 30)
        v.verticalHeader().close()
        v.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
        v.sortByColumn(0, Qt.SortOrder.AscendingOrder)
        l.addRow(v)

        self.backend_settings = initial_backend_settings or {}
Esempio n. 21
0
    def __init__(self, parent=None):
        BasicSettings.__init__(self, parent)
        self.l = l = QFormLayout(self)
        self.setLayout(l)

        nd = self('nestable_dock_widgets')
        nd.setText(_('Allow dockable &windows to be nested inside the dock areas'))
        nd.setToolTip('<p>' + _(
            'By default, you can have only a single row or column of windows in the dock'
            ' areas (the areas around the central editors). This option allows'
            ' for more flexible window layout, but is a little more complex to use.'))
        l.addRow(nd)

        l.addRow(QLabel(_('Choose which windows will occupy the corners of the dockable areas')))
        for v, h in product(('top', 'bottom'), ('left', 'right')):
            choices = {'vertical':{'left':_('Left'), 'right':_('Right')}[h],
                       'horizontal':{'top':_('Top'), 'bottom':_('Bottom')}[v]}
            name = 'dock_%s_%s' % (v, h)
            w = self.choices_widget(name, choices, 'horizontal', 'horizontal')
            cn = {('top', 'left'): _('The &top-left corner'), ('top', 'right'):_('The top-&right corner'),
                  ('bottom', 'left'):_('The &bottom-left corner'), ('bottom', 'right'):_('The bottom-ri&ght corner')}[(v, h)]
            l.addRow(cn + ':', w)
        nd = self('restore_book_state')
        nd.setText(_('Restore &state of previously edited book when opening it again'))
        nd.setToolTip('<p>' + _(
            'When opening a previously edited book again, restore its state. That means all open'
            ' files are automatically re-opened and the cursor is positioned at its previous location.'
        ))
        l.addRow(nd)

        nd = self('file_list_shows_full_pathname')
        nd.setText(_('Show full &file paths in the File browser'))
        nd.setToolTip('<p>' + _(
            'Showing the full file paths is useful when editing books that contain'
            ' multiple files with the same file name.'
        ))
        l.addRow(nd)
Esempio n. 22
0
    def setup_ui(self):
        from calibre.gui2.convert.look_and_feel_ui import Ui_Form
        f, w = Ui_Form(), QWidget()
        f.setupUi(w)
        self.l = l = QFormLayout(self)
        self.setLayout(l)

        l.addRow(
            QLabel(
                _('Select what style information you want completely removed:')
            ))
        self.h = h = QHBoxLayout()

        for name, text in (
            ('fonts', _('&Fonts')),
            ('margins', _('&Margins')),
            ('padding', _('&Padding')),
            ('floats', _('Flo&ats')),
            ('colors', _('&Colors')),
        ):
            c = QCheckBox(text)
            setattr(self, 'opt_' + name, c)
            h.addWidget(c)
            c.setToolTip(getattr(f, 'filter_css_' + name).toolTip())
        l.addRow(h)

        self.others = o = QLineEdit(self)
        l.addRow(_('&Other CSS properties:'), o)
        o.setToolTip(f.filter_css_others.toolTip())

        if self.current_name is not None:
            self.filter_current = c = QCheckBox(
                _('Only filter CSS in the current file (%s)') %
                self.current_name)
            l.addRow(c)

        l.addRow(self.bb)
Esempio n. 23
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.l = l = QFormLayout(self)
        l.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
        self.username_label = la = QLabel('')
        l.addWidget(la)
        self.cpb = b = QPushButton(_('Change &password'))
        l.addWidget(b)
        b.clicked.connect(self.change_password)
        self.ro_text = _('Allow {} to make changes (i.e. grant write access)?')
        self.rw = rw = QCheckBox(self)
        rw.setToolTip(
            _('If enabled, allows the user to make changes to the library.'
              ' Adding books/deleting books/editing metadata, etc.'))
        rw.stateChanged.connect(self.readonly_changed)
        l.addWidget(rw)
        self.access_label = la = QLabel(self)
        l.addWidget(la), la.setWordWrap(True)
        self.restrict_button = b = QPushButton(self)
        b.clicked.connect(self.change_restriction)
        l.addWidget(b)

        self.show_user()
Esempio n. 24
0
    def __init__(self, width, height, parent=None):
        QDialog.__init__(self, parent)
        self.l = l = QFormLayout(self)
        self.setLayout(l)
        self.aspect_ratio = width / float(height)
        l.addRow(QLabel(_('Choose the new width and height')))

        self._width = w = QSpinBox(self)
        w.setMinimum(1)
        w.setMaximum(10 * width)
        w.setValue(width)
        w.setSuffix(' px')
        l.addRow(_('&Width:'), w)

        self._height = h = QSpinBox(self)
        h.setMinimum(1)
        h.setMaximum(10 * height)
        h.setValue(height)
        h.setSuffix(' px')
        l.addRow(_('&Height:'), h)
        connect_lambda(w.valueChanged, self,
                       lambda self: self.keep_ar('width'))
        connect_lambda(h.valueChanged, self,
                       lambda self: self.keep_ar('height'))

        self.ar = ar = QCheckBox(_('Keep &aspect ratio'))
        ar.setChecked(True)
        l.addRow(ar)
        self.resize(self.sizeHint())

        self.bb = bb = QDialogButtonBox(
            QDialogButtonBox.StandardButton.Ok
            | QDialogButtonBox.StandardButton.Cancel)
        bb.accepted.connect(self.accept)
        bb.rejected.connect(self.reject)
        l.addRow(bb)
Esempio n. 25
0
    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)
        connect_lambda(b.clicked, self, lambda self: self.set_fmt('epub'))
        b = bb.addButton('&AZW3', bb.AcceptRole)
        connect_lambda(b.clicked, self, lambda self: self.set_fmt('azw3'))
Esempio n. 26
0
    def __init__(self, parent=None):
        super(HistoryWidget, self).__init__(parent)
        self.setObjectName("HistoryWidget")
        self.resize(800, 480)
        self.setWindowTitle("历史数据查看")

        # layout - top
        horiLayoutTop = QHBoxLayout()

        buttonQuit = QPushButton(self)
        buttonQuit.setObjectName("buttonQuit")
        horiLayoutTop.addSpacing(25)
        horiLayoutTop.addWidget(buttonQuit, 0, Qt.AlignLeft)
        horiLayoutTop.addStretch()

        # button-export
        buttonExport = QPushButton(self)
        buttonExport.setObjectName("buttonExport")
        horiLayoutTop.addWidget(buttonExport)
        horiLayoutTop.addStretch()

        # button-open
        buttonOpen = QPushButton(self)
        buttonOpen.setObjectName("buttonOpen")
        horiLayoutTop.addWidget(buttonOpen)
        horiLayoutTop.addStretch()

        formLayoutTime = QFormLayout()
        formLayoutTime.setFormAlignment(Qt.AlignVCenter)
        horiLayoutTop.addLayout(formLayoutTime)
        horiLayoutTop.addStretch()

        self.dateTimeEditStart = QDateTimeEdit(self)
        self.dateTimeEditStart.setObjectName("dateTimeEditStart")
        self.dateTimeEditStart.setDisplayFormat("yyyy-MM-dd HH:mm:ss")
        formLayoutTime.addRow("起始时间:", self.dateTimeEditStart)

        self.dateTimeEditEnd = QDateTimeEdit(self)
        self.dateTimeEditEnd.setObjectName("dateTimeEditEnd")
        self.dateTimeEditEnd.setDisplayFormat("yyyy-MM-dd HH:mm:ss")
        formLayoutTime.addRow("结束时间:", self.dateTimeEditEnd)

        # LBP
        formLayoutLBP = QFormLayout()
        formLayoutLBP.setFormAlignment(Qt.AlignVCenter)
        formLayoutLBP.setLabelAlignment(Qt.AlignRight)
        horiLayoutTop.addLayout(formLayoutLBP)
        horiLayoutTop.addStretch()
        self.checkBoxLBPMajor = QCheckBox("主", self)
        self.checkBoxLBPMajor.setProperty("curveColor", "#101010")
        self.checkBoxLBPMinor = QCheckBox("副", self)
        self.checkBoxLBPMinor.setProperty("curveColor", "#101010")
        formLayoutLBP.addRow("左刹车压力:", self.checkBoxLBPMajor)
        formLayoutLBP.addRow("", self.checkBoxLBPMinor)

        # RBP
        formLayoutRBP = QFormLayout()
        formLayoutRBP.setFormAlignment(Qt.AlignVCenter)
        formLayoutRBP.setLabelAlignment(Qt.AlignRight)
        horiLayoutTop.addLayout(formLayoutRBP)
        horiLayoutTop.addStretch()
        self.checkBoxRBPMajor = QCheckBox("主", self)
        self.checkBoxRBPMajor.setProperty("curveColor", "#101010")
        self.checkBoxRBPMinor = QCheckBox("副", self)
        self.checkBoxRBPMinor.setProperty("curveColor", "#101010")
        formLayoutRBP.addRow("右刹车压力:", self.checkBoxRBPMajor)
        formLayoutRBP.addRow("", self.checkBoxRBPMinor)

        # LRP
        formLayoutLRP = QFormLayout()
        formLayoutLRP.setFormAlignment(Qt.AlignVCenter)
        formLayoutLRP.setLabelAlignment(Qt.AlignRight)
        horiLayoutTop.addLayout(formLayoutLRP)
        horiLayoutTop.addStretch()
        self.checkBoxLRPTheory = QCheckBox("理论", self)
        self.checkBoxLRPTheory.setProperty("curveColor", "#101010")
        self.checkBoxLRPReal = QCheckBox("实际", self)
        self.checkBoxLRPReal.setProperty("curveColor", "#101010")
        formLayoutLRP.addRow("左转速:", self.checkBoxLRPTheory)
        formLayoutLRP.addRow("", self.checkBoxLRPReal)

        # RRP
        formLayoutRRP = QFormLayout()
        formLayoutRRP.setFormAlignment(Qt.AlignVCenter)
        formLayoutRRP.setLabelAlignment(Qt.AlignRight)
        horiLayoutTop.addLayout(formLayoutRRP)
        horiLayoutTop.addStretch()
        self.checkBoxRRPTheory = QCheckBox("理论", self)
        self.checkBoxRRPTheory.setProperty("curveColor", "#101010")
        self.checkBoxRRPReal = QCheckBox("实际", self)
        self.checkBoxRRPReal.setProperty("curveColor", "#101010")
        formLayoutRRP.addRow("右转速:", self.checkBoxRRPTheory)
        formLayoutRRP.addRow("", self.checkBoxRRPReal)

        # button-update
        buttonUpdate = QPushButton(self)
        buttonUpdate.setObjectName("buttonUpdate")
        horiLayoutTop.addWidget(buttonUpdate)
        horiLayoutTop.addStretch()

        # middle-curves
        self.curveHistory = CurveWidget("历史数据回放", True, self)
        self.curveHistory.setMaximumWidth(10e5)
        self.curveHistory.setScaleLabelFormat("yyyy/MM/dd\n  HH:mm:ss")
        self.curveHistory.clear()

        #
        vertLayoutMain = QVBoxLayout(self)
        vertLayoutMain.addLayout(horiLayoutTop)
        vertLayoutMain.addWidget(self.curveHistory)

        buttonQuit.clicked.connect(self.accept)
        buttonOpen.clicked.connect(self.buttonOpenClicked)
        buttonExport.clicked.connect(self.buttonExportClicked)
        self.dateTimeEditStart.dateTimeChanged.connect(self.dateTimeStartChanged)
        self.dateTimeEditEnd.dateTimeChanged.connect(self.dateTimeEndChanged)
        self.checkBoxLBPMajor.toggled.connect(self.checkBoxLBPMajorToggled)
        self.checkBoxLBPMinor.toggled.connect(self.checkBoxLBPMinorToggled)
        self.checkBoxRBPMajor.toggled.connect(self.checkBoxRBPMajorToggled)
        self.checkBoxRBPMinor.toggled.connect(self.checkBoxRBPMinorToggled)
        self.checkBoxLRPTheory.toggled.connect(self.checkBoxLRPTheoryToggled)
        self.checkBoxLRPReal.toggled.connect(self.checkBoxLRPRealToggled)
        self.checkBoxRRPTheory.toggled.connect(self.checkBoxRRPTheoryToggled)
        self.checkBoxRRPReal.toggled.connect(self.checkBoxRRPRealToggled)
        buttonUpdate.clicked.connect(self.buttonUpdateClicked)

        # finalLy initialize
        self.checkBoxLBPMajor.setChecked(self._v_curve_checked[0])
        self.checkBoxLBPMinor.setChecked(self._v_curve_checked[1])
        self.checkBoxRBPMajor.setChecked(self._v_curve_checked[2])
        self.checkBoxRBPMinor.setChecked(self._v_curve_checked[3])
        self.checkBoxLRPTheory.setChecked(self._v_curve_checked[4])
        self.checkBoxLRPReal.setChecked(self._v_curve_checked[5])
        self.checkBoxRRPTheory.setChecked(self._v_curve_checked[6])
        self.checkBoxRRPReal.setChecked(self._v_curve_checked[7])
Esempio n. 27
0
    def __init__(self, main):
        super(GameListWidget, self).__init__()
        self.main_win = main
        self.keystore_exchanged = False

        self.setObjectName("GameListWidget")
        v_layout = QVBoxLayout()

        h_layout1 = QHBoxLayout()
        self.game_list_view = QListView()
        self.game_list_view.setViewMode(QListView.ListMode)
        self.game_list_view.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.game_list_model = GameListModel(self.main_win.games)
        self.game_list_view.setModel(self.game_list_model)
        self.game_list_view.clicked.connect(self.list_item_onclick)
        h_layout1.addWidget(self.game_list_view, 1)
        self.game_list_view.setCurrentIndex(
            self.game_list_model.index(self.main_win.game_index))
        self.game = self.main_win.games[self.main_win.game_index]

        form_layout = QFormLayout()
        form_layout.setContentsMargins(20, 50, 20, 50)
        self.game_name_value = QLineEdit()
        form_layout.addRow("游戏名称:", self.game_name_value)
        self.game_desc_value = QTextEdit()
        form_layout.addRow("游戏简介:", self.game_desc_value)
        self.game_appid_value = QLabel()
        self.game_appid_value.setTextInteractionFlags(Qt.TextSelectableByMouse)
        form_layout.addRow("游戏ID:", self.game_appid_value)
        self.game_appkey_value = QLabel()
        self.game_appkey_value.setTextInteractionFlags(
            Qt.TextSelectableByMouse)
        form_layout.addRow("客户端Key:", self.game_appkey_value)
        h_layout = QHBoxLayout()
        self.keystore_path = QLineEdit()
        select_key_btn = QPushButton("浏览")
        select_key_btn.setStyleSheet('QPushButton{border-radius: 0px;}')
        select_key_btn.clicked.connect(self.select_ketstore)
        h_layout.addWidget(self.keystore_path)
        h_layout.addWidget(select_key_btn)
        form_layout.addRow("KeyStore:", h_layout)
        self.keystore_pwd_value = QLineEdit()
        form_layout.addRow("KeyPass:"******"Alias:", self.keystore_alias_value)
        self.keystore_aliaspwd_value = QLineEdit()
        form_layout.addRow("AliasPass:"******"更换Icon")
        icon_exchange_btn.setFixedWidth(100)
        icon_exchange_btn.clicked.connect(self.exchange_icon)
        v_layout1.addWidget(icon_exchange_btn, alignment=Qt.AlignHCenter)
        v_layout1.addStretch(2)
        h_layout1.addLayout(v_layout1, 1)
        v_layout.addLayout(h_layout1)

        h_layout2 = QHBoxLayout()
        create_game_btn = QPushButton("返 回")
        create_game_btn.setFixedWidth(100)
        create_game_btn.clicked.connect(self.back)
        h_layout2.addWidget(create_game_btn,
                            alignment=Qt.AlignLeft | Qt.AlignBottom)
        back_btn = QPushButton("创建游戏")
        back_btn.setFixedWidth(100)
        back_btn.clicked.connect(self.add_game)
        h_layout2.addWidget(back_btn, alignment=Qt.AlignHCenter)
        next_btn = QPushButton("下一步")
        next_btn.setFixedWidth(100)
        next_btn.clicked.connect(self.next)
        h_layout2.addWidget(next_btn, alignment=Qt.AlignRight | Qt.AlignBottom)
        v_layout.addLayout(h_layout2)
        self.setLayout(v_layout)
        self.set_game_info()
Esempio n. 28
0
 def setupUi(self, ConfigureRPCserverDlg):
     ConfigureRPCserverDlg.setModal(True)
     ## -- Layout
     self.layout = QGroupBox(ConfigureRPCserverDlg)
     self.layout.setTitle("Local Pivx-Cli wallet Configuration")
     self.layout.setContentsMargins(80, 30, 10, 10)
     form = QFormLayout(ConfigureRPCserverDlg)
     form.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
     ## -- ROW 1
     line1 = QHBoxLayout()
     self.edt_rpcIp = QLineEdit()
     self.edt_rpcIp.setToolTip(
         "rpc server (local wallet) IP address\n-- example [IPv4] 88.172.23.1\n-- example [IPv6] 2001:db8:85a3::8a2e:370:7334"
     )
     self.edt_rpcIp.setText(ConfigureRPCserverDlg.rpc_ip)
     line1.addWidget(self.edt_rpcIp)
     line1.addWidget(QLabel("IP Port"))
     self.edt_rpcPort = QSpinBox()
     self.edt_rpcPort.setRange(1, 65535)
     self.edt_rpcPort.setValue(ConfigureRPCserverDlg.rpc_port)
     self.edt_rpcPort.setFixedWidth(180)
     line1.addWidget(self.edt_rpcPort)
     form.addRow(QLabel("IP Address"), line1)
     ## -- ROW 2
     self.edt_rpcUser = QLineEdit()
     self.edt_rpcUser.setText(ConfigureRPCserverDlg.rpc_user)
     form.addRow(QLabel("RPC Username"), self.edt_rpcUser)
     ## -- ROW 3
     self.edt_rpcPassword = QLineEdit()
     self.edt_rpcPassword.setText(ConfigureRPCserverDlg.rpc_password)
     form.addRow(QLabel("RPC Password"), self.edt_rpcPassword)
     ## -- ROW 4
     hBox = QHBoxLayout()
     self.buttonCancel = QPushButton("Cancel")
     self.buttonCancel.clicked.connect(
         lambda: self.onButtonCancel(ConfigureRPCserverDlg))
     hBox.addWidget(self.buttonCancel)
     self.buttonSave = QPushButton("Save")
     self.buttonSave.clicked.connect(
         lambda: self.onButtonSave(ConfigureRPCserverDlg))
     hBox.addWidget(self.buttonSave)
     form.addRow(hBox)
     ## Set Layout
     self.layout.setLayout(form)
     ConfigureRPCserverDlg.setFixedSize(self.layout.sizeHint())
Esempio n. 29
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self.l = l = QFormLayout(self)
        l.setFieldGrowthPolicy(l.ExpandingFieldsGrow)

        self.hm = hm = QLabel(
            _('Create a basic news recipe, by adding RSS feeds to it.\n'
              'For some news sources, you will have to use the "Switch to advanced mode" '
              'button below to further customize the fetch process.'))
        hm.setWordWrap(True)
        l.addRow(hm)

        self.title = t = QLineEdit(self)
        l.addRow(_('Recipe &title:'), t)
        t.setStyleSheet('QLineEdit { font-weight: bold }')

        self.oldest_article = o = QSpinBox(self)
        o.setSuffix(' ' + _('day(s)'))
        o.setToolTip(_("The oldest article to download"))
        o.setMinimum(1), o.setMaximum(36500)
        l.addRow(_('&Oldest article:'), o)

        self.max_articles = m = QSpinBox(self)
        m.setMinimum(5), m.setMaximum(100)
        m.setToolTip(_("Maximum number of articles to download per feed."))
        l.addRow(_("&Max. number of articles per feed:"), m)

        self.fg = fg = QGroupBox(self)
        fg.setTitle(_("Feeds in recipe"))
        self.feeds = f = QListWidget(self)
        fg.h = QHBoxLayout(fg)
        fg.h.addWidget(f)
        fg.l = QVBoxLayout()
        self.up_button = b = QToolButton(self)
        b.setIcon(QIcon(I('arrow-up.png')))
        b.setToolTip(_('Move selected feed up'))
        fg.l.addWidget(b)
        b.clicked.connect(self.move_up)
        self.remove_button = b = QToolButton(self)
        b.setIcon(QIcon(I('list_remove.png')))
        b.setToolTip(_('Remove selected feed'))
        fg.l.addWidget(b)
        b.clicked.connect(self.remove_feed)
        self.down_button = b = QToolButton(self)
        b.setIcon(QIcon(I('arrow-down.png')))
        b.setToolTip(_('Move selected feed down'))
        fg.l.addWidget(b)
        b.clicked.connect(self.move_down)
        fg.h.addLayout(fg.l)
        l.addRow(fg)

        self.afg = afg = QGroupBox(self)
        afg.setTitle(_('Add feed to recipe'))
        afg.l = QFormLayout(afg)
        afg.l.setFieldGrowthPolicy(l.ExpandingFieldsGrow)
        self.feed_title = ft = QLineEdit(self)
        afg.l.addRow(_('&Feed title:'), ft)
        self.feed_url = fu = QLineEdit(self)
        afg.l.addRow(_('Feed &URL:'), fu)
        self.afb = b = QPushButton(QIcon(I('plus.png')), _('&Add feed'), self)
        b.setToolTip(_('Add this feed to the recipe'))
        b.clicked.connect(self.add_feed)
        afg.l.addRow(b)
        l.addRow(afg)
Esempio n. 30
0
    def ask_link(self):
        d = QDialog(self)
        d.setWindowTitle(_('Create link'))
        l = QFormLayout()
        l.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
        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_type(d.url.text()).strip(), unicode_type(
                d.name.text()).strip()
            is_image = d.treat_as_image.isChecked()
        return link, name, is_image
Esempio n. 31
0
    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()
        tl.setFieldGrowthPolicy(tl.AllNonFixedFieldsGrow)
        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'))

        self.template_edit = t = HistoryComboBox(self)
        t.lineEdit().setClearButtonEnabled(True)
        t.initialize('edit_book_insert_link_template_history')
        tl.addRow(_('Tem&plate:'), t)
        from calibre.gui2.tweak_book.editor.smarts.html import DEFAULT_LINK_TEMPLATE
        t.setText(
            tprefs.get('insert-hyperlink-template', None)
            or DEFAULT_LINK_TEMPLATE)
        t.setToolTip('<p>' + _('''
            The template to use for generating the link. In addition to {0} and {1}
            you can also use {2}, {3} and {4} variables
            in the template, they will be replaced by the source filename, the destination
            filename and the anchor, respectively.
        ''').format('_TITLE_', '_TARGET', '_SOURCE_FILENAME_',
                    '_DEST_FILENAME_', '_ANCHOR_'))

        l.addWidget(self.bb)
Esempio n. 32
0
    def __init__(self, parent = None):
        super(SettingsWidget, self).__init__(parent, Qt.FramelessWindowHint)
        self._mousePressed = False
        self._orgPos = QPoint(0, 0)
        self.setObjectName('SettingsWidget')

        #
        self.stylize()

        # main layout
        labelTitle = QLabel('设置', self)
        buttonClose = JCloseButton(self)
        buttonClose.setObjectName('buttonClose')
        buttonClose.setToolTip('关闭')

        horiLayoutTitle = QHBoxLayout()
        horiLayoutTitle.setContentsMargins(6, 0, 6, 6)
        horiLayoutTitle.addWidget(labelTitle, 0, Qt.AlignTop)
        horiLayoutTitle.addStretch()
        horiLayoutTitle.addWidget(buttonClose, 0, Qt.AlignTop)

        groupBoxSettings = QGroupBox('设置端口', self)
        groupBoxSettings.setObjectName('groupBoxSettings')
        formLayoutSettings = QFormLayout(groupBoxSettings)
        formLayoutSettings.setContentsMargins(40, 10, 40, 10)
        formLayoutSettings.setVerticalSpacing(20)
        formLayoutSettings.setLabelAlignment(Qt.AlignRight)

        self.comboBoxPort = QComboBox(self)
        self.comboBoxPort.setMinimumWidth(100)
        formLayoutSettings.addRow('端口号:', self.comboBoxPort)

        self.comboBoxBaudRate = QComboBox(self)
        self.comboBoxBaudRate.setMinimumWidth(100)
        formLayoutSettings.addRow('波特率:', self.comboBoxBaudRate)

        self.labelDataBits = QComboBox(self)
        self.labelDataBits.setMinimumWidth(100)
        formLayoutSettings.addRow('数据位:', self.labelDataBits)

        self.comboBoxParity = QComboBox(self)
        self.comboBoxParity.setMinimumWidth(100)
        formLayoutSettings.addRow('校验位:', self.comboBoxParity)

        self.comboBoxStopBits = QComboBox(self)
        self.comboBoxStopBits.setMinimumWidth(100)
        formLayoutSettings.addRow('停止位:', self.comboBoxStopBits)

        # all
        horiLayoutSettings = QHBoxLayout();
        horiLayoutSettings.addStretch();
        horiLayoutSettings.addWidget(groupBoxSettings);
        horiLayoutSettings.addStretch();

        buttonOk = QPushButton('确定', self)
        buttonOk.setObjectName('buttonOk')
        horiLayoutButtons = QHBoxLayout()
        horiLayoutButtons.addStretch()
        horiLayoutButtons.addWidget(buttonOk)

        vertLayoutMain = QVBoxLayout(self)
        vertLayoutMain.addLayout(horiLayoutTitle)
        vertLayoutMain.addSpacing(5)
        # vertLayoutMain.addWidget(groupBoxSettings)
        vertLayoutMain.addLayout(horiLayoutSettings)
        vertLayoutMain.addStretch()
        vertLayoutMain.addLayout(horiLayoutButtons)

        buttonClose.clicked.connect(self.close)
Esempio n. 33
0
def ask_about_cc_mismatch(gui, db, newdb, missing_cols, incompatible_cols):  # {{{
    source_metadata = db.field_metadata.custom_field_metadata(include_composites=True)
    ndbname = os.path.basename(newdb.library_path)

    d = QDialog(gui)
    d.setWindowTitle(_('Different custom columns'))
    l = QFormLayout()
    tl = QVBoxLayout()
    d.setLayout(tl)
    d.s = QScrollArea(d)
    tl.addWidget(d.s)
    d.w = QWidget(d)
    d.s.setWidget(d.w)
    d.s.setWidgetResizable(True)
    d.w.setLayout(l)
    d.setMinimumWidth(600)
    d.setMinimumHeight(500)
    d.bb = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)

    msg = _('The custom columns in the <i>{0}</i> library are different from the '
        'custom columns in the <i>{1}</i> library. As a result, some metadata might not be copied.').format(
        os.path.basename(db.library_path), ndbname)
    d.la = la = QLabel(msg)
    la.setWordWrap(True)
    la.setStyleSheet('QLabel { margin-bottom: 1.5ex }')
    l.addRow(la)
    if incompatible_cols:
        la = d.la2 = QLabel(_('The following columns are incompatible - they have the same name'
                ' but different data types. They will be ignored: ') +
                    ', '.join(sorted(incompatible_cols, key=sort_key)))
        la.setWordWrap(True)
        la.setStyleSheet('QLabel { margin-bottom: 1.5ex }')
        l.addRow(la)

    missing_widgets = []
    if missing_cols:
        la = d.la3 = QLabel(_('The following columns are missing in the <i>{0}</i> library.'
                                ' You can choose to add them automatically below.').format(
                                    ndbname))
        la.setWordWrap(True)
        l.addRow(la)
        for k in missing_cols:
            widgets = (k, QCheckBox(_('Add to the %s library') % ndbname))
            l.addRow(QLabel(k), widgets[1])
            missing_widgets.append(widgets)
    d.la4 = la = QLabel(_('This warning is only shown once per library, per session'))
    la.setWordWrap(True)
    tl.addWidget(la)

    tl.addWidget(d.bb)
    d.bb.accepted.connect(d.accept)
    d.bb.rejected.connect(d.reject)
    d.resize(d.sizeHint())
    if d.exec_() == d.Accepted:
        for k, cb in missing_widgets:
            if cb.isChecked():
                col_meta = source_metadata[k]
                newdb.create_custom_column(
                            col_meta['label'], col_meta['name'], col_meta['datatype'],
                            len(col_meta['is_multiple']) > 0,
                            col_meta['is_editable'], col_meta['display'])
        return True
    return False
Esempio n. 34
0
    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