From 68af4aec86ad33d037cc8d673c8245d3e10796ae Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Mon, 13 Nov 2023 22:09:07 +0100 Subject: [PATCH] Add back the scroll past end setting --- novelwriter/config.py | 3 +++ novelwriter/dialogs/preferences.py | 10 ++++++++++ novelwriter/gui/doceditor.py | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/novelwriter/config.py b/novelwriter/config.py index ebd0d05f..bc8af368 100644 --- a/novelwriter/config.py +++ b/novelwriter/config.py @@ -148,6 +148,7 @@ class Config: self.autoScroll = False # Typewriter-like scrolling self.autoScrollPos = 30 # Start point for typewriter-like scrolling + self.scrollPastEnd = True # Scroll past end of document, and centre cursor self.wordCountTimer = 5.0 # Interval for word count update in seconds self.incNotesWCount = True # The status bar word count includes notes @@ -577,6 +578,7 @@ class Config: self.doReplaceDots = conf.rdBool(sec, "repdots", self.doReplaceDots) self.autoScroll = conf.rdBool(sec, "autoscroll", self.autoScroll) self.autoScrollPos = conf.rdInt(sec, "autoscrollpos", self.autoScrollPos) + self.scrollPastEnd = conf.rdBool(sec, "scrollpastend", self.scrollPastEnd) self.fmtSQuoteOpen = conf.rdStr(sec, "fmtsquoteopen", self.fmtSQuoteOpen) self.fmtSQuoteClose = conf.rdStr(sec, "fmtsquoteclose", self.fmtSQuoteClose) self.fmtDQuoteOpen = conf.rdStr(sec, "fmtdquoteopen", self.fmtDQuoteOpen) @@ -701,6 +703,7 @@ class Config: "repdots": str(self.doReplaceDots), "autoscroll": str(self.autoScroll), "autoscrollpos": str(self.autoScrollPos), + "scrollpastend": str(self.scrollPastEnd), "fmtsquoteopen": str(self.fmtSQuoteOpen), "fmtsquoteclose": str(self.fmtSQuoteClose), "fmtdquoteopen": str(self.fmtDQuoteOpen), diff --git a/novelwriter/dialogs/preferences.py b/novelwriter/dialogs/preferences.py index 54cad2fc..7605aedf 100644 --- a/novelwriter/dialogs/preferences.py +++ b/novelwriter/dialogs/preferences.py @@ -726,6 +726,15 @@ class GuiPreferencesEditor(QWidget): # ================ self.mainForm.addGroupLabel(self.tr("Scroll Behaviour")) + # Scroll Past End + self.scrollPastEnd = NSwitch() + self.scrollPastEnd.setChecked(CONFIG.scrollPastEnd) + self.mainForm.addRow( + self.tr("Scroll past end of the document"), + self.scrollPastEnd, + self.tr("Also centres the cursor when scrolling.") + ) + # Typewriter Scrolling self.autoScroll = NSwitch() self.autoScroll.setChecked(CONFIG.autoScroll) @@ -766,6 +775,7 @@ class GuiPreferencesEditor(QWidget): # Scroll Behaviour CONFIG.autoScroll = self.autoScroll.isChecked() CONFIG.autoScrollPos = self.autoScrollPos.value() + CONFIG.scrollPastEnd = self.scrollPastEnd.isChecked() return diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index d6d9c683..d4743c9b 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -164,7 +164,6 @@ class GuiDocEditor(QPlainTextEdit): self.setMinimumWidth(CONFIG.pxInt(300)) self.setAutoFillBackground(True) self.setFrameStyle(QFrame.NoFrame) - self.setCenterOnScroll(True) # Custom Shortcuts self.keyContext = QShortcut(self) @@ -342,7 +341,8 @@ class GuiDocEditor(QPlainTextEdit): self._qDocument.setDefaultTextOption(options) - # Scroll bars + # Scrolling + self.setCenterOnScroll(CONFIG.scrollPastEnd) if CONFIG.hideVScroll: self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) else: