diff --git a/nw/gui/statusbar.py b/nw/gui/statusbar.py new file mode 100644 index 00000000..32f32d53 --- /dev/null +++ b/nw/gui/statusbar.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +"""novelWriter GUI Main Window StatusBar + + novelWriter – GUI Main Window StatusBar +========================================= + Class holding the main window status bar + + File History: + Created: 2019-04-20 [0.0.1] + +""" + +import logging +import nw + +from os import path +from PyQt5.QtWidgets import QStatusBar, QLabel + +logger = logging.getLogger(__name__) + +class GuiMainStatus(QStatusBar): + + def __init__(self): + QStatusBar.__init__(self) + + logger.debug("Initialising GuiMainStatus ...") + + self.mainConf = nw.CONFIG + + self.boxWordCount = QLabel() + self.boxCharCount = QLabel() + self.boxDocHandle = QLabel() + + self.addPermanentWidget(self.boxWordCount) + self.addPermanentWidget(self.boxCharCount) + if self.mainConf.debugGUI: + self.addPermanentWidget(self.boxDocHandle) + + logger.debug("GuiMainStatus initialisation complete") + + self.setWordCount(None) + self.setCharCount(None) + self.setDocHandleCount(None) + + return + + def setWordCount(self, theCount): + if theCount is None: + self.boxWordCount.setText("Words: --") + else: + self.boxWordCount.setText("Words: {:n}".format(theCount)) + return + + def setCharCount(self, theCount): + if theCount is None: + self.boxCharCount.setText("Chars: --") + else: + self.boxCharCount.setText("Chars: {:n}".format(theCount)) + return + + def setDocHandleCount(self, theHandle): + if theHandle is None: + self.boxDocHandle.setText("0000000000000") + else: + self.boxDocHandle.setText("%13s" % theHandle) + return + +# END Class GuiMainStatus diff --git a/nw/gui/winmain.py b/nw/gui/winmain.py index 528fce80..2f3e2a51 100644 --- a/nw/gui/winmain.py +++ b/nw/gui/winmain.py @@ -23,6 +23,7 @@ from nw.gui.doctree import GuiDocTree from nw.gui.doctreectx import GuiDocTreeCtx from nw.gui.doceditor import GuiDocEditor from nw.gui.projecteditor import GuiProjectEditor +from nw.gui.statusbar import GuiMainStatus from nw.project.project import NWProject from nw.project.document import NWDoc @@ -36,13 +37,13 @@ class GuiMain(QMainWindow): logger.debug("Initialising GUI ...") self.mainConf = nw.CONFIG self.theProject = NWProject() - self.theDocument = NWDoc(self.theProject) + self.theDocument = NWDoc(self.theProject, self) self.resize(*self.mainConf.winGeometry) self._setWindowTitle() self.setWindowIcon(QIcon(path.join(self.mainConf.appPath,"..","novelWriter.svg"))) - self.docEditor = GuiDocEditor() + self.docEditor = GuiDocEditor(self) self.treePane = QFrame() self.treePane.setFrameShape(QFrame.StyledPanel) @@ -75,6 +76,10 @@ class GuiMain(QMainWindow): self.splitMain.setSizes(self.mainConf.mainPanePos) self.splitMain.splitterMoved.connect(self._splitMainMove) + self.statusBar = GuiMainStatus() + self.setStatusBar(self.statusBar) + self.statusBar.showMessage("Ready") + # Load Theme StyleSheet cssFile = path.join(self.mainConf.themePath,self.mainConf.guiTheme+".css") if path.isfile(cssFile): @@ -86,9 +91,6 @@ class GuiMain(QMainWindow): logger.debug("GUI initialisation complete") - statBar = self.statusBar() - statBar.showMessage("Ready") - return #