Set __package__ to nw and added variable __appname__

This commit is contained in:
Veronica K. B. Olsen
2020-07-31 14:48:37 +02:00
parent f5cc67d33f
commit 02f85bd5d7
7 changed files with 30 additions and 29 deletions
+8 -7
View File
@@ -36,7 +36,8 @@ from PyQt5.QtWidgets import QApplication, QErrorMessage
from nw.config import Config from nw.config import Config
__package__ = "novelWriter" __package__ = "nw"
__appname__ = "novelWriter"
__author__ = "Veronica Berglyd Olsen" __author__ = "Veronica Berglyd Olsen"
__copyright__ = "Copyright 20182020, Veronica Berglyd Olsen" __copyright__ = "Copyright 20182020, Veronica Berglyd Olsen"
__license__ = "GPLv3" __license__ = "GPLv3"
@@ -132,7 +133,7 @@ def main(sysArgs=None):
" --data= Alternative user data path.\n" " --data= Alternative user data path.\n"
" --testmode Do not display GUI. Used by the test suite.\n" " --testmode Do not display GUI. Used by the test suite.\n"
).format( ).format(
appname = __package__, appname = __appname__,
version = __version__, version = __version__,
status = __status__, status = __status__,
copyright = __copyright__, copyright = __copyright__,
@@ -167,7 +168,7 @@ def main(sysArgs=None):
print(helpMsg) print(helpMsg)
sys.exit() sys.exit()
elif inOpt in ("-v", "--version"): elif inOpt in ("-v", "--version"):
print("%s %s Version %s [%s]" % (__package__,__status__,__version__,__date__)) print("%s %s Version %s [%s]" % (__appname__,__status__,__version__,__date__))
sys.exit() sys.exit()
elif inOpt == "--info": elif inOpt == "--info":
debugLevel = logging.INFO debugLevel = logging.INFO
@@ -218,7 +219,7 @@ def main(sysArgs=None):
logger.setLevel(debugLevel) logger.setLevel(debugLevel)
logger.info("Starting %s %s (%s) %s" % ( logger.info("Starting %s %s (%s) %s" % (
__package__, __version__, __hexversion__, __date__ __appname__, __version__, __hexversion__, __date__
)) ))
# Check Packages and Versions # Check Packages and Versions
@@ -255,7 +256,7 @@ def main(sysArgs=None):
"ERROR: %s cannot start due to the following issues:<br><br>" "ERROR: %s cannot start due to the following issues:<br><br>"
"&nbsp;-&nbsp;%s<br><br>Exiting." "&nbsp;-&nbsp;%s<br><br>Exiting."
) % ( ) % (
__package__, "<br>&nbsp;-&nbsp;".join(errorData) __appname__, "<br>&nbsp;-&nbsp;".join(errorData)
)) ))
errApp.exec_() errApp.exec_()
sys.exit(1) sys.exit(1)
@@ -269,8 +270,8 @@ def main(sysArgs=None):
nwGUI = GuiMain() nwGUI = GuiMain()
return nwGUI return nwGUI
else: else:
nwApp = QApplication([__package__,("-style=%s" % qtStyle)]) nwApp = QApplication([__appname__,("-style=%s" % qtStyle)])
nwApp.setApplicationName(__package__) nwApp.setApplicationName(__appname__)
nwApp.setApplicationVersion(__version__) nwApp.setApplicationVersion(__version__)
nwApp.setWindowIcon(QIcon(CONFIG.appIcon)) nwApp.setWindowIcon(QIcon(CONFIG.appIcon))
nwApp.setOrganizationDomain("novelwriter.io") nwApp.setOrganizationDomain("novelwriter.io")
+2 -2
View File
@@ -52,8 +52,8 @@ class Config:
def __init__(self): def __init__(self):
# Set Application Variables # Set Application Variables
self.appName = nw.__package__ self.appName = nw.__appname__
self.appHandle = nw.__package__.lower() self.appHandle = nw.__appname__.lower()
self.showGUI = True self.showGUI = True
self.debugInfo = False self.debugInfo = False
self.cmdOpen = None self.cmdOpen = None
+3 -3
View File
@@ -373,7 +373,7 @@ class NWProject():
"Note that after the upgrade, you cannot open the project with an older " "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." "version of %s any more, so make sure you have a recent backup."
) % ( ) % (
nw.__package__, nw.__package__ nw.__appname__, nw.__appname__
)) ))
if msgRes != QMessageBox.Yes: if msgRes != QMessageBox.Yes:
return False return False
@@ -384,7 +384,7 @@ class NWProject():
"The project cannot be opened by this version of {nw:s}. " "The project cannot be opened by this version of {nw:s}. "
"The file was saved with {nw:s} version {vers:s}." "The file was saved with {nw:s} version {vers:s}."
).format( ).format(
nw = nw.__package__, nw = nw.__appname__,
vers = appVersion, vers = appVersion,
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
@@ -399,7 +399,7 @@ class NWProject():
"If you continue to open the project, some attributes and settings may not be " "If you continue to open the project, some attributes and settings may not be "
"preserved. Continue opening the project?" "preserved. Continue opening the project?"
) % ( ) % (
nw.__package__, appVersion, nw.__version__ nw.__appname__, appVersion, nw.__version__
)) ))
if msgRes != QMessageBox.Yes: if msgRes != QMessageBox.Yes:
return False return False
+3 -3
View File
@@ -54,13 +54,13 @@ class GuiAbout(QDialog):
self.innerBox = QHBoxLayout() self.innerBox = QHBoxLayout()
self.innerBox.setSpacing(self.mainConf.pxInt(16)) self.innerBox.setSpacing(self.mainConf.pxInt(16))
self.setWindowTitle("About %s" % nw.__package__) self.setWindowTitle("About %s" % nw.__appname__)
self.setMinimumWidth(self.mainConf.pxInt(650)) self.setMinimumWidth(self.mainConf.pxInt(650))
self.setMinimumHeight(self.mainConf.pxInt(600)) self.setMinimumHeight(self.mainConf.pxInt(600))
iPx = self.mainConf.pxInt(96) iPx = self.mainConf.pxInt(96)
self.guiDeco = self.theParent.theTheme.loadDecoration("nwicon", (iPx, iPx)) self.guiDeco = self.theParent.theTheme.loadDecoration("nwicon", (iPx, iPx))
self.lblName = QLabel("<b>%s</b>" % nw.__package__) self.lblName = QLabel("<b>%s</b>" % nw.__appname__)
self.lblVers = QLabel("v%s" % nw.__version__) self.lblVers = QLabel("v%s" % nw.__version__)
self.lblDate = QLabel(datetime.strptime(nw.__date__, "%Y-%m-%d").strftime("%x")) self.lblDate = QLabel(datetime.strptime(nw.__date__, "%Y-%m-%d").strftime("%x"))
@@ -132,7 +132,7 @@ class GuiAbout(QDialog):
"<h3>Credits</h3>" "<h3>Credits</h3>"
"<p>{credits:s}</p>" "<p>{credits:s}</p>"
).format( ).format(
name = nw.__package__, name = nw.__appname__,
copyright = nw.__copyright__, copyright = nw.__copyright__,
website = nw.__url__, website = nw.__url__,
domain = nw.__domain__, domain = nw.__domain__,
+3 -3
View File
@@ -258,7 +258,7 @@ class GuiMainMenu(QMenuBar):
# Project > Exit # Project > Exit
self.aExitNW = QAction("Exit", self) self.aExitNW = QAction("Exit", self)
self.aExitNW.setStatusTip("Exit %s" % nw.__package__) self.aExitNW.setStatusTip("Exit %s" % nw.__appname__)
self.aExitNW.setShortcut("Ctrl+Q") self.aExitNW.setShortcut("Ctrl+Q")
self.aExitNW.triggered.connect(self._menuExit) self.aExitNW.triggered.connect(self._menuExit)
self.projMenu.addAction(self.aExitNW) self.projMenu.addAction(self.aExitNW)
@@ -804,8 +804,8 @@ class GuiMainMenu(QMenuBar):
self.helpMenu = self.addMenu("&Help") self.helpMenu = self.addMenu("&Help")
# Help > About # Help > About
self.aAboutNW = QAction("About %s" % nw.__package__, self) self.aAboutNW = QAction("About %s" % nw.__appname__, self)
self.aAboutNW.setStatusTip("About %s" % nw.__package__) self.aAboutNW.setStatusTip("About %s" % nw.__appname__)
self.aAboutNW.triggered.connect(self._showAbout) self.aAboutNW.triggered.connect(self._showAbout)
self.helpMenu.addAction(self.aAboutNW) self.helpMenu.addAction(self.aAboutNW)
+5 -5
View File
@@ -108,7 +108,7 @@ class GuiPreferences(PagedDialog):
msgBox = QMessageBox() msgBox = QMessageBox()
msgBox.information( msgBox.information(
self, "Preferences", self, "Preferences",
"Some changes will not be applied until %s has been restarted." % nw.__package__ "Some changes will not be applied until %s has been restarted." % nw.__appname__
) )
if validEntries: if validEntries:
@@ -154,7 +154,7 @@ class GuiConfigEditGeneralTab(QWidget):
self.mainForm.addRow( self.mainForm.addRow(
"Main GUI theme", "Main GUI theme",
self.selectTheme, self.selectTheme,
"Changing this requires restarting %s." % nw.__package__ "Changing this requires restarting %s." % nw.__appname__
) )
## Select Icon Theme ## Select Icon Theme
@@ -170,7 +170,7 @@ class GuiConfigEditGeneralTab(QWidget):
self.mainForm.addRow( self.mainForm.addRow(
"Main icon theme", "Main icon theme",
self.selectIcons, self.selectIcons,
"Changing this requires restarting %s." % nw.__package__ "Changing this requires restarting %s." % nw.__appname__
) )
## Dark Icons ## Dark Icons
@@ -193,7 +193,7 @@ class GuiConfigEditGeneralTab(QWidget):
self.mainForm.addRow( self.mainForm.addRow(
"Font family", "Font family",
self.guiFont, self.guiFont,
"Changing this requires restarting %s." % nw.__package__, "Changing this requires restarting %s." % nw.__appname__,
theButton = self.fontButton theButton = self.fontButton
) )
@@ -206,7 +206,7 @@ class GuiConfigEditGeneralTab(QWidget):
self.mainForm.addRow( self.mainForm.addRow(
"Font size", "Font size",
self.guiFontSize, self.guiFontSize,
"Changing this requires restarting %s." % nw.__package__, "Changing this requires restarting %s." % nw.__appname__,
theUnit = "pt" theUnit = "pt"
) )
+6 -6
View File
@@ -45,8 +45,8 @@ from nw.gui import (
GuiOutline, GuiOutlineDetails, GuiPreferences, GuiProjectLoad, GuiTheme, GuiOutline, GuiOutlineDetails, GuiPreferences, GuiProjectLoad, GuiTheme,
GuiProjectSettings, GuiProjectTree, GuiWritingStats GuiProjectSettings, GuiProjectTree, GuiWritingStats
) )
from nw.core import NWProject, NWDoc, NWIndex from .core import NWProject, NWDoc, NWIndex
from nw.constants import nwFiles, nwItemType, nwAlert from .constants import nwFiles, nwItemType, nwAlert
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -220,7 +220,7 @@ class GuiMain(QMainWindow):
else: else:
self.manageProjects() self.manageProjects()
logger.debug("%s is ready ..." % nw.__package__) logger.debug("%s is ready ..." % nw.__appname__)
return return
@@ -390,7 +390,7 @@ class GuiMain(QMainWindow):
"can safely be overridden. If, however, another instance of %s has " "can safely be overridden. If, however, another instance of %s has "
"the project open, overriding the lock may corrupt the project, and " "the project open, overriding the lock may corrupt the project, and "
"is not recommended.%s" "is not recommended.%s"
) % (nw.__package__, nw.__package__, lockDetails), ) % (nw.__appname__, nw.__appname__, lockDetails),
QMessageBox.Yes | QMessageBox.No, QMessageBox.No QMessageBox.Yes | QMessageBox.No, QMessageBox.No
) )
if msgRes == QMessageBox.Yes: if msgRes == QMessageBox.Yes:
@@ -872,7 +872,7 @@ class GuiMain(QMainWindow):
if msgRes != QMessageBox.Yes: if msgRes != QMessageBox.Yes:
return False return False
logger.info("Exiting %s" % nw.__package__) logger.info("Exiting %s" % nw.__appname__)
if not self.isFocusMode: if not self.isFocusMode:
self.mainConf.setMainPanePos(self.splitMain.sizes()) self.mainConf.setMainPanePos(self.splitMain.sizes())
@@ -1037,7 +1037,7 @@ class GuiMain(QMainWindow):
return True return True
def _setWindowTitle(self, projName=None): def _setWindowTitle(self, projName=None):
winTitle = "%s" % nw.__package__ winTitle = "%s" % nw.__appname__
if projName is not None: if projName is not None:
winTitle += " - %s" % projName winTitle += " - %s" % projName
self.setWindowTitle(winTitle) self.setWindowTitle(winTitle)