From fe71353198f156ba5a16de6a7cc6a598105fb06c Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 11 Oct 2020 16:40:54 +0200 Subject: [PATCH] Add option to hide scrollbars on all major GUI areas --- nw/config.py | 4 ++++ nw/gui/build.py | 12 ++++++++++-- nw/gui/doceditor.py | 6 ++++++ nw/gui/docviewer.py | 6 ++++++ nw/gui/outline.py | 12 ++++++++++++ nw/gui/outlinedetails.py | 13 +++++++++++++ nw/gui/projtree.py | 14 ++++++++++++++ nw/guimain.py | 3 +++ 8 files changed, 68 insertions(+), 2 deletions(-) diff --git a/nw/config.py b/nw/config.py index 721901ab..24089d93 100644 --- a/nw/config.py +++ b/nw/config.py @@ -102,6 +102,10 @@ class Config: self.outlnPanePos = [500, 150] self.isFullScreen = False + ## Features + self.hideVScroll = False # Hide vertical scroll bars on main widgets + self.hideHScroll = False # Hide horizontal scroll bars on main widgets + ## Project self.autoSaveProj = 60 self.autoSaveDoc = 30 diff --git a/nw/gui/build.py b/nw/gui/build.py index ad9af97b..dc9d13ad 100644 --- a/nw/gui/build.py +++ b/nw/gui/build.py @@ -450,10 +450,12 @@ class GuiBuildNovel(QDialog): # Tool Box Scroll Area self.toolsArea = QScrollArea() self.toolsArea.setMinimumWidth(self.mainConf.pxInt(250)) - self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) - self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.toolsArea.setWidgetResizable(True) self.toolsArea.setWidget(self.toolsWidget) + if self.mainConf.hideVScroll: + self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + if self.mainConf.hideHScroll: + self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # Tools and Buttons Layout self.innerBox = QVBoxLayout() @@ -1116,6 +1118,12 @@ class GuiBuildNovelDocView(QTextBrowser): else: self.setTabStopWidth(self.mainConf.getTabWidth()) + # Scroll bars + if self.mainConf.hideVScroll: + self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + if self.mainConf.hideHScroll: + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + docPalette = self.palette() docPalette.setColor(QPalette.Base, QColor(255, 255, 255)) docPalette.setColor(QPalette.Text, QColor(0, 0, 0)) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 10f9de3f..85cda2a6 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -224,6 +224,12 @@ class GuiDocEditor(QTextEdit): self.qDocument.setDefaultTextOption(theOpt) + # Scroll bars + if self.mainConf.hideVScroll: + self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + if self.mainConf.hideHScroll: + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + # Refresh the tab stops if self.mainConf.verQtValue >= 51000: self.setTabStopDistance(self.mainConf.getTabWidth()) diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index b7404e9c..cfd289a4 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -124,6 +124,12 @@ class GuiDocViewer(QTextBrowser): theOpt.setAlignment(Qt.AlignJustify) self.qDocument.setDefaultTextOption(theOpt) + # Scroll bars + if self.mainConf.hideVScroll: + self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + if self.mainConf.hideHScroll: + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + # Refresh the tab stops if self.mainConf.verQtValue >= 51000: self.setTabStopDistance(self.mainConf.getTabWidth()) diff --git a/nw/gui/outline.py b/nw/gui/outline.py index 6d524992..3470013f 100644 --- a/nw/gui/outline.py +++ b/nw/gui/outline.py @@ -118,6 +118,7 @@ class GuiOutline(QTreeWidget): self.colIndex = {} self.treeNCols = 0 + self.initOutline() self.clearOutline() self.headerMenu.setHiddenState(self.colHidden) @@ -125,6 +126,17 @@ class GuiOutline(QTreeWidget): return + def initOutline(self): + """Set or update outline settings. + """ + # Scroll bars + if self.mainConf.hideVScroll: + self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + if self.mainConf.hideHScroll: + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + + return + def clearOutline(self): """Clear the tree and header and set the default values for the columns arrays. diff --git a/nw/gui/outlinedetails.py b/nw/gui/outlinedetails.py index c6372826..9f116b18 100644 --- a/nw/gui/outlinedetails.py +++ b/nw/gui/outlinedetails.py @@ -224,10 +224,23 @@ class GuiOutlineDetails(QScrollArea): self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setWidgetResizable(True) + self.initDetails() + logger.debug("GuiOutlineDetails initialisation complete") return + def initDetails(self): + """Set or update outline settings. + """ + # Scroll bars + if self.mainConf.hideVScroll: + self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + if self.mainConf.hideHScroll: + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + + return + def showItem(self, tHandle, sTitle): """Update the content of the tree with the given handle and line number pointing to a header. diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py index 858948dc..3c03b236 100644 --- a/nw/gui/projtree.py +++ b/nw/gui/projtree.py @@ -115,6 +115,9 @@ class GuiProjectTree(QTreeWidget): # The last column should just auto-scale self.resizeColumnToContents(self.C_FLAGS) + # Set custom settings + self.initTree() + logger.debug("GuiProjectTree initialisation complete") # Internal Mapping @@ -122,6 +125,17 @@ class GuiProjectTree(QTreeWidget): return + def initTree(self): + """Set or update tree widget settings. + """ + # Scroll bars + if self.mainConf.hideVScroll: + self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + if self.mainConf.hideHScroll: + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + + return + ## # Class Methods ## diff --git a/nw/guimain.py b/nw/guimain.py index 93c62210..18801727 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -790,6 +790,9 @@ class GuiMain(QMainWindow): self.saveDocument() self.docEditor.initEditor() self.docViewer.initViewer() + self.treeView.initTree() + self.projView.initOutline() + self.projMeta.initDetails() return