diff --git a/nw/gui/__init__.py b/nw/gui/__init__.py index 4df869b5..981173f2 100644 --- a/nw/gui/__init__.py +++ b/nw/gui/__init__.py @@ -13,7 +13,8 @@ from nw.gui.docviewer import GuiDocViewer from nw.gui.itemdetails import GuiItemDetails from nw.gui.itemeditor import GuiItemEditor from nw.gui.mainmenu import GuiMainMenu -from nw.gui.outline import GuiProjectOutline +from nw.gui.outline import GuiOutline +from nw.gui.outlinedetails import GuiOutlineDetails from nw.gui.preferences import GuiPreferences from nw.gui.projload import GuiProjectLoad from nw.gui.projsettings import GuiProjectSettings @@ -37,7 +38,8 @@ __all__ = [ "GuiItemDetails", "GuiItemEditor", "GuiMainMenu", - "GuiProjectOutline", + "GuiOutline", + "GuiOutlineDetails", "GuiPreferences", "GuiProjectLoad", "GuiProjectSettings", diff --git a/nw/gui/docdetails.py b/nw/gui/docdetails.py index d4b2621c..09b43426 100644 --- a/nw/gui/docdetails.py +++ b/nw/gui/docdetails.py @@ -37,13 +37,13 @@ logger = logging.getLogger(__name__) class GuiDocViewDetails(QWidget): - def __init__(self, theParent, theProject): + def __init__(self, theParent): QWidget.__init__(self, theParent) logger.debug("Initialising DocViewDetails ...") self.mainConf = nw.CONFIG self.theParent = theParent - self.theProject = theProject + self.theProject = theParent.theProject self.currHandle = None self.outerBox = QGridLayout(self) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index bf511e07..1b3f81bb 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -50,16 +50,16 @@ logger = logging.getLogger(__name__) class GuiDocEditor(QTextEdit): - def __init__(self, theParent, theProject): - QTextEdit.__init__(self) + def __init__(self, theParent): + QTextEdit.__init__(self, theParent) logger.debug("Initialising GuiDocEditor ...") # Class Variables self.mainConf = nw.CONFIG - self.theProject = theProject self.theParent = theParent self.theTheme = theParent.theTheme + self.theProject = theParent.theProject self.docChanged = False self.spellCheck = False self.nwDocument = NWDoc(self.theProject, self.theParent) diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index 1be66bba..446426e4 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -40,16 +40,16 @@ logger = logging.getLogger(__name__) class GuiDocViewer(QTextBrowser): - def __init__(self, theParent, theProject): - QTextBrowser.__init__(self) + def __init__(self, theParent): + QTextBrowser.__init__(self, theParent) - logger.debug("Initialising DocViewer ...") + logger.debug("Initialising GuiDocViewer ...") # Class Variables self.mainConf = nw.CONFIG - self.theProject = theProject self.theParent = theParent self.theTheme = theParent.theTheme + self.theProject = theParent.theProject self.theHandle = None self.qDocument = self.document() @@ -70,7 +70,7 @@ class GuiDocViewer(QTextBrowser): self.anchorClicked.connect(self._linkClicked) self.setFocusPolicy(Qt.StrongFocus) - logger.debug("DocViewer initialisation complete") + logger.debug("GuiDocViewer initialisation complete") # Connect Functions self.setSelectedHandle = self.theParent.treeView.setSelectedHandle diff --git a/nw/gui/itemdetails.py b/nw/gui/itemdetails.py index 93ffb788..7335a596 100644 --- a/nw/gui/itemdetails.py +++ b/nw/gui/itemdetails.py @@ -30,7 +30,7 @@ import nw from PyQt5.QtCore import Qt from PyQt5.QtGui import QFont, QIcon, QPixmap -from PyQt5.QtWidgets import QFrame, QGridLayout, QLabel +from PyQt5.QtWidgets import QWidget, QGridLayout, QLabel from nw.constants import ( nwLabels, nwItemClass, nwItemType, nwItemLayout, nwUnicode @@ -38,15 +38,15 @@ from nw.constants import ( logger = logging.getLogger(__name__) -class GuiItemDetails(QFrame): +class GuiItemDetails(QWidget): - def __init__(self, theParent, theProject): - QFrame.__init__(self, theParent) + def __init__(self, theParent): + QWidget.__init__(self, theParent) logger.debug("Initialising GuiItemDetails ...") self.mainConf = nw.CONFIG self.theParent = theParent - self.theProject = theProject + self.theProject = theParent.theProject self.theTheme = theParent.theTheme self.theHandle = None diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index 5ff4d918..fc170377 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -39,13 +39,13 @@ logger = logging.getLogger(__name__) class GuiMainMenu(QMenuBar): - def __init__(self, theParent, theProject): + def __init__(self, theParent): QMenuBar.__init__(self, theParent) - logger.debug("Initialising Main Menu ...") + logger.debug("Initialising GuiMainMenu ...") self.mainConf = nw.CONFIG self.theParent = theParent - self.theProject = theProject + self.theProject = theParent.theProject self._buildProjectMenu() self._buildDocumentMenu() @@ -60,7 +60,7 @@ class GuiMainMenu(QMenuBar): self._moveTreeItem = self.theParent.treeView.moveTreeItem self._newTreeItem = self.theParent.treeView.newTreeItem - logger.debug("Main Menu initialisation complete") + logger.debug("GuiMainMenu initialisation complete") return diff --git a/nw/gui/outline.py b/nw/gui/outline.py index 12c26383..c3c81e4f 100644 --- a/nw/gui/outline.py +++ b/nw/gui/outline.py @@ -39,7 +39,7 @@ from nw.constants import nwKeyWords, nwLabels, nwOutline logger = logging.getLogger(__name__) -class GuiProjectOutline(QTreeWidget): +class GuiOutline(QTreeWidget): DEF_WIDTH = { nwOutline.TITLE : 200, @@ -79,17 +79,17 @@ class GuiProjectOutline(QTreeWidget): nwOutline.SYNOP : False, } - def __init__(self, theParent, theProject): + def __init__(self, theParent): QTreeWidget.__init__(self, theParent) - logger.debug("Initialising ProjectOutline ...") + logger.debug("Initialising GuiOutline ...") self.mainConf = nw.CONFIG self.theParent = theParent - self.theProject = theProject + self.theProject = theParent.theProject self.theTheme = theParent.theTheme self.theIndex = theParent.theIndex - self.optState = theProject.optState + self.optState = theParent.theProject.optState self.headerMenu = GuiOutlineHeaderMenu(self) self.firstView = True @@ -120,7 +120,7 @@ class GuiProjectOutline(QTreeWidget): self.clearOutline() self.headerMenu.setHiddenState(self.colHidden) - logger.debug("ProjectOutline initialisation complete") + logger.debug("GuiOutline initialisation complete") return @@ -233,7 +233,7 @@ class GuiProjectOutline(QTreeWidget): # Load whatever we saved last time, regardless of wether it # contains the correct names or number of columns. The names # must be valid though. - tempOrder = self.optState.getValue("GuiProjectOutline", "headerOrder", []) + tempOrder = self.optState.getValue("GuiOutline", "headerOrder", []) treeOrder = [] for hName in tempOrder: try: @@ -256,14 +256,14 @@ class GuiProjectOutline(QTreeWidget): # We load whatever column widths and hidden states we find in # the file, and leave the rest in their default state. - tmpWidth = self.optState.getValue("GuiProjectOutline", "columnWidth", {}) + tmpWidth = self.optState.getValue("GuiOutline", "columnWidth", {}) for hName in tmpWidth: try: self.colWidth[nwOutline[hName]] = tmpWidth[hName] except: logger.warning("Ignored unknown outline column '%s'" % str(hName)) - tmpHidden = self.optState.getValue("GuiProjectOutline", "columnHidden", {}) + tmpHidden = self.optState.getValue("GuiOutline", "columnHidden", {}) for hName in tmpHidden: try: self.colHidden[nwOutline[hName]] = tmpHidden[hName] @@ -304,9 +304,9 @@ class GuiProjectOutline(QTreeWidget): if not logHidden and logWidth > 0: colWidth[hName] = logWidth - self.optState.setValue("GuiProjectOutline", "headerOrder", treeOrder) - self.optState.setValue("GuiProjectOutline", "columnWidth", colWidth) - self.optState.setValue("GuiProjectOutline", "columnHidden", colHidden) + self.optState.setValue("GuiOutline", "headerOrder", treeOrder) + self.optState.setValue("GuiOutline", "columnWidth", colWidth) + self.optState.setValue("GuiOutline", "columnHidden", colHidden) self.optState.saveSettings() return @@ -438,7 +438,7 @@ class GuiProjectOutline(QTreeWidget): return newItem -# END Class GuiProjectOutline +# END Class GuiOutline class GuiOutlineHeaderMenu(QMenu): diff --git a/nw/gui/outlinedetails.py b/nw/gui/outlinedetails.py new file mode 100644 index 00000000..d4701cd5 --- /dev/null +++ b/nw/gui/outlinedetails.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +"""novelWriter GUI Project Outline + + novelWriter – GUI Project Outline +=================================== + Class holding the project outline view + + File History: + Created: 2020-06-02 [0.7.0] + + 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 . +""" + +import logging +import nw + +from PyQt5.QtCore import Qt +from PyQt5.QtWidgets import ( + QWidget +) + +logger = logging.getLogger(__name__) + +class GuiOutlineDetails(QWidget): + + def __init__(self, theParent): + QWidget.__init__(self, theParent) + + logger.debug("Initialising GuiOutlineDetails ...") + + self.mainConf = nw.CONFIG + self.theParent = theParent + self.theProject = theParent.theProject + self.theTheme = theParent.theTheme + self.theIndex = theParent.theIndex + self.optState = theParent.theProject.optState + + logger.debug("GuiOutlineDetails initialisation complete") + + return + +# END Class GuiOutlineDetails diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py index 72246c3a..1dd065cc 100644 --- a/nw/gui/projtree.py +++ b/nw/gui/projtree.py @@ -49,14 +49,14 @@ class GuiProjectTree(QTreeWidget): C_EXPORT = 2 C_FLAGS = 3 - def __init__(self, theParent, theProject): + def __init__(self, theParent): QTreeWidget.__init__(self, theParent) logger.debug("Initialising GuiProjectTree ...") self.mainConf = nw.CONFIG self.theParent = theParent self.theTheme = theParent.theTheme - self.theProject = theProject + self.theProject = theParent.theProject # Tree Settings self.theMap = None diff --git a/nw/guimain.py b/nw/guimain.py index ea6c050e..639a015a 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -40,10 +40,10 @@ from PyQt5.QtWidgets import ( ) from nw.gui import ( - GuiMainMenu, GuiMainStatus, GuiTheme, GuiProjectTree, GuiDocEditor, - GuiDocViewer, GuiItemDetails, GuiSearchBar, GuiNoticeBar, GuiDocViewDetails, - GuiPreferences, GuiProjectSettings, GuiItemEditor, GuiProjectOutline, - GuiSessionLogView, GuiDocMerge, GuiDocSplit, GuiProjectLoad, GuiBuildNovel + GuiBuildNovel, GuiDocEditor, GuiDocMerge, GuiDocSplit, GuiDocViewDetails, + GuiDocViewer, GuiItemDetails, GuiItemEditor, GuiMainMenu, GuiMainStatus, + GuiNoticeBar, GuiOutline, GuiOutlineDetails, GuiPreferences, GuiProjectLoad, + GuiProjectSettings, GuiProjectTree, GuiSearchBar, GuiSessionLogView, GuiTheme ) from nw.core import NWProject, NWDoc, NWIndex from nw.constants import nwFiles, nwItemType, nwAlert @@ -91,14 +91,15 @@ class GuiMain(QMainWindow): # Main GUI Elements self.statusBar = GuiMainStatus(self) self.noticeBar = GuiNoticeBar(self) - self.treeView = GuiProjectTree(self, self.theProject) - self.docEditor = GuiDocEditor(self, self.theProject) - self.docViewer = GuiDocViewer(self, self.theProject) - self.viewMeta = GuiDocViewDetails(self, self.theProject) + self.treeView = GuiProjectTree(self) + self.docEditor = GuiDocEditor(self) + self.docViewer = GuiDocViewer(self) + self.viewMeta = GuiDocViewDetails(self) self.searchBar = GuiSearchBar(self) - self.treeMeta = GuiItemDetails(self, self.theProject) - self.projView = GuiProjectOutline(self, self.theProject) - self.mainMenu = GuiMainMenu(self, self.theProject) + self.treeMeta = GuiItemDetails(self) + self.projView = GuiOutline(self) + self.projMeta = GuiOutlineDetails(self) + self.mainMenu = GuiMainMenu(self) # Minor Gui Elements self.statusIcons = [] @@ -137,6 +138,7 @@ class GuiMain(QMainWindow): self.splitOutline = QSplitter(Qt.Vertical) self.splitOutline.addWidget(self.projView) + self.splitOutline.addWidget(self.projMeta) self.tabWidget = QTabWidget() self.tabWidget.setTabPosition(QTabWidget.East)