From 448ceaa74ca6929f626fa36962c4f3c0ca0f0659 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Thu, 20 Oct 2016 20:26:53 +0200 Subject: [PATCH] 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 --- src/bitmessageqt/messageview.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/bitmessageqt/messageview.py b/src/bitmessageqt/messageview.py index c322e421..5a964cd4 100644 --- a/src/bitmessageqt/messageview.py +++ b/src/bitmessageqt/messageview.py @@ -24,6 +24,11 @@ class MessageView(QtGui.QTextBrowser): self.rendering = False self.defaultFontPointSize = self.currentFont().pointSize() 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): #text = textCursor.block().text() @@ -42,6 +47,12 @@ class MessageView(QtGui.QTextBrowser): zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize 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): if link.scheme() == "mailto": QtGui.QApplication.activeWindow().ui.lineEditTo.setText(link.path())