コード例 #1
0
    def wheelEvent(self, event: QtGui.QWheelEvent):
        """Implementation.

    Handles zooming the editor's view.
    """

        if (event.modifiers() & Qt.ControlModifier
                and event.orientation() == Qt.Vertical):
            if event.delta() > 0:
                self.zoomIn()
            else:
                self.zoomOut()

            # TODO: Improve cursor anchoring; be more like Aseprite
            prevAnchor = self.transformationAnchor()
            self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
            self.setTransform(QTransform.fromScale(self.zoom(), self.zoom()))
            self.updateSceneRect(self.zoom())
            self.setTransformationAnchor(prevAnchor)
            event.accept()
        elif event.orientation() == Qt.Horizontal:
            # XXX: Workaround for the insane horizontal scroll delta of 15240 on the
            # Logitech G502 mouse.
            if abs(event.delta()) == 15240:
                newDelta = 120 if event.delta() > 0 else -120
                event = QtGui.QWheelEvent(event.pos(),
                                          event.globalPos(),
                                          newDelta,
                                          event.buttons(),
                                          event.modifiers(),
                                          orient=Qt.Horizontal)
            super().wheelEvent(event)
        else:
            super().wheelEvent(event)
コード例 #2
0
 def wheelEvent(self, e: QWheelEvent):
     if e.modifiers() & Qt.ControlModifier:
         if e.delta() > 0:
             self.view.zoomIn(6)
         else:
             self.view.zoomOut(6)
     else:
         QGraphicsView.wheelEvent(e)
コード例 #3
0
ファイル: combo_slider.py プロジェクト: IvanKosik/vision
    def wheelEvent(self, event: QWheelEvent):
        value_delta = event.angleDelta().y() / 120
        if event.modifiers() & Qt.ControlModifier:
            value_delta *= 10
        self.set_focus()
        self.increase_value(value_delta)

        event.accept()
コード例 #4
0
ファイル: qminimap.py プロジェクト: IMULMUL/angr-management
    def wheelEvent(self, event: QWheelEvent):
        """
        Forward the wheel event to target view to handle zoom events.
        """
        if event.modifiers() & Qt.ControlModifier == Qt.ControlModifier:
            self._target_view.centerOn(
                self.map_event_pos_to_target_scene_pos(event.pos()))

        self._target_view.wheelEvent(event)
コード例 #5
0
 def __cloneMouseWheelEvent(self, e: QWheelEvent):
     pos = e.pos()
     globalPos = e.globalPos()
     pixelDelta = e.pixelDelta()
     angleDelta = e.angleDelta()
     buttons = e.buttons()
     modifiers = e.modifiers()
     phase = e.phase()
     inverted = e.inverted()
     clone = QWheelEvent(pos, globalPos, pixelDelta, angleDelta, buttons, modifiers, phase, inverted)
     clone.ignore()
     clone.accepted = False
     return clone
コード例 #6
0
	def wheelEvent(self, event: QWheelEvent) -> None:
		"""
		Handle wheel scroll events. This will zoom in or out if the Ctrl key is pressed.
		
		:param event: the wheel scroll event
		:type event: QWheelEvent
		:return: None
		:rtype: NoneType
		"""
		if event.modifiers() != Qt.ControlModifier:
			return

		# Zoom
		if event.delta() > 0:
			self.zoomIn(event.pos())
		else:
			self.zoomOut(event.pos())
コード例 #7
0
 def wheelEvent(self, event:QtGui.QWheelEvent):
     if event.modifiers() & Qt.ControlModifier:
         point = event.angleDelta()
         delta = point.x()+point.y() # allow left-to-right balls as well
         self.loader.setZoomFactor(min(max(self.loader.zoomFactor() + delta*0.005, 0.25), 5.0))