PyBitmessage/src/bitmessageqt/messagecompose.py
mailchuck 2597ac63f6 Zooming info percent based an single step
Zooming in message body view / compose works in single steps
irrespective of wheel sensitivity, and info about zoom level is
displayed in percent rather than font pixel size.
2016-05-02 15:00:23 +02:00

23 lines
1.0 KiB
Python

from PyQt4 import QtCore, QtGui
class MessageCompose(QtGui.QTextEdit):
def __init__(self, parent = 0):
super(MessageCompose, self).__init__(parent)
self.setAcceptRichText(False) # we'll deal with this later when we have a new message format
self.defaultFontPointSize = self.currentFont().pointSize()
def wheelEvent(self, event):
if (QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
if event.delta() > 0:
self.zoomIn(1)
else:
self.zoomOut(1)
zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize
QtGui.QApplication.activeWindow().statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Zoom level %1%").arg(str(zoom)))
# super will actually automatically take care of zooming
super(MessageCompose, self).wheelEvent(event)
def reset(self):
self.setText('')