diff --git a/nw/gui/build.py b/nw/gui/build.py index dc9d13ad..754553d8 100644 --- a/nw/gui/build.py +++ b/nw/gui/build.py @@ -452,10 +452,16 @@ class GuiBuildNovel(QDialog): self.toolsArea.setMinimumWidth(self.mainConf.pxInt(250)) self.toolsArea.setWidgetResizable(True) self.toolsArea.setWidget(self.toolsWidget) + if self.mainConf.hideVScroll: self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) + if self.mainConf.hideHScroll: self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) # Tools and Buttons Layout self.innerBox = QVBoxLayout() @@ -1121,8 +1127,13 @@ class GuiBuildNovelDocView(QTextBrowser): # Scroll bars if self.mainConf.hideVScroll: self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) + if self.mainConf.hideHScroll: self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) docPalette = self.palette() docPalette.setColor(QPalette.Base, QColor(255, 255, 255)) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index fe9581e9..e459b1b1 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -47,7 +47,7 @@ from PyQt5.QtGui import ( from PyQt5.QtWidgets import ( qApp, QTextEdit, QAction, QMenu, QShortcut, QMessageBox, QWidget, QLabel, QToolBar, QToolButton, QHBoxLayout, QGridLayout, QLineEdit, QPushButton, - QFrame, QAbstractSlider + QFrame ) from nw.core import NWDoc, NWSpellCheck, NWSpellSimple, countWords @@ -231,8 +231,13 @@ class GuiDocEditor(QTextEdit): # Scroll bars if self.mainConf.hideVScroll: self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) + if self.mainConf.hideHScroll: self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) # Refresh the tab stops if self.mainConf.verQtValue >= 51000: @@ -479,11 +484,14 @@ class GuiDocEditor(QTextEdit): """ if not isinstance(thePosition, int): return False + if thePosition >= 0: theCursor = self.textCursor() theCursor.setPosition(thePosition) self.setTextCursor(theCursor) self.docFooter.updateLineCount() + self.cursorLast = self.cursorRect().center().y() + return True def getCursorPosition(self): diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index cfd289a4..2d9ac637 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -127,8 +127,13 @@ class GuiDocViewer(QTextBrowser): # Scroll bars if self.mainConf.hideVScroll: self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) + if self.mainConf.hideHScroll: self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) # Refresh the tab stops if self.mainConf.verQtValue >= 51000: diff --git a/nw/gui/outline.py b/nw/gui/outline.py index 3470013f..d3dc4815 100644 --- a/nw/gui/outline.py +++ b/nw/gui/outline.py @@ -132,8 +132,13 @@ class GuiOutline(QTreeWidget): # Scroll bars if self.mainConf.hideVScroll: self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) + if self.mainConf.hideHScroll: self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) return diff --git a/nw/gui/outlinedetails.py b/nw/gui/outlinedetails.py index 9f116b18..49998dd9 100644 --- a/nw/gui/outlinedetails.py +++ b/nw/gui/outlinedetails.py @@ -236,8 +236,13 @@ class GuiOutlineDetails(QScrollArea): # Scroll bars if self.mainConf.hideVScroll: self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) + if self.mainConf.hideHScroll: self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) return diff --git a/nw/gui/preferences.py b/nw/gui/preferences.py index 5cba9fda..f1848bb3 100644 --- a/nw/gui/preferences.py +++ b/nw/gui/preferences.py @@ -225,7 +225,24 @@ class GuiConfigEditGeneralTab(QWidget): self.showFullPath.setChecked(self.mainConf.showFullPath) self.mainForm.addRow( "Show full path in document header", - self.showFullPath + self.showFullPath, + "Shows the document title and parent folder names." + ) + + self.hideVScroll = QSwitch() + self.hideVScroll.setChecked(self.mainConf.hideVScroll) + self.mainForm.addRow( + "Hide vertical scroll bars in main windows", + self.hideVScroll, + "Scrolling with mouse wheel and keys only." + ) + + self.hideHScroll = QSwitch() + self.hideHScroll.setChecked(self.mainConf.hideHScroll) + self.mainForm.addRow( + "Hide horizontal scroll bars in main windows", + self.hideHScroll, + "Scrolling with mouse wheel and keys only." ) return @@ -242,6 +259,8 @@ class GuiConfigEditGeneralTab(QWidget): guiFont = self.guiFont.text() guiFontSize = self.guiFontSize.value() showFullPath = self.showFullPath.isChecked() + hideVScroll = self.hideVScroll.isChecked() + hideHScroll = self.hideHScroll.isChecked() # Check if restart is needed needsRestart |= self.mainConf.guiTheme != guiTheme @@ -255,6 +274,8 @@ class GuiConfigEditGeneralTab(QWidget): self.mainConf.guiFont = guiFont self.mainConf.guiFontSize = guiFontSize self.mainConf.showFullPath = showFullPath + self.mainConf.hideVScroll = hideVScroll + self.mainConf.hideHScroll = hideHScroll self.mainConf.confChanged = True @@ -534,6 +555,24 @@ class GuiConfigEditLayoutTab(QWidget): theUnit="px" ) + ## Scroll Past End + self.scrollPastEnd = QSwitch() + self.scrollPastEnd.setChecked(self.mainConf.scrollPastEnd) + self.mainForm.addRow( + "Scroll past end of the document", + self.scrollPastEnd, + "Allows scrolling until last line is at the top." + ) + + ## Typewriter Scrolling + self.scollWithCursor = QSwitch() + self.scollWithCursor.setChecked(self.mainConf.scollWithCursor) + self.mainForm.addRow( + "Typewriter style scrolling", + self.scollWithCursor, + "Scrolls up when the cursor moves to a new line." + ) + return def saveValues(self): @@ -551,6 +590,8 @@ class GuiConfigEditLayoutTab(QWidget): doJustify = self.textJustify.isChecked() textMargin = self.textMargin.value() tabWidth = self.tabWidth.value() + scrollPastEnd = self.scrollPastEnd.isChecked() + scollWithCursor = self.scollWithCursor.isChecked() self.mainConf.textFont = textFont self.mainConf.textSize = textSize @@ -561,6 +602,8 @@ class GuiConfigEditLayoutTab(QWidget): self.mainConf.doJustify = doJustify self.mainConf.textMargin = textMargin self.mainConf.tabWidth = tabWidth + self.mainConf.scrollPastEnd = scrollPastEnd + self.mainConf.scollWithCursor = scollWithCursor self.mainConf.confChanged = True diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py index 3c03b236..03dc2ff8 100644 --- a/nw/gui/projtree.py +++ b/nw/gui/projtree.py @@ -131,8 +131,13 @@ class GuiProjectTree(QTreeWidget): # Scroll bars if self.mainConf.hideVScroll: self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) + if self.mainConf.hideHScroll: self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + else: + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) return