Added a noticeBar to the top of the document editor that can display notifications

This commit is contained in:
Veronica K. B. Olsen
2019-10-31 14:45:00 +01:00
parent 6f893bf321
commit c815a9ce01
5 changed files with 80 additions and 6 deletions
+7 -3
View File
@@ -116,6 +116,7 @@ class GuiDocEditor(QTextEdit):
self.hasSelection = False
self.setDocumentChanged(False)
self.theParent.noticeBar.hideNote()
return True
@@ -201,6 +202,8 @@ class GuiDocEditor(QTextEdit):
if self.nwDocument.docEditable:
self.setReadOnly(False)
else:
self.theParent.noticeBar.showNote("This document is read only.")
return True
@@ -244,9 +247,10 @@ class GuiDocEditor(QTextEdit):
return theText
def setCursorPosition(self, thePosition):
theCursor = self.textCursor()
theCursor.setPosition(thePosition)
self.setTextCursor(theCursor)
if thePosition > 0:
theCursor = self.textCursor()
theCursor.setPosition(thePosition)
self.setTextCursor(theCursor)
return True
def getCursorPosition(self):
+65
View File
@@ -0,0 +1,65 @@
# -*- 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]
"""
import logging
import nw
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPalette, QColor
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("Hi there!")
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):
self.noteLabel.setText("<b>Note:</b> %s" % theNote)
self.setVisible(True)
return
def hideNote(self):
self.noteLabel.setText("")
self.setVisible(False)
return
# END Class GuiNoticeBar
+2 -2
View File
@@ -26,7 +26,7 @@ class GuiSearchBar(QFrame):
def __init__(self, theParent):
QFrame.__init__(self, theParent)
logger.debug("Initialising GuiSearchBar ...")
logger.debug("Initialising SearchBar ...")
self.mainConf = nw.CONFIG
self.theParent = theParent
@@ -73,7 +73,7 @@ class GuiSearchBar(QFrame):
self._replaceVisible(False)
logger.debug("GuiSearchBar initialisation complete")
logger.debug("SearchBar initialisation complete")
return