From 376b755acce56e2f17e982853077e8b94d942308 Mon Sep 17 00:00:00 2001 From: mailchuck Date: Mon, 4 Jan 2016 11:13:31 +0100 Subject: [PATCH] Allow zooming of message body Uses default system zoom settings (Ctrl-Wheel). Fixes #163 --- src/bitmessageqt/messageview.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/bitmessageqt/messageview.py b/src/bitmessageqt/messageview.py index 1d7758e4..9aa7ae54 100644 --- a/src/bitmessageqt/messageview.py +++ b/src/bitmessageqt/messageview.py @@ -21,6 +21,7 @@ class MessageView(QtGui.QTextBrowser): self.outpos = 0 self.document().setUndoRedoEnabled(False) self.rendering = False + self.defaultFontPointSize = self.currentFont().pointSize() self.verticalScrollBar().valueChanged.connect(self.lazyRender) def mousePressEvent(self, event): @@ -32,7 +33,16 @@ class MessageView(QtGui.QTextBrowser): self.showPlain() else: super(MessageView, self).mousePressEvent(event) - + + def wheelEvent(self, event): + if (QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical: + numDegrees = event.delta() / 8 + numSteps = numDegrees / 15 + zoomDiff = numSteps + self.currentFont().pointSize() - self.defaultFontPointSize + QtGui.QApplication.activeWindow().statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Zoom level %1").arg(str(zoomDiff))) + # super will actually automatically take care of zooming + super(MessageView, self).wheelEvent(event) + def confirmURL(self, link): reply = QtGui.QMessageBox.warning(self, QtGui.QApplication.translate(type(self).__name__, MessageView.CONFIRM_TITLE),