--- a/QScintilla/Shell.py Fri Dec 30 15:20:34 2011 +0100 +++ b/QScintilla/Shell.py Fri Dec 30 18:33:18 2011 +0100 @@ -10,7 +10,7 @@ import sys import re -from PyQt4.QtCore import QFileInfo, Qt +from PyQt4.QtCore import QFileInfo, Qt, QEvent from PyQt4.QtGui import QDialog, QInputDialog, QApplication, QClipboard, QMenu, \ QPalette, QFont from PyQt4.Qsci import QsciScintilla @@ -215,6 +215,8 @@ QsciScintilla.SCI_LINEENDEXTEND: self.extendSelectionToEOL, } + self.grabGesture(Qt.PinchGesture) + def closeShell(self): """ Public method to shutdown the shell. @@ -740,6 +742,41 @@ super().wheelEvent(evt) + def event(self, evt): + """ + Protected method handling events. + + @param evt reference to the event (QEvent) + @return flag indicating, if the event was handled (boolean) + """ + if evt.type() == QEvent.Gesture: + self.gestureEvent(evt) + return True + + return super().event(evt) + + def gestureEvent(self, evt): + """ + Protected method handling gesture events. + + @param evt reference to the gesture event (QGestureEvent + """ + pinch = evt.gesture(Qt.PinchGesture) + if pinch: + if pinch.state() == Qt.GestureStarted: + zoom = (self.getZoom() + 10) / 10.0 + pinch.setScaleFactor(zoom) + else: + zoom = int(pinch.scaleFactor() * 10) - 10 + if zoom <= -9: + zoom = -9 + pinch.setScaleFactor(0.1) + elif zoom >= 20: + zoom = 20 + pinch.setScaleFactor(3.0) + self.zoomTo(zoom) + evt.accept() + def editorCommand(self, cmd): """ Public method to perform an editor command.