diff --git a/nw/gui/__init__.py b/nw/gui/__init__.py
index b417ac6b..35cbac0a 100644
--- a/nw/gui/__init__.py
+++ b/nw/gui/__init__.py
@@ -20,12 +20,12 @@ 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.docbars import GuiDocTitleBar
from nw.gui.elements.doctree import GuiDocTree
from nw.gui.elements.docviewer import GuiDocViewer
-from nw.gui.elements.noticebar import GuiNoticeBar
+from nw.gui.elements.docbars import GuiNoticeBar
from nw.gui.elements.outline import GuiProjectOutline
-from nw.gui.elements.searchbar import GuiSearchBar
+from nw.gui.elements.docbars import GuiSearchBar
from nw.gui.elements.viewdetails import GuiDocViewDetails
# Tools
diff --git a/nw/gui/elements/__init__.py b/nw/gui/elements/__init__.py
index b0938816..29a334a4 100644
--- a/nw/gui/elements/__init__.py
+++ b/nw/gui/elements/__init__.py
@@ -2,12 +2,12 @@
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.docbars import GuiDocTitleBar
from nw.gui.elements.doctree import GuiDocTree
from nw.gui.elements.docviewer import GuiDocViewer
-from nw.gui.elements.noticebar import GuiNoticeBar
+from nw.gui.elements.docbars import GuiNoticeBar
from nw.gui.elements.outline import GuiProjectOutline
-from nw.gui.elements.searchbar import GuiSearchBar
+from nw.gui.elements.docbars import GuiSearchBar
from nw.gui.elements.viewdetails import GuiDocViewDetails
__all__ = [
diff --git a/nw/gui/elements/searchbar.py b/nw/gui/elements/docbars.py
similarity index 55%
rename from nw/gui/elements/searchbar.py
rename to nw/gui/elements/docbars.py
index 590d8d0a..0923cb91 100644
--- a/nw/gui/elements/searchbar.py
+++ b/nw/gui/elements/docbars.py
@@ -6,7 +6,9 @@
Class holding the main window search bar
File History:
- Created: 2019-09-29 [0.2.1]
+ Created: 2019-09-29 [0.2.1] GuiSearchBar
+ Created: 2019-10-31 [0.3.2] GuiNoticeBar
+ Created: 2020-04-25 [0.4.5] GuiDocTitleBar
This file is a part of novelWriter
Copyright 2020, Veronica Berglyd Olsen
@@ -29,11 +31,13 @@ import logging
import nw
from PyQt5.QtCore import Qt
+from PyQt5.QtGui import QPalette, QColor
from PyQt5.QtWidgets import (
- qApp, QFrame, QGridLayout, QLabel, QLineEdit, QPushButton
+ qApp, QFrame, QGridLayout, QLabel, QLineEdit, QPushButton,
+ QHBoxLayout
)
-from nw.constants import nwDocAction
+from nw.constants import nwDocAction, nwUnicode
logger = logging.getLogger(__name__)
@@ -42,7 +46,7 @@ class GuiSearchBar(QFrame):
def __init__(self, theParent):
QFrame.__init__(self, theParent)
- logger.debug("Initialising SearchBar ...")
+ logger.debug("Initialising GuiSearchBar ...")
self.mainConf = nw.CONFIG
self.theParent = theParent
@@ -89,7 +93,7 @@ class GuiSearchBar(QFrame):
self._replaceVisible(False)
- logger.debug("SearchBar initialisation complete")
+ logger.debug("GuiSearchBar initialisation complete")
return
@@ -163,3 +167,133 @@ class GuiSearchBar(QFrame):
return True
# END Class GuiSearchBar
+
+class GuiNoticeBar(QFrame):
+
+ def __init__(self, theParent):
+ QFrame.__init__(self, theParent)
+
+ logger.debug("Initialising GuiNoticeBar ...")
+
+ self.mainConf = nw.CONFIG
+ self.theParent = theParent
+ self.theTheme = theParent.theTheme
+
+ self.setContentsMargins(0,0,0,0)
+ self.setFrameShape(QFrame.Box)
+
+ self.mainBox = QHBoxLayout(self)
+ self.mainBox.setContentsMargins(8,2,2,2)
+
+ self.noteLabel = QLabel("")
+
+ self.closeButton = QPushButton(self.theTheme.getIcon("close"),"")
+ self.closeButton.clicked.connect(self.hideNote)
+
+ self.mainBox.addWidget(self.noteLabel)
+ self.mainBox.addWidget(self.closeButton)
+ self.mainBox.setStretch(0, 1)
+
+ self.setLayout(self.mainBox)
+
+ self.hideNote()
+
+ logger.debug("GuiNoticeBar initialisation complete")
+
+ return
+
+ def showNote(self, theNote):
+ """Show the note on the noticebar.
+ """
+ self.noteLabel.setText("Note: %s" % theNote)
+ self.setVisible(True)
+ return
+
+ def hideNote(self):
+ """Clear the noticebar and hide it.
+ """
+ self.noteLabel.setText("")
+ self.setVisible(False)
+ return
+
+# END Class GuiNoticeBar
+
+class GuiDocTitleBar(QLabel):
+
+ def __init__(self, theParent, theProject):
+ QLabel.__init__(self, theParent)
+
+ logger.debug("Initialising GuiDocTitleBar ...")
+
+ self.mainConf = nw.CONFIG
+ self.theParent = theParent
+ self.theProject = theProject
+ self.theTheme = theParent.theTheme
+ self.theHandle = None
+
+ self.setText("")
+ self.setIndent(0)
+ self.setMargin(0)
+ self.setContentsMargins(0, 0, 0, 0)
+ self.setAutoFillBackground(True)
+ self.setAlignment(Qt.AlignCenter)
+ self.setWordWrap(True)
+ self.setFrameShape(QFrame.NoFrame)
+ self.setLineWidth(0)
+
+ lblPalette = self.palette()
+ lblPalette.setColor(QPalette.Window, QColor(*self.theTheme.colBack))
+ lblPalette.setColor(QPalette.Text, QColor(*self.theTheme.colText))
+ self.setPalette(lblPalette)
+
+ lblFont = self.font()
+ lblFont.setPointSizeF(0.9*self.theTheme.fontPointSize)
+ self.setFont(lblFont)
+
+ logger.debug("GuiDocTitleBar initialisation complete")
+
+ return
+
+ ##
+ # Setters
+ ##
+
+ def setTitleFromHandle(self, tHandle):
+ """Sets the document title from the handle, or alternatively,
+ set the whole document path.
+ """
+ self.setText("")
+ self.theHandle = tHandle
+ if tHandle is None:
+ return False
+
+ if self.mainConf.showFullPath:
+ tTitle = []
+ tTree = self.theProject.projTree.getItemPath(tHandle)
+ for aHandle in reversed(tTree):
+ nwItem = self.theProject.projTree[aHandle]
+ if nwItem is not None:
+ tTitle.append(nwItem.itemName)
+ sSep = " %s " % nwUnicode.U_RSAQUO
+ self.setText(sSep.join(tTitle))
+ else:
+ nwItem = self.theProject.projTree[tHandle]
+ if nwItem is None:
+ return False
+
+ self.setText(nwItem.itemName)
+
+ return True
+
+ ##
+ # Events
+ ##
+
+ def mousePressEvent(self, theEvent):
+ """Capture a click on the title and ensure that the item is
+ selected in the project tree.
+ """
+ self.theParent.setSelectedHandle(self.theHandle)
+ return
+
+# END Class GuiDocTitleBar
diff --git a/nw/gui/elements/doceditor.py b/nw/gui/elements/doceditor.py
index 3a03369d..0493f167 100644
--- a/nw/gui/elements/doceditor.py
+++ b/nw/gui/elements/doceditor.py
@@ -42,7 +42,7 @@ from PyQt5.QtGui import (
from nw.core import NWDoc
from nw.gui.dochighlight import GuiDocHighlighter
-from nw.gui.elements.doctitlebar import GuiDocTitleBar
+from nw.gui.elements.docbars import GuiDocTitleBar
from nw.core import NWSpellSimple, countWords
from nw.constants import nwUnicode, nwDocAction
diff --git a/nw/gui/elements/doctitlebar.py b/nw/gui/elements/doctitlebar.py
deleted file mode 100644
index 8c5208e4..00000000
--- a/nw/gui/elements/doctitlebar.py
+++ /dev/null
@@ -1,117 +0,0 @@
-# -*- 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 .
-"""
-
-import logging
-import nw
-
-from PyQt5.QtCore import Qt
-from PyQt5.QtGui import QPalette, QColor
-from PyQt5.QtWidgets import QLabel, QFrame
-
-from nw.constants import nwUnicode
-
-logger = logging.getLogger(__name__)
-
-class GuiDocTitleBar(QLabel):
-
- def __init__(self, theParent, theProject):
- QLabel.__init__(self, theParent)
-
- logger.debug("Initialising DocTitleBar ...")
-
- self.mainConf = nw.CONFIG
- self.theParent = theParent
- self.theProject = theProject
- self.theTheme = theParent.theTheme
- self.theHandle = None
-
- self.setText("")
- self.setIndent(0)
- self.setMargin(0)
- self.setContentsMargins(0, 0, 0, 0)
- self.setAutoFillBackground(True)
- self.setAlignment(Qt.AlignCenter)
- self.setWordWrap(True)
- self.setFrameShape(QFrame.NoFrame)
- self.setLineWidth(0)
-
- lblPalette = self.palette()
- lblPalette.setColor(QPalette.Window, QColor(*self.theTheme.colBack))
- lblPalette.setColor(QPalette.Text, QColor(*self.theTheme.colText))
- self.setPalette(lblPalette)
-
- lblFont = self.font()
- lblFont.setPointSizeF(0.9*self.theTheme.fontPointSize)
- self.setFont(lblFont)
-
- logger.debug("DocTitleBar initialisation complete")
-
- return
-
- ##
- # Setters
- ##
-
- def setTitleFromHandle(self, tHandle):
- """Sets the document title from the handle, or alternatively,
- set the whole document path.
- """
- self.setText("")
- self.theHandle = tHandle
- if tHandle is None:
- return False
-
- if self.mainConf.showFullPath:
- tTitle = []
- tTree = self.theProject.projTree.getItemPath(tHandle)
- for aHandle in reversed(tTree):
- nwItem = self.theProject.projTree[aHandle]
- if nwItem is not None:
- tTitle.append(nwItem.itemName)
- sSep = " %s " % nwUnicode.U_RSAQUO
- self.setText(sSep.join(tTitle))
- else:
- nwItem = self.theProject.projTree[tHandle]
- if nwItem is None:
- return False
-
- self.setText(nwItem.itemName)
-
- return True
-
- ##
- # Events
- ##
-
- def mousePressEvent(self, theEvent):
- """Capture a click on the title and ensure that the item is
- selected in the project tree.
- """
- self.theParent.setSelectedHandle(self.theHandle)
- return
-
-# END Class GuiDocTitleBar
diff --git a/nw/gui/elements/docviewer.py b/nw/gui/elements/docviewer.py
index 66f2a5d3..820c6e85 100644
--- a/nw/gui/elements/docviewer.py
+++ b/nw/gui/elements/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.elements.doctitlebar import GuiDocTitleBar
+from nw.gui.elements.docbars import GuiDocTitleBar
logger = logging.getLogger(__name__)
diff --git a/nw/gui/elements/noticebar.py b/nw/gui/elements/noticebar.py
deleted file mode 100644
index 4b6d57aa..00000000
--- a/nw/gui/elements/noticebar.py
+++ /dev/null
@@ -1,83 +0,0 @@
-# -*- coding: utf-8 -*-
-"""novelWriter GUI Main Window Notice Bar
-
- novelWriter – GUI Main Window Notice Bar
-==========================================
- Class holding the main window notice bar for the doc editor
-
- File History:
- Created: 2019-10-31 [0.3.2]
-
- 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.QtWidgets import QFrame, QHBoxLayout, QLabel, QPushButton
-
-logger = logging.getLogger(__name__)
-
-class GuiNoticeBar(QFrame):
-
- def __init__(self, theParent):
- QFrame.__init__(self, theParent)
-
- logger.debug("Initialising NoticeBar ...")
-
- self.mainConf = nw.CONFIG
- self.theParent = theParent
- self.theTheme = theParent.theTheme
-
- self.setContentsMargins(0,0,0,0)
- self.setFrameShape(QFrame.Box)
-
- self.mainBox = QHBoxLayout(self)
- self.mainBox.setContentsMargins(8,2,2,2)
-
- self.noteLabel = QLabel("")
-
- self.closeButton = QPushButton(self.theTheme.getIcon("close"),"")
- self.closeButton.clicked.connect(self.hideNote)
-
- self.mainBox.addWidget(self.noteLabel)
- self.mainBox.addWidget(self.closeButton)
- self.mainBox.setStretch(0, 1)
-
- self.setLayout(self.mainBox)
-
- self.hideNote()
-
- logger.debug("NoticeBar initialisation complete")
-
- return
-
- def showNote(self, theNote):
- """Show the note on the noticebar.
- """
- self.noteLabel.setText("Note: %s" % theNote)
- self.setVisible(True)
- return
-
- def hideNote(self):
- """Clear the noticebar and hide it.
- """
- self.noteLabel.setText("")
- self.setVisible(False)
- return
-
-# END Class GuiNoticeBar