Moved doc details to a splitter and added a footer bar to the viewer

This commit is contained in:
Veronica K. B. Olsen
2020-06-09 21:01:08 +02:00
parent f096bbef26
commit ef70e63814
4 changed files with 83 additions and 15 deletions
+13
View File
@@ -96,6 +96,7 @@ class Config:
self.projColWidth = [140, 55, 140] self.projColWidth = [140, 55, 140]
self.mainPanePos = [300, 800] self.mainPanePos = [300, 800]
self.docPanePos = [400, 400] self.docPanePos = [400, 400]
self.viewPanePos = [500, 150]
self.outlnPanePos = [500, 150] self.outlnPanePos = [500, 150]
self.isFullScreen = False self.isFullScreen = False
@@ -363,6 +364,9 @@ class Config:
self.docPanePos = self._parseLine( self.docPanePos = self._parseLine(
cnfParse, cnfSec, "docpane", self.CNF_LIST, self.docPanePos cnfParse, cnfSec, "docpane", self.CNF_LIST, self.docPanePos
) )
self.viewPanePos = self._parseLine(
cnfParse, cnfSec, "viewpane", self.CNF_LIST, self.viewPanePos
)
self.outlnPanePos = self._parseLine( self.outlnPanePos = self._parseLine(
cnfParse, cnfSec, "outlinepane", self.CNF_LIST, self.outlnPanePos 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,"projcols", self._packList(self.projColWidth))
cnfParse.set(cnfSec,"mainpane", self._packList(self.mainPanePos)) cnfParse.set(cnfSec,"mainpane", self._packList(self.mainPanePos))
cnfParse.set(cnfSec,"docpane", self._packList(self.docPanePos)) 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,"outlinepane", self._packList(self.outlnPanePos))
cnfParse.set(cnfSec,"fullscreen", str(self.isFullScreen)) cnfParse.set(cnfSec,"fullscreen", str(self.isFullScreen))
@@ -730,6 +735,11 @@ class Config:
self.confChanged = True self.confChanged = True
return 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): def setOutlinePanePos(self, panePos):
self.outlnPanePos = [int(x/self.guiScale) for x in panePos] self.outlnPanePos = [int(x/self.guiScale) for x in panePos]
self.confChanged = True self.confChanged = True
@@ -770,6 +780,9 @@ class Config:
def getDocPanePos(self): def getDocPanePos(self):
return [int(x*self.guiScale) for x in self.docPanePos] 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): def getOutlinePanePos(self):
return [int(x*self.guiScale) for x in self.outlnPanePos] return [int(x*self.guiScale) for x in self.outlnPanePos]
+46
View File
@@ -343,3 +343,49 @@ class GuiDocTitleBar(QWidget):
return return
# END Class GuiDocTitleBar # 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
+10 -9
View File
@@ -34,7 +34,7 @@ from PyQt5.QtGui import QTextOption, QFont, QPalette, QColor, QTextCursor
from nw.core import ToHtml from nw.core import ToHtml
from nw.constants import nwAlert, nwItemType, nwDocAction from nw.constants import nwAlert, nwItemType, nwDocAction
from nw.gui.docbars import GuiDocTitleBar from nw.gui.docbars import GuiDocTitleBar, GuiDocViewFooter
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -57,10 +57,9 @@ class GuiDocViewer(QTextBrowser):
self.setOpenExternalLinks(False) self.setOpenExternalLinks(False)
self.initViewer() self.initViewer()
# Document Title # Document Title and Footer
self.docTitle = GuiDocTitleBar(self, self.theProject, isEditor=False) self.docTitle = GuiDocTitleBar(self, self.theProject, isEditor=False)
self.docTitle.setGeometry(0, 0, self.docTitle.width(), self.docTitle.height()) self.docFooter = GuiDocViewFooter(self, self.theProject)
self.setViewportMargins(0, self.docTitle.height(), 0, 0)
theOpt = QTextOption() theOpt = QTextOption()
if self.mainConf.doJustify: if self.mainConf.doJustify:
@@ -233,15 +232,17 @@ class GuiDocViewer(QTextBrowser):
tB = self.lineWidth() tB = self.lineWidth()
tW = self.width() - 2*tB - sW tW = self.width() - 2*tB - sW
tH = self.docTitle.height() tH = self.docTitle.height()
fH = self.docFooter.height()
fY = self.height() - fH - tB
tT = self.mainConf.getTextMargin() - tH tT = self.mainConf.getTextMargin() - tH
bT = self.mainConf.getTextMargin() - fH
self.docTitle.setGeometry(tB, tB, tW, tH) 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() docFormat = self.qDocument.rootFrame().frameFormat()
if tT > 0: docFormat.setTopMargin(max(0, tT))
docFormat.setTopMargin(tT) docFormat.setBottomMargin(max(0, bT))
else:
docFormat.setTopMargin(0)
self.qDocument.blockSignals(True) self.qDocument.blockSignals(True)
self.qDocument.rootFrame().setFrameFormat(docFormat) self.qDocument.rootFrame().setFrameFormat(docFormat)
+14 -6
View File
@@ -125,14 +125,19 @@ class GuiMain(QMainWindow):
self.docView.setContentsMargins(0, 0, 0, 0) self.docView.setContentsMargins(0, 0, 0, 0)
self.docView.setSpacing(self.mainConf.pxInt(2)) self.docView.setSpacing(self.mainConf.pxInt(2))
self.docView.addWidget(self.docViewer) self.docView.addWidget(self.docViewer)
self.docView.addWidget(self.viewMeta) # self.docView.addWidget(self.viewMeta)
self.docView.setStretch(0, 1) self.docView.setStretch(0, 1)
self.viewPane.setLayout(self.docView) 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 = QSplitter(Qt.Horizontal)
self.splitDocs.setOpaqueResize(False) self.splitDocs.setOpaqueResize(False)
self.splitDocs.addWidget(self.editPane) self.splitDocs.addWidget(self.editPane)
self.splitDocs.addWidget(self.viewPane) self.splitDocs.addWidget(self.splitView)
self.splitOutline = QSplitter(Qt.Vertical) self.splitOutline = QSplitter(Qt.Vertical)
self.splitOutline.addWidget(self.projView) self.splitOutline.addWidget(self.projView)
@@ -841,6 +846,12 @@ class GuiMain(QMainWindow):
if msgRes != QMessageBox.Yes: if msgRes != QMessageBox.Yes:
return False 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__) logger.info("Exiting %s" % nw.__package__)
if self.hasProject: if self.hasProject:
self.closeProject(True) self.closeProject(True)
@@ -848,10 +859,7 @@ class GuiMain(QMainWindow):
self.mainConf.setTreeColWidths(self.treeView.getColumnSizes()) self.mainConf.setTreeColWidths(self.treeView.getColumnSizes())
if not self.mainConf.isFullScreen: if not self.mainConf.isFullScreen:
self.mainConf.setWinSize(self.width(), self.height()) 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.mainConf.saveConfig()
self.reportConfErr() self.reportConfErr()