Added some useful menu option, and settings in project file

This commit is contained in:
Veronica K. B. Olsen
2020-04-13 16:02:44 +02:00
parent ac3adade18
commit 92f54af894
6 changed files with 98 additions and 5 deletions
+13 -1
View File
@@ -129,11 +129,23 @@ class GuiProjectOutline(QTreeWidget):
tree.
"""
# If it's the first time, we always build
if self.firstView or overRide:
self._loadHeaderState()
self._populateTree()
self.firstView = False
return
self.firstView = False
# If the novel index has changed since the tree was last built,
# we rebuild the tree from the updated index.
lastChange = self.theParent.theIndex.timeNovel
logger.verbose("Last outline build: %.3f" % self.lastBuild)
logger.verbose("Novel index change: %.3f" % lastChange)
doBuild = lastChange > self.lastBuild and self.theProject.autoOutline
if doBuild or overRide:
logger.debug("Rebuilding Project Outline")
self._populateTree()
return
+31
View File
@@ -69,6 +69,13 @@ class GuiMainMenu(QMenuBar):
self.aSpellCheck.setChecked(theMode)
return
def setAutoOutline(self, theMode):
"""Set the auto outline check box to theMode. Used during
initialisation.
"""
self.aAutoOutline.setChecked(theMode)
return
##
# Menu Action
##
@@ -85,6 +92,12 @@ class GuiMainMenu(QMenuBar):
self.theParent.docEditor.setSpellCheck(None)
return True
def _toggleAutoOutline(self, theMode):
"""Toggle auto outline when the menu entry is checked.
"""
self.theProject.setAutoOutline(theMode)
return True
def _toggleViewComments(self):
self.mainConf.setViewComments(self.aViewDocComments.isChecked())
self.theParent.docViewer.reloadText()
@@ -646,6 +659,24 @@ class GuiMainMenu(QMenuBar):
self.aRebuildIndex.triggered.connect(self.theParent.rebuildIndex)
self.toolsMenu.addAction(self.aRebuildIndex)
# Tools > Rebuild Outline
self.aRebuildOutline = QAction("Rebuild Outline", self)
self.aRebuildOutline.setStatusTip("Rebuild the novel outline tree")
self.aRebuildOutline.setShortcut("F10")
self.aRebuildOutline.triggered.connect(self.theParent.rebuildOutline)
self.toolsMenu.addAction(self.aRebuildOutline)
# Tools > Toggle Auto Build Outline
self.aAutoOutline = QAction("Auto-Update Outline", self)
self.aAutoOutline.setStatusTip("Update project outline when a novel file is changed")
self.aAutoOutline.setCheckable(True)
self.aAutoOutline.toggled.connect(self._toggleAutoOutline)
self.aAutoOutline.setShortcut("Ctrl+F10")
self.toolsMenu.addAction(self.aAutoOutline)
# Tools > Separator
self.toolsMenu.addSeparator()
# Tools > Backup
self.aBackupProject = QAction("Backup Project", self)
self.aBackupProject.setStatusTip("Backup Project")