Exemplo n.º 1
0
 def wheelEvent(self, a0: QtGui.QWheelEvent) -> None:
     if len(self.tdrWindow.td) == 0:
         a0.ignore()
         return
     chart_height = self.chartHeight
     chart_width = self.chartWidth
     do_zoom_x = do_zoom_y = True
     if a0.modifiers() == QtCore.Qt.ShiftModifier:
         do_zoom_x = False
     if a0.modifiers() == QtCore.Qt.ControlModifier:
         do_zoom_y = False
     if a0.angleDelta().y() > 0:
         # Zoom in
         a0.accept()
         # Center of zoom = a0.x(), a0.y()
         # We zoom in by 1/10 of the width/height.
         rate = a0.angleDelta().y() / 120
         if do_zoom_x:
             zoomx = rate * chart_width / 10
         else:
             zoomx = 0
         if do_zoom_y:
             zoomy = rate * chart_height / 10
         else:
             zoomy = 0
         absx = max(0, a0.x() - self.leftMargin)
         absy = max(0, a0.y() - self.topMargin)
         ratiox = absx / chart_width
         ratioy = absy / chart_height
         # TODO: Change zoom to center on the mouse if possible, or extend box to the side that has room if not.
         p1x = int(self.leftMargin + ratiox * zoomx)
         p1y = int(self.topMargin + ratioy * zoomy)
         p2x = int(self.leftMargin + chart_width - (1 - ratiox) * zoomx)
         p2y = int(self.topMargin + chart_height - (1 - ratioy) * zoomy)
         self.zoomTo(p1x, p1y, p2x, p2y)
     elif a0.angleDelta().y() < 0:
         # Zoom out
         a0.accept()
         # Center of zoom = a0.x(), a0.y()
         # We zoom out by 1/9 of the width/height, to match zoom in.
         rate = -a0.angleDelta().y() / 120
         if do_zoom_x:
             zoomx = rate * chart_width / 9
         else:
             zoomx = 0
         if do_zoom_y:
             zoomy = rate * chart_height / 9
         else:
             zoomy = 0
         absx = max(0, a0.x() - self.leftMargin)
         absy = max(0, a0.y() - self.topMargin)
         ratiox = absx / chart_width
         ratioy = absy / chart_height
         p1x = int(self.leftMargin - ratiox * zoomx)
         p1y = int(self.topMargin - ratioy * zoomy)
         p2x = int(self.leftMargin + chart_width + (1 - ratiox) * zoomx)
         p2y = int(self.topMargin + chart_height + (1 - ratioy) * zoomy)
         self.zoomTo(p1x, p1y, p2x, p2y)
     else:
         a0.ignore()
Exemplo n.º 2
0
 def wheelEvent(self, event: QtGui.QWheelEvent):
     try:
         zoom = super().page().mainFrame().zoomFactor()
         if self.ctrlOn is True:
             event.accept()
             if event.angleDelta().y() > 0:
                 zoom += 0.2
             else:
                 zoom -= 0.2
             if zoom <= 0.2: zoom = 0.2
             if zoom >= 3: zoom = 3
             print('zoom = {}'.format(zoom))
             super().page().mainFrame().setZoomFactor(zoom)
         # super().page().repaint()
         else:
             if self.mode.value == QwwMode.CBZ.value:
                 super().page().mainFrame().setZoomFactor(1)
                 event.accept()
                 passed = 0
                 if event.angleDelta().y() < 0: passed = 1
                 elif event.angleDelta().y() > 0: passed = -1
                 self.updatePositionCbz(passed)
             else:
                 self.updatePositionEpub(event.angleDelta().y() * -1)
                 event.ignore()
     except Exception:
         traceback.print_exc()
Exemplo n.º 3
0
 def wheelEvent(self, a0: QtGui.QWheelEvent) -> None:
     if len(self.data) == 0 and len(self.reference) == 0:
         a0.ignore()
         return
     do_zoom_x = do_zoom_y = True
     if a0.modifiers() == QtCore.Qt.ShiftModifier:
         do_zoom_x = False
     if a0.modifiers() == QtCore.Qt.ControlModifier:
         do_zoom_y = False
     if a0.angleDelta().y() > 0:
         # Zoom in
         a0.accept()
         # Center of zoom = a0.x(), a0.y()
         # We zoom in by 1/10 of the width/height.
         rate = a0.angleDelta().y() / 120
         if do_zoom_x:
             zoomx = rate * self.chartWidth / 10
         else:
             zoomx = 0
         if do_zoom_y:
             zoomy = rate * self.chartHeight / 10
         else:
             zoomy = 0
         absx = max(0, a0.x() - self.leftMargin)
         absy = max(0, a0.y() - self.topMargin)
         ratiox = absx / self.chartWidth
         ratioy = absy / self.chartHeight
         p1x = int(self.leftMargin + ratiox * zoomx)
         p1y = int(self.topMargin + ratioy * zoomy)
         p2x = int(self.leftMargin + self.chartWidth - (1 - ratiox) * zoomx)
         p2y = int(self.topMargin + self.chartHeight - (1 - ratioy) * zoomy)
         self.zoomTo(p1x, p1y, p2x, p2y)
     elif a0.angleDelta().y() < 0:
         # Zoom out
         a0.accept()
         # Center of zoom = a0.x(), a0.y()
         # We zoom out by 1/9 of the width/height, to match zoom in.
         rate = -a0.angleDelta().y() / 120
         if do_zoom_x:
             zoomx = rate * self.chartWidth / 9
         else:
             zoomx = 0
         if do_zoom_y:
             zoomy = rate * self.chartHeight / 9
         else:
             zoomy = 0
         absx = max(0, a0.x() - self.leftMargin)
         absy = max(0, a0.y() - self.topMargin)
         ratiox = absx / self.chartWidth
         ratioy = absy / self.chartHeight
         p1x = int(self.leftMargin - ratiox * zoomx)
         p1y = int(self.topMargin - ratioy * zoomy)
         p2x = int(self.leftMargin + self.chartWidth + (1 - ratiox) * zoomx)
         p2y = int(self.topMargin + self.chartHeight + (1 - ratioy) * zoomy)
         self.zoomTo(p1x, p1y, p2x, p2y)
     else:
         a0.ignore()
Exemplo n.º 4
0
 def wheelEvent(self, event: QWheelEvent):
     if event.modifiers() == QtCore.Qt.ControlModifier:
         self.font_size = self.font_size + event.angleDelta().y() / 15
         if self.font_size < 5:
             self.font_size = 5
         #fnt = self.ui.CsvVisualizer.font()
         #fnt.setPointSize(self.font_size)
         #self.ui.CsvVisualizer.setFont(fnt)
     else:
         event.ignore()
Exemplo n.º 5
0
 def wheelEvent(self, a0: QtGui.QWheelEvent) -> None:
     if ((len(self.data) == 0 and len(self.reference) == 0)
             or a0.angleDelta().y() == 0):
         a0.ignore()
         return
     do_zoom_x = do_zoom_y = True
     if a0.modifiers() == QtCore.Qt.ShiftModifier:
         do_zoom_x = False
     if a0.modifiers() == QtCore.Qt.ControlModifier:
         do_zoom_y = False
     self._wheel_zomm(a0, do_zoom_x, do_zoom_y,
                      math.copysign(1,
                                    a0.angleDelta().y()))
Exemplo n.º 6
0
    def wheelEvent(self, event: QWheelEvent):
        """
        Zoom in/out on the mouse cursor
        """
        # zoom only when CTRL key pressed
        if (event.modifiers() & Qt.ControlModifier) == Qt.ControlModifier:
            steps = event.angleDelta().y() / 15 / 8

            if steps == 0:
                event.ignore()
                return

            # scale factor 1.25
            sc = pow(1.25, steps)
            self.scale(sc, sc)
            self.centerOn(self.mapToScene(event.pos()))
            event.accept()
        #  act normally on scrollbar
        else:
            # transmit event to parent class wheelevent
            super(QGraphicsView, self).wheelEvent(event)
Exemplo n.º 7
0
    def wheelEvent(self, event: QWheelEvent):
        """
        Zoom in/out on the mouse cursor
        """
        # zoom only when CTRL key pressed
        if (event.modifiers() & Qt.ControlModifier) == Qt.ControlModifier:
            steps = event.angleDelta().y() / 15 / 8

            if steps == 0:
                event.ignore()
                return

            # scale factor 1.25
            sc = pow(1.25, steps)
            self.scale(sc, sc)
            self.centerOn(self.mapToScene(event.pos()))
            event.accept()
        #  act normally on scrollbar
        else:
            # transmit event to parent class wheelevent
            super(QGraphicsView, self).wheelEvent(event)
    def wheelEvent(self, event: QWheelEvent):

        if self.thumbs_manager is None:
            event.ignore()
            return

        numPixels: QPoint = event.pixelDelta()
        numDegrees: QPoint = event.angleDelta() / 8

        if not numPixels.isNull():
            event.ignore()
        elif not numDegrees.isNull():
            num_steps: QPoint = numDegrees / 15  # .y() == Down: -1, Up: 1
            if num_steps.y() == -1:
                self.thumbs_manager.show_next()
                event.accept()
            elif num_steps.y() == 1:
                self.thumbs_manager.show_previous()
                event.accept()
            else:
                event.ignore()
Exemplo n.º 9
0
 def wheelEvent(self, event: QWheelEvent) -> None:
     if self.hasFocus():
         super(MyComboBox, self).wheelEvent(event)
     else:
         event.ignore()
Exemplo n.º 10
0
 def wheelEvent(self, event: QWheelEvent) -> None:
     if self.hasFocus():
         super(MyDoubleSpinbox, self).wheelEvent(event)
     else:
         event.ignore()
Exemplo n.º 11
0
 def wheelEvent(self, event: QWheelEvent) -> NoReturn:
     event.ignore()
Exemplo n.º 12
0
 def wheelEvent(self, event: QWheelEvent):
     event.ignore()
Exemplo n.º 13
0
 def wheelEvent(self, event: QWheelEvent):
     event.ignore()
Exemplo n.º 14
0
 def wheelEvent(self, e: QtGui.QWheelEvent) -> None:
     e.ignore()
Exemplo n.º 15
0
 def wheelEvent(self, wheel_event: QtGui.QWheelEvent) -> None:
     wheel_event.ignore()