Drop the showGUI debug flag, removing test mode from beyond the main function

This commit is contained in:
Veronica K. B. Olsen
2021-01-18 18:55:32 +01:00
parent 91d96b162e
commit 92da954229
4 changed files with 36 additions and 33 deletions
+23 -21
View File
@@ -35,16 +35,16 @@ from PyQt5.QtWidgets import QApplication, QErrorMessage
from nw.error import exceptionHandler
from nw.config import Config
#
##
# Version Scheme
# ================
# Generally follows PEP 440
# Hex Version:
# - Digit 1,2 : Major Version (01, 02, 03)
# = Digit 3,4 : Minor Version (01, 09, 10, 99)
# - Digit 5,6 : Patch Version (01, 09, 10, 99)
# - Digit 1,2 : Major Version (01-ff)
# = Digit 3,4 : Minor Version (01-ff)
# - Digit 5,6 : Patch Version (01-ff)
# = Digit 7 : Release Type (a: aplha, b: beta, c: candidate, f: final)
# - Digit 8 : Release Number (0-9)
# - Digit 8 : Release Number (0-f)
#
# Example : Full Short Description
# -------------------------------------------------------------------------
@@ -55,7 +55,7 @@ from nw.config import Config
# 0x010200f0 : 1.2 1.2 Final release
# 0x010200f1 : 1.2-post1 1.2.post1 Post release, but not a code patch!
# 0x010201f0 : 1.2.1 1.2.1 Patch release
#
##
__package__ = "nw"
__copyright__ = "Copyright 20182021, Veronica Berglyd Olsen"
@@ -79,7 +79,7 @@ __credits__ = [
"Marian Lückhof (contributor, tester)"
]
#
##
# Logging
# =========
# Standard used for logging levels in novelWriter:
@@ -90,7 +90,7 @@ __credits__ = [
# ----------- SPAM Threshold : Output above should be minimal -----------------
# DEBUG Use for descriptions of main program flow
# VERBOSE Use for outputting values and program flow details
#
##
# Add verbose logging level
VERBOSE = 5
@@ -104,10 +104,9 @@ logging.Logger.verbose = logVerbose
# Initiating logging
logger = logging.getLogger(__name__)
#
##
# Main Program
# ==============
#
##
# Load the main config as a global object
CONFIG = Config()
@@ -142,15 +141,14 @@ def main(sysArgs=None):
"GNU General Public License for more details.\n"
"\n"
"Usage:\n"
" -h, --help Print this message.\n"
" -v, --version Print program version and exit.\n"
" --info Print additional runtime information.\n"
" --debug Print debug output. Includes --info.\n"
" --verbose Increase verbosity of debug output. Includes --debug.\n"
" --style= Sets Qt5 style flag. Defaults to 'Fusion'.\n"
" --config= Alternative config file.\n"
" --data= Alternative user data path.\n"
" --testmode Do not display GUI. Used by the test suite.\n"
" -h, --help Print this message.\n"
" -v, --version Print program version and exit.\n"
" --info Print additional runtime information.\n"
" --debug Print debug output. Includes --info.\n"
" --verbose Increase verbosity of debug output. Includes --debug.\n"
" --style= Sets Qt5 style flag. Defaults to 'Fusion'.\n"
" --config= Alternative config file.\n"
" --data= Alternative user data path.\n"
).format(
version = __version__,
status = __status__,
@@ -205,7 +203,6 @@ def main(sysArgs=None):
testMode = True
# Set Config Options
CONFIG.showGUI = not testMode
CONFIG.debugInfo = debugLevel < logging.INFO
CONFIG.cmdOpen = cmdOpen
@@ -292,7 +289,12 @@ def main(sysArgs=None):
# Connect the exception handler before making the main GUI
sys.excepthook = exceptionHandler
# Launch main GUI
nwGUI = GuiMain()
if not nwGUI.hasProject:
nwGUI.showProjectLoadDialog()
nwGUI.releaseNotes()
sys.exit(nwApp.exec_())
# END Function main
-1
View File
@@ -56,7 +56,6 @@ class Config:
self.appHandle = self.appName.lower()
# Debug Settings
self.showGUI = True # Allow blocking the GUI (disabled for testing)
self.debugInfo = False # True if log level is DEBUG or VERBOSE
# Config Error Handling
+10 -11
View File
@@ -275,20 +275,10 @@ class GuiMain(QMainWindow):
logger.debug("GUI initialisation complete")
# Check if a project path was provided at command line, and if
# not, open the project manager instead.
# If a project path was provided at command line, open it
if self.mainConf.cmdOpen is not None:
logger.debug("Opening project from additional command line option")
self.openProject(self.mainConf.cmdOpen)
else:
if self.mainConf.showGUI:
self.showProjectLoadDialog()
# Show the latest release notes, if they haven't been shown before
if hexToInt(self.mainConf.lastNotes) < hexToInt(nw.__hexversion__):
if self.mainConf.showGUI:
self.showAboutNWDialog(showNotes=True)
self.mainConf.lastNotes = nw.__hexversion__
logger.debug("novelWriter is ready ...")
self.setStatus("novelWriter is ready ...")
@@ -322,6 +312,15 @@ class GuiMain(QMainWindow):
self.asDocTimer.setInterval(int(self.mainConf.autoSaveDoc*1000))
return True
def releaseNotes(self):
"""Determine whether release notes need to be shown, and show
them by calling the About dialog.
"""
if hexToInt(self.mainConf.lastNotes) < hexToInt(nw.__hexversion__):
self.mainConf.lastNotes = nw.__hexversion__
self.showAboutNWDialog(showNotes=True)
return
##
# Project Actions
##
+3
View File
@@ -21,6 +21,9 @@ class DummyMain():
return
def releaseNotes(self):
return
def makeAlert(self, theMessage, theLevel):
print("%s: %s" % (str(theLevel), theMessage))
self.lastAlert = str(theMessage)