Rename ambiguous theParent variable to mainGui

This commit is contained in:
Veronica Berglyd Olsen
2022-06-11 15:33:32 +02:00
parent b8d557646a
commit 0181bebd70
28 changed files with 407 additions and 408 deletions
+39 -39
View File
@@ -56,11 +56,11 @@ class NWProject():
FILE_VERSION = "1.4" # The current project file format version FILE_VERSION = "1.4" # The current project file format version
def __init__(self, theParent): def __init__(self, mainGui):
# Internal # Internal
self.theParent = theParent self.mainConf = novelwriter.CONFIG
self.mainConf = novelwriter.CONFIG self.mainGui = mainGui
# Core Elements # Core Elements
self._optState = OptionState(self) # Project-specific GUI options self._optState = OptionState(self) # Project-specific GUI options
@@ -414,7 +414,7 @@ class NWProject():
if not os.path.isfile(fileName): if not os.path.isfile(fileName):
fileName = os.path.join(fileName, nwFiles.PROJ_FILE) fileName = os.path.join(fileName, nwFiles.PROJ_FILE)
if not os.path.isfile(fileName): if not os.path.isfile(fileName):
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"File not found: {0}" "File not found: {0}"
).format(fileName), nwAlert.ERROR) ).format(fileName), nwAlert.ERROR)
return False return False
@@ -465,20 +465,20 @@ class NWProject():
try: try:
nwXML = etree.parse(fileName) nwXML = etree.parse(fileName)
except Exception as exc: except Exception as exc:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Failed to parse project xml." "Failed to parse project xml."
), nwAlert.ERROR, exception=exc) ), nwAlert.ERROR, exception=exc)
# Trying to open backup file instead # Trying to open backup file instead
backFile = fileName[:-3]+"bak" backFile = fileName[:-3]+"bak"
if os.path.isfile(backFile): if os.path.isfile(backFile):
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Attempting to open backup project file instead." "Attempting to open backup project file instead."
), nwAlert.INFO) ), nwAlert.INFO)
try: try:
nwXML = etree.parse(backFile) nwXML = etree.parse(backFile)
except Exception as exc: except Exception as exc:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Failed to parse project xml." "Failed to parse project xml."
), nwAlert.ERROR, exception=exc) ), nwAlert.ERROR, exception=exc)
self.clearProject() self.clearProject()
@@ -501,7 +501,7 @@ class NWProject():
# =============== # ===============
if not nwxRoot == "novelWriterXML": if not nwxRoot == "novelWriterXML":
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Project file does not appear to be a novelWriterXML file." "Project file does not appear to be a novelWriterXML file."
), nwAlert.ERROR) ), nwAlert.ERROR)
self.clearProject() self.clearProject()
@@ -527,7 +527,7 @@ class NWProject():
# stored and handled. Introduced in version 1.7. # stored and handled. Introduced in version 1.7.
if fileVersion not in ("1.0", "1.1", "1.2", "1.3", "1.4"): if fileVersion not in ("1.0", "1.1", "1.2", "1.3", "1.4"):
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Unknown or unsupported novelWriter project file format. " "Unknown or unsupported novelWriter project file format. "
"The project cannot be opened by this version of novelWriter. " "The project cannot be opened by this version of novelWriter. "
"The file was saved with novelWriter version {0}." "The file was saved with novelWriter version {0}."
@@ -536,7 +536,7 @@ class NWProject():
return False return False
if fileVersion != self.FILE_VERSION: if fileVersion != self.FILE_VERSION:
msgYes = self.theParent.askQuestion( msgYes = self.mainGui.askQuestion(
self.tr("File Version"), self.tr("File Version"),
self.tr( self.tr(
"The file format of your project is about to be updated. " "The file format of your project is about to be updated. "
@@ -552,7 +552,7 @@ class NWProject():
# ========================= # =========================
if hexToInt(hexVersion) > hexToInt(novelwriter.__hexversion__): if hexToInt(hexVersion) > hexToInt(novelwriter.__hexversion__):
msgYes = self.theParent.askQuestion( msgYes = self.mainGui.askQuestion(
self.tr("Version Conflict"), self.tr("Version Conflict"),
self.tr( self.tr(
"This project was saved by a newer version of " "This project was saved by a newer version of "
@@ -646,7 +646,7 @@ class NWProject():
for projItem in legacyList: for projItem in legacyList:
errList = self._legacyDataFolder(projItem, errList) errList = self._legacyDataFolder(projItem, errList)
if errList: if errList:
self.theParent.makeAlert(errList, nwAlert.ERROR) self.mainGui.makeAlert(errList, nwAlert.ERROR)
# Clean up no longer used files # Clean up no longer used files
self._deprecatedFiles() self._deprecatedFiles()
@@ -672,7 +672,7 @@ class NWProject():
self._writeLockFile() self._writeLockFile()
self.setProjectChanged(False) self.setProjectChanged(False)
self.theParent.setStatus(self.tr("Opened Project: {0}").format(self.projName)) self.mainGui.setStatus(self.tr("Opened Project: {0}").format(self.projName))
return True return True
@@ -683,7 +683,7 @@ class NWProject():
file. file.
""" """
if self.projPath is None: if self.projPath is None:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Project path not set, cannot save project." "Project path not set, cannot save project."
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
@@ -763,7 +763,7 @@ class NWProject():
xml_declaration=True xml_declaration=True
)) ))
except Exception as exc: except Exception as exc:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Failed to save project." "Failed to save project."
), nwAlert.ERROR, exception=exc) ), nwAlert.ERROR, exception=exc)
return False return False
@@ -775,7 +775,7 @@ class NWProject():
os.replace(saveFile, backFile) os.replace(saveFile, backFile)
os.replace(tempFile, saveFile) os.replace(tempFile, saveFile)
except OSError as exc: except OSError as exc:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Failed to save project." "Failed to save project."
), nwAlert.ERROR, exception=exc) ), nwAlert.ERROR, exception=exc)
return False return False
@@ -788,7 +788,7 @@ class NWProject():
self.mainConf.saveRecentCache() self.mainConf.saveRecentCache()
self._writeLockFile() self._writeLockFile()
self.theParent.setStatus(self.tr("Saved Project: {0}").format(self.projName)) self.mainGui.setStatus(self.tr("Saved Project: {0}").format(self.projName))
self.setProjectChanged(False) self.setProjectChanged(False)
return True return True
@@ -836,22 +836,22 @@ class NWProject():
def zipIt(self, doNotify): def zipIt(self, doNotify):
"""Create a zip file of the entire project. """Create a zip file of the entire project.
""" """
if not self.theParent.hasProject: if not self.mainGui.hasProject:
logger.error("No project open") logger.error("No project open")
return False return False
logger.info("Backing up project") logger.info("Backing up project")
self.theParent.setStatus(self.tr("Backing up project ...")) self.mainGui.setStatus(self.tr("Backing up project ..."))
if not (self.mainConf.backupPath and os.path.isdir(self.mainConf.backupPath)): if not (self.mainConf.backupPath and os.path.isdir(self.mainConf.backupPath)):
self.theParent.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. "
"Please set a valid backup location in Preferences." "Please set a valid backup location in Preferences."
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
if not self.projName: if not self.projName:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Cannot backup project because no project name is set. " "Cannot backup project because no project name is set. "
"Please set a Working Title in Project Settings." "Please set a Working Title in Project Settings."
), nwAlert.ERROR) ), nwAlert.ERROR)
@@ -864,13 +864,13 @@ class NWProject():
os.mkdir(baseDir) os.mkdir(baseDir)
logger.debug("Created folder: %s", baseDir) logger.debug("Created folder: %s", baseDir)
except Exception as exc: except Exception as exc:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Could not create backup folder." "Could not create backup folder."
), nwAlert.ERROR, exception=exc) ), nwAlert.ERROR, exception=exc)
return False return False
if baseDir and baseDir.startswith(self.projPath): if baseDir and baseDir.startswith(self.projPath):
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Cannot backup project because the backup path is within the " "Cannot backup project because the backup path is within the "
"project folder to be backed up. Please choose a different " "project folder to be backed up. Please choose a different "
"backup path in Preferences." "backup path in Preferences."
@@ -886,17 +886,17 @@ class NWProject():
self._writeLockFile() self._writeLockFile()
logger.info("Backup written to: %s", archName) logger.info("Backup written to: %s", archName)
if doNotify: if doNotify:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Backup archive file written to: {0}" "Backup archive file written to: {0}"
).format(f"{os.path.join(cleanName, archName)}.zip"), nwAlert.INFO) ).format(f"{os.path.join(cleanName, archName)}.zip"), nwAlert.INFO)
except Exception as exc: except Exception as exc:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Could not write backup archive." "Could not write backup archive."
), nwAlert.ERROR, exception=exc) ), nwAlert.ERROR, exception=exc)
return False return False
self.theParent.setStatus(self.tr( self.mainGui.setStatus(self.tr(
"Project backed up to '{0}'" "Project backed up to '{0}'"
).format(f"{baseName}.zip")) ).format(f"{baseName}.zip"))
@@ -924,7 +924,7 @@ class NWProject():
shutil.unpack_archive(pkgSample, projPath) shutil.unpack_archive(pkgSample, projPath)
isSuccess = True isSuccess = True
except Exception as exc: except Exception as exc:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Failed to create a new example project." "Failed to create a new example project."
), nwAlert.ERROR, exception=exc) ), nwAlert.ERROR, exception=exc)
@@ -946,12 +946,12 @@ class NWProject():
isSuccess = True isSuccess = True
except Exception as exc: except Exception as exc:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Failed to create a new example project." "Failed to create a new example project."
), nwAlert.ERROR, exception=exc) ), nwAlert.ERROR, exception=exc)
else: else:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Failed to create a new example project. " "Failed to create a new example project. "
"Could not find the necessary files. " "Could not find the necessary files. "
"They seem to be missing from this installation." "They seem to be missing from this installation."
@@ -959,8 +959,8 @@ class NWProject():
if isSuccess: if isSuccess:
self.clearProject() self.clearProject()
self.theParent.openProject(projPath) self.mainGui.openProject(projPath)
self.theParent.rebuildIndex() self.mainGui.rebuildIndex()
return isSuccess return isSuccess
@@ -985,14 +985,14 @@ class NWProject():
os.mkdir(projPath) os.mkdir(projPath)
logger.debug("Created folder: %s", projPath) logger.debug("Created folder: %s", projPath)
except Exception as exc: except Exception as exc:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Could not create new project folder." "Could not create new project folder."
), nwAlert.ERROR, exception=exc) ), nwAlert.ERROR, exception=exc)
return False return False
if os.path.isdir(projPath): if os.path.isdir(projPath):
if os.listdir(self.projPath): if os.listdir(self.projPath):
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"New project folder is not empty. " "New project folder is not empty. "
"Each project requires a dedicated project folder." "Each project requires a dedicated project folder."
), nwAlert.ERROR) ), nwAlert.ERROR)
@@ -1042,14 +1042,14 @@ class NWProject():
self.doBackup = doBackup self.doBackup = doBackup
if doBackup: if doBackup:
if not os.path.isdir(self.mainConf.backupPath): if not os.path.isdir(self.mainConf.backupPath):
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"You must set a valid backup path in Preferences to use " "You must set a valid backup path in Preferences to use "
"the automatic project backup feature." "the automatic project backup feature."
), nwAlert.WARN) ), nwAlert.WARN)
return False return False
if self.projName == "": if self.projName == "":
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"You must set a valid project name in Project Settings to " "You must set a valid project name in Project Settings to "
"use the automatic project backup feature." "use the automatic project backup feature."
), nwAlert.WARN) ), nwAlert.WARN)
@@ -1154,7 +1154,7 @@ class NWProject():
information to the GUI statusbar. information to the GUI statusbar.
""" """
self.projChanged = bValue self.projChanged = bValue
self.theParent.statusBar.doUpdateProjectStatus(bValue) self.mainGui.statusBar.doUpdateProjectStatus(bValue)
if bValue: if bValue:
# If we've changed the project at all, this should be True # If we've changed the project at all, this should be True
self.projAltered = True self.projAltered = True
@@ -1384,7 +1384,7 @@ class NWProject():
os.mkdir(thePath) os.mkdir(thePath)
logger.debug("Created folder: %s", thePath) logger.debug("Created folder: %s", thePath)
except Exception as exc: except Exception as exc:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Could not create folder." "Could not create folder."
), nwAlert.ERROR, exception=exc) ), nwAlert.ERROR, exception=exc)
return False return False
@@ -1447,7 +1447,7 @@ class NWProject():
# Report status # Report status
if len(orphanFiles) > 0: if len(orphanFiles) > 0:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Found {0} orphaned file(s) in project folder." "Found {0} orphaned file(s) in project folder."
).format(len(orphanFiles)), nwAlert.WARN) ).format(len(orphanFiles)), nwAlert.WARN)
else: else:
@@ -1504,7 +1504,7 @@ class NWProject():
self._projTree.updateItemData(orphItem.itemHandle) self._projTree.updateItemData(orphItem.itemHandle)
if noWhere: if noWhere:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"One or more orphaned files could not be added back into the project. " "One or more orphaned files could not be added back into the project. "
"Make sure at least a Novel root folder exists." "Make sure at least a Novel root folder exists."
), nwAlert.WARN) ), nwAlert.WARN)
-1
View File
@@ -82,7 +82,6 @@ class Tokenizer(ABC):
def __init__(self, theProject): def __init__(self, theProject):
self.theProject = theProject self.theProject = theProject
self.theParent = theProject.theParent
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
# Data Variables # Data Variables
+11 -11
View File
@@ -43,15 +43,15 @@ logger = logging.getLogger(__name__)
class GuiAbout(QDialog): class GuiAbout(QDialog):
def __init__(self, theParent): def __init__(self, mainGui):
QDialog.__init__(self, theParent) QDialog.__init__(self, mainGui)
logger.debug("Initialising GuiAbout ...") logger.debug("Initialising GuiAbout ...")
self.setObjectName("GuiAbout") self.setObjectName("GuiAbout")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
self.innerBox = QHBoxLayout() self.innerBox = QHBoxLayout()
@@ -63,7 +63,7 @@ class GuiAbout(QDialog):
nPx = self.mainConf.pxInt(96) nPx = self.mainConf.pxInt(96)
self.nwIcon = QLabel() self.nwIcon = QLabel()
self.nwIcon.setPixmap(self.theParent.theTheme.getPixmap("novelwriter", (nPx, nPx))) self.nwIcon.setPixmap(self.mainGui.theTheme.getPixmap("novelwriter", (nPx, nPx)))
self.lblName = QLabel("<b>novelWriter</b>") self.lblName = QLabel("<b>novelWriter</b>")
self.lblVers = QLabel(f"v{novelwriter.__version__}") self.lblVers = QLabel(f"v{novelwriter.__version__}")
self.lblDate = QLabel(datetime.strptime(novelwriter.__date__, "%Y-%m-%d").strftime("%x")) self.lblDate = QLabel(datetime.strptime(novelwriter.__date__, "%Y-%m-%d").strftime("%x"))
@@ -191,8 +191,8 @@ class GuiAbout(QDialog):
]) ])
) )
theTheme = self.theParent.theTheme theTheme = self.mainGui.theTheme
theIcons = self.theParent.theTheme.theIcons theIcons = self.mainGui.theTheme.theIcons
if theTheme.themeName and theTheme.themeAuthor != "N/A": if theTheme.themeName and theTheme.themeAuthor != "N/A":
licURL = f"<a href='{theTheme.themeLicenseUrl}'>{theTheme.themeLicense}</a>" licURL = f"<a href='{theTheme.themeLicenseUrl}'>{theTheme.themeLicense}</a>"
aboutMsg += "<h4>{0}</h4><p>{1}</p>".format( aboutMsg += "<h4>{0}</h4><p>{1}</p>".format(
@@ -279,9 +279,9 @@ class GuiAbout(QDialog):
" padding-right: 0.8em;" " padding-right: 0.8em;"
"}}\n" "}}\n"
).format( ).format(
hColR=self.theParent.theTheme.colHead[0], hColR=self.mainGui.theTheme.colHead[0],
hColG=self.theParent.theTheme.colHead[1], hColG=self.mainGui.theTheme.colHead[1],
hColB=self.theParent.theTheme.colHead[2], hColB=self.mainGui.theTheme.colHead[2],
kColR=self.theTheme.colKey[0], kColR=self.theTheme.colKey[0],
kColG=self.theTheme.colKey[1], kColG=self.theTheme.colKey[1],
kColB=self.theTheme.colKey[2], kColB=self.theTheme.colKey[2],
+15 -15
View File
@@ -41,15 +41,15 @@ logger = logging.getLogger(__name__)
class GuiDocMerge(QDialog): class GuiDocMerge(QDialog):
def __init__(self, theParent): def __init__(self, mainGui):
QDialog.__init__(self, theParent) QDialog.__init__(self, mainGui)
logger.debug("Initialising GuiDocMerge ...") logger.debug("Initialising GuiDocMerge ...")
self.setObjectName("GuiDocMerge") self.setObjectName("GuiDocMerge")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theProject = theParent.theProject self.theProject = mainGui.theProject
self.sourceItem = None self.sourceItem = None
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
@@ -57,7 +57,7 @@ class GuiDocMerge(QDialog):
self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Documents to Merge"))) self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Documents to Merge")))
self.helpLabel = QHelpLabel( self.helpLabel = QHelpLabel(
self.tr("Drag and drop items to change the order."), self.theParent.theTheme.helpText self.tr("Drag and drop items to change the order."), self.mainGui.theTheme.helpText
) )
self.listBox = QListWidget() self.listBox = QListWidget()
@@ -102,7 +102,7 @@ class GuiDocMerge(QDialog):
finalOrder.append(self.listBox.item(i).data(Qt.UserRole)) finalOrder.append(self.listBox.item(i).data(Qt.UserRole))
if len(finalOrder) == 0: if len(finalOrder) == 0:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"No source documents found. Nothing to do." "No source documents found. Nothing to do."
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
@@ -113,21 +113,21 @@ class GuiDocMerge(QDialog):
docText = inDoc.readDocument() docText = inDoc.readDocument()
docErr = inDoc.getError() docErr = inDoc.getError()
if docText is None and docErr: if docText is None and docErr:
self.theParent.makeAlert([ self.mainGui.makeAlert([
self.tr("Failed to open document file."), docErr self.tr("Failed to open document file."), docErr
], nwAlert.ERROR) ], nwAlert.ERROR)
if docText: if docText:
theText += docText.rstrip("\n")+"\n\n" theText += docText.rstrip("\n")+"\n\n"
if self.sourceItem is None: if self.sourceItem is None:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"No source folder selected. Nothing to do." "No source folder selected. Nothing to do."
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
srcItem = self.theProject.tree[self.sourceItem] srcItem = self.theProject.tree[self.sourceItem]
if srcItem is None: if srcItem is None:
self.theParent.makeAlert(self.tr("Internal error."), nwAlert.ERROR) self.mainGui.makeAlert(self.tr("Internal error."), nwAlert.ERROR)
return False return False
nHandle = self.theProject.newFile(srcItem.itemName, srcItem.itemParent) nHandle = self.theProject.newFile(srcItem.itemName, srcItem.itemParent)
@@ -137,13 +137,13 @@ class GuiDocMerge(QDialog):
outDoc = NWDoc(self.theProject, nHandle) outDoc = NWDoc(self.theProject, nHandle)
if not outDoc.writeDocument(theText): if not outDoc.writeDocument(theText):
self.theParent.makeAlert([ self.mainGui.makeAlert([
self.tr("Could not save document."), outDoc.getError() self.tr("Could not save document."), outDoc.getError()
], nwAlert.ERROR) ], nwAlert.ERROR)
return False return False
self.theParent.treeView.revealNewTreeItem(nHandle) self.mainGui.treeView.revealNewTreeItem(nHandle)
self.theParent.openDocument(nHandle, doScroll=True) self.mainGui.openDocument(nHandle, doScroll=True)
self._doClose() self._doClose()
@@ -165,7 +165,7 @@ class GuiDocMerge(QDialog):
are then added to the list view in order. The list itself can be are then added to the list view in order. The list itself can be
reordered by the user. reordered by the user.
""" """
tHandle = self.theParent.treeView.getSelectedHandle() tHandle = self.mainGui.treeView.getSelectedHandle()
self.sourceItem = tHandle self.sourceItem = tHandle
if tHandle is None: if tHandle is None:
return False return False
@@ -175,12 +175,12 @@ class GuiDocMerge(QDialog):
return False return False
if nwItem.itemType is not nwItemType.FOLDER: if nwItem.itemType is not nwItemType.FOLDER:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Element selected in the project tree must be a folder." "Element selected in the project tree must be a folder."
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
for sHandle in self.theParent.treeView.getTreeFromHandle(tHandle): for sHandle in self.mainGui.treeView.getTreeFromHandle(tHandle):
newItem = QListWidgetItem() newItem = QListWidgetItem()
nwItem = self.theProject.tree[sHandle] nwItem = self.theProject.tree[sHandle]
if nwItem.itemType is not nwItemType.FILE: if nwItem.itemType is not nwItemType.FILE:
+15 -15
View File
@@ -41,15 +41,15 @@ logger = logging.getLogger(__name__)
class GuiDocSplit(QDialog): class GuiDocSplit(QDialog):
def __init__(self, theParent): def __init__(self, mainGui):
QDialog.__init__(self, theParent) QDialog.__init__(self, mainGui)
logger.debug("Initialising GuiDocSplit ...") logger.debug("Initialising GuiDocSplit ...")
self.setObjectName("GuiDocSplit") self.setObjectName("GuiDocSplit")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theProject = theParent.theProject self.theProject = mainGui.theProject
self.sourceItem = None self.sourceItem = None
self.sourceText = [] self.sourceText = []
@@ -60,7 +60,7 @@ class GuiDocSplit(QDialog):
self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Document Headers"))) self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Document Headers")))
self.helpLabel = QHelpLabel( self.helpLabel = QHelpLabel(
self.tr("Select the maximum level to split into files."), self.tr("Select the maximum level to split into files."),
self.theParent.theTheme.helpText self.mainGui.theTheme.helpText
) )
self.listBox = QListWidget() self.listBox = QListWidget()
@@ -115,14 +115,14 @@ class GuiDocSplit(QDialog):
logger.verbose("GuiDocSplit split button clicked") logger.verbose("GuiDocSplit split button clicked")
if self.sourceItem is None: if self.sourceItem is None:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"No source document selected. Nothing to do." "No source document selected. Nothing to do."
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
srcItem = self.theProject.tree[self.sourceItem] srcItem = self.theProject.tree[self.sourceItem]
if srcItem is None: if srcItem is None:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Could not parse source document." "Could not parse source document."
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
@@ -132,7 +132,7 @@ class GuiDocSplit(QDialog):
docErr = inDoc.getError() docErr = inDoc.getError()
if theText is None and docErr: if theText is None and docErr:
self.theParent.makeAlert([ self.mainGui.makeAlert([
self.tr("Failed to open document file."), docErr self.tr("Failed to open document file."), docErr
], nwAlert.ERROR) ], nwAlert.ERROR)
@@ -153,12 +153,12 @@ class GuiDocSplit(QDialog):
nFiles = len(finalOrder) nFiles = len(finalOrder)
if nFiles == 0: if nFiles == 0:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"No headers found. Nothing to do." "No headers found. Nothing to do."
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
msgYes = self.theParent.askQuestion( msgYes = self.mainGui.askQuestion(
self.tr("Split Document"), self.tr("Split Document"),
"{0}<br><br>{1}".format( "{0}<br><br>{1}".format(
self.tr( self.tr(
@@ -175,7 +175,7 @@ class GuiDocSplit(QDialog):
# Create the folder # Create the folder
fHandle = self.theProject.newFolder(srcItem.itemName, srcItem.itemParent) fHandle = self.theProject.newFolder(srcItem.itemName, srcItem.itemParent)
self.theParent.treeView.revealNewTreeItem(fHandle) self.mainGui.treeView.revealNewTreeItem(fHandle)
logger.verbose("Creating folder '%s'", fHandle) logger.verbose("Creating folder '%s'", fHandle)
# Loop through, and create the files # Loop through, and create the files
@@ -196,12 +196,12 @@ class GuiDocSplit(QDialog):
outDoc = NWDoc(self.theProject, nHandle) outDoc = NWDoc(self.theProject, nHandle)
if not outDoc.writeDocument(theText): if not outDoc.writeDocument(theText):
self.theParent.makeAlert([ self.mainGui.makeAlert([
self.tr("Could not save document."), outDoc.getError() self.tr("Could not save document."), outDoc.getError()
], nwAlert.ERROR) ], nwAlert.ERROR)
return False return False
self.theParent.treeView.revealNewTreeItem(nHandle) self.mainGui.treeView.revealNewTreeItem(nHandle)
self._doClose() self._doClose()
@@ -226,7 +226,7 @@ class GuiDocSplit(QDialog):
""" """
self.listBox.clear() self.listBox.clear()
if self.sourceItem is None: if self.sourceItem is None:
self.sourceItem = self.theParent.treeView.getSelectedHandle() self.sourceItem = self.mainGui.treeView.getSelectedHandle()
if self.sourceItem is None: if self.sourceItem is None:
return False return False
@@ -236,7 +236,7 @@ class GuiDocSplit(QDialog):
return False return False
if nwItem.itemType is not nwItemType.FILE: if nwItem.itemType is not nwItemType.FILE:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Element selected in the project tree must be a file." "Element selected in the project tree must be a file."
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
+4 -4
View File
@@ -41,15 +41,15 @@ logger = logging.getLogger(__name__)
class GuiItemEditor(QDialog): class GuiItemEditor(QDialog):
def __init__(self, theParent, tHandle): def __init__(self, mainGui, tHandle):
QDialog.__init__(self, theParent) QDialog.__init__(self, mainGui)
logger.debug("Initialising GuiItemEditor ...") logger.debug("Initialising GuiItemEditor ...")
self.setObjectName("GuiItemEditor") self.setObjectName("GuiItemEditor")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theProject = theParent.theProject self.theProject = mainGui.theProject
## ##
# Build GUI # Build GUI
+49 -49
View File
@@ -43,25 +43,25 @@ logger = logging.getLogger(__name__)
class GuiPreferences(PagedDialog): class GuiPreferences(PagedDialog):
def __init__(self, theParent): def __init__(self, mainGui):
PagedDialog.__init__(self, theParent) PagedDialog.__init__(self, mainGui)
logger.debug("Initialising GuiPreferences ...") logger.debug("Initialising GuiPreferences ...")
self.setObjectName("GuiPreferences") self.setObjectName("GuiPreferences")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theProject = theParent.theProject self.theProject = mainGui.theProject
self.setWindowTitle(self.tr("Preferences")) self.setWindowTitle(self.tr("Preferences"))
self.tabGeneral = GuiPreferencesGeneral(self.theParent) self.tabGeneral = GuiPreferencesGeneral(self.mainGui)
self.tabProjects = GuiPreferencesProjects(self.theParent) self.tabProjects = GuiPreferencesProjects(self.mainGui)
self.tabDocs = GuiPreferencesDocuments(self.theParent) self.tabDocs = GuiPreferencesDocuments(self.mainGui)
self.tabEditor = GuiPreferencesEditor(self.theParent) self.tabEditor = GuiPreferencesEditor(self.mainGui)
self.tabSyntax = GuiPreferencesSyntax(self.theParent) self.tabSyntax = GuiPreferencesSyntax(self.mainGui)
self.tabAuto = GuiPreferencesAutomation(self.theParent) self.tabAuto = GuiPreferencesAutomation(self.mainGui)
self.tabQuote = GuiPreferencesQuotes(self.theParent) self.tabQuote = GuiPreferencesQuotes(self.mainGui)
self.addTab(self.tabGeneral, self.tr("General")) self.addTab(self.tabGeneral, self.tr("General"))
self.addTab(self.tabProjects, self.tr("Projects")) self.addTab(self.tabProjects, self.tr("Projects"))
@@ -102,12 +102,12 @@ class GuiPreferences(PagedDialog):
self.tabQuote.saveValues() self.tabQuote.saveValues()
if needsRestart: if needsRestart:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Some changes will not be applied until novelWriter has been restarted." "Some changes will not be applied until novelWriter has been restarted."
), nwAlert.INFO) ), nwAlert.INFO)
if refreshTree: if refreshTree:
self.theParent.treeView.populateTree() self.mainGui.treeView.populateTree()
self._saveWindowSize() self._saveWindowSize()
self.accept() self.accept()
@@ -138,12 +138,12 @@ class GuiPreferences(PagedDialog):
class GuiPreferencesGeneral(QWidget): class GuiPreferencesGeneral(QWidget):
def __init__(self, theParent): def __init__(self, mainGui):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
# The Form # The Form
self.mainForm = QConfigLayout() self.mainForm = QConfigLayout()
@@ -344,12 +344,12 @@ class GuiPreferencesGeneral(QWidget):
class GuiPreferencesProjects(QWidget): class GuiPreferencesProjects(QWidget):
def __init__(self, theParent): def __init__(self, mainGui):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
# The Form # The Form
self.mainForm = QConfigLayout() self.mainForm = QConfigLayout()
@@ -505,12 +505,12 @@ class GuiPreferencesProjects(QWidget):
class GuiPreferencesDocuments(QWidget): class GuiPreferencesDocuments(QWidget):
def __init__(self, theParent): def __init__(self, mainGui):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
# The Form # The Form
self.mainForm = QConfigLayout() self.mainForm = QConfigLayout()
@@ -666,12 +666,12 @@ class GuiPreferencesDocuments(QWidget):
class GuiPreferencesEditor(QWidget): class GuiPreferencesEditor(QWidget):
def __init__(self, theParent): def __init__(self, mainGui):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
# The Form # The Form
self.mainForm = QConfigLayout() self.mainForm = QConfigLayout()
@@ -688,7 +688,7 @@ class GuiPreferencesEditor(QWidget):
self.spellLanguage = QComboBox(self) self.spellLanguage = QComboBox(self)
self.spellLanguage.setMaximumWidth(mW) self.spellLanguage.setMaximumWidth(mW)
langAvail = self.theParent.docEditor.spEnchant.listDictionaries() langAvail = self.mainGui.docEditor.spEnchant.listDictionaries()
if self.mainConf.hasEnchant: if self.mainConf.hasEnchant:
if langAvail: if langAvail:
for spTag, spProv in langAvail: for spTag, spProv in langAvail:
@@ -840,12 +840,12 @@ class GuiPreferencesEditor(QWidget):
class GuiPreferencesSyntax(QWidget): class GuiPreferencesSyntax(QWidget):
def __init__(self, theParent): def __init__(self, mainGui):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
# The Form # The Form
self.mainForm = QConfigLayout() self.mainForm = QConfigLayout()
@@ -943,12 +943,12 @@ class GuiPreferencesSyntax(QWidget):
class GuiPreferencesAutomation(QWidget): class GuiPreferencesAutomation(QWidget):
def __init__(self, theParent): def __init__(self, mainGui):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
# The Form # The Form
self.mainForm = QConfigLayout() self.mainForm = QConfigLayout()
@@ -1100,12 +1100,12 @@ class GuiPreferencesAutomation(QWidget):
class GuiPreferencesQuotes(QWidget): class GuiPreferencesQuotes(QWidget):
def __init__(self, theParent): def __init__(self, mainGui):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
# The Form # The Form
self.mainForm = QConfigLayout() self.mainForm = QConfigLayout()
+14 -14
View File
@@ -43,15 +43,15 @@ logger = logging.getLogger(__name__)
class GuiProjectDetails(PagedDialog): class GuiProjectDetails(PagedDialog):
def __init__(self, theParent): def __init__(self, mainGui):
PagedDialog.__init__(self, theParent) PagedDialog.__init__(self, mainGui)
logger.debug("Initialising GuiProjectDetails ...") logger.debug("Initialising GuiProjectDetails ...")
self.setObjectName("GuiProjectDetails") self.setObjectName("GuiProjectDetails")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theProject = theParent.theProject self.theProject = mainGui.theProject
self.setWindowTitle(self.tr("Project Details")) self.setWindowTitle(self.tr("Project Details"))
@@ -66,8 +66,8 @@ class GuiProjectDetails(PagedDialog):
self.mainConf.pxInt(pOptions.getInt("GuiProjectDetails", "winHeight", wH)) self.mainConf.pxInt(pOptions.getInt("GuiProjectDetails", "winHeight", wH))
) )
self.tabMain = GuiProjectDetailsMain(self.theParent, self.theProject) self.tabMain = GuiProjectDetailsMain(self.mainGui, self.theProject)
self.tabContents = GuiProjectDetailsContents(self.theParent, self.theProject) self.tabContents = GuiProjectDetailsContents(self.mainGui, self.theProject)
self.addTab(self.tabMain, self.tr("Overview")) self.addTab(self.tabMain, self.tr("Overview"))
self.addTab(self.tabContents, self.tr("Contents")) self.addTab(self.tabContents, self.tr("Contents"))
@@ -139,13 +139,13 @@ class GuiProjectDetails(PagedDialog):
class GuiProjectDetailsMain(QWidget): class GuiProjectDetailsMain(QWidget):
def __init__(self, theParent, theProject): def __init__(self, mainGui, theProject):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent
self.theProject = theProject self.theProject = theProject
self.theTheme = theParent.theTheme self.mainGui = mainGui
self.theTheme = mainGui.theTheme
fPx = self.theTheme.fontPixelSize fPx = self.theTheme.fontPixelSize
fPt = self.theTheme.fontPointSize fPt = self.theTheme.fontPointSize
@@ -271,13 +271,13 @@ class GuiProjectDetailsContents(QWidget):
C_PAGE = 3 C_PAGE = 3
C_PROG = 4 C_PROG = 4
def __init__(self, theParent, theProject): def __init__(self, mainGui, theProject):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent
self.theProject = theProject self.theProject = theProject
self.theTheme = theParent.theTheme self.mainGui = mainGui
self.theTheme = mainGui.theTheme
# Internal # Internal
self._theToC = [] self._theToC = []
+7 -7
View File
@@ -53,15 +53,15 @@ class GuiProjectLoad(QDialog):
C_COUNT = 1 C_COUNT = 1
C_TIME = 2 C_TIME = 2
def __init__(self, theParent): def __init__(self, mainGui):
QDialog.__init__(self, theParent) QDialog.__init__(self, mainGui)
logger.debug("Initialising GuiProjectLoad ...") logger.debug("Initialising GuiProjectLoad ...")
self.setObjectName("GuiProjectLoad") self.setObjectName("GuiProjectLoad")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.openState = self.NONE_STATE self.openState = self.NONE_STATE
self.openPath = None self.openPath = None
@@ -80,7 +80,7 @@ class GuiProjectLoad(QDialog):
self.setModal(True) self.setModal(True)
self.nwIcon = QLabel() self.nwIcon = QLabel()
self.nwIcon.setPixmap(self.theParent.theTheme.getPixmap("novelwriter", (nPx, nPx))) self.nwIcon.setPixmap(self.mainGui.theTheme.getPixmap("novelwriter", (nPx, nPx)))
self.innerBox.addWidget(self.nwIcon, 0, Qt.AlignTop) self.innerBox.addWidget(self.nwIcon, 0, Qt.AlignTop)
self.projectForm = QGridLayout() self.projectForm = QGridLayout()
@@ -225,7 +225,7 @@ class GuiProjectLoad(QDialog):
selList = self.listBox.selectedItems() selList = self.listBox.selectedItems()
if selList: if selList:
projName = selList[0].text(self.C_NAME) projName = selList[0].text(self.C_NAME)
msgYes = self.theParent.askQuestion( msgYes = self.mainGui.askQuestion(
self.tr("Remove Entry"), self.tr("Remove Entry"),
self.tr( self.tr(
"Remove '{0}' from the recent projects list? " "Remove '{0}' from the recent projects list? "
@@ -280,7 +280,7 @@ class GuiProjectLoad(QDialog):
sortList = sorted(dataList, key=lambda x: x[1], reverse=True) sortList = sorted(dataList, key=lambda x: x[1], reverse=True)
for theTitle, theTime, theWords, projPath in sortList: for theTitle, theTime, theWords, projPath in sortList:
newItem = QTreeWidgetItem([""]*4) newItem = QTreeWidgetItem([""]*4)
newItem.setIcon(self.C_NAME, self.theParent.theTheme.getIcon("proj_nwx")) newItem.setIcon(self.C_NAME, self.mainGui.theTheme.getIcon("proj_nwx"))
newItem.setText(self.C_NAME, theTitle) newItem.setText(self.C_NAME, theTitle)
newItem.setData(self.C_NAME, Qt.UserRole, projPath) newItem.setData(self.C_NAME, Qt.UserRole, projPath)
newItem.setText(self.C_COUNT, formatInt(theWords)) newItem.setText(self.C_COUNT, formatInt(theWords))
+24 -24
View File
@@ -43,15 +43,15 @@ logger = logging.getLogger(__name__)
class GuiProjectSettings(PagedDialog): class GuiProjectSettings(PagedDialog):
def __init__(self, theParent): def __init__(self, mainGui):
PagedDialog.__init__(self, theParent) PagedDialog.__init__(self, mainGui)
logger.debug("Initialising GuiProjectSettings ...") logger.debug("Initialising GuiProjectSettings ...")
self.setObjectName("GuiProjectSettings") self.setObjectName("GuiProjectSettings")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theProject = theParent.theProject self.theProject = mainGui.theProject
self.theProject.countStatus() self.theProject.countStatus()
self.setWindowTitle(self.tr("Project Settings")) self.setWindowTitle(self.tr("Project Settings"))
@@ -67,10 +67,10 @@ class GuiProjectSettings(PagedDialog):
self.mainConf.pxInt(pOptions.getInt("GuiProjectSettings", "winHeight", wH)) self.mainConf.pxInt(pOptions.getInt("GuiProjectSettings", "winHeight", wH))
) )
self.tabMain = GuiProjectEditMain(self.theParent, self.theProject) self.tabMain = GuiProjectEditMain(self.mainGui, self.theProject)
self.tabStatus = GuiProjectEditStatus(self.theParent, self.theProject, True) self.tabStatus = GuiProjectEditStatus(self.mainGui, self.theProject, True)
self.tabImport = GuiProjectEditStatus(self.theParent, self.theProject, False) self.tabImport = GuiProjectEditStatus(self.mainGui, self.theProject, False)
self.tabReplace = GuiProjectEditReplace(self.theParent, self.theProject) self.tabReplace = GuiProjectEditReplace(self.mainGui, self.theProject)
self.addTab(self.tabMain, self.tr("Settings")) self.addTab(self.tabMain, self.tr("Settings"))
self.addTab(self.tabStatus, self.tr("Status")) self.addTab(self.tabStatus, self.tr("Status"))
@@ -121,7 +121,7 @@ class GuiProjectSettings(PagedDialog):
self.theProject.setImportColours(newList, delList) self.theProject.setImportColours(newList, delList)
if self.tabStatus.colChanged or self.tabImport.colChanged: if self.tabStatus.colChanged or self.tabImport.colChanged:
self.theParent.rebuildTrees() self.mainGui.rebuildTrees()
if self.tabReplace.arChanged: if self.tabReplace.arChanged:
newList = self.tabReplace.getNewList() newList = self.tabReplace.getNewList()
@@ -166,22 +166,22 @@ class GuiProjectSettings(PagedDialog):
class GuiProjectEditMain(QWidget): class GuiProjectEditMain(QWidget):
def __init__(self, theParent, theProject): def __init__(self, mainGui, theProject):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theProject = theProject self.theProject = theProject
# The Form # The Form
self.mainForm = QConfigLayout() self.mainForm = QConfigLayout()
self.mainForm.setHelpTextStyle(self.theParent.theTheme.helpText) self.mainForm.setHelpTextStyle(self.mainGui.theTheme.helpText)
self.setLayout(self.mainForm) self.setLayout(self.mainForm)
self.mainForm.addGroupLabel(self.tr("Project Settings")) self.mainForm.addGroupLabel(self.tr("Project Settings"))
xW = self.mainConf.pxInt(250) xW = self.mainConf.pxInt(250)
xH = round(4.8*self.theParent.theTheme.fontPixelSize) xH = round(4.8*self.mainGui.theTheme.fontPixelSize)
self.editName = QLineEdit() self.editName = QLineEdit()
self.editName.setMaxLength(200) self.editName.setMaxLength(200)
@@ -216,7 +216,7 @@ class GuiProjectEditMain(QWidget):
self.spellLang = QComboBox(self) self.spellLang = QComboBox(self)
self.spellLang.setMaximumWidth(xW) self.spellLang.setMaximumWidth(xW)
self.spellLang.addItem(self.tr("Default"), "None") self.spellLang.addItem(self.tr("Default"), "None")
langAvail = self.theParent.docEditor.spEnchant.listDictionaries() langAvail = self.mainGui.docEditor.spEnchant.listDictionaries()
for spTag, spProv in langAvail: for spTag, spProv in langAvail:
qLocal = QLocale(spTag) qLocal = QLocale(spTag)
spLang = qLocal.nativeLanguageName().title() spLang = qLocal.nativeLanguageName().title()
@@ -256,13 +256,13 @@ class GuiProjectEditStatus(QWidget):
COL_ROLE = Qt.UserRole + 1 COL_ROLE = Qt.UserRole + 1
NUM_ROLE = Qt.UserRole + 2 NUM_ROLE = Qt.UserRole + 2
def __init__(self, theParent, theProject, isStatus): def __init__(self, mainGui, theProject, isStatus):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theProject = theProject self.theProject = theProject
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
if isStatus: if isStatus:
self.theStatus = self.theProject.statusItems self.theStatus = self.theProject.statusItems
@@ -411,7 +411,7 @@ class GuiProjectEditStatus(QWidget):
if selItem is not None: if selItem is not None:
iRow = self.listBox.indexOfTopLevelItem(selItem) iRow = self.listBox.indexOfTopLevelItem(selItem)
if selItem.data(self.COL_LABEL, self.NUM_ROLE) > 0: if selItem.data(self.COL_LABEL, self.NUM_ROLE) > 0:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Cannot delete a status item that is in use." "Cannot delete a status item that is in use."
), nwAlert.ERROR) ), nwAlert.ERROR)
else: else:
@@ -527,12 +527,12 @@ class GuiProjectEditReplace(QWidget):
COL_KEY = 0 COL_KEY = 0
COL_REPL = 1 COL_REPL = 1
def __init__(self, theParent, theProject): def __init__(self, mainGui, theProject):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.theProject = theProject self.theProject = theProject
self.arChanged = False self.arChanged = False
+2 -2
View File
@@ -42,8 +42,8 @@ class GuiQuoteSelect(QDialog):
selectedQuote = "" selectedQuote = ""
def __init__(self, theParent=None, currentQuote='"'): def __init__(self, parent=None, currentQuote='"'):
QDialog.__init__(self, parent=theParent) QDialog.__init__(self, parent=parent)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
+5 -5
View File
@@ -43,14 +43,14 @@ logger = logging.getLogger(__name__)
class GuiUpdates(QDialog): class GuiUpdates(QDialog):
def __init__(self, theParent): def __init__(self, mainGui):
QDialog.__init__(self, theParent) QDialog.__init__(self, mainGui)
logger.debug("Initialising GuiUpdates ...") logger.debug("Initialising GuiUpdates ...")
self.setObjectName("GuiUpdates") self.setObjectName("GuiUpdates")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.setWindowTitle(self.tr("Check for Updates")) self.setWindowTitle(self.tr("Check for Updates"))
@@ -61,7 +61,7 @@ class GuiUpdates(QDialog):
# Left Box # Left Box
self.nwIcon = QLabel() self.nwIcon = QLabel()
self.nwIcon.setPixmap(self.theParent.theTheme.getPixmap("novelwriter", (nPx, nPx))) self.nwIcon.setPixmap(self.mainGui.theTheme.getPixmap("novelwriter", (nPx, nPx)))
self.leftBox = QVBoxLayout() self.leftBox = QVBoxLayout()
self.leftBox.addWidget(self.nwIcon) self.leftBox.addWidget(self.nwIcon)
+7 -7
View File
@@ -42,16 +42,16 @@ logger = logging.getLogger(__name__)
class GuiWordList(QDialog): class GuiWordList(QDialog):
def __init__(self, theParent): def __init__(self, mainGui):
QDialog.__init__(self, theParent) QDialog.__init__(self, mainGui)
logger.debug("Initialising GuiWordList ...") logger.debug("Initialising GuiWordList ...")
self.setObjectName("GuiWordList") self.setObjectName("GuiWordList")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.theProject = theParent.theProject self.theProject = mainGui.theProject
self.setWindowTitle(self.tr("Project Word List")) self.setWindowTitle(self.tr("Project Word List"))
@@ -121,13 +121,13 @@ class GuiWordList(QDialog):
""" """
newWord = self.newEntry.text().strip() newWord = self.newEntry.text().strip()
if newWord == "": if newWord == "":
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Cannot add a blank word." "Cannot add a blank word."
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
if self.listBox.findItems(newWord, Qt.MatchExactly): if self.listBox.findItems(newWord, Qt.MatchExactly):
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"The word '{0}' is already in the word list." "The word '{0}' is already in the word list."
).format(newWord), nwAlert.ERROR) ).format(newWord), nwAlert.ERROR)
return False return False
+4 -4
View File
@@ -376,8 +376,8 @@ class QSwitch(QAbstractButton):
class PagedDialog(QDialog): class PagedDialog(QDialog):
def __init__(self, theParent=None): def __init__(self, parent=None):
QDialog.__init__(self, parent=theParent) QDialog.__init__(self, parent=parent)
self._tabBar = VerticalTabBar(self) self._tabBar = VerticalTabBar(self)
self._tabBar.setExpanding(False) self._tabBar.setExpanding(False)
@@ -426,8 +426,8 @@ class PagedDialog(QDialog):
class VerticalTabBar(QTabBar): class VerticalTabBar(QTabBar):
def __init__(self, theParent=None): def __init__(self, parent=None):
QTabBar.__init__(self, parent=theParent) QTabBar.__init__(self, parent=parent)
self._mW = novelwriter.CONFIG.pxInt(150) self._mW = novelwriter.CONFIG.pxInt(150)
return return
+35 -35
View File
@@ -72,16 +72,16 @@ class GuiDocEditor(QTextEdit):
docCountsChanged = pyqtSignal(str, int, int, int) docCountsChanged = pyqtSignal(str, int, int, int)
loadDocumentTagRequest = pyqtSignal(str, Enum) loadDocumentTagRequest = pyqtSignal(str, Enum)
def __init__(self, theParent): def __init__(self, mainGui):
QTextEdit.__init__(self, theParent) QTextEdit.__init__(self, mainGui)
logger.debug("Initialising GuiDocEditor ...") logger.debug("Initialising GuiDocEditor ...")
# Class Variables # Class Variables
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.theProject = theParent.theProject self.theProject = mainGui.theProject
self._nwDocument = None self._nwDocument = None
self._nwItem = None self._nwItem = None
@@ -124,7 +124,7 @@ class GuiDocEditor(QTextEdit):
# Syntax # Syntax
self.spEnchant = NWSpellEnchant() self.spEnchant = NWSpellEnchant()
self.highLight = GuiDocHighlighter(qDoc, self.theParent, self.spEnchant) self.highLight = GuiDocHighlighter(qDoc, self.mainGui, self.spEnchant)
# Context Menu # Context Menu
self.setContextMenuPolicy(Qt.CustomContextMenu) self.setContextMenuPolicy(Qt.CustomContextMenu)
@@ -341,7 +341,7 @@ class GuiDocEditor(QTextEdit):
docSize = len(theDoc) docSize = len(theDoc)
if docSize > nwConst.MAX_DOCSIZE: if docSize > nwConst.MAX_DOCSIZE:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"The document you are trying to open is too big. " "The document you are trying to open is too big. "
"The document size is {0} MB. " "The document size is {0} MB. "
"The maximum size allowed is {1} MB." "The maximum size allowed is {1} MB."
@@ -417,7 +417,7 @@ class GuiDocEditor(QTextEdit):
# Update the status bar # Update the status bar
if self._nwItem is not None: if self._nwItem is not None:
self.theParent.setStatus( self.mainGui.setStatus(
self.tr("Opened Document: {0}").format(self._nwItem.itemName) self.tr("Opened Document: {0}").format(self._nwItem.itemName)
) )
@@ -442,7 +442,7 @@ class GuiDocEditor(QTextEdit):
""" """
docSize = len(theText) docSize = len(theText)
if docSize > nwConst.MAX_DOCSIZE: if docSize > nwConst.MAX_DOCSIZE:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"The text you are trying to add is too big. " "The text you are trying to add is too big. "
"The text size is {0} MB. " "The text size is {0} MB. "
"The maximum size allowed is {1} MB." "The maximum size allowed is {1} MB."
@@ -488,7 +488,7 @@ class GuiDocEditor(QTextEdit):
if not self._nwDocument.writeDocument(docText): if not self._nwDocument.writeDocument(docText):
saveOk = False saveOk = False
if self._nwDocument._currHash != self._nwDocument._prevHash: if self._nwDocument._currHash != self._nwDocument._prevHash:
msgYes = self.theParent.askQuestion( msgYes = self.mainGui.askQuestion(
self.tr("File Changed on Disk"), self.tr("File Changed on Disk"),
self.tr( self.tr(
"This document has been changed outside of novelWriter " "This document has been changed outside of novelWriter "
@@ -499,7 +499,7 @@ class GuiDocEditor(QTextEdit):
saveOk = self._nwDocument.writeDocument(docText, forceWrite=True) saveOk = self._nwDocument.writeDocument(docText, forceWrite=True)
if not saveOk: if not saveOk:
self.theParent.makeAlert([ self.mainGui.makeAlert([
self.tr("Could not save document."), self._nwDocument.getError() self.tr("Could not save document."), self._nwDocument.getError()
], nwAlert.ERROR) ], nwAlert.ERROR)
@@ -512,17 +512,17 @@ class GuiDocEditor(QTextEdit):
newHeader = self.theProject.index.getHandleHeaderLevel(tHandle) newHeader = self.theProject.index.getHandleHeaderLevel(tHandle)
if self._updateHeaders(checkLevel=True): if self._updateHeaders(checkLevel=True):
self.theParent.requestNovelTreeRefresh() self.mainGui.requestNovelTreeRefresh()
else: else:
self.theParent.novelView.updateWordCounts(tHandle) self.mainGui.novelView.updateWordCounts(tHandle)
if oldHeader != newHeader: if oldHeader != newHeader:
self.theParent.treeView.setTreeItemValues(tHandle) self.mainGui.treeView.setTreeItemValues(tHandle)
self.theParent.treeMeta.updateViewBox(tHandle) self.mainGui.treeMeta.updateViewBox(tHandle)
self.docFooter.updateInfo() self.docFooter.updateInfo()
# Update the status bar # Update the status bar
self.theParent.setStatus( self.mainGui.setStatus(
self.tr("Saved Document: {0}").format(self._nwItem.itemName) self.tr("Saved Document: {0}").format(self._nwItem.itemName)
) )
@@ -544,8 +544,8 @@ class GuiDocEditor(QTextEdit):
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 or self.theParent.isFocusMode: if self.mainConf.textWidth > 0 or self.mainGui.isFocusMode:
tW = self.mainConf.getTextWidth(self.theParent.isFocusMode) tW = self.mainConf.getTextWidth(self.mainGui.isFocusMode)
tM = max((wW - sW - tW)//2, cM) tM = max((wW - sW - tW)//2, cM)
tB = self.frameWidth() tB = self.frameWidth()
@@ -704,7 +704,7 @@ class GuiDocEditor(QTextEdit):
if not self.mainConf.hasEnchant: if not self.mainConf.hasEnchant:
if theMode: if theMode:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Spell checking requires the package PyEnchant. " "Spell checking requires the package PyEnchant. "
"It does not appear to be installed." "It does not appear to be installed."
), nwAlert.INFO) ), nwAlert.INFO)
@@ -714,7 +714,7 @@ class GuiDocEditor(QTextEdit):
theMode = False theMode = False
self._spellCheck = theMode self._spellCheck = theMode
self.theParent.mainMenu.setSpellCheck(theMode) self.mainGui.mainMenu.setSpellCheck(theMode)
self.theProject.setSpellCheck(theMode) self.theProject.setSpellCheck(theMode)
self.highLight.setSpellCheck(theMode) self.highLight.setSpellCheck(theMode)
if not self._bigDoc: if not self._bigDoc:
@@ -742,7 +742,7 @@ class GuiDocEditor(QTextEdit):
qApp.restoreOverrideCursor() qApp.restoreOverrideCursor()
afTime = time() afTime = time()
logger.debug("Document highlighted in %.3f ms", 1000*(afTime-bfTime)) logger.debug("Document highlighted in %.3f ms", 1000*(afTime-bfTime))
self.theParent.statusBar.setStatus(self.tr("Spell check complete")) self.mainGui.statusBar.setStatus(self.tr("Spell check complete"))
return True return True
@@ -1085,7 +1085,7 @@ class GuiDocEditor(QTextEdit):
self._lastFind = None self._lastFind = None
if self.document().characterCount() > nwConst.MAX_DOCSIZE: if self.document().characterCount() > nwConst.MAX_DOCSIZE:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"The document has grown too big and you cannot add more text to it. " "The document has grown too big and you cannot add more text to it. "
"The maximum size of a single novelWriter document is {0} MB." "The maximum size of a single novelWriter document is {0} MB."
).format( ).format(
@@ -1245,7 +1245,7 @@ class GuiDocEditor(QTextEdit):
if time() - self._lastEdit < 5 * self.wcInterval: if time() - self._lastEdit < 5 * self.wcInterval:
logger.verbose("Running word counter") logger.verbose("Running word counter")
self.theParent.threadPool.start(self.wCounterDoc) self.mainGui.threadPool.start(self.wCounterDoc)
return return
@@ -1302,7 +1302,7 @@ class GuiDocEditor(QTextEdit):
logger.verbose("Selection word counter is busy") logger.verbose("Selection word counter is busy")
return return
self.theParent.threadPool.start(self.wCounterSel) self.mainGui.threadPool.start(self.wCounterSel)
return return
@@ -1381,7 +1381,7 @@ class GuiDocEditor(QTextEdit):
self.docSearch.setResultCount(0, 0) self.docSearch.setResultCount(0, 0)
self._lastFind = None self._lastFind = None
if self.docSearch.doNextFile and not goBack: if self.docSearch.doNextFile and not goBack:
self.theParent.openNextDocument( self.mainGui.openNextDocument(
self._docHandle, wrapAround=self.docSearch.doLoop self._docHandle, wrapAround=self.docSearch.doLoop
) )
self.beginSearch() self.beginSearch()
@@ -1401,7 +1401,7 @@ class GuiDocEditor(QTextEdit):
if resIdx > maxIdx: if resIdx > maxIdx:
if self.docSearch.doNextFile and not goBack: if self.docSearch.doNextFile and not goBack:
self.theParent.openNextDocument( self.mainGui.openNextDocument(
self._docHandle, wrapAround=self.docSearch.doLoop self._docHandle, wrapAround=self.docSearch.doLoop
) )
self.beginSearch() self.beginSearch()
@@ -1645,7 +1645,7 @@ class GuiDocEditor(QTextEdit):
""" """
theCursor = self.textCursor() theCursor = self.textCursor()
if not theCursor.hasSelection(): if not theCursor.hasSelection():
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Please select some text before calling replace quotes." "Please select some text before calling replace quotes."
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
@@ -2187,7 +2187,7 @@ class GuiDocEditSearch(QFrame):
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.docEditor = docEditor self.docEditor = docEditor
self.theParent = docEditor.theParent self.mainGui = docEditor.mainGui
self.theProject = docEditor.theProject self.theProject = docEditor.theProject
self.theTheme = docEditor.theTheme self.theTheme = docEditor.theTheme
@@ -2575,7 +2575,7 @@ class GuiDocEditHeader(QWidget):
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.docEditor = docEditor self.docEditor = docEditor
self.theParent = docEditor.theParent self.mainGui = docEditor.mainGui
self.theProject = docEditor.theProject self.theProject = docEditor.theProject
self.theTheme = docEditor.theTheme self.theTheme = docEditor.theTheme
@@ -2733,7 +2733,7 @@ class GuiDocEditHeader(QWidget):
This function is called by the GuiMain class via the This function is called by the GuiMain class via the
toggleFocusMode function and should not be activated directly. toggleFocusMode function and should not be activated directly.
""" """
if self.theParent.isFocusMode: if self.mainGui.isFocusMode:
self.minmaxButton.setIcon(self.theTheme.getIcon("minimise")) self.minmaxButton.setIcon(self.theTheme.getIcon("minimise"))
else: else:
self.minmaxButton.setIcon(self.theTheme.getIcon("maximise")) self.minmaxButton.setIcon(self.theTheme.getIcon("maximise"))
@@ -2746,7 +2746,7 @@ class GuiDocEditHeader(QWidget):
def _editDocument(self): def _editDocument(self):
"""Open the edit item dialog from the main GUI. """Open the edit item dialog from the main GUI.
""" """
self.theParent.editItem(self._docHandle) self.mainGui.editItem(self._docHandle)
return return
def _searchDocument(self): def _searchDocument(self):
@@ -2758,7 +2758,7 @@ class GuiDocEditHeader(QWidget):
def _closeDocument(self): def _closeDocument(self):
"""Trigger the close editor on the main window. """Trigger the close editor on the main window.
""" """
self.theParent.closeDocEditor() self.mainGui.closeDocEditor()
self.editButton.setVisible(False) self.editButton.setVisible(False)
self.searchButton.setVisible(False) self.searchButton.setVisible(False)
self.closeButton.setVisible(False) self.closeButton.setVisible(False)
@@ -2768,7 +2768,7 @@ class GuiDocEditHeader(QWidget):
def _minmaxDocument(self): def _minmaxDocument(self):
"""Switch on or off Focus Mode. """Switch on or off Focus Mode.
""" """
self.theParent.toggleFocusMode() self.mainGui.toggleFocusMode()
return return
## ##
@@ -2779,7 +2779,7 @@ class GuiDocEditHeader(QWidget):
"""Capture a click on the title and ensure that the item is """Capture a click on the title and ensure that the item is
selected in the project tree. selected in the project tree.
""" """
self.theParent.treeView.setSelectedHandle(self._docHandle, doScroll=True) self.mainGui.treeView.setSelectedHandle(self._docHandle, doScroll=True)
return return
# END Class GuiDocEditHeader # END Class GuiDocEditHeader
@@ -2799,7 +2799,7 @@ class GuiDocEditFooter(QWidget):
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.docEditor = docEditor self.docEditor = docEditor
self.theParent = docEditor.theParent self.mainGui = docEditor.mainGui
self.theProject = docEditor.theProject self.theProject = docEditor.theProject
self.theTheme = docEditor.theTheme self.theTheme = docEditor.theTheme
+5 -5
View File
@@ -46,16 +46,16 @@ class GuiDocHighlighter(QSyntaxHighlighter):
BLOCK_META = 2 BLOCK_META = 2
BLOCK_TITLE = 4 BLOCK_TITLE = 4
def __init__(self, theDoc, theParent, spEnchant): def __init__(self, theDoc, mainGui, spEnchant):
QSyntaxHighlighter.__init__(self, theDoc) QSyntaxHighlighter.__init__(self, theDoc)
logger.debug("Initialising GuiDocHighlighter ...") logger.debug("Initialising GuiDocHighlighter ...")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theDoc = theDoc self.theDoc = theDoc
self.spEnchant = spEnchant self.spEnchant = spEnchant
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.theProject = theParent.theProject self.theProject = mainGui.theProject
self.theHandle = None self.theHandle = None
self.spellCheck = False self.spellCheck = False
self.spellRx = None self.spellRx = None
@@ -288,7 +288,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
if theText.startswith("@"): # Keywords and commands if theText.startswith("@"): # Keywords and commands
self.setCurrentBlockState(self.BLOCK_META) self.setCurrentBlockState(self.BLOCK_META)
pIndex = self.theProject.index pIndex = self.theProject.index
tItem = self.theParent.theProject.tree[self.theHandle] tItem = self.mainGui.theProject.tree[self.theHandle]
isValid, theBits, thePos = pIndex.scanThis(theText) isValid, theBits, thePos = pIndex.scanThis(theText)
isGood = pIndex.checkThese(theBits, tItem) isGood = pIndex.checkThese(theBits, tItem)
if isValid: if isValid:
+20 -20
View File
@@ -53,16 +53,16 @@ class GuiDocViewer(QTextBrowser):
loadDocumentTagRequest = pyqtSignal(str, Enum) loadDocumentTagRequest = pyqtSignal(str, Enum)
def __init__(self, theParent): def __init__(self, mainGui):
QTextBrowser.__init__(self, theParent) QTextBrowser.__init__(self, mainGui)
logger.debug("Initialising GuiDocViewer ...") logger.debug("Initialising GuiDocViewer ...")
# Class Variables # Class Variables
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.theProject = theParent.theProject self.theProject = mainGui.theProject
# Internal Variables # Internal Variables
self._docHandle = None self._docHandle = None
@@ -221,7 +221,7 @@ class GuiDocViewer(QTextBrowser):
self.updateDocMargins() self.updateDocMargins()
# Make sure the main GUI knows we changed the content # Make sure the main GUI knows we changed the content
self.theParent.viewMeta.refreshReferences(tHandle) self.mainGui.viewMeta.refreshReferences(tHandle)
# Since we change the content while it may still be rendering, we mark # Since we change the content while it may still be rendering, we mark
# the document dirty again to make sure it's re-rendered properly. # the document dirty again to make sure it's re-rendered properly.
@@ -714,7 +714,7 @@ class GuiDocViewHeader(QWidget):
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.docViewer = docViewer self.docViewer = docViewer
self.theParent = docViewer.theParent self.mainGui = docViewer.mainGui
self.theProject = docViewer.theProject self.theProject = docViewer.theProject
self.theTheme = docViewer.theTheme self.theTheme = docViewer.theTheme
@@ -882,14 +882,14 @@ class GuiDocViewHeader(QWidget):
def _closeDocument(self): def _closeDocument(self):
"""Trigger the close editor/viewer on the main window. """Trigger the close editor/viewer on the main window.
""" """
self.theParent.closeDocViewer() self.mainGui.closeDocViewer()
return return
def _refreshDocument(self): def _refreshDocument(self):
"""Reload the content of the document. """Reload the content of the document.
""" """
if self.docViewer.docHandle() == self.theParent.docEditor.docHandle(): if self.docViewer.docHandle() == self.mainGui.docEditor.docHandle():
self.theParent.saveDocument() self.mainGui.saveDocument()
self.docViewer.reloadText() self.docViewer.reloadText()
return return
@@ -901,7 +901,7 @@ class GuiDocViewHeader(QWidget):
"""Capture a click on the title and ensure that the item is """Capture a click on the title and ensure that the item is
selected in the project tree. selected in the project tree.
""" """
self.theParent.treeView.setSelectedHandle(self._docHandle, doScroll=True) self.mainGui.treeView.setSelectedHandle(self._docHandle, doScroll=True)
return return
# END Class GuiDocViewHeader # END Class GuiDocViewHeader
@@ -921,9 +921,9 @@ class GuiDocViewFooter(QWidget):
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.docViewer = docViewer self.docViewer = docViewer
self.theParent = docViewer.theParent self.mainGui = docViewer.mainGui
self.theTheme = docViewer.theTheme self.theTheme = docViewer.theTheme
self.viewMeta = docViewer.theParent.viewMeta self.viewMeta = docViewer.mainGui.viewMeta
# Internal Variables # Internal Variables
self._docHandle = None self._docHandle = None
@@ -1140,14 +1140,14 @@ class GuiDocViewFooter(QWidget):
class GuiDocViewDetails(QScrollArea): class GuiDocViewDetails(QScrollArea):
def __init__(self, theParent): def __init__(self, mainGui):
QScrollArea.__init__(self, theParent) QScrollArea.__init__(self, mainGui)
logger.debug("Initialising GuiDocViewDetails ...") logger.debug("Initialising GuiDocViewDetails ...")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theProject = theParent.theProject self.theProject = mainGui.theProject
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.refList = QLabel("") self.refList = QLabel("")
self.refList.setWordWrap(True) self.refList.setWordWrap(True)
@@ -1181,7 +1181,7 @@ class GuiDocViewDetails(QScrollArea):
"""Update the current list of document references from the """Update the current list of document references from the
project index. project index.
""" """
if self.theParent.docViewer.stickyRef: if self.mainGui.docViewer.stickyRef:
return return
theRefs = self.theProject.index.getBackReferenceList(tHandle) theRefs = self.theProject.index.getBackReferenceList(tHandle)
@@ -1209,7 +1209,7 @@ class GuiDocViewDetails(QScrollArea):
if len(theLink) == 21: if len(theLink) == 21:
tHandle = theLink[:13] tHandle = theLink[:13]
tAnchor = theLink[13:] tAnchor = theLink[13:]
self.theParent.viewDocument(tHandle, tAnchor) self.mainGui.viewDocument(tHandle, tAnchor)
return return
# END Class GuiDocViewDetails # END Class GuiDocViewDetails
+5 -5
View File
@@ -38,14 +38,14 @@ logger = logging.getLogger(__name__)
class GuiItemDetails(QWidget): class GuiItemDetails(QWidget):
def __init__(self, theParent): def __init__(self, mainGui):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
logger.debug("Initialising GuiItemDetails ...") logger.debug("Initialising GuiItemDetails ...")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theProject = theParent.theProject self.theProject = mainGui.theProject
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
# Internal Variables # Internal Variables
self._itemHandle = None self._itemHandle = None
+51 -51
View File
@@ -41,13 +41,13 @@ logger = logging.getLogger(__name__)
class GuiMainMenu(QMenuBar): class GuiMainMenu(QMenuBar):
def __init__(self, theParent): def __init__(self, mainGui):
QMenuBar.__init__(self, theParent) QMenuBar.__init__(self, mainGui)
logger.debug("Initialising GuiMainMenu ...") logger.debug("Initialising GuiMainMenu ...")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theProject = theParent.theProject self.theProject = mainGui.theProject
# Build Menu # Build Menu
self._buildProjectMenu() self._buildProjectMenu()
@@ -61,9 +61,9 @@ class GuiMainMenu(QMenuBar):
self._buildHelpMenu() self._buildHelpMenu()
# Function Pointers # Function Pointers
self._docAction = self.theParent.passDocumentAction self._docAction = self.mainGui.passDocumentAction
self._docInsert = self.theParent.docEditor.insertText self._docInsert = self.mainGui.docEditor.insertText
self._insertKeyWord = self.theParent.docEditor.insertKeyWord self._insertKeyWord = self.mainGui.docEditor.insertKeyWord
logger.debug("GuiMainMenu initialisation complete") logger.debug("GuiMainMenu initialisation complete")
@@ -94,7 +94,7 @@ class GuiMainMenu(QMenuBar):
flag is handled by the document editor class, so we make no flag is handled by the document editor class, so we make no
decision, just pass a None to the function and let it decide. decision, just pass a None to the function and let it decide.
""" """
self.theParent.docEditor.toggleSpellCheck(None) self.mainGui.docEditor.toggleSpellCheck(None)
return True return True
def _openWebsite(self, theUrl): def _openWebsite(self, theUrl):
@@ -123,25 +123,25 @@ class GuiMainMenu(QMenuBar):
# Project > New Project # Project > New Project
self.aNewProject = QAction(self.tr("New Project"), self) self.aNewProject = QAction(self.tr("New Project"), self)
self.aNewProject.triggered.connect(lambda: self.theParent.newProject(None)) self.aNewProject.triggered.connect(lambda: self.mainGui.newProject(None))
self.projMenu.addAction(self.aNewProject) self.projMenu.addAction(self.aNewProject)
# Project > Open Project # Project > Open Project
self.aOpenProject = QAction(self.tr("Open Project"), self) self.aOpenProject = QAction(self.tr("Open Project"), self)
self.aOpenProject.setShortcut("Ctrl+Shift+O") self.aOpenProject.setShortcut("Ctrl+Shift+O")
self.aOpenProject.triggered.connect(lambda: self.theParent.showProjectLoadDialog()) self.aOpenProject.triggered.connect(lambda: self.mainGui.showProjectLoadDialog())
self.projMenu.addAction(self.aOpenProject) self.projMenu.addAction(self.aOpenProject)
# Project > Save Project # Project > Save Project
self.aSaveProject = QAction(self.tr("Save Project"), self) self.aSaveProject = QAction(self.tr("Save Project"), self)
self.aSaveProject.setShortcut("Ctrl+Shift+S") self.aSaveProject.setShortcut("Ctrl+Shift+S")
self.aSaveProject.triggered.connect(lambda: self.theParent.saveProject()) self.aSaveProject.triggered.connect(lambda: self.mainGui.saveProject())
self.projMenu.addAction(self.aSaveProject) self.projMenu.addAction(self.aSaveProject)
# Project > Close Project # Project > Close Project
self.aCloseProject = QAction(self.tr("Close Project"), self) self.aCloseProject = QAction(self.tr("Close Project"), self)
self.aCloseProject.setShortcut("Ctrl+Shift+W") self.aCloseProject.setShortcut("Ctrl+Shift+W")
self.aCloseProject.triggered.connect(lambda: self.theParent.closeProject(False)) self.aCloseProject.triggered.connect(lambda: self.mainGui.closeProject(False))
self.projMenu.addAction(self.aCloseProject) self.projMenu.addAction(self.aCloseProject)
# Project > Separator # Project > Separator
@@ -150,13 +150,13 @@ class GuiMainMenu(QMenuBar):
# Project > Project Settings # Project > Project Settings
self.aProjectSettings = QAction(self.tr("Project Settings"), self) self.aProjectSettings = QAction(self.tr("Project Settings"), self)
self.aProjectSettings.setShortcut("Ctrl+Shift+,") self.aProjectSettings.setShortcut("Ctrl+Shift+,")
self.aProjectSettings.triggered.connect(lambda: self.theParent.showProjectSettingsDialog()) self.aProjectSettings.triggered.connect(lambda: self.mainGui.showProjectSettingsDialog())
self.projMenu.addAction(self.aProjectSettings) self.projMenu.addAction(self.aProjectSettings)
# Project > Project Details # Project > Project Details
self.aProjectDetails = QAction(self.tr("Project Details"), self) self.aProjectDetails = QAction(self.tr("Project Details"), self)
self.aProjectDetails.setShortcut("Shift+F6") self.aProjectDetails.setShortcut("Shift+F6")
self.aProjectDetails.triggered.connect(lambda: self.theParent.showProjectDetailsDialog()) self.aProjectDetails.triggered.connect(lambda: self.mainGui.showProjectDetailsDialog())
self.projMenu.addAction(self.aProjectDetails) self.projMenu.addAction(self.aProjectDetails)
# Project > Separator # Project > Separator
@@ -165,18 +165,18 @@ class GuiMainMenu(QMenuBar):
# Project > Edit # Project > Edit
self.aEditItem = QAction(self.tr("Edit Item"), self) self.aEditItem = QAction(self.tr("Edit Item"), self)
self.aEditItem.setShortcuts(["Ctrl+E", "F2"]) self.aEditItem.setShortcuts(["Ctrl+E", "F2"])
self.aEditItem.triggered.connect(lambda: self.theParent.editItem(None)) self.aEditItem.triggered.connect(lambda: self.mainGui.editItem(None))
self.projMenu.addAction(self.aEditItem) self.projMenu.addAction(self.aEditItem)
# Project > Delete # Project > Delete
self.aDeleteItem = QAction(self.tr("Delete Item"), self) self.aDeleteItem = QAction(self.tr("Delete Item"), self)
self.aDeleteItem.setShortcut("Ctrl+Shift+Del") self.aDeleteItem.setShortcut("Ctrl+Shift+Del")
self.aDeleteItem.triggered.connect(lambda: self.theParent.treeView.deleteItem(None)) self.aDeleteItem.triggered.connect(lambda: self.mainGui.treeView.deleteItem(None))
self.projMenu.addAction(self.aDeleteItem) self.projMenu.addAction(self.aDeleteItem)
# Project > Empty Trash # Project > Empty Trash
self.aEmptyTrash = QAction(self.tr("Empty Trash"), self) self.aEmptyTrash = QAction(self.tr("Empty Trash"), self)
self.aEmptyTrash.triggered.connect(lambda: self.theParent.treeView.emptyTrash()) self.aEmptyTrash.triggered.connect(lambda: self.mainGui.treeView.emptyTrash())
self.projMenu.addAction(self.aEmptyTrash) self.projMenu.addAction(self.aEmptyTrash)
# Project > Separator # Project > Separator
@@ -186,7 +186,7 @@ class GuiMainMenu(QMenuBar):
self.aExitNW = QAction(self.tr("Exit"), self) self.aExitNW = QAction(self.tr("Exit"), self)
self.aExitNW.setShortcut("Ctrl+Q") self.aExitNW.setShortcut("Ctrl+Q")
self.aExitNW.setMenuRole(QAction.QuitRole) self.aExitNW.setMenuRole(QAction.QuitRole)
self.aExitNW.triggered.connect(lambda: self.theParent.closeMain()) self.aExitNW.triggered.connect(lambda: self.mainGui.closeMain())
self.projMenu.addAction(self.aExitNW) self.projMenu.addAction(self.aExitNW)
return return
@@ -200,19 +200,19 @@ class GuiMainMenu(QMenuBar):
# Document > Open # Document > Open
self.aOpenDoc = QAction(self.tr("Open Document"), self) self.aOpenDoc = QAction(self.tr("Open Document"), self)
self.aOpenDoc.setShortcut("Ctrl+O") self.aOpenDoc.setShortcut("Ctrl+O")
self.aOpenDoc.triggered.connect(lambda: self.theParent.openSelectedItem()) self.aOpenDoc.triggered.connect(lambda: self.mainGui.openSelectedItem())
self.docuMenu.addAction(self.aOpenDoc) self.docuMenu.addAction(self.aOpenDoc)
# Document > Save # Document > Save
self.aSaveDoc = QAction(self.tr("Save Document"), self) self.aSaveDoc = QAction(self.tr("Save Document"), self)
self.aSaveDoc.setShortcut("Ctrl+S") self.aSaveDoc.setShortcut("Ctrl+S")
self.aSaveDoc.triggered.connect(lambda: self.theParent.saveDocument()) self.aSaveDoc.triggered.connect(lambda: self.mainGui.saveDocument())
self.docuMenu.addAction(self.aSaveDoc) self.docuMenu.addAction(self.aSaveDoc)
# Document > Close # Document > Close
self.aCloseDoc = QAction(self.tr("Close Document"), self) self.aCloseDoc = QAction(self.tr("Close Document"), self)
self.aCloseDoc.setShortcut("Ctrl+W") self.aCloseDoc.setShortcut("Ctrl+W")
self.aCloseDoc.triggered.connect(lambda: self.theParent.closeDocEditor()) self.aCloseDoc.triggered.connect(lambda: self.mainGui.closeDocEditor())
self.docuMenu.addAction(self.aCloseDoc) self.docuMenu.addAction(self.aCloseDoc)
# Document > Separator # Document > Separator
@@ -221,13 +221,13 @@ class GuiMainMenu(QMenuBar):
# Document > Preview # Document > Preview
self.aViewDoc = QAction(self.tr("View Document"), self) self.aViewDoc = QAction(self.tr("View Document"), self)
self.aViewDoc.setShortcut("Ctrl+R") self.aViewDoc.setShortcut("Ctrl+R")
self.aViewDoc.triggered.connect(lambda: self.theParent.viewDocument(None)) self.aViewDoc.triggered.connect(lambda: self.mainGui.viewDocument(None))
self.docuMenu.addAction(self.aViewDoc) self.docuMenu.addAction(self.aViewDoc)
# Document > Close Preview # Document > Close Preview
self.aCloseView = QAction(self.tr("Close Document View"), self) self.aCloseView = QAction(self.tr("Close Document View"), self)
self.aCloseView.setShortcut("Ctrl+Shift+R") self.aCloseView.setShortcut("Ctrl+Shift+R")
self.aCloseView.triggered.connect(lambda: self.theParent.closeDocViewer()) self.aCloseView.triggered.connect(lambda: self.mainGui.closeDocViewer())
self.docuMenu.addAction(self.aCloseView) self.docuMenu.addAction(self.aCloseView)
# Document > Separator # Document > Separator
@@ -235,23 +235,23 @@ class GuiMainMenu(QMenuBar):
# Document > Show File Details # Document > Show File Details
self.aFileDetails = QAction(self.tr("Show File Details"), self) self.aFileDetails = QAction(self.tr("Show File Details"), self)
self.aFileDetails.triggered.connect(lambda: self.theParent.docEditor.revealLocation()) self.aFileDetails.triggered.connect(lambda: self.mainGui.docEditor.revealLocation())
self.docuMenu.addAction(self.aFileDetails) self.docuMenu.addAction(self.aFileDetails)
# Document > Import From File # Document > Import From File
self.aImportFile = QAction(self.tr("Import Text from File"), self) self.aImportFile = QAction(self.tr("Import Text from File"), self)
self.aImportFile.setShortcut("Ctrl+Shift+I") self.aImportFile.setShortcut("Ctrl+Shift+I")
self.aImportFile.triggered.connect(lambda: self.theParent.importDocument()) self.aImportFile.triggered.connect(lambda: self.mainGui.importDocument())
self.docuMenu.addAction(self.aImportFile) self.docuMenu.addAction(self.aImportFile)
# Document > Merge Documents # Document > Merge Documents
self.aMergeDocs = QAction(self.tr("Merge Folder to Document"), self) self.aMergeDocs = QAction(self.tr("Merge Folder to Document"), self)
self.aMergeDocs.triggered.connect(lambda: self.theParent.mergeDocuments()) self.aMergeDocs.triggered.connect(lambda: self.mainGui.mergeDocuments())
self.docuMenu.addAction(self.aMergeDocs) self.docuMenu.addAction(self.aMergeDocs)
# Document > Split Document # Document > Split Document
self.aSplitDoc = QAction(self.tr("Split Document to Folder"), self) self.aSplitDoc = QAction(self.tr("Split Document to Folder"), self)
self.aSplitDoc.triggered.connect(lambda: self.theParent.splitDocument()) self.aSplitDoc.triggered.connect(lambda: self.mainGui.splitDocument())
self.docuMenu.addAction(self.aSplitDoc) self.docuMenu.addAction(self.aSplitDoc)
return return
@@ -324,7 +324,7 @@ class GuiMainMenu(QMenuBar):
self.aFocusTree.setShortcut("Ctrl+Alt+1") self.aFocusTree.setShortcut("Ctrl+Alt+1")
else: else:
self.aFocusTree.setShortcut("Alt+1") self.aFocusTree.setShortcut("Alt+1")
self.aFocusTree.triggered.connect(lambda: self.theParent.switchFocus(nwWidget.TREE)) self.aFocusTree.triggered.connect(lambda: self.mainGui.switchFocus(nwWidget.TREE))
self.viewMenu.addAction(self.aFocusTree) self.viewMenu.addAction(self.aFocusTree)
# View > Document Pane 1 # View > Document Pane 1
@@ -333,7 +333,7 @@ class GuiMainMenu(QMenuBar):
self.aFocusEditor.setShortcut("Ctrl+Alt+2") self.aFocusEditor.setShortcut("Ctrl+Alt+2")
else: else:
self.aFocusEditor.setShortcut("Alt+2") self.aFocusEditor.setShortcut("Alt+2")
self.aFocusEditor.triggered.connect(lambda: self.theParent.switchFocus(nwWidget.EDITOR)) self.aFocusEditor.triggered.connect(lambda: self.mainGui.switchFocus(nwWidget.EDITOR))
self.viewMenu.addAction(self.aFocusEditor) self.viewMenu.addAction(self.aFocusEditor)
# View > Document Pane 2 # View > Document Pane 2
@@ -342,7 +342,7 @@ class GuiMainMenu(QMenuBar):
self.aFocusView.setShortcut("Ctrl+Alt+3") self.aFocusView.setShortcut("Ctrl+Alt+3")
else: else:
self.aFocusView.setShortcut("Alt+3") self.aFocusView.setShortcut("Alt+3")
self.aFocusView.triggered.connect(lambda: self.theParent.switchFocus(nwWidget.VIEWER)) self.aFocusView.triggered.connect(lambda: self.mainGui.switchFocus(nwWidget.VIEWER))
self.viewMenu.addAction(self.aFocusView) self.viewMenu.addAction(self.aFocusView)
# View > Outline # View > Outline
@@ -351,7 +351,7 @@ class GuiMainMenu(QMenuBar):
self.aFocusOutline.setShortcut("Ctrl+Alt+4") self.aFocusOutline.setShortcut("Ctrl+Alt+4")
else: else:
self.aFocusOutline.setShortcut("Alt+4") self.aFocusOutline.setShortcut("Alt+4")
self.aFocusOutline.triggered.connect(lambda: self.theParent.switchFocus(nwWidget.OUTLINE)) self.aFocusOutline.triggered.connect(lambda: self.mainGui.switchFocus(nwWidget.OUTLINE))
self.viewMenu.addAction(self.aFocusOutline) self.viewMenu.addAction(self.aFocusOutline)
# View > Separator # View > Separator
@@ -360,13 +360,13 @@ class GuiMainMenu(QMenuBar):
# View > Go Backward # View > Go Backward
self.aViewPrev = QAction(self.tr("Navigate Backward"), self) self.aViewPrev = QAction(self.tr("Navigate Backward"), self)
self.aViewPrev.setShortcut("Alt+Left") self.aViewPrev.setShortcut("Alt+Left")
self.aViewPrev.triggered.connect(lambda: self.theParent.docViewer.navBackward()) self.aViewPrev.triggered.connect(lambda: self.mainGui.docViewer.navBackward())
self.viewMenu.addAction(self.aViewPrev) self.viewMenu.addAction(self.aViewPrev)
# View > Go Forward # View > Go Forward
self.aViewNext = QAction(self.tr("Navigate Forward"), self) self.aViewNext = QAction(self.tr("Navigate Forward"), self)
self.aViewNext.setShortcut("Alt+Right") self.aViewNext.setShortcut("Alt+Right")
self.aViewNext.triggered.connect(lambda: self.theParent.docViewer.navForward()) self.aViewNext.triggered.connect(lambda: self.mainGui.docViewer.navForward())
self.viewMenu.addAction(self.aViewNext) self.viewMenu.addAction(self.aViewNext)
# View > Separator # View > Separator
@@ -376,14 +376,14 @@ class GuiMainMenu(QMenuBar):
self.aFocusMode = QAction(self.tr("Focus Mode"), self) self.aFocusMode = QAction(self.tr("Focus Mode"), self)
self.aFocusMode.setShortcut("F8") self.aFocusMode.setShortcut("F8")
self.aFocusMode.setCheckable(True) self.aFocusMode.setCheckable(True)
self.aFocusMode.setChecked(self.theParent.isFocusMode) self.aFocusMode.setChecked(self.mainGui.isFocusMode)
self.aFocusMode.triggered.connect(lambda: self.theParent.toggleFocusMode()) self.aFocusMode.triggered.connect(lambda: self.mainGui.toggleFocusMode())
self.viewMenu.addAction(self.aFocusMode) self.viewMenu.addAction(self.aFocusMode)
# View > Toggle Full Screen # View > Toggle Full Screen
self.aFullScreen = QAction(self.tr("Full Screen Mode"), self) self.aFullScreen = QAction(self.tr("Full Screen Mode"), self)
self.aFullScreen.setShortcut("F11") self.aFullScreen.setShortcut("F11")
self.aFullScreen.triggered.connect(lambda: self.theParent.toggleFullScreenMode()) self.aFullScreen.triggered.connect(lambda: self.mainGui.toggleFullScreenMode())
self.viewMenu.addAction(self.aFullScreen) self.viewMenu.addAction(self.aFullScreen)
return return
@@ -588,7 +588,7 @@ class GuiMainMenu(QMenuBar):
# Insert > Placeholder Text # Insert > Placeholder Text
self.aLipsumText = QAction(self.tr("Placeholder Text"), self) self.aLipsumText = QAction(self.tr("Placeholder Text"), self)
self.aLipsumText.triggered.connect(lambda: self.theParent.showLoremIpsumDialog()) self.aLipsumText.triggered.connect(lambda: self.mainGui.showLoremIpsumDialog())
self.insertMenu.addAction(self.aLipsumText) self.insertMenu.addAction(self.aLipsumText)
return return
@@ -752,7 +752,7 @@ class GuiMainMenu(QMenuBar):
# Search > Find # Search > Find
self.aFind = QAction(self.tr("Find"), self) self.aFind = QAction(self.tr("Find"), self)
self.aFind.setShortcut("Ctrl+F") self.aFind.setShortcut("Ctrl+F")
self.aFind.triggered.connect(lambda: self.theParent.docEditor.beginSearch()) self.aFind.triggered.connect(lambda: self.mainGui.docEditor.beginSearch())
self.srcMenu.addAction(self.aFind) self.srcMenu.addAction(self.aFind)
# Search > Replace # Search > Replace
@@ -761,7 +761,7 @@ class GuiMainMenu(QMenuBar):
self.aReplace.setShortcut("Ctrl+=") self.aReplace.setShortcut("Ctrl+=")
else: else:
self.aReplace.setShortcut("Ctrl+H") self.aReplace.setShortcut("Ctrl+H")
self.aReplace.triggered.connect(lambda: self.theParent.docEditor.beginReplace()) self.aReplace.triggered.connect(lambda: self.mainGui.docEditor.beginReplace())
self.srcMenu.addAction(self.aReplace) self.srcMenu.addAction(self.aReplace)
# Search > Find Next # Search > Find Next
@@ -770,7 +770,7 @@ class GuiMainMenu(QMenuBar):
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"])
self.aFindNext.triggered.connect(lambda: self.theParent.docEditor.findNext()) self.aFindNext.triggered.connect(lambda: self.mainGui.docEditor.findNext())
self.srcMenu.addAction(self.aFindNext) self.srcMenu.addAction(self.aFindNext)
# Search > Find Prev # Search > Find Prev
@@ -779,13 +779,13 @@ class GuiMainMenu(QMenuBar):
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"])
self.aFindPrev.triggered.connect(lambda: self.theParent.docEditor.findNext(goBack=True)) self.aFindPrev.triggered.connect(lambda: self.mainGui.docEditor.findNext(goBack=True))
self.srcMenu.addAction(self.aFindPrev) self.srcMenu.addAction(self.aFindPrev)
# Search > Replace Next # Search > Replace Next
self.aReplaceNext = QAction(self.tr("Replace Next"), self) self.aReplaceNext = QAction(self.tr("Replace Next"), self)
self.aReplaceNext.setShortcut("Ctrl+Shift+1") self.aReplaceNext.setShortcut("Ctrl+Shift+1")
self.aReplaceNext.triggered.connect(lambda: self.theParent.docEditor.replaceNext()) self.aReplaceNext.triggered.connect(lambda: self.mainGui.docEditor.replaceNext())
self.srcMenu.addAction(self.aReplaceNext) self.srcMenu.addAction(self.aReplaceNext)
return return
@@ -807,12 +807,12 @@ class GuiMainMenu(QMenuBar):
# Tools > Re-Run Spell Check # Tools > Re-Run Spell Check
self.aReRunSpell = QAction(self.tr("Re-Run Spell Check"), self) self.aReRunSpell = QAction(self.tr("Re-Run Spell Check"), self)
self.aReRunSpell.setShortcut("F7") self.aReRunSpell.setShortcut("F7")
self.aReRunSpell.triggered.connect(lambda: self.theParent.docEditor.spellCheckDocument()) self.aReRunSpell.triggered.connect(lambda: self.mainGui.docEditor.spellCheckDocument())
self.toolsMenu.addAction(self.aReRunSpell) self.toolsMenu.addAction(self.aReRunSpell)
# Tools > Project Word List # Tools > Project Word List
self.aEditWordList = QAction(self.tr("Project Word List"), self) self.aEditWordList = QAction(self.tr("Project Word List"), self)
self.aEditWordList.triggered.connect(lambda: self.theParent.showProjectWordListDialog()) self.aEditWordList.triggered.connect(lambda: self.mainGui.showProjectWordListDialog())
self.toolsMenu.addAction(self.aEditWordList) self.toolsMenu.addAction(self.aEditWordList)
# Tools > Separator # Tools > Separator
@@ -821,7 +821,7 @@ class GuiMainMenu(QMenuBar):
# Tools > Rebuild Indices # Tools > Rebuild Indices
self.aRebuildIndex = QAction(self.tr("Rebuild Index"), self) self.aRebuildIndex = QAction(self.tr("Rebuild Index"), self)
self.aRebuildIndex.setShortcut("F9") self.aRebuildIndex.setShortcut("F9")
self.aRebuildIndex.triggered.connect(lambda: self.theParent.rebuildIndex()) self.aRebuildIndex.triggered.connect(lambda: self.mainGui.rebuildIndex())
self.toolsMenu.addAction(self.aRebuildIndex) self.toolsMenu.addAction(self.aRebuildIndex)
# Tools > Separator # Tools > Separator
@@ -835,20 +835,20 @@ class GuiMainMenu(QMenuBar):
# Tools > Export Project # Tools > Export Project
self.aBuildProject = QAction(self.tr("Build Novel Project"), self) self.aBuildProject = QAction(self.tr("Build Novel Project"), self)
self.aBuildProject.setShortcut("F5") self.aBuildProject.setShortcut("F5")
self.aBuildProject.triggered.connect(lambda: self.theParent.showBuildProjectDialog()) self.aBuildProject.triggered.connect(lambda: self.mainGui.showBuildProjectDialog())
self.toolsMenu.addAction(self.aBuildProject) self.toolsMenu.addAction(self.aBuildProject)
# Tools > Writing Stats # Tools > Writing Stats
self.aWritingStats = QAction(self.tr("Writing Statistics"), self) self.aWritingStats = QAction(self.tr("Writing Statistics"), self)
self.aWritingStats.setShortcut("F6") self.aWritingStats.setShortcut("F6")
self.aWritingStats.triggered.connect(lambda: self.theParent.showWritingStatsDialog()) self.aWritingStats.triggered.connect(lambda: self.mainGui.showWritingStatsDialog())
self.toolsMenu.addAction(self.aWritingStats) self.toolsMenu.addAction(self.aWritingStats)
# Tools > Settings # Tools > Settings
self.aPreferences = QAction(self.tr("Preferences"), self) self.aPreferences = QAction(self.tr("Preferences"), self)
self.aPreferences.setShortcut("Ctrl+,") self.aPreferences.setShortcut("Ctrl+,")
self.aPreferences.setMenuRole(QAction.PreferencesRole) self.aPreferences.setMenuRole(QAction.PreferencesRole)
self.aPreferences.triggered.connect(lambda: self.theParent.showPreferencesDialog()) self.aPreferences.triggered.connect(lambda: self.mainGui.showPreferencesDialog())
self.toolsMenu.addAction(self.aPreferences) self.toolsMenu.addAction(self.aPreferences)
return return
@@ -862,13 +862,13 @@ class GuiMainMenu(QMenuBar):
# Help > About # Help > About
self.aAboutNW = QAction(self.tr("About novelWriter"), self) self.aAboutNW = QAction(self.tr("About novelWriter"), self)
self.aAboutNW.setMenuRole(QAction.AboutRole) self.aAboutNW.setMenuRole(QAction.AboutRole)
self.aAboutNW.triggered.connect(lambda: self.theParent.showAboutNWDialog()) self.aAboutNW.triggered.connect(lambda: self.mainGui.showAboutNWDialog())
self.helpMenu.addAction(self.aAboutNW) self.helpMenu.addAction(self.aAboutNW)
# Help > About Qt5 # Help > About Qt5
self.aAboutQt = QAction(self.tr("About Qt5"), self) self.aAboutQt = QAction(self.tr("About Qt5"), self)
self.aAboutQt.setMenuRole(QAction.AboutQtRole) self.aAboutQt.setMenuRole(QAction.AboutQtRole)
self.aAboutQt.triggered.connect(lambda: self.theParent.showAboutQtDialog()) self.aAboutQt.triggered.connect(lambda: self.mainGui.showAboutQtDialog())
self.helpMenu.addAction(self.aAboutQt) self.helpMenu.addAction(self.aAboutQt)
# Help > Separator # Help > Separator
@@ -915,7 +915,7 @@ class GuiMainMenu(QMenuBar):
# Document > Check for Updates # Document > Check for Updates
self.aUpdates = QAction(self.tr("Check for New Release"), self) self.aUpdates = QAction(self.tr("Check for New Release"), self)
self.aUpdates.triggered.connect(lambda: self.theParent.showUpdatesDialog()) self.aUpdates.triggered.connect(lambda: self.mainGui.showUpdatesDialog())
self.helpMenu.addAction(self.aUpdates) self.helpMenu.addAction(self.aUpdates)
return return
+9 -9
View File
@@ -45,15 +45,15 @@ class GuiNovelTree(QTreeWidget):
C_WORDS = 1 C_WORDS = 1
C_POV = 2 C_POV = 2
def __init__(self, theParent): def __init__(self, mainGui):
QTreeWidget.__init__(self, theParent) QTreeWidget.__init__(self, mainGui)
logger.debug("Initialising GuiNovelTree ...") logger.debug("Initialising GuiNovelTree ...")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.theProject = theParent.theProject self.theProject = mainGui.theProject
# Internal Variables # Internal Variables
self._treeMap = {} self._treeMap = {}
@@ -135,7 +135,7 @@ class GuiNovelTree(QTreeWidget):
"""Called whenever the Novel tab is activated. """Called whenever the Novel tab is activated.
""" """
logger.verbose("Requesting refresh of the novel tree") logger.verbose("Requesting refresh of the novel tree")
treeChanged = self.theParent.treeView.changedSince(self._lastBuild) treeChanged = self.mainGui.treeView.changedSince(self._lastBuild)
indexChanged = self.theProject.index.indexChangedSince(self._lastBuild) indexChanged = self.theProject.index.indexChangedSince(self._lastBuild)
if not (treeChanged or indexChanged or overRide): if not (treeChanged or indexChanged or overRide):
logger.verbose("No changes have been made to the novel index") logger.verbose("No changes have been made to the novel index")
@@ -209,7 +209,7 @@ class GuiNovelTree(QTreeWidget):
if tHandle is None: if tHandle is None:
return return
self.theParent.viewDocument(tHandle) self.mainGui.viewDocument(tHandle)
return return
@@ -223,7 +223,7 @@ class GuiNovelTree(QTreeWidget):
document editor. document editor.
""" """
tHandle, tLine = self.getSelectedHandle() tHandle, tLine = self.getSelectedHandle()
self.theParent.openDocument(tHandle, tLine=tLine-1, doScroll=True) self.mainGui.openDocument(tHandle, tLine=tLine-1, doScroll=True)
return return
def _itemSelected(self): def _itemSelected(self):
@@ -233,7 +233,7 @@ class GuiNovelTree(QTreeWidget):
selItems = self.selectedItems() selItems = self.selectedItems()
if selItems: if selItems:
tHandle = selItems[0].data(self.C_TITLE, Qt.UserRole)[0] tHandle = selItems[0].data(self.C_TITLE, Qt.UserRole)[0]
self.theParent.treeMeta.updateViewBox(tHandle) self.mainGui.treeMeta.updateViewBox(tHandle)
return return
+14 -14
View File
@@ -56,11 +56,11 @@ class GuiOutline(QWidget):
loadDocumentTagRequest = pyqtSignal(str, Enum) loadDocumentTagRequest = pyqtSignal(str, Enum)
def __init__(self, theParent): def __init__(self, mainGui):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
# Build GUI # Build GUI
self.outlineBar = GuiOutlineToolBar(self) self.outlineBar = GuiOutlineToolBar(self)
@@ -177,9 +177,9 @@ class GuiOutlineToolBar(QToolBar):
logger.debug("Initialising GuiOutlineToolBar ...") logger.debug("Initialising GuiOutlineToolBar ...")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theOutline.theParent self.mainGui = theOutline.mainGui
self.theProject = theOutline.theParent.theProject self.theProject = theOutline.mainGui.theProject
self.theTheme = theOutline.theParent.theTheme self.theTheme = theOutline.mainGui.theTheme
iPx = self.mainConf.pxInt(22) iPx = self.mainConf.pxInt(22)
mPx = self.mainConf.pxInt(12) mPx = self.mainConf.pxInt(12)
@@ -322,9 +322,9 @@ class GuiOutlineView(QTreeWidget):
logger.debug("Initialising GuiOutlineView ...") logger.debug("Initialising GuiOutlineView ...")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theOutline.theParent self.mainGui = theOutline.mainGui
self.theProject = theOutline.theParent.theProject self.theProject = theOutline.mainGui.theProject
self.theTheme = theOutline.theParent.theTheme self.theTheme = theOutline.mainGui.theTheme
self.setFrameStyle(QFrame.NoFrame) self.setFrameStyle(QFrame.NoFrame)
self.setSelectionBehavior(QAbstractItemView.SelectRows) self.setSelectionBehavior(QAbstractItemView.SelectRows)
@@ -464,7 +464,7 @@ class GuiOutlineView(QTreeWidget):
document editor. document editor.
""" """
tHandle, tLine = self.getSelectedHandle() tHandle, tLine = self.getSelectedHandle()
self.theParent.openDocument(tHandle, tLine=tLine - 1, doScroll=True) self.mainGui.openDocument(tHandle, tLine=tLine - 1, doScroll=True)
return return
@pyqtSlot() @pyqtSlot()
@@ -782,9 +782,9 @@ class GuiOutlineDetails(QScrollArea):
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theOutline = theOutline self.theOutline = theOutline
self.theParent = theOutline.theParent self.mainGui = theOutline.mainGui
self.theProject = theOutline.theParent.theProject self.theProject = theOutline.mainGui.theProject
self.theTheme = theOutline.theParent.theTheme self.theTheme = theOutline.mainGui.theTheme
# Sizes # Sizes
minTitle = 30*self.theTheme.textNWidth minTitle = 30*self.theTheme.textNWidth
+24 -24
View File
@@ -63,10 +63,10 @@ class GuiProjectView(QWidget):
selectedItemChanged = pyqtSignal(str) selectedItemChanged = pyqtSignal(str)
openDocumentRequest = pyqtSignal(str, Enum) openDocumentRequest = pyqtSignal(str, Enum)
def __init__(self, theParent): def __init__(self, mainGui):
QWidget.__init__(self, theParent) QWidget.__init__(self, mainGui)
self.theParent = theParent self.mainGui = mainGui
# Build GUI # Build GUI
self.projTree = GuiProjectTree(self) self.projTree = GuiProjectTree(self)
@@ -167,9 +167,9 @@ class GuiProjectToolBar(QWidget):
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.projView = projView self.projView = projView
self.projTree = projView.projTree self.projTree = projView.projTree
self.theParent = projView.theParent self.mainGui = projView.mainGui
self.theProject = projView.theParent.theProject self.theProject = projView.mainGui.theProject
self.theTheme = projView.theParent.theTheme self.theTheme = projView.mainGui.theTheme
iPx = self.theTheme.baseIconSize iPx = self.theTheme.baseIconSize
mPx = self.mainConf.pxInt(4) mPx = self.mainConf.pxInt(4)
@@ -323,9 +323,9 @@ class GuiProjectTree(QTreeWidget):
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.projView = projView self.projView = projView
self.theParent = projView.theParent self.mainGui = projView.mainGui
self.theTheme = projView.theParent.theTheme self.theTheme = projView.mainGui.theTheme
self.theProject = projView.theParent.theProject self.theProject = projView.mainGui.theProject
# Internal Variables # Internal Variables
self._treeMap = {} self._treeMap = {}
@@ -420,7 +420,7 @@ class GuiProjectTree(QTreeWidget):
make sure the item is added in a place it can be added, and that make sure the item is added in a place it can be added, and that
other meta data is set correctly to ensure a valid project tree. other meta data is set correctly to ensure a valid project tree.
""" """
if not self.theParent.hasProject: if not self.mainGui.hasProject:
logger.error("No project open") logger.error("No project open")
return False return False
@@ -435,7 +435,7 @@ class GuiProjectTree(QTreeWidget):
sHandle = self.getSelectedHandle() sHandle = self.getSelectedHandle()
if sHandle is None or sHandle not in self.theProject.tree: if sHandle is None or sHandle not in self.theProject.tree:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Did not find anywhere to add the file or folder!" "Did not find anywhere to add the file or folder!"
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
@@ -452,7 +452,7 @@ class GuiProjectTree(QTreeWidget):
return False return False
if self.theProject.tree.isTrash(sHandle): if self.theProject.tree.isTrash(sHandle):
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Cannot add new files or folders to the Trash folder." "Cannot add new files or folders to the Trash folder."
), nwAlert.ERROR) ), nwAlert.ERROR)
return False return False
@@ -611,7 +611,7 @@ class GuiProjectTree(QTreeWidget):
function only asks for confirmation once, and calls the regular function only asks for confirmation once, and calls the regular
deleteItem function for each document in the Trash folder. deleteItem function for each document in the Trash folder.
""" """
if not self.theParent.hasProject: if not self.mainGui.hasProject:
logger.error("No project open") logger.error("No project open")
return False return False
@@ -619,7 +619,7 @@ class GuiProjectTree(QTreeWidget):
logger.debug("Emptying Trash folder") logger.debug("Emptying Trash folder")
if trashHandle is None: if trashHandle is None:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"There is currently no Trash folder in this project." "There is currently no Trash folder in this project."
), nwAlert.INFO) ), nwAlert.INFO)
return False return False
@@ -630,12 +630,12 @@ class GuiProjectTree(QTreeWidget):
nTrash = len(theTrash) nTrash = len(theTrash)
if nTrash == 0: if nTrash == 0:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"The Trash folder is already empty." "The Trash folder is already empty."
), nwAlert.INFO) ), nwAlert.INFO)
return False return False
msgYes = self.theParent.askQuestion( msgYes = self.mainGui.askQuestion(
self.tr("Empty Trash"), self.tr("Empty Trash"),
self.tr("Permanently delete {0} file(s) from Trash?").format(nTrash) self.tr("Permanently delete {0} file(s) from Trash?").format(nTrash)
) )
@@ -660,7 +660,7 @@ class GuiProjectTree(QTreeWidget):
delete the files on disk. Root folders are deleted if they're empty delete the files on disk. Root folders are deleted if they're empty
only, and the deletion is always permanent. only, and the deletion is always permanent.
""" """
if not self.theParent.hasProject: if not self.mainGui.hasProject:
logger.error("No project open") logger.error("No project open")
return False return False
@@ -693,7 +693,7 @@ class GuiProjectTree(QTreeWidget):
self._deleteTreeItem(tHandle) self._deleteTreeItem(tHandle)
self._alertTreeChange(tHandle=tHandle, flush=True) self._alertTreeChange(tHandle=tHandle, flush=True)
else: else:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Cannot delete root folder. It is not empty. " "Cannot delete root folder. It is not empty. "
"Recursive deletion is not supported. " "Recursive deletion is not supported. "
"Please delete the content first." "Please delete the content first."
@@ -723,7 +723,7 @@ class GuiProjectTree(QTreeWidget):
# user if they want to permanently delete the file. # user if they want to permanently delete the file.
doPermanent = False doPermanent = False
if not alreadyAsked: if not alreadyAsked:
msgYes = self.theParent.askQuestion( msgYes = self.mainGui.askQuestion(
self.tr("Delete"), self.tr("Delete"),
self.tr("Permanently delete '{0}'?").format(nwItemS.itemName) self.tr("Permanently delete '{0}'?").format(nwItemS.itemName)
) )
@@ -739,8 +739,8 @@ class GuiProjectTree(QTreeWidget):
tIndex = trItemP.indexOfChild(trItemS) tIndex = trItemP.indexOfChild(trItemS)
trItemC = trItemP.takeChild(tIndex) trItemC = trItemP.takeChild(tIndex)
for dHandle in reversed(self.getTreeFromHandle(tHandle)): for dHandle in reversed(self.getTreeFromHandle(tHandle)):
if self.theParent.docEditor.docHandle() == dHandle: if self.mainGui.docEditor.docHandle() == dHandle:
self.theParent.closeDocument() self.mainGui.closeDocument()
self._deleteTreeItem(dHandle) self._deleteTreeItem(dHandle)
self._alertTreeChange(tHandle=tHandle, flush=autoFlush) self._alertTreeChange(tHandle=tHandle, flush=autoFlush)
@@ -749,7 +749,7 @@ class GuiProjectTree(QTreeWidget):
else: else:
# The item is not already in the trash folder, so we # The item is not already in the trash folder, so we
# move it there. # move it there.
msgYes = self.theParent.askQuestion( msgYes = self.mainGui.askQuestion(
self.tr("Delete"), self.tr("Delete"),
self.tr("Move '{0}' to Trash?").format(nwItemS.itemName), self.tr("Move '{0}' to Trash?").format(nwItemS.itemName),
) )
@@ -1199,7 +1199,7 @@ class GuiProjectTree(QTreeWidget):
if self.theProject.tree.checkType(tHandle, nwItemType.FILE): if self.theProject.tree.checkType(tHandle, nwItemType.FILE):
delDoc = NWDoc(self.theProject, tHandle) delDoc = NWDoc(self.theProject, tHandle)
if not delDoc.deleteDocument(): if not delDoc.deleteDocument():
self.theParent.makeAlert([ self.mainGui.makeAlert([
self.tr("Could not delete document file."), delDoc.getError() self.tr("Could not delete document file."), delDoc.getError()
], nwAlert.ERROR) ], nwAlert.ERROR)
return False return False
@@ -1295,7 +1295,7 @@ class GuiProjectTree(QTreeWidget):
newItem.setFlags(newItem.flags() ^ Qt.ItemIsDragEnabled) newItem.setFlags(newItem.flags() ^ Qt.ItemIsDragEnabled)
self.addTopLevelItem(newItem) self.addTopLevelItem(newItem)
else: else:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"There is nowhere to add item with name '{0}'." "There is nowhere to add item with name '{0}'."
).format(nwItem.itemName), nwAlert.ERROR) ).format(nwItem.itemName), nwAlert.ERROR)
del self._treeMap[tHandle] del self._treeMap[tHandle]
+4 -4
View File
@@ -41,14 +41,14 @@ logger = logging.getLogger(__name__)
class GuiMainStatus(QStatusBar): class GuiMainStatus(QStatusBar):
def __init__(self, theParent): def __init__(self, mainGui):
QStatusBar.__init__(self, theParent) QStatusBar.__init__(self, mainGui)
logger.debug("Initialising GuiMainStatus ...") logger.debug("Initialising GuiMainStatus ...")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.refTime = None self.refTime = None
self.userIdle = False self.userIdle = False
+10 -10
View File
@@ -40,14 +40,14 @@ class GuiViewsBar(QToolBar):
viewChangeRequested = pyqtSignal(nwView) viewChangeRequested = pyqtSignal(nwView)
def __init__(self, theParent): def __init__(self, mainGui):
QToolBar.__init__(self, theParent) QToolBar.__init__(self, mainGui)
logger.debug("Initialising GuiViewsBar ...") logger.debug("Initialising GuiViewsBar ...")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
# Style # Style
iPx = self.mainConf.pxInt(22) iPx = self.mainConf.pxInt(22)
@@ -89,29 +89,29 @@ class GuiViewsBar(QToolBar):
self.aBuild.setFont(lblFont) self.aBuild.setFont(lblFont)
self.aBuild.setToolTip(self.tr("Build novel project")) self.aBuild.setToolTip(self.tr("Build novel project"))
self.aBuild.setIcon(self.theTheme.getIcon("view_build")) self.aBuild.setIcon(self.theTheme.getIcon("view_build"))
self.aBuild.triggered.connect(lambda: self.theParent.showBuildProjectDialog()) self.aBuild.triggered.connect(lambda: self.mainGui.showBuildProjectDialog())
self.aDetails = QAction(self.tr("Details")) self.aDetails = QAction(self.tr("Details"))
self.aDetails.setFont(lblFont) self.aDetails.setFont(lblFont)
self.aDetails.setToolTip(self.tr("Show project details")) self.aDetails.setToolTip(self.tr("Show project details"))
self.aDetails.setIcon(self.theTheme.getIcon("proj_details")) self.aDetails.setIcon(self.theTheme.getIcon("proj_details"))
self.aDetails.triggered.connect(lambda: self.theParent.showProjectDetailsDialog()) self.aDetails.triggered.connect(lambda: self.mainGui.showProjectDetailsDialog())
self.aStats = QAction(self.tr("Stats")) self.aStats = QAction(self.tr("Stats"))
self.aStats.setFont(lblFont) self.aStats.setFont(lblFont)
self.aStats.setToolTip(self.tr("Show project statistics")) self.aStats.setToolTip(self.tr("Show project statistics"))
self.aStats.setIcon(self.theTheme.getIcon("proj_stats")) self.aStats.setIcon(self.theTheme.getIcon("proj_stats"))
self.aStats.triggered.connect(lambda: self.theParent.showWritingStatsDialog()) self.aStats.triggered.connect(lambda: self.mainGui.showWritingStatsDialog())
# Settings Menu # Settings Menu
self.mSettings = QMenu() self.mSettings = QMenu()
self.aPrjSettings = QAction(self.tr("Project Settings")) self.aPrjSettings = QAction(self.tr("Project Settings"))
self.aPrjSettings.triggered.connect(lambda: self.theParent.showProjectSettingsDialog()) self.aPrjSettings.triggered.connect(lambda: self.mainGui.showProjectSettingsDialog())
self.mSettings.addAction(self.aPrjSettings) self.mSettings.addAction(self.aPrjSettings)
self.aPreferences = QAction(self.tr("Preferences")) self.aPreferences = QAction(self.tr("Preferences"))
self.aPreferences.triggered.connect(lambda: self.theParent.showPreferencesDialog()) self.aPreferences.triggered.connect(lambda: self.mainGui.showPreferencesDialog())
self.mSettings.addAction(self.aPreferences) self.mSettings.addAction(self.aPreferences)
self.tbSettings = QToolButton(self) self.tbSettings = QToolButton(self)
+14 -14
View File
@@ -65,16 +65,16 @@ class GuiBuildNovel(QDialog):
FMT_JSON_H = 8 # HTML5 wrapped in JSON FMT_JSON_H = 8 # HTML5 wrapped in JSON
FMT_JSON_M = 9 # nW Markdown wrapped in JSON FMT_JSON_M = 9 # nW Markdown wrapped in JSON
def __init__(self, theParent): def __init__(self, mainGui):
QDialog.__init__(self, theParent) QDialog.__init__(self, mainGui)
logger.debug("Initialising GuiBuildNovel ...") logger.debug("Initialising GuiBuildNovel ...")
self.setObjectName("GuiBuildNovel") self.setObjectName("GuiBuildNovel")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.theProject = theParent.theProject self.theProject = mainGui.theProject
self.htmlText = [] # List of html documents self.htmlText = [] # List of html documents
self.htmlStyle = [] # List of html styles self.htmlStyle = [] # List of html styles
@@ -711,7 +711,7 @@ class GuiBuildNovel(QDialog):
bldObj.initDocument() bldObj.initDocument()
# Make sure the project and document is up to date # Make sure the project and document is up to date
self.theParent.saveDocument() self.mainGui.saveDocument()
self.buildProgress.setMaximum(len(self.theProject.tree)) self.buildProgress.setMaximum(len(self.theProject.tree))
self.buildProgress.setValue(0) self.buildProgress.setValue(0)
@@ -760,7 +760,7 @@ class GuiBuildNovel(QDialog):
logger.debug("Built project in %.3f ms", 1000*(tEnd - tStart)) logger.debug("Built project in %.3f ms", 1000*(tEnd - tStart))
if bldObj.errData: if bldObj.errData:
self.theParent.makeAlert([ self.mainGui.makeAlert([
self.tr("There were problems when building the project:") self.tr("There were problems when building the project:")
] + bldObj.errData, nwAlert.ERROR) ] + bldObj.errData, nwAlert.ERROR)
@@ -1003,11 +1003,11 @@ class GuiBuildNovel(QDialog):
# ============== # ==============
if wSuccess: if wSuccess:
self.theParent.makeAlert([ self.mainGui.makeAlert([
self.tr("{0} file successfully written to:").format(textFmt), savePath self.tr("{0} file successfully written to:").format(textFmt), savePath
], nwAlert.INFO) ], nwAlert.INFO)
else: else:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Failed to write {0} file. {1}" "Failed to write {0} file. {1}"
).format(textFmt, errMsg), nwAlert.ERROR) ).format(textFmt, errMsg), nwAlert.ERROR)
@@ -1193,18 +1193,18 @@ class GuiBuildNovel(QDialog):
class GuiBuildNovelDocView(QTextBrowser): class GuiBuildNovelDocView(QTextBrowser):
def __init__(self, theParent, theProject): def __init__(self, mainGui, theProject):
QTextBrowser.__init__(self, theParent) QTextBrowser.__init__(self, mainGui)
logger.debug("Initialising GuiBuildNovelDocView ...") logger.debug("Initialising GuiBuildNovelDocView ...")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theProject = theProject self.theProject = theProject
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.buildTime = 0 self.buildTime = 0
self.setMinimumWidth(40*self.theParent.theTheme.textNWidth) self.setMinimumWidth(40*self.mainGui.theTheme.textNWidth)
self.setOpenExternalLinks(False) self.setOpenExternalLinks(False)
self.document().setDocumentMargin(self.mainConf.getTextMargin()) self.document().setDocumentMargin(self.mainConf.getTextMargin())
+7 -7
View File
@@ -42,15 +42,15 @@ logger = logging.getLogger(__name__)
class GuiLipsum(QDialog): class GuiLipsum(QDialog):
def __init__(self, theParent): def __init__(self, mainGui):
QDialog.__init__(self, theParent) QDialog.__init__(self, mainGui)
logger.debug("Initialising GuiLipsum ...") logger.debug("Initialising GuiLipsum ...")
self.setObjectName("GuiLipsum") self.setObjectName("GuiLipsum")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.setWindowTitle(self.tr("Insert Placeholder Text")) self.setWindowTitle(self.tr("Insert Placeholder Text"))
@@ -61,7 +61,7 @@ class GuiLipsum(QDialog):
nPx = self.mainConf.pxInt(64) nPx = self.mainConf.pxInt(64)
vSp = self.mainConf.pxInt(4) vSp = self.mainConf.pxInt(4)
self.docIcon = QLabel() self.docIcon = QLabel()
self.docIcon.setPixmap(self.theParent.theTheme.getPixmap("proj_document", (nPx, nPx))) self.docIcon.setPixmap(self.mainGui.theTheme.getPixmap("proj_document", (nPx, nPx)))
self.leftBox = QVBoxLayout() self.leftBox = QVBoxLayout()
self.leftBox.setSpacing(vSp) self.leftBox.setSpacing(vSp)
@@ -129,7 +129,7 @@ class GuiLipsum(QDialog):
pCount = self.paraCount.value() pCount = self.paraCount.value()
inText = "\n\n".join(lipsumText[0:pCount]) + "\n\n" inText = "\n\n".join(lipsumText[0:pCount]) + "\n\n"
self.theParent.docEditor.insertText(inText) self.mainGui.docEditor.insertText(inText)
return return
+5 -5
View File
@@ -48,15 +48,15 @@ PAGE_FINAL = 4
class GuiProjectWizard(QWizard): class GuiProjectWizard(QWizard):
def __init__(self, theParent): def __init__(self, mainGui):
QWizard.__init__(self, theParent) QWizard.__init__(self, mainGui)
logger.debug("Initialising GuiProjectWizard ...") logger.debug("Initialising GuiProjectWizard ...")
self.setObjectName("GuiProjectWizard") self.setObjectName("GuiProjectWizard")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.sideImage = self.theTheme.loadDecoration( self.sideImage = self.theTheme.loadDecoration(
"wiz-back", None, self.mainConf.pxInt(370) "wiz-back", None, self.mainConf.pxInt(370)
+8 -8
View File
@@ -57,16 +57,16 @@ class GuiWritingStats(QDialog):
FMT_JSON = 0 FMT_JSON = 0
FMT_CSV = 1 FMT_CSV = 1
def __init__(self, theParent): def __init__(self, mainGui):
QDialog.__init__(self, theParent) QDialog.__init__(self, mainGui)
logger.debug("Initialising GuiWritingStats ...") logger.debug("Initialising GuiWritingStats ...")
self.setObjectName("GuiWritingStats") self.setObjectName("GuiWritingStats")
self.mainConf = novelwriter.CONFIG self.mainConf = novelwriter.CONFIG
self.theParent = theParent self.mainGui = mainGui
self.theTheme = theParent.theTheme self.theTheme = mainGui.theTheme
self.theProject = theParent.theProject self.theProject = mainGui.theProject
self.logData = [] self.logData = []
self.filterData = [] self.filterData = []
@@ -411,11 +411,11 @@ class GuiWritingStats(QDialog):
# Report to user # Report to user
if wSuccess: if wSuccess:
self.theParent.makeAlert([ self.mainGui.makeAlert([
self.tr("{0} file successfully written to:").format(textFmt), savePath self.tr("{0} file successfully written to:").format(textFmt), savePath
], nwAlert.INFO) ], nwAlert.INFO)
else: else:
self.theParent.makeAlert([ self.mainGui.makeAlert([
self.tr("Failed to write {0} file.").format(textFmt), errMsg self.tr("Failed to write {0} file.").format(textFmt), errMsg
], nwAlert.ERROR) ], nwAlert.ERROR)
@@ -478,7 +478,7 @@ class GuiWritingStats(QDialog):
self.logData.append((dStart, sDiff, wcNovel, wcNotes, sIdle)) self.logData.append((dStart, sDiff, wcNovel, wcNotes, sIdle))
except Exception as exc: except Exception as exc:
self.theParent.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Failed to read session log file." "Failed to read session log file."
), nwAlert.ERROR, exception=exc) ), nwAlert.ERROR, exception=exc)
return False return False