diff --git a/nw/__init__.py b/nw/__init__.py index 85b5cab4..3330c6b6 100644 --- a/nw/__init__.py +++ b/nw/__init__.py @@ -41,6 +41,7 @@ __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" diff --git a/nw/core/project.py b/nw/core/project.py index 23fa2c24..be9cc131 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 @@ -294,12 +296,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: @@ -317,6 +322,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") @@ -411,6 +428,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 97d54bc9..9e0468e6 100644 --- a/sample/sampleNovel/nwProject.nwx +++ b/sample/sampleNovel/nwProject.nwx @@ -1,5 +1,5 @@ - + Sample Project Sample Project