diff --git a/nw/__init__.py b/nw/__init__.py index 715b1e2e..b43c064a 100644 --- a/nw/__init__.py +++ b/nw/__init__.py @@ -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 diff --git a/nw/config.py b/nw/config.py index 5138a677..9af86619 100644 --- a/nw/config.py +++ b/nw/config.py @@ -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") diff --git a/nw/core/project.py b/nw/core/project.py index 5bead8f5..442e76c7 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -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." diff --git a/nw/error.py b/nw/error.py index e1283fbd..00abc818 100644 --- a/nw/error.py +++ b/nw/error.py @@ -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: diff --git a/nw/gui/build.py b/nw/gui/build.py index b61dfd0f..155c6596 100644 --- a/nw/gui/build.py +++ b/nw/gui/build.py @@ -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:
%s" % ( diff --git a/nw/gui/docsplit.py b/nw/gui/docsplit.py index 376eaf3a..8c3c4897 100644 --- a/nw/gui/docsplit.py +++ b/nw/gui/docsplit.py @@ -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", ( diff --git a/nw/gui/preferences.py b/nw/gui/preferences.py index e0490f1a..eca12735 100644 --- a/nw/gui/preferences.py +++ b/nw/gui/preferences.py @@ -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", diff --git a/nw/gui/projload.py b/nw/gui/projload.py index e8aed721..c21fc84c 100644 --- a/nw/gui/projload.py +++ b/nw/gui/projload.py @@ -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", diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py index 0a9c3905..db1aa626 100644 --- a/nw/gui/projtree.py +++ b/nw/gui/projtree.py @@ -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 diff --git a/nw/gui/writingstats.py b/nw/gui/writingstats.py index 27767916..91391ee3 100644 --- a/nw/gui/writingstats.py +++ b/nw/gui/writingstats.py @@ -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:
%s" % ( diff --git a/nw/guimain.py b/nw/guimain.py index 0da4f5a0..2182ab9c 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -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 = ( "

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?" diff --git a/tests/test_dialogs.py b/tests/test_dialogs.py index 07f64e8b..8acb3a9c 100644 --- a/tests/test_dialogs.py +++ b/tests/test_dialogs.py @@ -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