From 0387ce67b72e41d5fdf47885e9915bbed2d95304 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 26 Apr 2020 21:35:58 +0200 Subject: [PATCH] Base document title class ready. --- nw/gui/__init__.py | 2 ++ nw/gui/elements/__init__.py | 2 ++ nw/gui/elements/doceditor.py | 2 +- nw/gui/elements/doctitlebar.py | 61 ++++++++++++++++++++++++++++++++++ nw/guimain.py | 10 ++++-- 5 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 nw/gui/elements/doctitlebar.py diff --git a/nw/gui/__init__.py b/nw/gui/__init__.py index 87dec78c..d5f7e67b 100644 --- a/nw/gui/__init__.py +++ b/nw/gui/__init__.py @@ -19,6 +19,7 @@ from nw.gui.dialogs.sessionlog import GuiSessionLogView # GUI Elements from nw.gui.elements.docdetails import GuiDocDetails from nw.gui.elements.doceditor import GuiDocEditor +from nw.gui.elements.doctitlebar import GuiDocTitleBar from nw.gui.elements.doctree import GuiDocTree from nw.gui.elements.docviewer import GuiDocViewer from nw.gui.elements.noticebar import GuiNoticeBar @@ -45,6 +46,7 @@ __all__ = [ "GuiSessionLogView", "GuiDocDetails", "GuiDocEditor", + "GuiDocTitleBar", "GuiDocTree", "GuiDocViewer", "GuiNoticeBar", diff --git a/nw/gui/elements/__init__.py b/nw/gui/elements/__init__.py index 1d885de0..b0938816 100644 --- a/nw/gui/elements/__init__.py +++ b/nw/gui/elements/__init__.py @@ -2,6 +2,7 @@ from nw.gui.elements.docdetails import GuiDocDetails from nw.gui.elements.doceditor import GuiDocEditor +from nw.gui.elements.doctitlebar import GuiDocTitleBar from nw.gui.elements.doctree import GuiDocTree from nw.gui.elements.docviewer import GuiDocViewer from nw.gui.elements.noticebar import GuiNoticeBar @@ -12,6 +13,7 @@ from nw.gui.elements.viewdetails import GuiDocViewDetails __all__ = [ "GuiDocDetails", "GuiDocEditor", + "GuiDocTitleBar", "GuiDocTree", "GuiDocViewer", "GuiNoticeBar", diff --git a/nw/gui/elements/doceditor.py b/nw/gui/elements/doceditor.py index 2ad49a1b..0a63f816 100644 --- a/nw/gui/elements/doceditor.py +++ b/nw/gui/elements/doceditor.py @@ -131,7 +131,7 @@ class GuiDocEditor(QTextEdit): def clearEditor(self): """Clear the current document and reset all document related - flags and counters. + flags and counters. """ self.nwDocument.clearDocument() diff --git a/nw/gui/elements/doctitlebar.py b/nw/gui/elements/doctitlebar.py new file mode 100644 index 00000000..7addfcdf --- /dev/null +++ b/nw/gui/elements/doctitlebar.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +"""novelWriter GUI Document Title Bar + + novelWriter – GUI Document Title Bar +====================================== + Class holding the document title bar class + + File History: + Created: 2020-04-25 [0.4.5] + + This file is a part of novelWriter + Copyright 2020, Veronica Berglyd Olsen + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see https://www.gnu.org/licenses/. +""" + +import logging +import nw + +from PyQt5.QtCore import Qt +from PyQt5.QtGui import QPalette, QColor +from PyQt5.QtWidgets import QLabel + +logger = logging.getLogger(__name__) + +class GuiDocTitleBar(QLabel): + + def __init__(self, theParent): + QLabel.__init__(self, theParent) + + logger.debug("Initialising DocTitleBar ...") + + self.mainConf = nw.CONFIG + self.theParent = theParent + self.theTheme = theParent.theTheme + + self.setText("A > B > C") + self.setContentsMargins(8,2,8,2) + self.setAutoFillBackground(True) + self.setAlignment(Qt.AlignCenter) + docPalette = self.palette() + docPalette.setColor(QPalette.Window, QColor(*self.theTheme.colBack)) + docPalette.setColor(QPalette.Text, QColor(*self.theTheme.colText)) + self.setPalette(docPalette) + + logger.debug("DocTitleBar initialisation complete") + + return + +# END Class GuiDocTitleBar diff --git a/nw/guimain.py b/nw/guimain.py index 46a32384..8e561fc7 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -43,7 +43,7 @@ from nw.gui import ( GuiMainMenu, GuiMainStatus, GuiTheme, GuiDocTree, GuiDocEditor, GuiExport, GuiDocViewer, GuiDocDetails, GuiSearchBar, GuiNoticeBar, GuiDocViewDetails, GuiConfigEditor, GuiProjectEditor, GuiItemEditor, GuiProjectOutline, - GuiSessionLogView, GuiDocMerge, GuiDocSplit, GuiProjectLoad + GuiSessionLogView, GuiDocMerge, GuiDocSplit, GuiProjectLoad, GuiDocTitleBar ) from nw.project import NWProject, NWDoc, NWItem, NWIndex, NWBackup from nw.tools import countWords @@ -93,6 +93,8 @@ class GuiMain(QMainWindow): self.treeView = GuiDocTree(self, self.theProject) self.projView = GuiProjectOutline(self, self.theProject) self.mainMenu = GuiMainMenu(self, self.theProject) + self.viewTitle = GuiDocTitleBar(self) + self.editTitle = GuiDocTitleBar(self) # Minor Gui Elements self.statusIcons = [] @@ -109,17 +111,21 @@ class GuiMain(QMainWindow): self.editPane = QFrame() self.docEdit = QVBoxLayout() self.docEdit.setContentsMargins(0,0,0,0) + self.docEdit.setSpacing(0) self.docEdit.addWidget(self.searchBar) self.docEdit.addWidget(self.noticeBar) + self.docEdit.addWidget(self.editTitle) self.docEdit.addWidget(self.docEditor) self.editPane.setLayout(self.docEdit) self.viewPane = QFrame() self.docView = QVBoxLayout() self.docView.setContentsMargins(0,0,0,0) + self.docView.setSpacing(0) + self.docView.addWidget(self.viewTitle) self.docView.addWidget(self.docViewer) self.docView.addWidget(self.viewMeta) - self.docView.setStretch(0, 1) + self.docView.setStretch(1, 1) self.viewPane.setLayout(self.docView) self.splitView = QSplitter(Qt.Horizontal)