Esempio n. 1
0
class ViewLog(QDialog): # {{{

    def __init__(self, title, html, parent=None):
        QDialog.__init__(self, parent)
        self.l = l = QVBoxLayout()
        self.setLayout(l)

        self.tb = QTextBrowser(self)
        self.tb.setHtml('<pre style="font-family: monospace">%s</pre>' % html)
        l.addWidget(self.tb)

        self.bb = QDialogButtonBox(QDialogButtonBox.Ok)
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        self.copy_button = self.bb.addButton(_('Copy to clipboard'),
                self.bb.ActionRole)
        self.copy_button.setIcon(QIcon(I('edit-copy.png')))
        self.copy_button.clicked.connect(self.copy_to_clipboard)
        l.addWidget(self.bb)
        self.setModal(False)
        self.resize(QSize(700, 500))
        self.setWindowTitle(title)
        self.setWindowIcon(QIcon(I('debug.png')))
        self.show()

    def copy_to_clipboard(self):
        txt = self.tb.toPlainText()
        QApplication.clipboard().setText(txt)
Esempio n. 2
0
class ViewLog(QDialog):  # {{{
    def __init__(self, title, html, parent=None):
        QDialog.__init__(self, parent)
        self.l = l = QVBoxLayout()
        self.setLayout(l)

        self.tb = QTextBrowser(self)
        self.tb.setHtml('<pre style="font-family: monospace">%s</pre>' % html)
        l.addWidget(self.tb)

        self.bb = QDialogButtonBox(QDialogButtonBox.Ok)
        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        self.copy_button = self.bb.addButton(_('Copy to clipboard'),
                                             self.bb.ActionRole)
        self.copy_button.setIcon(QIcon(I('edit-copy.png')))
        self.copy_button.clicked.connect(self.copy_to_clipboard)
        l.addWidget(self.bb)
        self.setModal(False)
        self.resize(QSize(700, 500))
        self.setWindowTitle(title)
        self.setWindowIcon(QIcon(I('debug.png')))
        self.show()

    def copy_to_clipboard(self):
        txt = self.tb.toPlainText()
        QApplication.clipboard().setText(txt)
Esempio n. 3
0
class WikiHelpBrowser(QDialog):
    """
    The WikiHelpBrowser Dialog.
    """
    def __init__(self,
                 text,
                 parent=None,
                 clicked_func=None,
                 caption="(caption)",
                 size=None):
        QDialog.__init__(self, parent)

        self.setWindowTitle(caption)
        self.setWindowIcon(QtGui.QIcon("ui/border/MainWindow"))
        self.setObjectName("WikiHelpBrowser")
        TextBrowserLayout = QGridLayout(self)
        TextBrowserLayout.setSpacing(5)
        TextBrowserLayout.setMargin(2)
        self.text_browser = QTextBrowser(self)
        self.text_browser.setOpenExternalLinks(True)
        self.text_browser.setObjectName("text_browser")
        TextBrowserLayout.addWidget(self.text_browser, 0, 0, 1, 0)

        self.text_browser.setMinimumSize(400, 200)
        # make it pale yellow like a post-it note
        self.text_browser.setHtml("<qt bgcolor=\"#FFFF80\">" + text)

        self.close_button = QPushButton(self)
        self.close_button.setObjectName("close_button")
        self.close_button.setText("Close")
        TextBrowserLayout.addWidget(self.close_button, 1, 1)

        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        TextBrowserLayout.addItem(spacer, 1, 0)

        self.resize(QSize(300, 300).expandedTo(self.minimumSizeHint()))
        if size == 1:
            self.text_browser.setMinimumSize(200, 400)
            self.resize(QSize(300, 550).expandedTo(self.minimumSizeHint()))
        if size == 2:
            self.resize(QSize(650, 250).expandedTo(self.minimumSizeHint()))
        self.connect(self.close_button, SIGNAL("clicked()"), self.close)
        return

    pass
Esempio n. 4
0
class LogViewer(QDialog): # {{{

    def __init__(self, log, parent=None):
        QDialog.__init__(self, parent)
        self.log = log
        self.l = l = QVBoxLayout()
        self.setLayout(l)

        self.tb = QTextBrowser(self)
        l.addWidget(self.tb)

        self.bb = QDialogButtonBox(QDialogButtonBox.Close)
        l.addWidget(self.bb)
        self.copy_button = self.bb.addButton(_('Copy to clipboard'),
                self.bb.ActionRole)
        self.copy_button.clicked.connect(self.copy_to_clipboard)
        self.copy_button.setIcon(QIcon(I('edit-copy.png')))
        self.bb.rejected.connect(self.reject)
        self.bb.accepted.connect(self.accept)

        self.setWindowTitle(_('Download log'))
        self.setWindowIcon(QIcon(I('debug.png')))
        self.resize(QSize(800, 400))

        self.keep_updating = True
        self.last_html = None
        self.finished.connect(self.stop)
        QTimer.singleShot(100, self.update_log)

        self.show()

    def copy_to_clipboard(self):
        QApplication.clipboard().setText(''.join(self.log.plain_text))

    def stop(self, *args):
        self.keep_updating = False

    def update_log(self):
        if not self.keep_updating:
            return
        html = self.log.html
        if html != self.last_html:
            self.last_html = html
            self.tb.setHtml('<pre style="font-family:monospace">%s</pre>'%html)
        QTimer.singleShot(1000, self.update_log)
Esempio n. 5
0
class LogViewer(QDialog):  # {{{
    def __init__(self, log, parent=None):
        QDialog.__init__(self, parent)
        self.log = log
        self.l = l = QVBoxLayout()
        self.setLayout(l)

        self.tb = QTextBrowser(self)
        l.addWidget(self.tb)

        self.bb = QDialogButtonBox(QDialogButtonBox.Close)
        l.addWidget(self.bb)
        self.copy_button = self.bb.addButton(_('Copy to clipboard'),
                                             self.bb.ActionRole)
        self.copy_button.clicked.connect(self.copy_to_clipboard)
        self.copy_button.setIcon(QIcon(I('edit-copy.png')))
        self.bb.rejected.connect(self.reject)
        self.bb.accepted.connect(self.accept)

        self.setWindowTitle(_('Download log'))
        self.setWindowIcon(QIcon(I('debug.png')))
        self.resize(QSize(800, 400))

        self.keep_updating = True
        self.last_html = None
        self.finished.connect(self.stop)
        QTimer.singleShot(100, self.update_log)

        self.show()

    def copy_to_clipboard(self):
        QApplication.clipboard().setText(''.join(self.log.plain_text))

    def stop(self, *args):
        self.keep_updating = False

    def update_log(self):
        if not self.keep_updating:
            return
        html = self.log.html
        if html != self.last_html:
            self.last_html = html
            self.tb.setHtml('<pre style="font-family:monospace">%s</pre>' %
                            html)
        QTimer.singleShot(1000, self.update_log)
Esempio n. 6
0
class WikiHelpBrowser(QDialog):
    """
    The WikiHelpBrowser Dialog.
    """

    def __init__(self, text, parent=None, clicked_func=None, caption="(caption)", size=None):
        QDialog.__init__(self, parent)

        self.setWindowTitle(caption)
        self.setWindowIcon(QtGui.QIcon("ui/border/MainWindow"))
        self.setObjectName("WikiHelpBrowser")
        TextBrowserLayout = QGridLayout(self)
        TextBrowserLayout.setSpacing(5)
        TextBrowserLayout.setMargin(2)
        self.text_browser = QTextBrowser(self)
        self.text_browser.setOpenExternalLinks(True)
        self.text_browser.setObjectName("text_browser")
        TextBrowserLayout.addWidget(self.text_browser, 0, 0, 1, 0)

        self.text_browser.setMinimumSize(400, 200)
        # make it pale yellow like a post-it note
        self.text_browser.setHtml('<qt bgcolor="#FFFF80">' + text)

        self.close_button = QPushButton(self)
        self.close_button.setObjectName("close_button")
        self.close_button.setText("Close")
        TextBrowserLayout.addWidget(self.close_button, 1, 1)

        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        TextBrowserLayout.addItem(spacer, 1, 0)

        self.resize(QSize(300, 300).expandedTo(self.minimumSizeHint()))
        if size == 1:
            self.text_browser.setMinimumSize(200, 400)
            self.resize(QSize(300, 550).expandedTo(self.minimumSizeHint()))
        if size == 2:
            self.resize(QSize(650, 250).expandedTo(self.minimumSizeHint()))
        self.connect(self.close_button, SIGNAL("clicked()"), self.close)
        return

    pass