Rename showGUI variable to blockGUI and added some comments in Config class

This commit is contained in:
Veronica K. B. Olsen
2020-09-22 21:37:00 +02:00
parent 7a9124ca58
commit 9a9cfe1ce5
12 changed files with 49 additions and 51 deletions
+1 -1
View File
@@ -195,7 +195,7 @@ def main(sysArgs=None):
testMode = True
# Set Config Options
CONFIG.showGUI = not testMode
CONFIG.blockGUI = not testMode
CONFIG.debugInfo = debugLevel < logging.INFO
CONFIG.cmdOpen = cmdOpen
+19 -21
View File
@@ -57,32 +57,31 @@ class Config:
self.cmdOpen = None
# Debug Settings
self.showGUI = True
self.debugInfo = False
self.blockGUI = True # Allow blocking the GUI (disabled for testing)
self.debugInfo = False # True if log level is DEBUG or VERBOSE
# Config Error Handling
self.hasError = False
self.errData = []
self.hasError = False # True if the config class encountered an error
self.errData = [] # List of error messages
# Set Paths
self.confPath = None
self.confFile = None
self.dataPath = None
self.homePath = None
self.lastPath = None
self.appPath = None
self.appRoot = None
self.appIcon = None
self.assetPath = None
self.themeRoot = None
self.graphPath = None
self.dictPath = None
self.iconPath = None
self.helpPath = None
self.confPath = None # Folder where the config is saved
self.confFile = None # The config file name
self.dataPath = None # Folder where app data is stored
self.homePath = None # The user's home folder
self.lastPath = None # The last user-selected folder (browse dialogs)
self.appPath = None # The full path to the novelwriter package folder
self.appRoot = None # The full path to the novelwriter root folder
self.appIcon = None # The full path to the novelwriter icon file
self.assetPath = None # The full path to the nw/assets folder
self.themeRoot = None # The full path to the nw/assets/themes folder
self.dictPath = None # The full path to the nw/assets/dict folder
self.iconPath = None # The full path to the nw/assets/icons folder
self.helpPath = None # The full path to the novelwriter .qhc help file
# Runtime Settings and Variables
self.confChanged = False
self.hasHelp = False
self.confChanged = False # True whenever the config has chenged, false after save
self.hasHelp = False # True if the Qt help files are present in the assets folder
## General
self.guiTheme = "default"
@@ -264,7 +263,6 @@ class Config:
self.appRoot = path.join(self.appPath, path.pardir)
self.assetPath = path.join(self.appPath, "assets")
self.themeRoot = path.join(self.assetPath, "themes")
self.graphPath = path.join(self.assetPath, "graphics")
self.dictPath = path.join(self.assetPath, "dict")
self.iconPath = path.join(self.assetPath, "icons")
self.appIcon = path.join(self.iconPath, "novelwriter.svg")
+2 -2
View File
@@ -513,7 +513,7 @@ class NWProject():
# Check novelWriter Version
# =========================
if int(hexVersion, 16) > int(nw.__hexversion__, 16) and self.mainConf.showGUI:
if int(hexVersion, 16) > int(nw.__hexversion__, 16) and self.mainConf.blockGUI:
msgBox = QMessageBox()
msgRes = msgBox.question(self.theParent, "Version Conflict", (
"This project was saved by a newer version of novelWriter, version %s. "
@@ -926,7 +926,7 @@ class NWProject():
return False
if path.isdir(projPath):
if self.mainConf.showGUI and listdir(self.projPath):
if self.mainConf.blockGUI and listdir(self.projPath):
self.theParent.makeAlert((
"New project folder is not empty. "
"Each project requires a dedicated project folder."
+1 -1
View File
@@ -160,7 +160,7 @@ def exceptionHandler(exType, exValue, exTrace, testMode=False):
errMsg = NWErrorMessage(nwGUI)
errMsg.setMessage(exType, exValue, exTrace)
if nw.CONFIG.showGUI:
if nw.CONFIG.blockGUI:
errMsg.exec_()
try:
+2 -2
View File
@@ -633,7 +633,7 @@ class GuiBuildNovel(QDialog):
if not path.isdir(saveDir):
saveDir = self.mainConf.homePath
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.DontUseNativeDialog
saveTo = QFileDialog.getSaveFileName(
@@ -745,7 +745,7 @@ class GuiBuildNovel(QDialog):
errMsg = "Unknown format"
# Report to user
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
if wSuccess:
self.theParent.makeAlert(
"%s file successfully written to:<br> %s" % (
+1 -1
View File
@@ -160,7 +160,7 @@ class GuiDocSplit(QDialog):
), nwAlert.ERROR)
return
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
msgBox = QMessageBox()
msgRes = msgBox.question(
self, "Split Document", (
+1 -1
View File
@@ -103,7 +103,7 @@ class GuiPreferences(PagedDialog):
validEntries &= retA
needsRestart |= retB
if needsRestart and self.mainConf.showGUI:
if needsRestart and self.mainConf.blockGUI:
msgBox = QMessageBox()
msgBox.information(
self, "Preferences",
+2 -2
View File
@@ -177,7 +177,7 @@ class GuiProjectLoad(QDialog):
"""Browse for a folder path.
"""
logger.verbose("GuiProjectLoad browse button clicked")
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.DontUseNativeDialog
projFile, _ = QFileDialog.getOpenFileName(
@@ -218,7 +218,7 @@ class GuiProjectLoad(QDialog):
selList = self.listBox.selectedItems()
if selList:
doRemove = False
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
msgBox = QMessageBox()
msgRes = msgBox.question(
self, "Remove Entry",
+2 -2
View File
@@ -410,7 +410,7 @@ class GuiProjectTree(QTreeWidget):
# If the file is in the trash folder already, as the
# user if they want to permanently delete the file.
doPermanent = False
if self.mainConf.showGUI and not alreadyAsked:
if self.mainConf.blockGUI and not alreadyAsked:
msgBox = QMessageBox()
msgRes = msgBox.question(
self, "Delete File", "Permanently delete file '%s'?" % nwItemS.itemName
@@ -439,7 +439,7 @@ class GuiProjectTree(QTreeWidget):
# The file is not already in the trash folder, so we
# move it there.
doTrash = False
if self.mainConf.showGUI and askForTrash:
if self.mainConf.blockGUI and askForTrash:
msgBox = QMessageBox()
msgRes = msgBox.question(
self, "Delete File", "Move file '%s' to Trash?" % nwItemS.itemName
+2 -2
View File
@@ -325,7 +325,7 @@ class GuiWritingStats(QDialog):
if not path.isdir(saveDir):
saveDir = self.mainConf.homePath
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.DontUseNativeDialog
saveTo = QFileDialog.getSaveFileName(
@@ -379,7 +379,7 @@ class GuiWritingStats(QDialog):
errMsg = str(e)
# Report to user
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
if wSuccess:
self.theParent.makeAlert(
"%s file successfully written to:<br> %s" % (
+15 -15
View File
@@ -195,7 +195,7 @@ class GuiMain(QMainWindow):
self.setStatus = self.statusBar.setStatus
self.setProjectStatus = self.statusBar.setProjectStatus
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
self.show()
# Check that config loaded fine
@@ -250,7 +250,7 @@ class GuiMain(QMainWindow):
projects from a cache of recently opened projects, or provide a
browse button for projects not yet cached.
"""
if not self.mainConf.showGUI:
if not self.mainConf.blockGUI:
return False
dlgProj = GuiProjectLoad(self)
@@ -275,7 +275,7 @@ class GuiMain(QMainWindow):
)
return False
if projData is None and self.mainConf.showGUI:
if projData is None and self.mainConf.blockGUI:
projData = self.newProjectDialog()
if projData is None:
@@ -316,7 +316,7 @@ class GuiMain(QMainWindow):
# There is no project loaded, everything OK
return True
if self.mainConf.showGUI and not isYes:
if self.mainConf.blockGUI and not isYes:
msgBox = QMessageBox()
msgRes = msgBox.question(
self, "Close Project", "Save changes and close current project?"
@@ -332,7 +332,7 @@ class GuiMain(QMainWindow):
doBackup = False
if self.theProject.doBackup and self.mainConf.backupOnClose:
doBackup = True
if self.mainConf.showGUI and self.mainConf.askBeforeBackup:
if self.mainConf.blockGUI and self.mainConf.askBeforeBackup:
msgBox = QMessageBox()
msgRes = msgBox.question(
self, "Backup Project", "Backup current project?"
@@ -379,7 +379,7 @@ class GuiMain(QMainWindow):
# reason handled by the project class.
return False
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
try:
lockDetails = (
"<br><br>The project was locked by the computer "
@@ -611,7 +611,7 @@ class GuiMain(QMainWindow):
return False
if not self.docEditor.isEmpty():
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
msgBox = QMessageBox()
msgRes = msgBox.question(self, "Import Document", (
"Importing the file will overwrite the current content of the document. "
@@ -629,7 +629,7 @@ class GuiMain(QMainWindow):
def mergeDocuments(self):
"""Merge multiple documents to one single new document.
"""
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
dlgMerge = GuiDocMerge(self, self.theProject)
dlgMerge.exec_()
return True
@@ -637,7 +637,7 @@ class GuiMain(QMainWindow):
def splitDocument(self):
"""Split a single document into multiple documents.
"""
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
dlgSplit = GuiDocSplit(self, self.theProject)
dlgSplit.exec_()
return True
@@ -684,7 +684,7 @@ class GuiMain(QMainWindow):
return
logger.verbose("Requesting change to item %s" % tHandle)
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
dlgProj = GuiItemEditor(self, self.theProject, tHandle)
if dlgProj.exec_():
self.treeView.setTreeItemValues(tHandle)
@@ -745,7 +745,7 @@ class GuiMain(QMainWindow):
qApp.restoreOverrideCursor()
if self.mainConf.showGUI and not beQuiet:
if self.mainConf.blockGUI and not beQuiet:
self.makeAlert("The project index has been successfully rebuilt.", nwAlert.INFO)
return True
@@ -830,7 +830,7 @@ class GuiMain(QMainWindow):
def showAboutNWDialog(self):
"""Show the about dialog for novelWriter.
"""
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
dlgAbout = GuiAbout(self)
dlgAbout.exec_()
return True
@@ -838,7 +838,7 @@ class GuiMain(QMainWindow):
def showAboutQtDialog(self):
"""Show the about dialog for Qt.
"""
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
msgBox = QMessageBox()
msgBox.aboutQt(self, "About Qt")
return True
@@ -870,7 +870,7 @@ class GuiMain(QMainWindow):
logger.error(msgLine)
# Popup
if self.mainConf.showGUI:
if self.mainConf.blockGUI:
msgBox = QMessageBox()
if theLevel == nwAlert.INFO:
msgBox.information(self, "Information", popMsg)
@@ -901,7 +901,7 @@ class GuiMain(QMainWindow):
def closeMain(self):
"""Save everything, and close novelWriter.
"""
if self.mainConf.showGUI and self.hasProject:
if self.mainConf.blockGUI and self.hasProject:
msgBox = QMessageBox()
msgRes = msgBox.question(
self, "Exit", "Do you want to save changes and exit?"
+1 -1
View File
@@ -779,7 +779,7 @@ def testPreferences(qtbot, nwMinimal, nwTemp, nwRef, tmpConf):
nwPrefs.show()
# Override Config
tmpConf.showGUI = False
tmpConf.blockGUI = False
tmpConf.confPath = nwMinimal
nwGUI.mainConf = tmpConf
nwPrefs.mainConf = tmpConf