fixed CQ for bitmessageqt.messagecompose module

This commit is contained in:
coolguy-cell 2020-06-05 17:13:42 +05:30
parent d56191ebba
commit 035fac1fc5
No known key found for this signature in database
GPG Key ID: CD3A42E1D470AD70

View File

@ -1,23 +1,37 @@
"""
Message editor with a wheel zoom functionality
"""
# pylint: disable=bad-continuation
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
class MessageCompose(QtGui.QTextEdit):
class MessageCompose(QtGui.QTextEdit):
"""Editor class with wheel zoom functionality"""
def __init__(self, parent=0): def __init__(self, parent=0):
super(MessageCompose, self).__init__(parent) super(MessageCompose, self).__init__(parent)
self.setAcceptRichText(False) # we'll deal with this later when we have a new message format self.setAcceptRichText(False)
self.defaultFontPointSize = self.currentFont().pointSize() self.defaultFontPointSize = self.currentFont().pointSize()
def wheelEvent(self, event): def wheelEvent(self, event):
if (QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical: """Mouse wheel scroll event handler"""
if (
QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier
) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
if event.delta() > 0: if event.delta() > 0:
self.zoomIn(1) self.zoomIn(1)
else: else:
self.zoomOut(1) self.zoomOut(1)
zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize
QtGui.QApplication.activeWindow().statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Zoom level %1%").arg(str(zoom))) QtGui.QApplication.activeWindow().statusBar().showMessage(
QtGui.QApplication.translate("MainWindow", "Zoom level %1%").arg(
str(zoom)
)
)
else: else:
# in QTextEdit, super does not zoom, only scroll # in QTextEdit, super does not zoom, only scroll
super(MessageCompose, self).wheelEvent(event) super(MessageCompose, self).wheelEvent(event)
def reset(self): def reset(self):
"""Clear the edit content"""
self.setText('') self.setText('')