Changeset 8873:0351daa36987 in orange


Ignore:
Timestamp:
09/01/11 11:25:24 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
f9d710c7ffe41a1f79a10de067550222bd22718b
Message:

Added (I think) basic Gesture support, please test on a Mac

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/plot/owplot.py

    r8869 r8873  
    2929 
    3030from PyQt4.QtGui import QGraphicsView,  QGraphicsScene, QPainter, QTransform, QPolygonF, QGraphicsItem, QGraphicsPolygonItem, QGraphicsRectItem, QRegion 
    31 from PyQt4.QtCore import QPointF, QPropertyAnimation, pyqtProperty, SIGNAL 
     31from PyQt4.QtCore import QPointF, QPropertyAnimation, pyqtProperty, SIGNAL, Qt, QEvent 
    3232 
    3333from OWDlgs import OWChooseImageSizeDlg 
     
    368368        self.tips = TooltipManager(self) 
    369369        self.setMouseTracking(True) 
     370        self.grabGesture(Qt.PinchGesture) 
     371        self.grabGesture(Qt.PanGesture) 
    370372         
    371373        self.state = NOTHING 
     
    11501152     
    11511153    ## Event handling 
     1154     
     1155    def event(self, event): 
     1156        if event.type() == QEvent.Gesture: 
     1157            qDebug('We have gesture!') 
     1158            return self.gestureEvent(event) 
     1159        else: 
     1160            return orangeqt.Plot.event(self, event) 
     1161             
     1162    def gestureEvent(self, event): 
     1163        qDebug('Gesture event with %d gestures' % (len(event.gestures()))) 
     1164        for gesture in event.gestures(): 
     1165            if gesture.state() == Qt.GestureStarted: 
     1166                event.accept(gesture) 
     1167                continue 
     1168            elif gesture.gestureType() == Qt.PinchGesture: 
     1169                self.zoom(gesture.centerPoint(), gesture.scaleFactor()) 
     1170            elif gesture.gestureType() == Qt.PanGesture: 
     1171                self.pan(gesture.delta()) 
     1172     
    11521173    def resizeEvent(self, event): 
    11531174        self.replot() 
Note: See TracChangeset for help on using the changeset viewer.