Line wrap performance workaround

- some messages (e.g. some long messages on Windows, or binary data)
  cause an excessive amount of time in rendering the body. This
  change is base on a workaround I found at
  http://www.qtcentre.org/threads/8188-bug-setLineWrapMode
This commit is contained in:
Peter Šurda 2016-10-20 20:26:53 +02:00
parent 96212693b2
commit 448ceaa74c
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -24,6 +24,11 @@ class MessageView(QtGui.QTextBrowser):
self.rendering = False self.rendering = False
self.defaultFontPointSize = self.currentFont().pointSize() self.defaultFontPointSize = self.currentFont().pointSize()
self.verticalScrollBar().valueChanged.connect(self.lazyRender) self.verticalScrollBar().valueChanged.connect(self.lazyRender)
self.setWrappingWidth()
def resizeEvent(self, event):
super(MessageView, self).resizeEvent(event)
self.setWrappingWidth(event.size().width())
def mousePressEvent(self, event): def mousePressEvent(self, event):
#text = textCursor.block().text() #text = textCursor.block().text()
@ -42,6 +47,12 @@ class MessageView(QtGui.QTextBrowser):
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)))
def setWrappingWidth(self, width=None):
self.setLineWrapMode(QtGui.QTextEdit.FixedPixelWidth)
if width is None:
width = self.width()
self.setLineWrapColumnOrWidth(width)
def confirmURL(self, link): def confirmURL(self, link):
if link.scheme() == "mailto": if link.scheme() == "mailto":
QtGui.QApplication.activeWindow().ui.lineEditTo.setText(link.path()) QtGui.QApplication.activeWindow().ui.lineEditTo.setText(link.path())