Exemplo n.º 1
0
Arquivo: ui.py Projeto: kba/calibre
 def event(self, ev):
     if ev.type() == ev.ToolTip:
         evh = QHelpEvent(ev)
         self.tooltip_requested.emit(
                 (self, evh.globalPos()))
         return True
     return QSystemTrayIcon.event(self, ev)
Exemplo n.º 2
0
    def eventFilter(self, receiver, event):
        #QtGui.QToolTip.showText(QtGui.QCursor.pos(), tip)
        if event.type() == QtCore.QEvent.ToolTip:
            helpEvent = QHelpEvent(event)
            cursor = QtGui.QTextCursor()
            cursor = receiver.cursorForPosition(helpEvent.pos())
            pos = cursor.position()
            receiver.setToolTip("")
            displayText = ""
            # occasional None type error
            if self.code_text is None:
                #Call Base Class Method to Continue Normal Event Processing
                return super(ToolTip_EventFilter, self).eventFilter(receiver, event)
            for item in self.code_text:
                if item['pos0'] <= pos and item['pos1'] >= pos:
                    if displayText == "":
                        displayText = item['name']
                    else:  # can have multiple codes on same selected area
                        try:
                            displayText += "\n" + item['name']
                        except Exception as e:
                            msg = "Codes ToolTipEventFilter " + str(e) + ". Possible key error: "
                            msg += str(item) + "\n" + self.code_text
                            logger.error(msg)
            if displayText != "":
                receiver.setToolTip(displayText)

        #Call Base Class Method to Continue Normal Event Processing
        return super(ToolTip_EventFilter, self).eventFilter(receiver, event)
Exemplo n.º 3
0
 def eventFilter(self, receiver, event):
     # QtGui.QToolTip.showText(QtGui.QCursor.pos(), tip)
     # Added check for media_data, it may be None
     if event.type() == QtCore.QEvent.ToolTip and self.media_data:
         help_event = QHelpEvent(event)
         # cursor = QtGui.QTextCursor()
         cursor = receiver.cursorForPosition(help_event.pos())
         pos = cursor.position()
         receiver.setToolTip("")
         for item in self.media_data:
             if item['pos0'] <= pos and item['pos1'] >= pos:
                 receiver.setToolTip(_("Right click to view"))
     # Call Base Class Method to Continue Normal Event Processing
     return super(ToolTipEventFilter, self).eventFilter(receiver, event)
Exemplo n.º 4
0
    def eventFilter(self, receiver, event):
        # QtWidgets.QToolTip.showText(QtGui.QCursor.pos(), tip)
        if event.type() == QtCore.QEvent.ToolTip:
            helpEvent = QHelpEvent(event)
            cursor = QtGui.QTextCursor()
            cursor = receiver.cursorForPosition(helpEvent.pos())
            pos = cursor.position()
            receiver.setToolTip("")
            displayText = ""
            if isinstance(self.coding, list):
                # self.coding can be None if not file is open
                for item in self.coding:
                    if item['selfirst'] <= pos and item['selend'] >= pos:
                        if displayText == "":
                            displayText = item['name']
                        else: # can have multiple codes on same selected area
                            displayText += "\n" + item['name']
            if displayText != "":
                receiver.setToolTip(displayText)

        # Call Base Class Method to Continue Normal Event Processing
        return super(TT_EventFilter,self).eventFilter(receiver, event)
Exemplo n.º 5
0
 def event(self, ev):
     if ev.type() == ev.ToolTip:
         evh = QHelpEvent(ev)
         self.tooltip_requested.emit((self, evh.globalPos()))
         return True
     return QSystemTrayIcon.event(self, ev)