Drop all mappings of config object into classes now that tests don't need that

This commit is contained in:
Veronica Berglyd Olsen
2023-05-16 23:00:30 +02:00
parent 7f8ffb228e
commit 324b204eaa
39 changed files with 578 additions and 638 deletions
+4 -4
View File
@@ -776,8 +776,8 @@ class Config:
class RecentProjects: class RecentProjects:
def __init__(self, mainConf): def __init__(self, config):
self.mainConf = mainConf self._conf = config
self._data = {} self._data = {}
return return
@@ -786,7 +786,7 @@ class RecentProjects:
""" """
self._data = {} self._data = {}
cacheFile = self.mainConf.dataPath(nwFiles.RECENT_FILE) cacheFile = self._conf.dataPath(nwFiles.RECENT_FILE)
if not cacheFile.is_file(): if not cacheFile.is_file():
return True return True
@@ -809,7 +809,7 @@ class RecentProjects:
def saveCache(self): def saveCache(self):
"""Save the cache dictionary of recent projects. """Save the cache dictionary of recent projects.
""" """
cacheFile = self.mainConf.dataPath(nwFiles.RECENT_FILE) cacheFile = self._conf.dataPath(nwFiles.RECENT_FILE)
cacheTemp = cacheFile.with_suffix(".tmp") cacheTemp = cacheFile.with_suffix(".tmp")
try: try:
with open(cacheTemp, mode="w+", encoding="utf-8") as outFile: with open(cacheTemp, mode="w+", encoding="utf-8") as outFile:
+2 -6
View File
@@ -27,13 +27,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import shutil import shutil
import logging import logging
import novelwriter
from time import time from time import time
from functools import partial from functools import partial
from PyQt5.QtCore import QCoreApplication from PyQt5.QtCore import QCoreApplication
from novelwriter import CONFIG
from novelwriter.enum import nwAlert from novelwriter.enum import nwAlert
from novelwriter.common import minmax, simplified from novelwriter.common import minmax, simplified
from novelwriter.constants import nwItemClass from novelwriter.constants import nwItemClass
@@ -268,12 +268,8 @@ class ProjectBuilder:
""" """
def __init__(self, mainGui): def __init__(self, mainGui):
self.mainGui = mainGui self.mainGui = mainGui
self.mainConf = novelwriter.CONFIG
self.tr = partial(QCoreApplication.translate, "NWProject") self.tr = partial(QCoreApplication.translate, "NWProject")
return return
## ##
@@ -431,7 +427,7 @@ class ProjectBuilder:
logger.error("No project path set for the example project") logger.error("No project path set for the example project")
return False return False
pkgSample = self.mainConf.assetPath("sample.zip") pkgSample = CONFIG.assetPath("sample.zip")
if pkgSample.is_file(): if pkgSample.is_file():
try: try:
shutil.unpack_archive(pkgSample, projPath) shutil.unpack_archive(pkgSample, projPath)
+10 -11
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import json import json
import logging import logging
import novelwriter
from time import time from time import time
from pathlib import Path from pathlib import Path
@@ -33,6 +32,7 @@ from functools import partial
from PyQt5.QtCore import QCoreApplication, QObject, pyqtSignal from PyQt5.QtCore import QCoreApplication, QObject, pyqtSignal
from novelwriter import CONFIG, __version__, __hexversion__
from novelwriter.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert from novelwriter.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert
from novelwriter.error import logException from novelwriter.error import logException
from novelwriter.constants import trConst, nwFiles, nwLabels from novelwriter.constants import trConst, nwFiles, nwLabels
@@ -58,8 +58,7 @@ class NWProject(QObject):
super().__init__(parent=mainGui) super().__init__(parent=mainGui)
# Internal # Internal
self.mainConf = novelwriter.CONFIG self.mainGui = mainGui
self.mainGui = mainGui
# Core Elements # Core Elements
self._options = OptionState(self) # Project-specific GUI options self._options = OptionState(self) # Project-specific GUI options
@@ -328,7 +327,7 @@ class NWProject(QObject):
# Check novelWriter Version # Check novelWriter Version
# ========================= # =========================
if xmlReader.hexVersion > hexToInt(novelwriter.__hexversion__): if xmlReader.hexVersion > hexToInt(__hexversion__):
msgYes = self.mainGui.askQuestion( msgYes = self.mainGui.askQuestion(
self.tr("Version Conflict"), self.tr("Version Conflict"),
self.tr( self.tr(
@@ -337,7 +336,7 @@ class NWProject(QObject):
"continue to open the project, some attributes and " "continue to open the project, some attributes and "
"settings may not be preserved, but the overall project " "settings may not be preserved, but the overall project "
"should be fine. Continue opening the project?" "should be fine. Continue opening the project?"
).format(appVersion, novelwriter.__version__) ).format(appVersion, __version__)
) )
if not msgYes: if not msgYes:
self.clearProject() self.clearProject()
@@ -351,7 +350,7 @@ class NWProject(QObject):
self._loadProjectLocalisation() self._loadProjectLocalisation()
# Update recent projects # Update recent projects
self.mainConf.recentProjects.update( CONFIG.recentProjects.update(
self._storage.storagePath, self._data.name, sum(self._data.initCounts), time() self._storage.storagePath, self._data.name, sum(self._data.initCounts), time()
) )
@@ -422,7 +421,7 @@ class NWProject(QObject):
self._storage.runPostSaveTasks(autoSave=autoSave) self._storage.runPostSaveTasks(autoSave=autoSave)
# Update recent projects # Update recent projects
self.mainConf.recentProjects.update( CONFIG.recentProjects.update(
self._storage.storagePath, self._data.name, sum(self._data.currCounts), saveTime self._storage.storagePath, self._data.name, sum(self._data.currCounts), saveTime
) )
@@ -455,7 +454,7 @@ class NWProject(QObject):
logger.info("Backing up project") logger.info("Backing up project")
self.mainGui.setStatus(self.tr("Backing up project ...")) self.mainGui.setStatus(self.tr("Backing up project ..."))
backupPath = self.mainConf.backupPath() backupPath = CONFIG.backupPath()
if not isinstance(backupPath, Path): if not isinstance(backupPath, Path):
self.mainGui.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Cannot backup project because no valid backup path is set. " "Cannot backup project because no valid backup path is set. "
@@ -677,13 +676,13 @@ class NWProject(QObject):
def _loadProjectLocalisation(self): def _loadProjectLocalisation(self):
"""Load the language data for the current project language. """Load the language data for the current project language.
""" """
if self._data.language is None or self.mainConf._nwLangPath is None: if self._data.language is None or CONFIG._nwLangPath is None:
self._langData = {} self._langData = {}
return False return False
langFile = Path(self.mainConf._nwLangPath) / f"project_{self._data.language}.json" langFile = Path(CONFIG._nwLangPath) / f"project_{self._data.language}.json"
if not langFile.is_file(): if not langFile.is_file():
langFile = Path(self.mainConf._nwLangPath) / "project_en_GB.json" langFile = Path(CONFIG._nwLangPath) / "project_en_GB.json"
try: try:
with open(langFile, mode="r", encoding="utf-8") as inFile: with open(langFile, mode="r", encoding="utf-8") as inFile:
+3 -3
View File
@@ -26,13 +26,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from enum import Enum from enum import Enum
from lxml import etree from lxml import etree
from time import time from time import time
from pathlib import Path from pathlib import Path
from novelwriter import __version__, __hexversion__
from novelwriter.common import ( from novelwriter.common import (
checkBool, checkInt, checkString, checkStringNone, formatTimeStamp, checkBool, checkInt, checkString, checkStringNone, formatTimeStamp,
hexToInt, simplified, yesNo hexToInt, simplified, yesNo
@@ -501,8 +501,8 @@ class ProjectXMLWriter:
logger.debug("Writing project XML") logger.debug("Writing project XML")
xRoot = etree.Element("novelWriterXML", attrib={ xRoot = etree.Element("novelWriterXML", attrib={
"appVersion": str(novelwriter.__version__), "appVersion": str(__version__),
"hexVersion": str(novelwriter.__hexversion__), "hexVersion": str(__hexversion__),
"fileVersion": FILE_VERSION, "fileVersion": FILE_VERSION,
"timeStamp": formatTimeStamp(saveTime), "timeStamp": formatTimeStamp(saveTime),
}) })
+5 -5
View File
@@ -26,11 +26,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import random import random
import logging import logging
import novelwriter
from PyQt5.QtGui import QIcon, QPainter, QPainterPath, QPixmap, QColor from PyQt5.QtGui import QIcon, QPainter, QPainterPath, QPixmap, QColor
from PyQt5.QtCore import QRectF, Qt from PyQt5.QtCore import QRectF, Qt
from novelwriter import CONFIG
from novelwriter.common import minmax, simplified from novelwriter.common import minmax, simplified
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -47,11 +47,11 @@ class NWStatus:
self._store = {} self._store = {}
self._default = None self._default = None
self._iPX = novelwriter.CONFIG.pxInt(24) self._iPX = CONFIG.pxInt(24)
pA = novelwriter.CONFIG.pxInt(2) pA = CONFIG.pxInt(2)
pB = novelwriter.CONFIG.pxInt(20) pB = CONFIG.pxInt(20)
pR = float(novelwriter.CONFIG.pxInt(4)) pR = float(CONFIG.pxInt(4))
self._iconPath = QPainterPath() self._iconPath = QPainterPath()
self._iconPath.addRoundedRect(QRectF(pA, pA, pB, pB), pR, pR) self._iconPath.addRoundedRect(QRectF(pA, pA, pB, pB), pR, pR)
+3 -4
View File
@@ -24,12 +24,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from time import time from time import time
from pathlib import Path from pathlib import Path
from zipfile import ZIP_DEFLATED, ZIP_STORED, ZipFile from zipfile import ZIP_DEFLATED, ZIP_STORED, ZipFile
from novelwriter import CONFIG
from novelwriter.error import logException from novelwriter.error import logException
from novelwriter.common import minmax from novelwriter.common import minmax
from novelwriter.constants import nwFiles from novelwriter.constants import nwFiles
@@ -47,7 +47,6 @@ class NWStorage:
def __init__(self, theProject): def __init__(self, theProject):
self.mainConf = novelwriter.CONFIG
self.theProject = theProject self.theProject = theProject
self._storagePath = None self._storagePath = None
@@ -220,8 +219,8 @@ class NWStorage:
return False return False
data = [ data = [
self.mainConf.hostName, self.mainConf.osType, CONFIG.hostName, CONFIG.osType,
self.mainConf.kernelVer, str(int(time())) CONFIG.kernelVer, str(int(time()))
] ]
try: try:
self._lockFilePath.write_text(";".join(data), encoding="utf-8") self._lockFilePath.write_text(";".join(data), encoding="utf-8")
+3 -2
View File
@@ -25,6 +25,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging import logging
from novelwriter import CONFIG
from novelwriter.constants import nwKeyWords, nwLabels, nwHtmlUnicode from novelwriter.constants import nwKeyWords, nwLabels, nwHtmlUnicode
from novelwriter.core.tokenizer import Tokenizer, stripEscape from novelwriter.core.tokenizer import Tokenizer, stripEscape
@@ -204,9 +205,9 @@ class ToHtml(Tokenizer):
aStyle.append("margin-top: 0;") aStyle.append("margin-top: 0;")
if tStyle & self.A_IND_L: if tStyle & self.A_IND_L:
aStyle.append(f"margin-left: {self.mainConf.tabWidth:d}px;") aStyle.append(f"margin-left: {CONFIG.tabWidth:d}px;")
if tStyle & self.A_IND_R: if tStyle & self.A_IND_R:
aStyle.append(f"margin-right: {self.mainConf.tabWidth:d}px;") aStyle.append(f"margin-right: {CONFIG.tabWidth:d}px;")
if len(aStyle) > 0: if len(aStyle) > 0:
stVals = " ".join(aStyle) stVals = " ".join(aStyle)
-2
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import re import re
import logging import logging
import novelwriter
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from operator import itemgetter from operator import itemgetter
@@ -92,7 +91,6 @@ class Tokenizer(ABC):
def __init__(self, theProject): def __init__(self, theProject):
self.theProject = theProject self.theProject = theProject
self.mainConf = novelwriter.CONFIG
# Data Variables # Data Variables
self._theText = "" # The raw text to be tokenized self._theText = "" # The raw text to be tokenized
+2 -2
View File
@@ -24,13 +24,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from lxml import etree from lxml import etree
from hashlib import sha256 from hashlib import sha256
from zipfile import ZipFile from zipfile import ZipFile
from datetime import datetime from datetime import datetime
from novelwriter import __version__
from novelwriter.constants import nwKeyWords, nwLabels from novelwriter.constants import nwKeyWords, nwLabels
from novelwriter.core.tokenizer import Tokenizer, stripEscape from novelwriter.core.tokenizer import Tokenizer, stripEscape
@@ -336,7 +336,7 @@ class ToOdt(Tokenizer):
xMeta.text = timeStamp xMeta.text = timeStamp
xMeta = etree.SubElement(self._xMeta, _mkTag("meta", "generator")) xMeta = etree.SubElement(self._xMeta, _mkTag("meta", "generator"))
xMeta.text = f"novelWriter/{novelwriter.__version__}" xMeta.text = f"novelWriter/{__version__}"
xMeta = etree.SubElement(self._xMeta, _mkTag("meta", "initial-creator")) xMeta = etree.SubElement(self._xMeta, _mkTag("meta", "initial-creator"))
xMeta.text = self.theProject.data.author xMeta.text = self.theProject.data.author
+8 -8
View File
@@ -26,7 +26,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from PyQt5.QtGui import QColor, QPalette, QPainter from PyQt5.QtGui import QColor, QPalette, QPainter
from PyQt5.QtCore import ( from PyQt5.QtCore import (
@@ -38,6 +37,7 @@ from PyQt5.QtWidgets import (
QStyleOptionTab, QLineEdit QStyleOptionTab, QLineEdit
) )
from novelwriter import CONFIG
from novelwriter.constants import nwUnicode from novelwriter.constants import nwUnicode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -58,7 +58,7 @@ class QConfigLayout(QGridLayout):
self._itemMap = {} self._itemMap = {}
wSp = novelwriter.CONFIG.pxInt(8) wSp = CONFIG.pxInt(8)
self.setHorizontalSpacing(wSp) self.setHorizontalSpacing(wSp)
self.setVerticalSpacing(wSp) self.setVerticalSpacing(wSp)
self.setColumnStretch(0, 1) self.setColumnStretch(0, 1)
@@ -108,7 +108,7 @@ class QConfigLayout(QGridLayout):
qLabel = None qLabel = None
raise ValueError("theLabel must be a QLabel") raise ValueError("theLabel must be a QLabel")
hM = novelwriter.CONFIG.pxInt(4) hM = CONFIG.pxInt(4)
qLabel.setContentsMargins(0, hM, 0, hM) qLabel.setContentsMargins(0, hM, 0, hM)
self.addWidget(qLabel, self._nextRow, 0, 1, 2, Qt.AlignLeft) self.addWidget(qLabel, self._nextRow, 0, 1, 2, Qt.AlignLeft)
@@ -142,7 +142,7 @@ class QConfigLayout(QGridLayout):
qWidget = None qWidget = None
raise ValueError("theWidget must be a QWidget") raise ValueError("theWidget must be a QWidget")
wSp = novelwriter.CONFIG.pxInt(8) wSp = CONFIG.pxInt(8)
qLabel.setIndent(wSp) qLabel.setIndent(wSp)
if helpText is not None: if helpText is not None:
qHelp = QHelpLabel(str(helpText), self._helpCol, self._fontScale) qHelp = QHelpLabel(str(helpText), self._helpCol, self._fontScale)
@@ -235,18 +235,18 @@ class QSwitch(QAbstractButton):
super().__init__(parent=parent) super().__init__(parent=parent)
if width is None: if width is None:
self._xW = novelwriter.CONFIG.pxInt(40) self._xW = CONFIG.pxInt(40)
else: else:
self._xW = width self._xW = width
if height is None: if height is None:
self._xH = novelwriter.CONFIG.pxInt(20) self._xH = CONFIG.pxInt(20)
else: else:
self._xH = height self._xH = height
self._xR = int(self._xH*0.5) self._xR = int(self._xH*0.5)
self._xT = int(self._xH*0.6) self._xT = int(self._xH*0.6)
self._rB = int(novelwriter.CONFIG.guiScale*2) self._rB = int(CONFIG.guiScale*2)
self._rH = self._xH - 2*self._rB self._rH = self._xH - 2*self._rB
self._rR = self._xR - self._rB self._rR = self._xR - self._rB
@@ -434,7 +434,7 @@ class VerticalTabBar(QTabBar):
def __init__(self, parent=None): def __init__(self, parent=None):
super().__init__(parent=parent) super().__init__(parent=parent)
self._mW = novelwriter.CONFIG.pxInt(150) self._mW = CONFIG.pxInt(150)
return return
def tabSizeHint(self, index): def tabSizeHint(self, index):
+13 -13
View File
@@ -35,6 +35,7 @@ from PyQt5.QtWidgets import (
QTextBrowser, QLabel QTextBrowser, QLabel
) )
from novelwriter import CONFIG
from novelwriter.common import readTextFile from novelwriter.common import readTextFile
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -48,19 +49,18 @@ class GuiAbout(QDialog):
logger.debug("Initialising GuiAbout ...") logger.debug("Initialising GuiAbout ...")
self.setObjectName("GuiAbout") self.setObjectName("GuiAbout")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
self.innerBox = QHBoxLayout() self.innerBox = QHBoxLayout()
self.innerBox.setSpacing(self.mainConf.pxInt(16)) self.innerBox.setSpacing(CONFIG.pxInt(16))
self.setWindowTitle(self.tr("About novelWriter")) self.setWindowTitle(self.tr("About novelWriter"))
self.setMinimumWidth(self.mainConf.pxInt(650)) self.setMinimumWidth(CONFIG.pxInt(650))
self.setMinimumHeight(self.mainConf.pxInt(600)) self.setMinimumHeight(CONFIG.pxInt(600))
nPx = self.mainConf.pxInt(96) nPx = CONFIG.pxInt(96)
self.nwIcon = QLabel() self.nwIcon = QLabel()
self.nwIcon.setPixmap(self.mainGui.mainTheme.getPixmap("novelwriter", (nPx, nPx))) self.nwIcon.setPixmap(self.mainGui.mainTheme.getPixmap("novelwriter", (nPx, nPx)))
self.lblName = QLabel("<b>novelWriter</b>") self.lblName = QLabel("<b>novelWriter</b>")
@@ -68,7 +68,7 @@ class GuiAbout(QDialog):
self.lblDate = QLabel(datetime.strptime(novelwriter.__date__, "%Y-%m-%d").strftime("%x")) self.lblDate = QLabel(datetime.strptime(novelwriter.__date__, "%Y-%m-%d").strftime("%x"))
self.leftBox = QVBoxLayout() self.leftBox = QVBoxLayout()
self.leftBox.setSpacing(self.mainConf.pxInt(4)) self.leftBox.setSpacing(CONFIG.pxInt(4))
self.leftBox.addWidget(self.nwIcon, 0, Qt.AlignCenter) self.leftBox.addWidget(self.nwIcon, 0, Qt.AlignCenter)
self.leftBox.addWidget(self.lblName, 0, Qt.AlignCenter) self.leftBox.addWidget(self.lblName, 0, Qt.AlignCenter)
self.leftBox.addWidget(self.lblVers, 0, Qt.AlignCenter) self.leftBox.addWidget(self.lblVers, 0, Qt.AlignCenter)
@@ -79,19 +79,19 @@ class GuiAbout(QDialog):
# Pages # Pages
self.pageAbout = QTextBrowser() self.pageAbout = QTextBrowser()
self.pageAbout.setOpenExternalLinks(True) self.pageAbout.setOpenExternalLinks(True)
self.pageAbout.document().setDocumentMargin(self.mainConf.pxInt(16)) self.pageAbout.document().setDocumentMargin(CONFIG.pxInt(16))
self.pageNotes = QTextBrowser() self.pageNotes = QTextBrowser()
self.pageNotes.setOpenExternalLinks(True) self.pageNotes.setOpenExternalLinks(True)
self.pageNotes.document().setDocumentMargin(self.mainConf.pxInt(16)) self.pageNotes.document().setDocumentMargin(CONFIG.pxInt(16))
self.pageCredits = QTextBrowser() self.pageCredits = QTextBrowser()
self.pageCredits.setOpenExternalLinks(True) self.pageCredits.setOpenExternalLinks(True)
self.pageCredits.document().setDocumentMargin(self.mainConf.pxInt(16)) self.pageCredits.document().setDocumentMargin(CONFIG.pxInt(16))
self.pageLicense = QTextBrowser() self.pageLicense = QTextBrowser()
self.pageLicense.setOpenExternalLinks(True) self.pageLicense.setOpenExternalLinks(True)
self.pageLicense.document().setDocumentMargin(self.mainConf.pxInt(16)) self.pageLicense.document().setDocumentMargin(CONFIG.pxInt(16))
# Main Tab Area # Main Tab Area
self.tabBox = QTabWidget() self.tabBox = QTabWidget()
@@ -182,7 +182,7 @@ class GuiAbout(QDialog):
def _fillNotesPage(self): def _fillNotesPage(self):
"""Load the content for the Release Notes page. """Load the content for the Release Notes page.
""" """
docPath = self.mainConf.assetPath("text") / "release_notes.htm" docPath = CONFIG.assetPath("text") / "release_notes.htm"
docText = readTextFile(docPath) docText = readTextFile(docPath)
if docText: if docText:
self.pageNotes.setHtml(docText) self.pageNotes.setHtml(docText)
@@ -193,7 +193,7 @@ class GuiAbout(QDialog):
def _fillCreditsPage(self): def _fillCreditsPage(self):
"""Load the content for the Credits page. """Load the content for the Credits page.
""" """
docPath = self.mainConf.assetPath("text") / "credits_en.htm" docPath = CONFIG.assetPath("text") / "credits_en.htm"
docText = readTextFile(docPath) docText = readTextFile(docPath)
if docText: if docText:
self.pageCredits.setHtml(docText) self.pageCredits.setHtml(docText)
@@ -204,7 +204,7 @@ class GuiAbout(QDialog):
def _fillLicensePage(self): def _fillLicensePage(self):
"""Load the content for the Licence page. """Load the content for the Licence page.
""" """
docPath = self.mainConf.assetPath("text") / "gplv3_en.htm" docPath = CONFIG.assetPath("text") / "gplv3_en.htm"
docText = readTextFile(docPath) docText = readTextFile(docPath)
if docText: if docText:
self.pageLicense.setHtml(docText) self.pageLicense.setHtml(docText)
+6 -7
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from PyQt5.QtCore import Qt, QSize from PyQt5.QtCore import Qt, QSize
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
@@ -33,6 +32,7 @@ from PyQt5.QtWidgets import (
QListWidget, QListWidgetItem, QVBoxLayout, QListWidget, QListWidgetItem, QVBoxLayout,
) )
from novelwriter import CONFIG
from novelwriter.custom import QHelpLabel, QSwitch from novelwriter.custom import QHelpLabel, QSwitch
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -46,7 +46,6 @@ class GuiDocMerge(QDialog):
logger.debug("Initialising GuiDocMerge ...") logger.debug("Initialising GuiDocMerge ...")
self.setObjectName("GuiDocMerge") self.setObjectName("GuiDocMerge")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
@@ -61,14 +60,14 @@ class GuiDocMerge(QDialog):
), self.mainTheme.helpText) ), self.mainTheme.helpText)
iPx = self.mainTheme.baseIconSize iPx = self.mainTheme.baseIconSize
hSp = self.mainConf.pxInt(12) hSp = CONFIG.pxInt(12)
vSp = self.mainConf.pxInt(8) vSp = CONFIG.pxInt(8)
bSp = self.mainConf.pxInt(12) bSp = CONFIG.pxInt(12)
self.listBox = QListWidget() self.listBox = QListWidget()
self.listBox.setIconSize(QSize(iPx, iPx)) self.listBox.setIconSize(QSize(iPx, iPx))
self.listBox.setMinimumWidth(self.mainConf.pxInt(400)) self.listBox.setMinimumWidth(CONFIG.pxInt(400))
self.listBox.setMinimumHeight(self.mainConf.pxInt(180)) self.listBox.setMinimumHeight(CONFIG.pxInt(180))
self.listBox.setSelectionBehavior(QAbstractItemView.SelectRows) self.listBox.setSelectionBehavior(QAbstractItemView.SelectRows)
self.listBox.setSelectionMode(QAbstractItemView.SingleSelection) self.listBox.setSelectionMode(QAbstractItemView.SingleSelection)
self.listBox.setDragDropMode(QAbstractItemView.InternalMove) self.listBox.setDragDropMode(QAbstractItemView.InternalMove)
+6 -7
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
@@ -33,6 +32,7 @@ from PyQt5.QtWidgets import (
QListWidgetItem, QDialogButtonBox, QLabel, QGridLayout QListWidgetItem, QDialogButtonBox, QLabel, QGridLayout
) )
from novelwriter import CONFIG
from novelwriter.custom import QHelpLabel, QSwitch from novelwriter.custom import QHelpLabel, QSwitch
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -50,7 +50,6 @@ class GuiDocSplit(QDialog):
logger.debug("Initialising GuiDocSplit ...") logger.debug("Initialising GuiDocSplit ...")
self.setObjectName("GuiDocSplit") self.setObjectName("GuiDocSplit")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
@@ -68,9 +67,9 @@ class GuiDocSplit(QDialog):
# Values # Values
iPx = self.mainTheme.baseIconSize iPx = self.mainTheme.baseIconSize
hSp = self.mainConf.pxInt(12) hSp = CONFIG.pxInt(12)
vSp = self.mainConf.pxInt(8) vSp = CONFIG.pxInt(8)
bSp = self.mainConf.pxInt(12) bSp = CONFIG.pxInt(12)
pOptions = self.theProject.options pOptions = self.theProject.options
spLevel = pOptions.getInt("GuiDocSplit", "spLevel", 3) spLevel = pOptions.getInt("GuiDocSplit", "spLevel", 3)
@@ -80,8 +79,8 @@ class GuiDocSplit(QDialog):
# Header Selection # Header Selection
self.listBox = QListWidget() self.listBox = QListWidget()
self.listBox.setDragDropMode(QAbstractItemView.NoDragDrop) self.listBox.setDragDropMode(QAbstractItemView.NoDragDrop)
self.listBox.setMinimumWidth(self.mainConf.pxInt(400)) self.listBox.setMinimumWidth(CONFIG.pxInt(400))
self.listBox.setMinimumHeight(self.mainConf.pxInt(180)) self.listBox.setMinimumHeight(CONFIG.pxInt(180))
self.splitLevel = QComboBox(self) self.splitLevel = QComboBox(self)
self.splitLevel.addItem(self.tr("Split on Header Level 1 (Title)"), 1) self.splitLevel.addItem(self.tr("Split on Header Level 1 (Title)"), 1)
+4 -3
View File
@@ -24,12 +24,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QDialog, QVBoxLayout, QLineEdit, QLabel, QDialogButtonBox, QHBoxLayout QDialog, QVBoxLayout, QLineEdit, QLabel, QDialogButtonBox, QHBoxLayout
) )
from novelwriter import CONFIG
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -41,8 +42,8 @@ class GuiEditLabel(QDialog):
self.setObjectName("GuiEditLabel") self.setObjectName("GuiEditLabel")
self.setWindowTitle(self.tr("Item Label")) self.setWindowTitle(self.tr("Item Label"))
mVd = novelwriter.CONFIG.pxInt(220) mVd = CONFIG.pxInt(220)
mSp = novelwriter.CONFIG.pxInt(12) mSp = CONFIG.pxInt(12)
# Item Label # Item Label
self.labelValue = QLineEdit() self.labelValue = QLineEdit()
+133 -141
View File
@@ -24,7 +24,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from PyQt5.QtGui import QFont from PyQt5.QtGui import QFont
from PyQt5.QtCore import Qt, QLocale from PyQt5.QtCore import Qt, QLocale
@@ -33,6 +32,7 @@ from PyQt5.QtWidgets import (
QLineEdit, QFileDialog, QFontDialog, QDoubleSpinBox QLineEdit, QFileDialog, QFontDialog, QDoubleSpinBox
) )
from novelwriter import CONFIG
from novelwriter.custom import QSwitch, QConfigLayout, PagedDialog from novelwriter.custom import QSwitch, QConfigLayout, PagedDialog
from novelwriter.dialogs.quotes import GuiQuoteSelect from novelwriter.dialogs.quotes import GuiQuoteSelect
@@ -47,7 +47,6 @@ class GuiPreferences(PagedDialog):
logger.debug("Initialising GuiPreferences ...") logger.debug("Initialising GuiPreferences ...")
self.setObjectName("GuiPreferences") self.setObjectName("GuiPreferences")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
@@ -74,7 +73,7 @@ class GuiPreferences(PagedDialog):
self.buttonBox.rejected.connect(self._doClose) self.buttonBox.rejected.connect(self._doClose)
self.addControls(self.buttonBox) self.addControls(self.buttonBox)
self.resize(*self.mainConf.preferencesWinSize) self.resize(*CONFIG.preferencesWinSize)
# Settings # Settings
self._updateTheme = False self._updateTheme = False
@@ -125,7 +124,7 @@ class GuiPreferences(PagedDialog):
self.tabQuote.saveValues() self.tabQuote.saveValues()
self._saveWindowSize() self._saveWindowSize()
self.mainConf.saveConfig() CONFIG.saveConfig()
self.accept() self.accept()
return return
@@ -144,7 +143,7 @@ class GuiPreferences(PagedDialog):
def _saveWindowSize(self): def _saveWindowSize(self):
"""Save the dialog window size. """Save the dialog window size.
""" """
self.mainConf.setPreferencesWinSize(self.width(), self.height()) CONFIG.setPreferencesWinSize(self.width(), self.height())
return return
# END Class GuiPreferences # END Class GuiPreferences
@@ -155,7 +154,6 @@ class GuiPreferencesGeneral(QWidget):
def __init__(self, prefsGui): def __init__(self, prefsGui):
super().__init__(parent=prefsGui) super().__init__(parent=prefsGui)
self.mainConf = novelwriter.CONFIG
self.prefsGui = prefsGui self.prefsGui = prefsGui
self.mainGui = prefsGui.mainGui self.mainGui = prefsGui.mainGui
self.mainTheme = prefsGui.mainGui.mainTheme self.mainTheme = prefsGui.mainGui.mainTheme
@@ -168,15 +166,15 @@ class GuiPreferencesGeneral(QWidget):
# Look and Feel # Look and Feel
# ============= # =============
self.mainForm.addGroupLabel(self.tr("Look and Feel")) self.mainForm.addGroupLabel(self.tr("Look and Feel"))
minWidth = self.mainConf.pxInt(200) minWidth = CONFIG.pxInt(200)
# Select Locale # Select Locale
self.guiLocale = QComboBox() self.guiLocale = QComboBox()
self.guiLocale.setMinimumWidth(minWidth) self.guiLocale.setMinimumWidth(minWidth)
theLangs = self.mainConf.listLanguages(self.mainConf.LANG_NW) theLangs = CONFIG.listLanguages(CONFIG.LANG_NW)
for lang, langName in theLangs: for lang, langName in theLangs:
self.guiLocale.addItem(langName, lang) self.guiLocale.addItem(langName, lang)
langIdx = self.guiLocale.findData(self.mainConf.guiLocale) langIdx = self.guiLocale.findData(CONFIG.guiLocale)
if langIdx != -1: if langIdx != -1:
self.guiLocale.setCurrentIndex(langIdx) self.guiLocale.setCurrentIndex(langIdx)
@@ -192,7 +190,7 @@ class GuiPreferencesGeneral(QWidget):
self.theThemes = self.mainTheme.listThemes() self.theThemes = self.mainTheme.listThemes()
for themeDir, themeName in self.theThemes: for themeDir, themeName in self.theThemes:
self.guiTheme.addItem(themeName, themeDir) self.guiTheme.addItem(themeName, themeDir)
themeIdx = self.guiTheme.findData(self.mainConf.guiTheme) themeIdx = self.guiTheme.findData(CONFIG.guiTheme)
if themeIdx != -1: if themeIdx != -1:
self.guiTheme.setCurrentIndex(themeIdx) self.guiTheme.setCurrentIndex(themeIdx)
@@ -204,11 +202,11 @@ class GuiPreferencesGeneral(QWidget):
# Editor Theme # Editor Theme
self.guiSyntax = QComboBox() self.guiSyntax = QComboBox()
self.guiSyntax.setMinimumWidth(self.mainConf.pxInt(200)) self.guiSyntax.setMinimumWidth(CONFIG.pxInt(200))
self.theSyntaxes = self.mainTheme.listSyntax() self.theSyntaxes = self.mainTheme.listSyntax()
for syntaxFile, syntaxName in self.theSyntaxes: for syntaxFile, syntaxName in self.theSyntaxes:
self.guiSyntax.addItem(syntaxName, syntaxFile) self.guiSyntax.addItem(syntaxName, syntaxFile)
syntaxIdx = self.guiSyntax.findData(self.mainConf.guiSyntax) syntaxIdx = self.guiSyntax.findData(CONFIG.guiSyntax)
if syntaxIdx != -1: if syntaxIdx != -1:
self.guiSyntax.setCurrentIndex(syntaxIdx) self.guiSyntax.setCurrentIndex(syntaxIdx)
@@ -221,8 +219,8 @@ class GuiPreferencesGeneral(QWidget):
# Font Family # Font Family
self.guiFont = QLineEdit() self.guiFont = QLineEdit()
self.guiFont.setReadOnly(True) self.guiFont.setReadOnly(True)
self.guiFont.setFixedWidth(self.mainConf.pxInt(162)) self.guiFont.setFixedWidth(CONFIG.pxInt(162))
self.guiFont.setText(self.mainConf.guiFont) self.guiFont.setText(CONFIG.guiFont)
self.fontButton = QPushButton("...") self.fontButton = QPushButton("...")
self.fontButton.setMaximumWidth(int(2.5*self.mainTheme.getTextWidth("..."))) self.fontButton.setMaximumWidth(int(2.5*self.mainTheme.getTextWidth("...")))
self.fontButton.clicked.connect(self._selectFont) self.fontButton.clicked.connect(self._selectFont)
@@ -238,7 +236,7 @@ class GuiPreferencesGeneral(QWidget):
self.guiFontSize.setMinimum(8) self.guiFontSize.setMinimum(8)
self.guiFontSize.setMaximum(60) self.guiFontSize.setMaximum(60)
self.guiFontSize.setSingleStep(1) self.guiFontSize.setSingleStep(1)
self.guiFontSize.setValue(self.mainConf.guiFontSize) self.guiFontSize.setValue(CONFIG.guiFontSize)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Font size"), self.tr("Font size"),
self.guiFontSize, self.guiFontSize,
@@ -251,7 +249,7 @@ class GuiPreferencesGeneral(QWidget):
self.mainForm.addGroupLabel(self.tr("GUI Settings")) self.mainForm.addGroupLabel(self.tr("GUI Settings"))
self.emphLabels = QSwitch() self.emphLabels = QSwitch()
self.emphLabels.setChecked(self.mainConf.emphLabels) self.emphLabels.setChecked(CONFIG.emphLabels)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Emphasise partition and chapter labels"), self.tr("Emphasise partition and chapter labels"),
self.emphLabels, self.emphLabels,
@@ -259,7 +257,7 @@ class GuiPreferencesGeneral(QWidget):
) )
self.showFullPath = QSwitch() self.showFullPath = QSwitch()
self.showFullPath.setChecked(self.mainConf.showFullPath) self.showFullPath.setChecked(CONFIG.showFullPath)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Show full path in document header"), self.tr("Show full path in document header"),
self.showFullPath, self.showFullPath,
@@ -267,7 +265,7 @@ class GuiPreferencesGeneral(QWidget):
) )
self.hideVScroll = QSwitch() self.hideVScroll = QSwitch()
self.hideVScroll.setChecked(self.mainConf.hideVScroll) self.hideVScroll.setChecked(CONFIG.hideVScroll)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Hide vertical scroll bars in main windows"), self.tr("Hide vertical scroll bars in main windows"),
self.hideVScroll, self.hideVScroll,
@@ -275,7 +273,7 @@ class GuiPreferencesGeneral(QWidget):
) )
self.hideHScroll = QSwitch() self.hideHScroll = QSwitch()
self.hideHScroll.setChecked(self.mainConf.hideHScroll) self.hideHScroll.setChecked(CONFIG.hideHScroll)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Hide horizontal scroll bars in main windows"), self.tr("Hide horizontal scroll bars in main windows"),
self.hideHScroll, self.hideHScroll,
@@ -295,22 +293,22 @@ class GuiPreferencesGeneral(QWidget):
emphLabels = self.emphLabels.isChecked() emphLabels = self.emphLabels.isChecked()
# Update Flags # Update Flags
self.prefsGui._updateTheme |= self.mainConf.guiTheme != guiTheme self.prefsGui._updateTheme |= CONFIG.guiTheme != guiTheme
self.prefsGui._updateSyntax |= self.mainConf.guiSyntax != guiSyntax self.prefsGui._updateSyntax |= CONFIG.guiSyntax != guiSyntax
self.prefsGui._needsRestart |= self.mainConf.guiLocale != guiLocale self.prefsGui._needsRestart |= CONFIG.guiLocale != guiLocale
self.prefsGui._needsRestart |= self.mainConf.guiFont != guiFont self.prefsGui._needsRestart |= CONFIG.guiFont != guiFont
self.prefsGui._needsRestart |= self.mainConf.guiFontSize != guiFontSize self.prefsGui._needsRestart |= CONFIG.guiFontSize != guiFontSize
self.prefsGui._refreshTree |= self.mainConf.emphLabels != emphLabels self.prefsGui._refreshTree |= CONFIG.emphLabels != emphLabels
self.mainConf.guiLocale = guiLocale CONFIG.guiLocale = guiLocale
self.mainConf.guiTheme = guiTheme CONFIG.guiTheme = guiTheme
self.mainConf.guiSyntax = guiSyntax CONFIG.guiSyntax = guiSyntax
self.mainConf.guiFont = guiFont CONFIG.guiFont = guiFont
self.mainConf.guiFontSize = guiFontSize CONFIG.guiFontSize = guiFontSize
self.mainConf.emphLabels = emphLabels CONFIG.emphLabels = emphLabels
self.mainConf.showFullPath = self.showFullPath.isChecked() CONFIG.showFullPath = self.showFullPath.isChecked()
self.mainConf.hideVScroll = self.hideVScroll.isChecked() CONFIG.hideVScroll = self.hideVScroll.isChecked()
self.mainConf.hideHScroll = self.hideHScroll.isChecked() CONFIG.hideHScroll = self.hideHScroll.isChecked()
return return
@@ -322,8 +320,8 @@ class GuiPreferencesGeneral(QWidget):
"""Open the QFontDialog and set a font for the font style. """Open the QFontDialog and set a font for the font style.
""" """
currFont = QFont() currFont = QFont()
currFont.setFamily(self.mainConf.guiFont) currFont.setFamily(CONFIG.guiFont)
currFont.setPointSize(self.mainConf.guiFontSize) currFont.setPointSize(CONFIG.guiFontSize)
theFont, theStatus = QFontDialog.getFont(currFont, self) theFont, theStatus = QFontDialog.getFont(currFont, self)
if theStatus: if theStatus:
self.guiFont.setText(theFont.family()) self.guiFont.setText(theFont.family())
@@ -338,7 +336,6 @@ class GuiPreferencesProjects(QWidget):
def __init__(self, prefsGui): def __init__(self, prefsGui):
super().__init__(parent=prefsGui) super().__init__(parent=prefsGui)
self.mainConf = novelwriter.CONFIG
self.mainGui = prefsGui.mainGui self.mainGui = prefsGui.mainGui
self.mainTheme = prefsGui.mainGui.mainTheme self.mainTheme = prefsGui.mainGui.mainTheme
@@ -356,7 +353,7 @@ class GuiPreferencesProjects(QWidget):
self.autoSaveDoc.setMinimum(5) self.autoSaveDoc.setMinimum(5)
self.autoSaveDoc.setMaximum(600) self.autoSaveDoc.setMaximum(600)
self.autoSaveDoc.setSingleStep(1) self.autoSaveDoc.setSingleStep(1)
self.autoSaveDoc.setValue(self.mainConf.autoSaveDoc) self.autoSaveDoc.setValue(CONFIG.autoSaveDoc)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Save document interval"), self.tr("Save document interval"),
self.autoSaveDoc, self.autoSaveDoc,
@@ -369,7 +366,7 @@ class GuiPreferencesProjects(QWidget):
self.autoSaveProj.setMinimum(5) self.autoSaveProj.setMinimum(5)
self.autoSaveProj.setMaximum(600) self.autoSaveProj.setMaximum(600)
self.autoSaveProj.setSingleStep(1) self.autoSaveProj.setSingleStep(1)
self.autoSaveProj.setValue(self.mainConf.autoSaveProj) self.autoSaveProj.setValue(CONFIG.autoSaveProj)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Save project interval"), self.tr("Save project interval"),
self.autoSaveProj, self.autoSaveProj,
@@ -382,7 +379,7 @@ class GuiPreferencesProjects(QWidget):
self.mainForm.addGroupLabel(self.tr("Project Backup")) self.mainForm.addGroupLabel(self.tr("Project Backup"))
# Backup Path # Backup Path
self.backupPath = self.mainConf.backupPath() self.backupPath = CONFIG.backupPath()
self.backupGetPath = QPushButton(self.tr("Browse")) self.backupGetPath = QPushButton(self.tr("Browse"))
self.backupGetPath.clicked.connect(self._backupFolder) self.backupGetPath.clicked.connect(self._backupFolder)
self.backupPathRow = self.mainForm.addRow( self.backupPathRow = self.mainForm.addRow(
@@ -393,7 +390,7 @@ class GuiPreferencesProjects(QWidget):
# Run when closing # Run when closing
self.backupOnClose = QSwitch() self.backupOnClose = QSwitch()
self.backupOnClose.setChecked(self.mainConf.backupOnClose) self.backupOnClose.setChecked(CONFIG.backupOnClose)
self.backupOnClose.toggled.connect(self._toggledBackupOnClose) self.backupOnClose.toggled.connect(self._toggledBackupOnClose)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Run backup when the project is closed"), self.tr("Run backup when the project is closed"),
@@ -404,8 +401,8 @@ class GuiPreferencesProjects(QWidget):
# Ask before backup # Ask before backup
# Only enabled when "Run when closing" is checked # Only enabled when "Run when closing" is checked
self.askBeforeBackup = QSwitch() self.askBeforeBackup = QSwitch()
self.askBeforeBackup.setChecked(self.mainConf.askBeforeBackup) self.askBeforeBackup.setChecked(CONFIG.askBeforeBackup)
self.askBeforeBackup.setEnabled(self.mainConf.backupOnClose) self.askBeforeBackup.setEnabled(CONFIG.backupOnClose)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Ask before running backup"), self.tr("Ask before running backup"),
self.askBeforeBackup, self.askBeforeBackup,
@@ -418,7 +415,7 @@ class GuiPreferencesProjects(QWidget):
# Pause when idle # Pause when idle
self.stopWhenIdle = QSwitch() self.stopWhenIdle = QSwitch()
self.stopWhenIdle.setChecked(self.mainConf.stopWhenIdle) self.stopWhenIdle.setChecked(CONFIG.stopWhenIdle)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Pause the session timer when not writing"), self.tr("Pause the session timer when not writing"),
self.stopWhenIdle, self.stopWhenIdle,
@@ -431,7 +428,7 @@ class GuiPreferencesProjects(QWidget):
self.userIdleTime.setMaximum(600.0) self.userIdleTime.setMaximum(600.0)
self.userIdleTime.setSingleStep(0.5) self.userIdleTime.setSingleStep(0.5)
self.userIdleTime.setDecimals(1) self.userIdleTime.setDecimals(1)
self.userIdleTime.setValue(self.mainConf.userIdleTime/60.0) self.userIdleTime.setValue(CONFIG.userIdleTime/60.0)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Editor inactive time before pausing timer"), self.tr("Editor inactive time before pausing timer"),
self.userIdleTime, self.userIdleTime,
@@ -445,17 +442,17 @@ class GuiPreferencesProjects(QWidget):
"""Save the values set for this tab. """Save the values set for this tab.
""" """
# Automatic Save # Automatic Save
self.mainConf.autoSaveDoc = self.autoSaveDoc.value() CONFIG.autoSaveDoc = self.autoSaveDoc.value()
self.mainConf.autoSaveProj = self.autoSaveProj.value() CONFIG.autoSaveProj = self.autoSaveProj.value()
# Project Backup # Project Backup
self.mainConf.setBackupPath(self.backupPath) CONFIG.setBackupPath(self.backupPath)
self.mainConf.backupOnClose = self.backupOnClose.isChecked() CONFIG.backupOnClose = self.backupOnClose.isChecked()
self.mainConf.askBeforeBackup = self.askBeforeBackup.isChecked() CONFIG.askBeforeBackup = self.askBeforeBackup.isChecked()
# Session Timer # Session Timer
self.mainConf.stopWhenIdle = self.stopWhenIdle.isChecked() CONFIG.stopWhenIdle = self.stopWhenIdle.isChecked()
self.mainConf.userIdleTime = round(self.userIdleTime.value() * 60) CONFIG.userIdleTime = round(self.userIdleTime.value() * 60)
return return
@@ -494,7 +491,6 @@ class GuiPreferencesDocuments(QWidget):
def __init__(self, prefsGui): def __init__(self, prefsGui):
super().__init__(parent=prefsGui) super().__init__(parent=prefsGui)
self.mainConf = novelwriter.CONFIG
self.mainGui = prefsGui.mainGui self.mainGui = prefsGui.mainGui
self.mainTheme = prefsGui.mainGui.mainTheme self.mainTheme = prefsGui.mainGui.mainTheme
@@ -510,8 +506,8 @@ class GuiPreferencesDocuments(QWidget):
# Font Family # Font Family
self.textFont = QLineEdit() self.textFont = QLineEdit()
self.textFont.setReadOnly(True) self.textFont.setReadOnly(True)
self.textFont.setFixedWidth(self.mainConf.pxInt(162)) self.textFont.setFixedWidth(CONFIG.pxInt(162))
self.textFont.setText(self.mainConf.textFont) self.textFont.setText(CONFIG.textFont)
self.fontButton = QPushButton("...") self.fontButton = QPushButton("...")
self.fontButton.setMaximumWidth(int(2.5*self.mainTheme.getTextWidth("..."))) self.fontButton.setMaximumWidth(int(2.5*self.mainTheme.getTextWidth("...")))
self.fontButton.clicked.connect(self._selectFont) self.fontButton.clicked.connect(self._selectFont)
@@ -527,7 +523,7 @@ class GuiPreferencesDocuments(QWidget):
self.textSize.setMinimum(8) self.textSize.setMinimum(8)
self.textSize.setMaximum(60) self.textSize.setMaximum(60)
self.textSize.setSingleStep(1) self.textSize.setSingleStep(1)
self.textSize.setValue(self.mainConf.textSize) self.textSize.setValue(CONFIG.textSize)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Font size"), self.tr("Font size"),
self.textSize, self.textSize,
@@ -544,7 +540,7 @@ class GuiPreferencesDocuments(QWidget):
self.textWidth.setMinimum(0) self.textWidth.setMinimum(0)
self.textWidth.setMaximum(10000) self.textWidth.setMaximum(10000)
self.textWidth.setSingleStep(10) self.textWidth.setSingleStep(10)
self.textWidth.setValue(self.mainConf.textWidth) self.textWidth.setValue(CONFIG.textWidth)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Maximum text width in \"Normal Mode\""), self.tr("Maximum text width in \"Normal Mode\""),
self.textWidth, self.textWidth,
@@ -557,7 +553,7 @@ class GuiPreferencesDocuments(QWidget):
self.focusWidth.setMinimum(200) self.focusWidth.setMinimum(200)
self.focusWidth.setMaximum(10000) self.focusWidth.setMaximum(10000)
self.focusWidth.setSingleStep(10) self.focusWidth.setSingleStep(10)
self.focusWidth.setValue(self.mainConf.focusWidth) self.focusWidth.setValue(CONFIG.focusWidth)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Maximum text width in \"Focus Mode\""), self.tr("Maximum text width in \"Focus Mode\""),
self.focusWidth, self.focusWidth,
@@ -567,7 +563,7 @@ class GuiPreferencesDocuments(QWidget):
# Focus Mode Footer # Focus Mode Footer
self.hideFocusFooter = QSwitch() self.hideFocusFooter = QSwitch()
self.hideFocusFooter.setChecked(self.mainConf.hideFocusFooter) self.hideFocusFooter.setChecked(CONFIG.hideFocusFooter)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Hide document footer in \"Focus Mode\""), self.tr("Hide document footer in \"Focus Mode\""),
self.hideFocusFooter, self.hideFocusFooter,
@@ -576,7 +572,7 @@ class GuiPreferencesDocuments(QWidget):
# Justify Text # Justify Text
self.doJustify = QSwitch() self.doJustify = QSwitch()
self.doJustify.setChecked(self.mainConf.doJustify) self.doJustify.setChecked(CONFIG.doJustify)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Justify the text margins"), self.tr("Justify the text margins"),
self.doJustify, self.doJustify,
@@ -588,7 +584,7 @@ class GuiPreferencesDocuments(QWidget):
self.textMargin.setMinimum(0) self.textMargin.setMinimum(0)
self.textMargin.setMaximum(900) self.textMargin.setMaximum(900)
self.textMargin.setSingleStep(1) self.textMargin.setSingleStep(1)
self.textMargin.setValue(self.mainConf.textMargin) self.textMargin.setValue(CONFIG.textMargin)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Minimum text margin"), self.tr("Minimum text margin"),
self.textMargin, self.textMargin,
@@ -601,7 +597,7 @@ class GuiPreferencesDocuments(QWidget):
self.tabWidth.setMinimum(0) self.tabWidth.setMinimum(0)
self.tabWidth.setMaximum(200) self.tabWidth.setMaximum(200)
self.tabWidth.setSingleStep(1) self.tabWidth.setSingleStep(1)
self.tabWidth.setValue(self.mainConf.tabWidth) self.tabWidth.setValue(CONFIG.tabWidth)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Tab width"), self.tr("Tab width"),
self.tabWidth, self.tabWidth,
@@ -615,16 +611,16 @@ class GuiPreferencesDocuments(QWidget):
"""Save the values set for this tab. """Save the values set for this tab.
""" """
# Text Style # Text Style
self.mainConf.textFont = self.textFont.text() CONFIG.textFont = self.textFont.text()
self.mainConf.textSize = self.textSize.value() CONFIG.textSize = self.textSize.value()
# Text Flow # Text Flow
self.mainConf.textWidth = self.textWidth.value() CONFIG.textWidth = self.textWidth.value()
self.mainConf.focusWidth = self.focusWidth.value() CONFIG.focusWidth = self.focusWidth.value()
self.mainConf.hideFocusFooter = self.hideFocusFooter.isChecked() CONFIG.hideFocusFooter = self.hideFocusFooter.isChecked()
self.mainConf.doJustify = self.doJustify.isChecked() CONFIG.doJustify = self.doJustify.isChecked()
self.mainConf.textMargin = self.textMargin.value() CONFIG.textMargin = self.textMargin.value()
self.mainConf.tabWidth = self.tabWidth.value() CONFIG.tabWidth = self.tabWidth.value()
return return
@@ -636,8 +632,8 @@ class GuiPreferencesDocuments(QWidget):
"""Open the QFontDialog and set a font for the font style. """Open the QFontDialog and set a font for the font style.
""" """
currFont = QFont() currFont = QFont()
currFont.setFamily(self.mainConf.textFont) currFont.setFamily(CONFIG.textFont)
currFont.setPointSize(self.mainConf.textSize) currFont.setPointSize(CONFIG.textSize)
theFont, theStatus = QFontDialog.getFont(currFont, self) theFont, theStatus = QFontDialog.getFont(currFont, self)
if theStatus: if theStatus:
self.textFont.setText(theFont.family()) self.textFont.setText(theFont.family())
@@ -653,7 +649,6 @@ class GuiPreferencesEditor(QWidget):
def __init__(self, prefsGui): def __init__(self, prefsGui):
super().__init__(parent=prefsGui) super().__init__(parent=prefsGui)
self.mainConf = novelwriter.CONFIG
self.mainGui = prefsGui.mainGui self.mainGui = prefsGui.mainGui
self.mainTheme = prefsGui.mainGui.mainTheme self.mainTheme = prefsGui.mainGui.mainTheme
@@ -662,7 +657,7 @@ class GuiPreferencesEditor(QWidget):
self.mainForm.setHelpTextStyle(self.mainTheme.helpText) self.mainForm.setHelpTextStyle(self.mainTheme.helpText)
self.setLayout(self.mainForm) self.setLayout(self.mainForm)
mW = self.mainConf.pxInt(250) mW = CONFIG.pxInt(250)
# Spell Checking # Spell Checking
# ============== # ==============
@@ -673,7 +668,7 @@ class GuiPreferencesEditor(QWidget):
self.spellLanguage.setMaximumWidth(mW) self.spellLanguage.setMaximumWidth(mW)
langAvail = self.mainGui.docEditor.spEnchant.listDictionaries() langAvail = self.mainGui.docEditor.spEnchant.listDictionaries()
if self.mainConf.hasEnchant: if CONFIG.hasEnchant:
if langAvail: if langAvail:
for spTag, spProv in langAvail: for spTag, spProv in langAvail:
qLocal = QLocale(spTag) qLocal = QLocale(spTag)
@@ -686,7 +681,7 @@ class GuiPreferencesEditor(QWidget):
self.spellLanguage.addItem(self.tr("Not installed"), "") self.spellLanguage.addItem(self.tr("Not installed"), "")
self.spellLanguage.setEnabled(False) self.spellLanguage.setEnabled(False)
spellIdx = self.spellLanguage.findData(self.mainConf.spellLanguage) spellIdx = self.spellLanguage.findData(CONFIG.spellLanguage)
if spellIdx != -1: if spellIdx != -1:
self.spellLanguage.setCurrentIndex(spellIdx) self.spellLanguage.setCurrentIndex(spellIdx)
@@ -701,7 +696,7 @@ class GuiPreferencesEditor(QWidget):
self.bigDocLimit.setMinimum(10) self.bigDocLimit.setMinimum(10)
self.bigDocLimit.setMaximum(10000) self.bigDocLimit.setMaximum(10000)
self.bigDocLimit.setSingleStep(10) self.bigDocLimit.setSingleStep(10)
self.bigDocLimit.setValue(self.mainConf.bigDocLimit) self.bigDocLimit.setValue(CONFIG.bigDocLimit)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Big document limit"), self.tr("Big document limit"),
self.bigDocLimit, self.bigDocLimit,
@@ -719,7 +714,7 @@ class GuiPreferencesEditor(QWidget):
self.wordCountTimer.setMinimum(2.0) self.wordCountTimer.setMinimum(2.0)
self.wordCountTimer.setMaximum(600.0) self.wordCountTimer.setMaximum(600.0)
self.wordCountTimer.setSingleStep(0.1) self.wordCountTimer.setSingleStep(0.1)
self.wordCountTimer.setValue(self.mainConf.wordCountTimer) self.wordCountTimer.setValue(CONFIG.wordCountTimer)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Word count interval"), self.tr("Word count interval"),
self.wordCountTimer, self.wordCountTimer,
@@ -728,7 +723,7 @@ class GuiPreferencesEditor(QWidget):
# Include Notes in Word Count # Include Notes in Word Count
self.incNotesWCount = QSwitch() self.incNotesWCount = QSwitch()
self.incNotesWCount.setChecked(self.mainConf.incNotesWCount) self.incNotesWCount.setChecked(CONFIG.incNotesWCount)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Include project notes in status bar word count"), self.tr("Include project notes in status bar word count"),
self.incNotesWCount self.incNotesWCount
@@ -740,7 +735,7 @@ class GuiPreferencesEditor(QWidget):
# Show Tabs and Spaces # Show Tabs and Spaces
self.showTabsNSpaces = QSwitch() self.showTabsNSpaces = QSwitch()
self.showTabsNSpaces.setChecked(self.mainConf.showTabsNSpaces) self.showTabsNSpaces.setChecked(CONFIG.showTabsNSpaces)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Show tabs and spaces"), self.tr("Show tabs and spaces"),
self.showTabsNSpaces self.showTabsNSpaces
@@ -748,7 +743,7 @@ class GuiPreferencesEditor(QWidget):
# Show Line Endings # Show Line Endings
self.showLineEndings = QSwitch() self.showLineEndings = QSwitch()
self.showLineEndings.setChecked(self.mainConf.showLineEndings) self.showLineEndings.setChecked(CONFIG.showLineEndings)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Show line endings"), self.tr("Show line endings"),
self.showLineEndings self.showLineEndings
@@ -763,7 +758,7 @@ class GuiPreferencesEditor(QWidget):
self.scrollPastEnd.setMinimum(0) self.scrollPastEnd.setMinimum(0)
self.scrollPastEnd.setMaximum(100) self.scrollPastEnd.setMaximum(100)
self.scrollPastEnd.setSingleStep(1) self.scrollPastEnd.setSingleStep(1)
self.scrollPastEnd.setValue(int(self.mainConf.scrollPastEnd)) self.scrollPastEnd.setValue(int(CONFIG.scrollPastEnd))
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Scroll past end of the document"), self.tr("Scroll past end of the document"),
self.scrollPastEnd, self.scrollPastEnd,
@@ -773,7 +768,7 @@ class GuiPreferencesEditor(QWidget):
# Typewriter Scrolling # Typewriter Scrolling
self.autoScroll = QSwitch() self.autoScroll = QSwitch()
self.autoScroll.setChecked(self.mainConf.autoScroll) self.autoScroll.setChecked(CONFIG.autoScroll)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Typewriter style scrolling when you type"), self.tr("Typewriter style scrolling when you type"),
self.autoScroll, self.autoScroll,
@@ -785,7 +780,7 @@ class GuiPreferencesEditor(QWidget):
self.autoScrollPos.setMinimum(10) self.autoScrollPos.setMinimum(10)
self.autoScrollPos.setMaximum(90) self.autoScrollPos.setMaximum(90)
self.autoScrollPos.setSingleStep(1) self.autoScrollPos.setSingleStep(1)
self.autoScrollPos.setValue(int(self.mainConf.autoScrollPos)) self.autoScrollPos.setValue(int(CONFIG.autoScrollPos))
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Minimum position for Typewriter scrolling"), self.tr("Minimum position for Typewriter scrolling"),
self.autoScrollPos, self.autoScrollPos,
@@ -799,21 +794,21 @@ class GuiPreferencesEditor(QWidget):
"""Save the values set for this tab. """Save the values set for this tab.
""" """
# Spell Checking # Spell Checking
self.mainConf.spellLanguage = self.spellLanguage.currentData() CONFIG.spellLanguage = self.spellLanguage.currentData()
self.mainConf.bigDocLimit = self.bigDocLimit.value() CONFIG.bigDocLimit = self.bigDocLimit.value()
# Word Count # Word Count
self.mainConf.wordCountTimer = self.wordCountTimer.value() CONFIG.wordCountTimer = self.wordCountTimer.value()
self.mainConf.incNotesWCount = self.incNotesWCount.isChecked() CONFIG.incNotesWCount = self.incNotesWCount.isChecked()
# Writing Guides # Writing Guides
self.mainConf.showTabsNSpaces = self.showTabsNSpaces.isChecked() CONFIG.showTabsNSpaces = self.showTabsNSpaces.isChecked()
self.mainConf.showLineEndings = self.showLineEndings.isChecked() CONFIG.showLineEndings = self.showLineEndings.isChecked()
# Scroll Behaviour # Scroll Behaviour
self.mainConf.scrollPastEnd = self.scrollPastEnd.value() CONFIG.scrollPastEnd = self.scrollPastEnd.value()
self.mainConf.autoScroll = self.autoScroll.isChecked() CONFIG.autoScroll = self.autoScroll.isChecked()
self.mainConf.autoScrollPos = self.autoScrollPos.value() CONFIG.autoScrollPos = self.autoScrollPos.value()
return return
@@ -825,7 +820,6 @@ class GuiPreferencesSyntax(QWidget):
def __init__(self, prefsGui): def __init__(self, prefsGui):
super().__init__(parent=prefsGui) super().__init__(parent=prefsGui)
self.mainConf = novelwriter.CONFIG
self.prefsGui = prefsGui self.prefsGui = prefsGui
self.mainGui = prefsGui.mainGui self.mainGui = prefsGui.mainGui
self.mainTheme = prefsGui.mainGui.mainTheme self.mainTheme = prefsGui.mainGui.mainTheme
@@ -840,7 +834,7 @@ class GuiPreferencesSyntax(QWidget):
self.mainForm.addGroupLabel(self.tr("Quotes & Dialogue")) self.mainForm.addGroupLabel(self.tr("Quotes & Dialogue"))
self.highlightQuotes = QSwitch() self.highlightQuotes = QSwitch()
self.highlightQuotes.setChecked(self.mainConf.highlightQuotes) self.highlightQuotes.setChecked(CONFIG.highlightQuotes)
self.highlightQuotes.toggled.connect(self._toggleHighlightQuotes) self.highlightQuotes.toggled.connect(self._toggleHighlightQuotes)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Highlight text wrapped in quotes"), self.tr("Highlight text wrapped in quotes"),
@@ -849,7 +843,7 @@ class GuiPreferencesSyntax(QWidget):
) )
self.allowOpenSQuote = QSwitch() self.allowOpenSQuote = QSwitch()
self.allowOpenSQuote.setChecked(self.mainConf.allowOpenSQuote) self.allowOpenSQuote.setChecked(CONFIG.allowOpenSQuote)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Allow open-ended single quotes"), self.tr("Allow open-ended single quotes"),
self.allowOpenSQuote, self.allowOpenSQuote,
@@ -857,7 +851,7 @@ class GuiPreferencesSyntax(QWidget):
) )
self.allowOpenDQuote = QSwitch() self.allowOpenDQuote = QSwitch()
self.allowOpenDQuote.setChecked(self.mainConf.allowOpenDQuote) self.allowOpenDQuote.setChecked(CONFIG.allowOpenDQuote)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Allow open-ended double quotes"), self.tr("Allow open-ended double quotes"),
self.allowOpenDQuote, self.allowOpenDQuote,
@@ -869,7 +863,7 @@ class GuiPreferencesSyntax(QWidget):
self.mainForm.addGroupLabel(self.tr("Text Emphasis")) self.mainForm.addGroupLabel(self.tr("Text Emphasis"))
self.highlightEmph = QSwitch() self.highlightEmph = QSwitch()
self.highlightEmph.setChecked(self.mainConf.highlightEmph) self.highlightEmph.setChecked(CONFIG.highlightEmph)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Add highlight colour to emphasised text"), self.tr("Add highlight colour to emphasised text"),
self.highlightEmph, self.highlightEmph,
@@ -882,7 +876,7 @@ class GuiPreferencesSyntax(QWidget):
self.mainForm.addGroupLabel(self.tr("Text Errors")) self.mainForm.addGroupLabel(self.tr("Text Errors"))
self.showMultiSpaces = QSwitch() self.showMultiSpaces = QSwitch()
self.showMultiSpaces.setChecked(self.mainConf.showMultiSpaces) self.showMultiSpaces.setChecked(CONFIG.showMultiSpaces)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Highlight multiple or trailing spaces"), self.tr("Highlight multiple or trailing spaces"),
self.showMultiSpaces, self.showMultiSpaces,
@@ -900,15 +894,15 @@ class GuiPreferencesSyntax(QWidget):
highlightEmph = self.highlightEmph.isChecked() highlightEmph = self.highlightEmph.isChecked()
showMultiSpaces = self.showMultiSpaces.isChecked() showMultiSpaces = self.showMultiSpaces.isChecked()
self.prefsGui._updateSyntax |= self.mainConf.highlightQuotes != highlightQuotes self.prefsGui._updateSyntax |= CONFIG.highlightQuotes != highlightQuotes
self.prefsGui._updateSyntax |= self.mainConf.highlightEmph != highlightEmph self.prefsGui._updateSyntax |= CONFIG.highlightEmph != highlightEmph
self.prefsGui._updateSyntax |= self.mainConf.showMultiSpaces != showMultiSpaces self.prefsGui._updateSyntax |= CONFIG.showMultiSpaces != showMultiSpaces
self.mainConf.highlightQuotes = highlightQuotes CONFIG.highlightQuotes = highlightQuotes
self.mainConf.allowOpenSQuote = allowOpenSQuote CONFIG.allowOpenSQuote = allowOpenSQuote
self.mainConf.allowOpenDQuote = allowOpenDQuote CONFIG.allowOpenDQuote = allowOpenDQuote
self.mainConf.highlightEmph = highlightEmph CONFIG.highlightEmph = highlightEmph
self.mainConf.showMultiSpaces = showMultiSpaces CONFIG.showMultiSpaces = showMultiSpaces
return return
@@ -932,7 +926,6 @@ class GuiPreferencesAutomation(QWidget):
def __init__(self, prefsGui): def __init__(self, prefsGui):
super().__init__(parent=prefsGui) super().__init__(parent=prefsGui)
self.mainConf = novelwriter.CONFIG
self.mainGui = prefsGui.mainGui self.mainGui = prefsGui.mainGui
self.mainTheme = prefsGui.mainGui.mainTheme self.mainTheme = prefsGui.mainGui.mainTheme
@@ -947,7 +940,7 @@ class GuiPreferencesAutomation(QWidget):
# Auto-Select Word Under Cursor # Auto-Select Word Under Cursor
self.autoSelect = QSwitch() self.autoSelect = QSwitch()
self.autoSelect.setChecked(self.mainConf.autoSelect) self.autoSelect.setChecked(CONFIG.autoSelect)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Auto-select word under cursor"), self.tr("Auto-select word under cursor"),
self.autoSelect, self.autoSelect,
@@ -956,7 +949,7 @@ class GuiPreferencesAutomation(QWidget):
# Auto-Replace as You Type Main Switch # Auto-Replace as You Type Main Switch
self.doReplace = QSwitch() self.doReplace = QSwitch()
self.doReplace.setChecked(self.mainConf.doReplace) self.doReplace.setChecked(CONFIG.doReplace)
self.doReplace.toggled.connect(self._toggleAutoReplaceMain) self.doReplace.toggled.connect(self._toggleAutoReplaceMain)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Auto-replace text as you type"), self.tr("Auto-replace text as you type"),
@@ -970,8 +963,8 @@ class GuiPreferencesAutomation(QWidget):
# Auto-Replace Single Quotes # Auto-Replace Single Quotes
self.doReplaceSQuote = QSwitch() self.doReplaceSQuote = QSwitch()
self.doReplaceSQuote.setChecked(self.mainConf.doReplaceSQuote) self.doReplaceSQuote.setChecked(CONFIG.doReplaceSQuote)
self.doReplaceSQuote.setEnabled(self.mainConf.doReplace) self.doReplaceSQuote.setEnabled(CONFIG.doReplace)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Auto-replace single quotes"), self.tr("Auto-replace single quotes"),
self.doReplaceSQuote, self.doReplaceSQuote,
@@ -980,8 +973,8 @@ class GuiPreferencesAutomation(QWidget):
# Auto-Replace Double Quotes # Auto-Replace Double Quotes
self.doReplaceDQuote = QSwitch() self.doReplaceDQuote = QSwitch()
self.doReplaceDQuote.setChecked(self.mainConf.doReplaceDQuote) self.doReplaceDQuote.setChecked(CONFIG.doReplaceDQuote)
self.doReplaceDQuote.setEnabled(self.mainConf.doReplace) self.doReplaceDQuote.setEnabled(CONFIG.doReplace)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Auto-replace double quotes"), self.tr("Auto-replace double quotes"),
self.doReplaceDQuote, self.doReplaceDQuote,
@@ -990,8 +983,8 @@ class GuiPreferencesAutomation(QWidget):
# Auto-Replace Hyphens # Auto-Replace Hyphens
self.doReplaceDash = QSwitch() self.doReplaceDash = QSwitch()
self.doReplaceDash.setChecked(self.mainConf.doReplaceDash) self.doReplaceDash.setChecked(CONFIG.doReplaceDash)
self.doReplaceDash.setEnabled(self.mainConf.doReplace) self.doReplaceDash.setEnabled(CONFIG.doReplace)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Auto-replace dashes"), self.tr("Auto-replace dashes"),
self.doReplaceDash, self.doReplaceDash,
@@ -1000,8 +993,8 @@ class GuiPreferencesAutomation(QWidget):
# Auto-Replace Dots # Auto-Replace Dots
self.doReplaceDots = QSwitch() self.doReplaceDots = QSwitch()
self.doReplaceDots.setChecked(self.mainConf.doReplaceDots) self.doReplaceDots.setChecked(CONFIG.doReplaceDots)
self.doReplaceDots.setEnabled(self.mainConf.doReplace) self.doReplaceDots.setEnabled(CONFIG.doReplace)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Auto-replace dots"), self.tr("Auto-replace dots"),
self.doReplaceDots, self.doReplaceDots,
@@ -1015,7 +1008,7 @@ class GuiPreferencesAutomation(QWidget):
# Pad Before # Pad Before
self.fmtPadBefore = QLineEdit() self.fmtPadBefore = QLineEdit()
self.fmtPadBefore.setMaxLength(32) self.fmtPadBefore.setMaxLength(32)
self.fmtPadBefore.setText(self.mainConf.fmtPadBefore) self.fmtPadBefore.setText(CONFIG.fmtPadBefore)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Insert non-breaking space before"), self.tr("Insert non-breaking space before"),
self.fmtPadBefore, self.fmtPadBefore,
@@ -1025,7 +1018,7 @@ class GuiPreferencesAutomation(QWidget):
# Pad After # Pad After
self.fmtPadAfter = QLineEdit() self.fmtPadAfter = QLineEdit()
self.fmtPadAfter.setMaxLength(32) self.fmtPadAfter.setMaxLength(32)
self.fmtPadAfter.setText(self.mainConf.fmtPadAfter) self.fmtPadAfter.setText(CONFIG.fmtPadAfter)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Insert non-breaking space after"), self.tr("Insert non-breaking space after"),
self.fmtPadAfter, self.fmtPadAfter,
@@ -1034,8 +1027,8 @@ class GuiPreferencesAutomation(QWidget):
# Use Thin Space # Use Thin Space
self.fmtPadThin = QSwitch() self.fmtPadThin = QSwitch()
self.fmtPadThin.setChecked(self.mainConf.fmtPadThin) self.fmtPadThin.setChecked(CONFIG.fmtPadThin)
self.fmtPadThin.setEnabled(self.mainConf.doReplace) self.fmtPadThin.setEnabled(CONFIG.doReplace)
self.mainForm.addRow( self.mainForm.addRow(
self.tr("Use thin space instead"), self.tr("Use thin space instead"),
self.fmtPadThin, self.fmtPadThin,
@@ -1048,19 +1041,19 @@ class GuiPreferencesAutomation(QWidget):
"""Save the values set for this tab. """Save the values set for this tab.
""" """
# Automatic Features # Automatic Features
self.mainConf.autoSelect = self.autoSelect.isChecked() CONFIG.autoSelect = self.autoSelect.isChecked()
self.mainConf.doReplace = self.doReplace.isChecked() CONFIG.doReplace = self.doReplace.isChecked()
# Replace as You Type # Replace as You Type
self.mainConf.doReplaceSQuote = self.doReplaceSQuote.isChecked() CONFIG.doReplaceSQuote = self.doReplaceSQuote.isChecked()
self.mainConf.doReplaceDQuote = self.doReplaceDQuote.isChecked() CONFIG.doReplaceDQuote = self.doReplaceDQuote.isChecked()
self.mainConf.doReplaceDash = self.doReplaceDash.isChecked() CONFIG.doReplaceDash = self.doReplaceDash.isChecked()
self.mainConf.doReplaceDots = self.doReplaceDots.isChecked() CONFIG.doReplaceDots = self.doReplaceDots.isChecked()
# Automatic Padding # Automatic Padding
self.mainConf.fmtPadBefore = self.fmtPadBefore.text().strip() CONFIG.fmtPadBefore = self.fmtPadBefore.text().strip()
self.mainConf.fmtPadAfter = self.fmtPadAfter.text().strip() CONFIG.fmtPadAfter = self.fmtPadAfter.text().strip()
self.mainConf.fmtPadThin = self.fmtPadThin.isChecked() CONFIG.fmtPadThin = self.fmtPadThin.isChecked()
return return
@@ -1087,7 +1080,6 @@ class GuiPreferencesQuotes(QWidget):
def __init__(self, prefsGui): def __init__(self, prefsGui):
super().__init__(parent=prefsGui) super().__init__(parent=prefsGui)
self.mainConf = novelwriter.CONFIG
self.mainGui = prefsGui.mainGui self.mainGui = prefsGui.mainGui
self.mainTheme = prefsGui.mainGui.mainTheme self.mainTheme = prefsGui.mainGui.mainTheme
@@ -1100,7 +1092,7 @@ class GuiPreferencesQuotes(QWidget):
# =============== # ===============
self.mainForm.addGroupLabel(self.tr("Quotation Style")) self.mainForm.addGroupLabel(self.tr("Quotation Style"))
qWidth = self.mainConf.pxInt(40) qWidth = CONFIG.pxInt(40)
bWidth = int(2.5*self.mainTheme.getTextWidth("...")) bWidth = int(2.5*self.mainTheme.getTextWidth("..."))
self.quoteSym = {} self.quoteSym = {}
@@ -1110,7 +1102,7 @@ class GuiPreferencesQuotes(QWidget):
self.quoteSym["SO"].setReadOnly(True) self.quoteSym["SO"].setReadOnly(True)
self.quoteSym["SO"].setFixedWidth(qWidth) self.quoteSym["SO"].setFixedWidth(qWidth)
self.quoteSym["SO"].setAlignment(Qt.AlignCenter) self.quoteSym["SO"].setAlignment(Qt.AlignCenter)
self.quoteSym["SO"].setText(self.mainConf.fmtSQuoteOpen) self.quoteSym["SO"].setText(CONFIG.fmtSQuoteOpen)
self.btnSingleStyleO = QPushButton("...") self.btnSingleStyleO = QPushButton("...")
self.btnSingleStyleO.setMaximumWidth(bWidth) self.btnSingleStyleO.setMaximumWidth(bWidth)
self.btnSingleStyleO.clicked.connect(lambda: self._getQuote("SO")) self.btnSingleStyleO.clicked.connect(lambda: self._getQuote("SO"))
@@ -1126,7 +1118,7 @@ class GuiPreferencesQuotes(QWidget):
self.quoteSym["SC"].setReadOnly(True) self.quoteSym["SC"].setReadOnly(True)
self.quoteSym["SC"].setFixedWidth(qWidth) self.quoteSym["SC"].setFixedWidth(qWidth)
self.quoteSym["SC"].setAlignment(Qt.AlignCenter) self.quoteSym["SC"].setAlignment(Qt.AlignCenter)
self.quoteSym["SC"].setText(self.mainConf.fmtSQuoteClose) self.quoteSym["SC"].setText(CONFIG.fmtSQuoteClose)
self.btnSingleStyleC = QPushButton("...") self.btnSingleStyleC = QPushButton("...")
self.btnSingleStyleC.setMaximumWidth(bWidth) self.btnSingleStyleC.setMaximumWidth(bWidth)
self.btnSingleStyleC.clicked.connect(lambda: self._getQuote("SC")) self.btnSingleStyleC.clicked.connect(lambda: self._getQuote("SC"))
@@ -1143,7 +1135,7 @@ class GuiPreferencesQuotes(QWidget):
self.quoteSym["DO"].setReadOnly(True) self.quoteSym["DO"].setReadOnly(True)
self.quoteSym["DO"].setFixedWidth(qWidth) self.quoteSym["DO"].setFixedWidth(qWidth)
self.quoteSym["DO"].setAlignment(Qt.AlignCenter) self.quoteSym["DO"].setAlignment(Qt.AlignCenter)
self.quoteSym["DO"].setText(self.mainConf.fmtDQuoteOpen) self.quoteSym["DO"].setText(CONFIG.fmtDQuoteOpen)
self.btnDoubleStyleO = QPushButton("...") self.btnDoubleStyleO = QPushButton("...")
self.btnDoubleStyleO.setMaximumWidth(bWidth) self.btnDoubleStyleO.setMaximumWidth(bWidth)
self.btnDoubleStyleO.clicked.connect(lambda: self._getQuote("DO")) self.btnDoubleStyleO.clicked.connect(lambda: self._getQuote("DO"))
@@ -1159,7 +1151,7 @@ class GuiPreferencesQuotes(QWidget):
self.quoteSym["DC"].setReadOnly(True) self.quoteSym["DC"].setReadOnly(True)
self.quoteSym["DC"].setFixedWidth(qWidth) self.quoteSym["DC"].setFixedWidth(qWidth)
self.quoteSym["DC"].setAlignment(Qt.AlignCenter) self.quoteSym["DC"].setAlignment(Qt.AlignCenter)
self.quoteSym["DC"].setText(self.mainConf.fmtDQuoteClose) self.quoteSym["DC"].setText(CONFIG.fmtDQuoteClose)
self.btnDoubleStyleC = QPushButton("...") self.btnDoubleStyleC = QPushButton("...")
self.btnDoubleStyleC.setMaximumWidth(bWidth) self.btnDoubleStyleC.setMaximumWidth(bWidth)
self.btnDoubleStyleC.clicked.connect(lambda: self._getQuote("DC")) self.btnDoubleStyleC.clicked.connect(lambda: self._getQuote("DC"))
@@ -1176,10 +1168,10 @@ class GuiPreferencesQuotes(QWidget):
"""Save the values set for this tab. """Save the values set for this tab.
""" """
# Quotation Style # Quotation Style
self.mainConf.fmtSQuoteOpen = self.quoteSym["SO"].text() CONFIG.fmtSQuoteOpen = self.quoteSym["SO"].text()
self.mainConf.fmtSQuoteClose = self.quoteSym["SC"].text() CONFIG.fmtSQuoteClose = self.quoteSym["SC"].text()
self.mainConf.fmtDQuoteOpen = self.quoteSym["DO"].text() CONFIG.fmtDQuoteOpen = self.quoteSym["DO"].text()
self.mainConf.fmtDQuoteClose = self.quoteSym["DC"].text() CONFIG.fmtDQuoteClose = self.quoteSym["DC"].text()
return return
## ##
+22 -25
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import math import math
import logging import logging
import novelwriter
from PyQt5.QtCore import Qt, QSize, pyqtSlot from PyQt5.QtCore import Qt, QSize, pyqtSlot
from PyQt5.QtGui import QFont from PyQt5.QtGui import QFont
@@ -34,6 +33,7 @@ from PyQt5.QtWidgets import (
QLineEdit, QSpinBox, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget QLineEdit, QSpinBox, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
) )
from novelwriter import CONFIG
from novelwriter.common import formatTime, numberToRoman from novelwriter.common import formatTime, numberToRoman
from novelwriter.custom import PagedDialog, QSwitch from novelwriter.custom import PagedDialog, QSwitch
from novelwriter.constants import nwUnicode from novelwriter.constants import nwUnicode
@@ -50,21 +50,20 @@ class GuiProjectDetails(PagedDialog):
logger.debug("Initialising GuiProjectDetails ...") logger.debug("Initialising GuiProjectDetails ...")
self.setObjectName("GuiProjectDetails") self.setObjectName("GuiProjectDetails")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
self.setWindowTitle(self.tr("Project Details")) self.setWindowTitle(self.tr("Project Details"))
wW = self.mainConf.pxInt(600) wW = CONFIG.pxInt(600)
wH = self.mainConf.pxInt(400) wH = CONFIG.pxInt(400)
pOptions = self.theProject.options pOptions = self.theProject.options
self.setMinimumWidth(wW) self.setMinimumWidth(wW)
self.setMinimumHeight(wH) self.setMinimumHeight(wH)
self.resize( self.resize(
self.mainConf.pxInt(pOptions.getInt("GuiProjectDetails", "winWidth", wW)), CONFIG.pxInt(pOptions.getInt("GuiProjectDetails", "winWidth", wW)),
self.mainConf.pxInt(pOptions.getInt("GuiProjectDetails", "winHeight", wH)) CONFIG.pxInt(pOptions.getInt("GuiProjectDetails", "winHeight", wH))
) )
self.tabMain = GuiProjectDetailsMain(self.mainGui, self.theProject) self.tabMain = GuiProjectDetailsMain(self.mainGui, self.theProject)
@@ -107,15 +106,15 @@ class GuiProjectDetails(PagedDialog):
def _saveGuiSettings(self): def _saveGuiSettings(self):
"""Save GUI settings. """Save GUI settings.
""" """
winWidth = self.mainConf.rpxInt(self.width()) winWidth = CONFIG.rpxInt(self.width())
winHeight = self.mainConf.rpxInt(self.height()) winHeight = CONFIG.rpxInt(self.height())
cColWidth = self.tabContents.getColumnSizes() cColWidth = self.tabContents.getColumnSizes()
widthCol0 = self.mainConf.rpxInt(cColWidth[0]) widthCol0 = CONFIG.rpxInt(cColWidth[0])
widthCol1 = self.mainConf.rpxInt(cColWidth[1]) widthCol1 = CONFIG.rpxInt(cColWidth[1])
widthCol2 = self.mainConf.rpxInt(cColWidth[2]) widthCol2 = CONFIG.rpxInt(cColWidth[2])
widthCol3 = self.mainConf.rpxInt(cColWidth[3]) widthCol3 = CONFIG.rpxInt(cColWidth[3])
widthCol4 = self.mainConf.rpxInt(cColWidth[4]) widthCol4 = CONFIG.rpxInt(cColWidth[4])
wordsPerPage = self.tabContents.wpValue.value() wordsPerPage = self.tabContents.wpValue.value()
countFrom = self.tabContents.poValue.value() countFrom = self.tabContents.poValue.value()
@@ -143,15 +142,14 @@ class GuiProjectDetailsMain(QWidget):
def __init__(self, mainGui, theProject): def __init__(self, mainGui, theProject):
super().__init__(parent=mainGui) super().__init__(parent=mainGui)
self.mainConf = novelwriter.CONFIG
self.theProject = theProject self.theProject = theProject
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
fPx = self.mainTheme.fontPixelSize fPx = self.mainTheme.fontPixelSize
fPt = self.mainTheme.fontPointSize fPt = self.mainTheme.fontPointSize
vPx = self.mainConf.pxInt(4) vPx = CONFIG.pxInt(4)
hPx = self.mainConf.pxInt(12) hPx = CONFIG.pxInt(12)
# Header # Header
# ====== # ======
@@ -277,7 +275,6 @@ class GuiProjectDetailsContents(QWidget):
def __init__(self, mainGui, theProject): def __init__(self, mainGui, theProject):
super().__init__(parent=mainGui) super().__init__(parent=mainGui)
self.mainConf = novelwriter.CONFIG
self.theProject = theProject self.theProject = theProject
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
@@ -287,8 +284,8 @@ class GuiProjectDetailsContents(QWidget):
self._currentRoot = None self._currentRoot = None
iPx = self.mainTheme.baseIconSize iPx = self.mainTheme.baseIconSize
hPx = self.mainConf.pxInt(12) hPx = CONFIG.pxInt(12)
vPx = self.mainConf.pxInt(4) vPx = CONFIG.pxInt(4)
pOptions = self.theProject.options pOptions = self.theProject.options
# Header # Header
@@ -297,7 +294,7 @@ class GuiProjectDetailsContents(QWidget):
self.tocLabel = QLabel("<b>%s</b>" % self.tr("Table of Contents")) self.tocLabel = QLabel("<b>%s</b>" % self.tr("Table of Contents"))
self.novelValue = NovelSelector(self, self.theProject, self.mainGui) self.novelValue = NovelSelector(self, self.theProject, self.mainGui)
self.novelValue.setMinimumWidth(self.mainConf.pxInt(200)) self.novelValue.setMinimumWidth(CONFIG.pxInt(200))
self.novelValue.novelSelectionChanged.connect(self._novelValueChanged) self.novelValue.novelSelectionChanged.connect(self._novelValueChanged)
self.headBox = QHBoxLayout() self.headBox = QHBoxLayout()
@@ -331,11 +328,11 @@ class GuiProjectDetailsContents(QWidget):
treeHeader.setStretchLastSection(True) treeHeader.setStretchLastSection(True)
treeHeader.setMinimumSectionSize(hPx) treeHeader.setMinimumSectionSize(hPx)
wCol0 = self.mainConf.pxInt(pOptions.getInt("GuiProjectDetails", "widthCol0", 200)) wCol0 = CONFIG.pxInt(pOptions.getInt("GuiProjectDetails", "widthCol0", 200))
wCol1 = self.mainConf.pxInt(pOptions.getInt("GuiProjectDetails", "widthCol1", 60)) wCol1 = CONFIG.pxInt(pOptions.getInt("GuiProjectDetails", "widthCol1", 60))
wCol2 = self.mainConf.pxInt(pOptions.getInt("GuiProjectDetails", "widthCol2", 60)) wCol2 = CONFIG.pxInt(pOptions.getInt("GuiProjectDetails", "widthCol2", 60))
wCol3 = self.mainConf.pxInt(pOptions.getInt("GuiProjectDetails", "widthCol3", 60)) wCol3 = CONFIG.pxInt(pOptions.getInt("GuiProjectDetails", "widthCol3", 60))
wCol4 = self.mainConf.pxInt(pOptions.getInt("GuiProjectDetails", "widthCol4", 90)) wCol4 = CONFIG.pxInt(pOptions.getInt("GuiProjectDetails", "widthCol4", 90))
self.tocTree.setColumnWidth(0, wCol0) self.tocTree.setColumnWidth(0, wCol0)
self.tocTree.setColumnWidth(1, wCol1) self.tocTree.setColumnWidth(1, wCol1)
+11 -12
View File
@@ -24,7 +24,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from pathlib import Path from pathlib import Path
from datetime import datetime from datetime import datetime
@@ -37,6 +36,7 @@ from PyQt5.QtWidgets import (
QFileDialog, QLineEdit QFileDialog, QLineEdit
) )
from novelwriter import CONFIG
from novelwriter.common import formatInt from novelwriter.common import formatInt
from novelwriter.constants import nwFiles from novelwriter.constants import nwFiles
@@ -59,14 +59,13 @@ class GuiProjectLoad(QDialog):
logger.debug("Initialising GuiProjectLoad ...") logger.debug("Initialising GuiProjectLoad ...")
self.setObjectName("GuiProjectLoad") self.setObjectName("GuiProjectLoad")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
self.openState = self.NONE_STATE self.openState = self.NONE_STATE
self.openPath = None self.openPath = None
sPx = self.mainConf.pxInt(16) sPx = CONFIG.pxInt(16)
nPx = self.mainConf.pxInt(96) nPx = CONFIG.pxInt(96)
iPx = self.mainTheme.baseIconSize iPx = self.mainTheme.baseIconSize
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
@@ -75,8 +74,8 @@ class GuiProjectLoad(QDialog):
self.innerBox.setSpacing(sPx) self.innerBox.setSpacing(sPx)
self.setWindowTitle(self.tr("Open Project")) self.setWindowTitle(self.tr("Open Project"))
self.setMinimumWidth(self.mainConf.pxInt(650)) self.setMinimumWidth(CONFIG.pxInt(650))
self.setMinimumHeight(self.mainConf.pxInt(400)) self.setMinimumHeight(CONFIG.pxInt(400))
self.nwIcon = QLabel() self.nwIcon = QLabel()
self.nwIcon.setPixmap(self.mainGui.mainTheme.getPixmap("novelwriter", (nPx, nPx))) self.nwIcon.setPixmap(self.mainGui.mainTheme.getPixmap("novelwriter", (nPx, nPx)))
@@ -120,8 +119,8 @@ class GuiProjectLoad(QDialog):
self.projectForm.setColumnStretch(0, 0) self.projectForm.setColumnStretch(0, 0)
self.projectForm.setColumnStretch(1, 1) self.projectForm.setColumnStretch(1, 1)
self.projectForm.setColumnStretch(2, 0) self.projectForm.setColumnStretch(2, 0)
self.projectForm.setVerticalSpacing(self.mainConf.pxInt(4)) self.projectForm.setVerticalSpacing(CONFIG.pxInt(4))
self.projectForm.setHorizontalSpacing(self.mainConf.pxInt(8)) self.projectForm.setHorizontalSpacing(CONFIG.pxInt(8))
self.innerBox.addLayout(self.projectForm) self.innerBox.addLayout(self.projectForm)
@@ -228,7 +227,7 @@ class GuiProjectLoad(QDialog):
).format(projName) ).format(projName)
) )
if msgYes: if msgYes:
self.mainConf.recentProjects.remove( CONFIG.recentProjects.remove(
selList[0].data(self.C_NAME, Qt.UserRole) selList[0].data(self.C_NAME, Qt.UserRole)
) )
self._populateList() self._populateList()
@@ -257,14 +256,14 @@ class GuiProjectLoad(QDialog):
colWidths[self.C_NAME] = self.listBox.columnWidth(self.C_NAME) colWidths[self.C_NAME] = self.listBox.columnWidth(self.C_NAME)
colWidths[self.C_COUNT] = self.listBox.columnWidth(self.C_COUNT) colWidths[self.C_COUNT] = self.listBox.columnWidth(self.C_COUNT)
colWidths[self.C_TIME] = self.listBox.columnWidth(self.C_TIME) colWidths[self.C_TIME] = self.listBox.columnWidth(self.C_TIME)
self.mainConf.setProjLoadColWidths(colWidths) CONFIG.setProjLoadColWidths(colWidths)
return return
def _populateList(self): def _populateList(self):
"""Populate the list box with recent project data. """Populate the list box with recent project data.
""" """
self.listBox.clear() self.listBox.clear()
dataList = self.mainConf.recentProjects.listEntries() dataList = CONFIG.recentProjects.listEntries()
sortList = sorted(dataList, key=lambda x: x[3], reverse=True) sortList = sorted(dataList, key=lambda x: x[3], reverse=True)
nwxIcon = self.mainGui.mainTheme.getIcon("proj_nwx") nwxIcon = self.mainGui.mainTheme.getIcon("proj_nwx")
for path, title, words, time in sortList: for path, title, words, time in sortList:
@@ -283,7 +282,7 @@ class GuiProjectLoad(QDialog):
if self.listBox.topLevelItemCount() > 0: if self.listBox.topLevelItemCount() > 0:
self.listBox.topLevelItem(0).setSelected(True) self.listBox.topLevelItem(0).setSelected(True)
projColWidth = self.mainConf.projLoadColWidths projColWidth = CONFIG.projLoadColWidths
if len(projColWidth) == 3: if len(projColWidth) == 3:
self.listBox.setColumnWidth(self.C_NAME, projColWidth[self.C_NAME]) self.listBox.setColumnWidth(self.C_NAME, projColWidth[self.C_NAME])
self.listBox.setColumnWidth(self.C_COUNT, projColWidth[self.C_COUNT]) self.listBox.setColumnWidth(self.C_COUNT, projColWidth[self.C_COUNT])
+13 -17
View File
@@ -24,7 +24,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from PyQt5.QtGui import QIcon, QPixmap, QColor from PyQt5.QtGui import QIcon, QPixmap, QColor
from PyQt5.QtCore import Qt, QLocale, pyqtSlot from PyQt5.QtCore import Qt, QLocale, pyqtSlot
@@ -33,6 +32,7 @@ from PyQt5.QtWidgets import (
QPushButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget QPushButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
) )
from novelwriter import CONFIG
from novelwriter.enum import nwAlert from novelwriter.enum import nwAlert
from novelwriter.common import simplified from novelwriter.common import simplified
from novelwriter.custom import QSwitch, PagedDialog, QConfigLayout from novelwriter.custom import QSwitch, PagedDialog, QConfigLayout
@@ -53,22 +53,21 @@ class GuiProjectSettings(PagedDialog):
logger.debug("Initialising GuiProjectSettings ...") logger.debug("Initialising GuiProjectSettings ...")
self.setObjectName("GuiProjectSettings") self.setObjectName("GuiProjectSettings")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
self.theProject.countStatus() self.theProject.countStatus()
self.setWindowTitle(self.tr("Project Settings")) self.setWindowTitle(self.tr("Project Settings"))
wW = self.mainConf.pxInt(570) wW = CONFIG.pxInt(570)
wH = self.mainConf.pxInt(375) wH = CONFIG.pxInt(375)
pOptions = self.theProject.options pOptions = self.theProject.options
self.setMinimumWidth(wW) self.setMinimumWidth(wW)
self.setMinimumHeight(wH) self.setMinimumHeight(wH)
self.resize( self.resize(
self.mainConf.pxInt(pOptions.getInt("GuiProjectSettings", "winWidth", wW)), CONFIG.pxInt(pOptions.getInt("GuiProjectSettings", "winWidth", wW)),
self.mainConf.pxInt(pOptions.getInt("GuiProjectSettings", "winHeight", wH)) CONFIG.pxInt(pOptions.getInt("GuiProjectSettings", "winHeight", wH))
) )
self.tabMain = GuiProjectEditMain(self) self.tabMain = GuiProjectEditMain(self)
@@ -168,11 +167,11 @@ class GuiProjectSettings(PagedDialog):
def _saveGuiSettings(self): def _saveGuiSettings(self):
"""Save GUI settings. """Save GUI settings.
""" """
winWidth = self.mainConf.rpxInt(self.width()) winWidth = CONFIG.rpxInt(self.width())
winHeight = self.mainConf.rpxInt(self.height()) winHeight = CONFIG.rpxInt(self.height())
replaceColW = self.mainConf.rpxInt(self.tabReplace.listBox.columnWidth(0)) replaceColW = CONFIG.rpxInt(self.tabReplace.listBox.columnWidth(0))
statusColW = self.mainConf.rpxInt(self.tabStatus.listBox.columnWidth(0)) statusColW = CONFIG.rpxInt(self.tabStatus.listBox.columnWidth(0))
importColW = self.mainConf.rpxInt(self.tabImport.listBox.columnWidth(0)) importColW = CONFIG.rpxInt(self.tabImport.listBox.columnWidth(0))
pOptions = self.theProject.options pOptions = self.theProject.options
pOptions.setValue("GuiProjectSettings", "winWidth", winWidth) pOptions.setValue("GuiProjectSettings", "winWidth", winWidth)
@@ -191,7 +190,6 @@ class GuiProjectEditMain(QWidget):
def __init__(self, projGui): def __init__(self, projGui):
super().__init__(parent=projGui) super().__init__(parent=projGui)
self.mainConf = novelwriter.CONFIG
self.mainGui = projGui.mainGui self.mainGui = projGui.mainGui
self.theProject = projGui.theProject self.theProject = projGui.theProject
@@ -202,7 +200,7 @@ class GuiProjectEditMain(QWidget):
self.mainForm.addGroupLabel(self.tr("Project Settings")) self.mainForm.addGroupLabel(self.tr("Project Settings"))
xW = self.mainConf.pxInt(250) xW = CONFIG.pxInt(250)
self.editName = QLineEdit() self.editName = QLineEdit()
self.editName.setMaxLength(200) self.editName.setMaxLength(200)
@@ -280,7 +278,6 @@ class GuiProjectEditStatus(QWidget):
def __init__(self, projGui, isStatus): def __init__(self, projGui, isStatus):
super().__init__(parent=projGui) super().__init__(parent=projGui)
self.mainConf = novelwriter.CONFIG
self.mainGui = projGui.mainGui self.mainGui = projGui.mainGui
self.theProject = projGui.theProject self.theProject = projGui.theProject
self.mainTheme = projGui.mainGui.mainTheme self.mainTheme = projGui.mainGui.mainTheme
@@ -294,7 +291,7 @@ class GuiProjectEditStatus(QWidget):
pageLabel = self.tr("Note File Importance Levels") pageLabel = self.tr("Note File Importance Levels")
colSetting = "importColW" colSetting = "importColW"
wCol0 = self.mainConf.pxInt( wCol0 = CONFIG.pxInt(
self.theProject.options.getInt("GuiProjectSettings", colSetting, 130) self.theProject.options.getInt("GuiProjectSettings", colSetting, 130)
) )
@@ -569,13 +566,12 @@ class GuiProjectEditReplace(QWidget):
def __init__(self, projGui): def __init__(self, projGui):
super().__init__(parent=projGui) super().__init__(parent=projGui)
self.mainConf = novelwriter.CONFIG
self.mainGui = projGui.mainGui self.mainGui = projGui.mainGui
self.mainTheme = projGui.mainGui.mainTheme self.mainTheme = projGui.mainGui.mainTheme
self.theProject = projGui.theProject self.theProject = projGui.theProject
self.arChanged = False self.arChanged = False
wCol0 = self.mainConf.pxInt( wCol0 = CONFIG.pxInt(
self.theProject.options.getInt("GuiProjectSettings", "replaceColW", 130) self.theProject.options.getInt("GuiProjectSettings", "replaceColW", 130)
) )
pageLabel = self.tr("Text Replace List for Preview and Export") pageLabel = self.tr("Text Replace List for Preview and Export")
+3 -5
View File
@@ -24,7 +24,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from PyQt5.QtGui import QFontMetrics from PyQt5.QtGui import QFontMetrics
from PyQt5.QtCore import Qt, QSize from PyQt5.QtCore import Qt, QSize
@@ -33,6 +32,7 @@ from PyQt5.QtWidgets import (
QListWidget, QListWidgetItem, QFrame QListWidget, QListWidgetItem, QFrame
) )
from novelwriter import CONFIG
from novelwriter.constants import trConst, nwQuotes from novelwriter.constants import trConst, nwQuotes
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -45,8 +45,6 @@ class GuiQuoteSelect(QDialog):
def __init__(self, parent=None, currentQuote='"'): def __init__(self, parent=None, currentQuote='"'):
super().__init__(parent=parent) super().__init__(parent=parent)
self.mainConf = novelwriter.CONFIG
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
self.innerBox = QHBoxLayout() self.innerBox = QHBoxLayout()
self.labelBox = QVBoxLayout() self.labelBox = QVBoxLayout()
@@ -82,8 +80,8 @@ class GuiQuoteSelect(QDialog):
if sKey == currentQuote: if sKey == currentQuote:
self.listBox.setCurrentItem(qtItem) self.listBox.setCurrentItem(qtItem)
self.listBox.setMinimumWidth(minSize + self.mainConf.pxInt(40)) self.listBox.setMinimumWidth(minSize + CONFIG.pxInt(40))
self.listBox.setMinimumHeight(self.mainConf.pxInt(150)) self.listBox.setMinimumHeight(CONFIG.pxInt(150))
# Buttons # Buttons
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
+9 -10
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import json import json
import logging import logging
import novelwriter
from datetime import datetime from datetime import datetime
from urllib.request import Request, urlopen from urllib.request import Request, urlopen
@@ -36,6 +35,7 @@ from PyQt5.QtWidgets import (
qApp, QDialog, QHBoxLayout, QVBoxLayout, QDialogButtonBox, QLabel qApp, QDialog, QHBoxLayout, QVBoxLayout, QDialogButtonBox, QLabel
) )
from novelwriter import CONFIG, __version__, __date__, __url__
from novelwriter.common import logException from novelwriter.common import logException
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -49,15 +49,14 @@ class GuiUpdates(QDialog):
logger.debug("Initialising GuiUpdates ...") logger.debug("Initialising GuiUpdates ...")
self.setObjectName("GuiUpdates") self.setObjectName("GuiUpdates")
self.mainConf = novelwriter.CONFIG self.mainGui = mainGui
self.mainGui = mainGui
self.setWindowTitle(self.tr("Check for Updates")) self.setWindowTitle(self.tr("Check for Updates"))
nPx = self.mainConf.pxInt(96) nPx = CONFIG.pxInt(96)
sPx = self.mainConf.pxInt(16) sPx = CONFIG.pxInt(16)
tPx = self.mainConf.pxInt(8) tPx = CONFIG.pxInt(8)
mPx = self.mainConf.pxInt(4) mPx = CONFIG.pxInt(4)
# Left Box # Left Box
self.nwIcon = QLabel() self.nwIcon = QLabel()
@@ -72,8 +71,8 @@ class GuiUpdates(QDialog):
self.currentValue = QLabel(self.tr( self.currentValue = QLabel(self.tr(
"novelWriter {0} released on {1}" "novelWriter {0} released on {1}"
).format( ).format(
"v%s" % novelwriter.__version__, "v%s" % __version__,
datetime.strptime(novelwriter.__date__, "%Y-%m-%d").strftime("%x")) datetime.strptime(__date__, "%Y-%m-%d").strftime("%x"))
) )
self.latestLabel = QLabel(self.tr("Latest Release")) self.latestLabel = QLabel(self.tr("Latest Release"))
@@ -152,7 +151,7 @@ class GuiUpdates(QDialog):
self.latestLink.setText(self.tr( self.latestLink.setText(self.tr(
"Download: {0}" "Download: {0}"
).format( ).format(
f'<a href="{novelwriter.__url__}">{novelwriter.__url__}</a>' f'<a href="{__url__}">{__url__}</a>'
)) ))
qApp.restoreOverrideCursor() qApp.restoreOverrideCursor()
+10 -11
View File
@@ -24,7 +24,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from pathlib import Path from pathlib import Path
@@ -34,6 +33,7 @@ from PyQt5.QtWidgets import (
QAbstractItemView, QPushButton, QLineEdit, QLabel QAbstractItemView, QPushButton, QLineEdit, QLabel
) )
from novelwriter import CONFIG
from novelwriter.enum import nwAlert from novelwriter.enum import nwAlert
from novelwriter.error import logException from novelwriter.error import logException
from novelwriter.constants import nwFiles from novelwriter.constants import nwFiles
@@ -49,23 +49,22 @@ class GuiWordList(QDialog):
logger.debug("Initialising GuiWordList ...") logger.debug("Initialising GuiWordList ...")
self.setObjectName("GuiWordList") self.setObjectName("GuiWordList")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
self.setWindowTitle(self.tr("Project Word List")) self.setWindowTitle(self.tr("Project Word List"))
mS = self.mainConf.pxInt(250) mS = CONFIG.pxInt(250)
wW = self.mainConf.pxInt(320) wW = CONFIG.pxInt(320)
wH = self.mainConf.pxInt(340) wH = CONFIG.pxInt(340)
pOptions = self.theProject.options pOptions = self.theProject.options
self.setMinimumWidth(mS) self.setMinimumWidth(mS)
self.setMinimumHeight(mS) self.setMinimumHeight(mS)
self.resize( self.resize(
self.mainConf.pxInt(pOptions.getInt("GuiWordList", "winWidth", wW)), CONFIG.pxInt(pOptions.getInt("GuiWordList", "winWidth", wW)),
self.mainConf.pxInt(pOptions.getInt("GuiWordList", "winHeight", wH)) CONFIG.pxInt(pOptions.getInt("GuiWordList", "winHeight", wH))
) )
# Main Widgets # Main Widgets
@@ -99,10 +98,10 @@ class GuiWordList(QDialog):
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
self.outerBox.addWidget(self.headLabel) self.outerBox.addWidget(self.headLabel)
self.outerBox.addSpacing(self.mainConf.pxInt(8)) self.outerBox.addSpacing(CONFIG.pxInt(8))
self.outerBox.addWidget(self.listBox, 1) self.outerBox.addWidget(self.listBox, 1)
self.outerBox.addLayout(self.editBox, 0) self.outerBox.addLayout(self.editBox, 0)
self.outerBox.addSpacing(self.mainConf.pxInt(12)) self.outerBox.addSpacing(CONFIG.pxInt(12))
self.outerBox.addWidget(self.buttonBox, 0) self.outerBox.addWidget(self.buttonBox, 0)
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
@@ -210,8 +209,8 @@ class GuiWordList(QDialog):
def _saveGuiSettings(self): def _saveGuiSettings(self):
"""Save GUI settings. """Save GUI settings.
""" """
winWidth = self.mainConf.rpxInt(self.width()) winWidth = CONFIG.rpxInt(self.width())
winHeight = self.mainConf.rpxInt(self.height()) winHeight = CONFIG.rpxInt(self.height())
pOptions = self.theProject.options pOptions = self.theProject.options
pOptions.setValue("GuiWordList", "winWidth", winWidth) pOptions.setValue("GuiWordList", "winWidth", winWidth)
+66 -70
View File
@@ -31,7 +31,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import bisect import bisect
import logging import logging
import novelwriter
from enum import Enum from enum import Enum
from time import time from time import time
@@ -50,6 +49,7 @@ from PyQt5.QtWidgets import (
QFrame QFrame
) )
from novelwriter import CONFIG
from novelwriter.enum import nwAlert, nwDocAction, nwDocInsert, nwDocMode, nwItemClass from novelwriter.enum import nwAlert, nwDocAction, nwDocInsert, nwDocMode, nwItemClass
from novelwriter.common import minmax, transferCase from novelwriter.common import minmax, transferCase
from novelwriter.constants import nwConst, nwFiles, nwKeyWords, nwUnicode from novelwriter.constants import nwConst, nwFiles, nwKeyWords, nwUnicode
@@ -81,7 +81,6 @@ class GuiDocEditor(QTextEdit):
logger.debug("Initialising GuiDocEditor ...") logger.debug("Initialising GuiDocEditor ...")
# Class Variables # Class Variables
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
@@ -140,7 +139,7 @@ class GuiDocEditor(QTextEdit):
self.customContextMenuRequested.connect(self._openContextMenu) self.customContextMenuRequested.connect(self._openContextMenu)
# Editor Settings # Editor Settings
self.setMinimumWidth(self.mainConf.pxInt(300)) self.setMinimumWidth(CONFIG.pxInt(300))
self.setAcceptRichText(False) self.setAcceptRichText(False)
self.setAutoFillBackground(True) self.setAutoFillBackground(True)
self.setFrameStyle(QFrame.NoFrame) self.setFrameStyle(QFrame.NoFrame)
@@ -169,7 +168,7 @@ class GuiDocEditor(QTextEdit):
self.wCounterDoc.setAutoDelete(False) self.wCounterDoc.setAutoDelete(False)
self.wCounterDoc.signals.countsReady.connect(self._updateDocCounts) self.wCounterDoc.signals.countsReady.connect(self._updateDocCounts)
self.wcInterval = self.mainConf.wordCountTimer self.wcInterval = CONFIG.wordCountTimer
# Set Up Selection Word Counter # Set Up Selection Word Counter
self.wcTimerSel = QTimer() self.wcTimerSel = QTimer()
@@ -252,26 +251,26 @@ class GuiDocEditor(QTextEdit):
# Some Constants # Some Constants
self._nonWord = ( self._nonWord = (
"\"'" "\"'"
f"{self.mainConf.fmtSQuoteOpen}{self.mainConf.fmtSQuoteClose}" f"{CONFIG.fmtSQuoteOpen}{CONFIG.fmtSQuoteClose}"
f"{self.mainConf.fmtDQuoteOpen}{self.mainConf.fmtDQuoteClose}" f"{CONFIG.fmtDQuoteOpen}{CONFIG.fmtDQuoteClose}"
) )
# Typography # Typography
if self.mainConf.fmtPadThin: if CONFIG.fmtPadThin:
self._typPadChar = nwUnicode.U_THNBSP self._typPadChar = nwUnicode.U_THNBSP
else: else:
self._typPadChar = nwUnicode.U_NBSP self._typPadChar = nwUnicode.U_NBSP
self._typSQuoteO = self.mainConf.fmtSQuoteOpen self._typSQuoteO = CONFIG.fmtSQuoteOpen
self._typSQuoteC = self.mainConf.fmtSQuoteClose self._typSQuoteC = CONFIG.fmtSQuoteClose
self._typDQuoteO = self.mainConf.fmtDQuoteOpen self._typDQuoteO = CONFIG.fmtDQuoteOpen
self._typDQuoteC = self.mainConf.fmtDQuoteClose self._typDQuoteC = CONFIG.fmtDQuoteClose
self._typRepDQuote = self.mainConf.doReplaceDQuote self._typRepDQuote = CONFIG.doReplaceDQuote
self._typRepSQuote = self.mainConf.doReplaceSQuote self._typRepSQuote = CONFIG.doReplaceSQuote
self._typRepDash = self.mainConf.doReplaceDash self._typRepDash = CONFIG.doReplaceDash
self._typRepDots = self.mainConf.doReplaceDots self._typRepDots = CONFIG.doReplaceDots
self._typPadBefore = self.mainConf.fmtPadBefore self._typPadBefore = CONFIG.fmtPadBefore
self._typPadAfter = self.mainConf.fmtPadAfter self._typPadAfter = CONFIG.fmtPadAfter
# Reload spell check and dictionaries # Reload spell check and dictionaries
self.setDictionaries() self.setDictionaries()
@@ -279,23 +278,23 @@ class GuiDocEditor(QTextEdit):
# Set font # Set font
theFont = QFont() theFont = QFont()
qDoc = self.document() qDoc = self.document()
if self.mainConf.textFont is None: if CONFIG.textFont is None:
# If none is defined, set a default font # If none is defined, set a default font
theFont = QFont() theFont = QFont()
if self.mainConf.osWindows and "Arial" in self.mainTheme.guiFontDB.families(): if CONFIG.osWindows and "Arial" in self.mainTheme.guiFontDB.families():
theFont.setFamily("Arial") theFont.setFamily("Arial")
theFont.setPointSize(12) theFont.setPointSize(12)
elif self.mainConf.osDarwin and "Courier" in self.mainTheme.guiFontDB.families(): elif CONFIG.osDarwin and "Courier" in self.mainTheme.guiFontDB.families():
theFont.setFamily("Courier") theFont.setFamily("Courier")
theFont.setPointSize(12) theFont.setPointSize(12)
else: else:
theFont = qDoc.defaultFont() theFont = qDoc.defaultFont()
self.mainConf.textFont = theFont.family() CONFIG.textFont = theFont.family()
self.mainConf.textSize = theFont.pointSize() CONFIG.textSize = theFont.pointSize()
theFont.setFamily(self.mainConf.textFont) theFont.setFamily(CONFIG.textFont)
theFont.setPointSize(self.mainConf.textSize) theFont.setPointSize(CONFIG.textSize)
self.setFont(theFont) self.setFont(theFont)
# Set default text margins # Set default text margins
@@ -303,37 +302,37 @@ class GuiDocEditor(QTextEdit):
# allocated to the document itself. See issue #1112. # allocated to the document itself. See issue #1112.
cW = self.cursorWidth() cW = self.cursorWidth()
qDoc.setDocumentMargin(cW) qDoc.setDocumentMargin(cW)
self._vpMargin = max(self.mainConf.getTextMargin() - cW, 0) self._vpMargin = max(CONFIG.getTextMargin() - cW, 0)
self.setViewportMargins(self._vpMargin, self._vpMargin, self._vpMargin, self._vpMargin) self.setViewportMargins(self._vpMargin, self._vpMargin, self._vpMargin, self._vpMargin)
# Also set the document text options for the document text flow # Also set the document text options for the document text flow
theOpt = QTextOption() theOpt = QTextOption()
if self.mainConf.doJustify: if CONFIG.doJustify:
theOpt.setAlignment(Qt.AlignJustify) theOpt.setAlignment(Qt.AlignJustify)
if self.mainConf.showTabsNSpaces: if CONFIG.showTabsNSpaces:
theOpt.setFlags(theOpt.flags() | QTextOption.ShowTabsAndSpaces) theOpt.setFlags(theOpt.flags() | QTextOption.ShowTabsAndSpaces)
if self.mainConf.showLineEndings: if CONFIG.showLineEndings:
theOpt.setFlags(theOpt.flags() | QTextOption.ShowLineAndParagraphSeparators) theOpt.setFlags(theOpt.flags() | QTextOption.ShowLineAndParagraphSeparators)
qDoc.setDefaultTextOption(theOpt) qDoc.setDefaultTextOption(theOpt)
# Scroll bars # Scroll bars
if self.mainConf.hideVScroll: if CONFIG.hideVScroll:
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
if self.mainConf.hideHScroll: if CONFIG.hideHScroll:
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
# Refresh the tab stops # Refresh the tab stops
self.setTabStopDistance(self.mainConf.getTabWidth()) self.setTabStopDistance(CONFIG.getTabWidth())
# Configure word count timer # Configure word count timer
self.wcInterval = self.mainConf.wordCountTimer self.wcInterval = CONFIG.wordCountTimer
self.wcTimerDoc.setInterval(int(self.wcInterval*1000)) self.wcTimerDoc.setInterval(int(self.wcInterval*1000))
# If we have a document open, we should reload it in case the # If we have a document open, we should reload it in case the
@@ -420,10 +419,10 @@ class GuiDocEditor(QTextEdit):
elif isinstance(tLine, int): elif isinstance(tLine, int):
self.setCursorLine(tLine) self.setCursorLine(tLine)
if self.mainConf.scrollPastEnd > 0: if CONFIG.scrollPastEnd > 0:
fSize = QFontMetrics(self.font()).lineSpacing() fSize = QFontMetrics(self.font()).lineSpacing()
docFrame = self.document().rootFrame().frameFormat() docFrame = self.document().rootFrame().frameFormat()
docFrame.setBottomMargin(round(self.mainConf.scrollPastEnd * fSize)) docFrame.setBottomMargin(round(CONFIG.scrollPastEnd * fSize))
self.document().rootFrame().setFrameFormat(docFrame) self.document().rootFrame().setFrameFormat(docFrame)
self.docFooter.updateLineCount() self.docFooter.updateLineCount()
@@ -571,8 +570,8 @@ class GuiDocEditor(QTextEdit):
sH = hBar.height() if hBar.isVisible() else 0 sH = hBar.height() if hBar.isVisible() else 0
tM = self._vpMargin tM = self._vpMargin
if self.mainConf.textWidth > 0 or self.mainGui.isFocusMode: if CONFIG.textWidth > 0 or self.mainGui.isFocusMode:
tW = self.mainConf.getTextWidth(self.mainGui.isFocusMode) tW = CONFIG.getTextWidth(self.mainGui.isFocusMode)
tM = max((wW - sW - tW)//2, self._vpMargin) tM = max((wW - sW - tW)//2, self._vpMargin)
tB = self.frameWidth() tB = self.frameWidth()
@@ -674,7 +673,7 @@ class GuiDocEditor(QTextEdit):
# when it is enabled. By default, it's 30% of viewport. # when it is enabled. By default, it's 30% of viewport.
vPos = self.verticalScrollBar().value() vPos = self.verticalScrollBar().value()
cPos = self.cursorRect().topLeft().y() cPos = self.cursorRect().topLeft().y()
mPos = int(self.mainConf.autoScrollPos*0.01 * self.viewport().height()) mPos = int(CONFIG.autoScrollPos*0.01 * self.viewport().height())
if cPos > mPos: if cPos > mPos:
# Only scroll if the cursor is past the auto-scroll limit # Only scroll if the cursor is past the auto-scroll limit
self.verticalScrollBar().setValue(max(0, vPos + cPos - mPos)) self.verticalScrollBar().setValue(max(0, vPos + cPos - mPos))
@@ -715,7 +714,7 @@ class GuiDocEditor(QTextEdit):
dictionary changed signal. dictionary changed signal.
""" """
if self.theProject.data.spellLang is None: if self.theProject.data.spellLang is None:
theLang = self.mainConf.spellLanguage theLang = CONFIG.spellLanguage
else: else:
theLang = self.theProject.data.spellLang theLang = self.theProject.data.spellLang
@@ -738,7 +737,7 @@ class GuiDocEditor(QTextEdit):
if theMode is None: if theMode is None:
theMode = not self._spellCheck theMode = not self._spellCheck
if not self.mainConf.hasEnchant: if not CONFIG.hasEnchant:
if theMode: if theMode:
self.mainGui.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Spell checking requires the package PyEnchant. " "Spell checking requires the package PyEnchant. "
@@ -1038,7 +1037,7 @@ class GuiDocEditor(QTextEdit):
self.docAction(nwDocAction.SEL_ALL) self.docAction(nwDocAction.SEL_ALL)
return return
if self.mainConf.autoScroll: if CONFIG.autoScroll:
cOld = self.cursorRect().center().y() cOld = self.cursorRect().center().y()
super().keyPressEvent(keyEvent) super().keyPressEvent(keyEvent)
@@ -1049,7 +1048,7 @@ class GuiDocEditor(QTextEdit):
if okMod and okKey: if okMod and okKey:
cNew = self.cursorRect().center().y() cNew = self.cursorRect().center().y()
cMov = cNew - cOld cMov = cNew - cOld
mPos = self.mainConf.autoScrollPos*0.01 * self.viewport().height() mPos = CONFIG.autoScrollPos*0.01 * self.viewport().height()
if abs(cMov) > 0 and cOld > mPos: if abs(cMov) > 0 and cOld > mPos:
# Move the scroll bar # Move the scroll bar
vBar = self.verticalScrollBar() vBar = self.verticalScrollBar()
@@ -2090,7 +2089,7 @@ class GuiDocEditor(QTextEdit):
"""Check if document size crosses the big document limit set in """Check if document size crosses the big document limit set in
config. If so, we will set the big document flag to True. config. If so, we will set the big document flag to True.
""" """
bigLim = round(self.mainConf.bigDocLimit*1000) bigLim = round(CONFIG.bigDocLimit*1000)
newState = theSize > bigLim newState = theSize > bigLim
if newState != self._bigDoc: if newState != self._bigDoc:
@@ -2114,7 +2113,7 @@ class GuiDocEditor(QTextEdit):
on user settings and document action. on user settings and document action.
""" """
theCursor = self.textCursor() theCursor = self.textCursor()
if self.mainConf.autoSelect and not theCursor.hasSelection(): if CONFIG.autoSelect and not theCursor.hasSelection():
theCursor.select(QTextCursor.WordUnderCursor) theCursor.select(QTextCursor.WordUnderCursor)
posS = theCursor.selectionStart() posS = theCursor.selectionStart()
posE = theCursor.selectionEnd() posE = theCursor.selectionEnd()
@@ -2175,7 +2174,7 @@ class GuiDocEditor(QTextEdit):
"""Enable/disable the auto-replace feature temporarily. """Enable/disable the auto-replace feature temporarily.
""" """
if theState: if theState:
self._doReplace = self.mainConf.doReplace self._doReplace = CONFIG.doReplace
else: else:
self._doReplace = False self._doReplace = False
return return
@@ -2245,21 +2244,20 @@ class GuiDocEditSearch(QFrame):
logger.debug("Initialising GuiDocEditSearch ...") logger.debug("Initialising GuiDocEditSearch ...")
self.mainConf = novelwriter.CONFIG
self.docEditor = docEditor self.docEditor = docEditor
self.mainGui = docEditor.mainGui self.mainGui = docEditor.mainGui
self.theProject = docEditor.theProject self.theProject = docEditor.theProject
self.mainTheme = docEditor.mainTheme self.mainTheme = docEditor.mainTheme
self.repVisible = False self.repVisible = False
self.isCaseSense = self.mainConf.searchCase self.isCaseSense = CONFIG.searchCase
self.isWholeWord = self.mainConf.searchWord self.isWholeWord = CONFIG.searchWord
self.isRegEx = self.mainConf.searchRegEx self.isRegEx = CONFIG.searchRegEx
self.doLoop = self.mainConf.searchLoop self.doLoop = CONFIG.searchLoop
self.doNextFile = self.mainConf.searchNextFile self.doNextFile = CONFIG.searchNextFile
self.doMatchCap = self.mainConf.searchMatchCap self.doMatchCap = CONFIG.searchMatchCap
mPx = self.mainConf.pxInt(6) mPx = CONFIG.pxInt(6)
tPx = int(0.8*self.mainTheme.fontPixelSize) tPx = int(0.8*self.mainTheme.fontPixelSize)
self.boxFont = self.mainTheme.guiFont self.boxFont = self.mainTheme.guiFont
self.boxFont.setPointSizeF(0.9*self.mainTheme.fontPointSize) self.boxFont.setPointSizeF(0.9*self.mainTheme.fontPointSize)
@@ -2291,7 +2289,7 @@ class GuiDocEditSearch(QFrame):
self.searchLabel = QLabel(self.tr("Search")) self.searchLabel = QLabel(self.tr("Search"))
self.searchLabel.setFont(self.boxFont) self.searchLabel.setFont(self.boxFont)
self.searchLabel.setIndent(self.mainConf.pxInt(6)) self.searchLabel.setIndent(CONFIG.pxInt(6))
self.resultLabel = QLabel("?/?") self.resultLabel = QLabel("?/?")
self.resultLabel.setFont(self.boxFont) self.resultLabel.setFont(self.boxFont)
@@ -2376,10 +2374,10 @@ class GuiDocEditSearch(QFrame):
self.mainBox.setColumnStretch(3, 0) self.mainBox.setColumnStretch(3, 0)
self.mainBox.setColumnStretch(4, 0) self.mainBox.setColumnStretch(4, 0)
self.mainBox.setColumnStretch(5, 0) self.mainBox.setColumnStretch(5, 0)
self.mainBox.setSpacing(self.mainConf.pxInt(2)) self.mainBox.setSpacing(CONFIG.pxInt(2))
self.mainBox.setContentsMargins(mPx, mPx, mPx, mPx) self.mainBox.setContentsMargins(mPx, mPx, mPx, mPx)
boxWidth = self.mainConf.pxInt(200) boxWidth = CONFIG.pxInt(200)
self.searchBox.setFixedWidth(boxWidth) self.searchBox.setFixedWidth(boxWidth)
self.replaceBox.setFixedWidth(boxWidth) self.replaceBox.setFixedWidth(boxWidth)
self.replaceBox.setVisible(False) self.replaceBox.setVisible(False)
@@ -2438,12 +2436,12 @@ class GuiDocEditSearch(QFrame):
def closeSearch(self): def closeSearch(self):
"""Close the search box. """Close the search box.
""" """
self.mainConf.searchCase = self.isCaseSense CONFIG.searchCase = self.isCaseSense
self.mainConf.searchWord = self.isWholeWord CONFIG.searchWord = self.isWholeWord
self.mainConf.searchRegEx = self.isRegEx CONFIG.searchRegEx = self.isRegEx
self.mainConf.searchLoop = self.doLoop CONFIG.searchLoop = self.doLoop
self.mainConf.searchNextFile = self.doNextFile CONFIG.searchNextFile = self.doNextFile
self.mainConf.searchMatchCap = self.doMatchCap CONFIG.searchMatchCap = self.doMatchCap
self.showReplace.setChecked(False) self.showReplace.setChecked(False)
self.setVisible(False) self.setVisible(False)
@@ -2517,7 +2515,7 @@ class GuiDocEditSearch(QFrame):
# Using the Unicode-capable QRegularExpression class was # Using the Unicode-capable QRegularExpression class was
# only added in Qt 5.13. Otherwise, 5.3 and up supports # only added in Qt 5.13. Otherwise, 5.3 and up supports
# only the QRegExp class. # only the QRegExp class.
if self.mainConf.verQtValue >= 0x050d00: if CONFIG.verQtValue >= 0x050d00:
rxOpt = QRegularExpression.UseUnicodePropertiesOption rxOpt = QRegularExpression.UseUnicodePropertiesOption
if not self.isCaseSense: if not self.isCaseSense:
rxOpt |= QRegularExpression.CaseInsensitiveOption rxOpt |= QRegularExpression.CaseInsensitiveOption
@@ -2661,7 +2659,6 @@ class GuiDocEditHeader(QWidget):
logger.debug("Initialising GuiDocEditHeader ...") logger.debug("Initialising GuiDocEditHeader ...")
self.mainConf = novelwriter.CONFIG
self.docEditor = docEditor self.docEditor = docEditor
self.mainGui = docEditor.mainGui self.mainGui = docEditor.mainGui
self.theProject = docEditor.theProject self.theProject = docEditor.theProject
@@ -2670,7 +2667,7 @@ class GuiDocEditHeader(QWidget):
self._docHandle = None self._docHandle = None
fPx = int(0.9*self.mainTheme.fontPixelSize) fPx = int(0.9*self.mainTheme.fontPixelSize)
hSp = self.mainConf.pxInt(6) hSp = CONFIG.pxInt(6)
# Main Widget Settings # Main Widget Settings
self.setAutoFillBackground(True) self.setAutoFillBackground(True)
@@ -2738,7 +2735,7 @@ class GuiDocEditHeader(QWidget):
# Fix Margins and Size # Fix Margins and Size
# This is needed for high DPI systems. See issue #499. # This is needed for high DPI systems. See issue #499.
cM = self.mainConf.pxInt(8) cM = CONFIG.pxInt(8)
self.setContentsMargins(0, 0, 0, 0) self.setContentsMargins(0, 0, 0, 0)
self.outerBox.setContentsMargins(cM, cM, cM, cM) self.outerBox.setContentsMargins(cM, cM, cM, cM)
self.setMinimumHeight(fPx + 2*cM) self.setMinimumHeight(fPx + 2*cM)
@@ -2802,7 +2799,7 @@ class GuiDocEditHeader(QWidget):
self.minmaxButton.setVisible(False) self.minmaxButton.setVisible(False)
return True return True
if self.mainConf.showFullPath: if CONFIG.showFullPath:
tTitle = [] tTitle = []
tTree = self.theProject.tree.getItemPath(tHandle) tTree = self.theProject.tree.getItemPath(tHandle)
for aHandle in reversed(tTree): for aHandle in reversed(tTree):
@@ -2897,7 +2894,6 @@ class GuiDocEditFooter(QWidget):
logger.debug("Initialising GuiDocEditFooter ...") logger.debug("Initialising GuiDocEditFooter ...")
self.mainConf = novelwriter.CONFIG
self.docEditor = docEditor self.docEditor = docEditor
self.mainGui = docEditor.mainGui self.mainGui = docEditor.mainGui
self.theProject = docEditor.theProject self.theProject = docEditor.theProject
@@ -2910,8 +2906,8 @@ class GuiDocEditFooter(QWidget):
self.sPx = int(round(0.9*self.mainTheme.baseIconSize)) self.sPx = int(round(0.9*self.mainTheme.baseIconSize))
fPx = int(0.9*self.mainTheme.fontPixelSize) fPx = int(0.9*self.mainTheme.fontPixelSize)
bSp = self.mainConf.pxInt(4) bSp = CONFIG.pxInt(4)
hSp = self.mainConf.pxInt(6) hSp = CONFIG.pxInt(6)
lblFont = self.font() lblFont = self.font()
lblFont.setPointSizeF(0.9*self.mainTheme.fontPointSize) lblFont.setPointSizeF(0.9*self.mainTheme.fontPointSize)
@@ -2980,7 +2976,7 @@ class GuiDocEditFooter(QWidget):
# Fix Margins and Size # Fix Margins and Size
# This is needed for high DPI systems. See issue #499. # This is needed for high DPI systems. See issue #499.
cM = self.mainConf.pxInt(8) cM = CONFIG.pxInt(8)
self.setContentsMargins(0, 0, 0, 0) self.setContentsMargins(0, 0, 0, 0)
self.outerBox.setContentsMargins(cM, cM, cM, cM) self.outerBox.setContentsMargins(cM, cM, cM, cM)
self.setMinimumHeight(fPx + 2*cM) self.setMinimumHeight(fPx + 2*cM)
+11 -12
View File
@@ -24,7 +24,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from time import time from time import time
@@ -33,6 +32,7 @@ from PyQt5.QtGui import (
QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush
) )
from novelwriter import CONFIG
from novelwriter.common import checkInt from novelwriter.common import checkInt
from novelwriter.constants import nwRegEx, nwUnicode from novelwriter.constants import nwRegEx, nwUnicode
@@ -50,7 +50,6 @@ class GuiDocHighlighter(QSyntaxHighlighter):
super().__init__(theDoc) super().__init__(theDoc)
logger.debug("Initialising GuiDocHighlighter ...") logger.debug("Initialising GuiDocHighlighter ...")
self.mainConf = novelwriter.CONFIG
self.theDoc = theDoc self.theDoc = theDoc
self.spEnchant = spEnchant self.spEnchant = spEnchant
self.mainGui = mainGui self.mainGui = mainGui
@@ -103,7 +102,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self.colBreak.setAlpha(64) self.colBreak.setAlpha(64)
self.colEmph = None self.colEmph = None
if self.mainConf.highlightEmph: if CONFIG.highlightEmph:
self.colEmph = QColor(*self.mainTheme.colEmph) self.colEmph = QColor(*self.mainTheme.colEmph)
self.hStyles = { self.hStyles = {
@@ -135,7 +134,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self.hRules = [] self.hRules = []
# Multiple or Trailing Spaces # Multiple or Trailing Spaces
if self.mainConf.showMultiSpaces: if CONFIG.showMultiSpaces:
self.hRules.append(( self.hRules.append((
r"[ ]{2,}|[ ]*$", { r"[ ]{2,}|[ ]*$", {
0: self.hStyles["mspaces"], 0: self.hStyles["mspaces"],
@@ -150,11 +149,11 @@ class GuiDocHighlighter(QSyntaxHighlighter):
)) ))
# Quoted Strings # Quoted Strings
if self.mainConf.highlightQuotes: if CONFIG.highlightQuotes:
fmtDblO = self.mainConf.fmtDQuoteOpen fmtDblO = CONFIG.fmtDQuoteOpen
fmtDblC = self.mainConf.fmtDQuoteClose fmtDblC = CONFIG.fmtDQuoteClose
fmtSngO = self.mainConf.fmtSQuoteOpen fmtSngO = CONFIG.fmtSQuoteOpen
fmtSngC = self.mainConf.fmtSQuoteClose fmtSngC = CONFIG.fmtSQuoteClose
# Straight Quotes # Straight Quotes
if not (fmtDblO == fmtDblC == "\""): if not (fmtDblO == fmtDblC == "\""):
@@ -165,7 +164,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
)) ))
# Double Quotes # Double Quotes
dblEnd = "|$" if self.mainConf.allowOpenDQuote else "" dblEnd = "|$" if CONFIG.allowOpenDQuote else ""
self.hRules.append(( self.hRules.append((
f"(\\B{fmtDblO})(.*?)({fmtDblC}\\B{dblEnd})", { f"(\\B{fmtDblO})(.*?)({fmtDblC}\\B{dblEnd})", {
0: self.hStyles["dialogue2"], 0: self.hStyles["dialogue2"],
@@ -173,7 +172,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
)) ))
# Single Quotes # Single Quotes
sngEnd = "|$" if self.mainConf.allowOpenSQuote else "" sngEnd = "|$" if CONFIG.allowOpenSQuote else ""
self.hRules.append(( self.hRules.append((
f"(\\B{fmtSngO})(.*?)({fmtSngC}\\B{sngEnd})", { f"(\\B{fmtSngO})(.*?)({fmtSngC}\\B{sngEnd})", {
0: self.hStyles["dialogue3"], 0: self.hStyles["dialogue3"],
@@ -432,7 +431,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
theFormat.setBackground(QBrush(fmtCol, Qt.SolidPattern)) theFormat.setBackground(QBrush(fmtCol, Qt.SolidPattern))
if fmtSize is not None: if fmtSize is not None:
theFormat.setFontPointSize(int(round(fmtSize*self.mainConf.textSize))) theFormat.setFontPointSize(int(round(fmtSize*CONFIG.textSize)))
return theFormat return theFormat
+26 -30
View File
@@ -28,7 +28,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from enum import Enum from enum import Enum
@@ -41,6 +40,7 @@ from PyQt5.QtWidgets import (
QAction, QMenu, QFrame QAction, QMenu, QFrame
) )
from novelwriter import CONFIG
from novelwriter.enum import nwItemType, nwDocAction, nwDocMode from novelwriter.enum import nwItemType, nwDocAction, nwDocMode
from novelwriter.error import logException from novelwriter.error import logException
from novelwriter.constants import nwUnicode from novelwriter.constants import nwUnicode
@@ -59,7 +59,6 @@ class GuiDocViewer(QTextBrowser):
logger.debug("Initialising GuiDocViewer ...") logger.debug("Initialising GuiDocViewer ...")
# Class Variables # Class Variables
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
@@ -68,7 +67,7 @@ class GuiDocViewer(QTextBrowser):
self._docHandle = None self._docHandle = None
# Settings # Settings
self.setMinimumWidth(self.mainConf.pxInt(300)) self.setMinimumWidth(CONFIG.pxInt(300))
self.setAutoFillBackground(True) self.setAutoFillBackground(True)
self.setOpenExternalLinks(False) self.setOpenExternalLinks(False)
self.setFocusPolicy(Qt.StrongFocus) self.setFocusPolicy(Qt.StrongFocus)
@@ -116,11 +115,11 @@ class GuiDocViewer(QTextBrowser):
# Set Font # Set Font
theFont = QFont() theFont = QFont()
if self.mainConf.textFont is None: if CONFIG.textFont is None:
# If none is defined, set the default back to config # If none is defined, set the default back to config
self.mainConf.textFont = self.document().defaultFont().family() CONFIG.textFont = self.document().defaultFont().family()
theFont.setFamily(self.mainConf.textFont) theFont.setFamily(CONFIG.textFont)
theFont.setPointSize(self.mainConf.textSize) theFont.setPointSize(CONFIG.textSize)
self.setFont(theFont) self.setFont(theFont)
# Set the widget colours to match syntax theme # Set the widget colours to match syntax theme
@@ -141,23 +140,23 @@ class GuiDocViewer(QTextBrowser):
# Set default text margins # Set default text margins
self.document().setDocumentMargin(0) self.document().setDocumentMargin(0)
theOpt = QTextOption() theOpt = QTextOption()
if self.mainConf.doJustify: if CONFIG.doJustify:
theOpt.setAlignment(Qt.AlignJustify) theOpt.setAlignment(Qt.AlignJustify)
self.document().setDefaultTextOption(theOpt) self.document().setDefaultTextOption(theOpt)
# Scroll bars # Scroll bars
if self.mainConf.hideVScroll: if CONFIG.hideVScroll:
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
if self.mainConf.hideHScroll: if CONFIG.hideHScroll:
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
# Refresh the tab stops # Refresh the tab stops
self.setTabStopDistance(self.mainConf.getTabWidth()) self.setTabStopDistance(CONFIG.getTabWidth())
# If we have a document open, we should reload it in case the font changed # If we have a document open, we should reload it in case the font changed
if self._docHandle is not None: if self._docHandle is not None:
@@ -177,7 +176,7 @@ class GuiDocViewer(QTextBrowser):
sPos = self.verticalScrollBar().value() sPos = self.verticalScrollBar().value()
aDoc = ToHtml(self.theProject) aDoc = ToHtml(self.theProject)
aDoc.setPreview(self.mainConf.viewComments, self.mainConf.viewSynopsis) aDoc.setPreview(CONFIG.viewComments, CONFIG.viewSynopsis)
aDoc.setLinkHeaders(True) aDoc.setLinkHeaders(True)
# Be extra careful here to prevent crashes when first opening a # Be extra careful here to prevent crashes when first opening a
@@ -196,7 +195,7 @@ class GuiDocViewer(QTextBrowser):
return False return False
# Refresh the tab stops # Refresh the tab stops
self.setTabStopDistance(self.mainConf.getTabWidth()) self.setTabStopDistance(CONFIG.getTabWidth())
# Must be before setHtml # Must be before setHtml
if updateHistory: if updateHistory:
@@ -297,7 +296,7 @@ class GuiDocViewer(QTextBrowser):
""" """
wW = self.width() wW = self.width()
wH = self.height() wH = self.height()
cM = self.mainConf.getTextMargin() cM = CONFIG.getTextMargin()
vBar = self.verticalScrollBar() vBar = self.verticalScrollBar()
sW = vBar.width() if vBar.isVisible() else 0 sW = vBar.width() if vBar.isVisible() else 0
@@ -306,8 +305,8 @@ class GuiDocViewer(QTextBrowser):
sH = hBar.height() if hBar.isVisible() else 0 sH = hBar.height() if hBar.isVisible() else 0
tM = cM tM = cM
if self.mainConf.textWidth > 0: if CONFIG.textWidth > 0:
tW = self.mainConf.getTextWidth() tW = CONFIG.getTextWidth()
tM = max((wW - sW - tW)//2, cM) tM = max((wW - sW - tW)//2, cM)
tB = self.frameWidth() tB = self.frameWidth()
@@ -685,7 +684,6 @@ class GuiDocViewHeader(QWidget):
logger.debug("Initialising GuiDocViewHeader ...") logger.debug("Initialising GuiDocViewHeader ...")
self.mainConf = novelwriter.CONFIG
self.docViewer = docViewer self.docViewer = docViewer
self.mainGui = docViewer.mainGui self.mainGui = docViewer.mainGui
self.theProject = docViewer.theProject self.theProject = docViewer.theProject
@@ -695,7 +693,7 @@ class GuiDocViewHeader(QWidget):
self._docHandle = None self._docHandle = None
fPx = int(0.9*self.mainTheme.fontPixelSize) fPx = int(0.9*self.mainTheme.fontPixelSize)
hSp = self.mainConf.pxInt(6) hSp = CONFIG.pxInt(6)
# Main Widget Settings # Main Widget Settings
self.setAutoFillBackground(True) self.setAutoFillBackground(True)
@@ -763,7 +761,7 @@ class GuiDocViewHeader(QWidget):
# Fix Margins and Size # Fix Margins and Size
# This is needed for high DPI systems. See issue #499. # This is needed for high DPI systems. See issue #499.
cM = self.mainConf.pxInt(8) cM = CONFIG.pxInt(8)
self.setContentsMargins(0, 0, 0, 0) self.setContentsMargins(0, 0, 0, 0)
self.outerBox.setContentsMargins(cM, cM, cM, cM) self.outerBox.setContentsMargins(cM, cM, cM, cM)
self.setMinimumHeight(fPx + 2*cM) self.setMinimumHeight(fPx + 2*cM)
@@ -828,7 +826,7 @@ class GuiDocViewHeader(QWidget):
self.refreshButton.setVisible(False) self.refreshButton.setVisible(False)
return True return True
if self.mainConf.showFullPath: if CONFIG.showFullPath:
tTitle = [] tTitle = []
tTree = self.theProject.tree.getItemPath(tHandle) tTree = self.theProject.tree.getItemPath(tHandle)
for aHandle in reversed(tTree): for aHandle in reversed(tTree):
@@ -903,7 +901,6 @@ class GuiDocViewFooter(QWidget):
logger.debug("Initialising GuiDocViewFooter ...") logger.debug("Initialising GuiDocViewFooter ...")
self.mainConf = novelwriter.CONFIG
self.docViewer = docViewer self.docViewer = docViewer
self.mainGui = docViewer.mainGui self.mainGui = docViewer.mainGui
self.mainTheme = docViewer.mainTheme self.mainTheme = docViewer.mainTheme
@@ -913,8 +910,8 @@ class GuiDocViewFooter(QWidget):
self._docHandle = None self._docHandle = None
fPx = int(0.9*self.mainTheme.fontPixelSize) fPx = int(0.9*self.mainTheme.fontPixelSize)
bSp = self.mainConf.pxInt(2) bSp = CONFIG.pxInt(2)
hSp = self.mainConf.pxInt(8) hSp = CONFIG.pxInt(8)
# Main Widget Settings # Main Widget Settings
self.setContentsMargins(0, 0, 0, 0) self.setContentsMargins(0, 0, 0, 0)
@@ -942,7 +939,7 @@ class GuiDocViewFooter(QWidget):
# Show Comments # Show Comments
self.showComments = QToolButton(self) self.showComments = QToolButton(self)
self.showComments.setCheckable(True) self.showComments.setCheckable(True)
self.showComments.setChecked(self.mainConf.viewComments) self.showComments.setChecked(CONFIG.viewComments)
self.showComments.setToolButtonStyle(Qt.ToolButtonIconOnly) self.showComments.setToolButtonStyle(Qt.ToolButtonIconOnly)
self.showComments.setIconSize(QSize(fPx, fPx)) self.showComments.setIconSize(QSize(fPx, fPx))
self.showComments.setFixedSize(QSize(fPx, fPx)) self.showComments.setFixedSize(QSize(fPx, fPx))
@@ -952,7 +949,7 @@ class GuiDocViewFooter(QWidget):
# Show Synopsis # Show Synopsis
self.showSynopsis = QToolButton(self) self.showSynopsis = QToolButton(self)
self.showSynopsis.setCheckable(True) self.showSynopsis.setCheckable(True)
self.showSynopsis.setChecked(self.mainConf.viewSynopsis) self.showSynopsis.setChecked(CONFIG.viewSynopsis)
self.showSynopsis.setToolButtonStyle(Qt.ToolButtonIconOnly) self.showSynopsis.setToolButtonStyle(Qt.ToolButtonIconOnly)
self.showSynopsis.setIconSize(QSize(fPx, fPx)) self.showSynopsis.setIconSize(QSize(fPx, fPx))
self.showSynopsis.setFixedSize(QSize(fPx, fPx)) self.showSynopsis.setFixedSize(QSize(fPx, fPx))
@@ -1021,7 +1018,7 @@ class GuiDocViewFooter(QWidget):
# Fix Margins and Size # Fix Margins and Size
# This is needed for high DPI systems. See issue #499. # This is needed for high DPI systems. See issue #499.
cM = self.mainConf.pxInt(8) cM = CONFIG.pxInt(8)
self.setContentsMargins(0, 0, 0, 0) self.setContentsMargins(0, 0, 0, 0)
self.outerBox.setContentsMargins(cM, cM, cM, cM) self.outerBox.setContentsMargins(cM, cM, cM, cM)
self.setMinimumHeight(fPx + 2*cM) self.setMinimumHeight(fPx + 2*cM)
@@ -1120,7 +1117,7 @@ class GuiDocViewFooter(QWidget):
def _doToggleComments(self, theState): def _doToggleComments(self, theState):
"""Toggle the view comment button and reload the document. """Toggle the view comment button and reload the document.
""" """
self.mainConf.viewComments = theState CONFIG.viewComments = theState
self.docViewer.reloadText() self.docViewer.reloadText()
return return
@@ -1128,7 +1125,7 @@ class GuiDocViewFooter(QWidget):
def _doToggleSynopsis(self, theState): def _doToggleSynopsis(self, theState):
"""Toggle the view synopsis button and reload the document. """Toggle the view synopsis button and reload the document.
""" """
self.mainConf.viewSynopsis = theState CONFIG.viewSynopsis = theState
self.docViewer.reloadText() self.docViewer.reloadText()
return return
@@ -1146,7 +1143,6 @@ class GuiDocViewDetails(QScrollArea):
super().__init__(parent=mainGui) super().__init__(parent=mainGui)
logger.debug("Initialising GuiDocViewDetails ...") logger.debug("Initialising GuiDocViewDetails ...")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
@@ -1172,7 +1168,7 @@ class GuiDocViewDetails(QScrollArea):
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.setWidgetResizable(True) self.setWidgetResizable(True)
self.setMinimumHeight(self.mainConf.pxInt(50)) self.setMinimumHeight(CONFIG.pxInt(50))
self.setFrameStyle(QFrame.NoFrame) self.setFrameStyle(QFrame.NoFrame)
logger.debug("GuiDocViewDetails initialisation complete") logger.debug("GuiDocViewDetails initialisation complete")
+4 -5
View File
@@ -24,12 +24,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from PyQt5.QtCore import Qt, pyqtSlot from PyQt5.QtCore import Qt, pyqtSlot
from PyQt5.QtGui import QFont, QPixmap from PyQt5.QtGui import QFont, QPixmap
from PyQt5.QtWidgets import QWidget, QGridLayout, QLabel from PyQt5.QtWidgets import QWidget, QGridLayout, QLabel
from novelwriter import CONFIG
from novelwriter.constants import trConst, nwLabels from novelwriter.constants import trConst, nwLabels
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -41,7 +41,6 @@ class GuiItemDetails(QWidget):
super().__init__(parent=mainGui) super().__init__(parent=mainGui)
logger.debug("Initialising GuiItemDetails ...") logger.debug("Initialising GuiItemDetails ...")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
@@ -50,9 +49,9 @@ class GuiItemDetails(QWidget):
self._itemHandle = None self._itemHandle = None
# Sizes # Sizes
hSp = self.mainConf.pxInt(6) hSp = CONFIG.pxInt(6)
vSp = self.mainConf.pxInt(1) vSp = CONFIG.pxInt(1)
mPx = self.mainConf.pxInt(6) mPx = CONFIG.pxInt(6)
fPt = self.mainTheme.fontPointSize fPt = self.mainTheme.fontPointSize
fntLabel = QFont() fntLabel = QFont()
+11 -11
View File
@@ -34,6 +34,7 @@ from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QDesktopServices from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QMenuBar, QAction from PyQt5.QtWidgets import QMenuBar, QAction
from novelwriter import CONFIG
from novelwriter.enum import nwDocAction, nwDocInsert, nwWidget from novelwriter.enum import nwDocAction, nwDocInsert, nwWidget
from novelwriter.constants import trConst, nwKeyWords, nwLabels, nwUnicode from novelwriter.constants import trConst, nwKeyWords, nwLabels, nwUnicode
@@ -50,7 +51,6 @@ class GuiMainMenu(QMenuBar):
super().__init__(parent=mainGui) super().__init__(parent=mainGui)
logger.debug("Initialising GuiMainMenu ...") logger.debug("Initialising GuiMainMenu ...")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
@@ -105,9 +105,9 @@ class GuiMainMenu(QMenuBar):
def _openUserManualFile(self): def _openUserManualFile(self):
"""Open the documentation in PDF format. """Open the documentation in PDF format.
""" """
if isinstance(self.mainConf.pdfDocs, Path): if isinstance(CONFIG.pdfDocs, Path):
QDesktopServices.openUrl( QDesktopServices.openUrl(
QUrl(urljoin("file:", pathname2url(str(self.mainConf.pdfDocs)))) QUrl(urljoin("file:", pathname2url(str(CONFIG.pdfDocs))))
) )
return return
@@ -310,7 +310,7 @@ class GuiMainMenu(QMenuBar):
# View > TreeView # View > TreeView
self.aFocusTree = QAction(self.tr("Go to Project Tree"), self) self.aFocusTree = QAction(self.tr("Go to Project Tree"), self)
if self.mainConf.osWindows: if CONFIG.osWindows:
self.aFocusTree.setShortcut("Ctrl+Alt+1") self.aFocusTree.setShortcut("Ctrl+Alt+1")
else: else:
self.aFocusTree.setShortcut("Alt+1") self.aFocusTree.setShortcut("Alt+1")
@@ -319,7 +319,7 @@ class GuiMainMenu(QMenuBar):
# View > Document Pane 1 # View > Document Pane 1
self.aFocusEditor = QAction(self.tr("Go to Document Editor"), self) self.aFocusEditor = QAction(self.tr("Go to Document Editor"), self)
if self.mainConf.osWindows: if CONFIG.osWindows:
self.aFocusEditor.setShortcut("Ctrl+Alt+2") self.aFocusEditor.setShortcut("Ctrl+Alt+2")
else: else:
self.aFocusEditor.setShortcut("Alt+2") self.aFocusEditor.setShortcut("Alt+2")
@@ -328,7 +328,7 @@ class GuiMainMenu(QMenuBar):
# View > Document Pane 2 # View > Document Pane 2
self.aFocusView = QAction(self.tr("Go to Document Viewer"), self) self.aFocusView = QAction(self.tr("Go to Document Viewer"), self)
if self.mainConf.osWindows: if CONFIG.osWindows:
self.aFocusView.setShortcut("Ctrl+Alt+3") self.aFocusView.setShortcut("Ctrl+Alt+3")
else: else:
self.aFocusView.setShortcut("Alt+3") self.aFocusView.setShortcut("Alt+3")
@@ -337,7 +337,7 @@ class GuiMainMenu(QMenuBar):
# View > Outline # View > Outline
self.aFocusOutline = QAction(self.tr("Go to Outline"), self) self.aFocusOutline = QAction(self.tr("Go to Outline"), self)
if self.mainConf.osWindows: if CONFIG.osWindows:
self.aFocusOutline.setShortcut("Ctrl+Alt+4") self.aFocusOutline.setShortcut("Ctrl+Alt+4")
else: else:
self.aFocusOutline.setShortcut("Alt+4") self.aFocusOutline.setShortcut("Alt+4")
@@ -754,7 +754,7 @@ class GuiMainMenu(QMenuBar):
# Search > Replace # Search > Replace
self.aReplace = QAction(self.tr("Replace"), self) self.aReplace = QAction(self.tr("Replace"), self)
if self.mainConf.osDarwin: if CONFIG.osDarwin:
self.aReplace.setShortcut("Ctrl+=") self.aReplace.setShortcut("Ctrl+=")
else: else:
self.aReplace.setShortcut("Ctrl+H") self.aReplace.setShortcut("Ctrl+H")
@@ -763,7 +763,7 @@ class GuiMainMenu(QMenuBar):
# Search > Find Next # Search > Find Next
self.aFindNext = QAction(self.tr("Find Next"), self) self.aFindNext = QAction(self.tr("Find Next"), self)
if self.mainConf.osDarwin: if CONFIG.osDarwin:
self.aFindNext.setShortcuts(["Ctrl+G", "F3"]) self.aFindNext.setShortcuts(["Ctrl+G", "F3"])
else: else:
self.aFindNext.setShortcuts(["F3", "Ctrl+G"]) self.aFindNext.setShortcuts(["F3", "Ctrl+G"])
@@ -772,7 +772,7 @@ class GuiMainMenu(QMenuBar):
# Search > Find Prev # Search > Find Prev
self.aFindPrev = QAction(self.tr("Find Previous"), self) self.aFindPrev = QAction(self.tr("Find Previous"), self)
if self.mainConf.osDarwin: if CONFIG.osDarwin:
self.aFindPrev.setShortcuts(["Ctrl+Shift+G", "Shift+F3"]) self.aFindPrev.setShortcuts(["Ctrl+Shift+G", "Shift+F3"])
else: else:
self.aFindPrev.setShortcuts(["Shift+F3", "Ctrl+Shift+G"]) self.aFindPrev.setShortcuts(["Shift+F3", "Ctrl+Shift+G"])
@@ -883,7 +883,7 @@ class GuiMainMenu(QMenuBar):
self.helpMenu.addAction(self.aHelpDocs) self.helpMenu.addAction(self.aHelpDocs)
# Help > User Manual (PDF) # Help > User Manual (PDF)
if isinstance(self.mainConf.pdfDocs, Path): if isinstance(CONFIG.pdfDocs, Path):
self.aPdfDocs = QAction(self.tr("User Manual (PDF)"), self) self.aPdfDocs = QAction(self.tr("User Manual (PDF)"), self)
self.aPdfDocs.setShortcut("Shift+F1") self.aPdfDocs.setShortcut("Shift+F1")
self.aPdfDocs.triggered.connect(self._openUserManualFile) self.aPdfDocs.triggered.connect(self._openUserManualFile)
+7 -9
View File
@@ -26,7 +26,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from enum import Enum from enum import Enum
from time import time from time import time
@@ -39,6 +38,7 @@ from PyQt5.QtWidgets import (
QTreeWidgetItem, QVBoxLayout, QWidget QTreeWidgetItem, QVBoxLayout, QWidget
) )
from novelwriter import CONFIG
from novelwriter.enum import nwDocMode, nwItemClass, nwOutline from novelwriter.enum import nwDocMode, nwItemClass, nwOutline
from novelwriter.common import minmax from novelwriter.common import minmax
from novelwriter.constants import nwHeaders, nwKeyWords, nwLabels, trConst from novelwriter.constants import nwHeaders, nwKeyWords, nwLabels, trConst
@@ -198,14 +198,13 @@ class GuiNovelToolBar(QWidget):
logger.debug("Initialising GuiNovelToolBar ...") logger.debug("Initialising GuiNovelToolBar ...")
self.mainConf = novelwriter.CONFIG
self.novelView = novelView self.novelView = novelView
self.mainGui = novelView.mainGui self.mainGui = novelView.mainGui
self.theProject = novelView.mainGui.theProject self.theProject = novelView.mainGui.theProject
self.mainTheme = novelView.mainGui.mainTheme self.mainTheme = novelView.mainGui.mainTheme
iPx = self.mainTheme.baseIconSize iPx = self.mainTheme.baseIconSize
mPx = self.mainConf.pxInt(2) mPx = CONFIG.pxInt(2)
self.setContentsMargins(0, 0, 0, 0) self.setContentsMargins(0, 0, 0, 0)
self.setAutoFillBackground(True) self.setAutoFillBackground(True)
@@ -216,7 +215,7 @@ class GuiNovelToolBar(QWidget):
self.novelPrefix = self.tr("Outline of {0}") self.novelPrefix = self.tr("Outline of {0}")
self.novelValue = NovelSelector(self, self.theProject, self.mainGui) self.novelValue = NovelSelector(self, self.theProject, self.mainGui)
self.novelValue.setFont(selFont) self.novelValue.setFont(selFont)
self.novelValue.setMinimumWidth(self.mainConf.pxInt(150)) self.novelValue.setMinimumWidth(CONFIG.pxInt(150))
self.novelValue.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.novelValue.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.novelValue.novelSelectionChanged.connect(self.setCurrentRoot) self.novelValue.novelSelectionChanged.connect(self.setCurrentRoot)
@@ -290,7 +289,7 @@ class GuiNovelToolBar(QWidget):
buttonStyle = ( buttonStyle = (
"QToolButton {{padding: {0}px; border: none; background: transparent;}} " "QToolButton {{padding: {0}px; border: none; background: transparent;}} "
"QToolButton:hover {{border: none; background: rgba({1},{2},{3},0.2);}}" "QToolButton:hover {{border: none; background: rgba({1},{2},{3},0.2);}}"
).format(self.mainConf.pxInt(2), fadeCol.red(), fadeCol.green(), fadeCol.blue()) ).format(CONFIG.pxInt(2), fadeCol.red(), fadeCol.green(), fadeCol.blue())
self.tbNovel.setStyleSheet(buttonStyle) self.tbNovel.setStyleSheet(buttonStyle)
self.tbRefresh.setStyleSheet(buttonStyle) self.tbRefresh.setStyleSheet(buttonStyle)
@@ -398,7 +397,6 @@ class GuiNovelTree(QTreeWidget):
logger.debug("Initialising GuiNovelTree ...") logger.debug("Initialising GuiNovelTree ...")
self.mainConf = novelwriter.CONFIG
self.novelView = novelView self.novelView = novelView
self.mainGui = novelView.mainGui self.mainGui = novelView.mainGui
self.mainTheme = novelView.mainGui.mainTheme self.mainTheme = novelView.mainGui.mainTheme
@@ -420,7 +418,7 @@ class GuiNovelTree(QTreeWidget):
# ========= # =========
iPx = self.mainTheme.baseIconSize iPx = self.mainTheme.baseIconSize
cMg = self.mainConf.pxInt(6) cMg = CONFIG.pxInt(6)
self.setIconSize(QSize(iPx, iPx)) self.setIconSize(QSize(iPx, iPx))
self.setFrameStyle(QFrame.NoFrame) self.setFrameStyle(QFrame.NoFrame)
@@ -470,12 +468,12 @@ class GuiNovelTree(QTreeWidget):
"""Set or update tree widget settings. """Set or update tree widget settings.
""" """
# Scroll bars # Scroll bars
if self.mainConf.hideVScroll: if CONFIG.hideVScroll:
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
if self.mainConf.hideHScroll: if CONFIG.hideHScroll:
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
+14 -18
View File
@@ -28,7 +28,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from time import time from time import time
from enum import Enum from enum import Enum
@@ -42,6 +41,7 @@ from PyQt5.QtWidgets import (
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
) )
from novelwriter import CONFIG
from novelwriter.enum import ( from novelwriter.enum import (
nwDocMode, nwItemClass, nwItemLayout, nwItemType, nwOutline nwDocMode, nwItemClass, nwItemLayout, nwItemType, nwOutline
) )
@@ -61,7 +61,6 @@ class GuiOutlineView(QWidget):
def __init__(self, mainGui): def __init__(self, mainGui):
super().__init__(parent=mainGui) super().__init__(parent=mainGui)
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
@@ -75,7 +74,7 @@ class GuiOutlineView(QWidget):
self.splitOutline.addWidget(self.outlineTree) self.splitOutline.addWidget(self.outlineTree)
self.splitOutline.addWidget(self.outlineData) self.splitOutline.addWidget(self.outlineData)
self.splitOutline.setOpaqueResize(False) self.splitOutline.setOpaqueResize(False)
self.splitOutline.setSizes(self.mainConf.outlinePanePos) self.splitOutline.setSizes(CONFIG.outlinePanePos)
# Assemble # Assemble
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
@@ -215,13 +214,12 @@ class GuiOutlineToolBar(QToolBar):
logger.debug("Initialising GuiOutlineToolBar ...") logger.debug("Initialising GuiOutlineToolBar ...")
self.mainConf = novelwriter.CONFIG
self.mainGui = theOutline.mainGui self.mainGui = theOutline.mainGui
self.theProject = theOutline.mainGui.theProject self.theProject = theOutline.mainGui.theProject
self.mainTheme = theOutline.mainGui.mainTheme self.mainTheme = theOutline.mainGui.mainTheme
iPx = self.mainConf.pxInt(22) iPx = CONFIG.pxInt(22)
mPx = self.mainConf.pxInt(12) mPx = CONFIG.pxInt(12)
self.setMovable(False) self.setMovable(False)
self.setIconSize(QSize(iPx, iPx)) self.setIconSize(QSize(iPx, iPx))
@@ -235,7 +233,7 @@ class GuiOutlineToolBar(QToolBar):
self.novelLabel.setContentsMargins(0, 0, mPx, 0) self.novelLabel.setContentsMargins(0, 0, mPx, 0)
self.novelValue = NovelSelector(self, self.theProject, self.mainGui) self.novelValue = NovelSelector(self, self.theProject, self.mainGui)
self.novelValue.setMinimumWidth(self.mainConf.pxInt(200)) self.novelValue.setMinimumWidth(CONFIG.pxInt(200))
self.novelValue.novelSelectionChanged.connect(self._novelValueChanged) self.novelValue.novelSelectionChanged.connect(self._novelValueChanged)
# Actions # Actions
@@ -373,7 +371,6 @@ class GuiOutlineTree(QTreeWidget):
logger.debug("Initialising GuiOutlineTree ...") logger.debug("Initialising GuiOutlineTree ...")
self.mainConf = novelwriter.CONFIG
self.outlineView = outlineView self.outlineView = outlineView
self.mainGui = outlineView.mainGui self.mainGui = outlineView.mainGui
self.theProject = outlineView.mainGui.theProject self.theProject = outlineView.mainGui.theProject
@@ -446,12 +443,12 @@ class GuiOutlineTree(QTreeWidget):
"""Set or update outline settings. """Set or update outline settings.
""" """
# Scroll bars # Scroll bars
if self.mainConf.hideVScroll: if CONFIG.hideVScroll:
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
if self.mainConf.hideHScroll: if CONFIG.hideHScroll:
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
@@ -610,7 +607,7 @@ class GuiOutlineTree(QTreeWidget):
tmpWidth = pOptions.getValue("GuiOutline", "columnWidth", {}) tmpWidth = pOptions.getValue("GuiOutline", "columnWidth", {})
for hName in tmpWidth: for hName in tmpWidth:
try: try:
self._colWidth[nwOutline[hName]] = self.mainConf.pxInt(tmpWidth[hName]) self._colWidth[nwOutline[hName]] = CONFIG.pxInt(tmpWidth[hName])
except Exception: except Exception:
logger.warning("Ignored unknown outline column '%s'", str(hName)) logger.warning("Ignored unknown outline column '%s'", str(hName))
@@ -640,7 +637,7 @@ class GuiOutlineTree(QTreeWidget):
colHidden = {} colHidden = {}
for hItem in nwOutline: for hItem in nwOutline:
colWidth[hItem.name] = self.mainConf.rpxInt(self._colWidth[hItem]) colWidth[hItem.name] = CONFIG.rpxInt(self._colWidth[hItem])
colHidden[hItem.name] = self._colHidden[hItem] colHidden[hItem.name] = self._colHidden[hItem]
for iCol in range(self.columnCount()): for iCol in range(self.columnCount()):
@@ -648,7 +645,7 @@ class GuiOutlineTree(QTreeWidget):
treeOrder.append(hName) treeOrder.append(hName)
iLog = self.treeHead.logicalIndex(iCol) iLog = self.treeHead.logicalIndex(iCol)
logWidth = self.mainConf.rpxInt(self.columnWidth(iLog)) logWidth = CONFIG.rpxInt(self.columnWidth(iLog))
logHidden = self.isColumnHidden(iLog) logHidden = self.isColumnHidden(iLog)
colHidden[hName] = logHidden colHidden[hName] = logHidden
@@ -801,7 +798,6 @@ class GuiOutlineDetails(QScrollArea):
logger.debug("Initialising GuiOutlineDetails ...") logger.debug("Initialising GuiOutlineDetails ...")
self.mainConf = novelwriter.CONFIG
self.theOutline = theOutline self.theOutline = theOutline
self.mainGui = theOutline.mainGui self.mainGui = theOutline.mainGui
self.theProject = theOutline.mainGui.theProject self.theProject = theOutline.mainGui.theProject
@@ -811,8 +807,8 @@ class GuiOutlineDetails(QScrollArea):
minTitle = 30*self.mainTheme.textNWidth minTitle = 30*self.mainTheme.textNWidth
maxTitle = 40*self.mainTheme.textNWidth maxTitle = 40*self.mainTheme.textNWidth
wCount = self.mainTheme.getTextWidth("999,999") wCount = self.mainTheme.getTextWidth("999,999")
hSpace = int(self.mainConf.pxInt(10)) hSpace = int(CONFIG.pxInt(10))
vSpace = int(self.mainConf.pxInt(4)) vSpace = int(CONFIG.pxInt(4))
# Details Area # Details Area
self.titleLabel = QLabel("<b>%s</b>" % self.tr("Title")) self.titleLabel = QLabel("<b>%s</b>" % self.tr("Title"))
@@ -994,12 +990,12 @@ class GuiOutlineDetails(QScrollArea):
"""Set or update outline settings. """Set or update outline settings.
""" """
# Scroll bars # Scroll bars
if self.mainConf.hideVScroll: if CONFIG.hideVScroll:
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
if self.mainConf.hideHScroll: if CONFIG.hideHScroll:
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
+8 -10
View File
@@ -26,7 +26,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from enum import Enum from enum import Enum
from time import time from time import time
@@ -38,10 +37,11 @@ from PyQt5.QtWidgets import (
QMenu, QShortcut, QSizePolicy, QToolButton, QTreeWidget, QTreeWidgetItem, QMenu, QShortcut, QSizePolicy, QToolButton, QTreeWidget, QTreeWidgetItem,
QVBoxLayout, QWidget QVBoxLayout, QWidget
) )
from novelwriter.core.item import NWItem
from novelwriter import CONFIG
from novelwriter.enum import nwDocMode, nwItemType, nwItemClass, nwItemLayout, nwAlert, nwWidget from novelwriter.enum import nwDocMode, nwItemType, nwItemClass, nwItemLayout, nwAlert, nwWidget
from novelwriter.constants import nwHeaders, nwUnicode, trConst, nwLabels from novelwriter.constants import nwHeaders, nwUnicode, trConst, nwLabels
from novelwriter.core.item import NWItem
from novelwriter.core.coretools import DocMerger, DocSplitter from novelwriter.core.coretools import DocMerger, DocSplitter
from novelwriter.dialogs.docmerge import GuiDocMerge from novelwriter.dialogs.docmerge import GuiDocMerge
from novelwriter.dialogs.docsplit import GuiDocSplit from novelwriter.dialogs.docsplit import GuiDocSplit
@@ -217,7 +217,6 @@ class GuiProjectToolBar(QWidget):
logger.debug("Initialising GuiProjectToolBar ...") logger.debug("Initialising GuiProjectToolBar ...")
self.mainConf = novelwriter.CONFIG
self.projView = projView self.projView = projView
self.projTree = projView.projTree self.projTree = projView.projTree
self.mainGui = projView.mainGui self.mainGui = projView.mainGui
@@ -225,7 +224,7 @@ class GuiProjectToolBar(QWidget):
self.mainTheme = projView.mainGui.mainTheme self.mainTheme = projView.mainGui.mainTheme
iPx = self.mainTheme.baseIconSize iPx = self.mainTheme.baseIconSize
mPx = self.mainConf.pxInt(2) mPx = CONFIG.pxInt(2)
self.setContentsMargins(0, 0, 0, 0) self.setContentsMargins(0, 0, 0, 0)
self.setAutoFillBackground(True) self.setAutoFillBackground(True)
@@ -348,7 +347,7 @@ class GuiProjectToolBar(QWidget):
buttonStyle = ( buttonStyle = (
"QToolButton {{padding: {0}px; border: none; background: transparent;}} " "QToolButton {{padding: {0}px; border: none; background: transparent;}} "
"QToolButton:hover {{border: none; background: rgba({1},{2},{3},0.2);}}" "QToolButton:hover {{border: none; background: rgba({1},{2},{3},0.2);}}"
).format(self.mainConf.pxInt(2), fadeCol.red(), fadeCol.green(), fadeCol.blue()) ).format(CONFIG.pxInt(2), fadeCol.red(), fadeCol.green(), fadeCol.blue())
self.tbQuick.setStyleSheet(buttonStyle) self.tbQuick.setStyleSheet(buttonStyle)
self.tbMoveU.setStyleSheet(buttonStyle) self.tbMoveU.setStyleSheet(buttonStyle)
@@ -458,7 +457,6 @@ class GuiProjectTree(QTreeWidget):
logger.debug("Initialising GuiProjectTree ...") logger.debug("Initialising GuiProjectTree ...")
self.mainConf = novelwriter.CONFIG
self.projView = projView self.projView = projView
self.mainGui = projView.mainGui self.mainGui = projView.mainGui
self.mainTheme = projView.mainGui.mainTheme self.mainTheme = projView.mainGui.mainTheme
@@ -478,7 +476,7 @@ class GuiProjectTree(QTreeWidget):
# Tree Settings # Tree Settings
iPx = self.mainTheme.baseIconSize iPx = self.mainTheme.baseIconSize
cMg = self.mainConf.pxInt(6) cMg = CONFIG.pxInt(6)
self.setIconSize(QSize(iPx, iPx)) self.setIconSize(QSize(iPx, iPx))
self.setFrameStyle(QFrame.NoFrame) self.setFrameStyle(QFrame.NoFrame)
@@ -532,12 +530,12 @@ class GuiProjectTree(QTreeWidget):
"""Set or update tree widget settings. """Set or update tree widget settings.
""" """
# Scroll bars # Scroll bars
if self.mainConf.hideVScroll: if CONFIG.hideVScroll:
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
if self.mainConf.hideHScroll: if CONFIG.hideHScroll:
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
@@ -987,7 +985,7 @@ class GuiProjectTree(QTreeWidget):
trItem.setIcon(self.C_ACTIVE, self.mainTheme.getIcon(iconName)) trItem.setIcon(self.C_ACTIVE, self.mainTheme.getIcon(iconName))
if self.mainConf.emphLabels and nwItem.isDocumentLayout(): if CONFIG.emphLabels and nwItem.isDocumentLayout():
trFont = trItem.font(self.C_NAME) trFont = trItem.font(self.C_NAME)
trFont.setBold(hLevel == "H1" or hLevel == "H2") trFont.setBold(hLevel == "H1" or hLevel == "H2")
trFont.setUnderline(hLevel == "H1") trFont.setUnderline(hLevel == "H1")
+3 -4
View File
@@ -24,13 +24,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from PyQt5.QtCore import Qt, QSize, pyqtSignal from PyQt5.QtCore import Qt, QSize, pyqtSignal
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QToolBar, QWidget, QSizePolicy, QAction, QMenu, QToolButton QToolBar, QWidget, QSizePolicy, QAction, QMenu, QToolButton
) )
from novelwriter import CONFIG
from novelwriter.enum import nwView from novelwriter.enum import nwView
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -45,13 +45,12 @@ class GuiSideBar(QToolBar):
logger.debug("Initialising GuiSideBar ...") logger.debug("Initialising GuiSideBar ...")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
# Style # Style
iPx = self.mainConf.pxInt(22) iPx = CONFIG.pxInt(22)
mPx = self.mainConf.pxInt(60) mPx = CONFIG.pxInt(60)
lblFont = self.mainTheme.guiFont lblFont = self.mainTheme.guiFont
lblFont.setPointSizeF(0.65*self.mainTheme.fontPointSize) lblFont.setPointSizeF(0.65*self.mainTheme.fontPointSize)
+5 -6
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from time import time from time import time
@@ -33,6 +32,7 @@ from PyQt5.QtCore import pyqtSlot, QLocale
from PyQt5.QtGui import QColor from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import qApp, QStatusBar, QLabel from PyQt5.QtWidgets import qApp, QStatusBar, QLabel
from novelwriter import CONFIG
from novelwriter.common import formatTime from novelwriter.common import formatTime
from novelwriter.gui.components import StatusLED from novelwriter.gui.components import StatusLED
@@ -46,7 +46,6 @@ class GuiMainStatus(QStatusBar):
logger.debug("Initialising GuiMainStatus ...") logger.debug("Initialising GuiMainStatus ...")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
self.refTime = None self.refTime = None
@@ -61,7 +60,7 @@ class GuiMainStatus(QStatusBar):
# Permanent Widgets # Permanent Widgets
# ================= # =================
xM = self.mainConf.pxInt(8) xM = CONFIG.pxInt(8)
# The Spell Checker Language # The Spell Checker Language
self.langIcon = QLabel("") self.langIcon = QLabel("")
@@ -174,7 +173,7 @@ class GuiMainStatus(QStatusBar):
def setUserIdle(self, userIdle): def setUserIdle(self, userIdle):
"""Change the idle status icon. """Change the idle status icon.
""" """
if not self.mainConf.stopWhenIdle: if not CONFIG.stopWhenIdle:
userIdle = False userIdle = False
if self.userIdle != userIdle: if self.userIdle != userIdle:
@@ -191,7 +190,7 @@ class GuiMainStatus(QStatusBar):
"""Update the current project statistics. """Update the current project statistics.
""" """
self.statsText.setText(self.tr("Words: {0} ({1})").format(f"{pWC:n}", f"{sWC:+n}")) self.statsText.setText(self.tr("Words: {0} ({1})").format(f"{pWC:n}", f"{sWC:+n}"))
if self.mainConf.incNotesWCount: if CONFIG.incNotesWCount:
self.statsText.setToolTip(self.tr("Project word count (session change)")) self.statsText.setToolTip(self.tr("Project word count (session change)"))
else: else:
self.statsText.setToolTip(self.tr("Novel word count (session change)")) self.statsText.setToolTip(self.tr("Novel word count (session change)"))
@@ -203,7 +202,7 @@ class GuiMainStatus(QStatusBar):
if self.refTime is None: if self.refTime is None:
self.timeText.setText("00:00:00") self.timeText.setText("00:00:00")
else: else:
if self.mainConf.stopWhenIdle: if CONFIG.stopWhenIdle:
sessTime = round(time() - self.refTime - idleTime) sessTime = round(time() - self.refTime - idleTime)
else: else:
sessTime = round(time() - self.refTime) sessTime = round(time() - self.refTime)
+19 -21
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from math import ceil from math import ceil
@@ -35,6 +34,7 @@ from PyQt5.QtGui import (
QPalette, QColor, QIcon, QFont, QFontMetrics, QFontDatabase, QPixmap QPalette, QColor, QIcon, QFont, QFontMetrics, QFontDatabase, QPixmap
) )
from novelwriter import CONFIG
from novelwriter.enum import nwItemLayout, nwItemType from novelwriter.enum import nwItemLayout, nwItemType
from novelwriter.error import logException from novelwriter.error import logException
from novelwriter.common import NWConfigParser, minmax from novelwriter.common import NWConfigParser, minmax
@@ -52,7 +52,6 @@ class GuiTheme:
def __init__(self): def __init__(self):
self.mainConf = novelwriter.CONFIG
self.iconCache = GuiIcons(self) self.iconCache = GuiIcons(self)
# Loaded Theme Settings # Loaded Theme Settings
@@ -118,10 +117,10 @@ class GuiTheme:
self._availThemes = {} self._availThemes = {}
self._availSyntax = {} self._availSyntax = {}
self._listConf(self._availSyntax, self.mainConf.assetPath("syntax")) self._listConf(self._availSyntax, CONFIG.assetPath("syntax"))
self._listConf(self._availThemes, self.mainConf.assetPath("themes")) self._listConf(self._availThemes, CONFIG.assetPath("themes"))
self._listConf(self._availSyntax, self.mainConf.dataPath("syntax")) self._listConf(self._availSyntax, CONFIG.dataPath("syntax"))
self._listConf(self._availThemes, self.mainConf.dataPath("themes")) self._listConf(self._availThemes, CONFIG.dataPath("themes"))
self.loadTheme() self.loadTheme()
self.loadSyntax() self.loadSyntax()
@@ -136,7 +135,7 @@ class GuiTheme:
# Extract Other Info # Extract Other Info
self.guiDPI = qApp.primaryScreen().logicalDotsPerInchX() self.guiDPI = qApp.primaryScreen().logicalDotsPerInchX()
self.guiScale = qApp.primaryScreen().logicalDotsPerInchX()/96.0 self.guiScale = qApp.primaryScreen().logicalDotsPerInchX()/96.0
self.mainConf.guiScale = self.guiScale CONFIG.guiScale = self.guiScale
logger.debug("GUI DPI: %.1f", self.guiDPI) logger.debug("GUI DPI: %.1f", self.guiDPI)
logger.debug("GUI Scale: %.2f", self.guiScale) logger.debug("GUI Scale: %.2f", self.guiScale)
@@ -184,11 +183,11 @@ class GuiTheme:
def loadTheme(self): def loadTheme(self):
"""Load the currently specified GUI theme. """Load the currently specified GUI theme.
""" """
guiTheme = self.mainConf.guiTheme guiTheme = CONFIG.guiTheme
if guiTheme not in self._availThemes: if guiTheme not in self._availThemes:
logger.error("Could not find GUI theme '%s'", guiTheme) logger.error("Could not find GUI theme '%s'", guiTheme)
guiTheme = "default" guiTheme = "default"
self.mainConf.guiTheme = guiTheme CONFIG.guiTheme = guiTheme
themeFile = self._availThemes.get(guiTheme, None) themeFile = self._availThemes.get(guiTheme, None)
if themeFile is None: if themeFile is None:
@@ -270,11 +269,11 @@ class GuiTheme:
def loadSyntax(self): def loadSyntax(self):
"""Load the currently specified syntax highlighter theme. """Load the currently specified syntax highlighter theme.
""" """
guiSyntax = self.mainConf.guiSyntax guiSyntax = CONFIG.guiSyntax
if guiSyntax not in self._availSyntax: if guiSyntax not in self._availSyntax:
logger.error("Could not find syntax theme '%s'", guiSyntax) logger.error("Could not find syntax theme '%s'", guiSyntax)
guiSyntax = "default_light" guiSyntax = "default_light"
self.mainConf.guiSyntax = guiSyntax CONFIG.guiSyntax = guiSyntax
syntaxFile = self._availSyntax.get(guiSyntax, None) syntaxFile = self._availSyntax.get(guiSyntax, None)
if syntaxFile is None: if syntaxFile is None:
@@ -367,18 +366,18 @@ class GuiTheme:
"""Update the GUI's font style from settings. """Update the GUI's font style from settings.
""" """
theFont = QFont() theFont = QFont()
if self.mainConf.guiFont not in self.guiFontDB.families(): if CONFIG.guiFont not in self.guiFontDB.families():
if self.mainConf.osWindows and "Arial" in self.guiFontDB.families(): if CONFIG.osWindows and "Arial" in self.guiFontDB.families():
# On Windows we default to Arial if possible # On Windows we default to Arial if possible
theFont.setFamily("Arial") theFont.setFamily("Arial")
theFont.setPointSize(10) theFont.setPointSize(10)
else: else:
theFont = self.guiFontDB.systemFont(QFontDatabase.GeneralFont) theFont = self.guiFontDB.systemFont(QFontDatabase.GeneralFont)
self.mainConf.guiFont = theFont.family() CONFIG.guiFont = theFont.family()
self.mainConf.guiFontSize = theFont.pointSize() CONFIG.guiFontSize = theFont.pointSize()
else: else:
theFont.setFamily(self.mainConf.guiFont) theFont.setFamily(CONFIG.guiFont)
theFont.setPointSize(self.mainConf.guiFontSize) theFont.setPointSize(CONFIG.guiFontSize)
qApp.setFont(theFont) qApp.setFont(theFont)
@@ -472,7 +471,6 @@ class GuiIcons:
def __init__(self, mainTheme): def __init__(self, mainTheme):
self.mainConf = novelwriter.CONFIG
self.mainTheme = mainTheme self.mainTheme = mainTheme
# Storage # Storage
@@ -482,7 +480,7 @@ class GuiIcons:
self._confName = "icons.conf" self._confName = "icons.conf"
# Icon Theme Path # Icon Theme Path
self._iconPath = self.mainConf.assetPath("icons") self._iconPath = CONFIG.assetPath("icons")
# Icon Theme Meta # Icon Theme Meta
self.themeName = "" self.themeName = ""
@@ -507,7 +505,7 @@ class GuiIcons:
self._themeMap = {} self._themeMap = {}
themePath = self._iconPath / iconTheme themePath = self._iconPath / iconTheme
if not themePath.is_dir(): if not themePath.is_dir():
themePath = self.mainConf.dataPath("icons") / iconTheme themePath = CONFIG.dataPath("icons") / iconTheme
if not themePath.is_dir(): if not themePath.is_dir():
logger.warning("No icons loaded for '%s'", iconTheme) logger.warning("No icons loaded for '%s'", iconTheme)
return False return False
@@ -580,7 +578,7 @@ class GuiIcons:
if decoKey in self._themeMap: if decoKey in self._themeMap:
imgPath = self._themeMap[decoKey] imgPath = self._themeMap[decoKey]
elif decoKey in self.IMAGE_MAP: elif decoKey in self.IMAGE_MAP:
imgPath = self.mainConf.assetPath("images") / self.IMAGE_MAP[decoKey] imgPath = CONFIG.assetPath("images") / self.IMAGE_MAP[decoKey]
else: else:
logger.error("Decoration with name '%s' does not exist", decoKey) logger.error("Decoration with name '%s' does not exist", decoKey)
return QPixmap() return QPixmap()
+40 -41
View File
@@ -24,7 +24,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
import logging import logging
import novelwriter
from enum import Enum from enum import Enum
from time import time from time import time
@@ -38,6 +37,7 @@ from PyQt5.QtWidgets import (
QMessageBox, QDialog, QStackedWidget QMessageBox, QDialog, QStackedWidget
) )
from novelwriter import CONFIG, __hexversion__
from novelwriter.gui.theme import GuiTheme from novelwriter.gui.theme import GuiTheme
from novelwriter.gui.sidebar import GuiSideBar from novelwriter.gui.sidebar import GuiSideBar
from novelwriter.gui.outline import GuiOutlineView from novelwriter.gui.outline import GuiOutlineView
@@ -78,19 +78,18 @@ class GuiMain(QMainWindow):
logger.debug("Initialising GUI ...") logger.debug("Initialising GUI ...")
self.setObjectName("GuiMain") self.setObjectName("GuiMain")
self.mainConf = novelwriter.CONFIG
self.threadPool = QThreadPool() self.threadPool = QThreadPool()
# System Info # System Info
# =========== # ===========
logger.info("OS: %s", self.mainConf.osType) logger.info("OS: %s", CONFIG.osType)
logger.info("Kernel: %s", self.mainConf.kernelVer) logger.info("Kernel: %s", CONFIG.kernelVer)
logger.info("Host: %s", self.mainConf.hostName) logger.info("Host: %s", CONFIG.hostName)
logger.info("Qt5: %s (0x%06x)", self.mainConf.verQtString, self.mainConf.verQtValue) logger.info("Qt5: %s (0x%06x)", CONFIG.verQtString, CONFIG.verQtValue)
logger.info("PyQt5: %s (0x%06x)", self.mainConf.verPyQtString, self.mainConf.verPyQtValue) logger.info("PyQt5: %s (0x%06x)", CONFIG.verPyQtString, CONFIG.verPyQtValue)
logger.info("Python: %s (0x%08x)", self.mainConf.verPyString, self.mainConf.verPyHexVal) logger.info("Python: %s (0x%08x)", CONFIG.verPyString, CONFIG.verPyHexVal)
logger.info("GUI Language: %s", self.mainConf.guiLocale) logger.info("GUI Language: %s", CONFIG.guiLocale)
# Core Classes # Core Classes
# ============ # ============
@@ -104,10 +103,10 @@ class GuiMain(QMainWindow):
self.idleTime = 0.0 self.idleTime = 0.0
# Prepare Main Window # Prepare Main Window
self.resize(*self.mainConf.mainWinSize) self.resize(*CONFIG.mainWinSize)
self._updateWindowTitle() self._updateWindowTitle()
nwIcon = self.mainConf.assetPath("icons") / "novelwriter.svg" nwIcon = CONFIG.assetPath("icons") / "novelwriter.svg"
self.nwIcon = QIcon(str(nwIcon)) if nwIcon.is_file() else QIcon() self.nwIcon = QIcon(str(nwIcon)) if nwIcon.is_file() else QIcon()
self.setWindowIcon(self.nwIcon) self.setWindowIcon(self.nwIcon)
qApp.setWindowIcon(self.nwIcon) qApp.setWindowIcon(self.nwIcon)
@@ -116,8 +115,8 @@ class GuiMain(QMainWindow):
# ============= # =============
# Sizes # Sizes
mPx = self.mainConf.pxInt(4) mPx = CONFIG.pxInt(4)
hWd = self.mainConf.pxInt(4) hWd = CONFIG.pxInt(4)
# Main GUI Elements # Main GUI Elements
self.mainStatus = GuiMainStatus(self) self.mainStatus = GuiMainStatus(self)
@@ -152,7 +151,7 @@ class GuiMain(QMainWindow):
self.splitView.addWidget(self.viewMeta) self.splitView.addWidget(self.viewMeta)
self.splitView.setHandleWidth(hWd) self.splitView.setHandleWidth(hWd)
self.splitView.setOpaqueResize(False) self.splitView.setOpaqueResize(False)
self.splitView.setSizes(self.mainConf.viewPanePos) self.splitView.setSizes(CONFIG.viewPanePos)
# Splitter : Document Editor / Document Viewer # Splitter : Document Editor / Document Viewer
self.splitDocs = QSplitter(Qt.Horizontal) self.splitDocs = QSplitter(Qt.Horizontal)
@@ -168,7 +167,7 @@ class GuiMain(QMainWindow):
self.splitMain.addWidget(self.splitDocs) self.splitMain.addWidget(self.splitDocs)
self.splitMain.setOpaqueResize(False) self.splitMain.setOpaqueResize(False)
self.splitMain.setHandleWidth(hWd) self.splitMain.setHandleWidth(hWd)
self.splitMain.setSizes(self.mainConf.mainPanePos) self.splitMain.setSizes(CONFIG.mainPanePos)
# Main Stack : Editor / Outline # Main Stack : Editor / Outline
self.mainStack = QStackedWidget() self.mainStack = QStackedWidget()
@@ -298,12 +297,12 @@ class GuiMain(QMainWindow):
# Handle Windows Mode # Handle Windows Mode
self.showNormal() self.showNormal()
if self.mainConf.isFullScreen: if CONFIG.isFullScreen:
self.toggleFullScreenMode() self.toggleFullScreenMode()
logger.debug("GUI initialisation complete") logger.debug("GUI initialisation complete")
if novelwriter.__hexversion__[-2] == "a" and logger.getEffectiveLevel() > logging.DEBUG: if __hexversion__[-2] == "a" and logger.getEffectiveLevel() > logging.DEBUG:
self.makeAlert(self.tr( self.makeAlert(self.tr(
"You are running an untested development version of novelWriter. " "You are running an untested development version of novelWriter. "
"Please be careful when working on a live project " "Please be careful when working on a live project "
@@ -338,8 +337,8 @@ class GuiMain(QMainWindow):
def initMain(self): def initMain(self):
"""Initialise elements that depend on user settings. """Initialise elements that depend on user settings.
""" """
self.asProjTimer.setInterval(int(self.mainConf.autoSaveProj*1000)) self.asProjTimer.setInterval(int(CONFIG.autoSaveProj*1000))
self.asDocTimer.setInterval(int(self.mainConf.autoSaveDoc*1000)) self.asDocTimer.setInterval(int(CONFIG.autoSaveDoc*1000))
return True return True
def postLaunchTasks(self, cmdOpen): def postLaunchTasks(self, cmdOpen):
@@ -354,8 +353,8 @@ class GuiMain(QMainWindow):
self.showProjectLoadDialog() self.showProjectLoadDialog()
# Determine whether release notes need to be shown or not # Determine whether release notes need to be shown or not
if hexToInt(self.mainConf.lastNotes) < hexToInt(novelwriter.__hexversion__): if hexToInt(CONFIG.lastNotes) < hexToInt(__hexversion__):
self.mainConf.lastNotes = novelwriter.__hexversion__ CONFIG.lastNotes = __hexversion__
self.showAboutNWDialog(showNotes=True) self.showAboutNWDialog(showNotes=True)
return return
@@ -426,9 +425,9 @@ class GuiMain(QMainWindow):
saveOK = self.saveProject() saveOK = self.saveProject()
doBackup = False doBackup = False
if self.theProject.data.doBackup and self.mainConf.backupOnClose: if self.theProject.data.doBackup and CONFIG.backupOnClose:
doBackup = True doBackup = True
if self.mainConf.askBeforeBackup: if CONFIG.askBeforeBackup:
msgYes = self.askQuestion( msgYes = self.askQuestion(
self.tr("Backup Project"), self.tr("Backup Project"),
self.tr("Backup the current project?") self.tr("Backup the current project?")
@@ -712,7 +711,7 @@ class GuiMain(QMainWindow):
vPos[0] = int(bPos[1]/2) vPos[0] = int(bPos[1]/2)
vPos[1] = bPos[1] - vPos[0] vPos[1] = bPos[1] - vPos[0]
self.splitDocs.setSizes(vPos) self.splitDocs.setSizes(vPos)
self.viewMeta.setVisible(self.mainConf.showRefPanel) self.viewMeta.setVisible(CONFIG.showRefPanel)
if sTitle: if sTitle:
self.docViewer.navigateTo(f"#{sTitle}") self.docViewer.navigateTo(f"#{sTitle}")
@@ -727,7 +726,7 @@ class GuiMain(QMainWindow):
logger.error("No project open") logger.error("No project open")
return False return False
lastPath = self.mainConf.lastPath() lastPath = CONFIG.lastPath()
extFilter = [ extFilter = [
self.tr("Text files ({0})").format("*.txt"), self.tr("Text files ({0})").format("*.txt"),
self.tr("Markdown files ({0})").format("*.md"), self.tr("Markdown files ({0})").format("*.md"),
@@ -747,7 +746,7 @@ class GuiMain(QMainWindow):
try: try:
with open(loadFile, mode="rt", encoding="utf-8") as inFile: with open(loadFile, mode="rt", encoding="utf-8") as inFile:
theText = inFile.read() theText = inFile.read()
self.mainConf.setLastPath(loadFile) CONFIG.setLastPath(loadFile)
except Exception as exc: except Exception as exc:
self.makeAlert(self.tr( self.makeAlert(self.tr(
"Could not read file. The file must be an existing text file." "Could not read file. The file must be an existing text file."
@@ -1162,8 +1161,8 @@ class GuiMain(QMainWindow):
the user know if this is the case. The Config module caches the user know if this is the case. The Config module caches
errors since it is initialised before the GUI itself. errors since it is initialised before the GUI itself.
""" """
if self.mainConf.hasError: if CONFIG.hasError:
self.makeAlert(self.mainConf.errorText(), nwAlert.ERROR) self.makeAlert(CONFIG.errorText(), nwAlert.ERROR)
return True return True
return False return False
@@ -1188,19 +1187,19 @@ class GuiMain(QMainWindow):
logger.info("Exiting novelWriter") logger.info("Exiting novelWriter")
if not self.isFocusMode: if not self.isFocusMode:
self.mainConf.setMainPanePos(self.splitMain.sizes()) CONFIG.setMainPanePos(self.splitMain.sizes())
self.mainConf.setOutlinePanePos(self.outlineView.splitSizes()) CONFIG.setOutlinePanePos(self.outlineView.splitSizes())
if self.viewMeta.isVisible(): if self.viewMeta.isVisible():
self.mainConf.setViewPanePos(self.splitView.sizes()) CONFIG.setViewPanePos(self.splitView.sizes())
self.mainConf.showRefPanel = self.viewMeta.isVisible() CONFIG.showRefPanel = self.viewMeta.isVisible()
if not self.mainConf.isFullScreen: if not CONFIG.isFullScreen:
self.mainConf.setMainWinSize(self.width(), self.height()) CONFIG.setMainWinSize(self.width(), self.height())
if self.hasProject: if self.hasProject:
self.closeProject(True) self.closeProject(True)
self.mainConf.saveConfig() CONFIG.saveConfig()
self.reportConfErr() self.reportConfErr()
qApp.quit() qApp.quit()
@@ -1269,7 +1268,7 @@ class GuiMain(QMainWindow):
self.mainMenu.setVisible(isVisible) self.mainMenu.setVisible(isVisible)
self.viewsBar.setVisible(isVisible) self.viewsBar.setVisible(isVisible)
hideDocFooter = self.isFocusMode and self.mainConf.hideFocusFooter hideDocFooter = self.isFocusMode and CONFIG.hideFocusFooter
self.docEditor.docFooter.setVisible(not hideDocFooter) self.docEditor.docFooter.setVisible(not hideDocFooter)
self.docEditor.docHeader.updateFocusMode() self.docEditor.docHeader.updateFocusMode()
@@ -1295,7 +1294,7 @@ class GuiMain(QMainWindow):
else: else:
logger.debug("Deactivated full screen mode") logger.debug("Deactivated full screen mode")
self.mainConf.isFullScreen = winState CONFIG.isFullScreen = winState
return return
@@ -1390,7 +1389,7 @@ class GuiMain(QMainWindow):
# Help # Help
self.addAction(self.mainMenu.aHelpDocs) self.addAction(self.mainMenu.aHelpDocs)
if isinstance(self.mainConf.pdfDocs, Path): if isinstance(CONFIG.pdfDocs, Path):
self.addAction(self.mainMenu.aPdfDocs) self.addAction(self.mainMenu.aPdfDocs)
return True return True
@@ -1398,7 +1397,7 @@ class GuiMain(QMainWindow):
def _updateWindowTitle(self, projName=None): def _updateWindowTitle(self, projName=None):
"""Set the window title and add the project's name. """Set the window title and add the project's name.
""" """
winTitle = self.mainConf.appName winTitle = CONFIG.appName
if projName is not None: if projName is not None:
winTitle += " - %s" % projName winTitle += " - %s" % projName
self.setWindowTitle(winTitle) self.setWindowTitle(winTitle)
@@ -1549,7 +1548,7 @@ class GuiMain(QMainWindow):
return return
currTime = time() currTime = time()
editIdle = currTime - self.docEditor.lastActive() > self.mainConf.userIdleTime editIdle = currTime - self.docEditor.lastActive() > CONFIG.userIdleTime
userIdle = qApp.applicationState() != Qt.ApplicationActive userIdle = qApp.applicationState() != Qt.ApplicationActive
if editIdle or userIdle: if editIdle or userIdle:
@@ -1571,7 +1570,7 @@ class GuiMain(QMainWindow):
self.mainStatus.setProjectStats(0, 0) self.mainStatus.setProjectStats(0, 0)
self.theProject.updateWordCounts() self.theProject.updateWordCounts()
if self.mainConf.incNotesWCount: if CONFIG.incNotesWCount:
iTotal = sum(self.theProject.data.initCounts) iTotal = sum(self.theProject.data.initCounts)
cTotal = sum(self.theProject.data.currCounts) cTotal = sum(self.theProject.data.currCounts)
self.mainStatus.setProjectStats(cTotal, cTotal - iTotal) self.mainStatus.setProjectStats(cTotal, cTotal - iTotal)
+27 -29
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import json import json
import logging import logging
import novelwriter
from time import time from time import time
from pathlib import Path from pathlib import Path
@@ -43,6 +42,7 @@ from PyQt5.QtWidgets import (
) )
from PyQt5.QtPrintSupport import QPrinter, QPrintPreviewDialog from PyQt5.QtPrintSupport import QPrinter, QPrintPreviewDialog
from novelwriter import CONFIG
from novelwriter.enum import nwAlert, nwItemType, nwItemLayout, nwItemClass from novelwriter.enum import nwAlert, nwItemType, nwItemLayout, nwItemClass
from novelwriter.error import formatException, logException from novelwriter.error import formatException, logException
from novelwriter.common import fuzzyTime, makeFileNameSafe from novelwriter.common import fuzzyTime, makeFileNameSafe
@@ -73,7 +73,6 @@ class GuiBuildNovel(QDialog):
logger.debug("Initialising GuiBuildNovel ...") logger.debug("Initialising GuiBuildNovel ...")
self.setObjectName("GuiBuildNovel") self.setObjectName("GuiBuildNovel")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
@@ -84,13 +83,13 @@ class GuiBuildNovel(QDialog):
self.buildTime = 0 # The timestamp of the last build self.buildTime = 0 # The timestamp of the last build
self.setWindowTitle(self.tr("Build Novel Project")) self.setWindowTitle(self.tr("Build Novel Project"))
self.setMinimumWidth(self.mainConf.pxInt(700)) self.setMinimumWidth(CONFIG.pxInt(700))
self.setMinimumHeight(self.mainConf.pxInt(600)) self.setMinimumHeight(CONFIG.pxInt(600))
pOptions = self.theProject.options pOptions = self.theProject.options
self.resize( self.resize(
self.mainConf.pxInt(pOptions.getInt("GuiBuildNovel", "winWidth", 900)), CONFIG.pxInt(pOptions.getInt("GuiBuildNovel", "winWidth", 900)),
self.mainConf.pxInt(pOptions.getInt("GuiBuildNovel", "winHeight", 800)) CONFIG.pxInt(pOptions.getInt("GuiBuildNovel", "winHeight", 800))
) )
self.docView = GuiBuildNovelDocView(self, self.theProject) self.docView = GuiBuildNovelDocView(self, self.theProject)
@@ -121,7 +120,7 @@ class GuiBuildNovel(QDialog):
"be centred automatically and only appear between sections of " "be centred automatically and only appear between sections of "
"the same type." "the same type."
).format("* * *") ).format("* * *")
xFmt = self.mainConf.pxInt(100) xFmt = CONFIG.pxInt(100)
self.fmtTitle = QLineEdit() self.fmtTitle = QLineEdit()
self.fmtTitle.setMaxLength(200) self.fmtTitle.setMaxLength(200)
@@ -165,7 +164,7 @@ class GuiBuildNovel(QDialog):
self.buildLang = QComboBox() self.buildLang = QComboBox()
self.buildLang.setMinimumWidth(xFmt) self.buildLang.setMinimumWidth(xFmt)
theLangs = self.mainConf.listLanguages(self.mainConf.LANG_PROJ) theLangs = CONFIG.listLanguages(CONFIG.LANG_PROJ)
self.buildLang.addItem("[%s]" % self.tr("Not Set"), "None") self.buildLang.addItem("[%s]" % self.tr("Not Set"), "None")
for langID, langName in theLangs: for langID, langName in theLangs:
self.buildLang.addItem(langName, langID) self.buildLang.addItem(langName, langID)
@@ -237,7 +236,7 @@ class GuiBuildNovel(QDialog):
self.textFont.setReadOnly(True) self.textFont.setReadOnly(True)
self.textFont.setMinimumWidth(xFmt) self.textFont.setMinimumWidth(xFmt)
self.textFont.setText( self.textFont.setText(
pOptions.getString("GuiBuildNovel", "textFont", self.mainConf.textFont) pOptions.getString("GuiBuildNovel", "textFont", CONFIG.textFont)
) )
self.fontButton = QPushButton("...") self.fontButton = QPushButton("...")
self.fontButton.setMaximumWidth(int(2.5*self.mainTheme.getTextWidth("..."))) self.fontButton.setMaximumWidth(int(2.5*self.mainTheme.getTextWidth("...")))
@@ -249,7 +248,7 @@ class GuiBuildNovel(QDialog):
self.textSize.setMaximum(72) self.textSize.setMaximum(72)
self.textSize.setSingleStep(1) self.textSize.setSingleStep(1)
self.textSize.setValue( self.textSize.setValue(
pOptions.getInt("GuiBuildNovel", "textSize", self.mainConf.textSize) pOptions.getInt("GuiBuildNovel", "textSize", CONFIG.textSize)
) )
self.lineHeight = QDoubleSpinBox(self) self.lineHeight = QDoubleSpinBox(self)
@@ -518,13 +517,13 @@ class GuiBuildNovel(QDialog):
self.buttonBox.addWidget(self.btnSave) self.buttonBox.addWidget(self.btnSave)
self.buttonBox.addWidget(self.btnPrint) self.buttonBox.addWidget(self.btnPrint)
self.buttonBox.addWidget(self.btnClose) self.buttonBox.addWidget(self.btnClose)
self.buttonBox.setSpacing(self.mainConf.pxInt(4)) self.buttonBox.setSpacing(CONFIG.pxInt(4))
# Assemble GUI # Assemble GUI
# ============ # ============
# Splitter Position # Splitter Position
boxWidth = self.mainConf.pxInt(350) boxWidth = CONFIG.pxInt(350)
boxWidth = pOptions.getInt("GuiBuildNovel", "boxWidth", boxWidth) boxWidth = pOptions.getInt("GuiBuildNovel", "boxWidth", boxWidth)
docWidth = max(self.width() - boxWidth, 100) docWidth = max(self.width() - boxWidth, 100)
docWidth = pOptions.getInt("GuiBuildNovel", "docWidth", docWidth) docWidth = pOptions.getInt("GuiBuildNovel", "docWidth", docWidth)
@@ -547,22 +546,22 @@ class GuiBuildNovel(QDialog):
# Tool Box Scroll Area # Tool Box Scroll Area
self.toolsArea = QScrollArea() self.toolsArea = QScrollArea()
self.toolsArea.setMinimumWidth(self.mainConf.pxInt(250)) self.toolsArea.setMinimumWidth(CONFIG.pxInt(250))
self.toolsArea.setWidgetResizable(True) self.toolsArea.setWidgetResizable(True)
self.toolsArea.setWidget(self.toolsWidget) self.toolsArea.setWidget(self.toolsWidget)
if self.mainConf.hideVScroll: if CONFIG.hideVScroll:
self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
if self.mainConf.hideHScroll: if CONFIG.hideHScroll:
self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
else: else:
self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
# Tools and Buttons Layout # Tools and Buttons Layout
tSp = self.mainConf.pxInt(8) tSp = CONFIG.pxInt(8)
self.innerBox = QVBoxLayout() self.innerBox = QVBoxLayout()
self.innerBox.addWidget(self.toolsArea) self.innerBox.addWidget(self.toolsArea)
self.innerBox.addSpacing(tSp) self.innerBox.addSpacing(tSp)
@@ -891,14 +890,14 @@ class GuiBuildNovel(QDialog):
cleanName = makeFileNameSafe(self.theProject.data.name) cleanName = makeFileNameSafe(self.theProject.data.name)
fileName = "%s.%s" % (cleanName, fileExt) fileName = "%s.%s" % (cleanName, fileExt)
savePath = self.mainConf.lastPath() / fileName savePath = CONFIG.lastPath() / fileName
savePath, _ = QFileDialog.getSaveFileName( savePath, _ = QFileDialog.getSaveFileName(
self, self.tr("Save Document As"), str(savePath) self, self.tr("Save Document As"), str(savePath)
) )
if not savePath: if not savePath:
return False return False
self.mainConf.setLastPath(savePath) CONFIG.setLastPath(savePath)
# Build and Write # Build and Write
# =============== # ===============
@@ -1173,8 +1172,8 @@ class GuiBuildNovel(QDialog):
buildLang = self.buildLang.currentData() buildLang = self.buildLang.currentData()
hideScene = self.hideScene.isChecked() hideScene = self.hideScene.isChecked()
hideSection = self.hideSection.isChecked() hideSection = self.hideSection.isChecked()
winWidth = self.mainConf.rpxInt(self.width()) winWidth = CONFIG.rpxInt(self.width())
winHeight = self.mainConf.rpxInt(self.height()) winHeight = CONFIG.rpxInt(self.height())
justifyText = self.justifyText.isChecked() justifyText = self.justifyText.isChecked()
noStyling = self.noStyling.isChecked() noStyling = self.noStyling.isChecked()
textFont = self.textFont.text() textFont = self.textFont.text()
@@ -1192,8 +1191,8 @@ class GuiBuildNovel(QDialog):
rootFilter = self._generateRootFilter() rootFilter = self._generateRootFilter()
mainSplit = self.mainSplit.sizes() mainSplit = self.mainSplit.sizes()
boxWidth = self.mainConf.rpxInt(mainSplit[0]) boxWidth = CONFIG.rpxInt(mainSplit[0])
docWidth = self.mainConf.rpxInt(mainSplit[1]) docWidth = CONFIG.rpxInt(mainSplit[1])
self.theProject.setProjectLang(buildLang) self.theProject.setProjectLang(buildLang)
@@ -1243,7 +1242,6 @@ class GuiBuildNovelDocView(QTextBrowser):
logger.debug("Initialising GuiBuildNovelDocView ...") logger.debug("Initialising GuiBuildNovelDocView ...")
self.mainConf = novelwriter.CONFIG
self.theProject = theProject self.theProject = theProject
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
@@ -1252,7 +1250,7 @@ class GuiBuildNovelDocView(QTextBrowser):
self.setMinimumWidth(40*self.mainGui.mainTheme.textNWidth) self.setMinimumWidth(40*self.mainGui.mainTheme.textNWidth)
self.setOpenExternalLinks(False) self.setOpenExternalLinks(False)
self.document().setDocumentMargin(self.mainConf.getTextMargin()) self.document().setDocumentMargin(CONFIG.getTextMargin())
self.setPlaceholderText(self.tr( self.setPlaceholderText(self.tr(
"This area will show the content of the document to be " "This area will show the content of the document to be "
"exported or printed. Press the \"Build Preview\" button " "exported or printed. Press the \"Build Preview\" button "
@@ -1260,15 +1258,15 @@ class GuiBuildNovelDocView(QTextBrowser):
)) ))
theFont = QFont() theFont = QFont()
if self.mainConf.textFont is None: if CONFIG.textFont is None:
# If none is defined, set the default back to config # If none is defined, set the default back to config
self.mainConf.textFont = self.document().defaultFont().family() CONFIG.textFont = self.document().defaultFont().family()
theFont.setFamily(self.mainConf.textFont) theFont.setFamily(CONFIG.textFont)
theFont.setPointSize(self.mainConf.textSize) theFont.setPointSize(CONFIG.textSize)
self.setFont(theFont) self.setFont(theFont)
# Set the tab stops # Set the tab stops
self.setTabStopDistance(self.mainConf.getTabWidth()) self.setTabStopDistance(CONFIG.getTabWidth())
docPalette = self.palette() docPalette = self.palette()
docPalette.setColor(QPalette.Base, QColor(255, 255, 255)) docPalette.setColor(QPalette.Base, QColor(255, 255, 255))
+6 -7
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import random import random
import logging import logging
import novelwriter
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
@@ -33,6 +32,7 @@ from PyQt5.QtWidgets import (
QSpinBox QSpinBox
) )
from novelwriter import CONFIG
from novelwriter.common import readTextFile from novelwriter.common import readTextFile
from novelwriter.custom import QSwitch from novelwriter.custom import QSwitch
@@ -47,18 +47,17 @@ class GuiLipsum(QDialog):
logger.debug("Initialising GuiLipsum ...") logger.debug("Initialising GuiLipsum ...")
self.setObjectName("GuiLipsum") self.setObjectName("GuiLipsum")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
self.setWindowTitle(self.tr("Insert Placeholder Text")) self.setWindowTitle(self.tr("Insert Placeholder Text"))
self.innerBox = QHBoxLayout() self.innerBox = QHBoxLayout()
self.innerBox.setSpacing(self.mainConf.pxInt(16)) self.innerBox.setSpacing(CONFIG.pxInt(16))
# Icon # Icon
nPx = self.mainConf.pxInt(64) nPx = CONFIG.pxInt(64)
vSp = self.mainConf.pxInt(4) vSp = CONFIG.pxInt(4)
self.docIcon = QLabel() self.docIcon = QLabel()
self.docIcon.setPixmap(self.mainTheme.getPixmap("proj_document", (nPx, nPx))) self.docIcon.setPixmap(self.mainTheme.getPixmap("proj_document", (nPx, nPx)))
@@ -105,7 +104,7 @@ class GuiLipsum(QDialog):
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
self.outerBox.addLayout(self.innerBox) self.outerBox.addLayout(self.innerBox)
self.outerBox.addWidget(self.buttonBox) self.outerBox.addWidget(self.buttonBox)
self.outerBox.setSpacing(self.mainConf.pxInt(16)) self.outerBox.setSpacing(CONFIG.pxInt(16))
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
logger.debug("GuiLipsum initialisation complete") logger.debug("GuiLipsum initialisation complete")
@@ -119,7 +118,7 @@ class GuiLipsum(QDialog):
def _doInsert(self): def _doInsert(self):
"""Load the text and insert it in the open document. """Load the text and insert it in the open document.
""" """
lipsumFile = self.mainConf.assetPath("text") / "lipsum.txt" lipsumFile = CONFIG.assetPath("text") / "lipsum.txt"
lipsumText = readTextFile(lipsumFile).splitlines() lipsumText = readTextFile(lipsumFile).splitlines()
if self.randSwitch.isChecked(): if self.randSwitch.isChecked():
+16 -22
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import os import os
import logging import logging
import novelwriter
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
@@ -33,6 +32,7 @@ from PyQt5.QtWidgets import (
QPushButton, QRadioButton, QSpinBox, QVBoxLayout, QWizard, QWizardPage QPushButton, QRadioButton, QSpinBox, QVBoxLayout, QWizard, QWizardPage
) )
from novelwriter import CONFIG
from novelwriter.common import makeFileNameSafe from novelwriter.common import makeFileNameSafe
from novelwriter.custom import QSwitch from novelwriter.custom import QSwitch
@@ -53,12 +53,11 @@ class GuiProjectWizard(QWizard):
logger.debug("Initialising GuiProjectWizard ...") logger.debug("Initialising GuiProjectWizard ...")
self.setObjectName("GuiProjectWizard") self.setObjectName("GuiProjectWizard")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
self.sideImage = self.mainTheme.loadDecoration( self.sideImage = self.mainTheme.loadDecoration(
"wiz-back", None, self.mainConf.pxInt(370) "wiz-back", None, CONFIG.pxInt(370)
) )
self.setWizardStyle(QWizard.ModernStyle) self.setWizardStyle(QWizard.ModernStyle)
self.setPixmap(QWizard.WatermarkPixmap, self.sideImage) self.setPixmap(QWizard.WatermarkPixmap, self.sideImage)
@@ -89,7 +88,6 @@ class ProjWizardIntroPage(QWizardPage):
def __init__(self, theWizard): def __init__(self, theWizard):
super().__init__() super().__init__()
self.mainConf = novelwriter.CONFIG
self.theWizard = theWizard self.theWizard = theWizard
self.mainTheme = theWizard.mainTheme self.mainTheme = theWizard.mainTheme
@@ -109,9 +107,9 @@ class ProjWizardIntroPage(QWizardPage):
lblFont.setPointSizeF(0.6*self.mainTheme.fontPointSize) lblFont.setPointSizeF(0.6*self.mainTheme.fontPointSize)
self.imgCredit.setFont(lblFont) self.imgCredit.setFont(lblFont)
xW = self.mainConf.pxInt(300) xW = CONFIG.pxInt(300)
vS = self.mainConf.pxInt(12) vS = CONFIG.pxInt(12)
fS = self.mainConf.pxInt(4) fS = CONFIG.pxInt(4)
# The Page Form # The Page Form
self.projName = QLineEdit() self.projName = QLineEdit()
@@ -158,7 +156,6 @@ class ProjWizardFolderPage(QWizardPage):
def __init__(self, theWizard): def __init__(self, theWizard):
super().__init__() super().__init__()
self.mainConf = novelwriter.CONFIG
self.theWizard = theWizard self.theWizard = theWizard
self.mainTheme = theWizard.mainTheme self.mainTheme = theWizard.mainTheme
@@ -169,9 +166,9 @@ class ProjWizardFolderPage(QWizardPage):
)) ))
self.theText.setWordWrap(True) self.theText.setWordWrap(True)
xW = self.mainConf.pxInt(300) xW = CONFIG.pxInt(300)
vS = self.mainConf.pxInt(12) vS = CONFIG.pxInt(12)
fS = self.mainConf.pxInt(8) fS = CONFIG.pxInt(8)
self.projPath = QLineEdit("") self.projPath = QLineEdit("")
self.projPath.setFixedWidth(xW) self.projPath.setFixedWidth(xW)
@@ -234,7 +231,7 @@ class ProjWizardFolderPage(QWizardPage):
def _doBrowse(self): def _doBrowse(self):
"""Select a project folder. """Select a project folder.
""" """
lastPath = self.mainConf.lastPath() lastPath = CONFIG.lastPath()
projDir = QFileDialog.getExistingDirectory( projDir = QFileDialog.getExistingDirectory(
self, self.tr("Select Project Folder"), str(lastPath), options=QFileDialog.ShowDirsOnly self, self.tr("Select Project Folder"), str(lastPath), options=QFileDialog.ShowDirsOnly
) )
@@ -256,7 +253,6 @@ class ProjWizardPopulatePage(QWizardPage):
def __init__(self, theWizard): def __init__(self, theWizard):
super().__init__() super().__init__()
self.mainConf = novelwriter.CONFIG
self.theWizard = theWizard self.theWizard = theWizard
self.setTitle(self.tr("Populate Project")) self.setTitle(self.tr("Populate Project"))
@@ -267,8 +263,8 @@ class ProjWizardPopulatePage(QWizardPage):
)) ))
self.theText.setWordWrap(True) self.theText.setWordWrap(True)
vS = self.mainConf.pxInt(12) vS = CONFIG.pxInt(12)
fS = self.mainConf.pxInt(4) fS = CONFIG.pxInt(4)
self.popMinimal = QRadioButton(self.tr("Fill the project with a minimal set of items")) self.popMinimal = QRadioButton(self.tr("Fill the project with a minimal set of items"))
self.popSample = QRadioButton(self.tr("Fill the project with example files")) self.popSample = QRadioButton(self.tr("Fill the project with example files"))
@@ -312,7 +308,6 @@ class ProjWizardCustomPage(QWizardPage):
def __init__(self, theWizard): def __init__(self, theWizard):
super().__init__() super().__init__()
self.mainConf = novelwriter.CONFIG
self.theWizard = theWizard self.theWizard = theWizard
self.setTitle(self.tr("Custom Project Options")) self.setTitle(self.tr("Custom Project Options"))
@@ -323,9 +318,9 @@ class ProjWizardCustomPage(QWizardPage):
)) ))
self.theText.setWordWrap(True) self.theText.setWordWrap(True)
cM = self.mainConf.pxInt(12) cM = CONFIG.pxInt(12)
mH = self.mainConf.pxInt(26) mH = CONFIG.pxInt(26)
fS = self.mainConf.pxInt(4) fS = CONFIG.pxInt(4)
# Root Folders # Root Folders
self.addPlot = QSwitch() self.addPlot = QSwitch()
@@ -413,7 +408,6 @@ class ProjWizardFinalPage(QWizardPage):
def __init__(self, theWizard): def __init__(self, theWizard):
super().__init__() super().__init__()
self.mainConf = novelwriter.CONFIG
self.theWizard = theWizard self.theWizard = theWizard
self.setTitle(self.tr("Summary")) self.setTitle(self.tr("Summary"))
@@ -422,7 +416,7 @@ class ProjWizardFinalPage(QWizardPage):
# Assemble # Assemble
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
self.outerBox.setSpacing(self.mainConf.pxInt(12)) self.outerBox.setSpacing(CONFIG.pxInt(12))
self.outerBox.addWidget(self.theText) self.outerBox.addWidget(self.theText)
self.outerBox.addStretch(1) self.outerBox.addStretch(1)
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
@@ -470,7 +464,7 @@ class ProjWizardFinalPage(QWizardPage):
self.tr("You have selected the following:"), self.tr("You have selected the following:"),
"<br>&nbsp;&bull;&nbsp;".join(sumList), "<br>&nbsp;&bull;&nbsp;".join(sumList),
self.tr("Press '{0}' to create the new project.").format( self.tr("Press '{0}' to create the new project.").format(
self.tr("Done") if self.mainConf.osDarwin else self.tr("Finish") self.tr("Done") if CONFIG.osDarwin else self.tr("Finish")
) )
) )
) )
+18 -19
View File
@@ -25,7 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import json import json
import logging import logging
import novelwriter
from pathlib import Path from pathlib import Path
from datetime import datetime from datetime import datetime
@@ -37,6 +36,7 @@ from PyQt5.QtWidgets import (
QLabel, QGroupBox, QMenu, QAction, QFileDialog, QSpinBox, QHBoxLayout QLabel, QGroupBox, QMenu, QAction, QFileDialog, QSpinBox, QHBoxLayout
) )
from novelwriter import CONFIG
from novelwriter.enum import nwAlert from novelwriter.enum import nwAlert
from novelwriter.error import formatException from novelwriter.error import formatException
from novelwriter.common import formatTime, checkInt, checkIntTuple, minmax from novelwriter.common import formatTime, checkInt, checkIntTuple, minmax
@@ -63,7 +63,6 @@ class GuiWritingStats(QDialog):
logger.debug("Initialising GuiWritingStats ...") logger.debug("Initialising GuiWritingStats ...")
self.setObjectName("GuiWritingStats") self.setObjectName("GuiWritingStats")
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme self.mainTheme = mainGui.mainTheme
self.theProject = mainGui.theProject self.theProject = mainGui.theProject
@@ -76,24 +75,24 @@ class GuiWritingStats(QDialog):
pOptions = self.theProject.options pOptions = self.theProject.options
self.setWindowTitle(self.tr("Writing Statistics")) self.setWindowTitle(self.tr("Writing Statistics"))
self.setMinimumWidth(self.mainConf.pxInt(420)) self.setMinimumWidth(CONFIG.pxInt(420))
self.setMinimumHeight(self.mainConf.pxInt(400)) self.setMinimumHeight(CONFIG.pxInt(400))
self.resize( self.resize(
self.mainConf.pxInt(pOptions.getInt("GuiWritingStats", "winWidth", 550)), CONFIG.pxInt(pOptions.getInt("GuiWritingStats", "winWidth", 550)),
self.mainConf.pxInt(pOptions.getInt("GuiWritingStats", "winHeight", 500)) CONFIG.pxInt(pOptions.getInt("GuiWritingStats", "winHeight", 500))
) )
# List Box # List Box
wCol0 = self.mainConf.pxInt( wCol0 = CONFIG.pxInt(
pOptions.getInt("GuiWritingStats", "widthCol0", 180) pOptions.getInt("GuiWritingStats", "widthCol0", 180)
) )
wCol1 = self.mainConf.pxInt( wCol1 = CONFIG.pxInt(
pOptions.getInt("GuiWritingStats", "widthCol1", 80) pOptions.getInt("GuiWritingStats", "widthCol1", 80)
) )
wCol2 = self.mainConf.pxInt( wCol2 = CONFIG.pxInt(
pOptions.getInt("GuiWritingStats", "widthCol2", 80) pOptions.getInt("GuiWritingStats", "widthCol2", 80)
) )
wCol3 = self.mainConf.pxInt( wCol3 = CONFIG.pxInt(
pOptions.getInt("GuiWritingStats", "widthCol3", 80) pOptions.getInt("GuiWritingStats", "widthCol3", 80)
) )
@@ -127,7 +126,7 @@ class GuiWritingStats(QDialog):
# Word Bar # Word Bar
self.barHeight = int(round(0.5*self.mainTheme.fontPixelSize)) self.barHeight = int(round(0.5*self.mainTheme.fontPixelSize))
self.barWidth = self.mainConf.pxInt(200) self.barWidth = CONFIG.pxInt(200)
self.barImage = QPixmap(self.barHeight, self.barHeight) self.barImage = QPixmap(self.barHeight, self.barHeight)
self.barImage.fill(self.palette().highlight().color()) self.barImage.fill(self.palette().highlight().color())
@@ -309,12 +308,12 @@ class GuiWritingStats(QDialog):
""" """
self.logData = [] self.logData = []
winWidth = self.mainConf.rpxInt(self.width()) winWidth = CONFIG.rpxInt(self.width())
winHeight = self.mainConf.rpxInt(self.height()) winHeight = CONFIG.rpxInt(self.height())
widthCol0 = self.mainConf.rpxInt(self.listBox.columnWidth(0)) widthCol0 = CONFIG.rpxInt(self.listBox.columnWidth(0))
widthCol1 = self.mainConf.rpxInt(self.listBox.columnWidth(1)) widthCol1 = CONFIG.rpxInt(self.listBox.columnWidth(1))
widthCol2 = self.mainConf.rpxInt(self.listBox.columnWidth(2)) widthCol2 = CONFIG.rpxInt(self.listBox.columnWidth(2))
widthCol3 = self.mainConf.rpxInt(self.listBox.columnWidth(3)) widthCol3 = CONFIG.rpxInt(self.listBox.columnWidth(3))
sortCol = self.listBox.sortColumn() sortCol = self.listBox.sortColumn()
sortOrder = self.listBox.header().sortIndicatorOrder() sortOrder = self.listBox.header().sortIndicatorOrder()
incNovel = self.incNovel.isChecked() incNovel = self.incNovel.isChecked()
@@ -362,14 +361,14 @@ class GuiWritingStats(QDialog):
return False return False
# Generate the file name # Generate the file name
savePath = self.mainConf.lastPath() / f"sessionStats.{fileExt}" savePath = CONFIG.lastPath() / f"sessionStats.{fileExt}"
savePath, _ = QFileDialog.getSaveFileName( savePath, _ = QFileDialog.getSaveFileName(
self, self.tr("Save Data As"), str(savePath), "%s (*.%s)" % (textFmt, fileExt) self, self.tr("Save Data As"), str(savePath), "%s (*.%s)" % (textFmt, fileExt)
) )
if not savePath: if not savePath:
return False return False
self.mainConf.setLastPath(savePath) CONFIG.setLastPath(savePath)
# Do the actual writing # Do the actual writing
wSuccess = False wSuccess = False
+25 -24
View File
@@ -22,10 +22,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import sys import sys
import pytest import pytest
import logging import logging
import novelwriter
from mock import MockGuiMain from mock import MockGuiMain
from novelwriter import CONFIG, main, logger
@pytest.mark.base @pytest.mark.base
def testBaseInit_Launch(caplog, monkeypatch, fncPath): def testBaseInit_Launch(caplog, monkeypatch, fncPath):
@@ -34,34 +35,34 @@ def testBaseInit_Launch(caplog, monkeypatch, fncPath):
monkeypatch.setattr("novelwriter.guimain.GuiMain", MockGuiMain) monkeypatch.setattr("novelwriter.guimain.GuiMain", MockGuiMain)
# TestMode Launch # TestMode Launch
nwGUI = novelwriter.main(["--testmode", f"--config={fncPath}", f"--data={fncPath}"]) nwGUI = main(["--testmode", f"--config={fncPath}", f"--data={fncPath}"])
assert isinstance(nwGUI, MockGuiMain) assert isinstance(nwGUI, MockGuiMain)
# Darwin Launch # Darwin Launch
caplog.clear() caplog.clear()
osDarwin = novelwriter.CONFIG.osDarwin osDarwin = CONFIG.osDarwin
novelwriter.CONFIG.osDarwin = True CONFIG.osDarwin = True
with monkeypatch.context() as mp: with monkeypatch.context() as mp:
mp.setitem(sys.modules, "Foundation", None) mp.setitem(sys.modules, "Foundation", None)
nwGUI = novelwriter.main(["--testmode", f"--config={fncPath}", f"--data={fncPath}"]) nwGUI = main(["--testmode", f"--config={fncPath}", f"--data={fncPath}"])
assert isinstance(nwGUI, MockGuiMain) assert isinstance(nwGUI, MockGuiMain)
assert "Failed" in caplog.text assert "Failed" in caplog.text
novelwriter.CONFIG.osDarwin = osDarwin CONFIG.osDarwin = osDarwin
# Windows Launch # Windows Launch
caplog.clear() caplog.clear()
osWindows = novelwriter.CONFIG.osWindows osWindows = CONFIG.osWindows
novelwriter.CONFIG.osWindows = True CONFIG.osWindows = True
with monkeypatch.context() as mp: with monkeypatch.context() as mp:
mp.setitem(sys.modules, "ctypes", None) mp.setitem(sys.modules, "ctypes", None)
nwGUI = novelwriter.main(["--testmode", f"--config={fncPath}", f"--data={fncPath}"]) nwGUI = main(["--testmode", f"--config={fncPath}", f"--data={fncPath}"])
assert isinstance(nwGUI, MockGuiMain) assert isinstance(nwGUI, MockGuiMain)
if not sys.platform.startswith("darwin"): if not sys.platform.startswith("darwin"):
# For some reason, the test doesn't work on macOS # For some reason, the test doesn't work on macOS
assert "Failed" in caplog.text assert "Failed" in caplog.text
novelwriter.CONFIG.osWindows = osWindows CONFIG.osWindows = osWindows
# Normal Launch # Normal Launch
monkeypatch.setattr("PyQt5.QtWidgets.QApplication.__init__", lambda *a: None) monkeypatch.setattr("PyQt5.QtWidgets.QApplication.__init__", lambda *a: None)
@@ -71,7 +72,7 @@ def testBaseInit_Launch(caplog, monkeypatch, fncPath):
monkeypatch.setattr("PyQt5.QtWidgets.QApplication.setOrganizationDomain", lambda *a: None) monkeypatch.setattr("PyQt5.QtWidgets.QApplication.setOrganizationDomain", lambda *a: None)
monkeypatch.setattr("PyQt5.QtWidgets.QApplication.exec_", lambda *a: 0) monkeypatch.setattr("PyQt5.QtWidgets.QApplication.exec_", lambda *a: 0)
with pytest.raises(SystemExit) as ex: with pytest.raises(SystemExit) as ex:
novelwriter.main([f"--config={fncPath}", f"--data={fncPath}"]) main([f"--config={fncPath}", f"--data={fncPath}"])
assert ex.value.code == 0 assert ex.value.code == 0
# END Test testBaseInit_Launch # END Test testBaseInit_Launch
@@ -87,40 +88,40 @@ def testBaseInit_Options(monkeypatch, fncPath):
]) ])
# Defaults w/None Args # Defaults w/None Args
nwGUI = novelwriter.main() nwGUI = main()
assert novelwriter.logger.getEffectiveLevel() == logging.WARNING assert logger.getEffectiveLevel() == logging.WARNING
assert nwGUI.closeMain() == "closeMain" assert nwGUI.closeMain() == "closeMain"
# Defaults # Defaults
nwGUI = novelwriter.main( nwGUI = main(
["--testmode", f"--config={fncPath}", f"--data={fncPath}", "--style=Fusion"] ["--testmode", f"--config={fncPath}", f"--data={fncPath}", "--style=Fusion"]
) )
assert novelwriter.logger.getEffectiveLevel() == logging.WARNING assert logger.getEffectiveLevel() == logging.WARNING
assert nwGUI.closeMain() == "closeMain" assert nwGUI.closeMain() == "closeMain"
# Log Levels # Log Levels
nwGUI = novelwriter.main( nwGUI = main(
["--testmode", "--info", f"--config={fncPath}", f"--data={fncPath}"] ["--testmode", "--info", f"--config={fncPath}", f"--data={fncPath}"]
) )
assert novelwriter.logger.getEffectiveLevel() == logging.INFO assert logger.getEffectiveLevel() == logging.INFO
assert nwGUI.closeMain() == "closeMain" assert nwGUI.closeMain() == "closeMain"
nwGUI = novelwriter.main( nwGUI = main(
["--testmode", "--debug", f"--config={fncPath}", f"--data={fncPath}"] ["--testmode", "--debug", f"--config={fncPath}", f"--data={fncPath}"]
) )
assert novelwriter.logger.getEffectiveLevel() == logging.DEBUG assert logger.getEffectiveLevel() == logging.DEBUG
assert nwGUI.closeMain() == "closeMain" assert nwGUI.closeMain() == "closeMain"
# Help and Version # Help and Version
with pytest.raises(SystemExit) as ex: with pytest.raises(SystemExit) as ex:
nwGUI = novelwriter.main( nwGUI = main(
["--testmode", "--help", f"--config={fncPath}", f"--data={fncPath}"] ["--testmode", "--help", f"--config={fncPath}", f"--data={fncPath}"]
) )
assert nwGUI.closeMain() == "closeMain" assert nwGUI.closeMain() == "closeMain"
assert ex.value.code == 0 assert ex.value.code == 0
with pytest.raises(SystemExit) as ex: with pytest.raises(SystemExit) as ex:
nwGUI = novelwriter.main( nwGUI = main(
["--testmode", "--version", f"--config={fncPath}", f"--data={fncPath}"] ["--testmode", "--version", f"--config={fncPath}", f"--data={fncPath}"]
) )
assert nwGUI.closeMain() == "closeMain" assert nwGUI.closeMain() == "closeMain"
@@ -128,14 +129,14 @@ def testBaseInit_Options(monkeypatch, fncPath):
# Invalid options # Invalid options
with pytest.raises(SystemExit) as ex: with pytest.raises(SystemExit) as ex:
nwGUI = novelwriter.main( nwGUI = main(
["--testmode", "--invalid", f"--config={fncPath}", f"--data={fncPath}"] ["--testmode", "--invalid", f"--config={fncPath}", f"--data={fncPath}"]
) )
assert nwGUI.closeMain() == "closeMain" assert nwGUI.closeMain() == "closeMain"
assert ex.value.code == 2 assert ex.value.code == 2
# Project Path # Project Path
nwGUI = novelwriter.main( nwGUI = main(
["--testmode", f"--config={fncPath}", f"--data={fncPath}", "sample/"] ["--testmode", f"--config={fncPath}", f"--data={fncPath}", "sample/"]
) )
assert nwGUI.closeMain() == "closeMain" assert nwGUI.closeMain() == "closeMain"
@@ -159,7 +160,7 @@ def testBaseInit_Imports(caplog, monkeypatch, fncPath):
monkeypatch.setattr("novelwriter.CONFIG.verPyQtValue", 0x050000) monkeypatch.setattr("novelwriter.CONFIG.verPyQtValue", 0x050000)
with pytest.raises(SystemExit) as ex: with pytest.raises(SystemExit) as ex:
_ = novelwriter.main( _ = main(
["--testmode", f"--config={fncPath}", f"--data={fncPath}"] ["--testmode", f"--config={fncPath}", f"--data={fncPath}"]
) )
+2 -2
View File
@@ -40,8 +40,8 @@ class MockProject:
@pytest.fixture(scope="function", autouse=True) @pytest.fixture(scope="function", autouse=True)
def mockVersion(monkeypatch): def mockVersion(monkeypatch):
monkeypatch.setattr("novelwriter.__version__", "2.0-rc1") monkeypatch.setattr("novelwriter.core.projectxml.__version__", "2.0-rc1")
monkeypatch.setattr("novelwriter.__hexversion__", "0x020000c1") monkeypatch.setattr("novelwriter.core.projectxml.__hexversion__", "0x020000c1")
return return