Move theme and project instances to new shared data class
This commit is contained in:
@@ -35,7 +35,7 @@ from PyQt5.QtWidgets import (
|
||||
QTextBrowser, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.common import readTextFile
|
||||
from novelwriter.constants import nwConst
|
||||
|
||||
@@ -60,7 +60,7 @@ class GuiAbout(QDialog):
|
||||
|
||||
nPx = CONFIG.pxInt(96)
|
||||
self.nwIcon = QLabel()
|
||||
self.nwIcon.setPixmap(CONFIG.theme.getPixmap("novelwriter", (nPx, nPx)))
|
||||
self.nwIcon.setPixmap(SHARED.theme.getPixmap("novelwriter", (nPx, nPx)))
|
||||
self.lblName = QLabel("<b>novelWriter</b>")
|
||||
self.lblVers = QLabel(f"v{novelwriter.__version__}")
|
||||
self.lblDate = QLabel(datetime.strptime(novelwriter.__date__, "%Y-%m-%d").strftime("%x"))
|
||||
@@ -228,12 +228,12 @@ class GuiAbout(QDialog):
|
||||
" color: rgb({kColR},{kColG},{kColB});"
|
||||
"}}\n"
|
||||
).format(
|
||||
hColR=CONFIG.theme.colHead[0],
|
||||
hColG=CONFIG.theme.colHead[1],
|
||||
hColB=CONFIG.theme.colHead[2],
|
||||
kColR=CONFIG.theme.colKey[0],
|
||||
kColG=CONFIG.theme.colKey[1],
|
||||
kColB=CONFIG.theme.colKey[2],
|
||||
hColR=SHARED.theme.colHead[0],
|
||||
hColG=SHARED.theme.colHead[1],
|
||||
hColB=SHARED.theme.colHead[2],
|
||||
kColR=SHARED.theme.colKey[0],
|
||||
kColG=SHARED.theme.colKey[1],
|
||||
kColB=SHARED.theme.colKey[2],
|
||||
)
|
||||
self.pageAbout.document().setDefaultStyleSheet(styleSheet)
|
||||
self.pageNotes.document().setDefaultStyleSheet(styleSheet)
|
||||
|
||||
@@ -29,10 +29,10 @@ import logging
|
||||
from PyQt5.QtCore import Qt, QSize
|
||||
from PyQt5.QtWidgets import (
|
||||
QAbstractItemView, QDialog, QDialogButtonBox, QGridLayout, QLabel,
|
||||
QListWidget, QListWidgetItem, QVBoxLayout,
|
||||
QListWidget, QListWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
from novelwriter.extensions.configlayout import NHelpLabel
|
||||
|
||||
@@ -43,24 +43,21 @@ class GuiDocMerge(QDialog):
|
||||
|
||||
D_HANDLE = Qt.ItemDataRole.UserRole
|
||||
|
||||
def __init__(self, mainGui, sHandle, itemList):
|
||||
super().__init__(parent=mainGui)
|
||||
def __init__(self, parent: QWidget, sHandle: str, itemList: list[str]) -> None:
|
||||
super().__init__(parent=parent)
|
||||
|
||||
logger.debug("Create: GuiDocMerge")
|
||||
self.setObjectName("GuiDocMerge")
|
||||
|
||||
self.mainGui = mainGui
|
||||
self.setWindowTitle(self.tr("Merge Documents"))
|
||||
|
||||
self._data = {}
|
||||
|
||||
self.setWindowTitle(self.tr("Merge Documents"))
|
||||
|
||||
self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Documents to Merge")))
|
||||
self.helpLabel = NHelpLabel(self.tr(
|
||||
"Drag and drop items to change the order, or uncheck to exclude."
|
||||
), CONFIG.theme.helpText)
|
||||
), SHARED.theme.helpText)
|
||||
|
||||
iPx = CONFIG.theme.baseIconSize
|
||||
iPx = SHARED.theme.baseIconSize
|
||||
hSp = CONFIG.pxInt(12)
|
||||
vSp = CONFIG.pxInt(8)
|
||||
bSp = CONFIG.pxInt(12)
|
||||
@@ -155,11 +152,11 @@ class GuiDocMerge(QDialog):
|
||||
|
||||
self.listBox.clear()
|
||||
for tHandle in itemList:
|
||||
nwItem = self.mainGui.project.tree[tHandle]
|
||||
nwItem = SHARED.project.tree[tHandle]
|
||||
if nwItem is None or not nwItem.isFileType():
|
||||
continue
|
||||
|
||||
itemIcon = CONFIG.theme.getItemIcon(
|
||||
itemIcon = SHARED.theme.getItemIcon(
|
||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, nwItem.mainHeading
|
||||
)
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ from PyQt5.QtWidgets import (
|
||||
QListWidgetItem, QDialogButtonBox, QLabel, QGridLayout
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
from novelwriter.extensions.configlayout import NHelpLabel
|
||||
|
||||
@@ -45,14 +45,12 @@ class GuiDocSplit(QDialog):
|
||||
LEVEL_ROLE = Qt.ItemDataRole.UserRole + 1
|
||||
LABEL_ROLE = Qt.ItemDataRole.UserRole + 2
|
||||
|
||||
def __init__(self, mainGui, sHandle):
|
||||
super().__init__(parent=mainGui)
|
||||
def __init__(self, parent, sHandle):
|
||||
super().__init__(parent=parent)
|
||||
|
||||
logger.debug("Create: GuiDocSplit")
|
||||
self.setObjectName("GuiDocSplit")
|
||||
|
||||
self.mainGui = mainGui
|
||||
|
||||
self._data = {}
|
||||
self._text = []
|
||||
|
||||
@@ -61,16 +59,16 @@ class GuiDocSplit(QDialog):
|
||||
self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Document Headers")))
|
||||
self.helpLabel = NHelpLabel(
|
||||
self.tr("Select the maximum level to split into files."),
|
||||
CONFIG.theme.helpText
|
||||
SHARED.theme.helpText
|
||||
)
|
||||
|
||||
# Values
|
||||
iPx = CONFIG.theme.baseIconSize
|
||||
iPx = SHARED.theme.baseIconSize
|
||||
hSp = CONFIG.pxInt(12)
|
||||
vSp = CONFIG.pxInt(8)
|
||||
bSp = CONFIG.pxInt(12)
|
||||
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions = SHARED.project.options
|
||||
spLevel = pOptions.getInt("GuiDocSplit", "spLevel", 3)
|
||||
intoFolder = pOptions.getBool("GuiDocSplit", "intoFolder", True)
|
||||
docHierarchy = pOptions.getBool("GuiDocSplit", "docHierarchy", True)
|
||||
@@ -169,7 +167,7 @@ class GuiDocSplit(QDialog):
|
||||
self._data["docHierarchy"] = docHierarchy
|
||||
self._data["moveToTrash"] = moveToTrash
|
||||
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions = SHARED.project.options
|
||||
pOptions.setValue("GuiDocSplit", "spLevel", spLevel)
|
||||
pOptions.setValue("GuiDocSplit", "intoFolder", intoFolder)
|
||||
pOptions.setValue("GuiDocSplit", "docHierarchy", docHierarchy)
|
||||
@@ -199,13 +197,13 @@ class GuiDocSplit(QDialog):
|
||||
|
||||
self.listBox.clear()
|
||||
|
||||
nwItem = self.mainGui.project.tree[sHandle]
|
||||
nwItem = SHARED.project.tree[sHandle]
|
||||
if nwItem is None or not nwItem.isFileType():
|
||||
return
|
||||
|
||||
spLevel = self.splitLevel.currentData()
|
||||
if not self._text:
|
||||
inDoc = self.mainGui.project.storage.getDocument(sHandle)
|
||||
inDoc = SHARED.project.storage.getDocument(sHandle)
|
||||
self._text = (inDoc.readDocument() or "").splitlines()
|
||||
|
||||
for lineNo, aLine in enumerate(self._text):
|
||||
|
||||
@@ -32,7 +32,7 @@ from PyQt5.QtWidgets import (
|
||||
QLineEdit, QFileDialog, QFontDialog, QDoubleSpinBox
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
from novelwriter.extensions.pageddialog import NPagedDialog
|
||||
@@ -163,7 +163,7 @@ class GuiPreferencesGeneral(QWidget):
|
||||
|
||||
# The Form
|
||||
self.mainForm = NConfigLayout()
|
||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
||||
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||
self.setLayout(self.mainForm)
|
||||
|
||||
# Look and Feel
|
||||
@@ -190,7 +190,7 @@ class GuiPreferencesGeneral(QWidget):
|
||||
# Select Theme
|
||||
self.guiTheme = QComboBox()
|
||||
self.guiTheme.setMinimumWidth(minWidth)
|
||||
self.theThemes = CONFIG.theme.listThemes()
|
||||
self.theThemes = SHARED.theme.listThemes()
|
||||
for themeDir, themeName in self.theThemes:
|
||||
self.guiTheme.addItem(themeName, themeDir)
|
||||
themeIdx = self.guiTheme.findData(CONFIG.guiTheme)
|
||||
@@ -206,7 +206,7 @@ class GuiPreferencesGeneral(QWidget):
|
||||
# Editor Theme
|
||||
self.guiSyntax = QComboBox()
|
||||
self.guiSyntax.setMinimumWidth(CONFIG.pxInt(200))
|
||||
self.theSyntaxes = CONFIG.theme.listSyntax()
|
||||
self.theSyntaxes = SHARED.theme.listSyntax()
|
||||
for syntaxFile, syntaxName in self.theSyntaxes:
|
||||
self.guiSyntax.addItem(syntaxName, syntaxFile)
|
||||
syntaxIdx = self.guiSyntax.findData(CONFIG.guiSyntax)
|
||||
@@ -225,7 +225,7 @@ class GuiPreferencesGeneral(QWidget):
|
||||
self.guiFont.setFixedWidth(CONFIG.pxInt(162))
|
||||
self.guiFont.setText(CONFIG.guiFont)
|
||||
self.fontButton = QPushButton("...")
|
||||
self.fontButton.setMaximumWidth(int(2.5*CONFIG.theme.getTextWidth("...")))
|
||||
self.fontButton.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
|
||||
self.fontButton.clicked.connect(self._selectFont)
|
||||
self.mainForm.addRow(
|
||||
self.tr("Font family"),
|
||||
@@ -341,7 +341,7 @@ class GuiPreferencesProjects(QWidget):
|
||||
|
||||
# The Form
|
||||
self.mainForm = NConfigLayout()
|
||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
||||
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||
self.setLayout(self.mainForm)
|
||||
|
||||
# Automatic Save
|
||||
@@ -493,7 +493,7 @@ class GuiPreferencesDocuments(QWidget):
|
||||
|
||||
# The Form
|
||||
self.mainForm = NConfigLayout()
|
||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
||||
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||
self.setLayout(self.mainForm)
|
||||
|
||||
# Text Style
|
||||
@@ -506,7 +506,7 @@ class GuiPreferencesDocuments(QWidget):
|
||||
self.textFont.setFixedWidth(CONFIG.pxInt(162))
|
||||
self.textFont.setText(CONFIG.textFont)
|
||||
self.fontButton = QPushButton("...")
|
||||
self.fontButton.setMaximumWidth(int(2.5*CONFIG.theme.getTextWidth("...")))
|
||||
self.fontButton.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
|
||||
self.fontButton.clicked.connect(self._selectFont)
|
||||
self.mainForm.addRow(
|
||||
self.tr("Font family"),
|
||||
@@ -649,7 +649,7 @@ class GuiPreferencesEditor(QWidget):
|
||||
|
||||
# The Form
|
||||
self.mainForm = NConfigLayout()
|
||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
||||
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||
self.setLayout(self.mainForm)
|
||||
|
||||
mW = CONFIG.pxInt(250)
|
||||
@@ -819,7 +819,7 @@ class GuiPreferencesSyntax(QWidget):
|
||||
|
||||
# The Form
|
||||
self.mainForm = NConfigLayout()
|
||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
||||
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||
self.setLayout(self.mainForm)
|
||||
|
||||
# Quotes & Dialogue
|
||||
@@ -921,7 +921,7 @@ class GuiPreferencesAutomation(QWidget):
|
||||
|
||||
# The Form
|
||||
self.mainForm = NConfigLayout()
|
||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
||||
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||
self.setLayout(self.mainForm)
|
||||
|
||||
# Automatic Features
|
||||
@@ -1072,7 +1072,7 @@ class GuiPreferencesQuotes(QWidget):
|
||||
|
||||
# The Form
|
||||
self.mainForm = NConfigLayout()
|
||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
||||
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||
self.setLayout(self.mainForm)
|
||||
|
||||
# Quotation Style
|
||||
@@ -1080,7 +1080,7 @@ class GuiPreferencesQuotes(QWidget):
|
||||
self.mainForm.addGroupLabel(self.tr("Quotation Style"))
|
||||
|
||||
qWidth = CONFIG.pxInt(40)
|
||||
bWidth = int(2.5*CONFIG.theme.getTextWidth("..."))
|
||||
bWidth = int(2.5*SHARED.theme.getTextWidth("..."))
|
||||
self.quoteSym = {}
|
||||
|
||||
# Single Quote Style
|
||||
|
||||
@@ -33,7 +33,7 @@ from PyQt5.QtWidgets import (
|
||||
QLineEdit, QSpinBox, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.common import formatTime, numberToRoman
|
||||
from novelwriter.constants import nwUnicode
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
@@ -45,19 +45,17 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class GuiProjectDetails(NPagedDialog):
|
||||
|
||||
def __init__(self, mainGui):
|
||||
super().__init__(parent=mainGui)
|
||||
def __init__(self, parent):
|
||||
super().__init__(parent=parent)
|
||||
|
||||
logger.debug("Create: GuiProjectDetails")
|
||||
self.setObjectName("GuiProjectDetails")
|
||||
|
||||
self.mainGui = mainGui
|
||||
|
||||
self.setWindowTitle(self.tr("Project Details"))
|
||||
|
||||
wW = CONFIG.pxInt(600)
|
||||
wH = CONFIG.pxInt(400)
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions = SHARED.project.options
|
||||
|
||||
self.setMinimumWidth(wW)
|
||||
self.setMinimumHeight(wH)
|
||||
@@ -66,8 +64,8 @@ class GuiProjectDetails(NPagedDialog):
|
||||
CONFIG.pxInt(pOptions.getInt("GuiProjectDetails", "winHeight", wH))
|
||||
)
|
||||
|
||||
self.tabMain = GuiProjectDetailsMain(self.mainGui)
|
||||
self.tabContents = GuiProjectDetailsContents(self.mainGui)
|
||||
self.tabMain = GuiProjectDetailsMain(self)
|
||||
self.tabContents = GuiProjectDetailsContents(self)
|
||||
|
||||
self.addTab(self.tabMain, self.tr("Overview"))
|
||||
self.addTab(self.tabContents, self.tr("Contents"))
|
||||
@@ -124,7 +122,7 @@ class GuiProjectDetails(NPagedDialog):
|
||||
countFrom = self.tabContents.poValue.value()
|
||||
clearDouble = self.tabContents.dblValue.isChecked()
|
||||
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions = SHARED.project.options
|
||||
pOptions.setValue("GuiProjectDetails", "winWidth", winWidth)
|
||||
pOptions.setValue("GuiProjectDetails", "winHeight", winHeight)
|
||||
pOptions.setValue("GuiProjectDetails", "widthCol0", widthCol0)
|
||||
@@ -143,13 +141,11 @@ class GuiProjectDetails(NPagedDialog):
|
||||
|
||||
class GuiProjectDetailsMain(QWidget):
|
||||
|
||||
def __init__(self, mainGui):
|
||||
super().__init__(parent=mainGui)
|
||||
def __init__(self, parent):
|
||||
super().__init__(parent=parent)
|
||||
|
||||
self.mainGui = mainGui
|
||||
|
||||
fPx = CONFIG.theme.fontPixelSize
|
||||
fPt = CONFIG.theme.fontPointSize
|
||||
fPx = SHARED.theme.fontPixelSize
|
||||
fPt = SHARED.theme.fontPointSize
|
||||
vPx = CONFIG.pxInt(4)
|
||||
hPx = CONFIG.pxInt(12)
|
||||
|
||||
@@ -244,7 +240,7 @@ class GuiProjectDetailsMain(QWidget):
|
||||
def updateValues(self):
|
||||
"""Set all the values.
|
||||
"""
|
||||
project = self.mainGui.project
|
||||
project = SHARED.project
|
||||
pIndex = project.index
|
||||
hCounts = pIndex.getNovelTitleCounts()
|
||||
nwCount = pIndex.getNovelWordCount()
|
||||
@@ -275,26 +271,24 @@ class GuiProjectDetailsContents(QWidget):
|
||||
C_PAGE = 3
|
||||
C_PROG = 4
|
||||
|
||||
def __init__(self, mainGui):
|
||||
super().__init__(parent=mainGui)
|
||||
|
||||
self.mainGui = mainGui
|
||||
def __init__(self, parent):
|
||||
super().__init__(parent=parent)
|
||||
|
||||
# Internal
|
||||
self._theToC = []
|
||||
self._currentRoot = None
|
||||
|
||||
iPx = CONFIG.theme.baseIconSize
|
||||
iPx = SHARED.theme.baseIconSize
|
||||
hPx = CONFIG.pxInt(12)
|
||||
vPx = CONFIG.pxInt(4)
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions = SHARED.project.options
|
||||
|
||||
# Header
|
||||
# ======
|
||||
|
||||
self.tocLabel = QLabel("<b>%s</b>" % self.tr("Table of Contents"))
|
||||
|
||||
self.novelValue = NovelSelector(self, self.mainGui)
|
||||
self.novelValue = NovelSelector(self)
|
||||
self.novelValue.setMinimumWidth(CONFIG.pxInt(200))
|
||||
self.novelValue.novelSelectionChanged.connect(self._novelValueChanged)
|
||||
|
||||
@@ -320,10 +314,11 @@ class GuiProjectDetailsContents(QWidget):
|
||||
])
|
||||
|
||||
treeHeadItem = self.tocTree.headerItem()
|
||||
treeHeadItem.setTextAlignment(self.C_WORDS, Qt.AlignRight)
|
||||
treeHeadItem.setTextAlignment(self.C_PAGES, Qt.AlignRight)
|
||||
treeHeadItem.setTextAlignment(self.C_PAGE, Qt.AlignRight)
|
||||
treeHeadItem.setTextAlignment(self.C_PROG, Qt.AlignRight)
|
||||
if treeHeadItem:
|
||||
treeHeadItem.setTextAlignment(self.C_WORDS, Qt.AlignRight)
|
||||
treeHeadItem.setTextAlignment(self.C_PAGES, Qt.AlignRight)
|
||||
treeHeadItem.setTextAlignment(self.C_PAGE, Qt.AlignRight)
|
||||
treeHeadItem.setTextAlignment(self.C_PROG, Qt.AlignRight)
|
||||
|
||||
treeHeader = self.tocTree.header()
|
||||
treeHeader.setStretchLastSection(True)
|
||||
@@ -347,7 +342,7 @@ class GuiProjectDetailsContents(QWidget):
|
||||
|
||||
wordsPerPage = pOptions.getInt("GuiProjectDetails", "wordsPerPage", 350)
|
||||
countFrom = pOptions.getInt("GuiProjectDetails", "countFrom", 1)
|
||||
clearDouble = pOptions.getInt("GuiProjectDetails", "clearDouble", True)
|
||||
clearDouble = pOptions.getBool("GuiProjectDetails", "clearDouble", True)
|
||||
|
||||
wordsHelp = (
|
||||
self.tr("Typical word count for a 5 by 8 inch book page with 11 pt font is 350.")
|
||||
@@ -443,7 +438,7 @@ class GuiProjectDetailsContents(QWidget):
|
||||
"""Extract the information from the project index.
|
||||
"""
|
||||
logger.debug("Populating ToC from handle '%s'", rootHandle)
|
||||
self._theToC = self.mainGui.project.index.getTableOfContents(rootHandle, 2)
|
||||
self._theToC = SHARED.project.index.getTableOfContents(rootHandle, 2)
|
||||
self._theToC.append(("", 0, self.tr("END"), 0))
|
||||
return
|
||||
|
||||
@@ -496,7 +491,7 @@ class GuiProjectDetailsContents(QWidget):
|
||||
progPage = f"{cPage:n}"
|
||||
progText = f"{pgProg:.1f}{nwUnicode.U_THSP}%"
|
||||
|
||||
hDec = CONFIG.theme.getHeaderDecoration(tLevel)
|
||||
hDec = SHARED.theme.getHeaderDecoration(tLevel)
|
||||
if tTitle.strip() == "":
|
||||
tTitle = self.tr("Untitled")
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ from PyQt5.QtWidgets import (
|
||||
QFileDialog, QLineEdit
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.common import formatInt
|
||||
from novelwriter.constants import nwFiles
|
||||
|
||||
@@ -67,7 +67,7 @@ class GuiProjectLoad(QDialog):
|
||||
|
||||
sPx = CONFIG.pxInt(16)
|
||||
nPx = CONFIG.pxInt(96)
|
||||
iPx = CONFIG.theme.baseIconSize
|
||||
iPx = SHARED.theme.baseIconSize
|
||||
|
||||
self.outerBox = QVBoxLayout()
|
||||
self.innerBox = QHBoxLayout()
|
||||
@@ -79,7 +79,7 @@ class GuiProjectLoad(QDialog):
|
||||
self.setMinimumHeight(CONFIG.pxInt(400))
|
||||
|
||||
self.nwIcon = QLabel()
|
||||
self.nwIcon.setPixmap(CONFIG.theme.getPixmap("novelwriter", (nPx, nPx)))
|
||||
self.nwIcon.setPixmap(SHARED.theme.getPixmap("novelwriter", (nPx, nPx)))
|
||||
self.innerBox.addWidget(self.nwIcon, 0, Qt.AlignTop)
|
||||
|
||||
self.projectForm = QGridLayout()
|
||||
@@ -110,7 +110,7 @@ class GuiProjectLoad(QDialog):
|
||||
self.selPath.setReadOnly(True)
|
||||
|
||||
self.browseButton = QPushButton("...")
|
||||
self.browseButton.setMaximumWidth(int(2.5*CONFIG.theme.getTextWidth("...")))
|
||||
self.browseButton.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
|
||||
self.browseButton.clicked.connect(self._doBrowse)
|
||||
|
||||
self.projectForm.addWidget(self.lblRecent, 0, 0, 1, 3)
|
||||
@@ -268,7 +268,7 @@ class GuiProjectLoad(QDialog):
|
||||
self.listBox.clear()
|
||||
dataList = CONFIG.recentProjects.listEntries()
|
||||
sortList = sorted(dataList, key=lambda x: x[3], reverse=True)
|
||||
nwxIcon = CONFIG.theme.getIcon("proj_nwx")
|
||||
nwxIcon = SHARED.theme.getIcon("proj_nwx")
|
||||
for path, title, words, time in sortList:
|
||||
newItem = QTreeWidgetItem([""]*4)
|
||||
newItem.setIcon(self.C_NAME, nwxIcon)
|
||||
@@ -279,7 +279,7 @@ class GuiProjectLoad(QDialog):
|
||||
newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter)
|
||||
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight | Qt.AlignVCenter)
|
||||
newItem.setTextAlignment(self.C_TIME, Qt.AlignRight | Qt.AlignVCenter)
|
||||
newItem.setFont(self.C_TIME, CONFIG.theme.guiFontFixed)
|
||||
newItem.setFont(self.C_TIME, SHARED.theme.guiFontFixed)
|
||||
self.listBox.addTopLevelItem(newItem)
|
||||
|
||||
self.listBox.setCurrentItem(self.listBox.topLevelItem(0))
|
||||
|
||||
@@ -34,7 +34,7 @@ from PyQt5.QtWidgets import (
|
||||
QPushButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwAlert
|
||||
from novelwriter.common import simplified
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
@@ -61,12 +61,12 @@ class GuiProjectSettings(NPagedDialog):
|
||||
self.setObjectName("GuiProjectSettings")
|
||||
|
||||
self.mainGui = mainGui
|
||||
self.mainGui.project.countStatus()
|
||||
SHARED.project.countStatus()
|
||||
self.setWindowTitle(self.tr("Project Settings"))
|
||||
|
||||
wW = CONFIG.pxInt(570)
|
||||
wH = CONFIG.pxInt(375)
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions = SHARED.project.options
|
||||
|
||||
self.setMinimumWidth(wW)
|
||||
self.setMinimumHeight(wH)
|
||||
@@ -115,7 +115,7 @@ class GuiProjectSettings(NPagedDialog):
|
||||
def _doSave(self):
|
||||
"""Save settings and close dialog.
|
||||
"""
|
||||
project = self.mainGui.project
|
||||
project = SHARED.project
|
||||
projName = self.tabMain.editName.text()
|
||||
bookTitle = self.tabMain.editTitle.text()
|
||||
bookAuthor = self.tabMain.editAuthor.text()
|
||||
@@ -183,7 +183,7 @@ class GuiProjectSettings(NPagedDialog):
|
||||
statusColW = CONFIG.rpxInt(self.tabStatus.listBox.columnWidth(0))
|
||||
importColW = CONFIG.rpxInt(self.tabImport.listBox.columnWidth(0))
|
||||
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions = SHARED.project.options
|
||||
pOptions.setValue("GuiProjectSettings", "winWidth", winWidth)
|
||||
pOptions.setValue("GuiProjectSettings", "winHeight", winHeight)
|
||||
pOptions.setValue("GuiProjectSettings", "replaceColW", replaceColW)
|
||||
@@ -204,13 +204,13 @@ class GuiProjectEditMain(QWidget):
|
||||
|
||||
# The Form
|
||||
self.mainForm = NConfigLayout()
|
||||
self.mainForm.setHelpTextStyle(CONFIG.theme.helpText)
|
||||
self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
|
||||
self.setLayout(self.mainForm)
|
||||
|
||||
self.mainForm.addGroupLabel(self.tr("Project Settings"))
|
||||
|
||||
xW = CONFIG.pxInt(250)
|
||||
pData = self.mainGui.project.data
|
||||
pData = SHARED.project.data
|
||||
|
||||
self.editName = QLineEdit()
|
||||
self.editName.setMaxLength(200)
|
||||
@@ -291,23 +291,23 @@ class GuiProjectEditStatus(QWidget):
|
||||
self.mainGui = projGui.mainGui
|
||||
|
||||
if isStatus:
|
||||
self.theStatus = self.mainGui.project.data.itemStatus
|
||||
self.theStatus = SHARED.project.data.itemStatus
|
||||
pageLabel = self.tr("Novel File Status Levels")
|
||||
colSetting = "statusColW"
|
||||
else:
|
||||
self.theStatus = self.mainGui.project.data.itemImport
|
||||
self.theStatus = SHARED.project.data.itemImport
|
||||
pageLabel = self.tr("Note File Importance Levels")
|
||||
colSetting = "importColW"
|
||||
|
||||
wCol0 = CONFIG.pxInt(
|
||||
self.mainGui.project.options.getInt("GuiProjectSettings", colSetting, 130)
|
||||
SHARED.project.options.getInt("GuiProjectSettings", colSetting, 130)
|
||||
)
|
||||
|
||||
self.colDeleted = []
|
||||
self.colChanged = False
|
||||
self.selColour = QColor(100, 100, 100)
|
||||
|
||||
self.iPx = CONFIG.theme.baseIconSize
|
||||
self.iPx = SHARED.theme.baseIconSize
|
||||
|
||||
# The List
|
||||
# ========
|
||||
@@ -326,16 +326,16 @@ class GuiProjectEditStatus(QWidget):
|
||||
# List Controls
|
||||
# =============
|
||||
|
||||
self.addButton = QPushButton(CONFIG.theme.getIcon("add"), "")
|
||||
self.addButton = QPushButton(SHARED.theme.getIcon("add"), "")
|
||||
self.addButton.clicked.connect(self._newItem)
|
||||
|
||||
self.delButton = QPushButton(CONFIG.theme.getIcon("remove"), "")
|
||||
self.delButton = QPushButton(SHARED.theme.getIcon("remove"), "")
|
||||
self.delButton.clicked.connect(self._delItem)
|
||||
|
||||
self.upButton = QPushButton(CONFIG.theme.getIcon("up"), "")
|
||||
self.upButton = QPushButton(SHARED.theme.getIcon("up"), "")
|
||||
self.upButton.clicked.connect(lambda: self._moveItem(-1))
|
||||
|
||||
self.dnButton = QPushButton(CONFIG.theme.getIcon("down"), "")
|
||||
self.dnButton = QPushButton(SHARED.theme.getIcon("down"), "")
|
||||
self.dnButton.clicked.connect(lambda: self._moveItem(1))
|
||||
|
||||
# Edit Form
|
||||
@@ -578,7 +578,7 @@ class GuiProjectEditReplace(QWidget):
|
||||
self.arChanged = False
|
||||
|
||||
wCol0 = CONFIG.pxInt(
|
||||
self.mainGui.project.options.getInt("GuiProjectSettings", "replaceColW", 130)
|
||||
SHARED.project.options.getInt("GuiProjectSettings", "replaceColW", 130)
|
||||
)
|
||||
pageLabel = self.tr("Text Replace List for Preview and Export")
|
||||
|
||||
@@ -594,7 +594,7 @@ class GuiProjectEditReplace(QWidget):
|
||||
self.listBox.setColumnWidth(self.COL_KEY, wCol0)
|
||||
self.listBox.setIndentation(0)
|
||||
|
||||
for aKey, aVal in self.mainGui.project.data.autoReplace.items():
|
||||
for aKey, aVal in SHARED.project.data.autoReplace.items():
|
||||
newItem = QTreeWidgetItem(["<%s>" % aKey, aVal])
|
||||
self.listBox.addTopLevelItem(newItem)
|
||||
|
||||
@@ -604,10 +604,10 @@ class GuiProjectEditReplace(QWidget):
|
||||
# List Controls
|
||||
# =============
|
||||
|
||||
self.addButton = QPushButton(CONFIG.theme.getIcon("add"), "")
|
||||
self.addButton = QPushButton(SHARED.theme.getIcon("add"), "")
|
||||
self.addButton.clicked.connect(self._addEntry)
|
||||
|
||||
self.delButton = QPushButton(CONFIG.theme.getIcon("remove"), "")
|
||||
self.delButton = QPushButton(SHARED.theme.getIcon("remove"), "")
|
||||
self.delButton.clicked.connect(self._delEntry)
|
||||
|
||||
# Edit Form
|
||||
|
||||
@@ -35,7 +35,7 @@ from PyQt5.QtWidgets import (
|
||||
qApp, QDialog, QHBoxLayout, QVBoxLayout, QDialogButtonBox, QLabel
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, __version__, __date__
|
||||
from novelwriter import CONFIG, SHARED, __version__, __date__
|
||||
from novelwriter.common import logException
|
||||
from novelwriter.constants import nwConst
|
||||
|
||||
@@ -58,7 +58,7 @@ class GuiUpdates(QDialog):
|
||||
|
||||
# Left Box
|
||||
self.nwIcon = QLabel()
|
||||
self.nwIcon.setPixmap(CONFIG.theme.getPixmap("novelwriter", (nPx, nPx)))
|
||||
self.nwIcon.setPixmap(SHARED.theme.getPixmap("novelwriter", (nPx, nPx)))
|
||||
|
||||
self.leftBox = QVBoxLayout()
|
||||
self.leftBox.addWidget(self.nwIcon)
|
||||
|
||||
@@ -33,7 +33,7 @@ from PyQt5.QtWidgets import (
|
||||
QLineEdit, QListWidget, QListWidgetItem, QPushButton, QVBoxLayout
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwAlert
|
||||
from novelwriter.core.spellcheck import UserDictionary
|
||||
|
||||
@@ -57,7 +57,7 @@ class GuiWordList(QDialog):
|
||||
mS = CONFIG.pxInt(250)
|
||||
wW = CONFIG.pxInt(320)
|
||||
wH = CONFIG.pxInt(340)
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions = SHARED.project.options
|
||||
|
||||
self.setMinimumWidth(mS)
|
||||
self.setMinimumHeight(mS)
|
||||
@@ -77,10 +77,10 @@ class GuiWordList(QDialog):
|
||||
|
||||
self.newEntry = QLineEdit()
|
||||
|
||||
self.addButton = QPushButton(CONFIG.theme.getIcon("add"), "")
|
||||
self.addButton = QPushButton(SHARED.theme.getIcon("add"), "")
|
||||
self.addButton.clicked.connect(self._doAdd)
|
||||
|
||||
self.delButton = QPushButton(CONFIG.theme.getIcon("remove"), "")
|
||||
self.delButton = QPushButton(SHARED.theme.getIcon("remove"), "")
|
||||
self.delButton.clicked.connect(self._doDelete)
|
||||
|
||||
self.editBox = QHBoxLayout()
|
||||
@@ -149,7 +149,7 @@ class GuiWordList(QDialog):
|
||||
def _doSave(self):
|
||||
"""Save the new word list and close."""
|
||||
self._saveGuiSettings()
|
||||
userDict = UserDictionary(self.mainGui.project)
|
||||
userDict = UserDictionary(SHARED.project)
|
||||
for i in range(self.listBox.count()):
|
||||
item = self.listBox.item(i)
|
||||
if isinstance(item, QListWidgetItem):
|
||||
@@ -172,7 +172,7 @@ class GuiWordList(QDialog):
|
||||
|
||||
def _loadWordList(self):
|
||||
"""Load the project's word list, if it exists."""
|
||||
userDict = UserDictionary(self.mainGui.project)
|
||||
userDict = UserDictionary(SHARED.project)
|
||||
userDict.load()
|
||||
self.listBox.clear()
|
||||
for word in userDict:
|
||||
@@ -185,7 +185,7 @@ class GuiWordList(QDialog):
|
||||
winWidth = CONFIG.rpxInt(self.width())
|
||||
winHeight = CONFIG.rpxInt(self.height())
|
||||
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions = SHARED.project.options
|
||||
pOptions.setValue("GuiWordList", "winWidth", winWidth)
|
||||
pOptions.setValue("GuiWordList", "winHeight", winHeight)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user