2016-01-22 19:16:47 +01:00
|
|
|
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:
|
2016-01-23 09:55:12 +01:00
|
|
|
if event.delta() > 0:
|
|
|
|
self.zoomIn(1)
|
2016-01-22 19:16:47 +01:00
|
|
|
else:
|
2016-01-23 09:55:12 +01:00
|
|
|
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)))
|
2016-01-23 12:21:58 +01:00
|
|
|
else:
|
|
|
|
# in QTextEdit, super does not zoom, only scroll
|
|
|
|
super(MessageCompose, self).wheelEvent(event)
|
2016-01-22 19:16:47 +01:00
|
|
|
|
|
|
|
def reset(self):
|
|
|
|
self.setText('')
|