コード例 #1
0
    def mouseMoveEvent(self, event):
        blockNumber = self._qpart.cursorForPosition(event.pos()).blockNumber()
        if blockNumber in self._qpart._lintMarks:
            msgType, msgText = self._qpart._lintMarks[blockNumber]
            QToolTip.showText(event.globalPos(), msgText)
        else:
            QToolTip.hideText()

        return QWidget.mouseMoveEvent(self, event)
コード例 #2
0
 def mouseMoveEvent(self, event):
     # This reimplementation adds support for tool tips
     
     QsciScintilla.mouseMoveEvent(self, event)
     QToolTip.hideText()
     self._global_mouse_position = event.globalPos()
     self._mouse_position = event.pos()
     self._tool_tip_timer.stop()
     self._tool_tip_timer.start(self.tool_tip_delay * 1000)
コード例 #3
0
ファイル: color_swatcher.py プロジェクト: hlamer/kate
 def show_swatch(self, view):
     '''Shows the swatch if a valid color is selected'''
     if view.selection():
         color = QColor(view.selectionText())
         if color.isValid():
             cursor_pos = view.mapToGlobal(view.cursorPositionCoordinates())
             QToolTip.showText(cursor_pos, ColorSwatcher._SWATCH_TEMPLATE)
             self.change_palette(color)
     else:
         QToolTip.hideText()
コード例 #4
0
ファイル: qt4tools.py プロジェクト: heysion/backintime
 def event(self, e):
     action = self.activeAction()
     if e.type() == QEvent.ToolTip and \
         action                    and \
         action.toolTip() != action.text():
             QToolTip.showText(e.globalPos(),
                               self.activeAction().toolTip())
     else:
         QToolTip.hideText()
     return super(Menu, self).event(e)
コード例 #5
0
 def show(self):
     " Shows the tooltip at the proper position "
     QToolTip.hideText()
     QApplication.processEvents()
     if not inside:
         return
     self.move(self.__getTooltipPos())
     self.raise_()
     QFrame.show(self)
     return
コード例 #6
0
 def show(self):
     " Shows the tooltip at the proper position "
     QToolTip.hideText()
     QApplication.processEvents()
     if not inside:
         return
     self.move(self.__getTooltipPos())
     self.raise_()
     QFrame.show(self)
     return
コード例 #7
0
 def eventFilter( self, obj, event ):
     """
     Filters particular events for a given QObject through this class. \
     Will use this to intercept events to the completer tree widget while \
     filtering.
     
     :param      obj     | <QObject>
                 event   | <QEvent>
     
     :return     <bool> consumed
     """
     if ( not obj == self._completerTree ):
         return False
     
     if ( event.type() != event.KeyPress ):
         return False
         
     if ( event.key() == Qt.Key_Escape ):
         QToolTip.hideText()
         self.cancelCompletion()
         return False
     
     elif ( event.key() in (Qt.Key_Enter, Qt.Key_Return, Qt.Key_Tab) ):
         self.acceptCompletion()
         return False
     
     elif ( event.key() in (Qt.Key_Up, 
                            Qt.Key_Down) ):
         
         return False
     
     else:
         self.keyPressEvent(event)
         
         # update the completer
         cursor   = self.textCursor()
         text     = projex.text.toUtf8(cursor.block().text())
         text     = text[:cursor.columnNumber()].split(' ')[-1]
         text     = text.split('.')[-1]
         
         self._completerTree.blockSignals(True)
         self._completerTree.setUpdatesEnabled(False)
         
         self._completerTree.setCurrentItem(None)
         
         for i in range(self._completerTree.topLevelItemCount()):
             item = self._completerTree.topLevelItem(i)
             if projex.text.toUtf8(item.text(0)).startswith(text):
                 self._completerTree.setCurrentItem(item)
                 break
         
         self._completerTree.blockSignals(False)
         self._completerTree.setUpdatesEnabled(True)
         
         return True
コード例 #8
0
    def eventFilter(self, obj, event):
        """
        Filters particular events for a given QObject through this class. \
        Will use this to intercept events to the completer tree widget while \
        filtering.
        
        :param      obj     | <QObject>
                    event   | <QEvent>
        
        :return     <bool> consumed
        """
        if (not obj == self._completerTree):
            return False

        if (event.type() != event.KeyPress):
            return False

        if (event.key() == Qt.Key_Escape):
            QToolTip.hideText()
            self.cancelCompletion()
            return False

        elif (event.key() in (Qt.Key_Enter, Qt.Key_Return, Qt.Key_Tab)):
            self.acceptCompletion()
            return False

        elif (event.key() in (Qt.Key_Up, Qt.Key_Down)):

            return False

        else:
            self.keyPressEvent(event)

            # update the completer
            cursor = self.textCursor()
            text = projex.text.toUtf8(cursor.block().text())
            text = text[:cursor.columnNumber()].split(' ')[-1]
            text = text.split('.')[-1]

            self._completerTree.blockSignals(True)
            self._completerTree.setUpdatesEnabled(False)

            self._completerTree.setCurrentItem(None)

            for i in range(self._completerTree.topLevelItemCount()):
                item = self._completerTree.topLevelItem(i)
                if projex.text.toUtf8(item.text(0)).startswith(text):
                    self._completerTree.setCurrentItem(item)
                    break

            self._completerTree.blockSignals(False)
            self._completerTree.setUpdatesEnabled(True)

            return True
コード例 #9
0
ファイル: qtebase.py プロジェクト: cheesinglee/spyder
 def hide_tooltip_if_necessary(self, key):
     """Hide calltip when necessary"""
     try:
         calltip_char = self.get_character(self.calltip_position)
         before = self.is_cursor_before(self.calltip_position,
                                        char_offset=1)
         other = key in (Qt.Key_ParenRight, Qt.Key_Period, Qt.Key_Tab)
         if calltip_char not in ('?','(') or before or other:
             QToolTip.hideText()
     except (IndexError, TypeError):
         QToolTip.hideText()
コード例 #10
0
ファイル: qtebase.py プロジェクト: vipmath/luminoso
 def hide_tooltip_if_necessary(self, key):
     """Hide calltip when necessary"""
     try:
         calltip_char = self.get_character(self.calltip_position)
         before = self.is_cursor_before(self.calltip_position,
                                        char_offset=1)
         other = key in (Qt.Key_ParenRight, Qt.Key_Period, Qt.Key_Tab)
         if calltip_char not in ('?','(') or before or other:
             QToolTip.hideText()
     except (IndexError, TypeError):
         QToolTip.hideText()
コード例 #11
0
    def hoverLeaveEvent(self, event):
        """
        Processes when this hotspot is entered.
        
        :param      event | <QHoverEvent>
        
        :return     <bool> | processed
        """
        self._hovered = False
        if self.toolTip():
            QToolTip.hideText()

        return self.style() == XNodeHotspot.Style.Icon
コード例 #12
0
 def hoverLeaveEvent(self, event):
     """
     Processes when this hotspot is entered.
     
     :param      event | <QHoverEvent>
     
     :return     <bool> | processed
     """
     self._hovered = False
     if self.toolTip():
         QToolTip.hideText()
     
     return self.style() == XNodeHotspot.Style.Icon
コード例 #13
0
 def startActionToolTip( self, action ):
     """
     Starts the timer to hover over an action for the current tool tip.
     
     :param      action | <QAction>
     """
     self._toolTipTimer.stop()
     QToolTip.hideText()
     
     if not action.toolTip():
         return
     
     self._toolTipAction = action
     self._toolTipTimer.start()
コード例 #14
0
 def hide_tooltip_if_necessary(self, key):
     """
     Hide calltip when necessary
     (this is handled here because QScintilla does not support
     user-defined calltips except very basic ones)
     """
     try:
         calltip_char = self.get_character(self.calltip_position)
         before = self.is_cursor_before(self.calltip_position,
                                        char_offset=1)
         other = key in (Qt.Key_ParenRight, Qt.Key_Period, Qt.Key_Tab)
         if calltip_char not in ('?','(') or before or other:
             QToolTip.hideText()
     except (IndexError, TypeError):
         QToolTip.hideText()
コード例 #15
0
ファイル: qscibase.py プロジェクト: cheesinglee/spyder
 def hide_tooltip_if_necessary(self, key):
     """
     Hide calltip when necessary
     (this is handled here because QScintilla does not support
     user-defined calltips except very basic ones)
     """
     try:
         calltip_char = self.get_character(self.calltip_position)
         before = self.is_cursor_before(self.calltip_position,
                                        char_offset=1)
         other = key in (Qt.Key_ParenRight, Qt.Key_Period, Qt.Key_Tab)
         if calltip_char not in ('?','(') or before or other:
             QToolTip.hideText()
     except (IndexError, TypeError):
         QToolTip.hideText()
コード例 #16
0
ファイル: owparallelgraph.py プロジェクト: mstajdohar/orange3
    def event(self, ev):
        if ev.type() == QEvent.ToolTip:
            x = self.inv_transform(xBottom, ev.pos().x())
            y = self.inv_transform(yLeft, ev.pos().y())

            canvas_position = self.mapToScene(ev.pos())
            x_float = self.inv_transform(xBottom, canvas_position.x())
            contact, (index, pos) = self.testArrowContact(int(round(x_float)), canvas_position.x(), canvas_position.y())
            if contact:
                attr = self.data_domain[self.attributes[index]]
                if isinstance(attr, ContinuousVariable):
                    condition = self.selection_conditions.get(attr.name, [0, 1])
                    val = self.attr_values[attr.name][0] + condition[pos] * (
                        self.attr_values[attr.name][1] - self.attr_values[attr.name][0]
                    )
                    str_val = attr.name + "= %%.%df" % attr.number_of_decimals % val
                    QToolTip.showText(ev.globalPos(), str_val)
            else:
                for curve in self.items():
                    if (
                        type(curve) == PolygonCurve
                        and curve.boundingRect().contains(x, y)
                        and getattr(curve, "tooltip", None)
                    ):
                        (name, value, total, dist) = curve.tooltip
                        count = sum([v[1] for v in dist])
                        if count == 0:
                            continue
                        tooltip_text = (
                            "Attribute: <b>%s</b><br>Value: <b>%s</b><br>"
                            "Total instances: <b>%i</b> (%.1f%%)<br>"
                            "Class distribution:<br>" % (name, value, count, 100.0 * count / float(total))
                        )
                        for (val, n) in dist:
                            tooltip_text += "&nbsp; &nbsp; <b>%s</b> : <b>%i</b> (%.1f%%)<br>" % (
                                val,
                                n,
                                100.0 * float(n) / float(count),
                            )
                        QToolTip.showText(ev.globalPos(), tooltip_text[:-4])

        elif ev.type() == QEvent.MouseMove:
            QToolTip.hideText()

        return OWPlot.event(self, ev)
コード例 #17
0
ファイル: surface.py プロジェクト: arnaldorusso/frescobaldi
 def updateKineticCursor(self, active):
     """Cursor handling when kinetic move starts/stops.
     
     - reset the cursor and hide tooltips if visible at start,
     - update the cursor and show the appropriate tooltips at stop.
     
     Used as a slot linked to the kineticStarted() signal.
     """
     if active:
         self.unsetCursor()
         if QToolTip.isVisible():
             QToolTip.hideText()
     else:
         self.updateCursor(QCursor.pos())
         if self._linksEnabled:
             page, link = self.pageLayout().linkAt(self.mapFromGlobal(QCursor.pos()))
             if link:
                 self.linkHelpEvent(QCursor.pos(), page, link)
コード例 #18
0
    def event(self, ev):
        if ev.type() == QEvent.ToolTip:
            x = self.inv_transform(xBottom, ev.pos().x())
            y = self.inv_transform(yLeft, ev.pos().y())

            canvas_position = self.mapToScene(ev.pos())
            x_float = self.inv_transform(xBottom, canvas_position.x())
            contact, (index,
                      pos) = self.testArrowContact(int(round(x_float)),
                                                   canvas_position.x(),
                                                   canvas_position.y())
            if contact:
                attr = self.data_domain[self.attributes[index]]
                if attr.is_continuous:
                    condition = self.selection_conditions.get(
                        attr.name, [0, 1])
                    val = self.attr_values[attr.name][0] + condition[pos] * (
                        self.attr_values[attr.name][1] -
                        self.attr_values[attr.name][0])
                    str_val = attr.name + "= %%.%df" % attr.number_of_decimals % val
                    QToolTip.showText(ev.globalPos(), str_val)
            else:
                for curve in self.items():
                    if type(curve) == PolygonCurve and \
                            curve.boundingRect().contains(x, y) and \
                            getattr(curve, "tooltip", None):
                        (name, value, total, dist) = curve.tooltip
                        count = sum([v[1] for v in dist])
                        if count == 0:
                            continue
                        tooltip_text = "Attribute: <b>%s</b><br>Value: <b>%s</b><br>" \
                                       "Total instances: <b>%i</b> (%.1f%%)<br>" \
                                       "Class distribution:<br>" % (
                                           name, value, count, 100.0 * count / float(total))
                        for (val, n) in dist:
                            tooltip_text += "&nbsp; &nbsp; <b>%s</b> : <b>%i</b> (%.1f%%)<br>" % (
                                val, n, 100.0 * float(n) / float(count))
                        QToolTip.showText(ev.globalPos(), tooltip_text[:-4])

        elif ev.type() == QEvent.MouseMove:
            QToolTip.hideText()

        return OWPlot.event(self, ev)
コード例 #19
0
 def updateKineticCursor(self, active):
     """Cursor handling when kinetic move starts/stops.
     
     - reset the cursor and hide tooltips if visible at start,
     - update the cursor and show the appropriate tooltips at stop.
     
     Used as a slot linked to the kineticStarted() signal.
     """
     if active:
         self.unsetCursor()
         if QToolTip.isVisible():
             QToolTip.hideText()
     else:
         self.updateCursor(QCursor.pos())
         if self._linksEnabled:
             page, link = self.pageLayout().linkAt(
                 self.mapFromGlobal(QCursor.pos()))
             if link:
                 self.linkHelpEvent(QCursor.pos(), page, link)
コード例 #20
0
ファイル: edit.py プロジェクト: terrence2/millipede
	def event(self, e):
		if e.type() == QEvent.ToolTip:
			cursor = self.cursorForPosition(e.pos())
			cursor.select(QTextCursor.WordUnderCursor)
			if cursor.selectedText():
				# discover where our text is in the document
				ln = cursor.block().firstLineNumber() + 1
				col_end = cursor.position() - cursor.block().position()
				content = cursor.selectedText()
				col_start = max(1, col_end - len(content))
				print('hover:', ln, str(col_start) + '->' + str(col_end), content)

				# map to an ast node and format a tooltip
				tooltip = QCoreApplication.instance().on_hover_text(self.document().module, (ln, col_start), (ln, col_end), content)

				# show the tooltip
				if tooltip:
					QToolTip.showText(e.globalPos(), tooltip)
			else:
				QToolTip.hideText()
			return True

		return super().event(e)
コード例 #21
0
ファイル: console.py プロジェクト: jonathanverner/qidle
 def _tool_tip_event(self, event):
     if event.key() in [ Qt.Key_Escape ]:
         QToolTip.hideText()
         return
     if ( self.mode == Console.MODE_CODE_EDITING and event.text() == '(' ):
         func_name = self.wordUnderCursor(delta=-2)
         cursor = self._currentCursor
     elif ( self.mode == Console.MODE_CODE_EDITING ):
         try:
             cursor, func_name = self._containing_function()
         except:
             QToolTip.hideText()
             return
     else:
         QToolTip.hideText()
         return
     doc = self.get_docs(func_name, _timeout=0.01, _default=None)
     try:
         args, defaults, varargs, kwargs = self.get_f_sign(func_name, _timeout=0.01, _default = None)
         if defaults is not None:
             start = len(args)-len(defaults)
             for i in range(len(defaults)):
                 args[i+start] += '=' + str(defaults[i])
         if varargs is not None:
             args.append('*'+varargs)
         if kwargs is not None:
             args.append('**'+kwargs)
         pos_args = ', '.join(args)
         sign_help = func_name+'('+pos_args+')\n\n'
     except:
         sign_help = None
     tooltip_text = ''
     if sign_help is not None:
         tooltip_text = sign_help
     if doc is not None:
         tooltip_text += doc
     if len(tooltip_text) > 0:
         cursor_rect = self.widget.cursorRect(cursor)
         logger.debug("Showing help: "+tooltip_text+" at "+str(self.widget.mapToGlobal(cursor_rect.bottomRight())))
         QToolTip.showText(self.widget.mapToGlobal(cursor_rect.bottomRight()),tooltip_text,self.widget)
     else:
         QToolTip.hideText()
コード例 #22
0
ファイル: editor.py プロジェクト: pdorrell/ninja-ide
    def highlight_current_line(self):
        self.emit(SIGNAL("cursorPositionChange(int, int)"),
            self.textCursor().blockNumber() + 1,
            self.textCursor().columnNumber())
        self.extraSelections = []

        if not self.isReadOnly():
            block = self.textCursor()
            selection = QTextEdit.ExtraSelection()
            lineColor = self._current_line_color
            lineColor.setAlpha(resources.CUSTOM_SCHEME.get(
                "current-line-opacity",
                resources.COLOR_SCHEME["current-line-opacity"]))

            checkers = sorted(self._neditable.registered_checkers,
                key=lambda x: x[2], reverse=True)
            for items in checkers:
                checker, color, _ = items
                if block.blockNumber() in checker.checks:
                    lineColor = color
                    lineColor.setAlpha(resources.CUSTOM_SCHEME.get(
                        "checker-background-opacity",
                        resources.COLOR_SCHEME["checker-background-opacity"]))
                    break

            selection.format.setBackground(lineColor)
            selection.format.setProperty(QTextFormat.FullWidthSelection, True)
            selection.cursor = self.textCursor()
            selection.cursor.clearSelection()
            self.extraSelections.append(selection)
        self.setExtraSelections(self.extraSelections)

        #Re-position tooltip to allow text editing in the line of the error
        if QToolTip.isVisible():
            QToolTip.hideText()

        if self._braces is not None:
            self._braces = None
        cursor = self.textCursor()
        if cursor.position() == 0:
            self.setExtraSelections(self.extraSelections)
            return
        cursor.movePosition(QTextCursor.PreviousCharacter,
                             QTextCursor.KeepAnchor)
        text = cursor.selectedText()
        pos1 = cursor.position()
        if text in (")", "]", "}"):
            pos2 = self._match_braces(pos1, text, forward=False)
        elif text in ("(", "[", "{"):
            pos2 = self._match_braces(pos1, text, forward=True)
        else:
            self.setExtraSelections(self.extraSelections)
            return
        if pos2 is not None:
            self._braces = (pos1, pos2)
            selection = QTextEdit.ExtraSelection()
            selection.format.setForeground(QColor(
                resources.CUSTOM_SCHEME.get('brace-foreground',
                resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.cursor = cursor
            self.extraSelections.append(selection)
            selection = QTextEdit.ExtraSelection()
            selection.format.setForeground(QColor(
                resources.CUSTOM_SCHEME.get('brace-foreground',
                resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.format.setBackground(QColor(
                resources.CUSTOM_SCHEME.get('brace-background',
                resources.COLOR_SCHEME.get('brace-background'))))
            selection.cursor = self.textCursor()
            selection.cursor.setPosition(pos2)
            selection.cursor.movePosition(QTextCursor.NextCharacter,
                             QTextCursor.KeepAnchor)
            self.extraSelections.append(selection)
        else:
            self._braces = (pos1,)
            selection = QTextEdit.ExtraSelection()
            selection.format.setBackground(QColor(
                resources.CUSTOM_SCHEME.get('brace-background',
                resources.COLOR_SCHEME.get('brace-background'))))
            selection.format.setForeground(QColor(
                resources.CUSTOM_SCHEME.get('brace-foreground',
                resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.cursor = cursor
            self.extraSelections.append(selection)
        self.setExtraSelections(self.extraSelections)
コード例 #23
0
ファイル: editor.py プロジェクト: Fieldbyte/ninja-ide
    def highlight_current_line(self):
        self.emit(SIGNAL("cursorPositionChange(int, int)"),
            self.textCursor().blockNumber() + 1,
            self.textCursor().columnNumber())
        self.extraSelections = []

        if not self.isReadOnly():
            selection = QTextEdit.ExtraSelection()
            lineColor = QColor(resources.CUSTOM_SCHEME.get('current-line',
                        resources.COLOR_SCHEME['current-line']))
            lineColor.setAlpha(20)
            selection.format.setBackground(lineColor)
            selection.format.setProperty(QTextFormat.FullWidthSelection, True)
            selection.cursor = self.textCursor()
            selection.cursor.clearSelection()
            self.extraSelections.append(selection)
        self.setExtraSelections(self.extraSelections)

        #Find Errors
        if settings.ERRORS_HIGHLIGHT_LINE and \
        len(self.errors.errorsSummary) < settings.MAX_HIGHLIGHT_ERRORS:
            cursor = self.textCursor()
            for lineno in self.errors.errorsSummary:
                block = self.document().findBlockByLineNumber(lineno - 1)
                if not block.isValid():
                    continue
                cursor.setPosition(block.position())
                selection = QTextEdit.ExtraSelection()
                selection.format.setUnderlineColor(QColor(
                    resources.CUSTOM_SCHEME.get('error-underline',
                    resources.COLOR_SCHEME['error-underline'])))
                selection.format.setUnderlineStyle(
                    QTextCharFormat.WaveUnderline)
                selection.cursor = cursor
                selection.cursor.movePosition(QTextCursor.EndOfBlock,
                    QTextCursor.KeepAnchor)
                self.extraSelections.append(selection)
            if self.errors.errorsSummary:
                self.setExtraSelections(self.extraSelections)

        #Check Style
        if settings.CHECK_HIGHLIGHT_LINE and \
        len(self.pep8.pep8checks) < settings.MAX_HIGHLIGHT_ERRORS:
            cursor = self.textCursor()
            for line in self.pep8.pep8checks:
                block = self.document().findBlockByLineNumber(line - 1)
                if not block.isValid():
                    continue
                cursor.setPosition(block.position())
                selection = QTextEdit.ExtraSelection()
                selection.format.setUnderlineColor(QColor(
                    resources.CUSTOM_SCHEME.get('pep8-underline',
                    resources.COLOR_SCHEME['pep8-underline'])))
                selection.format.setUnderlineStyle(
                    QTextCharFormat.WaveUnderline)
                selection.cursor = cursor
                selection.cursor.movePosition(QTextCursor.EndOfBlock,
                    QTextCursor.KeepAnchor)
                self.extraSelections.append(selection)
            if self.pep8.pep8checks:
                self.setExtraSelections(self.extraSelections)

        #Re-position tooltip to allow text editing in the line of the error
        if QToolTip.isVisible():
            QToolTip.hideText()

        if self._braces is not None:
            self._braces = None
        cursor = self.textCursor()
        if cursor.position() == 0:
            self.setExtraSelections(self.extraSelections)
            return
        cursor.movePosition(QTextCursor.PreviousCharacter,
                             QTextCursor.KeepAnchor)
        text = unicode(cursor.selectedText())
        pos1 = cursor.position()
        if text in (')', ']', '}'):
            pos2 = self._match_braces(pos1, text, forward=False)
        elif text in ('(', '[', '{'):
            pos2 = self._match_braces(pos1, text, forward=True)
        else:
            self.setExtraSelections(self.extraSelections)
            return
        if pos2 is not None:
            self._braces = (pos1, pos2)
            selection = QTextEdit.ExtraSelection()
            selection.format.setForeground(QColor(
                resources.CUSTOM_SCHEME.get('brace-foreground',
                resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.cursor = cursor
            self.extraSelections.append(selection)
            selection = QTextEdit.ExtraSelection()
            selection.format.setForeground(QColor(
                resources.CUSTOM_SCHEME.get('brace-foreground',
                resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.format.setBackground(QColor(
                resources.CUSTOM_SCHEME.get('brace-background',
                resources.COLOR_SCHEME.get('brace-background'))))
            selection.cursor = self.textCursor()
            selection.cursor.setPosition(pos2)
            selection.cursor.movePosition(QTextCursor.NextCharacter,
                             QTextCursor.KeepAnchor)
            self.extraSelections.append(selection)
        else:
            self._braces = (pos1,)
            selection = QTextEdit.ExtraSelection()
            selection.format.setBackground(QColor(
                resources.CUSTOM_SCHEME.get('brace-background',
                resources.COLOR_SCHEME.get('brace-background'))))
            selection.format.setForeground(QColor(
                resources.CUSTOM_SCHEME.get('brace-foreground',
                resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.cursor = cursor
            self.extraSelections.append(selection)
        self.setExtraSelections(self.extraSelections)
コード例 #24
0
ファイル: toolTip.py プロジェクト: ronaldomsjr/DsgTools
 	def deactivate(self):
 		QToolTip.hideText()
コード例 #25
0
 def canvasMoveEvent(self, e):
     if self.canvas.underMouse():  # Only if mouse is over the map
         QToolTip.hideText()
         self.timerMapTips.start(700)  # time in milliseconds
コード例 #26
0
ファイル: mikisearch.py プロジェクト: OSUser/mikidown
 def mouseMoveEvent(self, event):
     if self.flag:
         QToolTip.showText(QCursor.pos(), self.link)
     else:
         QToolTip.hideText()
     QWebView.mouseMoveEvent(self, event)
コード例 #27
0
ファイル: control.py プロジェクト: davidmorrill/facets
 def _set_tooltip ( self, tooltip ):
     self.control.setToolTip( tooltip )
     if tooltip == '':
         QToolTip.hideText()
コード例 #28
0
 def mouseMoveEvent(self, event):
     if self.flag:
         QToolTip.showText(QCursor.pos(), self.link)
     else:
         QToolTip.hideText()
     QWebView.mouseMoveEvent(self, event)
コード例 #29
0
ファイル: editor.py プロジェクト: Fieldbyte/ninja-ide
    def highlight_current_line(self):
        self.emit(SIGNAL("cursorPositionChange(int, int)"),
                  self.textCursor().blockNumber() + 1,
                  self.textCursor().columnNumber())
        self.extraSelections = []

        if not self.isReadOnly():
            selection = QTextEdit.ExtraSelection()
            lineColor = QColor(
                resources.CUSTOM_SCHEME.get(
                    'current-line', resources.COLOR_SCHEME['current-line']))
            lineColor.setAlpha(20)
            selection.format.setBackground(lineColor)
            selection.format.setProperty(QTextFormat.FullWidthSelection, True)
            selection.cursor = self.textCursor()
            selection.cursor.clearSelection()
            self.extraSelections.append(selection)
        self.setExtraSelections(self.extraSelections)

        #Find Errors
        if settings.ERRORS_HIGHLIGHT_LINE and \
        len(self.errors.errorsSummary) < settings.MAX_HIGHLIGHT_ERRORS:
            cursor = self.textCursor()
            for lineno in self.errors.errorsSummary:
                block = self.document().findBlockByLineNumber(lineno - 1)
                if not block.isValid():
                    continue
                cursor.setPosition(block.position())
                selection = QTextEdit.ExtraSelection()
                selection.format.setUnderlineColor(
                    QColor(
                        resources.CUSTOM_SCHEME.get(
                            'error-underline',
                            resources.COLOR_SCHEME['error-underline'])))
                selection.format.setUnderlineStyle(
                    QTextCharFormat.WaveUnderline)
                selection.cursor = cursor
                selection.cursor.movePosition(QTextCursor.EndOfBlock,
                                              QTextCursor.KeepAnchor)
                self.extraSelections.append(selection)
            if self.errors.errorsSummary:
                self.setExtraSelections(self.extraSelections)

        #Check Style
        if settings.CHECK_HIGHLIGHT_LINE and \
        len(self.pep8.pep8checks) < settings.MAX_HIGHLIGHT_ERRORS:
            cursor = self.textCursor()
            for line in self.pep8.pep8checks:
                block = self.document().findBlockByLineNumber(line - 1)
                if not block.isValid():
                    continue
                cursor.setPosition(block.position())
                selection = QTextEdit.ExtraSelection()
                selection.format.setUnderlineColor(
                    QColor(
                        resources.CUSTOM_SCHEME.get(
                            'pep8-underline',
                            resources.COLOR_SCHEME['pep8-underline'])))
                selection.format.setUnderlineStyle(
                    QTextCharFormat.WaveUnderline)
                selection.cursor = cursor
                selection.cursor.movePosition(QTextCursor.EndOfBlock,
                                              QTextCursor.KeepAnchor)
                self.extraSelections.append(selection)
            if self.pep8.pep8checks:
                self.setExtraSelections(self.extraSelections)

        #Re-position tooltip to allow text editing in the line of the error
        if QToolTip.isVisible():
            QToolTip.hideText()

        if self._braces is not None:
            self._braces = None
        cursor = self.textCursor()
        if cursor.position() == 0:
            self.setExtraSelections(self.extraSelections)
            return
        cursor.movePosition(QTextCursor.PreviousCharacter,
                            QTextCursor.KeepAnchor)
        text = unicode(cursor.selectedText())
        pos1 = cursor.position()
        if text in (')', ']', '}'):
            pos2 = self._match_braces(pos1, text, forward=False)
        elif text in ('(', '[', '{'):
            pos2 = self._match_braces(pos1, text, forward=True)
        else:
            self.setExtraSelections(self.extraSelections)
            return
        if pos2 is not None:
            self._braces = (pos1, pos2)
            selection = QTextEdit.ExtraSelection()
            selection.format.setForeground(
                QColor(
                    resources.CUSTOM_SCHEME.get(
                        'brace-foreground',
                        resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.cursor = cursor
            self.extraSelections.append(selection)
            selection = QTextEdit.ExtraSelection()
            selection.format.setForeground(
                QColor(
                    resources.CUSTOM_SCHEME.get(
                        'brace-foreground',
                        resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.format.setBackground(
                QColor(
                    resources.CUSTOM_SCHEME.get(
                        'brace-background',
                        resources.COLOR_SCHEME.get('brace-background'))))
            selection.cursor = self.textCursor()
            selection.cursor.setPosition(pos2)
            selection.cursor.movePosition(QTextCursor.NextCharacter,
                                          QTextCursor.KeepAnchor)
            self.extraSelections.append(selection)
        else:
            self._braces = (pos1, )
            selection = QTextEdit.ExtraSelection()
            selection.format.setBackground(
                QColor(
                    resources.CUSTOM_SCHEME.get(
                        'brace-background',
                        resources.COLOR_SCHEME.get('brace-background'))))
            selection.format.setForeground(
                QColor(
                    resources.CUSTOM_SCHEME.get(
                        'brace-foreground',
                        resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.cursor = cursor
            self.extraSelections.append(selection)
        self.setExtraSelections(self.extraSelections)
コード例 #30
0
 def canvasMoveEvent(self, e):
     QToolTip.hideText()
     self.timerMapTips.start( 500 ) # time in milliseconds
     self.showToolTip()               
コード例 #31
0
 def _onDwellEnd( self, position, x, y ):
     " Triggered when mouse ended to dwell "
     if self.__revisionTooltipShown:
         self.__revisionTooltipShown = False
         QToolTip.hideText()
     return
コード例 #32
0
 def _onDwellEnd(self, position, x, y):
     " Triggered when mouse ended to dwell "
     if self.__timestampTooltipShown:
         self.__timestampTooltipShown = False
         QToolTip.hideText()
     return
コード例 #33
0
ファイル: editor.py プロジェクト: akatrevorjay/ninja-ide
    def highlight_current_line(self):
        self.emit(SIGNAL("cursorPositionChange(int, int)"),
            self.textCursor().blockNumber() + 1,
            self.textCursor().columnNumber())
        self.extraSelections = []

        if not self.isReadOnly():
            selection = QTextEdit.ExtraSelection()
            lineColor = QColor(resources.CUSTOM_SCHEME.get('current-line',
                        resources.COLOR_SCHEME['current-line']))
            lineColor.setAlpha(20)
            selection.format.setBackground(lineColor)
            selection.format.setProperty(QTextFormat.FullWidthSelection, True)
            selection.cursor = self.textCursor()
            selection.cursor.clearSelection()
            self.extraSelections.append(selection)
        self.setExtraSelections(self.extraSelections)

        #Re-position tooltip to allow text editing in the line of the error
        if QToolTip.isVisible():
            QToolTip.hideText()

        if self._braces is not None:
            self._braces = None
        cursor = self.textCursor()
        if cursor.position() == 0:
            self.setExtraSelections(self.extraSelections)
            return
        cursor.movePosition(QTextCursor.PreviousCharacter,
                             QTextCursor.KeepAnchor)
        text = unicode(cursor.selectedText())
        pos1 = cursor.position()
        if text in (")", "]", "}"):
            pos2 = self._match_braces(pos1, text, forward=False)
        elif text in ("(", "[", "{"):
            pos2 = self._match_braces(pos1, text, forward=True)
        else:
            self.setExtraSelections(self.extraSelections)
            return
        if pos2 is not None:
            self._braces = (pos1, pos2)
            selection = QTextEdit.ExtraSelection()
            selection.format.setForeground(QColor(
                resources.CUSTOM_SCHEME.get('brace-foreground',
                resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.cursor = cursor
            self.extraSelections.append(selection)
            selection = QTextEdit.ExtraSelection()
            selection.format.setForeground(QColor(
                resources.CUSTOM_SCHEME.get('brace-foreground',
                resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.format.setBackground(QColor(
                resources.CUSTOM_SCHEME.get('brace-background',
                resources.COLOR_SCHEME.get('brace-background'))))
            selection.cursor = self.textCursor()
            selection.cursor.setPosition(pos2)
            selection.cursor.movePosition(QTextCursor.NextCharacter,
                             QTextCursor.KeepAnchor)
            self.extraSelections.append(selection)
        else:
            self._braces = (pos1,)
            selection = QTextEdit.ExtraSelection()
            selection.format.setBackground(QColor(
                resources.CUSTOM_SCHEME.get('brace-background',
                resources.COLOR_SCHEME.get('brace-background'))))
            selection.format.setForeground(QColor(
                resources.CUSTOM_SCHEME.get('brace-foreground',
                resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.cursor = cursor
            self.extraSelections.append(selection)
        self.setExtraSelections(self.extraSelections)
コード例 #34
0
ファイル: editor.py プロジェクト: skela/ninja-ide
    def highlight_current_line(self):
        self.emit(SIGNAL("cursorPositionChange(int, int)"),
                  self.textCursor().blockNumber() + 1,
                  self.textCursor().columnNumber())
        self.extraSelections = []

        if not self.isReadOnly():
            block = self.textCursor()
            selection = QTextEdit.ExtraSelection()
            lineColor = self._current_line_color
            lineColor.setAlpha(
                resources.CUSTOM_SCHEME.get(
                    "current-line-opacity",
                    resources.COLOR_SCHEME["current-line-opacity"]))

            checkers = self._neditable.sorted_checkers
            for items in checkers:
                checker, color, _ = items
                if block.blockNumber() in checker.checks:
                    lineColor = QColor(color)
                    lineColor.setAlpha(
                        resources.CUSTOM_SCHEME.get(
                            "checker-background-opacity", resources.
                            COLOR_SCHEME["checker-background-opacity"]))
                    break

            selection.format.setBackground(lineColor)
            selection.format.setProperty(QTextFormat.FullWidthSelection, True)
            selection.cursor = self.textCursor()
            selection.cursor.clearSelection()
            self.extraSelections.append(selection)
        self.setExtraSelections(self.extraSelections)

        #Re-position tooltip to allow text editing in the line of the error
        if QToolTip.isVisible():
            QToolTip.hideText()

        if self._braces is not None:
            self._braces = None
        cursor = self.textCursor()
        if cursor.position() == 0:
            self.setExtraSelections(self.extraSelections)
            return
        cursor.movePosition(QTextCursor.PreviousCharacter,
                            QTextCursor.KeepAnchor)
        text = cursor.selectedText()
        pos1 = cursor.position()
        if text in (")", "]", "}"):
            pos2 = self._match_braces(pos1, text, forward=False)
        elif text in ("(", "[", "{"):
            pos2 = self._match_braces(pos1, text, forward=True)
        else:
            self.setExtraSelections(self.extraSelections)
            return
        if pos2 is not None:
            self._braces = (pos1, pos2)
            selection = QTextEdit.ExtraSelection()
            selection.format.setForeground(
                QColor(
                    resources.CUSTOM_SCHEME.get(
                        'brace-foreground',
                        resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.cursor = cursor
            self.extraSelections.append(selection)
            selection = QTextEdit.ExtraSelection()
            selection.format.setForeground(
                QColor(
                    resources.CUSTOM_SCHEME.get(
                        'brace-foreground',
                        resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.format.setBackground(
                QColor(
                    resources.CUSTOM_SCHEME.get(
                        'brace-background',
                        resources.COLOR_SCHEME.get('brace-background'))))
            selection.cursor = self.textCursor()
            selection.cursor.setPosition(pos2)
            selection.cursor.movePosition(QTextCursor.NextCharacter,
                                          QTextCursor.KeepAnchor)
            self.extraSelections.append(selection)
        else:
            self._braces = (pos1, )
            selection = QTextEdit.ExtraSelection()
            selection.format.setBackground(
                QColor(
                    resources.CUSTOM_SCHEME.get(
                        'brace-background',
                        resources.COLOR_SCHEME.get('brace-background'))))
            selection.format.setForeground(
                QColor(
                    resources.CUSTOM_SCHEME.get(
                        'brace-foreground',
                        resources.COLOR_SCHEME.get('brace-foreground'))))
            selection.cursor = cursor
            self.extraSelections.append(selection)
        self.setExtraSelections(self.extraSelections)
コード例 #35
0
ファイル: console.py プロジェクト: jonathanverner/qidle
    def keyPressEvent(self, event):

        # Ctrl-C Handling
        if event.matches(QKeySequence.Copy):
            if (self._currentCursor.selection().isEmpty and (self.mode == Console.MODE_RUNNING or self.mode == Console.MODE_RAW_INPUT)):
                self._mode = Console.MODE_WAITING_FOR_INTERRUPT
                self.timer.timeout.connect(self._restart_shell_from_interrupt)
                self.timer.start(1000)
                self.interrupt_shell.emit()

        # Ctrl-Q Handling
        if event.matches(QKeySequence.Quit):
            if self.allow_quit:
                self.quit.emit()
                # logger.debug(msg("Quitting ..."))
                # self.widget.close()
                event.ignore()
            return

        # Ctrl-+/- Handling
        if event.matches(QKeySequence.ZoomIn):
            self.increase_font()
            return
        if event.matches(QKeySequence.ZoomOut):
            self.decrease_font()

        # Ctrl-O Handling
        if event.matches(QKeySequence.Open) and self.mode == Console.MODE_CODE_EDITING:
            self.load_file_dlg()
            event.ignore()
            return

        # No editing allowed in read only mode
        elif self.mode == Console.MODE_READ_ONLY:
            if event.key() in [Qt.Key_Return, Qt.Key_Backspace, Qt.Key_Delete] or len(event.text()) != 0:
                event.ignore()
                return

        # Nothing allowed when the shell is running or waiting for interrupt
        elif self.mode in [Console.MODE_RUNNING, Console.MODE_WAITING_FOR_INTERRUPT]:
            event.ignore()
            return

        # Completer widget is shown, delegate to completer
        elif self._process_completion_widget(event):
            return

        # Enter
        elif event.key() == Qt.Key_Return:
            self._process_enter()
            QToolTip.hideText()
            return

        # BackSpace
        elif event.key() == Qt.Key_Backspace:
            if self.mode == Console.MODE_CODE_EDITING:
                # If in leading position
                if self._currentBlock.isInLeadingPosition(self._currentCursor):
                    # no indent present, join with previous block
                    if self._currentBlock.indentLevel() == 0:
                        if self._currentBlock.type == TextBlock.TYPE_CODE_CONTINUED:
                            self._joinCurrentToPreviousBlock()
                            return
                        event.ignore()
                        return
                    # unindent the current line
                    else:
                        self._currentBlock.unIndent()
                        return
            # prevent deleting inactive characters
            if not self._canDeletePreviousChar():
                event.ignore()
                return

        # HOME
        elif event.matches(QKeySequence.MoveToStartOfLine):
            self._currentCursor = self._currentBlock.leadingCursor()
            return
        elif event.key() == Qt.Key_Home and (event.modifiers() & Qt.ShiftModifier):
            c = self._currentCursor
            self._currentBlock.cursorSelectToLeadingPosition(c)
            self._currentCursor = c
            return

        # LEFT, UP, DOWN ...
        # elif event.matches(QKeySequence.MoveToPreviousChar):
        elif event.key() == Qt.Key_Left and not self._currentBlock.containsCursor(self._currentCursor, in_active_area='strict'):
            event.ignore()
            return

        # Ctrl-UP
        elif event.key() == Qt.Key_Up and (event.modifiers() & Qt.ControlModifier):
            prev = self._currentBlock.firstSameBlock()
            if not prev.isFirst():
                prev = prev.previous().firstSameBlock()
            self._currentCursor = prev.cursorAt(
                self._currentCursor.positionInBlock())

        # Ctrl-Down
        elif event.key() == Qt.Key_Down and (event.modifiers() & Qt.ControlModifier):
            next = self._currentBlock.lastSameBlock()
            if not next.isLast():
                next = next.next()
            self._currentCursor = next.cursorAt(
                self._currentCursor.positionInBlock())

        # DELETE KEY
        # Prevent Editing of Noneditable blocks
        elif (not self._currentBlock.type in TextBlock.EDITABLE_TYPES or not self._cursorInEditableArea()):
            if len(event.text()) != 0:
                self._gotoEnd()
                # event.ignore()
                # return

        # Code Completion
        if self._completion_event(event):
            return

        ret =  self._widgetKeyPressEvent(event)

        # Function call tooltips
        self._tool_tip_event(event)

        return ret