Changed how the application name is passed around
This commit is contained in:
+10
-11
@@ -37,7 +37,6 @@ from PyQt5.QtWidgets import QApplication, QErrorMessage
|
||||
from nw.config import Config
|
||||
|
||||
__package__ = "nw"
|
||||
__appname__ = "novelWriter"
|
||||
__author__ = "Veronica Berglyd Olsen"
|
||||
__copyright__ = "Copyright 2018–2020, Veronica Berglyd Olsen"
|
||||
__license__ = "GPLv3"
|
||||
@@ -46,7 +45,7 @@ __hexversion__ = "0x001002f0"
|
||||
__date__ = "2020-07-29"
|
||||
__maintainer__ = "Veronica Berglyd Olsen"
|
||||
__email__ = "code@vkbo.net"
|
||||
__status__ = "Pre-Release"
|
||||
__status__ = "Beta"
|
||||
__url__ = "https://github.com/vkbo/novelWriter"
|
||||
__issuesurl__ = "https://github.com/vkbo/novelWriter/issues"
|
||||
__domain__ = "novelwriter.io"
|
||||
@@ -91,7 +90,6 @@ CONFIG = Config()
|
||||
def main(sysArgs=None):
|
||||
"""Parses command line, sets up logging, and launches main GUI.
|
||||
"""
|
||||
|
||||
if sysArgs is None:
|
||||
sysArgs = sys.argv[1:]
|
||||
|
||||
@@ -112,7 +110,7 @@ def main(sysArgs=None):
|
||||
]
|
||||
|
||||
helpMsg = (
|
||||
"{appname} {version} ({status} {date})\n"
|
||||
"novelWriter {version} ({status} {date})\n"
|
||||
"{copyright}\n"
|
||||
"\n"
|
||||
"This program is distributed in the hope that it will be useful,\n"
|
||||
@@ -133,7 +131,6 @@ def main(sysArgs=None):
|
||||
" --data= Alternative user data path.\n"
|
||||
" --testmode Do not display GUI. Used by the test suite.\n"
|
||||
).format(
|
||||
appname = __appname__,
|
||||
version = __version__,
|
||||
status = __status__,
|
||||
copyright = __copyright__,
|
||||
@@ -168,7 +165,9 @@ def main(sysArgs=None):
|
||||
print(helpMsg)
|
||||
sys.exit()
|
||||
elif inOpt in ("-v", "--version"):
|
||||
print("%s %s Version %s [%s]" % (__appname__,__status__,__version__,__date__))
|
||||
print("%s %s Version %s [%s]" % (
|
||||
CONFIG.appName, __status__, __version__, __date__)
|
||||
)
|
||||
sys.exit()
|
||||
elif inOpt == "--info":
|
||||
debugLevel = logging.INFO
|
||||
@@ -219,7 +218,7 @@ def main(sysArgs=None):
|
||||
|
||||
logger.setLevel(debugLevel)
|
||||
logger.info("Starting %s %s (%s) %s" % (
|
||||
__appname__, __version__, __hexversion__, __date__
|
||||
CONFIG.appName, __version__, __hexversion__, __date__
|
||||
))
|
||||
|
||||
# Check Packages and Versions
|
||||
@@ -256,7 +255,7 @@ def main(sysArgs=None):
|
||||
"ERROR: %s cannot start due to the following issues:<br><br>"
|
||||
" - %s<br><br>Exiting."
|
||||
) % (
|
||||
__appname__, "<br> - ".join(errorData)
|
||||
CONFIG.appName, "<br> - ".join(errorData)
|
||||
))
|
||||
errApp.exec_()
|
||||
sys.exit(1)
|
||||
@@ -270,11 +269,11 @@ def main(sysArgs=None):
|
||||
nwGUI = GuiMain()
|
||||
return nwGUI
|
||||
else:
|
||||
nwApp = QApplication([__appname__,("-style=%s" % qtStyle)])
|
||||
nwApp.setApplicationName(__appname__)
|
||||
nwApp = QApplication([CONFIG.appName, ("-style=%s" % qtStyle)])
|
||||
nwApp.setApplicationName(CONFIG.appName)
|
||||
nwApp.setApplicationVersion(__version__)
|
||||
nwApp.setWindowIcon(QIcon(CONFIG.appIcon))
|
||||
nwApp.setOrganizationDomain("novelwriter.io")
|
||||
nwApp.setOrganizationDomain(__domain__)
|
||||
nwGUI = GuiMain()
|
||||
sys.exit(nwApp.exec_())
|
||||
|
||||
|
||||
+2
-2
@@ -52,8 +52,8 @@ class Config:
|
||||
def __init__(self):
|
||||
|
||||
# Set Application Variables
|
||||
self.appName = nw.__appname__
|
||||
self.appHandle = nw.__appname__.lower()
|
||||
self.appName = "novelWriter"
|
||||
self.appHandle = self.appName.lower()
|
||||
self.showGUI = True
|
||||
self.debugInfo = False
|
||||
self.cmdOpen = None
|
||||
|
||||
+12
-14
@@ -368,23 +368,21 @@ class NWProject():
|
||||
if fileVersion == "1.0":
|
||||
msgBox = QMessageBox()
|
||||
msgRes = msgBox.question(self.theParent, "Old Project Version", (
|
||||
"The project file and data is created by a %s version lower than 0.7. "
|
||||
"Do you want to upgrade the project to the most recent format?<br><br>"
|
||||
"Note that after the upgrade, you cannot open the project with an older "
|
||||
"version of %s any more, so make sure you have a recent backup."
|
||||
) % (
|
||||
nw.__appname__, nw.__appname__
|
||||
"The project file and data is created by a novelWriter version "
|
||||
"lower than 0.7. Do you want to upgrade the project to the "
|
||||
"most recent format?<br><br>Note that after the upgrade, you "
|
||||
"cannot open the project with an older version of novelWriter "
|
||||
"any more, so make sure you have a recent backup."
|
||||
))
|
||||
if msgRes != QMessageBox.Yes:
|
||||
return False
|
||||
|
||||
elif fileVersion != "1.1" and fileVersion != "1.2":
|
||||
self.makeAlert((
|
||||
"Unknown or unsupported {nw:s} project file format. "
|
||||
"The project cannot be opened by this version of {nw:s}. "
|
||||
"The file was saved with {nw:s} version {vers:s}."
|
||||
"Unknown or unsupported novelWriter project file format. "
|
||||
"The project cannot be opened by this version of novelWriter. "
|
||||
"The file was saved with novelWriter version {vers:s}."
|
||||
).format(
|
||||
nw = nw.__appname__,
|
||||
vers = appVersion,
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
@@ -395,11 +393,11 @@ class NWProject():
|
||||
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?"
|
||||
"This project was saved by a newer version of novelWriter, 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.__appname__, appVersion, nw.__version__
|
||||
appVersion, nw.__version__
|
||||
))
|
||||
if msgRes != QMessageBox.Yes:
|
||||
return False
|
||||
|
||||
+3
-3
@@ -54,13 +54,13 @@ class GuiAbout(QDialog):
|
||||
self.innerBox = QHBoxLayout()
|
||||
self.innerBox.setSpacing(self.mainConf.pxInt(16))
|
||||
|
||||
self.setWindowTitle("About %s" % nw.__appname__)
|
||||
self.setWindowTitle("About %s" % self.mainConf.appName)
|
||||
self.setMinimumWidth(self.mainConf.pxInt(650))
|
||||
self.setMinimumHeight(self.mainConf.pxInt(600))
|
||||
|
||||
iPx = self.mainConf.pxInt(96)
|
||||
self.guiDeco = self.theParent.theTheme.loadDecoration("nwicon", (iPx, iPx))
|
||||
self.lblName = QLabel("<b>%s</b>" % nw.__appname__)
|
||||
self.lblName = QLabel("<b>%s</b>" % self.mainConf.appName)
|
||||
self.lblVers = QLabel("v%s" % nw.__version__)
|
||||
self.lblDate = QLabel(datetime.strptime(nw.__date__, "%Y-%m-%d").strftime("%x"))
|
||||
|
||||
@@ -132,7 +132,7 @@ class GuiAbout(QDialog):
|
||||
"<h3>Credits</h3>"
|
||||
"<p>{credits:s}</p>"
|
||||
).format(
|
||||
name = nw.__appname__,
|
||||
name = self.mainConf.appName,
|
||||
copyright = nw.__copyright__,
|
||||
website = nw.__url__,
|
||||
domain = nw.__domain__,
|
||||
|
||||
+3
-3
@@ -258,7 +258,7 @@ class GuiMainMenu(QMenuBar):
|
||||
|
||||
# Project > Exit
|
||||
self.aExitNW = QAction("Exit", self)
|
||||
self.aExitNW.setStatusTip("Exit %s" % nw.__appname__)
|
||||
self.aExitNW.setStatusTip("Exit %s" % self.mainConf.appName)
|
||||
self.aExitNW.setShortcut("Ctrl+Q")
|
||||
self.aExitNW.triggered.connect(self._menuExit)
|
||||
self.projMenu.addAction(self.aExitNW)
|
||||
@@ -804,8 +804,8 @@ class GuiMainMenu(QMenuBar):
|
||||
self.helpMenu = self.addMenu("&Help")
|
||||
|
||||
# Help > About
|
||||
self.aAboutNW = QAction("About %s" % nw.__appname__, self)
|
||||
self.aAboutNW.setStatusTip("About %s" % nw.__appname__)
|
||||
self.aAboutNW = QAction("About %s" % self.mainConf.appName, self)
|
||||
self.aAboutNW.setStatusTip("About %s" % self.mainConf.appName)
|
||||
self.aAboutNW.triggered.connect(self._showAbout)
|
||||
self.helpMenu.addAction(self.aAboutNW)
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ class GuiPreferences(PagedDialog):
|
||||
msgBox = QMessageBox()
|
||||
msgBox.information(
|
||||
self, "Preferences",
|
||||
"Some changes will not be applied until %s has been restarted." % nw.__appname__
|
||||
"Some changes will not be applied until novelWriter has been restarted."
|
||||
)
|
||||
|
||||
if validEntries:
|
||||
@@ -154,7 +154,7 @@ class GuiConfigEditGeneralTab(QWidget):
|
||||
self.mainForm.addRow(
|
||||
"Main GUI theme",
|
||||
self.selectTheme,
|
||||
"Changing this requires restarting %s." % nw.__appname__
|
||||
"Changing this requires restarting novelWriter."
|
||||
)
|
||||
|
||||
## Select Icon Theme
|
||||
@@ -170,7 +170,7 @@ class GuiConfigEditGeneralTab(QWidget):
|
||||
self.mainForm.addRow(
|
||||
"Main icon theme",
|
||||
self.selectIcons,
|
||||
"Changing this requires restarting %s." % nw.__appname__
|
||||
"Changing this requires restarting novelWriter."
|
||||
)
|
||||
|
||||
## Dark Icons
|
||||
@@ -193,7 +193,7 @@ class GuiConfigEditGeneralTab(QWidget):
|
||||
self.mainForm.addRow(
|
||||
"Font family",
|
||||
self.guiFont,
|
||||
"Changing this requires restarting %s." % nw.__appname__,
|
||||
"Changing this requires restarting novelWriter.",
|
||||
theButton = self.fontButton
|
||||
)
|
||||
|
||||
@@ -206,7 +206,7 @@ class GuiConfigEditGeneralTab(QWidget):
|
||||
self.mainForm.addRow(
|
||||
"Font size",
|
||||
self.guiFontSize,
|
||||
"Changing this requires restarting %s." % nw.__appname__,
|
||||
"Changing this requires restarting novelWriter.",
|
||||
theUnit = "pt"
|
||||
)
|
||||
|
||||
|
||||
+11
-11
@@ -45,8 +45,8 @@ from nw.gui import (
|
||||
GuiOutline, GuiOutlineDetails, GuiPreferences, GuiProjectLoad, GuiTheme,
|
||||
GuiProjectSettings, GuiProjectTree, GuiWritingStats
|
||||
)
|
||||
from .core import NWProject, NWDoc, NWIndex
|
||||
from .constants import nwFiles, nwItemType, nwAlert
|
||||
from nw.core import NWProject, NWDoc, NWIndex
|
||||
from nw.constants import nwFiles, nwItemType, nwAlert
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -220,7 +220,7 @@ class GuiMain(QMainWindow):
|
||||
else:
|
||||
self.manageProjects()
|
||||
|
||||
logger.debug("%s is ready ..." % nw.__appname__)
|
||||
logger.debug("novelWriter is ready ...")
|
||||
|
||||
return
|
||||
|
||||
@@ -384,13 +384,13 @@ class GuiMain(QMainWindow):
|
||||
msgBox = QMessageBox()
|
||||
msgRes = msgBox.warning(
|
||||
self, "Project Locked", (
|
||||
"The project is already open by another instance of %s, and is "
|
||||
"therefore locked. Override lock and continue anyway?<br><br>"
|
||||
"The project is already open by another instance of novelWriter, and "
|
||||
"is therefore locked. Override lock and continue anyway?<br><br>"
|
||||
"Note: If the program or the computer previously crashed, the lock "
|
||||
"can safely be overridden. If, however, another instance of %s has "
|
||||
"the project open, overriding the lock may corrupt the project, and "
|
||||
"is not recommended.%s"
|
||||
) % (nw.__appname__, nw.__appname__, lockDetails),
|
||||
"can safely be overridden. If, however, another instance of "
|
||||
"novelWriter has the project open, overriding the lock may corrupt "
|
||||
"the project, and is not recommended.%s"
|
||||
) % lockDetails,
|
||||
QMessageBox.Yes | QMessageBox.No, QMessageBox.No
|
||||
)
|
||||
if msgRes == QMessageBox.Yes:
|
||||
@@ -872,7 +872,7 @@ class GuiMain(QMainWindow):
|
||||
if msgRes != QMessageBox.Yes:
|
||||
return False
|
||||
|
||||
logger.info("Exiting %s" % nw.__appname__)
|
||||
logger.info("Exiting novelWriter")
|
||||
|
||||
if not self.isFocusMode:
|
||||
self.mainConf.setMainPanePos(self.splitMain.sizes())
|
||||
@@ -1037,7 +1037,7 @@ class GuiMain(QMainWindow):
|
||||
return True
|
||||
|
||||
def _setWindowTitle(self, projName=None):
|
||||
winTitle = "%s" % nw.__appname__
|
||||
winTitle = self.mainConf.appName
|
||||
if projName is not None:
|
||||
winTitle += " - %s" % projName
|
||||
self.setWindowTitle(winTitle)
|
||||
|
||||
Reference in New Issue
Block a user