From ef70e63814d52ed566738cbb33b3325e889d21ee Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Tue, 9 Jun 2020 21:01:08 +0200 Subject: [PATCH] Moved doc details to a splitter and added a footer bar to the viewer --- nw/config.py | 13 +++++++++++++ nw/gui/docbars.py | 46 +++++++++++++++++++++++++++++++++++++++++++++ nw/gui/docviewer.py | 19 ++++++++++--------- nw/guimain.py | 20 ++++++++++++++------ 4 files changed, 83 insertions(+), 15 deletions(-) diff --git a/nw/config.py b/nw/config.py index ca9cab7b..5c734981 100644 --- a/nw/config.py +++ b/nw/config.py @@ -96,6 +96,7 @@ class Config: self.projColWidth = [140, 55, 140] self.mainPanePos = [300, 800] self.docPanePos = [400, 400] + self.viewPanePos = [500, 150] self.outlnPanePos = [500, 150] self.isFullScreen = False @@ -363,6 +364,9 @@ class Config: self.docPanePos = self._parseLine( cnfParse, cnfSec, "docpane", self.CNF_LIST, self.docPanePos ) + self.viewPanePos = self._parseLine( + cnfParse, cnfSec, "viewpane", self.CNF_LIST, self.viewPanePos + ) self.outlnPanePos = self._parseLine( cnfParse, cnfSec, "outlinepane", self.CNF_LIST, self.outlnPanePos ) @@ -513,6 +517,7 @@ class Config: cnfParse.set(cnfSec,"projcols", self._packList(self.projColWidth)) cnfParse.set(cnfSec,"mainpane", self._packList(self.mainPanePos)) cnfParse.set(cnfSec,"docpane", self._packList(self.docPanePos)) + cnfParse.set(cnfSec,"viewpane", self._packList(self.viewPanePos)) cnfParse.set(cnfSec,"outlinepane", self._packList(self.outlnPanePos)) cnfParse.set(cnfSec,"fullscreen", str(self.isFullScreen)) @@ -730,6 +735,11 @@ class Config: self.confChanged = True return True + def setViewPanePos(self, panePos): + self.viewPanePos = [int(x/self.guiScale) for x in panePos] + self.confChanged = True + return True + def setOutlinePanePos(self, panePos): self.outlnPanePos = [int(x/self.guiScale) for x in panePos] self.confChanged = True @@ -770,6 +780,9 @@ class Config: def getDocPanePos(self): return [int(x*self.guiScale) for x in self.docPanePos] + def getViewPanePos(self): + return [int(x*self.guiScale) for x in self.viewPanePos] + def getOutlinePanePos(self): return [int(x*self.guiScale) for x in self.outlnPanePos] diff --git a/nw/gui/docbars.py b/nw/gui/docbars.py index 6720933d..4c521860 100644 --- a/nw/gui/docbars.py +++ b/nw/gui/docbars.py @@ -343,3 +343,49 @@ class GuiDocTitleBar(QWidget): return # END Class GuiDocTitleBar + +class GuiDocViewFooter(QWidget): + + def __init__(self, theParent, theProject): + QWidget.__init__(self, theParent) + + logger.debug("Initialising GuiDocViewFooter ...") + + self.mainConf = nw.CONFIG + self.theParent = theParent + self.theProject = theProject + self.theTheme = theParent.theTheme + self.theHandle = None + + # Make a QPalette that matches the Syntax Theme + self.thePalette = QPalette() + self.thePalette.setColor(QPalette.Window, QColor(*self.theTheme.colBack)) + self.thePalette.setColor(QPalette.Text, QColor(*self.theTheme.colText)) + + fPx = int(0.9*self.theTheme.fontPixelSize) + hSp = self.mainConf.pxInt(6) + + # Main Widget Settings + self.setContentsMargins(0, 0, 0, 0) + self.setAutoFillBackground(True) + self.setPalette(self.thePalette) + + # Title Label + self.theTitle = QLabel() + self.theTitle.setText("References") + + lblFont = self.theTitle.font() + lblFont.setPointSizeF(0.9*self.theTheme.fontPointSize) + self.theTitle.setFont(lblFont) + + # Assemble Layout + self.outerBox = QHBoxLayout() + self.outerBox.setSpacing(hSp) + self.outerBox.addWidget(self.theTitle, 1) + self.setLayout(self.outerBox) + + logger.debug("GuiDocViewFooter initialisation complete") + + return + +# END Class GuiDocViewFooter diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index c43c6cc0..e4c37bf9 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -34,7 +34,7 @@ from PyQt5.QtGui import QTextOption, QFont, QPalette, QColor, QTextCursor from nw.core import ToHtml from nw.constants import nwAlert, nwItemType, nwDocAction -from nw.gui.docbars import GuiDocTitleBar +from nw.gui.docbars import GuiDocTitleBar, GuiDocViewFooter logger = logging.getLogger(__name__) @@ -57,10 +57,9 @@ class GuiDocViewer(QTextBrowser): self.setOpenExternalLinks(False) self.initViewer() - # Document Title + # Document Title and Footer self.docTitle = GuiDocTitleBar(self, self.theProject, isEditor=False) - self.docTitle.setGeometry(0, 0, self.docTitle.width(), self.docTitle.height()) - self.setViewportMargins(0, self.docTitle.height(), 0, 0) + self.docFooter = GuiDocViewFooter(self, self.theProject) theOpt = QTextOption() if self.mainConf.doJustify: @@ -233,15 +232,17 @@ class GuiDocViewer(QTextBrowser): tB = self.lineWidth() tW = self.width() - 2*tB - sW tH = self.docTitle.height() + fH = self.docFooter.height() + fY = self.height() - fH - tB tT = self.mainConf.getTextMargin() - tH + bT = self.mainConf.getTextMargin() - fH self.docTitle.setGeometry(tB, tB, tW, tH) - self.setViewportMargins(0, tH, 0, 0) + self.docFooter.setGeometry(tB, fY, tW, fH) + self.setViewportMargins(0, tH, 0, fH) docFormat = self.qDocument.rootFrame().frameFormat() - if tT > 0: - docFormat.setTopMargin(tT) - else: - docFormat.setTopMargin(0) + docFormat.setTopMargin(max(0, tT)) + docFormat.setBottomMargin(max(0, bT)) self.qDocument.blockSignals(True) self.qDocument.rootFrame().setFrameFormat(docFormat) diff --git a/nw/guimain.py b/nw/guimain.py index 6f8ed4a7..773e0592 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -125,14 +125,19 @@ class GuiMain(QMainWindow): self.docView.setContentsMargins(0, 0, 0, 0) self.docView.setSpacing(self.mainConf.pxInt(2)) self.docView.addWidget(self.docViewer) - self.docView.addWidget(self.viewMeta) + # self.docView.addWidget(self.viewMeta) self.docView.setStretch(0, 1) self.viewPane.setLayout(self.docView) + self.splitView = QSplitter(Qt.Vertical) + self.splitView.addWidget(self.viewPane) + self.splitView.addWidget(self.viewMeta) + self.splitView.setSizes(self.mainConf.getViewPanePos()) + self.splitDocs = QSplitter(Qt.Horizontal) self.splitDocs.setOpaqueResize(False) self.splitDocs.addWidget(self.editPane) - self.splitDocs.addWidget(self.viewPane) + self.splitDocs.addWidget(self.splitView) self.splitOutline = QSplitter(Qt.Vertical) self.splitOutline.addWidget(self.projView) @@ -841,6 +846,12 @@ class GuiMain(QMainWindow): if msgRes != QMessageBox.Yes: return False + if not self.isZenMode: + self.mainConf.setMainPanePos(self.splitMain.sizes()) + self.mainConf.setDocPanePos(self.splitDocs.sizes()) + self.mainConf.setViewPanePos(self.splitView.sizes()) + self.mainConf.setOutlinePanePos(self.splitOutline.sizes()) + logger.info("Exiting %s" % nw.__package__) if self.hasProject: self.closeProject(True) @@ -848,10 +859,7 @@ class GuiMain(QMainWindow): self.mainConf.setTreeColWidths(self.treeView.getColumnSizes()) if not self.mainConf.isFullScreen: self.mainConf.setWinSize(self.width(), self.height()) - if not self.isZenMode: - self.mainConf.setMainPanePos(self.splitMain.sizes()) - self.mainConf.setDocPanePos(self.splitDocs.sizes()) - self.mainConf.setOutlinePanePos(self.splitOutline.sizes()) + self.mainConf.saveConfig() self.reportConfErr()