コード例 #1
0
 def view_server_logs(self):
     from calibre.library.server import log_access_file, log_error_file
     d = QDialog(self)
     d.resize(QSize(800, 600))
     layout = QVBoxLayout()
     d.setLayout(layout)
     layout.addWidget(QLabel(_('Error log:')))
     el = QPlainTextEdit(d)
     layout.addWidget(el)
     try:
         el.setPlainText(
             open(log_error_file, 'rb').read().decode('utf8', 'replace'))
     except IOError:
         el.setPlainText('No error log found')
     layout.addWidget(QLabel(_('Access log:')))
     al = QPlainTextEdit(d)
     layout.addWidget(al)
     try:
         al.setPlainText(
             open(log_access_file, 'rb').read().decode('utf8', 'replace'))
     except IOError:
         al.setPlainText('No access log found')
     bx = QDialogButtonBox(QDialogButtonBox.Ok)
     layout.addWidget(bx)
     bx.accepted.connect(d.accept)
     d.show()
コード例 #2
0
ファイル: server.py プロジェクト: wpxdong/calibre
 def view_server_logs(self):
     from calibre.srv.embedded import log_paths
     log_error_file, log_access_file = log_paths()
     d = QDialog(self)
     d.resize(QSize(800, 600))
     layout = QVBoxLayout()
     d.setLayout(layout)
     layout.addWidget(QLabel(_('Error log:')))
     el = QPlainTextEdit(d)
     layout.addWidget(el)
     try:
         el.setPlainText(
             lopen(log_error_file, 'rb').read().decode('utf8', 'replace'))
     except EnvironmentError:
         el.setPlainText(_('No error log found'))
     layout.addWidget(QLabel(_('Access log:')))
     al = QPlainTextEdit(d)
     layout.addWidget(al)
     try:
         al.setPlainText(
             lopen(log_access_file, 'rb').read().decode('utf8', 'replace'))
     except EnvironmentError:
         al.setPlainText(_('No access log found'))
     loc = QLabel(
         _('The server log files are in: {}').format(
             os.path.dirname(log_error_file)))
     loc.setWordWrap(True)
     layout.addWidget(loc)
     bx = QDialogButtonBox(QDialogButtonBox.Ok)
     layout.addWidget(bx)
     bx.accepted.connect(d.accept)
     d.show()
コード例 #3
0
ファイル: search.py プロジェクト: shivangmenon/calibre
    def __init__(self, parent=None):
        QFrame.__init__(self, parent)
        self.setFrameShape(self.StyledPanel)
        self.search_index = -1
        self.search = {}
        self.original_name = None

        self.l = l = QVBoxLayout(self)
        self.title = la = QLabel('<h2>Edit...')
        self.ht = h = QHBoxLayout()
        l.addLayout(h)
        h.addWidget(la)
        self.cb = cb = QToolButton(self)
        cb.setIcon(QIcon(I('window-close.png')))
        cb.setToolTip(_('Abort editing of search'))
        h.addWidget(cb)
        cb.clicked.connect(self.abort_editing)
        self.search_name = n = QLineEdit('', self)
        n.setPlaceholderText(_('The name with which to save this search'))
        self.la1 = la = QLabel(_('&Name:'))
        la.setBuddy(n)
        self.h3 = h = QHBoxLayout()
        h.addWidget(la), h.addWidget(n)
        l.addLayout(h)

        self.find = f = QPlainTextEdit('', self)
        self.la2 = la = QLabel(_('&Find:'))
        la.setBuddy(f)
        l.addWidget(la), l.addWidget(f)

        self.replace = r = QPlainTextEdit('', self)
        self.la3 = la = QLabel(_('&Replace:'))
        la.setBuddy(r)
        l.addWidget(la), l.addWidget(r)

        self.case_sensitive = c = QCheckBox(_('Case sensitive'))
        self.h = h = QHBoxLayout()
        l.addLayout(h)
        h.addWidget(c)

        self.dot_all = d = QCheckBox(_('Dot matches all'))
        h.addWidget(d), h.addStretch(2)

        self.h2 = h = QHBoxLayout()
        l.addLayout(h)
        self.mode_box = m = ModeBox(self)
        m.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.la4 = la = QLabel(_('&Mode:'))
        la.setBuddy(m)
        h.addWidget(la), h.addWidget(m), h.addStretch(2)

        self.done_button = b = QPushButton(QIcon(I('ok.png')), _('&Done'))
        b.setToolTip(_('Finish editing of search'))
        h.addWidget(b)
        b.clicked.connect(self.emit_done)
コード例 #4
0
    def view_server_logs(self):
        from calibre.srv.embedded import log_paths
        log_error_file, log_access_file = log_paths()
        d = QDialog(self)
        d.resize(QSize(800, 600))
        layout = QVBoxLayout()
        d.setLayout(layout)
        layout.addWidget(QLabel(_('Error log:')))
        el = QPlainTextEdit(d)
        layout.addWidget(el)
        try:
            el.setPlainText(
                lopen(log_error_file, 'rb').read().decode('utf8', 'replace'))
        except EnvironmentError:
            el.setPlainText(_('No error log found'))
        layout.addWidget(QLabel(_('Access log:')))
        al = QPlainTextEdit(d)
        layout.addWidget(al)
        try:
            al.setPlainText(
                lopen(log_access_file, 'rb').read().decode('utf8', 'replace'))
        except EnvironmentError:
            al.setPlainText(_('No access log found'))
        loc = QLabel(
            _('The server log files are in: {}').format(
                os.path.dirname(log_error_file)))
        loc.setWordWrap(True)
        layout.addWidget(loc)
        bx = QDialogButtonBox(QDialogButtonBox.Ok)
        layout.addWidget(bx)
        bx.accepted.connect(d.accept)
        b = bx.addButton(_('&Clear logs'), bx.ActionRole)

        def clear_logs():
            if getattr(self.server, 'is_running', False):
                return error_dialog(
                    d,
                    _('Server running'),
                    _('Cannot clear logs while the server is running. First stop the server.'
                      ),
                    show=True)
            if self.server:
                self.server.access_log.clear()
                self.server.log.clear()
            else:
                for x in (log_error_file, log_access_file):
                    try:
                        os.remove(x)
                    except EnvironmentError as err:
                        if err.errno != errno.ENOENT:
                            raise
            el.setPlainText(''), al.setPlainText('')

        b.clicked.connect(clear_logs)
        d.show()
コード例 #5
0
    def __init__(self, log, icon):
        '''
        :param log: The text to show in the dialog
        :param icon: The window icon
        '''
        QDialog.__init__(self)

        self.setWindowTitle(_('Prince log'))
        self.setWindowIcon(icon)

        self.l = QVBoxLayout()
        self.setLayout(self.l)

        monofont = QFont('')
        monofont.setStyleHint(QFont.TypeWriter)

        self.box = QPlainTextEdit()
        self.box.setPlainText(log)
        self.box.setStyleSheet('* { font-family: monospace }')
        self.box.setMinimumWidth(500)
        self.box.setLineWrapMode(QPlainTextEdit.NoWrap)
        self.box.setReadOnly(True)
        self.box.setToolTip(
            _('<qt>Console output from the last Prince run</qt>'))
        self.l.addWidget(self.box)

        self.buttons = QDialogButtonBox(QDialogButtonBox.Ok)
        self.l.addWidget(self.buttons)
        self.buttons.accepted.connect(self.accept)

        self.adjustSize()
コード例 #6
0
ファイル: message_box.py プロジェクト: luckyman2123/calibre
 def setup_ui(self):
     self.setObjectName("Dialog")
     self.resize(497, 235)
     self.gridLayout = l = QGridLayout(self)
     l.setObjectName("gridLayout")
     self.icon_widget = Icon(self)
     l.addWidget(self.icon_widget)
     self.msg = la = QLabel(self)
     la.setWordWrap(True), la.setMinimumWidth(400)
     la.setOpenExternalLinks(True)
     la.setObjectName("msg")
     l.addWidget(la, 0, 1, 1, 1)
     self.det_msg = dm = QPlainTextEdit(self)
     dm.setReadOnly(True)
     dm.setObjectName("det_msg")
     l.addWidget(dm, 1, 0, 1, 2)
     self.bb = bb = QDialogButtonBox(self)
     bb.setStandardButtons(QDialogButtonBox.StandardButton.Ok)
     bb.setObjectName("bb")
     bb.accepted.connect(self.accept)
     bb.rejected.connect(self.reject)
     l.addWidget(bb, 3, 0, 1, 2)
     self.toggle_checkbox = tc = QCheckBox(self)
     tc.setObjectName("toggle_checkbox")
     l.addWidget(tc, 2, 0, 1, 2)
コード例 #7
0
 def setup_ui(self):
     self.resize(678, 430)
     self.setWindowTitle(_("Add books by ISBN"))
     self.setWindowIcon(QIcon(I('add_book.png')))
     self.l = l = QVBoxLayout(self)
     self.h = h = QHBoxLayout()
     l.addLayout(h)
     self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok|QDialogButtonBox.StandardButton.Cancel, self)
     bb.button(bb.Ok).setText(_('&OK'))
     l.addWidget(bb), bb.accepted.connect(self.accept), bb.rejected.connect(self.reject)
     self.ll = l = QVBoxLayout()
     h.addLayout(l)
     self.isbn_box = i = QPlainTextEdit(self)
     i.setFocus(Qt.FocusReason.OtherFocusReason)
     l.addWidget(i)
     self.paste_button = b = QPushButton(_("&Paste from clipboard"), self)
     l.addWidget(b), b.clicked.connect(self.paste)
     self.lll = l  = QVBoxLayout()
     h.addLayout(l)
     self.label = la = QLabel(_(
         "<p>Enter a list of ISBNs in the box to the left, one per line. calibre will automatically"
         " create entries for books based on the ISBN and download metadata and covers for them.</p>\n"
         "<p>Any invalid ISBNs in the list will be ignored.</p>\n"
         "<p>You can also specify a file that will be added with each ISBN. To do this enter the full"
         " path to the file after a <code>>></code>.  For example:</p>\n"
         "<p><code>9788842915232 >> %s</code></p>"), self)
     l.addWidget(la), la.setWordWrap(True)
     l.addSpacing(20)
     self.la2 = la = QLabel(_("&Tags to set on created book entries:"), self)
     l.addWidget(la)
     self.add_tags = le = QLineEdit(self)
     le.setText(', '.join(gprefs.get('add from ISBN tags', [])))
     la.setBuddy(le)
     l.addWidget(le)
     l.addStretch(10)
コード例 #8
0
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self.l = l = QFormLayout(self)
     self.username = u = QLineEdit(self)
     u.textChanged.connect(self.changed.emit)
     l.addRow(_('&Username:'******'Username for this account'))
     self.password = p = QLineEdit(self)
     l.addRow(_('&Password:'******'Password for this account'))
     p.textChanged.connect(self.changed.emit)
     p.setEchoMode(p.Password)
     self.show_password = sp = QCheckBox(_('&Show password'))
     l.addWidget(sp)
     sp.toggled.connect(lambda checked: p.setEchoMode(p.Normal if checked else p.Password))
     self.la = la = QLabel(_('&Notes:'))
     l.addRow(la)
     self.notes = n = QPlainTextEdit(self)
     la.setBuddy(n)
     n.textChanged.connect(self.changed.emit)
     l.addRow(n)
     self.autosubmit = asb = QCheckBox(_('&Auto login with these credentials'), self)
     l.addRow(asb)
     asb.stateChanged.connect(lambda: self.changed.emit())
     self.rb = b = QPushButton(_('&Delete this account'))
     b.clicked.connect(self.delete_requested.emit)
     l.addRow(b)
コード例 #9
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.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=unhexlify(opts.relay_password).decode('utf-8'),
                        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.Close)
     bb.rejected.connect(self.reject), bb.accepted.connect(self.accept)
     l.addWidget(bb)
コード例 #10
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.l = l = QGridLayout(self)

        def add_row(*args):
            r = l.rowCount()
            if len(args) == 1:
                l.addWidget(args[0], r, 0, 1, 2)
            else:
                la = QLabel(args[0])
                l.addWidget(la, r, 0, Qt.AlignmentFlag.AlignRight), l.addWidget(args[1], r, 1)
                la.setBuddy(args[1])

        self.heading = la = QLabel('<h2>\xa0')
        add_row(la)
        self.helpl = la = QLabel(_('For help with snippets, see the <a href="%s">User Manual</a>') %
                                 localize_user_manual_link('https://manual.calibre-ebook.com/snippets.html'))
        la.setOpenExternalLinks(True)
        add_row(la)

        self.name = n = QLineEdit(self)
        n.setPlaceholderText(_('The name of this snippet'))
        add_row(_('&Name:'), n)

        self.trig = t = QLineEdit(self)
        t.setPlaceholderText(_('The text used to trigger this snippet'))
        add_row(_('Tri&gger:'), t)

        self.template = t = QPlainTextEdit(self)
        la.setBuddy(t)
        add_row(_('&Template:'), t)

        self.types = t = QListWidget(self)
        t.setFlow(QListView.Flow.LeftToRight)
        t.setWrapping(True), t.setResizeMode(QListView.ResizeMode.Adjust), t.setSpacing(5)
        fm = t.fontMetrics()
        t.setMaximumHeight(2*(fm.ascent() + fm.descent()) + 25)
        add_row(_('&File types:'), t)
        t.setToolTip(_('Which file types this snippet should be active in'))

        self.frame = f = QFrame(self)
        f.setFrameShape(f.HLine)
        add_row(f)
        self.test = d = SnippetTextEdit('', self)
        d.snippet_manager.snip_func = self.snip_func
        d.setToolTip(_('You can test your snippet here'))
        d.setMaximumHeight(t.maximumHeight() + 15)
        add_row(_('T&est:'), d)

        i = QListWidgetItem(_('All'), t)
        i.setData(Qt.ItemDataRole.UserRole, '*')
        i.setCheckState(Qt.CheckState.Checked)
        i.setFlags(i.flags() | Qt.ItemFlag.ItemIsUserCheckable)
        for ftype in sorted(all_text_syntaxes):
            i = QListWidgetItem(ftype, t)
            i.setData(Qt.ItemDataRole.UserRole, ftype)
            i.setCheckState(Qt.CheckState.Checked)
            i.setFlags(i.flags() | Qt.ItemFlag.ItemIsUserCheckable)

        self.creating_snippet = False
コード例 #11
0
ファイル: annotations.py プロジェクト: zhibimohai/calibre
 def setup_ui(self):
     self.notes_edit = QPlainTextEdit(self)
     if self.initial_notes:
         self.notes_edit.setPlainText(self.initial_notes)
     self.notes_edit.setMinimumWidth(400)
     self.notes_edit.setMinimumHeight(300)
     l = QVBoxLayout(self)
     l.addWidget(self.notes_edit)
     l.addWidget(self.bb)
コード例 #12
0
 def setup_ui(self, parent):
     self._box = QGroupBox(parent)
     self._box.setTitle('&'+self.col_metadata['name'])
     self._layout = QVBoxLayout()
     self._tb = QPlainTextEdit(self._box)
     self._tb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
     self._layout.addWidget(self._tb)
     self._box.setLayout(self._layout)
     self.widgets = [self._box]
コード例 #13
0
 def setup_ui(self):
     self.l = l = QVBoxLayout(self)
     self.text = t = QPlainTextEdit(self)
     self.log_text = ''
     l.addWidget(t)
     l.addWidget(self.bb)
     self.bb.setStandardButtons(self.bb.Close)
     self.cb = b = self.bb.addButton(_('&Copy to clipboard'), self.bb.ActionRole)
     b.clicked.connect(self.copy_to_clipboard)
     b.setIcon(QIcon(I('edit-copy.png')))
コード例 #14
0
    def set_css_in_row(self, row, col, css):
        # Clean up multi-line css formatting
        # A single line is 30px tall, subsequent lines add 16px

        lines = []
        for line in css.split('\n'):
            lines.append(re.sub('^\s*', '', line))
        css_content = QPlainTextEdit('\n'.join(lines))
        css_content.setFont(self.FONT)
        css_content.textChanged.connect(partial(self.css_edited, row))
        self.setCellWidget(row, col, css_content)
        self.resize_row_height(lines, row)
コード例 #15
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self.default_template = default_custom_list_template()
        self.l = l = QFormLayout(self)
        l.setFieldGrowthPolicy(l.AllNonFixedFieldsGrow)
        self.la = la = QLabel('<p>' + _(
            'Here you can create a template to control what data is shown when'
            ' using the <i>Custom list</i> mode for the book list'))
        la.setWordWrap(True)
        l.addRow(la)
        self.thumbnail = t = QCheckBox(_('Show a cover &thumbnail'))
        self.thumbnail_height = th = QSpinBox(self)
        th.setSuffix(' px'), th.setRange(60, 600)
        self.entry_height = eh = QLineEdit(self)
        l.addRow(t), l.addRow(_('Thumbnail &height:'), th)
        l.addRow(_('Entry &height:'), eh)
        t.stateChanged.connect(self.changed_signal)
        th.valueChanged.connect(self.changed_signal)
        eh.textChanged.connect(self.changed_signal)
        eh.setToolTip(
            textwrap.fill(
                _('The height for each entry. The special value "auto" causes a height to be calculated'
                  ' based on the number of lines in the template. Otherwise, use a CSS length, such as'
                  ' 100px or 15ex')))
        t.stateChanged.connect(self.thumbnail_state_changed)
        th.setVisible(False)

        self.comments_fields = cf = QLineEdit(self)
        l.addRow(_('&Long text fields:'), cf)
        cf.setToolTip(
            textwrap.fill(
                _('A comma separated list of fields that will be added at the bottom of every entry.'
                  ' These fields are interpreted as containing HTML, not plain text.'
                  )))
        cf.textChanged.connect(self.changed_signal)

        self.la1 = la = QLabel('<p>' + _(
            'The template below will be interpreted as HTML and all {{fields}} will be replaced'
            ' by the actual metadata, if available. For custom columns use the column lookup'
            ' name, for example: #mytags. You can use {0} as a separator'
            ' to split a line into multiple columns.').format('|||'))
        la.setWordWrap(True)
        l.addRow(la)
        self.template = t = QPlainTextEdit(self)
        l.addRow(t)
        t.textChanged.connect(self.changed_signal)
        self.imex = bb = QDialogButtonBox(self)
        b = bb.addButton(_('&Import template'), bb.ActionRole)
        b.clicked.connect(self.import_template)
        b = bb.addButton(_('E&xport template'), bb.ActionRole)
        b.clicked.connect(self.export_template)
        l.addRow(bb)
コード例 #16
0
ファイル: NumberBar.py プロジェクト: ivanmrsulja/brick_ide
 def __init__(self):
     super(TestWidget, self).__init__()
     #window = LineTextWidget()
     self.edit = QPlainTextEdit()
     self.number_bar = NumberBar()
     self.number_bar.setTextEdit(self.edit)
     l = QHBoxLayout()
     l.addWidget(self.number_bar)
     l.addWidget(self.edit)
     self.setLayout(l)
     self.edit.installEventFilter(self)
     self.edit.viewport().installEventFilter(self)
     self.show()
コード例 #17
0
ファイル: proceed.py プロジェクト: kba/calibre
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.setAttribute(Qt.WA_DeleteOnClose, False)
        self.setWindowIcon(QIcon(I('dialog_question.png')))

        self.questions = []

        self._l = l = QGridLayout(self)
        self.setLayout(l)

        self.icon_label = ic = QLabel(self)
        ic.setPixmap(QPixmap(I('dialog_question.png')))
        self.msg_label = msg = QLabel('some random filler text')
        msg.setWordWrap(True)
        ic.setMaximumWidth(110)
        ic.setMaximumHeight(100)
        ic.setScaledContents(True)
        ic.setStyleSheet('QLabel { margin-right: 10px }')
        self.bb = QDialogButtonBox()
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        self.log_button = self.bb.addButton(_('View log'), self.bb.ActionRole)
        self.log_button.setIcon(QIcon(I('debug.png')))
        self.log_button.clicked.connect(self.show_log)
        self.copy_button = self.bb.addButton(_('&Copy to clipboard'),
                                             self.bb.ActionRole)
        self.copy_button.clicked.connect(self.copy_to_clipboard)
        self.action_button = self.bb.addButton('', self.bb.ActionRole)
        self.action_button.clicked.connect(self.action_clicked)
        self.show_det_msg = _('Show &details')
        self.hide_det_msg = _('Hide &details')
        self.det_msg_toggle = self.bb.addButton(self.show_det_msg,
                                                self.bb.ActionRole)
        self.det_msg_toggle.clicked.connect(self.toggle_det_msg)
        self.det_msg_toggle.setToolTip(
            _('Show detailed information about this error'))
        self.det_msg = QPlainTextEdit(self)
        self.det_msg.setReadOnly(True)
        self.bb.setStandardButtons(self.bb.Yes | self.bb.No | self.bb.Ok)
        self.bb.button(self.bb.Yes).setDefault(True)

        self.checkbox = QCheckBox('', self)

        l.addWidget(ic, 0, 0, 1, 1)
        l.addWidget(msg, 0, 1, 1, 1)
        l.addWidget(self.checkbox, 1, 0, 1, 2)
        l.addWidget(self.det_msg, 2, 0, 1, 2)
        l.addWidget(self.bb, 3, 0, 1, 2)

        self.ask_question.connect(self.do_ask_question,
                                  type=Qt.QueuedConnection)
コード例 #18
0
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, False)
        self.queue = []
        self.do_pop.connect(self.pop, type=Qt.ConnectionType.QueuedConnection)

        self._layout = l = QGridLayout()
        self.setLayout(l)
        self.icon = QIcon(I('dialog_error.png'))
        self.setWindowIcon(self.icon)
        self.icon_widget = Icon(self)
        self.icon_widget.set_icon(self.icon)
        self.msg_label = QLabel('<p>&nbsp;')
        self.msg_label.setStyleSheet('QLabel { margin-top: 1ex; }')
        self.msg_label.setWordWrap(True)
        self.msg_label.setTextFormat(Qt.TextFormat.RichText)
        self.det_msg = QPlainTextEdit(self)
        self.det_msg.setVisible(False)

        self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close,
                                   parent=self)
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        self.ctc_button = self.bb.addButton(
            _('&Copy to clipboard'), QDialogButtonBox.ButtonRole.ActionRole)
        self.ctc_button.clicked.connect(self.copy_to_clipboard)
        self.retry_button = self.bb.addButton(
            _('&Retry'), QDialogButtonBox.ButtonRole.ActionRole)
        self.retry_button.clicked.connect(self.retry)
        self.retry_func = None
        self.show_det_msg = _('Show &details')
        self.hide_det_msg = _('Hide &details')
        self.det_msg_toggle = self.bb.addButton(
            self.show_det_msg, QDialogButtonBox.ButtonRole.ActionRole)
        self.det_msg_toggle.clicked.connect(self.toggle_det_msg)
        self.det_msg_toggle.setToolTip(
            _('Show detailed information about this error'))
        self.suppress = QCheckBox(self)

        l.addWidget(self.icon_widget, 0, 0, 1, 1)
        l.addWidget(self.msg_label, 0, 1, 1, 1)
        l.addWidget(self.det_msg, 1, 0, 1, 2)
        l.addWidget(self.suppress, 2, 0, 1, 2,
                    Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignBottom)
        l.addWidget(self.bb, 3, 0, 1, 2,
                    Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignBottom)
        l.setColumnStretch(1, 100)

        self.setModal(False)
        self.suppress.setVisible(False)
        self.do_resize()
    def __init__(self):
        super().__init__()

        self.log = QPlainTextEdit()

        layout = QVBoxLayout()
        layout.addWidget(QLabel('Log:'))
        layout.addWidget(self.log)

        self.setLayout(layout)

        self.thread = AboutUpdateThread(self)
        self.thread.about_update.connect(self.on_about_update)
        self.thread.start()
コード例 #20
0
    def initSrcFiles(self):

        row = 0

        f = QFrame()
        l = QGridLayout()
        f.setLayout(l)

        l.addWidget(QLabel('Source Files :'), row, 0)
        self.srcFilesList = QListWidget()
        self.srcFilesList.setSelectionMode(QAbstractItemView.MultiSelection)
        self.srcFilesList.setAlternatingRowColors(True)
        self.srcFilesList.model().rowsInserted.connect(
            self.handleSrcFilesChanged)
        self.srcFilesList.model().rowsRemoved.connect(
            self.handleSrcFilesChanged)
        selectionModel = self.srcFilesList.selectionModel()
        selectionModel.selectionChanged.connect(
            self.handleSrcFilesSelectionChanged)
        l.addWidget(self.srcFilesList, row, 1, 3, 1)

        self.srcFilesBtn = QPushButton('Select Files')
        self.srcFilesBtn.clicked.connect(self.handleSelectSrcFiles)
        self.srcFilesBtn.setSizePolicy(QSizePolicy.Preferred,
                                       QSizePolicy.Expanding)
        l.addWidget(self.srcFilesBtn, row, 2)
        row += 1

        self.addFilesBtn = QPushButton('Add Files')
        self.addFilesBtn.clicked.connect(self.handleAddSrcFiles)
        self.addFilesBtn.setSizePolicy(QSizePolicy.Preferred,
                                       QSizePolicy.Expanding)
        l.addWidget(self.addFilesBtn, row, 2)
        row += 1

        self.removeFilesBtn = QPushButton('Remove Files')
        self.removeFilesBtn.setEnabled(False)
        self.removeFilesBtn.clicked.connect(self.handleRemoveSrcFiles)
        self.removeFilesBtn.setSizePolicy(QSizePolicy.Preferred,
                                          QSizePolicy.Expanding)
        l.addWidget(self.removeFilesBtn, row, 2)
        row += 1

        self.errorEdit = QPlainTextEdit()
        self.errorEdit.setReadOnly(True)
        l.addWidget(self.errorEdit, row, 1, 1, 2)
        self.comms.errorSignal.connect(self.errorEdit.appendPlainText)

        return f
コード例 #21
0
ファイル: jobs.py プロジェクト: oatall/calibre
 def setup_ui(self):
     self.l = l = QVBoxLayout(self)
     if self.html_view:
         self.tb = w = QTextBrowser(self)
     else:
         self.log = w = QPlainTextEdit(self)
         w.setReadOnly(True), w.setLineWrapMode(w.NoWrap)
     l.addWidget(w)
     l.addWidget(self.bb)
     self.bb.clear(), self.bb.setStandardButtons(self.bb.Close)
     self.next_pos = 0
     self.update()
     self.timer = QTimer(self)
     self.timer.timeout.connect(self.update)
     self.timer.start(1000)
     if not self.html_view:
         v = self.log.verticalScrollBar()
         v.setValue(v.maximum())
コード例 #22
0
 def show_debug_info(self):
     info = self.device.device_debug_info()
     d = QDialog(self)
     d.l = l = QVBoxLayout()
     d.setLayout(l)
     d.v = v = QPlainTextEdit()
     d.setWindowTitle(self.device.get_gui_name())
     v.setPlainText(info)
     v.setMinimumWidth(400)
     v.setMinimumHeight(350)
     l.addWidget(v)
     bb = d.bb = QDialogButtonBox(QDialogButtonBox.Close)
     bb.accepted.connect(d.accept)
     bb.rejected.connect(d.reject)
     l.addWidget(bb)
     bb.addButton(_('Copy to clipboard'), bb.ActionRole)
     bb.clicked.connect(
         lambda: QApplication.clipboard().setText(v.toPlainText()))
     d.exec_()
コード例 #23
0
ファイル: tweaks.py プロジェクト: kba/calibre
 def __init__(self, raw, parent=None):
     QDialog.__init__(self, parent)
     self.edit = QPlainTextEdit(self)
     self.highlighter = PythonHighlighter(self.edit.document())
     self.l = QVBoxLayout()
     self.setLayout(self.l)
     self.msg = QLabel(
         _('Add/edit tweaks for any custom plugins you have installed. '
           'Documentation for these tweaks should be available '
           'on the website from where you downloaded the plugins.'))
     self.msg.setWordWrap(True)
     self.l.addWidget(self.msg)
     self.l.addWidget(self.edit)
     self.edit.setPlainText(raw)
     self.bb = QDialogButtonBox(
         QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self)
     self.bb.accepted.connect(self.accept)
     self.bb.rejected.connect(self.reject)
     self.l.addWidget(self.bb)
     self.resize(550, 300)
コード例 #24
0
 def setup_ui(self):
     self.l = l = QVBoxLayout(self)
     if self.html_view:
         self.tb = w = QTextBrowser(self)
     else:
         self.log = w = QPlainTextEdit(self)
         w.setReadOnly(True), w.setLineWrapMode(QPlainTextEdit.LineWrapMode.NoWrap)
     l.addWidget(w)
     l.addWidget(self.bb)
     self.bb.clear(), self.bb.setStandardButtons(QDialogButtonBox.StandardButton.Close)
     self.copy_button = b = self.bb.addButton(_('&Copy to clipboard'), QDialogButtonBox.ButtonRole.ActionRole)
     b.setIcon(QIcon(I('edit-copy.png')))
     b.clicked.connect(self.copy_to_clipboard)
     self.next_pos = 0
     self.update()
     self.timer = QTimer(self)
     self.timer.timeout.connect(self.update)
     self.timer.start(1000)
     if not self.html_view:
         v = self.log.verticalScrollBar()
         v.setValue(v.maximum())
コード例 #25
0
 def __init__(self, parent=None):
     QDialog.__init__(self, parent)
     self._layout = QVBoxLayout(self)
     self.setLayout(self._layout)
     self.log = QPlainTextEdit(self)
     self._layout.addWidget(self.log)
     self.log.setPlainText(_('Getting device information') + '...')
     self.copy = QPushButton(_('Copy to &clipboard'))
     self.copy.setDefault(True)
     self.setWindowTitle(_('User-defined device information'))
     self.setWindowIcon(QIcon(I('debug.png')))
     self.copy.clicked.connect(self.copy_to_clipboard)
     self.ok = QPushButton('&OK')
     self.ok.setAutoDefault(False)
     self.ok.clicked.connect(self.accept)
     self.bbox = QDialogButtonBox(self)
     self.bbox.addButton(self.copy, QDialogButtonBox.ButtonRole.ActionRole)
     self.bbox.addButton(self.ok, QDialogButtonBox.ButtonRole.AcceptRole)
     self._layout.addWidget(self.bbox)
     self.resize(750, 500)
     self.bbox.setEnabled(False)
     QTimer.singleShot(1000, self.device_info)
コード例 #26
0
    def setup_ui(self):
        self.l = l = QFormLayout(self)
        l.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.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 = QPlainTextEdit(self)
        s.setMinimumWidth(400)
        l.addRow(_('&Search:'), s)
        s.setPlaceholderText(_('The search expression'))
        if self.initial_search:
            s.setPlainText(self.initial_search)
        n.setFocus(Qt.FocusReason.OtherFocusReason)
        l.addRow(self.bb)
コード例 #27
0
    def setupUi(self, Dialog):
        Dialog.setObjectName(_fromUtf8("Dialog"))
        Dialog.resize(497, 235)
        self.gridLayout = QGridLayout(Dialog)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.icon_label = QLabel(Dialog)
        self.icon_label.setMaximumSize(
            QtCore.QSize(COVER_ICON_SIZE, COVER_ICON_SIZE))
        self.icon_label.setText(_fromUtf8(""))
        self.icon_label.setPixmap(QPixmap(_fromUtf8(I("dialog_warning.png"))))
        self.icon_label.setScaledContents(False)
        self.icon_label.setObjectName(_fromUtf8("icon_label"))
        self.gridLayout.addWidget(self.icon_label, 0, 0, 1, 1)
        self.msg = QLabel(Dialog)
        self.msg.setText(_fromUtf8(""))
        self.msg.setWordWrap(True)
        self.msg.setOpenExternalLinks(True)
        self.msg.setObjectName(_fromUtf8("msg"))
        self.gridLayout.addWidget(self.msg, 0, 1, 1, 1)
        self.det_msg = QPlainTextEdit(Dialog)
        self.det_msg.setReadOnly(True)
        self.det_msg.setObjectName(_fromUtf8("det_msg"))
        self.gridLayout.addWidget(self.det_msg, 1, 0, 1, 2)
        self.bb = QDialogButtonBox(Dialog)
        self.bb.setOrientation(QtCore.Qt.Horizontal)
        self.bb.setStandardButtons(QDialogButtonBox.Ok)
        self.bb.setObjectName(_fromUtf8("bb"))
        self.gridLayout.addWidget(self.bb, 3, 0, 1, 2)
        self.toggle_checkbox = QCheckBox(Dialog)
        self.toggle_checkbox.setText(_fromUtf8(""))
        self.toggle_checkbox.setObjectName(_fromUtf8("toggle_checkbox"))
        self.gridLayout.addWidget(self.toggle_checkbox, 2, 0, 1, 2)

        self.retranslateUi(Dialog)
        self.bb.accepted.connect(Dialog.accept)
        self.bb.rejected.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
コード例 #28
0
    def setupUi(self, x):
        self.l = l = QVBoxLayout(self)
        self.la1 = la = QLabel(
            _("Values for the tweaks are shown below. Edit them to change the behavior of calibre."
              " Your changes will only take effect <b>after a restart</b> of calibre."
              ))
        l.addWidget(la), la.setWordWrap(True)
        self.splitter = s = QSplitter(self)
        s.setChildrenCollapsible(False)
        l.addWidget(s, 10)

        self.lv = lv = QWidget(self)
        lv.l = l2 = QVBoxLayout(lv)
        l2.setContentsMargins(0, 0, 0, 0)
        self.tweaks_view = tv = TweaksView(self)
        l2.addWidget(tv)
        self.plugin_tweaks_button = b = QPushButton(self)
        b.setToolTip(
            _("Edit tweaks for any custom plugins you have installed"))
        b.setText(_("&Plugin tweaks"))
        l2.addWidget(b)
        s.addWidget(lv)

        self.lv1 = lv = QWidget(self)
        s.addWidget(lv)
        lv.g = g = QGridLayout(lv)
        g.setContentsMargins(0, 0, 0, 0)

        self.search = sb = SearchBox2(self)
        sb.sizePolicy().setHorizontalStretch(10)
        sb.setSizeAdjustPolicy(sb.AdjustToMinimumContentsLength)
        sb.setMinimumContentsLength(10)
        g.addWidget(self.search, 0, 0, 1, 1)
        self.next_button = b = QPushButton(self)
        b.setIcon(QIcon(I("arrow-down.png")))
        b.setText(_("&Next"))
        g.addWidget(self.next_button, 0, 1, 1, 1)
        self.previous_button = b = QPushButton(self)
        b.setIcon(QIcon(I("arrow-up.png")))
        b.setText(_("&Previous"))
        g.addWidget(self.previous_button, 0, 2, 1, 1)

        self.hb = hb = QGroupBox(self)
        hb.setTitle(_("Help"))
        hb.l = l2 = QVBoxLayout(hb)
        self.help = h = QPlainTextEdit(self)
        l2.addWidget(h)
        h.setLineWrapMode(QPlainTextEdit.NoWrap)
        h.setReadOnly(True)
        g.addWidget(hb, 1, 0, 1, 3)

        self.eb = eb = QGroupBox(self)
        g.addWidget(eb, 2, 0, 1, 3)
        eb.setTitle(_("Edit tweak"))
        eb.g = ebg = QGridLayout(eb)
        self.edit_tweak = et = QPlainTextEdit(self)
        et.setMinimumWidth(400)
        et.setLineWrapMode(QPlainTextEdit.NoWrap)
        ebg.addWidget(et, 0, 0, 1, 2)
        self.restore_default_button = b = QPushButton(self)
        b.setToolTip(_("Restore this tweak to its default value"))
        b.setText(_("&Reset this tweak"))
        ebg.addWidget(b, 1, 0, 1, 1)
        self.apply_button = ab = QPushButton(self)
        ab.setToolTip(_("Apply any changes you made to this tweak"))
        ab.setText(_("&Apply changes to this tweak"))
        ebg.addWidget(ab, 1, 1, 1, 1)
コード例 #29
0
ファイル: comments_editor.py プロジェクト: prajoria/calibre
    def __init__(self,
                 parent=None,
                 one_line_toolbar=False,
                 toolbar_prefs_name=None):
        QWidget.__init__(self, parent)
        self.toolbar_prefs_name = toolbar_prefs_name or self.toolbar_prefs_name
        self.toolbar1 = QToolBar(self)
        self.toolbar2 = QToolBar(self)
        self.toolbar3 = QToolBar(self)
        for i in range(1, 4):
            t = getattr(self, 'toolbar%d' % i)
            t.setIconSize(QSize(18, 18))
        self.editor = EditorWidget(self)
        self.editor.data_changed.connect(self.data_changed)
        self.set_base_url = self.editor.set_base_url
        self.set_html = self.editor.set_html
        self.tabs = QTabWidget(self)
        self.tabs.setTabPosition(self.tabs.South)
        self.wyswyg = QWidget(self.tabs)
        self.code_edit = QPlainTextEdit(self.tabs)
        self.source_dirty = False
        self.wyswyg_dirty = True

        self._layout = QVBoxLayout(self)
        self.wyswyg.layout = l = QVBoxLayout(self.wyswyg)
        self.setLayout(self._layout)
        l.setContentsMargins(0, 0, 0, 0)
        if one_line_toolbar:
            tb = QHBoxLayout()
            l.addLayout(tb)
        else:
            tb = l
        tb.addWidget(self.toolbar1)
        tb.addWidget(self.toolbar2)
        tb.addWidget(self.toolbar3)
        l.addWidget(self.editor)
        self._layout.addWidget(self.tabs)
        self.tabs.addTab(self.wyswyg, _('N&ormal view'))
        self.tabs.addTab(self.code_edit, _('&HTML source'))
        self.tabs.currentChanged[int].connect(self.change_tab)
        self.highlighter = Highlighter(self.code_edit.document())
        self.layout().setContentsMargins(0, 0, 0, 0)
        if self.toolbar_prefs_name is not None:
            hidden = gprefs.get(self.toolbar_prefs_name)
            if hidden:
                self.hide_toolbars()

        # toolbar1 {{{
        self.toolbar1.addAction(self.editor.action_undo)
        self.toolbar1.addAction(self.editor.action_redo)
        self.toolbar1.addAction(self.editor.action_select_all)
        self.toolbar1.addAction(self.editor.action_remove_format)
        self.toolbar1.addAction(self.editor.action_clear)
        self.toolbar1.addSeparator()

        for x in ('copy', 'cut', 'paste'):
            ac = getattr(self.editor, 'action_' + x)
            self.toolbar1.addAction(ac)

        self.toolbar1.addSeparator()
        self.toolbar1.addAction(self.editor.action_background)
        # }}}

        # toolbar2 {{{
        for x in ('', 'un'):
            ac = getattr(self.editor, 'action_%sordered_list' % x)
            self.toolbar2.addAction(ac)
        self.toolbar2.addSeparator()
        for x in ('superscript', 'subscript', 'indent', 'outdent'):
            self.toolbar2.addAction(getattr(self.editor, 'action_' + x))
            if x in ('subscript', 'outdent'):
                self.toolbar2.addSeparator()

        self.toolbar2.addAction(self.editor.action_block_style)
        w = self.toolbar2.widgetForAction(self.editor.action_block_style)
        if hasattr(w, 'setPopupMode'):
            w.setPopupMode(w.InstantPopup)
        self.toolbar2.addAction(self.editor.action_insert_link)
        self.toolbar2.addAction(self.editor.action_insert_hr)
        # }}}

        # toolbar3 {{{
        for x in ('bold', 'italic', 'underline', 'strikethrough'):
            ac = getattr(self.editor, 'action_' + x)
            self.toolbar3.addAction(ac)
        self.toolbar3.addSeparator()

        for x in ('left', 'center', 'right', 'justified'):
            ac = getattr(self.editor, 'action_align_' + x)
            self.toolbar3.addAction(ac)
        self.toolbar3.addSeparator()
        self.toolbar3.addAction(self.editor.action_color)
        # }}}

        self.code_edit.textChanged.connect(self.code_dirtied)
        self.editor.page().contentsChanged.connect(self.wyswyg_dirtied)
コード例 #30
0
 def setup_ui(self):
     self.l = l = QVBoxLayout(self)
     self._text = QPlainTextEdit(self)
     l.addWidget(self._text)
     l.addWidget(self.bb)