From 3fbe5e218c63c07763267668c13765a6195a2175 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Tue, 13 Oct 2020 22:14:17 +0200 Subject: [PATCH] Make sure the scroll bar anim cannot go past 650 ms, and add a percentage of total to the line counter --- nw/gui/doceditor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 34ae52f2..16c2c08c 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -782,7 +782,7 @@ class GuiDocEditor(QTextEdit): # Compute the needed scroll and duration pOld = vBar.value() pNew = pOld + cPos - round(mPos*0.01) - aDur = 150 + round(abs(pNew - pOld)/hWid*500) + aDur = 150 + round(min(abs(pNew - pOld)/hWid, 1.0)*500) if pNew >= 0: doAnim = QPropertyAnimation(vBar, b"value", self) @@ -2346,11 +2346,13 @@ class GuiDocEditFooter(QWidget): """ if self.theItem is None: iLine = 0 + iDist = 0 else: theCursor = self.docEditor.textCursor() iLine = theCursor.blockNumber() + 1 + iDist = 100*iLine/self.docEditor.qDocument.blockCount() - self.linesText.setText(f"Line: {iLine:n}") + self.linesText.setText(f"Line: {iLine:n} ({iDist:.0f}\u202f%)") return