Graphics/PixmapDiagram.py

changeset 1518
e6e21910210d
parent 1509
c0b5e693b0eb
child 1588
dccffd13be8d
equal deleted inserted replaced
1516:7c0b621e537d 1518:e6e21910210d
5 5
6 """ 6 """
7 Module implementing a dialog showing a pixmap. 7 Module implementing a dialog showing a pixmap.
8 """ 8 """
9 9
10 from PyQt4.QtCore import Qt, QSize 10 from PyQt4.QtCore import Qt, QSize, QEvent
11 from PyQt4.QtGui import QMainWindow, QLabel, QPalette, QSizePolicy, QScrollArea, \ 11 from PyQt4.QtGui import QMainWindow, QLabel, QPalette, QSizePolicy, QScrollArea, \
12 QAction, QMenu, QToolBar, QImage, QPixmap, QDialog, QPrinter, QPrintDialog, \ 12 QAction, QMenu, QToolBar, QImage, QPixmap, QDialog, QPrinter, QPrintDialog, \
13 QPainter, QFont, QColor 13 QPainter, QFont, QColor
14 14
15 from E5Gui import E5MessageBox 15 from E5Gui import E5MessageBox
62 62
63 self.__initActions() 63 self.__initActions()
64 self.__initContextMenu() 64 self.__initContextMenu()
65 self.__initToolBars() 65 self.__initToolBars()
66 66
67 self.grabGesture(Qt.PinchGesture)
68
67 def __initActions(self): 69 def __initActions(self):
68 """ 70 """
69 Private method to initialize the view actions. 71 Private method to initialize the view actions.
70 """ 72 """
71 self.closeAct = \ 73 self.closeAct = \
198 self.__zoomIn() 200 self.__zoomIn()
199 evt.accept() 201 evt.accept()
200 return 202 return
201 203
202 super().wheelEvent(evt) 204 super().wheelEvent(evt)
205
206 def event(self, evt):
207 """
208 Protected method handling events.
209
210 @param evt reference to the event (QEvent)
211 @return flag indicating, if the event was handled (boolean)
212 """
213 if evt.type() == QEvent.Gesture:
214 self.gestureEvent(evt)
215 return True
216
217 return super().event(evt)
218
219 def gestureEvent(self, evt):
220 """
221 Protected method handling gesture events.
222
223 @param evt reference to the gesture event (QGestureEvent
224 """
225 pinch = evt.gesture(Qt.PinchGesture)
226 if pinch:
227 if pinch.state() == Qt.GestureStarted:
228 pinch.setScaleFactor(self.zoom)
229 else:
230 self.__doZoom(pinch.scaleFactor() / self.zoom)
231 evt.accept()
203 232
204 ############################################################################ 233 ############################################################################
205 ## Private menu handling methods below. 234 ## Private menu handling methods below.
206 ############################################################################ 235 ############################################################################
207 236

eric ide

mercurial