コード例 #1
0
class Inspector(QWidget):

    def __init__(self, dock_action, parent=None):
        QWidget.__init__(self, parent=parent)
        self.view_to_debug = parent
        self.view = None
        self.layout = QHBoxLayout(self)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.dock_action = dock_action
        QTimer.singleShot(0, self.connect_to_dock)

    def connect_to_dock(self):
        ac = self.dock_action
        ac.toggled.connect(self.visibility_changed)
        if ac.isChecked():
            self.visibility_changed(True)

    def visibility_changed(self, visible):
        if visible and self.view is None:
            self.view = QWebEngineView(self.view_to_debug)
            self.view_to_debug.page().setDevToolsPage(self.view.page())
            self.layout.addWidget(self.view)

    def sizeHint(self):
        return QSize(600, 1200)
コード例 #2
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self.sa = QScrollArea(self)
        self.lw = QWidget(self)
        self.l = QVBoxLayout(self.lw)
        self.sa.setWidget(self.lw), self.sa.setWidgetResizable(True)
        self.gl = gl = QVBoxLayout(self)
        self.la = QLabel(_(
            'Add new locations to search for books or authors using the "Search the internet" feature'
            ' of the Content server. The URLs should contain {author} which will be'
            ' replaced by the author name and, for book URLs, {title} which will'
            ' be replaced by the book title.'))
        self.la.setWordWrap(True)
        gl.addWidget(self.la)

        self.h = QHBoxLayout()
        gl.addLayout(self.h)
        self.add_url_button = b = QPushButton(QIcon(I('plus.png')), _('&Add URL'))
        b.clicked.connect(self.add_url)
        self.h.addWidget(b)
        self.export_button = b = QPushButton(_('Export URLs'))
        b.clicked.connect(self.export_urls)
        self.h.addWidget(b)
        self.import_button = b = QPushButton(_('Import URLs'))
        b.clicked.connect(self.import_urls)
        self.h.addWidget(b)
        self.clear_button = b = QPushButton(_('Clear'))
        b.clicked.connect(self.clear)
        self.h.addWidget(b)

        self.h.addStretch(10)
        gl.addWidget(self.sa, stretch=10)
        self.items = []
コード例 #3
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.l = l = QHBoxLayout(self)
        self.lp = lp = QVBoxLayout()
        l.addLayout(lp)

        self.h = h = QHBoxLayout()
        lp.addLayout(h)
        self.add_button = b = QPushButton(QIcon(I('plus.png')), _('&Add user'), self)
        b.clicked.connect(self.add_user)
        h.addWidget(b)
        self.remove_button = b = QPushButton(
            QIcon(I('minus.png')), _('&Remove user'), self
        )
        b.clicked.connect(self.remove_user)
        h.addStretch(2), h.addWidget(b)

        self.user_list = w = QListWidget(self)
        w.setSpacing(1)
        w.doubleClicked.connect(self.current_user_activated)
        w.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Expanding)
        lp.addWidget(w)

        self.user_display = u = User(self)
        u.changed_signal.connect(self.changed_signal.emit)
        l.addWidget(u)
コード例 #4
0
class Spacer(QWidget):  # {{{

    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self.l = QHBoxLayout()
        self.setLayout(self.l)
        self.l.addStretch(10)
コード例 #5
0
 def setup_ui(self):
     self.l = l = QVBoxLayout(self)
     self.recipes = r = QTreeView(self)
     r.setAnimated(True)
     r.setHeaderHidden(True)
     self.model = ChooseBuiltinRecipeModel(self)
     self.model.setSourceModel(self.recipe_model)
     r.setModel(self.model)
     r.doubleClicked.connect(self.accept)
     self.search = s = SearchBox2(self)
     self.search.initialize('scheduler_search_history')
     self.search.setMinimumContentsLength(15)
     self.search.search.connect(self.recipe_model.search)
     self.recipe_model.searched.connect(
         self.search.search_done, type=Qt.ConnectionType.QueuedConnection)
     self.recipe_model.searched.connect(self.search_done)
     self.go_button = b = QToolButton(self)
     b.setText(_("Go"))
     b.clicked.connect(self.search.do_search)
     h = QHBoxLayout()
     h.addWidget(s), h.addWidget(b)
     l.addLayout(h)
     l.addWidget(self.recipes)
     l.addWidget(self.bb)
     self.search.setFocus(Qt.FocusReason.OtherFocusReason)
コード例 #6
0
class CursorPositionWidget(QWidget):  # {{{

    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self.l = QHBoxLayout(self)
        self.setLayout(self.l)
        self.la = QLabel('')
        self.l.addWidget(self.la)
        self.l.setContentsMargins(0, 0, 0, 0)
        f = self.la.font()
        f.setBold(False)
        self.la.setFont(f)

    def update_position(self, line=None, col=None, character=None):
        if line is None:
            self.la.setText('')
        else:
            try:
                name = character_name_from_code(ord_string(character)[0]) if character and tprefs['editor_show_char_under_cursor'] else None
            except Exception:
                name = None
            text = _('Line: {0} : {1}').format(line, col)
            if not name:
                name = {'\t':'TAB'}.get(character, None)
            if name and tprefs['editor_show_char_under_cursor']:
                text = name + ' : ' + text
            self.la.setText(text)
コード例 #7
0
 def __init__(self, dock_action, parent=None):
     QWidget.__init__(self, parent=parent)
     self.view_to_debug = parent
     self.view = None
     self.layout = QHBoxLayout(self)
     self.layout.setContentsMargins(0, 0, 0, 0)
     self.dock_action = dock_action
     QTimer.singleShot(0, self.connect_to_dock)
コード例 #8
0
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     self.l = QHBoxLayout(self)
     self.setLayout(self.l)
     self.la = QLabel('')
     self.l.addWidget(self.la)
     self.l.setContentsMargins(0, 0, 0, 0)
     f = self.la.font()
     f.setBold(False)
     self.la.setFont(f)
コード例 #9
0
 def create_color_button(key, text):
     b = ColorButton(data, key, text, self)
     b.changed.connect(self.changed), l.addWidget(b)
     bc = QToolButton(self)
     bc.setIcon(QIcon(I('clear_left.png')))
     bc.setToolTip(_('Remove color'))
     bc.clicked.connect(b.clear)
     h = QHBoxLayout()
     h.addWidget(b), h.addWidget(bc)
     return h
コード例 #10
0
 def __init__(self, model, parent=None):
     QWidget.__init__(self, parent)
     self._layout = QHBoxLayout()
     self.setLayout(self._layout)
     self.view = QListView(self)
     self._layout.addWidget(self.view)
     self.view.setModel(model)
     self.delegate = Delegate()
     self.view.setItemDelegate(self.delegate)
     self.delegate.sizeHintChanged.connect(
         self.scrollTo, type=Qt.ConnectionType.QueuedConnection)
コード例 #11
0
 def __init__(self, parent=None):
     super().__init__(parent)
     l = QHBoxLayout(self)
     l.setContentsMargins(0, 0, 0, 0)
     self.edit = le = GenericEdit(self)
     l.addWidget(le)
     l.addSpacing(5)
     self.la = la = QLabel(_('<a href="{}">CSS selector help</a>').format('https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors'))
     la.setOpenExternalLinks(True)
     l.addWidget(la)
     self.setPlaceholderText = self.edit.setPlaceholderText
コード例 #12
0
    def setup_ui(self):
        self.setWindowIcon(QIcon(I('modified.png')))
        self.l = l = QVBoxLayout(self)
        self.stack = s = QStackedLayout()
        l.addLayout(s), l.addWidget(self.bb)
        self.listc = c = QWidget(self)
        s.addWidget(c)
        c.l = l = QVBoxLayout(c)
        c.h = h = QHBoxLayout()
        l.addLayout(h)

        self.search_bar = sb = QLineEdit(self)
        sb.setPlaceholderText(_('Search for a snippet'))
        h.addWidget(sb)
        self.next_button = b = QPushButton(_('&Next'))
        b.clicked.connect(self.find_next)
        h.addWidget(b)

        c.h2 = h = QHBoxLayout()
        l.addLayout(h)
        self.snip_list = sl = QListWidget(self)
        sl.doubleClicked.connect(self.edit_snippet)
        h.addWidget(sl)

        c.l2 = l = QVBoxLayout()
        h.addLayout(l)
        self.add_button = b = QToolButton(self)
        b.setIcon(QIcon(I('plus.png'))), b.setText(_('&Add snippet')), b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextUnderIcon)
        b.clicked.connect(self.add_snippet)
        l.addWidget(b)

        self.edit_button = b = QToolButton(self)
        b.setIcon(QIcon(I('modified.png'))), b.setText(_('&Edit snippet')), b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextUnderIcon)
        b.clicked.connect(self.edit_snippet)
        l.addWidget(b)

        self.add_button = b = QToolButton(self)
        b.setIcon(QIcon(I('minus.png'))), b.setText(_('&Remove snippet')), b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextUnderIcon)
        b.clicked.connect(self.remove_snippet)
        l.addWidget(b)

        self.add_button = b = QToolButton(self)
        b.setIcon(QIcon(I('config.png'))), b.setText(_('Change &built-in')), b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextUnderIcon)
        b.clicked.connect(self.change_builtin)
        l.addWidget(b)

        for i, snip in enumerate(sorted(user_snippets.get('snippets', []), key=itemgetter('trigger'))):
            item = self.snip_to_item(snip)
            if i == 0:
                self.snip_list.setCurrentItem(item)

        self.edit_snip = es = EditSnippet(self)
        self.stack.addWidget(es)
コード例 #13
0
    def __init__(self):
        QWidget.__init__(self)
        self.l = QHBoxLayout()
        self.setLayout(self.l)

        self.label = QLabel('Hello world &message:')
        self.l.addWidget(self.label)

        self.msg = QLineEdit(self)
        self.msg.setText(prefs['hello_world_msg'])
        self.l.addWidget(self.msg)
        self.label.setBuddy(self.msg)
コード例 #14
0
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     self.l = l = QVBoxLayout(self)
     self.cover = ZoomedCover(self)
     l.addWidget(self.cover)
     self.h = QHBoxLayout()
     l.addLayout(self.h)
     self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close, self)
     self.size_label = QLabel(self)
     self.h.addWidget(self.size_label)
     self.h.addStretch(10)
     self.h.addWidget(self.bb)
コード例 #15
0
class DaysOfWeek(Base):

    HELP = _('''\
                Download this periodical every week on the specified days after
                the specified time. For example, if you choose: Monday after
                9:00 AM, then the periodical will be download every Monday as
                soon after 9:00 AM as possible.
            ''')

    def __init__(self, parent=None):
        Base.__init__(self, parent)
        self.days = [
            QCheckBox(force_unicode(calendar.day_abbr[d]), self)
            for d in range(7)
        ]
        for i, cb in enumerate(self.days):
            row = i % 2
            col = i // 2
            self.l.addWidget(cb, row, col, 1, 1)

        self.time = QTimeEdit(self)
        self.time.setDisplayFormat('hh:mm AP')
        if canonicalize_lang(get_lang()) in {'deu', 'nds'}:
            self.time.setDisplayFormat('HH:mm')
        self.hl = QHBoxLayout()
        self.l1 = QLabel(_('&Download after:'))
        self.l1.setBuddy(self.time)
        self.hl.addWidget(self.l1)
        self.hl.addWidget(self.time)
        self.l.addLayout(self.hl, 1, 3, 1, 1)
        self.initialize()

    def initialize(self, typ=None, val=None):
        if typ is None:
            typ = 'day/time'
            val = (-1, 6, 0)
        if typ == 'day/time':
            val = convert_day_time_schedule(val)

        days_of_week, hour, minute = val
        for i, d in enumerate(self.days):
            d.setChecked(i in days_of_week)

        self.time.setTime(QTime(hour, minute))

    @property
    def schedule(self):
        days_of_week = tuple(
            [i for i, d in enumerate(self.days) if d.isChecked()])
        t = self.time.time()
        hour, minute = t.hour(), t.minute()
        return 'days_of_week', (days_of_week, int(hour), int(minute))
コード例 #16
0
ファイル: copy_to_library.py プロジェクト: smdx023/calibre
    def setup_ui(self):
        self.l = l = QGridLayout(self)
        self.items = i = QListWidget(self)
        i.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
        i.currentItemChanged.connect(self.current_changed)
        l.addWidget(i)
        self.v = v = QVBoxLayout()
        l.addLayout(v, 0, 1)
        self.sort_alphabetically = sa = QCheckBox(
            _('&Sort libraries alphabetically'))
        v.addWidget(sa)
        sa.setChecked(
            bool(
                gprefs.get(
                    'copy_to_library_choose_library_sort_alphabetically',
                    True)))
        sa.stateChanged.connect(self.resort)

        connect_lambda(
            sa.stateChanged, self, lambda self: gprefs.set(
                'copy_to_library_choose_library_sort_alphabetically',
                bool(self.sort_alphabetically.isChecked())))
        la = self.la = QLabel(_('Library &path:'))
        v.addWidget(la)
        le = self.le = QLineEdit(self)
        la.setBuddy(le)
        b = self.b = QToolButton(self)
        b.setIcon(QIcon(I('document_open.png')))
        b.setToolTip(_('Browse for library'))
        b.clicked.connect(self.browse)
        h = QHBoxLayout()
        h.addWidget(le), h.addWidget(b)
        v.addLayout(h)
        v.addStretch(10)
        bb = self.bb
        bb.setStandardButtons(QDialogButtonBox.StandardButton.Cancel)
        self.delete_after_copy = False
        b = bb.addButton(_('&Copy'), QDialogButtonBox.ButtonRole.AcceptRole)
        b.setIcon(QIcon(I('edit-copy.png')))
        b.setToolTip(_('Copy to the specified library'))
        b2 = bb.addButton(_('&Move'), QDialogButtonBox.ButtonRole.AcceptRole)
        connect_lambda(b2.clicked, self,
                       lambda self: setattr(self, 'delete_after_copy', True))
        b2.setIcon(QIcon(I('edit-cut.png')))
        b2.setToolTip(
            _('Copy to the specified library and delete from the current library'
              ))
        b.setDefault(True)
        l.addWidget(bb, 1, 0, 1, 2)
        self.items.setFocus(Qt.FocusReason.OtherFocusReason)
コード例 #17
0
ファイル: trim_image.py プロジェクト: kovidgoyal/calibre
    def __init__(self, img_data, parent=None):
        QDialog.__init__(self, parent)
        self.l = l = QVBoxLayout(self)
        self.setWindowTitle(_('Trim Image'))

        self.bar = b = QToolBar(self)
        l.addWidget(b)
        b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
        b.setIconSize(QSize(32, 32))

        self.msg = la = QLabel('\xa0' + _(
            'Select a region by dragging with your mouse, and then click trim')
                               )
        self.msg_txt = self.msg.text()
        self.sz = QLabel('')

        self.canvas = c = Canvas(self)
        c.image_changed.connect(self.image_changed)
        c.load_image(img_data)
        self.undo_action = u = c.undo_action
        u.setShortcut(QKeySequence(QKeySequence.StandardKey.Undo))
        self.redo_action = r = c.redo_action
        r.setShortcut(QKeySequence(QKeySequence.StandardKey.Redo))
        self.trim_action = ac = self.bar.addAction(QIcon(I('trim.png')),
                                                   _('&Trim'), self.do_trim)
        ac.setShortcut(QKeySequence('Ctrl+T'))
        ac.setToolTip('{} [{}]'.format(
            _('Trim image by removing borders outside the selected region'),
            ac.shortcut().toString(QKeySequence.SequenceFormat.NativeText)))
        ac.setEnabled(False)
        c.selection_state_changed.connect(self.selection_changed)
        c.selection_area_changed.connect(self.selection_area_changed)
        l.addWidget(c)
        self.bar.addAction(self.trim_action)
        self.bar.addSeparator()
        self.bar.addAction(u)
        self.bar.addAction(r)
        self.bar.addSeparator()
        self.bar.addWidget(la)
        self.bar.addSeparator()
        self.bar.addWidget(self.sz)

        self.bb = bb = QDialogButtonBox(
            QDialogButtonBox.StandardButton.Ok
            | QDialogButtonBox.StandardButton.Cancel)
        bb.accepted.connect(self.accept)
        bb.rejected.connect(self.reject)
        h = QHBoxLayout()
        l.addLayout(h)
        self.tr_sz = QLabel('')
        h.addWidget(self.tr_sz)
        h.addStretch(10)
        h.addWidget(bb)

        self.resize(QSize(900, 600))
        geom = gprefs.get('image-trim-dialog-geometry', None)
        if geom is not None:
            QApplication.instance().safe_restore_geometry(self, geom)
        self.setWindowIcon(self.trim_action.icon())
        self.image_data = None
コード例 #18
0
    def setup_ui(self):
        from calibre.ebooks.oeb.polish.images import get_compressible_images
        self.setWindowIcon(QIcon(I('compress-image.png')))
        self.h = h = QHBoxLayout(self)
        self.images = i = QListWidget(self)
        h.addWidget(i)
        self.l = l = QVBoxLayout()
        h.addLayout(l)
        c = current_container()
        for name in sorted(get_compressible_images(c), key=numeric_sort_key):
            x = QListWidgetItem(name, i)
            x.setData(Qt.ItemDataRole.UserRole, c.filesize(name))
        i.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
        i.setMinimumHeight(350), i.setMinimumWidth(350)
        i.selectAll(), i.setSpacing(5)
        self.delegate = ImageItemDelegate(self)
        i.setItemDelegate(self.delegate)
        self.la = la = QLabel(
            _('You can compress the images in this book losslessly, reducing the file size of the book,'
              ' without affecting image quality. Typically image size is reduced by 5 - 15%.'
              ))
        la.setWordWrap(True)
        la.setMinimumWidth(250)
        l.addWidget(la), l.addSpacing(30)

        self.enable_lossy = el = QCheckBox(
            _('Enable &lossy compression of JPEG images'))
        el.setToolTip(
            _('This allows you to change the quality factor used for JPEG images.\nBy lowering'
              ' the quality you can greatly reduce file size, at the expense of the image looking blurred.'
              ))
        l.addWidget(el)
        self.h2 = h = QHBoxLayout()
        l.addLayout(h)
        self.jq = jq = QSpinBox(self)
        jq.setMinimum(0), jq.setMaximum(100), jq.setValue(
            tprefs.get('jpeg_compression_quality_for_lossless_compression',
                       80)), jq.setEnabled(False)
        jq.setToolTip(
            _('The compression quality, 1 is high compression, 100 is low compression.\nImage'
              ' quality is inversely correlated with compression quality.'))
        jq.valueChanged.connect(self.save_compression_quality)
        el.toggled.connect(jq.setEnabled)
        self.jql = la = QLabel(_('Compression &quality:'))
        la.setBuddy(jq)
        h.addWidget(la), h.addWidget(jq)
        l.addStretch(10)
        l.addWidget(self.bb)
コード例 #19
0
 def __init__(self, pa, parent):
     QDialog.__init__(self, parent)
     self.test_func = parent.test_email_settings
     self.setWindowTitle(_("Test email settings"))
     self.setWindowIcon(QIcon(I('config.ui')))
     l = QVBoxLayout(self)
     opts = smtp_prefs().parse()
     self.from_ = la = QLabel(_("Send test mail from %s to:") % opts.from_)
     l.addWidget(la)
     self.to = le = QLineEdit(self)
     if pa:
         self.to.setText(pa)
     self.test_button = b = QPushButton(_('&Test'), self)
     b.clicked.connect(self.start_test)
     self.test_done.connect(self.on_test_done,
                            type=Qt.ConnectionType.QueuedConnection)
     self.h = h = QHBoxLayout()
     h.addWidget(le), h.addWidget(b)
     l.addLayout(h)
     if opts.relay_host:
         self.la = la = QLabel(
             _('Using: %(un)s:%(pw)s@%(host)s:%(port)s and %(enc)s encryption'
               ) % dict(un=opts.relay_username,
                        pw=from_hex_unicode(opts.relay_password),
                        host=opts.relay_host,
                        port=opts.relay_port,
                        enc=opts.encryption))
         l.addWidget(la)
     self.log = QPlainTextEdit(self)
     l.addWidget(self.log)
     self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close)
     bb.rejected.connect(self.reject), bb.accepted.connect(self.accept)
     l.addWidget(bb)
コード例 #20
0
ファイル: image_popup.py プロジェクト: zmshan2008/calibre
    def __init__(self,
                 parent,
                 current_img,
                 current_url,
                 geom_name='viewer_image_popup_geometry'):
        QDialog.__init__(self)
        self.current_image_name = ''
        self.setWindowFlag(Qt.WindowType.WindowMinimizeButtonHint)
        self.setWindowFlag(Qt.WindowType.WindowMaximizeButtonHint)
        dw = QApplication.instance().desktop()
        self.avail_geom = dw.availableGeometry(
            parent if parent is not None else self)
        self.current_img = current_img
        self.current_url = current_url
        self.factor = 1.0
        self.geom_name = geom_name

        self.scrollarea = sa = QScrollArea()
        sa.setAlignment(Qt.AlignmentFlag.AlignHCenter
                        | Qt.AlignmentFlag.AlignVCenter)
        sa.setBackgroundRole(QPalette.ColorRole.Dark)
        self.label = l = Label(sa)
        l.toggle_fit.connect(self.toggle_fit)
        sa.setWidget(l)

        self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close)
        bb.accepted.connect(self.accept)
        bb.rejected.connect(self.reject)
        self.zi_button = zi = bb.addButton(
            _('Zoom &in'), QDialogButtonBox.ButtonRole.ActionRole)
        self.zo_button = zo = bb.addButton(
            _('Zoom &out'), QDialogButtonBox.ButtonRole.ActionRole)
        self.save_button = so = bb.addButton(
            _('&Save as'), QDialogButtonBox.ButtonRole.ActionRole)
        self.rotate_button = ro = bb.addButton(
            _('&Rotate'), QDialogButtonBox.ButtonRole.ActionRole)
        zi.setIcon(QIcon(I('plus.png')))
        zo.setIcon(QIcon(I('minus.png')))
        so.setIcon(QIcon(I('save.png')))
        ro.setIcon(QIcon(I('rotate-right.png')))
        zi.clicked.connect(self.zoom_in)
        zo.clicked.connect(self.zoom_out)
        so.clicked.connect(self.save_image)
        ro.clicked.connect(self.rotate_image)

        self.l = l = QVBoxLayout(self)
        l.addWidget(sa)
        self.h = h = QHBoxLayout()
        h.setContentsMargins(0, 0, 0, 0)
        l.addLayout(h)
        self.fit_image = i = QCheckBox(_('&Fit image'))
        i.setToolTip(_('Fit image inside the available space'))
        i.setChecked(bool(gprefs.get('image_popup_fit_image')))
        i.stateChanged.connect(self.fit_changed)
        h.addWidget(i), h.addStretch(), h.addWidget(bb)
        if self.fit_image.isChecked():
            self.set_to_viewport_size()
        geom = gprefs.get(self.geom_name)
        if geom is not None:
            self.restoreGeometry(geom)
コード例 #21
0
    def setup_ui(self):
        self.pb = pb = QProgressBar(self)
        pb.setTextVisible(True)
        pb.setSizePolicy(QSizePolicy.Policy.Expanding,
                         QSizePolicy.Policy.Fixed)
        pb.setRange(0, 0)
        self.w = w = QWidget(self)
        self.w.l = l = QVBoxLayout(w)
        l.addStretch(), l.addWidget(pb)
        self.w.la = la = QLabel(_('Checking external links, please wait...'))
        la.setStyleSheet('QLabel { font-size: 20px; font-weight: bold }')
        l.addWidget(la, 0, Qt.AlignmentFlag.AlignCenter), l.addStretch()

        self.l = l = QVBoxLayout(self)
        self.results = QTextBrowser(self)
        self.results.setOpenLinks(False)
        self.results.anchorClicked.connect(self.anchor_clicked)
        self.stack = s = QStackedWidget(self)
        s.addWidget(w), s.addWidget(self.results)
        l.addWidget(s)
        self.bh = h = QHBoxLayout()
        self.check_anchors = ca = QCheckBox(_('Check &anchors'))
        ca.setToolTip(
            _('Check HTML anchors in links (the part after the #).\n'
              ' This can be a little slow, since it requires downloading and parsing all the HTML pages.'
              ))
        ca.setChecked(tprefs.get('check_external_link_anchors', True))
        ca.stateChanged.connect(self.anchors_changed)
        h.addWidget(ca), h.addStretch(100), h.addWidget(self.bb)
        l.addLayout(h)
        self.bb.setStandardButtons(QDialogButtonBox.StandardButton.Close)
        self.rb = b = self.bb.addButton(_('&Refresh'),
                                        QDialogButtonBox.ButtonRole.ActionRole)
        b.setIcon(QIcon(I('view-refresh.png')))
        b.clicked.connect(self.refresh)
コード例 #22
0
 def __init__(self, parent=None, object_name='', show_msg=True):
     QWidget.__init__(self, parent)
     self.h = h = QHBoxLayout(self)
     h.setContentsMargins(0, 0, 0, 0)
     self.l = l = QVBoxLayout()
     h.addLayout(l)
     self.button = b = QToolButton(self)
     b.setIcon(QIcon(I('wizard.png')))
     b.setToolTip(_('Use a wizard to generate the XPath expression'))
     b.clicked.connect(self.wizard)
     h.addWidget(b)
     self.edit = e = HistoryLineEdit(self)
     e.setMinimumWidth(350)
     e.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
     e.setMinimumContentsLength(30)
     self.msg = QLabel('')
     l.addWidget(self.msg)
     l.addWidget(self.edit)
     if object_name:
         self.setObjectName(object_name)
     if show_msg:
         b.setIconSize(QSize(40, 40))
         self.msg.setBuddy(self.edit)
     else:
         self.msg.setVisible(False)
         l.setContentsMargins(0, 0, 0, 0)
コード例 #23
0
ファイル: conversion.py プロジェクト: smdx023/calibre
 def setupUi(self, x):
     self.resize(720, 603)
     self.l = l = QHBoxLayout(self)
     self.list = lv = ListView(self)
     l.addWidget(lv)
     self.stack = s = QStackedWidget(self)
     l.addWidget(s, stretch=10)
コード例 #24
0
ファイル: jobs.py プロジェクト: kovidgoyal/calibre
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.num_jobs = 0
        self.mouse_over = False
        self.pi = ProgressIndicator(self, self.style().pixelMetric(QStyle.PixelMetric.PM_ToolBarIconSize))
        self.pi.setVisible(False)
        self._jobs = QLabel('')
        self._jobs.mouseReleaseEvent = self.mouseReleaseEvent
        self.update_label()
        self.shortcut = 'Alt+Shift+J'

        self.l = l = QHBoxLayout(self)
        l.setSpacing(3)
        l.addWidget(self.pi)
        l.addWidget(self._jobs)
        m = self.style().pixelMetric(QStyle.PixelMetric.PM_DefaultFrameWidth)
        self.layout().setContentsMargins(m, m, m, m)
        self._jobs.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum)
        self.setCursor(Qt.CursorShape.PointingHandCursor)
        b = _('Click to see list of jobs')
        self.setToolTip(b + _(' [Alt+Shift+J]'))
        self.action_toggle = QAction(b, parent)
        parent.addAction(self.action_toggle)
        self.action_toggle.triggered.connect(self.toggle)
        if hasattr(parent, 'keyboard'):
            parent.keyboard.register_shortcut('toggle jobs list', _('Show/hide the Jobs List'), default_keys=(self.shortcut,), action=self.action_toggle)
コード例 #25
0
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self._layout = l = QVBoxLayout(self)
     self.header = QLabel(
         _('Double click on any entry to change the'
           ' keyboard shortcuts associated with it'))
     l.addWidget(self.header)
     self.view = QTreeView(self)
     self.view.setAlternatingRowColors(True)
     self.view.setHeaderHidden(True)
     self.view.setAnimated(True)
     self.view.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
     self.view.customContextMenuRequested.connect(self.show_context_menu)
     l.addWidget(self.view)
     self.delegate = Delegate()
     self.view.setItemDelegate(self.delegate)
     self.delegate.sizeHintChanged.connect(
         self.editor_opened, type=Qt.ConnectionType.QueuedConnection)
     self.delegate.changed_signal.connect(self.changed_signal)
     self.search = SearchBox2(self)
     self.search.initialize('shortcuts_search_history',
                            help_text=_('Search for a shortcut by name'))
     self.search.search.connect(self.find)
     self._h = h = QHBoxLayout()
     l.addLayout(h)
     h.addWidget(self.search)
     self.nb = QPushButton(QIcon(I('arrow-down.png')), _('&Next'), self)
     self.pb = QPushButton(QIcon(I('arrow-up.png')), _('&Previous'), self)
     self.nb.clicked.connect(self.find_next)
     self.pb.clicked.connect(self.find_previous)
     h.addWidget(self.nb), h.addWidget(self.pb)
     h.setStretch(0, 100)
コード例 #26
0
 def __init__(self, parent=None, show_open_in_editor=False):
     QWidget.__init__(self, parent)
     self.changes = [[], [], []]
     self.delta = 0
     self.l = l = QHBoxLayout(self)
     self.setLayout(l)
     self.syncpos = 0
     l.setContentsMargins(0, 0, 0, 0), l.setSpacing(0)
     self.view = DiffSplit(self, show_open_in_editor=show_open_in_editor)
     l.addWidget(self.view)
     self.add_diff = self.view.add_diff
     self.scrollbar = QScrollBar(self)
     l.addWidget(self.scrollbar)
     self.syncing = False
     self.bars = []
     self.resize_timer = QTimer(self)
     self.resize_timer.setSingleShot(True)
     self.resize_timer.timeout.connect(self.resize_debounced)
     for bar in (self.scrollbar, self.view.left.verticalScrollBar(), self.view.right.verticalScrollBar()):
         self.bars.append(bar)
         bar.scroll_idx = len(self.bars) - 1
         connect_lambda(bar.valueChanged[int], self, lambda self: self.scrolled(self.sender().scroll_idx))
     self.view.left.resized.connect(self.resized)
     for v in (self.view.left, self.view.right, self.view.handle(1)):
         v.wheel_event.connect(self.scrollbar.wheelEvent)
         if v is self.view.left or v is self.view.right:
             v.next_change.connect(self.next_change)
             v.line_activated.connect(self.line_activated)
             connect_lambda(v.scrolled, self,
                     lambda self: self.scrolled(1 if self.sender() is self.view.left else 2))
コード例 #27
0
 def __init__(self, parent=None):
     self.loaded_ruleset = None
     QWidget.__init__(self, parent)
     self.PREFS_OBJECT = JSONConfig('style-transform-rules')
     l = QVBoxLayout(self)
     self.rules_widget = w = Rules(self)
     w.changed.connect(self.changed.emit)
     l.addWidget(w)
     self.h = h = QHBoxLayout()
     l.addLayout(h)
     self.export_button = b = QPushButton(_('E&xport'), self)
     b.setToolTip(_('Export these rules to a file'))
     b.clicked.connect(self.export_rules)
     h.addWidget(b)
     self.import_button = b = QPushButton(_('&Import'), self)
     b.setToolTip(_('Import previously exported rules'))
     b.clicked.connect(self.import_rules)
     h.addWidget(b)
     self.test_button = b = QPushButton(_('&Test rules'), self)
     b.clicked.connect(self.test_rules)
     h.addWidget(b)
     h.addStretch(10)
     self.save_button = b = QPushButton(_('&Save'), self)
     b.setToolTip(_('Save this ruleset for later re-use'))
     b.clicked.connect(self.save_ruleset)
     h.addWidget(b)
     self.export_button = b = QPushButton(_('&Load'), self)
     self.load_menu = QMenu(self)
     b.setMenu(self.load_menu)
     b.setToolTip(_('Load a previously saved ruleset'))
     b.clicked.connect(self.load_ruleset)
     h.addWidget(b)
     self.build_load_menu()
コード例 #28
0
    def setup_ui(self):
        self.l = l = QVBoxLayout(self)
        self.h = h = QHBoxLayout()
        l.addLayout(h)

        self.la1 = la = QLabel(_('F&unction name:'))
        h.addWidget(la)
        self.fb = fb = FunctionBox(self)
        la.setBuddy(fb)
        h.addWidget(fb, stretch=10)

        self.la3 = la = QLabel(_('&Code:'))
        self.source_code = TextEdit(self)
        self.source_code.load_text('', 'python')
        la.setBuddy(self.source_code)
        l.addWidget(la), l.addWidget(self.source_code)

        if self._func_name:
            self.fb.setText(self._func_name)
            func = functions().get(self._func_name)
            if func is not None:
                self.source_code.setPlainText(func.source
                                              or ('\n' + EMPTY_FUNC))
        else:
            self.source_code.setPlainText('\n' + EMPTY_FUNC)

        self.la2 = la = QLabel(
            _('For help with creating functions, see the <a href="%s">User Manual</a>'
              ) % localize_user_manual_link(
                  'https://manual.calibre-ebook.com/function_mode.html'))
        la.setOpenExternalLinks(True)
        l.addWidget(la)

        l.addWidget(self.bb)
コード例 #29
0
ファイル: web_store.py プロジェクト: qykth-git/calibre
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.l = l = QVBoxLayout(self)
        self.view = v = QWebEngineView(self)
        v.loadStarted.connect(self.load_started)
        v.loadProgress.connect(self.load_progress)
        v.loadFinished.connect(self.load_finished)
        l.addWidget(v)
        self.h = h = QHBoxLayout()
        l.addLayout(h)
        self.download_progress = d = DownloadProgress(self)
        h.addWidget(d)

        self.home_button = b = QPushButton(_('Home'))
        b.clicked.connect(self.home)
        h.addWidget(b)
        self.back_button = b = QPushButton(_('Back'))
        b.clicked.connect(v.back)
        h.addWidget(b)
        self.forward_button = b = QPushButton(_('Forward'))
        b.clicked.connect(v.forward)
        h.addWidget(b)

        self.progress_bar = b = QProgressBar(self)
        h.addWidget(b)

        self.reload_button = b = QPushButton(_('Reload'))
        b.clicked.connect(v.reload)
        h.addWidget(b)
コード例 #30
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)