Exemplo n.º 1
0
 def showMethodToolTip(self):
     """
     Pops up a tooltip message with the help for the object under the \
     cursor.
     
     :return     <bool> success
     """
     self.cancelCompletion()
     
     obj, _ = self.objectAtCursor()
     if not obj:
         return False
     
     docs = inspect.getdoc(obj)
     if not docs:
         return False
     
     # determine the cursor position
     rect   = self.cursorRect()
     cursor = self.textCursor()
     point  = QPoint(rect.left(), rect.top() + 18)
     
     QToolTip.showText(self.mapToGlobal(point), docs, self)
     
     return True
Exemplo n.º 2
0
    def showMethodToolTip(self):
        """
        Pops up a tooltip message with the help for the object under the \
        cursor.
        
        :return     <bool> success
        """
        self.cancelCompletion()

        obj, _ = self.objectAtCursor()
        if not obj:
            return False

        docs = inspect.getdoc(obj)
        if not docs:
            return False

        # determine the cursor position
        rect = self.cursorRect()
        cursor = self.textCursor()
        point = QPoint(rect.left(), rect.top() + 18)

        QToolTip.showText(self.mapToGlobal(point), docs, self)

        return True
Exemplo n.º 3
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, Qt.Key_PageUp,
                             Qt.Key_PageDown):
            return False

        else:
            self.keyPressEvent(event)

            # update the completer
            cursor = self.textCursor()
            text = projex.text.nativestring(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.nativestring(item.text(0)).startswith(text):
                    self._completerTree.setCurrentItem(item)
                    break

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

            return True
Exemplo n.º 4
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, Qt.Key_PageUp, Qt.Key_PageDown):
         return False
     
     else:
         self.keyPressEvent(event)
         
         # update the completer
         cursor   = self.textCursor()
         text     = projex.text.nativestring(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.nativestring(item.text(0)).startswith(text):
                 self._completerTree.setCurrentItem(item)
                 break
         
         self._completerTree.blockSignals(False)
         self._completerTree.setUpdatesEnabled(True)
         
         return True
Exemplo n.º 5
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
Exemplo n.º 6
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
Exemplo n.º 7
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()
Exemplo n.º 8
0
 def hoverEnterEvent(self, event):
     """
     Processes when this hotspot is entered.
     
     :param      event | <QHoverEvent>
     
     :return     <bool> | processed
     """
     self._hovered = True
     if self.toolTip():
         QToolTip.showText(QCursor.pos(), self.toolTip())
         return True
     
     return self.style() == XNodeHotspot.Style.Icon
Exemplo n.º 9
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()
Exemplo n.º 10
0
    def hoverEnterEvent(self, event):
        """
        Processes when this hotspot is entered.
        
        :param      event | <QHoverEvent>
        
        :return     <bool> | processed
        """
        self._hovered = True
        if self.toolTip():
            QToolTip.showText(QCursor.pos(), self.toolTip())
            return True

        return self.style() == XNodeHotspot.Style.Icon
Exemplo n.º 11
0
 def showActionToolTip(self):
     """
     Shows the tool tip of the action that is currently being hovered over.
     
     :param      action | <QAction>
     """
     if ( not self.isVisible() ):
         return
         
     geom  = self.actionGeometry(self._toolTipAction)
     pos   = self.mapToGlobal(QPoint(geom.left(), geom.top()))
     pos.setY(pos.y() + geom.height())
     
     tip   = nativestring(self._toolTipAction.toolTip()).strip().strip('.')
     text  = nativestring(self._toolTipAction.text()).strip().strip('.')
     
     # don't waste time showing the user what they already see
     if ( tip == text ):
         return
     
     QToolTip.showText(pos, self._toolTipAction.toolTip())
Exemplo n.º 12
0
    def showActionToolTip(self):
        """
        Shows the tool tip of the action that is currently being hovered over.
        
        :param      action | <QAction>
        """
        if (not self.isVisible()):
            return

        geom = self.actionGeometry(self._toolTipAction)
        pos = self.mapToGlobal(QPoint(geom.left(), geom.top()))
        pos.setY(pos.y() + geom.height())

        tip = nativestring(self._toolTipAction.toolTip()).strip().strip('.')
        text = nativestring(self._toolTipAction.text()).strip().strip('.')

        # don't waste time showing the user what they already see
        if (tip == text):
            return

        QToolTip.showText(pos, self._toolTipAction.toolTip())