Some changes to core classes and files to support the test suite

This commit is contained in:
Veronica K. B. Olsen
2019-05-12 13:29:41 +02:00
parent 223db59e3d
commit edab608c3b
3 changed files with 16 additions and 9 deletions
+4 -3
View File
@@ -62,7 +62,6 @@ logger = logging.getLogger(__name__)
# Load the main config as a global object
CONFIG = Config()
CONFIG.initConfig()
def main(sysArgs):
"""Parses command line, sets up logging, and launches main GUI.
@@ -149,10 +148,10 @@ def main(sysArgs):
showGUI = False
elif inOpt in ("-D","--debuggui"):
debugLevel = logging.DEBUG
debugStr = "{name:>22}:{lineno:<4d} {levelname:8} {message:}"
debugStr = "{name:>20}:{lineno:<4d} {levelname:8} {message:}"
debugGUI = True
# Set GUI options
# Set Config Options
CONFIG.showGUI = showGUI
CONFIG.debugGUI = debugGUI
@@ -179,6 +178,8 @@ def main(sysArgs):
logger.setLevel(debugLevel)
CONFIG.initConfig(confPath)
nwApp = QApplication([])
nwGUI = NovelWriter()
exit(nwApp.exec_())
+10 -5
View File
@@ -88,6 +88,7 @@ class Config:
if confPath is None:
self.confPath = user_config_dir(self.appHandle)
else:
logger.info("Setting config from alternative path: %s" % confPath)
self.confPath = confPath
self.confFile = self.appHandle+".conf"
@@ -110,13 +111,13 @@ class Config:
# If it does not exist, save a copy of the defaults
self.saveConfig()
return
return True
def loadConfig(self):
logger.debug("Loading config file")
confParser = configparser.ConfigParser()
confParser.readfp(open(path.join(self.confPath,self.confFile)))
confParser.read_file(open(path.join(self.confPath,self.confFile)))
# Get options
@@ -231,10 +232,14 @@ class Config:
confParser.set(cnfSec,"recent%d" % i, str(self.recentList[i]))
# Write config file
confParser.write(open(path.join(self.confPath,self.confFile),"w"))
self.confChanged = False
try:
confParser.write(open(path.join(self.confPath,self.confFile),"w"))
self.confChanged = False
except Exception as e:
logger.error("Could not save config file")
return False
return
return True
def unpackList(self, inStr, listLen, listDefault, castTo=int):
inData = inStr.split(",")
+2 -1
View File
@@ -106,7 +106,8 @@ class GuiMain(QMainWindow):
self.asDocTimer.timeout.connect(self._autoSaveDocument)
self.asDocTimer.start()
self.show()
if self.mainConf.showGUI:
self.show()
logger.debug("GUI initialisation complete")