Make project instance private to main GUI class
This commit is contained in:
@@ -65,8 +65,7 @@ class GuiManuscriptBuild(QDialog):
|
||||
logger.debug("Create: GuiManuscriptBuild")
|
||||
self.setObjectName("GuiManuscriptBuild")
|
||||
|
||||
self.mainGui = mainGui
|
||||
self.theProject = mainGui.theProject
|
||||
self.mainGui = mainGui
|
||||
|
||||
self._parent = parent
|
||||
self._build = build
|
||||
@@ -82,7 +81,7 @@ class GuiManuscriptBuild(QDialog):
|
||||
wWin = CONFIG.pxInt(620)
|
||||
hWin = CONFIG.pxInt(360)
|
||||
|
||||
pOptions = self.theProject.options
|
||||
pOptions = self.mainGui.project.options
|
||||
self.resize(
|
||||
CONFIG.pxInt(pOptions.getInt("GuiManuscriptBuild", "winWidth", wWin)),
|
||||
CONFIG.pxInt(pOptions.getInt("GuiManuscriptBuild", "winHeight", hWin))
|
||||
@@ -280,7 +279,7 @@ class GuiManuscriptBuild(QDialog):
|
||||
@pyqtSlot()
|
||||
def _doResetBuildName(self):
|
||||
"""Generate a default build name."""
|
||||
bName = f"{self.theProject.data.name} - {self._build.name}"
|
||||
bName = f"{self.mainGui.project.data.name} - {self._build.name}"
|
||||
self.buildName.setText(bName)
|
||||
self._build.setLastBuildName(bName)
|
||||
return
|
||||
@@ -321,7 +320,7 @@ class GuiManuscriptBuild(QDialog):
|
||||
):
|
||||
return False
|
||||
|
||||
docBuild = NWBuildDocument(self.theProject, self._build)
|
||||
docBuild = NWBuildDocument(self.mainGui.project, self._build)
|
||||
docBuild.queueAll()
|
||||
|
||||
self.buildProgress.setMaximum(len(docBuild))
|
||||
@@ -354,7 +353,7 @@ class GuiManuscriptBuild(QDialog):
|
||||
fmtWidth = CONFIG.rpxInt(mainSplit[0])
|
||||
sumWidth = CONFIG.rpxInt(mainSplit[1])
|
||||
|
||||
pOptions = self.theProject.options
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions.setValue("GuiManuscriptBuild", "winWidth", winWidth)
|
||||
pOptions.setValue("GuiManuscriptBuild", "winHeight", winHeight)
|
||||
pOptions.setValue("GuiManuscriptBuild", "fmtWidth", fmtWidth)
|
||||
@@ -366,9 +365,9 @@ class GuiManuscriptBuild(QDialog):
|
||||
def _populateContentList(self):
|
||||
"""Build the content list."""
|
||||
rootMap = {}
|
||||
filtered = self._build.buildItemFilter(self.theProject)
|
||||
filtered = self._build.buildItemFilter(self.mainGui.project)
|
||||
self.listContent.clear()
|
||||
for nwItem in self.theProject.tree:
|
||||
for nwItem in self.mainGui.project.tree:
|
||||
tHandle = nwItem.itemHandle
|
||||
rHandle = nwItem.itemRoot
|
||||
|
||||
@@ -377,7 +376,7 @@ class GuiManuscriptBuild(QDialog):
|
||||
|
||||
if filtered.get(tHandle, (False, 0))[0]:
|
||||
if rHandle not in rootMap:
|
||||
rItem = self.theProject.tree[rHandle]
|
||||
rItem = self.mainGui.project.tree[rHandle]
|
||||
if isinstance(rItem, NWItem):
|
||||
rootMap[rHandle] = rItem.itemName
|
||||
|
||||
|
||||
@@ -72,10 +72,9 @@ class GuiManuscript(QDialog):
|
||||
if CONFIG.osDarwin:
|
||||
self.setWindowFlag(Qt.WindowType.Tool)
|
||||
|
||||
self.mainGui = mainGui
|
||||
self.theProject = mainGui.theProject
|
||||
self.mainGui = mainGui
|
||||
|
||||
self._builds = BuildCollection(self.theProject)
|
||||
self._builds = BuildCollection(self.mainGui.project)
|
||||
self._buildMap: dict[str, QListWidgetItem] = {}
|
||||
|
||||
self.setWindowTitle(self.tr("Build Manuscript"))
|
||||
@@ -86,7 +85,7 @@ class GuiManuscript(QDialog):
|
||||
wWin = CONFIG.pxInt(900)
|
||||
hWin = CONFIG.pxInt(600)
|
||||
|
||||
pOptions = self.theProject.options
|
||||
pOptions = self.mainGui.project.options
|
||||
self.resize(
|
||||
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "winWidth", wWin)),
|
||||
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "winHeight", hWin))
|
||||
@@ -211,7 +210,7 @@ class GuiManuscript(QDialog):
|
||||
self._updateBuildsList()
|
||||
|
||||
logger.debug("Loading build cache")
|
||||
cache = CONFIG.dataPath("cache") / f"build_{self.theProject.data.uuid}.json"
|
||||
cache = CONFIG.dataPath("cache") / f"build_{self.mainGui.project.data.uuid}.json"
|
||||
if cache.is_file():
|
||||
try:
|
||||
with open(cache, mode="r", encoding="utf-8") as fObj:
|
||||
@@ -290,7 +289,7 @@ class GuiManuscript(QDialog):
|
||||
if build is None:
|
||||
return
|
||||
|
||||
docBuild = NWBuildDocument(self.theProject, build)
|
||||
docBuild = NWBuildDocument(self.mainGui.project, build)
|
||||
docBuild.queueAll()
|
||||
|
||||
self.docPreview.beginNewBuild(len(docBuild))
|
||||
@@ -310,7 +309,7 @@ class GuiManuscript(QDialog):
|
||||
self._updatePreview(result, build)
|
||||
|
||||
logger.debug("Saving build cache")
|
||||
cache = CONFIG.dataPath("cache") / f"build_{self.theProject.data.uuid}.json"
|
||||
cache = CONFIG.dataPath("cache") / f"build_{self.mainGui.project.data.uuid}.json"
|
||||
try:
|
||||
with open(cache, mode="w+", encoding="utf-8") as outFile:
|
||||
outFile.write(json.dumps(result, indent=2))
|
||||
@@ -391,7 +390,7 @@ class GuiManuscript(QDialog):
|
||||
optsWidth = CONFIG.rpxInt(mainSplit[0])
|
||||
viewWidth = CONFIG.rpxInt(mainSplit[1])
|
||||
|
||||
pOptions = self.theProject.options
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions.setValue("GuiManuscript", "winWidth", winWidth)
|
||||
pOptions.setValue("GuiManuscript", "winHeight", winHeight)
|
||||
pOptions.setValue("GuiManuscript", "optsWidth", optsWidth)
|
||||
@@ -450,8 +449,7 @@ class _PreviewWidget(QTextBrowser):
|
||||
def __init__(self, mainGui: GuiMain):
|
||||
super().__init__(parent=mainGui)
|
||||
|
||||
self.mainGui = mainGui
|
||||
self.theProject = mainGui.theProject
|
||||
self.mainGui = mainGui
|
||||
|
||||
self._docTime = 0
|
||||
self._buildName = ""
|
||||
@@ -524,12 +522,12 @@ class _PreviewWidget(QTextBrowser):
|
||||
|
||||
def setJustify(self, state: bool):
|
||||
"""Enable/disable the justify text option."""
|
||||
options = self.document().defaultTextOption()
|
||||
pOptions = self.document().defaultTextOption()
|
||||
if state:
|
||||
options.setAlignment(Qt.AlignJustify)
|
||||
pOptions.setAlignment(Qt.AlignJustify)
|
||||
else:
|
||||
options.setAlignment(Qt.AlignAbsolute)
|
||||
self.document().setDefaultTextOption(options)
|
||||
pOptions.setAlignment(Qt.AlignAbsolute)
|
||||
self.document().setDefaultTextOption(pOptions)
|
||||
return
|
||||
|
||||
def setTextFont(self, family: str, size: int):
|
||||
|
||||
@@ -76,8 +76,7 @@ class GuiBuildSettings(QDialog):
|
||||
if CONFIG.osDarwin:
|
||||
self.setWindowFlag(Qt.WindowType.Tool)
|
||||
|
||||
self.mainGui = mainGui
|
||||
self.theProject = mainGui.theProject
|
||||
self.mainGui = mainGui
|
||||
|
||||
self._build = build
|
||||
|
||||
@@ -89,7 +88,7 @@ class GuiBuildSettings(QDialog):
|
||||
wWin = CONFIG.pxInt(750)
|
||||
hWin = CONFIG.pxInt(550)
|
||||
|
||||
pOptions = self.theProject.options
|
||||
pOptions = self.mainGui.project.options
|
||||
self.resize(
|
||||
CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "winWidth", wWin)),
|
||||
CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "winHeight", hWin))
|
||||
@@ -263,7 +262,7 @@ class GuiBuildSettings(QDialog):
|
||||
|
||||
treeWidth, filterWidth = self.optTabSelect.mainSplitSizes()
|
||||
|
||||
pOptions = self.theProject.options
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions.setValue("GuiBuildSettings", "winWidth", winWidth)
|
||||
pOptions.setValue("GuiBuildSettings", "winHeight", winHeight)
|
||||
pOptions.setValue("GuiBuildSettings", "treeWidth", treeWidth)
|
||||
@@ -304,8 +303,7 @@ class _FilterTab(QWidget):
|
||||
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
|
||||
super().__init__(parent=buildMain)
|
||||
|
||||
self.mainGui = buildMain.mainGui
|
||||
self.theProject = buildMain.mainGui.theProject
|
||||
self.mainGui = buildMain.mainGui
|
||||
|
||||
self._treeMap: dict[str, QTreeWidgetItem] = {}
|
||||
self._build = build
|
||||
@@ -381,7 +379,7 @@ class _FilterTab(QWidget):
|
||||
# Assemble GUI
|
||||
# ============
|
||||
|
||||
pOptions = self.theProject.options
|
||||
pOptions = self.mainGui.project.options
|
||||
|
||||
self.selectionBox = QVBoxLayout()
|
||||
self.selectionBox.addWidget(self.optTree)
|
||||
@@ -447,7 +445,7 @@ class _FilterTab(QWidget):
|
||||
logger.debug("Building project tree")
|
||||
self._treeMap = {}
|
||||
self.optTree.clear()
|
||||
for nwItem in self.theProject.getProjectItems():
|
||||
for nwItem in self.mainGui.project.getProjectItems():
|
||||
|
||||
tHandle = nwItem.itemHandle
|
||||
pHandle = nwItem.itemParent
|
||||
@@ -523,7 +521,7 @@ class _FilterTab(QWidget):
|
||||
|
||||
# Root Classes
|
||||
self.filterOpt.addLabel(self.tr("Select Root Folders"))
|
||||
for tHandle, nwItem in self.theProject.tree.iterRoots(None):
|
||||
for tHandle, nwItem in self.mainGui.project.tree.iterRoots(None):
|
||||
if not nwItem.isInactiveClass():
|
||||
itemIcon = CONFIG.theme.getItemIcon(
|
||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout
|
||||
@@ -559,7 +557,7 @@ class _FilterTab(QWidget):
|
||||
|
||||
def _setTreeItemMode(self) -> None:
|
||||
"""Update the filtered mode icon on all items."""
|
||||
filtered = self._build.buildItemFilter(self.theProject)
|
||||
filtered = self._build.buildItemFilter(self.mainGui.project)
|
||||
for tHandle, item in self._treeMap.items():
|
||||
allow, mode = filtered.get(tHandle, (False, FilterMode.UNKNOWN))
|
||||
if mode == FilterMode.INCLUDED:
|
||||
@@ -599,8 +597,7 @@ class _HeadingsTab(QWidget):
|
||||
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
|
||||
super().__init__(parent=buildMain)
|
||||
|
||||
self.mainGui = buildMain.mainGui
|
||||
self.theProject = buildMain.mainGui.theProject
|
||||
self.mainGui = buildMain.mainGui
|
||||
|
||||
self._build = build
|
||||
self._editing = 0
|
||||
|
||||
@@ -72,15 +72,14 @@ class GuiWritingStats(QDialog):
|
||||
if CONFIG.osDarwin:
|
||||
self.setWindowFlag(Qt.WindowType.Tool)
|
||||
|
||||
self.mainGui = mainGui
|
||||
self.theProject = mainGui.theProject
|
||||
self.mainGui = mainGui
|
||||
|
||||
self.logData = []
|
||||
self.filterData = []
|
||||
self.timeFilter = 0.0
|
||||
self.wordOffset = 0
|
||||
|
||||
pOptions = self.theProject.options
|
||||
pOptions = self.mainGui.project.options
|
||||
|
||||
self.setWindowTitle(self.tr("Writing Statistics"))
|
||||
self.setMinimumWidth(CONFIG.pxInt(420))
|
||||
@@ -334,7 +333,7 @@ class GuiWritingStats(QDialog):
|
||||
showIdleTime = self.showIdleTime.isChecked()
|
||||
histMax = self.histMax.value()
|
||||
|
||||
pOptions = self.theProject.options
|
||||
pOptions = self.mainGui.project.options
|
||||
pOptions.setValue("GuiWritingStats", "winWidth", winWidth)
|
||||
pOptions.setValue("GuiWritingStats", "winHeight", winHeight)
|
||||
pOptions.setValue("GuiWritingStats", "widthCol0", widthCol0)
|
||||
@@ -442,7 +441,7 @@ class GuiWritingStats(QDialog):
|
||||
ttTime = 0
|
||||
ttIdle = 0
|
||||
|
||||
for record in self.theProject.session.iterRecords():
|
||||
for record in self.mainGui.project.session.iterRecords():
|
||||
rType = record.get("type")
|
||||
if rType == "initial":
|
||||
self.wordOffset = checkInt(record.get("offset"), 0)
|
||||
|
||||
Reference in New Issue
Block a user