def eventFilter(self, obj: QObject, event: QEvent) -> bool:
     """Filter events for custom title bar."""
     if obj is self.ui.titleRightInfo and event.type(
     ) == QEvent.MouseButtonDblClick:
         # This was originally done with a delay of 250 but I didn't like it.
         # QTimer.singleShot(250, lambda: self.maximize_restore())
         self.maximize_restore()
     if obj is self.ui.titleRightInfo and event.type(
     ) == QEvent.MouseButtonPress:
         self.drag_pos = event.globalPos()
     if obj is self.ui.titleRightInfo and event.type() == QEvent.MouseMove:
         # Restore the window when it is moved in maximized state.
         if self.isMaximized():
             # TODO: When doing this, we also need to move the window so it's under the mouse cursor!
             self.maximize_restore()
         # Move the window to the new position.
         if event.buttons() == Qt.LeftButton:
             self.move(self.pos() + event.globalPos() - self.drag_pos)
             self.drag_pos = event.globalPos()
             return True
     if obj is self.ui.titleRightInfo and event.type(
     ) == QEvent.MouseButtonRelease:
         # Todo: Check if we should move it to the last received position.
         self.drag_pos = None
     if obj is self and event.type() == QEvent.Resize:
         self.resize_grips()
     return False
Exemple #2
0
    def event(self, event: QEvent) -> bool:
        if event.type() == QEvent.ToolTip:
            offset = self.xy_to_offset(event.pos().x(), event.pos().y())
            if offset is None:
                QToolTip.hideText()
                return True
            self.signal_show_tooltip_at_offset.emit(offset, event.globalPos())
            return True

        return super().event(event)