diff --git a/nw/__init__.py b/nw/__init__.py index 8c5199d9..3330c6b6 100644 --- a/nw/__init__.py +++ b/nw/__init__.py @@ -41,10 +41,11 @@ __author__ = "Veronica Berglyd Olsen" __copyright__ = "Copyright 2018–2020, Veronica Berglyd Olsen" __license__ = "GPLv3" __version__ = "0.5" +__hexversion__ = "0x000500f0" __date__ = "2020-05-09" __maintainer__ = "Veronica Berglyd Olsen" __email__ = "code@vkbo.net" -__status__ = "Development" +__status__ = "Pre-Release" __url__ = "https://github.com/vkbo/novelWriter" __docurl__ = "https://novelwriter.readthedocs.io" __credits__ = [ @@ -92,7 +93,7 @@ def main(sysArgs=None): sysArgs = sys.argv[1:] # Valid Input Options - shortOpt = "hidvql:" + shortOpt = "hvq" longOpt = [ "help", "version", @@ -108,7 +109,7 @@ def main(sysArgs=None): ] helpMsg = ( - "{appname} {version} ({status})\n" + "{appname} {version} ({status} {date})\n" "{copyright}\n" "\n" "This program is distributed in the hope that it will be useful,\n" @@ -118,12 +119,12 @@ def main(sysArgs=None): "\n" "Usage:\n" " -h, --help Print this message.\n" - " --version Print program version and exit.\n" - " -i, --info Print additional runtime information.\n" - " -d, --debug Print debug output. Includes -i.\n" - " -v, --verbose Increase verbosity of debug output. Includes -d.\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" " -q, --quiet Disable output to command line. Does not affect log file.\n" - " -l, --logfile= Specify log file.\n" + " --logfile= Specify log file.\n" " --style= Sets Qt5 style flag. Defaults to 'Fusion'.\n" " --config= Alternative config file.\n" " --data= Alternative user data path.\n" @@ -132,7 +133,8 @@ def main(sysArgs=None): appname = __package__, version = __version__, status = __status__, - copyright = __copyright__ + copyright = __copyright__, + date = __date__, ) # Defaults @@ -162,20 +164,20 @@ def main(sysArgs=None): if inOpt in ("-h","--help"): print(helpMsg) sys.exit() - elif inOpt == "--version": - print("%s %s Version %s" % (__package__,__status__,__version__)) + elif inOpt in ("-v", "--version"): + print("%s %s Version %s [%s]" % (__package__,__status__,__version__,__date__)) sys.exit() - elif inOpt in ("-i", "--info"): + elif inOpt == "--info": debugLevel = logging.INFO - elif inOpt in ("-d", "--debug"): + elif inOpt == "--debug": debugLevel = logging.DEBUG logFormat = "[{asctime:}] {name:>30}:{lineno:<4d} {levelname:8} {message:}" - elif inOpt in ("-l","--logfile"): + elif inOpt == "--logfile": logFile = inArg toFile = True elif inOpt in ("-q","--quiet"): toStd = False - elif inOpt in ("-v","--verbose"): + elif inOpt == "--verbose": debugLevel = VERBOSE logFormat = "[{asctime:}] {name:>30}:{lineno:<4d} {levelname:8} {message:}" elif inOpt == "--style": diff --git a/nw/config.py b/nw/config.py index f0f21f32..4fb8278e 100644 --- a/nw/config.py +++ b/nw/config.py @@ -227,6 +227,9 @@ class Config: self.iconPath = path.join(self.assetPath,"icons") self.appIcon = path.join(self.iconPath, nwFiles.APP_ICON) + logger.verbose("App path: %s" % self.appPath) + logger.verbose("Home path: %s" % self.homePath) + # If config folder does not exist, make it. # This assumes that the os config folder itself exists. if not path.isdir(self.confPath): diff --git a/nw/core/project.py b/nw/core/project.py index ca1d7a55..4a74e0d0 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -39,6 +39,8 @@ from hashlib import sha256 from time import time from shutil import make_archive +from PyQt5.QtWidgets import QMessageBox + from nw.gui.tools import OptionState from nw.core.tools import projectMaintenance from nw.core.document import NWDoc @@ -285,12 +287,15 @@ class NWProject(): nwxRoot = xRoot.tag appVersion = "Unknown" + hexVersion = "0x0" fileVersion = "Unknown" self.saveCount = 0 self.autoCount = 0 if "appVersion" in xRoot.attrib: appVersion = xRoot.attrib["appVersion"] + if "hexVersion" in xRoot.attrib: + hexVersion = xRoot.attrib["hexVersion"] if "fileVersion" in xRoot.attrib: fileVersion = xRoot.attrib["fileVersion"] if "saveCount" in xRoot.attrib: @@ -308,6 +313,18 @@ class NWProject(): ) return False + if int(hexVersion, 16) > int(nw.__hexversion__, 16) and self.mainConf.showGUI: + msgBox = QMessageBox() + msgRes = msgBox.question(self.theParent, "Version Conflict", ( + "This project was saved by a newer version of %s, version %s. This is version %s. " + "If you continue to open the project, some attributes and settings may not be " + "preserved. Continue opening the project?" + ) % ( + nw.__package__, appVersion, nw.__version__ + )) + if msgRes != QMessageBox.Yes: + return False + for xChild in xRoot: if xChild.tag == "project": logger.debug("Found project meta") @@ -397,6 +414,7 @@ class NWProject(): logger.debug("Writing project meta") nwXML = etree.Element("novelWriterXML",attrib={ "appVersion" : str(nw.__version__), + "hexVersion" : str(nw.__hexversion__), "fileVersion" : "1.0", "saveCount" : str(self.saveCount), "autoCount" : str(self.autoCount), diff --git a/sample/sampleNovel/nwProject.nwx b/sample/sampleNovel/nwProject.nwx index a452021d..ad764dec 100644 --- a/sample/sampleNovel/nwProject.nwx +++ b/sample/sampleNovel/nwProject.nwx @@ -1,5 +1,5 @@ - + Sample Project Sample Project