From d0bda15b0ad1e28e167a274fe3ec41b826b9aa0c Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 11 Oct 2020 23:03:37 +0200 Subject: [PATCH] Change name of scroll position variable and fix calculation of it --- nw/config.py | 8 ++++---- nw/gui/doceditor.py | 4 ++-- nw/gui/preferences.py | 16 ++++++++-------- tests/reference/novelwriter.conf | 2 +- tests/reference/novelwriter_prefs.conf | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/nw/config.py b/nw/config.py index 66b03bcc..b4c14b27 100644 --- a/nw/config.py +++ b/nw/config.py @@ -128,7 +128,7 @@ class Config: self.doReplaceDots = True self.scrollPastEnd = True self.scollWithCursor = False - self.scollFromPoint = 40 + self.scollToPoint = 40 self.wordCountTimer = 5.0 self.showTabsNSpaces = False @@ -468,8 +468,8 @@ class Config: self.scollWithCursor = self._parseLine( cnfParse, cnfSec, "scollwithcursor", self.CNF_BOOL, self.scollWithCursor ) - self.scollFromPoint = self._parseLine( - cnfParse, cnfSec, "scollfrompoint", self.CNF_INT, self.scollFromPoint + self.scollToPoint = self._parseLine( + cnfParse, cnfSec, "scolltopoint", self.CNF_INT, self.scollToPoint ) self.fmtSingleQuotes = self._parseLine( cnfParse, cnfSec, "fmtsinglequote", self.CNF_LIST, self.fmtSingleQuotes @@ -617,7 +617,7 @@ class Config: cnfParse.set(cnfSec, "repdots", str(self.doReplaceDots)) cnfParse.set(cnfSec, "scrollpastend", str(self.scrollPastEnd)) cnfParse.set(cnfSec, "scollwithcursor", str(self.scollWithCursor)) - cnfParse.set(cnfSec, "scollfrompoint", str(self.scollFromPoint)) + cnfParse.set(cnfSec, "scolltopoint", str(self.scollToPoint)) cnfParse.set(cnfSec, "fmtsinglequote", self._packList(self.fmtSingleQuotes)) cnfParse.set(cnfSec, "fmtdoublequote", self._packList(self.fmtDoubleQuotes)) cnfParse.set(cnfSec, "spelltool", str(self.spellTool)) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 8ccdac08..a7779845 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -775,9 +775,9 @@ class GuiDocEditor(QTextEdit): kMod = keyEvent.modifiers() if kMod == Qt.NoModifier or kMod == Qt.ShiftModifier: cPos = self.cursorRect().center().y() - mPos = self.mainConf.scollFromPoint*self.height()*0.01 + mPos = self.mainConf.scollToPoint * self.viewport().height() vBar = self.verticalScrollBar() - vBar.setValue(vBar.value() + cPos - round(mPos)) + vBar.setValue(vBar.value() + cPos - round(mPos * 0.01)) self.ensureCursorVisible() return diff --git a/nw/gui/preferences.py b/nw/gui/preferences.py index 1af89953..2a1cf653 100644 --- a/nw/gui/preferences.py +++ b/nw/gui/preferences.py @@ -578,14 +578,14 @@ class GuiConfigEditLayoutTab(QWidget): ) ## Font Size - self.scollFromPoint = QSpinBox(self) - self.scollFromPoint.setMinimum(10) - self.scollFromPoint.setMaximum(90) - self.scollFromPoint.setSingleStep(1) - self.scollFromPoint.setValue(self.mainConf.scollFromPoint) + self.scollToPoint = QSpinBox(self) + self.scollToPoint.setMinimum(10) + self.scollToPoint.setMaximum(90) + self.scollToPoint.setSingleStep(1) + self.scollToPoint.setValue(self.mainConf.scollToPoint) self.mainForm.addRow( "Position in the editor to keep the cursor", - self.scollFromPoint, + self.scollToPoint, "In units of percentage of the editor height.", theUnit = "%" ) @@ -609,7 +609,7 @@ class GuiConfigEditLayoutTab(QWidget): tabWidth = self.tabWidth.value() scrollPastEnd = self.scrollPastEnd.isChecked() scollWithCursor = self.scollWithCursor.isChecked() - scollFromPoint = self.scollFromPoint.value() + scollToPoint = self.scollToPoint.value() self.mainConf.textFont = textFont self.mainConf.textSize = textSize @@ -622,7 +622,7 @@ class GuiConfigEditLayoutTab(QWidget): self.mainConf.tabWidth = tabWidth self.mainConf.scrollPastEnd = scrollPastEnd self.mainConf.scollWithCursor = scollWithCursor - self.mainConf.scollFromPoint = scollFromPoint + self.mainConf.scollToPoint = scollToPoint self.mainConf.confChanged = True diff --git a/tests/reference/novelwriter.conf b/tests/reference/novelwriter.conf index aa09b213..bb141482 100644 --- a/tests/reference/novelwriter.conf +++ b/tests/reference/novelwriter.conf @@ -41,7 +41,7 @@ repdash = True repdots = True scrollpastend = True scollwithcursor = False -scollfrompoint = 40 +scolltopoint = 40 fmtsinglequote = ‘, ’ fmtdoublequote = “, ” spelltool = internal diff --git a/tests/reference/novelwriter_prefs.conf b/tests/reference/novelwriter_prefs.conf index b2cceaff..ee591782 100644 --- a/tests/reference/novelwriter_prefs.conf +++ b/tests/reference/novelwriter_prefs.conf @@ -41,7 +41,7 @@ repdash = True repdots = True scrollpastend = False scollwithcursor = True -scollfrompoint = 40 +scolltopoint = 40 fmtsinglequote = ‘, ’ fmtdoublequote = “, ” spelltool = internal