From 601bd3dca636c4346bcfc18b6e8893a3e45608bd Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sun, 26 May 2019 14:06:48 +0200 Subject: [PATCH] Filenames are set nwFiles now, and deleted some unused file in nw/gui --- nw/config.py | 2 ++ nw/constants.py | 11 +++++-- nw/gui/aboutview.py | 77 ------------------------------------------- nw/gui/winmain.py | 9 +++-- nw/project/project.py | 9 ++--- 5 files changed, 22 insertions(+), 86 deletions(-) delete mode 100644 nw/gui/aboutview.py diff --git a/nw/config.py b/nw/config.py index 34fe87a4..1627270f 100644 --- a/nw/config.py +++ b/nw/config.py @@ -43,6 +43,7 @@ class Config: self.confFile = None self.homePath = None self.appPath = None + self.appRoot = None self.guiPath = None self.themePath = None @@ -101,6 +102,7 @@ class Config: self.confFile = self.appHandle+".conf" self.homePath = path.expanduser("~") self.appPath = path.dirname(__file__) + self.appRoot = path.join(self.appPath,path.pardir) self.guiPath = path.join(self.appPath,"gui") self.themePath = path.join(self.appPath,"themes") diff --git a/nw/constants.py b/nw/constants.py index 7dc39f05..f8a37ae7 100644 --- a/nw/constants.py +++ b/nw/constants.py @@ -12,6 +12,14 @@ from nw.enum import nwItemClass, nwItemLayout +class nwFiles(): + + APP_ICON = "novelWriter.svg" + PROJ_FILE = "nwProject.nwx" + PROJ_DICT = "wordlist.txt" + +# END Class nwFiles + class nwLabels(): CLASS_NAME = { @@ -59,5 +67,4 @@ class nwLabels(): nwItemLayout.NOTE : "Nt", } - -# END nwLabels +# END Class nwLabels diff --git a/nw/gui/aboutview.py b/nw/gui/aboutview.py deleted file mode 100644 index fa3e747c..00000000 --- a/nw/gui/aboutview.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding: utf-8 -*- -"""novelWriter GUI About View - - novelWriter – GUI About View -============================== - Class holding the tab viewing the about information - - File History: - Created: 2018-10-02 [0.0.1] - -""" - -import logging -import nw - -from os import path -from PyQt5.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QLabel -from PyQt5.QtSvg import QSvgWidget -from PyQt5.QtCore import Qt, QSize -from PyQt5.QtGui import QFont - -logger = logging.getLogger(__name__) - -class GuiAboutView(QWidget): - - def __init__(self): - QWidget.__init__(self) - - logger.debug("Initialising AboutView ...") - self.mainConf = nw.CONFIG - self.innerBox = QHBoxLayout() - self.outerBox = QVBoxLayout() - - logoPath = path.abspath(path.join(self.mainConf.appPath,"..","novelWriter.svg")) - logger.verbose("Loading image: %s" % logoPath) - nwLogo = QSvgWidget(logoPath) - nwLogo.setFixedSize(QSize(300,300)) - - nwName = QLabel() - nwName.setText(nw.__package__) - nwName.setAlignment(Qt.AlignCenter) - fnName = QFont() - fnName.setPointSize(22) - fnName.setBold(True) - nwName.setFont(fnName) - - nwVersion = QLabel() - nwVersion.setText("Version %s" % nw.__version__) - nwVersion.setAlignment(Qt.AlignCenter) - - nwCredits = QLabel() - nwCredits.setText("Created By: %s" % ",".join(nw.__credits__)) - nwCredits.setAlignment(Qt.AlignCenter) - - nwWebsite = QLabel() - nwWebsite.setText("%s" % (nw.__website__,nw.__website__)) - nwWebsite.setOpenExternalLinks(True) - nwWebsite.setAlignment(Qt.AlignCenter) - - self.outerBox.addStretch(1) - self.innerBox.addStretch(1) - self.innerBox.addWidget(nwLogo) - self.innerBox.addStretch(1) - self.outerBox.addLayout(self.innerBox) - self.outerBox.addWidget(nwName) - self.outerBox.addWidget(nwVersion) - self.outerBox.addWidget(nwCredits) - self.outerBox.addWidget(nwWebsite) - self.outerBox.addStretch(1) - - self.setLayout(self.outerBox) - - logger.debug("AboutView initialisation complete") - - return - -# END Class GuiAboutView diff --git a/nw/gui/winmain.py b/nw/gui/winmain.py index 616f415c..3d1b4f26 100644 --- a/nw/gui/winmain.py +++ b/nw/gui/winmain.py @@ -36,6 +36,7 @@ from nw.project.item import NWItem from nw.convert.tokenizer import Tokenizer from nw.convert.tohtml import ToHtml from nw.enum import nwItemType, nwAlert +from nw.constants import nwFiles logger = logging.getLogger(__name__) @@ -53,7 +54,7 @@ class GuiMain(QMainWindow): self.resize(*self.mainConf.winGeometry) self._setWindowTitle() - self.setWindowIcon(QIcon(path.join(self.mainConf.appPath,"..","novelWriter.svg"))) + self.setWindowIcon(QIcon(path.join(self.mainConf.appRoot, nwFiles.APP_ICON))) self.theTheme.loadTheme() # Main GUI Elements @@ -255,7 +256,7 @@ class GuiMain(QMainWindow): self.theProject.openProject(projFile) self._setWindowTitle(self.theProject.projName) self.rebuildTree() - self.docEditor.setPwl(path.join(self.theProject.projMeta,"wordlist.txt")) + self.docEditor.setPwl(path.join(self.theProject.projMeta, nwFiles.PROJ_DICT)) self.docEditor.setSpellCheck(self.theProject.spellCheck) self.mainMenu.updateMenu() @@ -394,7 +395,9 @@ class GuiMain(QMainWindow): dlgOpt = QFileDialog.Options() dlgOpt |= QFileDialog.DontUseNativeDialog projFile, _ = QFileDialog.getOpenFileName( - self,"Open novelWriter Project","","novelWriter Project File (nwProject.nwx);;All Files (*)",options=dlgOpt + self, "Open novelWriter Project", "", + "novelWriter Project File (%s);;All Files (*)" % nwFiles.PROJ_FILE, + options=dlgOpt ) if projFile: return projFile diff --git a/nw/project/project.py b/nw/project/project.py index dd21c3e4..d5c700e2 100644 --- a/nw/project/project.py +++ b/nw/project/project.py @@ -19,10 +19,11 @@ from hashlib import sha256 from datetime import datetime from time import time -from nw.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert -from nw.common import checkString, checkBool, checkInt from nw.project.item import NWItem from nw.project.status import NWStatus +from nw.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert +from nw.common import checkString, checkBool, checkInt +from nw.constants import nwFiles logger = logging.getLogger(__name__) @@ -143,7 +144,7 @@ class NWProject(): self.projPath = None self.projMeta = None self.projCache = None - self.projFile = "nwProject.nwx" + self.projFile = nwFiles.PROJ_FILE self.projName = "" self.bookTitle = "" self.bookAuthors = [] @@ -168,7 +169,7 @@ class NWProject(): def openProject(self, fileName): if not path.isfile(fileName): - fileName = path.join(fileName, "nwProject.nwx") + fileName = path.join(fileName, nwFiles.PROJ_FILE) if not path.isfile(fileName): self.makeAlert("File not found: %s" % fileName, nwAlert.ERROR) return False