예제 #1
0
파일: about.py 프로젝트: nyimbi/codimension
 def __createVersioning( self ):
     " Creates the versioning section "
     components = getComponentInfo()
     text = "<p>The major Codimension components are listed below:</p>" \
            "<ul>"
     for (prettyName, version, homeURL,
          patched, license, licenseLink) in components:
         text += "<li><a href='" + homeURL + "'>" + prettyName + "</a><br>" \
                 "Version: "
         if version is not None and version[ 0 ].isdigit():
             text += version
         elif version is not None and version.lower() == "not installed":
             text += version.lower()
         elif version is None:
             text += "n/a"
         else:
             text += str( version )
         if patched:
             text += " (patched for codimension)"
         text += "<br>"
         text += "License: "
         if licenseLink.startswith( "http" ):
             text += "<a href='" + licenseLink + "'>" + license + "</a>"
         else:
             text += license + " (" + licenseLink + ")"
         text += "<br></li>"
     text += "</ul>"
     browser = QTextBrowser()
     browser.setHtml( text )
     browser.setOpenExternalLinks( True )
     return browser
예제 #2
0
    def __createDescription(self):
        " Creates the description browser "
        browser = QTextBrowser()
        browser.setHtml("""
<p align="justify">
Codimension is a free experimental Python IDE.
</p>
<p align="justify">
Codimension aims to provide an integrated system for:
<ul>
<li>traditional text-based code editing, and</li>
<li>diagram-based code analysis (e.g. imports and classes diagrams,
    profiling results etc).</li>
</ul>
</p>

<p align="justify">
Many Python developers will find codimension useful as-is, even though not all
of its features have been implemented yet.
</p>
<p align="justify">
More information could be found on <a href='http://codimension.org'>
Codimension home page</a>.<br> Happy coding with Codimension!
</p>
""")
        browser.setOpenExternalLinks(True)
        return browser
예제 #3
0
파일: about.py 프로젝트: nyimbi/codimension
    def __createDescription( self ):
        " Creates the description browser "
        browser = QTextBrowser()
        browser.setHtml( """
<p align="justify">
Codimension is a free experimental Python IDE.
</p>
<p align="justify">
Codimension aims to provide an integrated system for:
<ul>
<li>traditional text-based code editing, and</li>
<li>diagram-based code analysis (e.g. imports and classes diagrams,
    profiling results etc).</li>
</ul>
</p>

<p align="justify">
Many Python developers will find codimension useful as-is, even though not all
of its features have been implemented yet.
</p>
<p align="justify">
More information could be found on <a href='http://satsky.spb.ru/codimension/'>
Codimension home page</a>.<br> Happy coding with Codimension!
</p>
""" )
        browser.setOpenExternalLinks( True )
        return browser
예제 #4
0
 def __createVersioning(self):
     " Creates the versioning section "
     components = getComponentInfo()
     text = "<p>The major Codimension components are listed below:</p>" \
            "<ul>"
     for (prettyName, version, homeURL, patched, license, licenseLink,
          localPath) in components:
         text += "<li><a href='" + homeURL + "'>" + prettyName + "</a><br>" \
                 "Version: "
         if version is not None and version[0].isdigit():
             text += version
         elif version is not None and version.lower() == "not installed":
             text += version.lower()
         elif version is None:
             text += "n/a"
         else:
             text += str(version)
         if patched:
             text += " (patched for codimension)"
         text += "<br>"
         text += "License: "
         if licenseLink.startswith("http"):
             text += "<a href='" + licenseLink + "'>" + license + "</a>"
         else:
             text += license + " (" + licenseLink + ")"
         if localPath:
             text += "<br/>Local path: " + localPath
         text += "<br></li>"
     text += "</ul>"
     browser = QTextBrowser()
     browser.setHtml(text)
     browser.setOpenExternalLinks(True)
     return browser
예제 #5
0
 def __createAuthors( self ):
     " Creates the authors section "
     addr1 = "<a href='mailto:[email protected]'>[email protected]</a>"
     addr2 = "<a href='mailto:[email protected]'>[email protected]</a>"
     addr3 = "<a href='mailto:[email protected]'>[email protected]</a>"
     text = "<p>Author: Sergey Satskiy &lt;" + addr1 + "&gt;</p>" \
            "<p>Packaging: Ilya Loginov &lt;" + addr2 + "&gt;</p>" \
            "<p>Initial packaging and logo: Dmitry Kazimirov &lt;" + addr3 + "&gt;</p>" \
            "<p align='justify'>Special thanks: Detlev Offenbach - the author of the Eric Python IDE." \
            " Codimension borrows some code and some ideas from Eric 4.</p>"
     browser = QTextBrowser()
     browser.setHtml( text )
     browser.setOpenExternalLinks( True )
     return browser
예제 #6
0
 def __init__(self, parent=None, text=""):
     #super(HelpForm, self).__init__(parent)
     self.setAttribute(Qt.WA_GroupLeader)
     self.setAttribute(Qt.WA_DeleteOnClose)
     browser = QTextBrowser()
     browser.setOpenExternalLinks(True)
     browser.setHtml(text)
     layout = QVBoxLayout()
     layout.setMargin(0)
     layout.addWidget(browser)
     self.setLayout(layout)
     self.resize(400, 200)
     QShortcut(QKeySequence("Escape"), self, self.close)
     self.setWindowTitle("R plugin - Help")
예제 #7
0
 def __createAuthors(self):
     " Creates the authors section "
     addr1 = "<a href='mailto:[email protected]'>[email protected]</a>"
     addr2 = "<a href='mailto:[email protected]'>[email protected]</a>"
     addr3 = "<a href='mailto:[email protected]'>[email protected]</a>"
     addr4 = "<a href='mailto:[email protected]'>[email protected]</a>"
     addr5 = "<a href='mailto:[email protected]'>[email protected]</a>"
     text = "<p>Author: Sergey Satskiy &lt;" + addr1 + "&gt;</p>" \
            "<p>Packaging and CI (travis): Sergey Fukanchik &lt;" + addr5 + "&gt;</p>" \
            "<p>Packaging: Ilya Loginov &lt;" + addr2 + "&gt;</p>" \
            "<p>Discussions, ideas, testing: David McElhany &lt;" + addr4 + "&gt;</p>" \
            "<p>Initial packaging and logo: Dmitry Kazimirov &lt;" + addr3 + "&gt;</p>" \
            "<p align='justify'>Special thanks: Detlev Offenbach - the author of the Eric Python IDE." \
            " Codimension borrows some code and some ideas from Eric 4.</p>"
     browser = QTextBrowser()
     browser.setHtml(text)
     browser.setOpenExternalLinks(True)
     return browser
예제 #8
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        p = parent.addPage(self, i18n("Titles and Headers"))

        l = QHBoxLayout(self)
        # The html view with the score layout example
        t = QTextBrowser(self)
        t.setOpenLinks(False)
        t.setOpenExternalLinks(False)

        # ensure that the full HTML example page is displayed
        t.setContentsMargins(2, 2, 2, 2)
        t.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        t.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        t.setMinimumSize(QSize(350, 350))
        #t.document().documentLayout().documentSizeChanged.connect(
            #lambda size: t.setMinimumSize(size.toSize() + QSize(4, 4)))

        headers = ly.headers(i18n)
        msg = i18n("Click to enter a value.")
        t.setHtml(titles_html.format(
            copyrightmsg = i18n("bottom of first page"),
            taglinemsg = i18n("bottom of last page"),
            **dict((k, "<a title='{0}' href='{1}'>{2}</a>".format(msg, k, v))
                    for k, v in headers)))
        l.addWidget(t)
        t.anchorClicked.connect(lambda qurl:
            self.findChild(KLineEdit, qurl.toString()).setFocus())

        g = QGridLayout()
        g.setVerticalSpacing(1)
        g.setColumnMinimumWidth(1, 200)
        l.addLayout(g)

        for row, (name, title) in enumerate(headers):
            l = QLabel(title + ":", self)
            e = KLineEdit(self)
            e.setObjectName(name)
            l.setBuddy(e)
            g.addWidget(l, row, 0)
            g.addWidget(e, row, 1)
            # set completion items
            parent.complete(e)
예제 #9
0
    def __createVersionWidget(self):
        " Creates the version tab content "
        ver = pysvn.svn_version
        svnVersion = ".".join([str(ver[0]), str(ver[1]), str(ver[2])])
        ver = pysvn.version
        pysvnVersion = ".".join([str(ver[0]), str(ver[1]), str(ver[2])])

        text = "<p>The major Codimension SVN plugin components are listed below:</p>" \
               "<ul>" \
               "<li><a href='http://subversion.apache.org/'>Subversion</a><br>" \
               "Version: " + svnVersion + "<br></li>" \
               "<li><a href='http://pysvn.tigris.org/docs/pysvn.html'>PySvn</a><br>" \
               "Version: " + pysvnVersion + "<br>" \
               "License: <a href='http://www.apache.org/licenses/LICENSE-1.1'>Apache License 1.1</a>" \
               "<br></li>" \
               "</ul>"

        browser = QTextBrowser()
        browser.setHtml(text)
        browser.setOpenExternalLinks(True)
        return browser
예제 #10
0
class AboutDialog(QDialog):
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.setFixedSize(500, 500)
        self.setWindowTitle(utils.tr('About MicroHex'))

        layout = QVBoxLayout(self)

        self.label = QLabel(self)
        self.label.setTextFormat(Qt.RichText)
        self.label.setText(utils.tr('MicroHex version {0}, (c) 2013 zenwarr<br><a href="{1}">{1}</a>')
                                    .format(QCoreApplication.applicationVersion(), QCoreApplication.organizationDomain()))
        self.label.setOpenExternalLinks(True)

        self.tabWidget = QTabWidget(self)
        self.copyingText = QTextBrowser(self)
        self.copyingText.setOpenExternalLinks(True)
        self.tabWidget.addTab(self.copyingText, utils.tr('License'))
        self.creditsText = QTextBrowser(self)
        self.creditsText.setOpenExternalLinks(True)
        self.tabWidget.addTab(self.creditsText, utils.tr('Credits'))

        l_file = QFile(':/main/data/COPYING.html')
        if l_file.open(QFile.ReadOnly | QFile.Text):
            self.copyingText.setText(str(l_file.readAll(), encoding='utf-8'))

        c_file = QFile(':/main/data/CREDITS.html')
        if c_file.open(QFile.ReadOnly | QFile.Text):
            self.creditsText.setText(str(c_file.readAll(), encoding='utf-8'))

        self.okButton = QPushButton(utils.tr('OK'), self)
        self.okButton.clicked.connect(self.close)
        self.okButton.setDefault(True)

        layout.addWidget(self.label)
        layout.addWidget(self.tabWidget)
        layout.addWidget(self.okButton)
예제 #11
0
    def __createVersionWidget( self ):
        " Creates the version tab content "
        ver = pysvn.svn_version
        svnVersion = ".".join( [ str( ver[ 0 ] ), str( ver[ 1 ] ),
                                 str( ver[ 2 ] ) ] )
        ver = pysvn.version
        pysvnVersion = ".".join( [ str( ver[ 0 ] ), str( ver[ 1 ] ),
                                   str( ver[ 2 ] ) ] )

        text = "<p>The major Codimension SVN plugin components are listed below:</p>" \
               "<ul>" \
               "<li><a href='http://subversion.apache.org/'>Subversion</a><br>" \
               "Version: " + svnVersion + "<br></li>" \
               "<li><a href='http://pysvn.tigris.org/docs/pysvn.html'>PySvn</a><br>" \
               "Version: " + pysvnVersion + "<br>" \
               "License: <a href='http://www.apache.org/licenses/LICENSE-1.1'>Apache License 1.1</a>" \
               "<br></li>" \
               "</ul>"

        browser = QTextBrowser()
        browser.setHtml( text )
        browser.setOpenExternalLinks( True )
        return browser
예제 #12
0
class Widget(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.tray = Tray(self)
        self.setMinimumSize(QSize(320, 200))
        self.setWindowFlags(Qt.Popup | Qt.FramelessWindowHint)
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setMargin(1)

        self.text = QTextBrowser(self)
        self.text.setReadOnly(True)
        self.text.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.text.setOpenExternalLinks(True)
        self.verticalLayout.addWidget(self.text)
        self.text.textChanged.connect(self.on_text_changed)
        self.notify = Notify(self)

        self.movie = QMovie()
        dev = QBuffer()
        dev.setData(QByteArray.fromBase64(CHECK_IMAGE))
        dev.open(QBuffer.ReadOnly)
        dev.setParent(self.movie)
        self.movie.setDevice(dev)
        self.movie.frameChanged.connect(self.on_frame_changed)

        self.realized = False
        self.show()

    def showEvent(self, event):
        if not self.realized:
            self.realized = True
            event.ignore()
        x, y = self.get_position()
        self.move(x, y)

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.hide()

    def get_position(self, size=None):
        if not size: size = self.size()
        tray = self.tray.geometry()
        screen = QApplication.desktop().availableGeometry()
        if tray.left() < screen.left():
            x = screen.left()
            y = screen.height() - size.height()
        elif tray.right() > screen.right():
            x = screen.width() - size.width()
            y = min(screen.height() - size.height(), tray.top())
        elif tray.top() < screen.top():
            x = min(screen.width() - size.width(), tray.left())
            y = screen.top()
        elif tray.bottom() > screen.bottom():
            x = min(screen.width() - size.width(), tray.left())
            y = screen.height() - size.height()
        return x, y

    def on_frame_changed(self):
        self.tray.setIcon(QIcon(self.movie.currentPixmap()))

    def on_text_changed(self):
        if self.text.toPlainText():
            screen = QApplication.desktop().availableGeometry()
            height = self.text.document().size().height()
            if height <= screen.height():
                self.setMinimumHeight(height)
                x, y = self.get_position()
                self.move(x, y)
예제 #13
0
    def __init__(self, parent=None, version=0.1, license="", currentdir="."):
        QDialog.__init__(self, parent)
        iconLabel = QLabel()
        icon = QPixmap(":logo.png")
        iconLabel.setPixmap(icon)
        nameLabel = QLabel(
            "<font size=8 color=#0066CC>&nbsp;<b>manageR</b></font>")
        versionLabel = QLabel(
            "<font color=#0066CC>%s on %s<br>manageR %s</font>" % (
            robjects.r.version[12][0], sys.platform, version))
        aboutBrowser = QTextBrowser()
        aboutBrowser.setOpenExternalLinks(True)
        aboutBrowser.setHtml(
            "<h3>Interface to the R statistical programming environment</h3>"
            "Copyright &copy; 2009-2010 Carson J. Q. Farmer"
            "<br/>[email protected]"
            "<br/><a href='http://www.ftools.ca/manageR'>http://www.ftools.ca/manageR</a>")
        licenseBrowser = QTextBrowser()
        licenseBrowser.setOpenExternalLinks(True)
        licenseBrowser.setHtml((license.replace("\n\n", "<p>").replace("(C)", "&copy;")))
        helpBrowser = QTextBrowser()
        helpBrowser.setOpenExternalLinks(True)
        helpBrowser.setHtml(
            "<center><h2>manageR version %s documentation</h2></center>"
            "<h4>Description:</h4>"
            "<b>manageR</b> adds comprehensive statistical capabilities to ..."
            "<h4>Features:</h4>"
            "<ul><li>Syntax highlighting</li><li>Minimal R script editor</li><li>Code checking/debuging</li>"
            "<li>Extensible GUI for common R functions</li>"
            "<li>Aides in building complex R scripts via an integrated console and editor</li>"
            "<li>Tools and widgets for exploring the R workspace, history, file system, working directory, "
            "plotting devices, library, help system, and online package repository</li></ul>"
            "<h4>Usage:</h4>"
            "<p>Use <tt>Ctrl+Return</tt> to send commands from an <b>EditR</b> window to the <b>manageR</b>"
            "console. If an <b>EditR</b> window contains selected text, only this text will be sent"
            "to the <b>manageR</b> console, otherwise, all text is sent. The <b>EditR</b> window"
            "also contains tools for creating, loading, editing, and saving R scripts. The suite of"
            "available tools is outlined in detail in the <b>Key bindings</b> section.</p>"
            "<p><i>Autocompletion</i><br>"
            "If enabled, command completion suggestions are automatically shown after a given time interval"
            "based on the current work. This can also be manually activated using <b>Ctrl+Space</b>."
            "In addition, a tooltip will appear if one is available for the selected command."
            "It is possible to turn off autocompletion (and tooltips)"
            "by unchecking File &rarr; Configure &rarr;"
            "General tab &rarr; Enable autocompletion.</p>"
            "<p><i>Search and Replace</i><br>"
            "A Search and Replace toolbar is available for both the <b>manageR</b> console and <b>EditR</b>"
            "window (the replace functionality is only available in <b>EditR</b>). When activated (see"
            "<b>Key Bindings</b> section below), if any text is selected in the parent dialog, this text"
            "will be placed in the 'Find toolbar' for searching. To search for"
            "the next occurrence of the text or phrase in the toolbar, type <tt>Enter</tt>"
            "or click the 'Next' button. Conversely, click the 'Previous' button to search backwards. To"
            "replace text as it is found, simply type the replacement text in the 'Replace' line edit and"
            "click 'Replace'. To replace all occurrences of the found text, click 'Replace all'. All"
            "searches can be refined by using the 'Case sensitive' and 'Whole words' check boxes.</p>"
            "<p><i>Workspace Manager</i></i><br>"
            "The Workspace Tree displays the name, type, and dimentions f all currently loaded variables "
            "in your global R environment (globalEnv). From here, it is possible to remove, save, and load "
            "R variables, as well as export R variables to file.</p>"
            "<p><i>Graphic Device Manager</i><br>"
            "The graphic devices table stores the ID and device type of all current R graphic devices. From here,"
            "it is possible to refresh the list of graphic devices, create a new empty graphic window, and remove"
            "existing devices. In addition, it is possible to export the selected graphic device to file in both raster"
            "and vector formats.</p>"
            "<p><i>History Manager</i><br>"
            "The command history displays a list of all previously executed commands (including commands loaded from a"
            ".RHistory file). From here it is possible to run a command in the <b>manageR</b> console by"
            "double clicking an item. Similarly, multiple commands can be selected, and copied"
            "using the popup menu. Individual commands can be selected or unselected simply by"
            "clicking on them using the left mouse button. To run all selected commands, right click anywhere within"
            "the command history widget, and select run from the popup menu.</p>"
            "<p><i>Working Directory Browser</i><br>"
            "The working directory widget is a simple toolbar to help browse to different working directories, making it"
            "simple to change the current R working directory.</p>"
            "<p><i>File System Browser</i><br>"
            "The file system browser widget is a simple tool to help browse to different directories, making it"
            "simple to view, load, delete, and manage your folders.</p>"
            "<p><i>Analysis</i><br>"
            "<b>manageR</b> supports simple plugins which help to streamline tedious R functions by providing a"
            "plugin framework for creating simple graphical user interfaces (GUI) to commonly used R functions."
            "These functions can be specified using an XML ('tools.xml') file stored in the <b>manageR</b>"
            "installation folder (%s). The format of the XML file should be as follows:"
            "<font color=green><i>"
            "<pre>&lt;?xml version='1.0'?&gt;"
            "&lt;manageRTools&gt;<br>"
            "  &lt;RTool name='Insert random R commands' query='|1|'&gt;<br>"
            "    &lt;Parameter label='R commands:' type='textEdit' default='ls()' notnull='true'/&gt;<br>"
            "  &lt;/RTool&gt;<br>"
            "&lt;manageRTools&gt;</i></font></pre>"
            "where each RTool specifies a unique R function. In the above example, the GUI will consist of a simple"
            "dialog with a text editing region to input user-defined R commands, and an OK and CLOSE button. When"
            "OK is clicked, the R commands in the text editing region will be run, and when CLOSE is clicked,"
            "the dialog will be closed. In the example above, query is set to <tt>|1|</tt>, which means take the"
            "output from the first parameter, and place here. In other words, in this case the entire query is"
            "equal to whatever is input into the text editing region (default here is <tt>ls()</tt>). Other GUI"
            "parameters that may be entered include:"
            "<ul><li>comboBox: Drop-down list box</li><li>doubleSpinBox: Widget for entering numerical values</li>"
            "<li>textEdit: Text editing region</li>"
            "<li>spComboBox: Combobox widget for displaying a dropdown list of variables (e.g. numeric,"
            "data.frame, Spatial*DataFrame)</li>"
            "<li>spListWidget: Widget for displaying lists of variables (e.g. numeric, data.frame, Spatial*DataFrame)</li>"
            "<li>helpString: Non-graphical parameter that is linked to the help button on the dialog"
            "(can use 'topic:help_topic' or custom html based help text)</li></ul>"
            "Default values for all of the above GUI parameters can be specified in the XML file, using semi-colons"
            "to separate multiple options. For the spComboBox, the default string should specify the type(s) of"
            "variables to display (e.g. numeric;data,frame;SpatialPointsDataFrame)."
            "<b>manageR</b> comes with several default R GUI functions which can be used as examples for creating"
            "custom R functions.</p>"
            "<h4>Key bindings:</h4>"
            "<ul>"
            "<li><tt>&uarr;</tt> : In the <b>manageR</b> console, show the previous command"
            "from the command history. In the <b>EditR</b> windows, move up one line."
            "<li><tt>&darr;</tt> : In the <b>manageR</b> console, show the next command"
            "from the command history. In the <b>EditR</b> windows, move down one line."
            "<li><tt>&larr;</tt> : Move the cursor left one character"
            "<li><tt>Ctrl+&larr;</tt> : Move the cursor left one word"
            "<li><tt>&rarr;</tt> : Move the cursor right one character"
            "<li><tt>Ctrl+&rarr;</tt> : Move the cursor right one word"
            "<li><tt>Tab</tt> : Indent the selected text (or the current line)"
            "<li><tt>Shift+Tab</tt> : Unindent the selected text (or the current line)"
            "<li><tt>Ctrl+A</tt> : Select all the text"
            "<li><tt>Backspace</tt> : Delete the character to the left of the cursor"
            "<li><tt>Ctrl+C</tt> : In the <b>manageR</b> console, if the cursor is in the command line, clear"
            "current command(s), otherwise copy the selected text to the clipboard (same for <b>EditR</b>"
            "windows."
            "<li><tt>Delete</tt> : Delete the character to the right of the cursor"
            "<li><tt>End</tt> : Move the cursor to the end of the line"
            "<li><tt>Ctrl+End</tt> : Move the cursor to the end of the file"
            "<li><tt>Ctrl+Return</tt> : In an <b>EditR</b> window, execute the (selected) code/text"
            "<li><tt>Ctrl+F</tt> : Pop up the Find toolbar"
            "<li><tt>Ctrl+R</tt> : In an <b>EditR</b> window, pop up the Find and Replace toolbar"
            "<li><tt>Home</tt> : Move the cursor to the beginning of the line"
            "<li><tt>Ctrl+Home</tt> : Move the cursor to the beginning of the file"
            "<li><tt>Ctrl+K</tt> : Delete to the end of the line"
            "<li><tt>Ctrl+G</tt> : Pop up the 'Goto line' dialog"
            "<li><tt>Ctrl+N</tt> : Open a new editor window"
            "<li><tt>Ctrl+O</tt> : Open a file open dialog to open an R script"
            "<li><tt>Ctrl+Space</tt> : Pop up a list of possible completions for"
            "the current word. Use the up and down arrow keys and the page up and page"
            "up keys (or the mouse) to navigate; click <tt>Enter</tt> to accept a"
            "completion or <tt>Esc</tt> to cancel."
            "<li><tt>PageUp</tt> : Move up one screen"
            "<li><tt>PageDown</tt> : Move down one screen"
            "<li><tt>Ctrl+Q</tt> : Terminate manageR; prompting to save any unsaved changes"
            "for every <b>EditR</b> window for which this is necessary. If the user cancels"
            "any 'save unsaved changes' message box, manageR will not terminate."
            "<li><tt>Ctrl+S</tt> : Save the current file"
            "<li><tt>Ctrl+V</tt> : Paste the clipboards text"
            "<li><tt>Ctrl+W</tt> : Close the current file; prompting to save any unsaved"
            "changes if necessary"
            "<li><tt>Ctrl+X</tt> : Cut the selected text to the clipboard"
            "<li><tt>Ctrl+Z</tt> : Undo the last editing action"
            "<li><tt>Ctrl+Shift+Z</tt> : Redo the last editing action</ul>"
            "Hold down <tt>Shift</tt> when pressing movement keys to select the text moved over.<br>" % (version, currentdir))

        tabWidget = QTabWidget()
        tabWidget.addTab(aboutBrowser, "&About")
        tabWidget.addTab(licenseBrowser, "&License")
        tabWidget.addTab(helpBrowser, "&Help")

        layout = QVBoxLayout(self)
        hbox = QHBoxLayout()
        hbox.addWidget(iconLabel)
        hbox.addWidget(nameLabel)
        hbox.addStretch()
        hbox.addWidget(versionLabel)
        layout.addLayout(hbox)
        layout.addWidget(tabWidget)

        self.setMinimumSize(min(self.width(),
            int(QApplication.desktop().availableGeometry().width() / 2)),
            int(QApplication.desktop().availableGeometry().height() / 2))
        self.setWindowTitle("manageR - About")
예제 #14
0
class QChatWidget(QWidget):
    def __init__(self, connectionManager, parent=None):
        QWidget.__init__(self, parent)

        self.connectionManager = connectionManager
        self.isDisabled = False
        self.wasCleared = False

        self.urlRegex = re.compile(constants.URL_REGEX)

        self.chatLog = QTextBrowser()
        self.chatLog.setOpenExternalLinks(True)

        self.chatInput = QTextEdit()
        self.chatInput.textChanged.connect(self.chatInputTextChanged)

        self.sendButton = QPushButton("Send")
        self.sendButton.clicked.connect(self.sendMessage)

        # Set the min height for the chatlog and a matching fixed height for the send button
        chatInputFontMetrics = QFontMetrics(self.chatInput.font())
        self.chatInput.setMinimumHeight(chatInputFontMetrics.lineSpacing() * 3)
        self.sendButton.setFixedHeight(chatInputFontMetrics.lineSpacing() * 3)

        hbox = QHBoxLayout()
        hbox.addWidget(self.chatInput)
        hbox.addWidget(self.sendButton)

        # Put the chatinput and send button in a wrapper widget so they may be added to the splitter
        chatInputWrapper = QWidget()
        chatInputWrapper.setLayout(hbox)
        chatInputWrapper.setMinimumHeight(chatInputFontMetrics.lineSpacing() * 3.7)

        # Put the chat log and chat input into a splitter so the user can resize them at will
        splitter = QSplitter(Qt.Vertical)
        splitter.addWidget(self.chatLog)
        splitter.addWidget(chatInputWrapper)
        splitter.setSizes([int(parent.height()), 1])

        hbox = QHBoxLayout()
        hbox.addWidget(splitter)
        self.setLayout(hbox)

        self.typingTimer = QTimer()
        self.typingTimer.setSingleShot(True)
        self.typingTimer.timeout.connect(self.stoppedTyping)

    def chatInputTextChanged(self):
        # Check if the text changed was the text box being cleared to avoid sending an invalid typing status
        if self.wasCleared:
            self.wasCleared = False
            return

        if str(self.chatInput.toPlainText())[-1:] == "\n":
            self.sendMessage()
        else:
            # Start a timer to check for the user stopping typing
            self.typingTimer.start(constants.TYPING_TIMEOUT)
            self.sendTypingStatus(constants.TYPING_START)

    def stoppedTyping(self):
        self.typingTimer.stop()
        if str(self.chatInput.toPlainText()) == "":
            self.sendTypingStatus(constants.TYPING_STOP_WITHOUT_TEXT)
        else:
            self.sendTypingStatus(constants.TYPING_STOP_WITH_TEXT)

    def sendMessage(self):
        if self.isDisabled:
            return

        self.typingTimer.stop()

        text = str(self.chatInput.toPlainText())[:-1]

        # Don't send empty messages
        if text == "":
            return

        # Convert URLs into clickable links
        text = self.__linkify(text)

        # Add the message to the message queue to be sent
        self.connectionManager.getClient(self.nick).sendChatMessage(text)

        # Clear the chat input
        self.wasCleared = True
        self.chatInput.clear()

        self.appendMessage(text, constants.SENDER)

    def sendTypingStatus(self, status):
        self.connectionManager.getClient(self.nick).sendTypingMessage(status)

    def showNowChattingMessage(self, nick):
        self.nick = nick
        self.appendMessage(
            "You are now securely chatting with " + self.nick + " :)", constants.SERVICE, showTimestampAndNick=False
        )

        self.appendMessage(
            "It's a good idea to verify the communcation is secure by selecting "
            '"authenticate buddy" in the options menu.',
            constants.SERVICE,
            showTimestampAndNick=False,
        )

    def appendMessage(self, message, source, showTimestampAndNick=True):
        color = self.__getColor(source)

        if showTimestampAndNick:
            timestamp = (
                '<font color="'
                + color
                + '">('
                + utils.getTimestamp()
                + ") <strong>"
                + (self.connectionManager.nick if source == constants.SENDER else self.nick)
                + ":</strong></font> "
            )
        else:
            timestamp = ""

        # If the user has scrolled up (current value != maximum), do not move the scrollbar
        # to the bottom after appending the message
        shouldScroll = True
        scrollbar = self.chatLog.verticalScrollBar()
        if scrollbar.value() != scrollbar.maximum() and source != constants.SENDER:
            shouldScroll = False

        self.chatLog.append(timestamp + message)

        # Move the vertical scrollbar to the bottom of the chat log
        if shouldScroll:
            scrollbar.setValue(scrollbar.maximum())

    def __linkify(self, text):
        matches = self.urlRegex.findall(text)

        for match in matches:
            text = text.replace(match[0], '<a href="%s">%s</a>' % (match[0], match[0]))

        return text

    def __getColor(self, source):
        if source == constants.SENDER:
            if qtUtils.isLightTheme:
                return "#0000CC"
            else:
                return "#6666FF"
        elif source == constants.RECEIVER:
            if qtUtils.isLightTheme:
                return "#CC0000"
            else:
                return "#CC3333"
        else:
            if qtUtils.isLightTheme:
                return "#000000"
            else:
                return "#FFFFFF"

    def disable(self):
        self.isDisabled = True
        self.chatInput.setReadOnly(True)

    def enable(self):
        self.isDisabled = False
        self.chatInput.setReadOnly(False)
예제 #15
0
class QChatWidget(QWidget):
    def __init__(self, connectionManager, parent=None):
        QWidget.__init__(self, parent)

        self.connectionManager = connectionManager
        self.isDisabled = False
        self.wasCleared = False

        self.urlRegex = re.compile(constants.URL_REGEX)

        self.chatLog = QTextBrowser()
        self.chatLog.setOpenExternalLinks(True)

        self.chatInput = QTextEdit()
        self.chatInput.textChanged.connect(self.chatInputTextChanged)

        self.sendButton = QPushButton("Send")
        self.sendButton.clicked.connect(self.sendMessage)

        # Set the min height for the chatlog and a matching fixed height for the send button
        chatInputFontMetrics = QFontMetrics(self.chatInput.font())
        self.chatInput.setMinimumHeight(chatInputFontMetrics.lineSpacing() * 3)
        self.sendButton.setFixedHeight(chatInputFontMetrics.lineSpacing() * 3)

        hbox = QHBoxLayout()
        hbox.addWidget(self.chatInput)
        hbox.addWidget(self.sendButton)

        # Put the chatinput and send button in a wrapper widget so they may be added to the splitter
        chatInputWrapper = QWidget()
        chatInputWrapper.setLayout(hbox)
        chatInputWrapper.setMinimumHeight(chatInputFontMetrics.lineSpacing() *
                                          3.7)

        # Put the chat log and chat input into a splitter so the user can resize them at will
        splitter = QSplitter(Qt.Vertical)
        splitter.addWidget(self.chatLog)
        splitter.addWidget(chatInputWrapper)
        splitter.setSizes([int(parent.height()), 1])

        hbox = QHBoxLayout()
        hbox.addWidget(splitter)
        self.setLayout(hbox)

        self.typingTimer = QTimer()
        self.typingTimer.setSingleShot(True)
        self.typingTimer.timeout.connect(self.stoppedTyping)

    def chatInputTextChanged(self):
        # Check if the text changed was the text box being cleared to avoid sending an invalid typing status
        if self.wasCleared:
            self.wasCleared = False
            return

        if str(self.chatInput.toPlainText())[-1:] == '\n':
            self.sendMessage()
        else:
            # Start a timer to check for the user stopping typing
            self.typingTimer.start(constants.TYPING_TIMEOUT)
            self.sendTypingStatus(constants.TYPING_START)

    def stoppedTyping(self):
        self.typingTimer.stop()
        if str(self.chatInput.toPlainText()) == '':
            self.sendTypingStatus(constants.TYPING_STOP_WITHOUT_TEXT)
        else:
            self.sendTypingStatus(constants.TYPING_STOP_WITH_TEXT)

    def sendMessage(self):
        if self.isDisabled:
            return

        self.typingTimer.stop()

        text = str(self.chatInput.toPlainText())[:-1]

        # Don't send empty messages
        if text == '':
            return

        # Convert URLs into clickable links
        text = self.__linkify(text)

        # Add the message to the message queue to be sent
        self.connectionManager.getClient(self.nick).sendChatMessage(text)

        # Clear the chat input
        self.wasCleared = True
        self.chatInput.clear()

        self.appendMessage(text, constants.SENDER)

    def sendTypingStatus(self, status):
        self.connectionManager.getClient(self.nick).sendTypingMessage(status)

    def showNowChattingMessage(self, nick):
        self.nick = nick
        self.appendMessage("You are now securely chatting with " + self.nick +
                           " :)",
                           constants.SERVICE,
                           showTimestampAndNick=False)

        self.appendMessage(
            "It's a good idea to verify the communcation is secure by selecting "
            "\"authenticate buddy\" in the options menu.",
            constants.SERVICE,
            showTimestampAndNick=False)

    def appendMessage(self, message, source, showTimestampAndNick=True):
        color = self.__getColor(source)

        if showTimestampAndNick:
            timestamp = '<font color="' + color + '">(' + utils.getTimestamp() + ') <strong>' + \
                        (self.connectionManager.nick if source == constants.SENDER else self.nick) + \
                        ':</strong></font> '
        else:
            timestamp = ''

        # If the user has scrolled up (current value != maximum), do not move the scrollbar
        # to the bottom after appending the message
        shouldScroll = True
        scrollbar = self.chatLog.verticalScrollBar()
        if scrollbar.value() != scrollbar.maximum(
        ) and source != constants.SENDER:
            shouldScroll = False

        self.chatLog.append(timestamp + message)

        # Move the vertical scrollbar to the bottom of the chat log
        if shouldScroll:
            scrollbar.setValue(scrollbar.maximum())

    def __linkify(self, text):
        matches = self.urlRegex.findall(text)

        for match in matches:
            text = text.replace(match[0],
                                '<a href="%s">%s</a>' % (match[0], match[0]))

        return text

    def __getColor(self, source):
        if source == constants.SENDER:
            if qtUtils.isLightTheme:
                return '#0000CC'
            else:
                return '#6666FF'
        elif source == constants.RECEIVER:
            if qtUtils.isLightTheme:
                return '#CC0000'
            else:
                return '#CC3333'
        else:
            if qtUtils.isLightTheme:
                return '#000000'
            else:
                return '#FFFFFF'

    def disable(self):
        self.isDisabled = True
        self.chatInput.setReadOnly(True)

    def enable(self):
        self.isDisabled = False
        self.chatInput.setReadOnly(False)
예제 #16
0
class Widget(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.tray = Tray(self)
        self.setMinimumSize(QSize(320, 200))
        self.setWindowFlags(Qt.Popup|Qt.FramelessWindowHint)
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setMargin(1)

        self.text = QTextBrowser(self)
        self.text.setReadOnly(True)
        self.text.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.text.setOpenExternalLinks(True)
        self.verticalLayout.addWidget(self.text)
        self.text.textChanged.connect(self.on_text_changed)
        self.notify = Notify(self)

        self.movie = QMovie()
        dev = QBuffer()
        dev.setData(QByteArray.fromBase64(CHECK_IMAGE))
        dev.open(QBuffer.ReadOnly)
        dev.setParent(self.movie)
        self.movie.setDevice(dev)
        self.movie.frameChanged.connect(self.on_frame_changed)

        self.realized = False
        self.show()

    def showEvent(self, event):
        if not self.realized:
            self.realized = True
            event.ignore()
        x, y = self.get_position()
        self.move(x, y)

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.hide()

    def get_position(self, size=None):
        if not size: size = self.size()
        tray = self.tray.geometry()
        screen = QApplication.desktop().availableGeometry()
        if tray.left() < screen.left():
            x = screen.left()
            y = screen.height() - size.height()
        elif tray.right() > screen.right():
            x = screen.width() - size.width()
            y = min(screen.height() - size.height(), tray.top())
        elif tray.top() < screen.top():
            x = min(screen.width() - size.width(), tray.left())
            y = screen.top()
        elif tray.bottom() > screen.bottom():
            x = min(screen.width() - size.width(), tray.left())
            y = screen.height() - size.height()
        return x, y

    def on_frame_changed(self):
        self.tray.setIcon(QIcon(self.movie.currentPixmap()))

    def on_text_changed(self):
        if self.text.toPlainText():
            screen = QApplication.desktop().availableGeometry()
            height = self.text.document().size().height()
            if height <= screen.height():
                self.setMinimumHeight(height)
                x, y = self.get_position()
                self.move(x, y)
예제 #17
0
파일: __init__.py 프로젝트: hlamer/kate
class CMakeToolView(QObject):
    '''CMake tool view class

        TODO Remember last dir/position/is-advanced?
        TODO Make the cache view editable and run `cmake` to reconfigure
    '''
    cmakeCache = []

    def __init__(self):
        super(CMakeToolView, self).__init__(None)
        self.toolView = kate.mainInterfaceWindow().createToolView(
            'cmake_utils'
          , kate.Kate.MainWindow.Bottom
          , KIcon('cmake').pixmap(32, 32)
          , i18nc('@title:tab', 'CMake')
          )
        self.toolView.installEventFilter(self)
        # By default, the toolview has box layout, which is not easy to delete.
        # For now, just add an extra widget.
        tabs = QTabWidget(self.toolView)
        # Make a page to view cmake cache
        self.cacheViewPage = uic.loadUi(
            os.path.join(os.path.dirname(__file__), settings.CMAKE_TOOLVIEW_CACHEVIEW_UI)
          )
        self.cacheViewPage.buildDir.setText(kate.sessionConfiguration[settings.PROJECT_DIR])
        # TODO It seems not only KTextEditor's SIP files are damn out of date...
        # KUrlRequester actually *HAS* setPlaceholderText() method... but damn SIP
        # files for KIO are damn out of date either! A NEW BUG NEEDS TO BE ADDED!
        # (but I have fraking doubts that it will be closed next few damn years)
        #
        #self.buildDir.setPlaceholderText(i18nc('@info', 'Project build directory'))
        self.cacheViewPage.buildDir.lineEdit().setPlaceholderText(
            i18nc('@info/plain', 'Project build directory')
          )
        self.cacheViewPage.buildDir.setMode(
            KFile.Mode(KFile.Directory | KFile.ExistingOnly | KFile.LocalOnly)
          )
        self.cacheViewPage.cacheItems.sortItems(0, Qt.AscendingOrder)
        self.cacheViewPage.cacheFilter.setTreeWidget(self.cacheViewPage.cacheItems)
        tabs.addTab(self.cacheViewPage, i18nc('@title:tab', 'CMake Cache Viewer'))
        # Make a page w/ cmake help
        splitter = QSplitter(Qt.Horizontal, tabs)
        self.vewHelpPage = uic.loadUi(
            os.path.join(os.path.dirname(__file__), settings.CMAKE_TOOLVIEW_HELP_UI)
          )
        self.vewHelpPage.helpFilter.setTreeWidget(self.vewHelpPage.helpTargets)
        self.updateHelpIndex()                              # Prepare Help view
        self.helpPage = QTextBrowser(splitter)
        self.helpPage.setReadOnly(True)
        self.helpPage.setOpenExternalLinks(False)
        self.helpPage.setOpenLinks(False)
        splitter.addWidget(self.vewHelpPage)
        splitter.addWidget(self.helpPage)
        splitter.setStretchFactor(0, 10)
        splitter.setStretchFactor(1, 20)
        tabs.addTab(splitter, i18nc('@title:tab', 'CMake Help'))
        # Make a page w/ some instant settings
        self.cfgPage = uic.loadUi(
            os.path.join(os.path.dirname(__file__), settings.CMAKE_TOOLVIEW_SETTINGS_UI)
          )
        self.cfgPage.mode.setChecked(kate.sessionConfiguration[settings.TOOLVIEW_ADVANCED_MODE])
        self.cfgPage.htmlize.setChecked(kate.sessionConfiguration[settings.TOOLVIEW_BEAUTIFY])
        tabs.addTab(self.cfgPage, i18nc('@title:tab', 'Tool View Settings'))

        # Connect signals
        self.cacheViewPage.cacheItems.itemActivated.connect(self.insertIntoCurrentDocument)
        self.cacheViewPage.buildDir.returnPressed.connect(self.updateCacheView)
        self.cacheViewPage.buildDir.urlSelected.connect(self.updateCacheView)
        self.cfgPage.mode.toggled.connect(self.updateCacheView)
        self.cfgPage.mode.toggled.connect(self.saveSettings)
        self.cfgPage.htmlize.toggled.connect(self.updateHelpText)
        self.cfgPage.htmlize.toggled.connect(self.saveSettings)
        self.vewHelpPage.helpTargets.itemActivated.connect(self.updateHelpText)
        self.vewHelpPage.helpTargets.itemDoubleClicked.connect(self.insertHelpItemIntoCurrentDocument)
        self.helpPage.anchorClicked.connect(openDocument)

        # Refresh the cache view
        self._updateCacheView(self.cacheViewPage.buildDir.text())


    def __del__(self):
        '''Plugins that use a toolview need to delete it for reloading to work.'''
        assert(self.toolView is not None)
        mw = kate.mainInterfaceWindow()
        if mw:
            mw.hideToolView(self.toolView)
            mw.destroyToolView(self.toolView)
            self.toolView.removeEventFilter(self)
        self.toolView = None


    def eventFilter(self, obj, event):
        """Hide the CMake tool view on ESCAPE key"""
        if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Escape:
            kate.mainInterfaceWindow().hideToolView(self.toolView)
            return True
        return self.toolView.eventFilter(obj, event)


    @pyqtSlot()
    def saveSettings(self):
        kate.sessionConfiguration[settings.TOOLVIEW_ADVANCED_MODE] = self.cfgPage.mode.isChecked()
        kate.sessionConfiguration[settings.TOOLVIEW_BEAUTIFY] = self.cfgPage.htmlize.isChecked()


    @pyqtSlot()
    def updateCacheView(self):
        self._updateCacheView(self.cacheViewPage.buildDir.text())


    def _updateCacheView(self, build_dir):
        # Do nothing if build dir is not configured
        if not build_dir:
            return

        self.cacheViewPage.cacheItems.clear()               # Remove previously collected cache
        is_advanced = self.cfgPage.mode.isChecked()

        try:
            items = cmake_help_parser.get_cache_content(build_dir, is_advanced)
        except ValueError as error:
            kate.ui.popup(
                i18nc('@title:window', 'Error')
              , i18nc(
                    '@info:tooltip'
                  , 'Unable to get CMake cache content:<nl/><message>%1</message>'
                  , str(error)
                  )
              , 'dialog-error'
              )
            return

        # Add items to a list
        for key, value in items.items():
            item = QTreeWidgetItem(self.cacheViewPage.cacheItems, [key, value[1], value[0]])
            item.setToolTip(0, value[2])

        self.cacheViewPage.cacheItems.resizeColumnToContents(0)
        self.cacheViewPage.cacheItems.resizeColumnToContents(1)
        self.cacheViewPage.cacheItems.resizeColumnToContents(2)


    def updateHelpIndex(self):
        # Add commands group
        commands = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Commands')]
          , cmake_help_parser.help_category.COMMAND
          )
        deprecated = [cmd[0] for cmd in cmake_help_parser.get_cmake_deprecated_commands_list()]
        for cmd in cmake_help_parser.get_cmake_commands_list():
            c = QTreeWidgetItem(
                commands
              , [cmd]
              , cmake_help_parser.help_category.HELP_ITEM
              )
            global _cmake_completion_model
            schema = KColorScheme(QPalette.Normal, KColorScheme.Selection)
            if _cmake_completion_model.has_completion_for_command(cmd):
                c.setForeground(0, schema.foreground(KColorScheme.PositiveText).color())
            else:
                if cmd in deprecated:
                    c.setForeground(0, schema.foreground(KColorScheme.NeutralText).color())
                else:
                    c.setForeground(0, schema.foreground(KColorScheme.NegativeText).color())

        # Add modules group
        standard_modules = cmake_help_parser.get_cmake_modules_list()
        total_modules_count = len(standard_modules)
        custom_modules = {}
        for path in kate.sessionConfiguration[settings.AUX_MODULE_DIRS]:
            modules_list = cmake_help_parser.get_cmake_modules_list(path)
            filtered_modules_list = [mod for mod in modules_list if mod not in standard_modules]
            filtered_modules_list.sort()
            custom_modules[
                i18nc('@item:inlistbox', 'Modules from %1 (%2)', path, len(path))
              ] = filtered_modules_list
            total_modules_count += len(filtered_modules_list)
        custom_modules[
            i18nc('@item:inlistbox', 'Standard modules (%1)', len(standard_modules))
          ] = standard_modules
        #
        modules = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Modules (%1)', total_modules_count)]
          , cmake_help_parser.help_category.MODULE
          )
        for from_path, modules_list in custom_modules.items():
            ss_item = QTreeWidgetItem(
                modules
              , [from_path]
              , cmake_help_parser.help_category.MODULE
              )
            for mod in modules_list:
                m = QTreeWidgetItem(
                    ss_item
                  , [mod]
                  , cmake_help_parser.help_category.HELP_ITEM
                  )

        # Add policies group
        policies = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Policies')]
          , cmake_help_parser.help_category.POLICY
          )
        for pol in cmake_help_parser.get_cmake_policies_list():
            p = QTreeWidgetItem(
                policies
              , [pol]
              , cmake_help_parser.help_category.HELP_ITEM
              )

        # Add properties group
        properties = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Properties')]
          , cmake_help_parser.help_category.PROPERTY
          )
        for subsection, props_list in cmake_help_parser.get_cmake_properties_list().items():
            ss_item = QTreeWidgetItem(
                properties
              , [subsection]
              , cmake_help_parser.help_category.PROPERTY
              )
            for prop in props_list:
                v = QTreeWidgetItem(
                    ss_item
                  , [prop[0]]
                  , cmake_help_parser.help_category.HELP_ITEM
                  )
                v.setToolTip(0, prop[1])

        # Add variables group
        variables = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Variables')]
          , cmake_help_parser.help_category.VARIABLE
          )
        for subsection, vars_list in cmake_help_parser.get_cmake_vars_list().items():
            ss_item = QTreeWidgetItem(
                variables
              , [subsection]
              , cmake_help_parser.help_category.VARIABLE
              )
            for var in vars_list:
                v = QTreeWidgetItem(
                    ss_item
                  , [var[0]]
                  , cmake_help_parser.help_category.HELP_ITEM
                  )
                v.setToolTip(0, var[1])
        #
        self.vewHelpPage.helpTargets.resizeColumnToContents(0)


    @pyqtSlot()
    def updateHelpText(self):
        tgt = self.vewHelpPage.helpTargets.currentItem()
        if tgt is None or tgt.type() != cmake_help_parser.help_category.HELP_ITEM:
            return
        parent = tgt.parent()
        if parent is None:
            return

        category = parent.type()
        text = cmake_help_parser.get_help_on(category, tgt.text(0))

        if not self.cfgPage.htmlize.isChecked():
            self.helpPage.setText(text[text.index('\n') + 1:])
            return

        # TODO How *else* we can beautify the text?
        lines = text.splitlines()[1:]
        file_link_re = re.compile('Defined in: (.*)')
        file_link_sb = 'Defined in: <a href="file://\\1">\\1</a>'
        pre = False
        para = True
        for i, line in enumerate(lines):
            # Remove '&', '<' and '>' from text
            # TODO Use some HTML encoder instead of this...
            line = line.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
            #
            if line.lstrip().startswith('Defined in: '):
                line = file_link_re.sub(file_link_sb, line)
            #
            if i == 0:
                line = '<h1>{}</h1>'.format(line)
            elif line.startswith(' ' * cmake_help_parser.CMAKE_HELP_VARBATIM_TEXT_PADDING_SIZE):
                if not pre:
                    line = '<pre>' + line
                    pre = True
            elif len(line.strip()) == 0:
                if pre:
                    line = line + '</pre>'
                    pre = False
                elif para:
                    line = line + '</p>'
                    para = False
                else:
                    line = '<p>' + line
                    para = True
            lines[i] = line
        self.helpPage.setText('\n'.join(lines))


    @pyqtSlot(QTreeWidgetItem, int)
    def insertIntoCurrentDocument(self, item, column):
        if item is not None and column == 0:
            view = kate.activeView()
            document = kate.activeDocument()
            document.startEditing()
            document.insertText(view.cursorPosition(), item.text(0))
            document.endEditing()


    @pyqtSlot(QTreeWidgetItem, int)
    def insertHelpItemIntoCurrentDocument(self,item, column):
        if item is not None and item.type() == cmake_help_parser.help_category.HELP_ITEM and column == 0:
            view = kate.activeView()
            document = kate.activeDocument()
            document.startEditing()
            document.insertText(view.cursorPosition(), item.text(0))
            document.endEditing()