Merge pull request #205 from vkbo/fixes

Fixes and Updates for 0.5
This commit is contained in:
Veronica K. Berglyd Olsen
2020-05-12 19:59:39 +02:00
committed by GitHub
4 changed files with 39 additions and 16 deletions
+17 -15
View File
@@ -41,10 +41,11 @@ __author__ = "Veronica Berglyd Olsen"
__copyright__ = "Copyright 20182020, 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":
+3
View File
@@ -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):
+18
View File
@@ -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),
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="0.4.5" fileVersion="1.0" saveCount="127" autoCount="17" timeStamp="2020-05-09 16:03:23">
<novelWriterXML appVersion="0.5" hexVersion="0x000500f0" fileVersion="1.0" saveCount="130" autoCount="17" timeStamp="2020-05-11 19:23:21">
<project>
<name>Sample Project</name>
<title>Sample Project</title>