Finish porting of QWheelEvent

This commit is contained in:
Kovid Goyal 2014-05-10 13:21:57 +05:30
parent 615d1104d2
commit 5c2bcdf8fc
4 changed files with 11 additions and 16 deletions

View File

@ -11,9 +11,6 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
# https://github.com/ariya/phantomjs/pull/173 for info on how to enable fonts # https://github.com/ariya/phantomjs/pull/173 for info on how to enable fonts
# with fontconfig (probably needed for PDF output and SVG rendering) # with fontconfig (probably needed for PDF output and SVG rendering)
# QT5XX: Port def wheelEvent() (orientation() and delta() to be replaced by
# angleDelta())
# QT5XX: Add a import checker that looks for all from PyQt5.* imports and runs # QT5XX: Add a import checker that looks for all from PyQt5.* imports and runs
# them to check that they work. This can probably be made part of python # them to check that they work. This can probably be made part of python
# setup.py check. # setup.py check.

View File

@ -154,11 +154,10 @@ if pictureflow is not None:
return self.minimumSize() return self.minimumSize()
def wheelEvent(self, ev): def wheelEvent(self, ev):
d = ev.angleDelta().y()
if abs(d) > 0:
ev.accept() ev.accept()
if ev.delta() < 0: (self.showNext if d < 0 else self.showPrevious)()
self.showNext()
elif ev.delta() > 0:
self.showPrevious()
def dataChanged(self): def dataChanged(self):
self.dc_signal.emit() self.dc_signal.emit()

View File

@ -235,9 +235,10 @@ class Main(MainWindow, Ui_MainWindow):
self.document.back() self.document.back()
def wheelEvent(self, ev): def wheelEvent(self, ev):
if ev.delta() >= 0: d = ev.angleDelta().y()
if d > 0:
self.document.previous() self.document.previous()
else: elif d < 0:
self.document.next() self.document.next()
def closeEvent(self, event): def closeEvent(self, event):

View File

@ -18,7 +18,7 @@ class ImageView(QDialog):
def __init__(self, parent, current_img, current_url, geom_name='viewer_image_popup_geometry'): def __init__(self, parent, current_img, current_url, geom_name='viewer_image_popup_geometry'):
QDialog.__init__(self) QDialog.__init__(self)
dw = QApplication.instance().desktop() dw = QApplication.instance().desktop()
self.avail_geom = dw.availableGeometry(parent) self.avail_geom = dw.availableGeometry(parent if parent is not None else self)
self.current_img = current_img self.current_img = current_img
self.current_url = current_url self.current_url = current_url
self.factor = 1.0 self.factor = 1.0
@ -113,12 +113,10 @@ class ImageView(QDialog):
return QDialog.done(self, e) return QDialog.done(self, e)
def wheelEvent(self, event): def wheelEvent(self, event):
if event.delta() < -14: d = event.angleDelta().y()
self.zoom_out() if abs(d) > 0 and not self.scrollarea.verticalScrollBar().isVisible():
event.accept() event.accept()
elif event.delta() > 14: (self.zoom_out if d < 0 else self.zoom_in)()
event.accept()
self.zoom_in()
class ImagePopup(object): class ImagePopup(object):