コード例 #1
0
 def wheelEvent(self, event: QWheelEvent):
     # Zoom
     if event.modifiers() & Qt.ControlModifier \
             and event.buttons() == Qt.NoButton:
         delta = event.angleDelta().y()
         # use mouse position as anchor while zooming
         anchor = self.transformationAnchor()
         self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
         self.__setZoomLevel(self.__zoomLevel + 10 * delta / 120)
         self.setTransformationAnchor(anchor)
         event.accept()
     # Scroll horizontally
     elif self.__should_scroll_horizontally(event):
         x, y = event.angleDelta().x(), event.angleDelta().y()
         sign_value = x if x != 0 else y
         sign = 1 if sign_value >= 0 else -1
         new_angle_delta = QPoint(sign * max(abs(x), abs(y), sign_value), 0)
         new_pixel_delta = QPoint(0, 0)
         new_modifiers = event.modifiers() & ~(Qt.ShiftModifier
                                               | Qt.AltModifier)
         new_event = QWheelEvent(event.pos(), event.globalPos(),
                                 new_pixel_delta, new_angle_delta,
                                 event.buttons(), new_modifiers,
                                 event.phase(), event.inverted(),
                                 event.source())
         event.accept()
         super().wheelEvent(new_event)
     else:
         super().wheelEvent(event)
コード例 #2
0
ファイル: view.py プロジェクト: scoobiii/orange-canvas-core
 def wheelEvent(self, event: QWheelEvent):
     if event.modifiers() & Qt.ControlModifier \
             and event.buttons() == Qt.NoButton:
         # Zoom
         delta = event.angleDelta().y()
         # use mouse position as anchor while zooming
         anchor = self.transformationAnchor()
         self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
         self.__setZoomLevel(self.__zoomLevel + 10 * delta / 120)
         self.setTransformationAnchor(anchor)
         event.accept()
     elif event.source() == Qt.MouseEventNotSynthesized \
                and (event.angleDelta().x() == 0 \
                and not self.verticalScrollBar().isVisible()) \
                or (sys.platform == 'darwin' and event.modifiers() & Qt.ShiftModifier
                    or sys.platform != 'darwin' and event.modifiers() & Qt.AltModifier):
         # Scroll horizontally
         x, y = event.angleDelta().x(), event.angleDelta().y()
         sign_value = x if x != 0 else y
         sign = 1 if sign_value >= 0 else -1
         new_angle_delta = QPoint(sign * max(abs(x), abs(y), sign_value), 0)
         new_pixel_delta = QPoint(0, 0)
         new_modifiers = event.modifiers() & ~(Qt.ShiftModifier
                                               | Qt.AltModifier)
         new_event = QWheelEvent(event.pos(), event.globalPos(),
                                 new_pixel_delta, new_angle_delta,
                                 event.buttons(), new_modifiers,
                                 event.phase(), event.inverted(),
                                 event.source())
         event.accept()
         super().wheelEvent(new_event)
     else:
         super().wheelEvent(event)
コード例 #3
0
ファイル: gui.py プロジェクト: zyblx/orange3
 def wheelEvent(self, event: QWheelEvent):
     if event.source() == Qt.MouseEventNotSynthesized and \
             (event.modifiers() & Qt.ShiftModifier and sys.platform == 'darwin' or
              event.modifiers() & Qt.AltModifier and sys.platform != 'darwin'):
         new_event = QWheelEvent(event.pos(), event.globalPos(),
                                 event.pixelDelta(), event.angleDelta(),
                                 event.buttons(), Qt.NoModifier,
                                 event.phase(), event.inverted(),
                                 Qt.MouseEventSynthesizedByApplication)
         event.accept()
         super().wheelEvent(new_event)
     else:
         super().wheelEvent(event)